-rw-r--r-- | korganizer/mainwindow.cpp | 98 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 2 |
2 files changed, 29 insertions, 71 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index bce2a54..fe7e6d3 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -747,467 +747,466 @@ void MainWindow::initActions() | |||
747 | 747 | ||
748 | 748 | ||
749 | iconToolBar->setHorizontalStretchable (true ); | 749 | iconToolBar->setHorizontalStretchable (true ); |
750 | //menuBar->insertItem( iconToolBar ); | 750 | //menuBar->insertItem( iconToolBar ); |
751 | //xdays_action | 751 | //xdays_action |
752 | if (p-> mShowIconNewEvent) | 752 | if (p-> mShowIconNewEvent) |
753 | ne_action->addTo( iconToolBar ); | 753 | ne_action->addTo( iconToolBar ); |
754 | if (p->mShowIconNewTodo ) | 754 | if (p->mShowIconNewTodo ) |
755 | nt_action->addTo( iconToolBar ); | 755 | nt_action->addTo( iconToolBar ); |
756 | if (p-> mShowIconSearch) | 756 | if (p-> mShowIconSearch) |
757 | search_action->addTo( iconToolBar ); | 757 | search_action->addTo( iconToolBar ); |
758 | if (p-> mShowIconNext) | 758 | if (p-> mShowIconNext) |
759 | whatsnext_action->addTo( iconToolBar ); | 759 | whatsnext_action->addTo( iconToolBar ); |
760 | if (p-> mShowIconNextDays) | 760 | if (p-> mShowIconNextDays) |
761 | xdays_action->addTo( iconToolBar ); | 761 | xdays_action->addTo( iconToolBar ); |
762 | if (p-> mShowIconList) | 762 | if (p-> mShowIconList) |
763 | showlist_action->addTo( iconToolBar ); | 763 | showlist_action->addTo( iconToolBar ); |
764 | if (p-> mShowIconDay1) | 764 | if (p-> mShowIconDay1) |
765 | day1_action->addTo( iconToolBar ); | 765 | day1_action->addTo( iconToolBar ); |
766 | if (p-> mShowIconDay5) | 766 | if (p-> mShowIconDay5) |
767 | day5_action->addTo( iconToolBar ); | 767 | day5_action->addTo( iconToolBar ); |
768 | if (p-> mShowIconDay7) | 768 | if (p-> mShowIconDay7) |
769 | day7_action->addTo( iconToolBar ); | 769 | day7_action->addTo( iconToolBar ); |
770 | if (p-> mShowIconMonth) | 770 | if (p-> mShowIconMonth) |
771 | month_action->addTo( iconToolBar ); | 771 | month_action->addTo( iconToolBar ); |
772 | if (p-> mShowIconTodoview) | 772 | if (p-> mShowIconTodoview) |
773 | todoview_action->addTo( iconToolBar ); | 773 | todoview_action->addTo( iconToolBar ); |
774 | if (p-> mShowIconJournal) | 774 | if (p-> mShowIconJournal) |
775 | viewjournal_action->addTo( iconToolBar ); | 775 | viewjournal_action->addTo( iconToolBar ); |
776 | icon = loadPixmap( pathString + "2leftarrowB" ); | 776 | icon = loadPixmap( pathString + "2leftarrowB" ); |
777 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 777 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
778 | if (p-> mShowIconBackFast) { | 778 | if (p-> mShowIconBackFast) { |
779 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 779 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
780 | connect( action, SIGNAL( activated() ), | 780 | connect( action, SIGNAL( activated() ), |
781 | mView, SLOT( goPreviousMonth() ) ); | 781 | mView, SLOT( goPreviousMonth() ) ); |
782 | action->addTo( iconToolBar ); | 782 | action->addTo( iconToolBar ); |
783 | } | 783 | } |
784 | icon = loadPixmap( pathString + "1leftarrowB" ); | 784 | icon = loadPixmap( pathString + "1leftarrowB" ); |
785 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 785 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
786 | if (p-> mShowIconBack) { | 786 | if (p-> mShowIconBack) { |
787 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 787 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
788 | connect( action, SIGNAL( activated() ), | 788 | connect( action, SIGNAL( activated() ), |
789 | mView, SLOT( goPrevious() ) ); | 789 | mView, SLOT( goPrevious() ) ); |
790 | action->addTo( iconToolBar ); | 790 | action->addTo( iconToolBar ); |
791 | } | 791 | } |
792 | if (p-> mShowIconToday) | 792 | if (p-> mShowIconToday) |
793 | today_action->addTo( iconToolBar ); | 793 | today_action->addTo( iconToolBar ); |
794 | icon = loadPixmap( pathString + "1rightarrowB" ); | 794 | icon = loadPixmap( pathString + "1rightarrowB" ); |
795 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 795 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
796 | if (p-> mShowIconForward) { | 796 | if (p-> mShowIconForward) { |
797 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 797 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
798 | connect( action, SIGNAL( activated() ), | 798 | connect( action, SIGNAL( activated() ), |
799 | mView, SLOT( goNext() ) ); | 799 | mView, SLOT( goNext() ) ); |
800 | action->addTo( iconToolBar ); | 800 | action->addTo( iconToolBar ); |
801 | } | 801 | } |
802 | icon = loadPixmap( pathString + "2rightarrowB" ); | 802 | icon = loadPixmap( pathString + "2rightarrowB" ); |
803 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 803 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
804 | if (p-> mShowIconForwardFast) { | 804 | if (p-> mShowIconForwardFast) { |
805 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 805 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
806 | connect( action, SIGNAL( activated() ), | 806 | connect( action, SIGNAL( activated() ), |
807 | mView, SLOT( goNextMonth() ) ); | 807 | mView, SLOT( goNextMonth() ) ); |
808 | action->addTo( iconToolBar ); | 808 | action->addTo( iconToolBar ); |
809 | } | 809 | } |
810 | 810 | ||
811 | 811 | ||
812 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 812 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
813 | 813 | ||
814 | if (p-> mShowIconNewEvent) | 814 | if (p-> mShowIconNewEvent) |
815 | configureToolBarMenu->setItemChecked( 10, true ); | 815 | configureToolBarMenu->setItemChecked( 10, true ); |
816 | if (p->mShowIconNewTodo ) | 816 | if (p->mShowIconNewTodo ) |
817 | configureToolBarMenu->setItemChecked( 20, true ); | 817 | configureToolBarMenu->setItemChecked( 20, true ); |
818 | if (p-> mShowIconSearch) | 818 | if (p-> mShowIconSearch) |
819 | configureToolBarMenu->setItemChecked( 120, true ); | 819 | configureToolBarMenu->setItemChecked( 120, true ); |
820 | if (p-> mShowIconList) | 820 | if (p-> mShowIconList) |
821 | configureToolBarMenu->setItemChecked( 30, true ); | 821 | configureToolBarMenu->setItemChecked( 30, true ); |
822 | if (p-> mShowIconDay1) | 822 | if (p-> mShowIconDay1) |
823 | configureToolBarMenu->setItemChecked( 40, true ); | 823 | configureToolBarMenu->setItemChecked( 40, true ); |
824 | if (p-> mShowIconDay5) | 824 | if (p-> mShowIconDay5) |
825 | configureToolBarMenu->setItemChecked( 50, true ); | 825 | configureToolBarMenu->setItemChecked( 50, true ); |
826 | if (p-> mShowIconDay7) | 826 | if (p-> mShowIconDay7) |
827 | configureToolBarMenu->setItemChecked( 60, true ); | 827 | configureToolBarMenu->setItemChecked( 60, true ); |
828 | if (p-> mShowIconMonth) | 828 | if (p-> mShowIconMonth) |
829 | configureToolBarMenu->setItemChecked( 70, true ); | 829 | configureToolBarMenu->setItemChecked( 70, true ); |
830 | if (p-> mShowIconTodoview) | 830 | if (p-> mShowIconTodoview) |
831 | configureToolBarMenu->setItemChecked( 80, true ); | 831 | configureToolBarMenu->setItemChecked( 80, true ); |
832 | if (p-> mShowIconBackFast) | 832 | if (p-> mShowIconBackFast) |
833 | configureToolBarMenu->setItemChecked( 200, true ); | 833 | configureToolBarMenu->setItemChecked( 200, true ); |
834 | if (p-> mShowIconBack) | 834 | if (p-> mShowIconBack) |
835 | configureToolBarMenu->setItemChecked( 210, true ); | 835 | configureToolBarMenu->setItemChecked( 210, true ); |
836 | if (p-> mShowIconToday) | 836 | if (p-> mShowIconToday) |
837 | configureToolBarMenu->setItemChecked( 130, true ); | 837 | configureToolBarMenu->setItemChecked( 130, true ); |
838 | if (p-> mShowIconForward) | 838 | if (p-> mShowIconForward) |
839 | configureToolBarMenu->setItemChecked( 220, true ); | 839 | configureToolBarMenu->setItemChecked( 220, true ); |
840 | if (p-> mShowIconForwardFast) | 840 | if (p-> mShowIconForwardFast) |
841 | configureToolBarMenu->setItemChecked( 230, true ); | 841 | configureToolBarMenu->setItemChecked( 230, true ); |
842 | if (p-> mShowIconNextDays) | 842 | if (p-> mShowIconNextDays) |
843 | configureToolBarMenu->setItemChecked( 100, true ); | 843 | configureToolBarMenu->setItemChecked( 100, true ); |
844 | if (p-> mShowIconNext) | 844 | if (p-> mShowIconNext) |
845 | configureToolBarMenu->setItemChecked( 110, true ); | 845 | configureToolBarMenu->setItemChecked( 110, true ); |
846 | if (p-> mShowIconJournal) | 846 | if (p-> mShowIconJournal) |
847 | configureToolBarMenu->setItemChecked( 90, true ); | 847 | configureToolBarMenu->setItemChecked( 90, true ); |
848 | if (p-> mShowIconWhatsThis) | 848 | if (p-> mShowIconWhatsThis) |
849 | configureToolBarMenu->setItemChecked( 300, true ); | 849 | configureToolBarMenu->setItemChecked( 300, true ); |
850 | 850 | ||
851 | QLabel* dummy = new QLabel( iconToolBar ); | 851 | QLabel* dummy = new QLabel( iconToolBar ); |
852 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 852 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
853 | if (!p-> mShowIconStretch) | 853 | if (!p-> mShowIconStretch) |
854 | iconToolBar->setStretchableWidget ( dummy ) ; | 854 | iconToolBar->setStretchableWidget ( dummy ) ; |
855 | else | 855 | else |
856 | configureToolBarMenu->setItemChecked( 5, true ); | 856 | configureToolBarMenu->setItemChecked( 5, true ); |
857 | if (p-> mShowIconWhatsThis) | 857 | if (p-> mShowIconWhatsThis) |
858 | QWhatsThis::whatsThisButton ( iconToolBar ); | 858 | QWhatsThis::whatsThisButton ( iconToolBar ); |
859 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 859 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
860 | configureAgenda( p->mHourSize ); | 860 | configureAgenda( p->mHourSize ); |
861 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 861 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
862 | } | 862 | } |
863 | void MainWindow::fillSyncMenu() | 863 | void MainWindow::fillSyncMenu() |
864 | { | 864 | { |
865 | if ( syncMenu->count() ) | 865 | if ( syncMenu->count() ) |
866 | syncMenu->clear(); | 866 | syncMenu->clear(); |
867 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 867 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
868 | syncMenu->insertSeparator(); | 868 | syncMenu->insertSeparator(); |
869 | if ( mServerSocket == 0 ) { | 869 | if ( mServerSocket == 0 ) { |
870 | syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 870 | syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
871 | } else { | 871 | } else { |
872 | syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 872 | syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
873 | } | 873 | } |
874 | syncMenu->insertSeparator(); | 874 | syncMenu->insertSeparator(); |
875 | syncMenu->insertItem( i18n("New Pi-Sync!"), 4 ); | ||
876 | syncMenu->insertItem( i18n("Quick Pi-Sync!"), 5 ); | ||
877 | syncMenu->insertSeparator(); | ||
878 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 875 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
879 | syncMenu->insertSeparator(); | 876 | syncMenu->insertSeparator(); |
880 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 877 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
881 | config.setGroup("General"); | 878 | config.setGroup("General"); |
882 | QStringList prof = config.readListEntry("SyncProfileNames"); | 879 | QStringList prof = config.readListEntry("SyncProfileNames"); |
883 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 880 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
884 | if ( prof.count() < 3 ) { | 881 | if ( prof.count() < 3 ) { |
885 | prof.clear(); | 882 | prof.clear(); |
886 | prof << i18n("Sharp_DTM"); | 883 | prof << i18n("Sharp_DTM"); |
887 | prof << i18n("Local_file"); | 884 | prof << i18n("Local_file"); |
888 | prof << i18n("Last_file"); | 885 | prof << i18n("Last_file"); |
889 | KSyncProfile* temp = new KSyncProfile (); | 886 | KSyncProfile* temp = new KSyncProfile (); |
890 | temp->setName( prof[0] ); | 887 | temp->setName( prof[0] ); |
891 | temp->writeConfig(&config); | 888 | temp->writeConfig(&config); |
892 | temp->setName( prof[1] ); | 889 | temp->setName( prof[1] ); |
893 | temp->writeConfig(&config); | 890 | temp->writeConfig(&config); |
894 | temp->setName( prof[2] ); | 891 | temp->setName( prof[2] ); |
895 | temp->writeConfig(&config); | 892 | temp->writeConfig(&config); |
896 | config.setGroup("General"); | 893 | config.setGroup("General"); |
897 | config.writeEntry("SyncProfileNames",prof); | 894 | config.writeEntry("SyncProfileNames",prof); |
898 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 895 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
899 | config.sync(); | 896 | config.sync(); |
900 | delete temp; | 897 | delete temp; |
901 | } | 898 | } |
902 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 899 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
903 | KOPrefs::instance()->mSyncProfileNames = prof; | 900 | KOPrefs::instance()->mSyncProfileNames = prof; |
904 | int i; | 901 | int i; |
905 | for ( i = 0; i < prof.count(); ++i ) { | 902 | for ( i = 0; i < prof.count(); ++i ) { |
906 | 903 | ||
907 | syncMenu->insertItem( prof[i], 1000+i ); | 904 | syncMenu->insertItem( prof[i], 1000+i ); |
908 | if ( i == 2 ) | 905 | if ( i == 2 ) |
909 | syncMenu->insertSeparator(); | 906 | syncMenu->insertSeparator(); |
910 | } | 907 | } |
911 | QDir app_dir; | 908 | QDir app_dir; |
912 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 909 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
913 | syncMenu->setItemEnabled( false , 1000 ); | 910 | syncMenu->setItemEnabled( false , 1000 ); |
914 | } | 911 | } |
915 | mView->setupExternSyncProfiles(); | 912 | mView->setupExternSyncProfiles(); |
916 | } | 913 | } |
917 | 914 | ||
918 | int MainWindow::ringSync() | 915 | int MainWindow::ringSync() |
919 | { | 916 | { |
920 | int syncedProfiles = 0; | 917 | int syncedProfiles = 0; |
921 | int i; | 918 | int i; |
922 | QTime timer; | 919 | QTime timer; |
923 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 920 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
924 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | 921 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; |
925 | KSyncProfile* temp = new KSyncProfile (); | 922 | KSyncProfile* temp = new KSyncProfile (); |
926 | KOPrefs::instance()->mAskForPreferences = false; | 923 | KOPrefs::instance()->mAskForPreferences = false; |
927 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 924 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
928 | mCurrentSyncProfile = i; | 925 | mCurrentSyncProfile = i; |
929 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 926 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
930 | temp->readConfig(&config); | 927 | temp->readConfig(&config); |
931 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | 928 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { |
932 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 929 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
933 | ++syncedProfiles; | 930 | ++syncedProfiles; |
934 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 931 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
935 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 932 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
936 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 933 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
937 | KOPrefs::instance()->mWriteBackInFuture = 0; | 934 | KOPrefs::instance()->mWriteBackInFuture = 0; |
938 | if ( temp->getWriteBackFuture() ) | 935 | if ( temp->getWriteBackFuture() ) |
939 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 936 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
940 | KOPrefs::instance()->mShowSyncSummary = false; | 937 | KOPrefs::instance()->mShowSyncSummary = false; |
941 | mView->setSyncDevice(syncProfileNames[i] ); | 938 | mView->setSyncDevice(syncProfileNames[i] ); |
942 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 939 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
943 | if ( i == 0 ) { | 940 | if ( i == 0 ) { |
944 | syncSharp(); | 941 | syncSharp(); |
945 | } else { | 942 | } else { |
946 | if ( temp->getIsLocalFileSync() ) { | 943 | if ( temp->getIsLocalFileSync() ) { |
947 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | 944 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) |
948 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 945 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
949 | } else { | 946 | } else { |
950 | if ( temp->getIsPhoneSync() ) { | 947 | if ( temp->getIsPhoneSync() ) { |
951 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 948 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
952 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 949 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
953 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 950 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
954 | syncPhone(); | 951 | syncPhone(); |
955 | } else | 952 | } else if ( temp->getIsPiSync() ) { |
953 | mPassWordPiSync = temp->getRemotePw(); | ||
954 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | ||
955 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | ||
956 | syncPi(); | ||
957 | } else | ||
956 | syncRemote( temp, false ); | 958 | syncRemote( temp, false ); |
957 | 959 | ||
958 | } | 960 | } |
959 | } | 961 | } |
960 | timer.start(); | 962 | timer.start(); |
961 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 963 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
962 | while ( timer.elapsed () < 2000 ) { | 964 | while ( timer.elapsed () < 2000 ) { |
963 | qApp->processEvents(); | 965 | qApp->processEvents(); |
964 | #ifndef _WIN32_ | 966 | #ifndef _WIN32_ |
965 | sleep (1); | 967 | sleep (1); |
966 | #endif | 968 | #endif |
967 | } | 969 | } |
968 | 970 | ||
969 | } | 971 | } |
970 | 972 | ||
971 | } | 973 | } |
972 | delete temp; | 974 | delete temp; |
973 | return syncedProfiles; | 975 | return syncedProfiles; |
974 | } | 976 | } |
975 | 977 | ||
976 | void MainWindow::multiSync( bool askforPrefs ) | 978 | void MainWindow::multiSync( bool askforPrefs ) |
977 | { | 979 | { |
978 | if (mBlockSaveFlag) | 980 | if (mBlockSaveFlag) |
979 | return; | 981 | return; |
980 | mBlockSaveFlag = true; | 982 | mBlockSaveFlag = true; |
981 | 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!"); |
982 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 984 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
983 | question, | 985 | question, |
984 | i18n("Yes"), i18n("No"), | 986 | i18n("Yes"), i18n("No"), |
985 | 0, 0 ) != 0 ) { | 987 | 0, 0 ) != 0 ) { |
986 | mBlockSaveFlag = false; | 988 | mBlockSaveFlag = false; |
987 | setCaption(i18n("Aborted! Nothing synced!")); | 989 | setCaption(i18n("Aborted! Nothing synced!")); |
988 | return; | 990 | return; |
989 | } | 991 | } |
990 | mView->setSyncDevice(i18n("Multiple profiles") ); | 992 | mView->setSyncDevice(i18n("Multiple profiles") ); |
991 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; | 993 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; |
992 | if ( askforPrefs ) { | 994 | if ( askforPrefs ) { |
993 | mView->edit_sync_options(); | 995 | mView->edit_sync_options(); |
994 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; | 996 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; |
995 | } | 997 | } |
996 | setCaption(i18n("Multiple sync started.") ); | 998 | setCaption(i18n("Multiple sync started.") ); |
997 | qApp->processEvents(); | 999 | qApp->processEvents(); |
998 | int num = ringSync() ; | 1000 | int num = ringSync() ; |
999 | if ( num > 1 ) | 1001 | if ( num > 1 ) |
1000 | ringSync(); | 1002 | ringSync(); |
1001 | mBlockSaveFlag = false; | 1003 | mBlockSaveFlag = false; |
1002 | if ( num ) | 1004 | if ( num ) |
1003 | save(); | 1005 | save(); |
1004 | if ( num ) | 1006 | if ( num ) |
1005 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 1007 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
1006 | else | 1008 | else |
1007 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 1009 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
1008 | return; | 1010 | return; |
1009 | } | 1011 | } |
1010 | void MainWindow::slotSyncMenu( int action ) | 1012 | void MainWindow::slotSyncMenu( int action ) |
1011 | { | 1013 | { |
1012 | qDebug("syncaction %d ", action); | 1014 | qDebug("syncaction %d ", action); |
1013 | if ( action == 0 ) { | 1015 | if ( action == 0 ) { |
1014 | 1016 | ||
1015 | // seems to be a Qt2 event handling bug | 1017 | // seems to be a Qt2 event handling bug |
1016 | // syncmenu.clear causes a segfault at first time | 1018 | // syncmenu.clear causes a segfault at first time |
1017 | // 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 |
1018 | // 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 |
1019 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 1021 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
1020 | //confSync(); | 1022 | //confSync(); |
1021 | 1023 | ||
1022 | return; | 1024 | return; |
1023 | } | 1025 | } |
1024 | if ( action == 1 ) { | 1026 | if ( action == 1 ) { |
1025 | multiSync( true ); | 1027 | multiSync( true ); |
1026 | return; | 1028 | return; |
1027 | } | 1029 | } |
1028 | if ( action == 2 ) { | 1030 | if ( action == 2 ) { |
1029 | enableQuick(); | 1031 | enableQuick(); |
1030 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 1032 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
1031 | return; | 1033 | return; |
1032 | } | 1034 | } |
1033 | if ( action == 3 ) { | 1035 | if ( action == 3 ) { |
1034 | delete mServerSocket; | 1036 | delete mServerSocket; |
1035 | mServerSocket = 0; | 1037 | mServerSocket = 0; |
1036 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 1038 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
1037 | return; | 1039 | return; |
1038 | } | 1040 | } |
1039 | if ( action == 4 ) { | ||
1040 | performQuick(); | ||
1041 | return; | ||
1042 | } | ||
1043 | if ( action == 5 ) { | ||
1044 | performQuickQuick(); | ||
1045 | return; | ||
1046 | } | ||
1047 | 1041 | ||
1048 | if (mBlockSaveFlag) | 1042 | if (mBlockSaveFlag) |
1049 | return; | 1043 | return; |
1050 | mBlockSaveFlag = true; | 1044 | mBlockSaveFlag = true; |
1051 | mCurrentSyncProfile = action - 1000 ; | 1045 | mCurrentSyncProfile = action - 1000 ; |
1052 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 1046 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
1053 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 1047 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
1054 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 1048 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
1055 | KSyncProfile* temp = new KSyncProfile (); | 1049 | KSyncProfile* temp = new KSyncProfile (); |
1056 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 1050 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
1057 | temp->readConfig(&config); | 1051 | temp->readConfig(&config); |
1058 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1052 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
1059 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 1053 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
1060 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1054 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1061 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1055 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1062 | KOPrefs::instance()->mWriteBackInFuture = 0; | 1056 | KOPrefs::instance()->mWriteBackInFuture = 0; |
1063 | if ( temp->getWriteBackFuture() ) | 1057 | if ( temp->getWriteBackFuture() ) |
1064 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 1058 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
1065 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 1059 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
1066 | if ( action == 1000 ) { | 1060 | if ( action == 1000 ) { |
1067 | syncSharp(); | 1061 | syncSharp(); |
1068 | 1062 | ||
1069 | } else if ( action == 1001 ) { | 1063 | } else if ( action == 1001 ) { |
1070 | syncLocalFile(); | 1064 | syncLocalFile(); |
1071 | 1065 | ||
1072 | } else if ( action == 1002 ) { | 1066 | } else if ( action == 1002 ) { |
1073 | quickSyncLocalFile(); | 1067 | quickSyncLocalFile(); |
1074 | 1068 | ||
1075 | } else if ( action >= 1003 ) { | 1069 | } else if ( action >= 1003 ) { |
1076 | if ( temp->getIsLocalFileSync() ) { | 1070 | if ( temp->getIsLocalFileSync() ) { |
1077 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 1071 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
1078 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1072 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1079 | } else { | 1073 | } else { |
1080 | if ( temp->getIsPhoneSync() ) { | 1074 | if ( temp->getIsPhoneSync() ) { |
1081 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1075 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1082 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1076 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1083 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1077 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1084 | syncPhone(); | 1078 | syncPhone(); |
1085 | } else | 1079 | } else if ( temp->getIsPiSync() ) { |
1080 | mPassWordPiSync = temp->getRemotePw(); | ||
1081 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | ||
1082 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | ||
1083 | syncPi(); | ||
1084 | } else | ||
1086 | syncRemote( temp ); | 1085 | syncRemote( temp ); |
1087 | 1086 | ||
1088 | } | 1087 | } |
1089 | } | 1088 | } |
1090 | delete temp; | 1089 | delete temp; |
1091 | mBlockSaveFlag = false; | 1090 | mBlockSaveFlag = false; |
1092 | } | 1091 | } |
1093 | void MainWindow::setDefaultPreferences() | 1092 | void MainWindow::setDefaultPreferences() |
1094 | { | 1093 | { |
1095 | KOPrefs *p = KOPrefs::instance(); | 1094 | KOPrefs *p = KOPrefs::instance(); |
1096 | 1095 | ||
1097 | p->mCompactDialogs = true; | 1096 | p->mCompactDialogs = true; |
1098 | p->mConfirm = true; | 1097 | p->mConfirm = true; |
1099 | // p->mEnableQuickTodo = false; | 1098 | // p->mEnableQuickTodo = false; |
1100 | } | 1099 | } |
1101 | 1100 | ||
1102 | QString MainWindow::resourcePath() | 1101 | QString MainWindow::resourcePath() |
1103 | { | 1102 | { |
1104 | return KGlobal::iconLoader()->iconPath(); | 1103 | return KGlobal::iconLoader()->iconPath(); |
1105 | } | 1104 | } |
1106 | 1105 | ||
1107 | void MainWindow::displayText( QString text ,QString cap ) | 1106 | void MainWindow::displayText( QString text ,QString cap ) |
1108 | { | 1107 | { |
1109 | QDialog dia( this, "name", true ); ; | 1108 | QDialog dia( this, "name", true ); ; |
1110 | dia.setCaption( cap ); | 1109 | dia.setCaption( cap ); |
1111 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1110 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1112 | lay->setSpacing( 3 ); | 1111 | lay->setSpacing( 3 ); |
1113 | lay->setMargin( 3 ); | 1112 | lay->setMargin( 3 ); |
1114 | QTextBrowser tb ( &dia ); | 1113 | QTextBrowser tb ( &dia ); |
1115 | lay->addWidget( &tb ); | 1114 | lay->addWidget( &tb ); |
1116 | tb.setText( text ); | 1115 | tb.setText( text ); |
1117 | #ifdef DESKTOP_VERSION | 1116 | #ifdef DESKTOP_VERSION |
1118 | dia.resize( 640, 480); | 1117 | dia.resize( 640, 480); |
1119 | #else | 1118 | #else |
1120 | dia.showMaximized(); | 1119 | dia.showMaximized(); |
1121 | #endif | 1120 | #endif |
1122 | dia.exec(); | 1121 | dia.exec(); |
1123 | } | 1122 | } |
1124 | void MainWindow::displayFile( QString fn, QString cap ) | 1123 | void MainWindow::displayFile( QString fn, QString cap ) |
1125 | { | 1124 | { |
1126 | QString fileName = resourcePath() + fn; | 1125 | QString fileName = resourcePath() + fn; |
1127 | QString text; | 1126 | QString text; |
1128 | QFile file( fileName ); | 1127 | QFile file( fileName ); |
1129 | if (!file.open( IO_ReadOnly ) ) { | 1128 | if (!file.open( IO_ReadOnly ) ) { |
1130 | return ; | 1129 | return ; |
1131 | 1130 | ||
1132 | } | 1131 | } |
1133 | QTextStream ts( &file ); | 1132 | QTextStream ts( &file ); |
1134 | text = ts.read(); | 1133 | text = ts.read(); |
1135 | file.close(); | 1134 | file.close(); |
1136 | displayText( text, cap); | 1135 | displayText( text, cap); |
1137 | } | 1136 | } |
1138 | void MainWindow::features() | 1137 | void MainWindow::features() |
1139 | { | 1138 | { |
1140 | 1139 | ||
1141 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1140 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1142 | } | 1141 | } |
1143 | 1142 | ||
1144 | void MainWindow::usertrans() | 1143 | void MainWindow::usertrans() |
1145 | { | 1144 | { |
1146 | 1145 | ||
1147 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1146 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1148 | } | 1147 | } |
1149 | 1148 | ||
1150 | void MainWindow::synchowto() | 1149 | void MainWindow::synchowto() |
1151 | { | 1150 | { |
1152 | #if 0 | 1151 | #if 0 |
1153 | QPtrList<Incidence> er = mCalendar->rawIncidences(); | 1152 | QPtrList<Incidence> er = mCalendar->rawIncidences(); |
1154 | Incidence* inR = er.first(); | 1153 | Incidence* inR = er.first(); |
1155 | VCalFormat vf; | 1154 | VCalFormat vf; |
1156 | QString strout; | 1155 | QString strout; |
1157 | while ( inR ) { | 1156 | while ( inR ) { |
1158 | if ( inR->type() == "Todo" ) | 1157 | if ( inR->type() == "Todo" ) |
1159 | strout = vf.todoToString( (Todo *) inR ); | 1158 | strout = vf.todoToString( (Todo *) inR ); |
1160 | if ( inR->type() == "Event" ) | 1159 | if ( inR->type() == "Event" ) |
1161 | strout = vf.eventToString( (Event *) inR ); | 1160 | strout = vf.eventToString( (Event *) inR ); |
1162 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); | 1161 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); |
1163 | inR = er.next(); | 1162 | inR = er.next(); |
1164 | } | 1163 | } |
1165 | #endif | 1164 | #endif |
1166 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); | 1165 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); |
1167 | } | 1166 | } |
1168 | void MainWindow::faq() | 1167 | void MainWindow::faq() |
1169 | { | 1168 | { |
1170 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1169 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1171 | 1170 | ||
1172 | } | 1171 | } |
1173 | void MainWindow::whatsNew() | 1172 | void MainWindow::whatsNew() |
1174 | { | 1173 | { |
1175 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); | 1174 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); |
1176 | 1175 | ||
1177 | } | 1176 | } |
1178 | void MainWindow::licence() | 1177 | void MainWindow::licence() |
1179 | { | 1178 | { |
1180 | KApplication::showLicence(); | 1179 | KApplication::showLicence(); |
1181 | 1180 | ||
1182 | } | 1181 | } |
1183 | void MainWindow::about() | 1182 | void MainWindow::about() |
1184 | { | 1183 | { |
1185 | QString version; | 1184 | QString version; |
1186 | #include <../version> | 1185 | #include <../version> |
1187 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1186 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1188 | i18n("KOrganizer/Platform-independent\n") + | 1187 | i18n("KOrganizer/Platform-independent\n") + |
1189 | "(KO/Pi) " + version + " - " + | 1188 | "(KO/Pi) " + version + " - " + |
1190 | 1189 | ||
1191 | #ifdef DESKTOP_VERSION | 1190 | #ifdef DESKTOP_VERSION |
1192 | i18n("Desktop Edition\n") + | 1191 | i18n("Desktop Edition\n") + |
1193 | #else | 1192 | #else |
1194 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1193 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1195 | #endif | 1194 | #endif |
1196 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); | 1195 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); |
1197 | } | 1196 | } |
1198 | void MainWindow::keyBindings() | 1197 | void MainWindow::keyBindings() |
1199 | { | 1198 | { |
1200 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1199 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1201 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1200 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1202 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1201 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1203 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1202 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1204 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1203 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1205 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1204 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1206 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1205 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1207 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1206 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1208 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1207 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1209 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1208 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1210 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1209 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1211 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1210 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1212 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1211 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1213 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1212 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
@@ -1830,297 +1829,258 @@ void MainWindow::importIcal() | |||
1830 | } | 1829 | } |
1831 | 1830 | ||
1832 | void MainWindow::exportVCalendar() | 1831 | void MainWindow::exportVCalendar() |
1833 | { | 1832 | { |
1834 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1833 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1835 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1834 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1836 | if ( fn == "" ) | 1835 | if ( fn == "" ) |
1837 | return; | 1836 | return; |
1838 | QFileInfo info; | 1837 | QFileInfo info; |
1839 | info.setFile( fn ); | 1838 | info.setFile( fn ); |
1840 | QString mes; | 1839 | QString mes; |
1841 | bool createbup = true; | 1840 | bool createbup = true; |
1842 | if ( info. exists() ) { | 1841 | if ( info. exists() ) { |
1843 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1842 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1844 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1843 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1845 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1844 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1846 | 0, 1 ); | 1845 | 0, 1 ); |
1847 | if ( result != 0 ) { | 1846 | if ( result != 0 ) { |
1848 | createbup = false; | 1847 | createbup = false; |
1849 | } | 1848 | } |
1850 | } | 1849 | } |
1851 | if ( createbup ) { | 1850 | if ( createbup ) { |
1852 | if ( mView->exportVCalendar( fn ) ) { | 1851 | if ( mView->exportVCalendar( fn ) ) { |
1853 | KOPrefs::instance()->mLastVcalFile = fn; | 1852 | KOPrefs::instance()->mLastVcalFile = fn; |
1854 | if ( fn.length() > 20 ) | 1853 | if ( fn.length() > 20 ) |
1855 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1854 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1856 | else | 1855 | else |
1857 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1856 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1858 | setCaption(mes); | 1857 | setCaption(mes); |
1859 | } | 1858 | } |
1860 | } | 1859 | } |
1861 | 1860 | ||
1862 | } | 1861 | } |
1863 | QString MainWindow::getPassword( ) | 1862 | QString MainWindow::getPassword( ) |
1864 | { | 1863 | { |
1865 | QString retfile = ""; | 1864 | QString retfile = ""; |
1866 | QDialog dia ( this, "input-dialog", true ); | 1865 | QDialog dia ( this, "input-dialog", true ); |
1867 | QLineEdit lab ( &dia ); | 1866 | QLineEdit lab ( &dia ); |
1868 | lab.setEchoMode( QLineEdit::Password ); | 1867 | lab.setEchoMode( QLineEdit::Password ); |
1869 | QVBoxLayout lay( &dia ); | 1868 | QVBoxLayout lay( &dia ); |
1870 | lay.setMargin(7); | 1869 | lay.setMargin(7); |
1871 | lay.setSpacing(7); | 1870 | lay.setSpacing(7); |
1872 | lay.addWidget( &lab); | 1871 | lay.addWidget( &lab); |
1873 | dia.setFixedSize( 230,50 ); | 1872 | dia.setFixedSize( 230,50 ); |
1874 | dia.setCaption( i18n("Enter password") ); | 1873 | dia.setCaption( i18n("Enter password") ); |
1875 | QPushButton pb ( "OK", &dia); | 1874 | QPushButton pb ( "OK", &dia); |
1876 | lay.addWidget( &pb ); | 1875 | lay.addWidget( &pb ); |
1877 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1876 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1878 | dia.show(); | 1877 | dia.show(); |
1879 | int res = dia.exec(); | 1878 | int res = dia.exec(); |
1880 | if ( res ) | 1879 | if ( res ) |
1881 | retfile = lab.text(); | 1880 | retfile = lab.text(); |
1882 | dia.hide(); | 1881 | dia.hide(); |
1883 | qApp->processEvents(); | 1882 | qApp->processEvents(); |
1884 | return retfile; | 1883 | return retfile; |
1885 | 1884 | ||
1886 | } | 1885 | } |
1887 | 1886 | ||
1888 | void MainWindow::enableQuick() | 1887 | void MainWindow::enableQuick() |
1889 | { | 1888 | { |
1890 | QString passWordPiSync = "bhdrvmk"; | 1889 | QString passWordPiSync = "bhdrvmk"; |
1891 | QString retfile = ""; | 1890 | QString retfile = ""; |
1892 | QDialog dia ( this, "input-dialog", true ); | 1891 | QDialog dia ( this, "input-dialog", true ); |
1893 | QLineEdit lab ( &dia ); | 1892 | QLineEdit lab ( &dia ); |
1894 | QVBoxLayout lay( &dia ); | 1893 | QVBoxLayout lay( &dia ); |
1895 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); | 1894 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); |
1896 | lay.setMargin(7); | 1895 | lay.setMargin(7); |
1897 | lay.setSpacing(7); | 1896 | lay.setSpacing(7); |
1898 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); | 1897 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); |
1899 | lay.addWidget( &label); | 1898 | lay.addWidget( &label); |
1900 | lay.addWidget( &lab); | 1899 | lay.addWidget( &lab); |
1901 | 1900 | ||
1902 | QLineEdit lepw ( &dia ); | 1901 | QLineEdit lepw ( &dia ); |
1903 | lepw.setText( "abc" ); | 1902 | lepw.setText( "abc" ); |
1904 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 1903 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
1905 | lay.addWidget( &label2); | 1904 | lay.addWidget( &label2); |
1906 | lay.addWidget( &lepw); | 1905 | lay.addWidget( &lepw); |
1907 | dia.setFixedSize( 230,80 ); | 1906 | dia.setFixedSize( 230,80 ); |
1908 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 1907 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
1909 | QPushButton pb ( "OK", &dia); | 1908 | QPushButton pb ( "OK", &dia); |
1910 | lay.addWidget( &pb ); | 1909 | lay.addWidget( &pb ); |
1911 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1910 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1912 | dia.show(); | 1911 | dia.show(); |
1913 | int res = dia.exec(); | 1912 | int res = dia.exec(); |
1914 | if ( res ) | 1913 | if ( res ) |
1915 | retfile = lab.text(); | 1914 | retfile = lab.text(); |
1916 | else | 1915 | else |
1917 | return; | 1916 | return; |
1918 | dia.hide(); | 1917 | dia.hide(); |
1919 | passWordPiSync = lepw.text(); | 1918 | passWordPiSync = lepw.text(); |
1920 | qApp->processEvents(); | 1919 | qApp->processEvents(); |
1921 | KOPrefs::instance()->mPassiveSyncPort = retfile; | 1920 | KOPrefs::instance()->mPassiveSyncPort = retfile; |
1922 | bool ok; | 1921 | bool ok; |
1923 | Q_UINT16 port = retfile.toUInt(&ok); | 1922 | Q_UINT16 port = retfile.toUInt(&ok); |
1924 | if ( ! ok ) { | 1923 | if ( ! ok ) { |
1925 | KMessageBox::information( this, i18n("No valid port")); | 1924 | KMessageBox::information( this, i18n("No valid port")); |
1926 | return; | 1925 | return; |
1927 | } | 1926 | } |
1928 | qDebug("port %d ", port); | 1927 | qDebug("port %d ", port); |
1929 | mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); | 1928 | mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); |
1930 | mServerSocket->setFileName( defaultFileName() ); | 1929 | mServerSocket->setFileName( defaultFileName() ); |
1931 | qDebug("connected "); | 1930 | qDebug("connected "); |
1932 | if ( !mServerSocket->ok() ) { | 1931 | if ( !mServerSocket->ok() ) { |
1933 | qWarning("Failed to bind to port %d", port); | 1932 | qWarning("Failed to bind to port %d", port); |
1934 | delete mServerSocket; | 1933 | delete mServerSocket; |
1935 | mServerSocket = 0; | 1934 | mServerSocket = 0; |
1936 | return; | 1935 | return; |
1937 | } | 1936 | } |
1938 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); | 1937 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); |
1939 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); | 1938 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); |
1940 | // connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); | 1939 | // connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); |
1941 | //connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); | 1940 | //connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); |
1942 | } | 1941 | } |
1943 | 1942 | ||
1944 | void MainWindow::getFile( bool success ) | 1943 | void MainWindow::getFile( bool success ) |
1945 | { | 1944 | { |
1946 | if ( ! success ) { | 1945 | if ( ! success ) { |
1947 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 1946 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
1948 | return; | 1947 | return; |
1949 | } | 1948 | } |
1950 | // pending adjust time for watchSavedFile() | 1949 | // pending adjust time for watchSavedFile() |
1951 | //mView->watchSavedFile(); | 1950 | //mView->watchSavedFile(); |
1952 | mView->openCalendar( defaultFileName() ); | 1951 | mView->openCalendar( defaultFileName() ); |
1953 | setCaption( i18n("Pi-Sync successful!") ); | 1952 | setCaption( i18n("Pi-Sync successful!") ); |
1954 | 1953 | ||
1955 | } | 1954 | } |
1956 | 1955 | ||
1957 | 1956 | ||
1958 | void MainWindow::performQuick() | 1957 | void MainWindow::syncPi() |
1959 | { | 1958 | { |
1960 | |||
1961 | setCaption( i18n("Please input connection settings") ); | ||
1962 | QString retfile = ""; | ||
1963 | QDialog dia ( this, "input-dialog", true ); | ||
1964 | QLineEdit lab ( &dia ); | ||
1965 | QVBoxLayout lay( &dia ); | ||
1966 | QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); | ||
1967 | lay.addWidget( &label); | ||
1968 | lab.setText( KOPrefs::instance()->mActiveSyncIP ); | ||
1969 | lay.setMargin(7); | ||
1970 | lay.setSpacing(7); | ||
1971 | lay.addWidget( &lab); | ||
1972 | QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); | ||
1973 | lay.addWidget( &label2); | ||
1974 | QLineEdit lab2 ( &dia ); | ||
1975 | lab2.setText( KOPrefs::instance()->mActiveSyncPort ); | ||
1976 | lay.addWidget( &lab2); | ||
1977 | |||
1978 | QLineEdit lepw ( &dia ); | ||
1979 | lepw.setText( mPassWordPiSync ); | ||
1980 | QLabel label3 ( i18n("Password to enable\naccess to remote:"), &dia ); | ||
1981 | lay.addWidget( &label3); | ||
1982 | lay.addWidget( &lepw); | ||
1983 | |||
1984 | dia.setFixedSize( 230,200 ); | ||
1985 | dia.setCaption( i18n("Enter port for Pi-Sync ") ); | ||
1986 | QPushButton pb ( "OK", &dia); | ||
1987 | lay.addWidget( &pb ); | ||
1988 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
1989 | dia.show(); | ||
1990 | int res = dia.exec(); | ||
1991 | if ( !res ) { | ||
1992 | setCaption( i18n("Syncing cancelled!") ); | ||
1993 | return; | ||
1994 | } | ||
1995 | mPassWordPiSync = lepw.text(); | ||
1996 | dia.hide(); | ||
1997 | KOPrefs::instance()->mActiveSyncPort = lab2.text(); | ||
1998 | KOPrefs::instance()->mActiveSyncIP = lab.text(); | ||
1999 | qApp->processEvents(); | 1959 | qApp->processEvents(); |
2000 | performQuickQuick(); | 1960 | performQuickQuick(); |
2001 | } | 1961 | } |
2002 | 1962 | ||
2003 | void MainWindow::performQuickQuick() | 1963 | void MainWindow::performQuickQuick() |
2004 | { | 1964 | { |
2005 | // setCaption( i18n("") ); | 1965 | // setCaption( i18n("") ); |
2006 | 1966 | ||
2007 | bool ok; | 1967 | bool ok; |
2008 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | 1968 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); |
2009 | if ( ! ok ) { | 1969 | if ( ! ok ) { |
2010 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1970 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
2011 | return; | 1971 | return; |
2012 | } | 1972 | } |
2013 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); | 1973 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); |
2014 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocket(KCommandSocket*,bool)) ); | 1974 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocket(KCommandSocket*,bool)) ); |
2015 | setCaption( i18n("Sending request for remote file ...") ); | 1975 | setCaption( i18n("Sending request for remote file ...") ); |
2016 | QString fileName; | 1976 | QString fileName; |
2017 | #ifdef _WIN32_ | 1977 | #ifdef _WIN32_ |
2018 | fileName = defaultFileName() +"sync"; | 1978 | fileName = defaultFileName() +"sync"; |
2019 | #else | 1979 | #else |
2020 | fileName = "/tmp/kopitempfile.ics"; | 1980 | fileName = "/tmp/kopitempfile.ics"; |
2021 | #endif | 1981 | #endif |
2022 | commandSocket->readFile( fileName ); | 1982 | commandSocket->readFile( fileName ); |
2023 | } | 1983 | } |
2024 | void MainWindow::deleteCommandSocket(KCommandSocket*s, bool success) | 1984 | void MainWindow::deleteCommandSocket(KCommandSocket*s, bool success) |
2025 | { | 1985 | { |
2026 | if ( ! success ) { | 1986 | if ( ! success ) { |
2027 | setCaption( i18n("ERROR:Receiving remote file failed.") ); | 1987 | setCaption( i18n("ERROR:Receiving remote file failed.") ); |
2028 | delete s; | 1988 | delete s; |
2029 | // pending : send stop | 1989 | // pending : send stop |
2030 | return; | 1990 | return; |
2031 | 1991 | ||
2032 | } | 1992 | } |
2033 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1993 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
2034 | qDebug("MainWindow::deleteCommandSocket "); | 1994 | qDebug("MainWindow::deleteCommandSocket "); |
2035 | delete s; | 1995 | delete s; |
2036 | } | 1996 | } |
2037 | void MainWindow::deleteCommandSocketFinish(KCommandSocket* s, bool success ) | 1997 | void MainWindow::deleteCommandSocketFinish(KCommandSocket* s, bool success ) |
2038 | { | 1998 | { |
2039 | if ( ! success ) { | 1999 | if ( ! success ) { |
2040 | setCaption( i18n("ERROR:Writing back file failed.") ); | 2000 | setCaption( i18n("ERROR:Writing back file failed.") ); |
2041 | } else { | 2001 | } else { |
2042 | qDebug("Syncing succesful! "); | 2002 | qDebug("Syncing succesful! "); |
2043 | setCaption( i18n("Pi-Sync succesful!") ); | 2003 | setCaption( i18n("Pi-Sync succesful!") ); |
2044 | } | 2004 | } |
2045 | qDebug("MainWindow::deleteCommandSocketFinish "); | 2005 | qDebug("MainWindow::deleteCommandSocketFinish "); |
2046 | delete s; | 2006 | delete s; |
2047 | } | 2007 | } |
2048 | void MainWindow::readFileFromSocket() | 2008 | void MainWindow::readFileFromSocket() |
2049 | { | 2009 | { |
2050 | // mTimerCommandSocket->stop(); | 2010 | // mTimerCommandSocket->stop(); |
2051 | setCaption( i18n("Receiving remote file ...") ); | 2011 | setCaption( i18n("Receiving remote file ...") ); |
2052 | qDebug("MainWindow::readFileFromSocket() "); | 2012 | qDebug("MainWindow::readFileFromSocket() "); |
2053 | QString fileName; | 2013 | QString fileName; |
2054 | #ifdef _WIN32_ | 2014 | #ifdef _WIN32_ |
2055 | fileName = defaultFileName() +"sync"; | 2015 | fileName = defaultFileName() +"sync"; |
2056 | #else | 2016 | #else |
2057 | fileName = "/tmp/kopitempfile.ics"; | 2017 | fileName = "/tmp/kopitempfile.ics"; |
2058 | #endif | 2018 | #endif |
2059 | 2019 | ||
2060 | setCaption( i18n("Remote file saved to temp file.") ); | 2020 | setCaption( i18n("Remote file saved to temp file.") ); |
2061 | //mCommandSocket = 0; | 2021 | //mCommandSocket = 0; |
2062 | mCurrentSyncProfile = 2 ; // last file | 2022 | mCurrentSyncProfile = 2 ; // last file |
2063 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 2023 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
2064 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 2024 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
2065 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2025 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2066 | KSyncProfile* temp = new KSyncProfile (); | 2026 | KSyncProfile* temp = new KSyncProfile (); |
2067 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2027 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2068 | temp->readConfig(&config); | 2028 | temp->readConfig(&config); |
2069 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2029 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2070 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2030 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2071 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2031 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2072 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2032 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2073 | KOPrefs::instance()->mWriteBackInFuture = 0; | 2033 | KOPrefs::instance()->mWriteBackInFuture = 0; |
2074 | if ( temp->getWriteBackFuture() ) | 2034 | if ( temp->getWriteBackFuture() ) |
2075 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2035 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2076 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2036 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2077 | delete temp; | 2037 | delete temp; |
2078 | setCaption( i18n("Remote file saved to temp file.") ); | 2038 | setCaption( i18n("Remote file saved to temp file.") ); |
2079 | if ( ! syncWithFile( fileName , true ) ) { | 2039 | if ( ! syncWithFile( fileName , true ) ) { |
2080 | setCaption( i18n("Syncing failed.") ); | 2040 | setCaption( i18n("Syncing failed.") ); |
2081 | qDebug("Syncing failed "); | 2041 | qDebug("Syncing failed "); |
2082 | return; | 2042 | return; |
2083 | } | 2043 | } |
2084 | 2044 | ||
2085 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | 2045 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); |
2086 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocketFinish(KCommandSocket*,bool)) ); | 2046 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocketFinish(KCommandSocket*,bool)) ); |
2087 | if ( KOPrefs::instance()->mWriteBackFile ) | 2047 | if ( KOPrefs::instance()->mWriteBackFile ) |
2088 | commandSocket->writeFile( fileName ); | 2048 | commandSocket->writeFile( fileName ); |
2089 | else | 2049 | else |
2090 | commandSocket->sendStop(); | 2050 | commandSocket->sendStop(); |
2091 | } | 2051 | } |
2092 | 2052 | ||
2093 | void MainWindow::syncLocalFile() | 2053 | void MainWindow::syncLocalFile() |
2094 | { | 2054 | { |
2095 | 2055 | ||
2096 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 2056 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; |
2097 | 2057 | ||
2098 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2058 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2099 | if ( fn == "" ) | 2059 | if ( fn == "" ) |
2100 | return; | 2060 | return; |
2101 | //mView->setSyncDevice("local-file" ); | 2061 | //mView->setSyncDevice("local-file" ); |
2102 | if ( syncWithFile( fn, false ) ) { | 2062 | if ( syncWithFile( fn, false ) ) { |
2103 | // Event* e = mView->getLastSyncEvent(); | 2063 | // Event* e = mView->getLastSyncEvent(); |
2104 | // e->setReadOnly( false ); | 2064 | // e->setReadOnly( false ); |
2105 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2065 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2106 | // e->setReadOnly( true ); | 2066 | // e->setReadOnly( true ); |
2107 | } | 2067 | } |
2108 | 2068 | ||
2109 | } | 2069 | } |
2110 | 2070 | ||
2111 | bool MainWindow::syncWithFile( QString fn , bool quick ) | 2071 | bool MainWindow::syncWithFile( QString fn , bool quick ) |
2112 | { | 2072 | { |
2113 | bool ret = false; | 2073 | bool ret = false; |
2114 | QFileInfo info; | 2074 | QFileInfo info; |
2115 | info.setFile( fn ); | 2075 | info.setFile( fn ); |
2116 | QString mess; | 2076 | QString mess; |
2117 | bool loadbup = true; | 2077 | bool loadbup = true; |
2118 | if ( !info. exists() ) { | 2078 | if ( !info. exists() ) { |
2119 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2079 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2120 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2080 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2121 | mess ); | 2081 | mess ); |
2122 | return ret; | 2082 | return ret; |
2123 | } | 2083 | } |
2124 | int result = 0; | 2084 | int result = 0; |
2125 | if ( !quick ) { | 2085 | if ( !quick ) { |
2126 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2086 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
@@ -2252,426 +2212,424 @@ void MainWindow::syncSSH() | |||
2252 | int maxlen = 30; | 2212 | int maxlen = 30; |
2253 | if ( QApplication::desktop()->width() > 320 ) | 2213 | if ( QApplication::desktop()->width() > 320 ) |
2254 | maxlen += 25; | 2214 | maxlen += 25; |
2255 | if ( remoteFile.length() > maxlen ) | 2215 | if ( remoteFile.length() > maxlen ) |
2256 | question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; | 2216 | question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; |
2257 | else | 2217 | else |
2258 | question += i18n("Remote file:\n " ) + remoteFile +"\n"; | 2218 | question += i18n("Remote file:\n " ) + remoteFile +"\n"; |
2259 | if ( localFile.length() > maxlen ) | 2219 | if ( localFile.length() > maxlen ) |
2260 | question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; | 2220 | question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; |
2261 | else | 2221 | else |
2262 | question += i18n("Local temp file:\n " ) + localFile +"\n"; | 2222 | question += i18n("Local temp file:\n " ) + localFile +"\n"; |
2263 | 2223 | ||
2264 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2224 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2265 | question, | 2225 | question, |
2266 | i18n("Yes"), i18n("No"), | 2226 | i18n("Yes"), i18n("No"), |
2267 | 0, 0 ) != 0 ) | 2227 | 0, 0 ) != 0 ) |
2268 | return; | 2228 | return; |
2269 | // if ( !p->mUsePassWd ) { | 2229 | // if ( !p->mUsePassWd ) { |
2270 | // QString pass = getPassword(); | 2230 | // QString pass = getPassword(); |
2271 | // if ( pass.length() > 0 ) | 2231 | // if ( pass.length() > 0 ) |
2272 | // remoteUser += ":" + pass; | 2232 | // remoteUser += ":" + pass; |
2273 | // } | 2233 | // } |
2274 | QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; | 2234 | QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; |
2275 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2235 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2276 | int fileSize = 0; | 2236 | int fileSize = 0; |
2277 | int result = system ( command ); | 2237 | int result = system ( command ); |
2278 | // 0 : okay | 2238 | // 0 : okay |
2279 | // 256: no such file or dir | 2239 | // 256: no such file or dir |
2280 | // | 2240 | // |
2281 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2241 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2282 | if ( result != 0 ) { | 2242 | if ( result != 0 ) { |
2283 | int len = maxlen; | 2243 | int len = maxlen; |
2284 | while ( len < command.length() ) { | 2244 | while ( len < command.length() ) { |
2285 | command.insert( len , "\n" ); | 2245 | command.insert( len , "\n" ); |
2286 | len += maxlen +2; | 2246 | len += maxlen +2; |
2287 | } | 2247 | } |
2288 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2248 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2289 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2249 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2290 | question, | 2250 | question, |
2291 | i18n("Okay!")) ; | 2251 | i18n("Okay!")) ; |
2292 | setCaption ("KO/Pi"); | 2252 | setCaption ("KO/Pi"); |
2293 | return; | 2253 | return; |
2294 | } | 2254 | } |
2295 | 2255 | ||
2296 | 2256 | ||
2297 | setCaption ( i18n( "Copying succeed." ) ); | 2257 | setCaption ( i18n( "Copying succeed." ) ); |
2298 | //mView->setSyncDevice("ssh-scp" ); | 2258 | //mView->setSyncDevice("ssh-scp" ); |
2299 | if ( syncWithFile(localFile , true ) ) { | 2259 | if ( syncWithFile(localFile , true ) ) { |
2300 | // Event* e = mView->getLastSyncEvent(); | 2260 | // Event* e = mView->getLastSyncEvent(); |
2301 | // e->setReadOnly( false ); | 2261 | // e->setReadOnly( false ); |
2302 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2262 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2303 | // e->setReadOnly( true ); | 2263 | // e->setReadOnly( true ); |
2304 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2264 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2305 | command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; | 2265 | command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; |
2306 | setCaption ( i18n( "Writing back file ..." ) ); | 2266 | setCaption ( i18n( "Writing back file ..." ) ); |
2307 | result = system ( command ); | 2267 | result = system ( command ); |
2308 | if ( result != 0 ) { | 2268 | if ( result != 0 ) { |
2309 | int len = maxlen; | 2269 | int len = maxlen; |
2310 | while ( len < command.length() ) { | 2270 | while ( len < command.length() ) { |
2311 | command.insert( len , "\n" ); | 2271 | command.insert( len , "\n" ); |
2312 | len += maxlen +2; | 2272 | len += maxlen +2; |
2313 | } | 2273 | } |
2314 | question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2274 | question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2315 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2275 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2316 | question, | 2276 | question, |
2317 | i18n("Okay!")) ; | 2277 | i18n("Okay!")) ; |
2318 | setCaption ("KO/Pi"); | 2278 | setCaption ("KO/Pi"); |
2319 | return; | 2279 | return; |
2320 | } else { | 2280 | } else { |
2321 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2281 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2322 | } | 2282 | } |
2323 | } | 2283 | } |
2324 | } | 2284 | } |
2325 | return; | 2285 | return; |
2326 | #if 0 | 2286 | #if 0 |
2327 | system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); | 2287 | system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); |
2328 | while ( timer.elapsed() < 5000 ) | 2288 | while ( timer.elapsed() < 5000 ) |
2329 | qApp->processEvents(); | 2289 | qApp->processEvents(); |
2330 | 2290 | ||
2331 | qDebug("MainWindow::merging) "); | 2291 | qDebug("MainWindow::merging) "); |
2332 | mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); | 2292 | mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); |
2333 | while ( mBlockSaveFlag ) | 2293 | while ( mBlockSaveFlag ) |
2334 | qApp->processEvents(); | 2294 | qApp->processEvents(); |
2335 | save(); | 2295 | save(); |
2336 | system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); | 2296 | system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); |
2337 | #endif | 2297 | #endif |
2338 | 2298 | ||
2339 | } | 2299 | } |
2340 | 2300 | ||
2341 | 2301 | ||
2342 | void MainWindow::syncSharp() | 2302 | void MainWindow::syncSharp() |
2343 | { | 2303 | { |
2344 | if ( mCalendarModifiedFlag ) | 2304 | if ( mCalendarModifiedFlag ) |
2345 | save(); | 2305 | save(); |
2346 | mView->syncSharp(); | 2306 | mView->syncSharp(); |
2347 | slotModifiedChanged( true ); | 2307 | slotModifiedChanged( true ); |
2348 | 2308 | ||
2349 | } | 2309 | } |
2350 | void MainWindow::syncPhone() | 2310 | void MainWindow::syncPhone() |
2351 | { | 2311 | { |
2352 | if ( mCalendarModifiedFlag ) | 2312 | if ( mCalendarModifiedFlag ) |
2353 | save(); | 2313 | save(); |
2354 | mView->syncPhone(); | 2314 | mView->syncPhone(); |
2355 | slotModifiedChanged( true ); | 2315 | slotModifiedChanged( true ); |
2356 | 2316 | ||
2357 | } | 2317 | } |
2358 | 2318 | ||
2359 | void MainWindow::printSel( ) | 2319 | void MainWindow::printSel( ) |
2360 | { | 2320 | { |
2361 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2321 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2362 | } | 2322 | } |
2363 | 2323 | ||
2364 | void MainWindow::printCal() | 2324 | void MainWindow::printCal() |
2365 | { | 2325 | { |
2366 | mView->print();//mCp->showDialog(); | 2326 | mView->print();//mCp->showDialog(); |
2367 | } | 2327 | } |
2368 | 2328 | ||
2369 | 2329 | ||
2370 | 2330 | ||
2371 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 2331 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
2372 | { | 2332 | { |
2373 | mPassWord = pw; | 2333 | mPassWord = pw; |
2374 | mSocket = 0; | 2334 | mSocket = 0; |
2375 | mSyncActionDialog = 0; | 2335 | mSyncActionDialog = 0; |
2376 | }; | 2336 | }; |
2377 | 2337 | ||
2378 | void KServerSocket::newConnection ( int socket ) | 2338 | void KServerSocket::newConnection ( int socket ) |
2379 | { | 2339 | { |
2380 | qDebug("KServerSocket:New connection %d ", socket); | 2340 | // qDebug("KServerSocket:New connection %d ", socket); |
2381 | if ( mSocket ) { | 2341 | if ( mSocket ) { |
2382 | qDebug("KServerSocket::newConnection Socket deleted! "); | 2342 | qDebug("KServerSocket::newConnection Socket deleted! "); |
2383 | delete mSocket; | 2343 | delete mSocket; |
2384 | mSocket = 0; | 2344 | mSocket = 0; |
2385 | } | 2345 | } |
2386 | mSocket = new QSocket( this ); | 2346 | mSocket = new QSocket( this ); |
2387 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 2347 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
2388 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 2348 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
2389 | mSocket->setSocket( socket ); | 2349 | mSocket->setSocket( socket ); |
2390 | } | 2350 | } |
2391 | 2351 | ||
2392 | void KServerSocket::discardClient() | 2352 | void KServerSocket::discardClient() |
2393 | { | 2353 | { |
2394 | qDebug(" KServerSocket::discardClient()"); | 2354 | //qDebug(" KServerSocket::discardClient()"); |
2395 | if ( mSocket ) { | 2355 | if ( mSocket ) { |
2396 | qDebug("delete "); | ||
2397 | delete mSocket; | 2356 | delete mSocket; |
2398 | mSocket = 0; | 2357 | mSocket = 0; |
2399 | } | 2358 | } |
2400 | //emit endConnect(); | 2359 | //emit endConnect(); |
2401 | } | 2360 | } |
2402 | void KServerSocket::readClient() | 2361 | void KServerSocket::readClient() |
2403 | { | 2362 | { |
2404 | if ( mSocket == 0 ) { | 2363 | if ( mSocket == 0 ) { |
2405 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 2364 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
2406 | return; | 2365 | return; |
2407 | } | 2366 | } |
2408 | qDebug("KServerSocket readClient()"); | 2367 | //qDebug("KServerSocket readClient()"); |
2409 | if ( mSocket->canReadLine() ) { | 2368 | if ( mSocket->canReadLine() ) { |
2410 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); | 2369 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); |
2411 | qDebug("KServerSocket socket->canReadLine()"); | ||
2412 | if ( tokens[0] == "GET" ) { | 2370 | if ( tokens[0] == "GET" ) { |
2413 | if ( tokens[1] == mPassWord ) | 2371 | if ( tokens[1] == mPassWord ) |
2414 | //emit sendFile( mSocket ); | 2372 | //emit sendFile( mSocket ); |
2415 | send_file(); | 2373 | send_file(); |
2416 | else { | 2374 | else { |
2417 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); | 2375 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); |
2418 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 2376 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
2419 | } | 2377 | } |
2420 | } | 2378 | } |
2421 | if ( tokens[0] == "PUT" ) { | 2379 | if ( tokens[0] == "PUT" ) { |
2422 | if ( tokens[1] == mPassWord ) | 2380 | if ( tokens[1] == mPassWord ) |
2423 | //emit getFile( mSocket ); | 2381 | //emit getFile( mSocket ); |
2424 | get_file(); | 2382 | get_file(); |
2425 | else { | 2383 | else { |
2426 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); | 2384 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); |
2427 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 2385 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
2428 | } | 2386 | } |
2429 | } | 2387 | } |
2430 | if ( tokens[0] == "STOP" ) { | 2388 | if ( tokens[0] == "STOP" ) { |
2431 | //emit endConnect(); | 2389 | //emit endConnect(); |
2432 | end_connect(); | 2390 | end_connect(); |
2433 | } | 2391 | } |
2434 | } | 2392 | } |
2435 | } | 2393 | } |
2436 | void KServerSocket::end_connect() | 2394 | void KServerSocket::end_connect() |
2437 | { | 2395 | { |
2438 | delete mSyncActionDialog; | 2396 | delete mSyncActionDialog; |
2439 | mSyncActionDialog = 0; | 2397 | mSyncActionDialog = 0; |
2440 | } | 2398 | } |
2441 | void KServerSocket::send_file() | 2399 | void KServerSocket::send_file() |
2442 | { | 2400 | { |
2443 | qDebug("MainWindow::sendFile(QSocket* s) "); | 2401 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
2444 | if ( mSyncActionDialog ) | 2402 | if ( mSyncActionDialog ) |
2445 | delete mSyncActionDialog; | 2403 | delete mSyncActionDialog; |
2446 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 2404 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
2447 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 2405 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
2448 | QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog ); | 2406 | QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog ); |
2449 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 2407 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
2450 | lay->addWidget( label); | 2408 | lay->addWidget( label); |
2451 | lay->setMargin(7); | 2409 | lay->setMargin(7); |
2452 | lay->setSpacing(7); | 2410 | lay->setSpacing(7); |
2453 | mSyncActionDialog->setFixedSize( 230, 120); | 2411 | mSyncActionDialog->setFixedSize( 230, 120); |
2454 | mSyncActionDialog->show(); | 2412 | mSyncActionDialog->show(); |
2455 | qDebug("KSS::saving ... "); | 2413 | qDebug("KSS::saving ... "); |
2456 | emit saveFile(); | 2414 | emit saveFile(); |
2457 | qApp->processEvents(); | 2415 | qApp->processEvents(); |
2458 | QString fileName = mFileName; | 2416 | QString fileName = mFileName; |
2459 | QFile file( fileName ); | 2417 | QFile file( fileName ); |
2460 | if (!file.open( IO_ReadOnly ) ) { | 2418 | if (!file.open( IO_ReadOnly ) ) { |
2461 | delete mSyncActionDialog; | 2419 | delete mSyncActionDialog; |
2462 | mSyncActionDialog = 0; | 2420 | mSyncActionDialog = 0; |
2463 | qDebug("KSS::error open file "); | 2421 | qDebug("KSS::error open file "); |
2464 | mSocket->close(); | 2422 | mSocket->close(); |
2465 | if ( mSocket->state() == QSocket::Idle ) | 2423 | if ( mSocket->state() == QSocket::Idle ) |
2466 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 2424 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
2467 | return ; | 2425 | return ; |
2468 | 2426 | ||
2469 | } | 2427 | } |
2470 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 2428 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
2471 | QTextStream ts( &file ); | 2429 | QTextStream ts( &file ); |
2472 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2430 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2473 | QTextStream os( mSocket ); | 2431 | QTextStream os( mSocket ); |
2474 | os.setCodec( QTextCodec::codecForName("utf8") ); | 2432 | os.setCodec( QTextCodec::codecForName("utf8") ); |
2475 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 2433 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
2476 | while ( ! ts.atEnd() ) { | 2434 | while ( ! ts.atEnd() ) { |
2477 | os << ts.readLine() << "\n"; | 2435 | os << ts.readLine() << "\n"; |
2478 | } | 2436 | } |
2479 | //os << ts.read(); | 2437 | //os << ts.read(); |
2480 | file.close(); | 2438 | file.close(); |
2481 | mSyncActionDialog->setCaption( i18n("Waiting to get back synced file") ); | 2439 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
2482 | qDebug("file sent "); | ||
2483 | mSocket->close(); | 2440 | mSocket->close(); |
2484 | if ( mSocket->state() == QSocket::Idle ) | 2441 | if ( mSocket->state() == QSocket::Idle ) |
2485 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 2442 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
2486 | } | 2443 | } |
2487 | void KServerSocket::get_file() | 2444 | void KServerSocket::get_file() |
2488 | { | 2445 | { |
2489 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 2446 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
2490 | 2447 | ||
2491 | piTime.start(); | 2448 | piTime.start(); |
2492 | piFileString = ""; | 2449 | piFileString = ""; |
2493 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 2450 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
2494 | } | 2451 | } |
2495 | 2452 | ||
2496 | 2453 | ||
2497 | void KServerSocket::readBackFileFromSocket() | 2454 | void KServerSocket::readBackFileFromSocket() |
2498 | { | 2455 | { |
2499 | qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 2456 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
2500 | while ( mSocket->canReadLine () ) { | 2457 | while ( mSocket->canReadLine () ) { |
2501 | piTime.restart(); | 2458 | piTime.restart(); |
2502 | QString line = mSocket->readLine (); | 2459 | QString line = mSocket->readLine (); |
2503 | piFileString += line; | 2460 | piFileString += line; |
2504 | qDebug("readline: %s ", line.latin1()); | 2461 | //qDebug("readline: %s ", line.latin1()); |
2505 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 2462 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
2506 | 2463 | ||
2507 | } | 2464 | } |
2508 | if ( piTime.elapsed () < 3000 ) { | 2465 | if ( piTime.elapsed () < 3000 ) { |
2509 | // wait for more | 2466 | // wait for more |
2510 | qDebug("waitformore "); | 2467 | //qDebug("waitformore "); |
2511 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 2468 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
2512 | return; | 2469 | return; |
2513 | } | 2470 | } |
2514 | QString fileName = mFileName; | 2471 | QString fileName = mFileName; |
2515 | QFile file ( fileName ); | 2472 | QFile file ( fileName ); |
2516 | if (!file.open( IO_WriteOnly ) ) { | 2473 | if (!file.open( IO_WriteOnly ) ) { |
2517 | delete mSyncActionDialog; | 2474 | delete mSyncActionDialog; |
2518 | mSyncActionDialog = 0; | 2475 | mSyncActionDialog = 0; |
2519 | qDebug("error open cal file "); | 2476 | qDebug("error open cal file "); |
2520 | piFileString = ""; | 2477 | piFileString = ""; |
2521 | emit file_received( false ); | 2478 | emit file_received( false ); |
2522 | return ; | 2479 | return ; |
2523 | 2480 | ||
2524 | } | 2481 | } |
2525 | 2482 | ||
2526 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 2483 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
2527 | QTextStream ts ( &file ); | 2484 | QTextStream ts ( &file ); |
2528 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2485 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2529 | qDebug("finish "); | ||
2530 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 2486 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
2531 | ts << piFileString; | 2487 | ts << piFileString; |
2532 | mSocket->close(); | 2488 | mSocket->close(); |
2533 | if ( mSocket->state() == QSocket::Idle ) | 2489 | if ( mSocket->state() == QSocket::Idle ) |
2534 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 2490 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
2535 | file.close(); | 2491 | file.close(); |
2536 | delete mSyncActionDialog; | 2492 | delete mSyncActionDialog; |
2537 | mSyncActionDialog = 0; | 2493 | mSyncActionDialog = 0; |
2538 | piFileString = ""; | 2494 | piFileString = ""; |
2539 | emit file_received( true ); | 2495 | emit file_received( true ); |
2540 | 2496 | ||
2541 | } | 2497 | } |
2542 | 2498 | ||
2543 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 2499 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
2544 | { | 2500 | { |
2545 | mPassWord = password; | 2501 | mPassWord = password; |
2546 | mSocket = 0; | 2502 | mSocket = 0; |
2547 | mPort = port; | 2503 | mPort = port; |
2548 | mHost = host; | 2504 | mHost = host; |
2549 | 2505 | ||
2550 | mRetVal = false; | 2506 | mRetVal = false; |
2551 | mTimerSocket = new QTimer ( this ); | 2507 | mTimerSocket = new QTimer ( this ); |
2552 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 2508 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
2553 | } | 2509 | } |
2554 | void KCommandSocket::readFile( QString fn ) | 2510 | void KCommandSocket::readFile( QString fn ) |
2555 | { | 2511 | { |
2556 | if ( !mSocket ) { | 2512 | if ( !mSocket ) { |
2557 | mSocket = new QSocket( this ); | 2513 | mSocket = new QSocket( this ); |
2558 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 2514 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
2559 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2515 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2560 | } | 2516 | } |
2561 | mFileString = ""; | 2517 | mFileString = ""; |
2562 | mFileName = fn; | 2518 | mFileName = fn; |
2563 | mFirst = true; | 2519 | mFirst = true; |
2564 | mSocket->connectToHost( mHost, mPort ); | 2520 | mSocket->connectToHost( mHost, mPort ); |
2565 | QTextStream os( mSocket ); | 2521 | QTextStream os( mSocket ); |
2566 | os.setEncoding( QTextStream::UnicodeUTF8 ); | 2522 | os.setEncoding( QTextStream::UnicodeUTF8 ); |
2567 | os << "GET " << mPassWord << "\r\n"; | 2523 | os << "GET " << mPassWord << "\r\n"; |
2568 | mTimerSocket->start( 10000 ); | 2524 | mTimerSocket->start( 10000 ); |
2569 | } | 2525 | } |
2570 | 2526 | ||
2571 | void KCommandSocket::writeFile( QString fileName ) | 2527 | void KCommandSocket::writeFile( QString fileName ) |
2572 | { | 2528 | { |
2573 | QFile file2( fileName ); | 2529 | QFile file2( fileName ); |
2574 | if (!file2.open( IO_ReadOnly ) ) { | 2530 | if (!file2.open( IO_ReadOnly ) ) { |
2575 | mRetVal= false; | 2531 | mRetVal= false; |
2576 | deleteSocket(); | 2532 | deleteSocket(); |
2577 | return ; | 2533 | return ; |
2578 | 2534 | ||
2579 | } | 2535 | } |
2580 | if ( !mSocket ) { | 2536 | if ( !mSocket ) { |
2581 | mSocket = new QSocket( this ); | 2537 | mSocket = new QSocket( this ); |
2582 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2538 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2583 | } | 2539 | } |
2540 | mSocket->connectToHost( mHost, mPort ); | ||
2584 | QTextStream ts2( &file2 ); | 2541 | QTextStream ts2( &file2 ); |
2585 | ts2.setCodec( QTextCodec::codecForName("utf8") ); | 2542 | ts2.setCodec( QTextCodec::codecForName("utf8") ); |
2586 | QTextStream os2( mSocket ); | 2543 | QTextStream os2( mSocket ); |
2587 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2544 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2588 | os2 << "PUT " << mPassWord << "\r\n";; | 2545 | os2 << "PUT " << mPassWord << "\r\n";; |
2589 | while ( ! ts2.atEnd() ) { | 2546 | while ( ! ts2.atEnd() ) { |
2590 | os2 << ts2.readLine() << "\n"; | 2547 | os2 << ts2.readLine() << "\n"; |
2591 | } | 2548 | } |
2549 | mRetVal= true; | ||
2592 | mSocket->close(); | 2550 | mSocket->close(); |
2593 | if ( mSocket->state() == QSocket::Idle ) | 2551 | if ( mSocket->state() == QSocket::Idle ) |
2594 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 2552 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
2595 | file2.close(); | 2553 | file2.close(); |
2596 | } | 2554 | } |
2597 | 2555 | ||
2598 | void KCommandSocket::sendStop() | 2556 | void KCommandSocket::sendStop() |
2599 | { | 2557 | { |
2600 | if ( !mSocket ) { | 2558 | if ( !mSocket ) { |
2601 | mSocket = new QSocket( this ); | 2559 | mSocket = new QSocket( this ); |
2602 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2560 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2603 | } | 2561 | } |
2562 | mSocket->connectToHost( mHost, mPort ); | ||
2604 | QTextStream os2( mSocket ); | 2563 | QTextStream os2( mSocket ); |
2605 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2564 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2606 | os2 << "STOP\r\n"; | 2565 | os2 << "STOP\r\n"; |
2607 | mRetVal= true; | 2566 | mRetVal= true; |
2608 | mSocket->close(); | 2567 | mSocket->close(); |
2609 | if ( mSocket->state() == QSocket::Idle ) | 2568 | if ( mSocket->state() == QSocket::Idle ) |
2610 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 2569 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
2611 | } | 2570 | } |
2612 | 2571 | ||
2613 | void KCommandSocket::startReadFileFromSocket() | 2572 | void KCommandSocket::startReadFileFromSocket() |
2614 | { | 2573 | { |
2615 | if ( ! mFirst ) | 2574 | if ( ! mFirst ) |
2616 | return; | 2575 | return; |
2617 | mFirst = false; | 2576 | mFirst = false; |
2618 | mTimerSocket->stop(); | 2577 | mTimerSocket->stop(); |
2619 | mFileString = ""; | 2578 | mFileString = ""; |
2620 | mTime.start(); | 2579 | mTime.start(); |
2621 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 2580 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
2622 | 2581 | ||
2623 | } | 2582 | } |
2624 | void KCommandSocket::readFileFromSocket() | 2583 | void KCommandSocket::readFileFromSocket() |
2625 | { | 2584 | { |
2626 | qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 2585 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
2627 | while ( mSocket->canReadLine () ) { | 2586 | while ( mSocket->canReadLine () ) { |
2628 | mTime.restart(); | 2587 | mTime.restart(); |
2629 | QString line = mSocket->readLine (); | 2588 | QString line = mSocket->readLine (); |
2630 | mFileString += line; | 2589 | mFileString += line; |
2631 | qDebug("readline: %s ", line.latin1()); | 2590 | //qDebug("readline: %s ", line.latin1()); |
2632 | } | 2591 | } |
2633 | if ( mTime.elapsed () < 3000 ) { | 2592 | if ( mTime.elapsed () < 3000 ) { |
2634 | // wait for more | 2593 | // wait for more |
2635 | qDebug("waitformore "); | 2594 | //qDebug("waitformore "); |
2636 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 2595 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
2637 | return; | 2596 | return; |
2638 | } | 2597 | } |
2639 | QString fileName = mFileName; | 2598 | QString fileName = mFileName; |
2640 | QFile file ( fileName ); | 2599 | QFile file ( fileName ); |
2641 | if (!file.open( IO_WriteOnly ) ) { | 2600 | if (!file.open( IO_WriteOnly ) ) { |
2642 | mFileString = ""; | 2601 | mFileString = ""; |
2643 | mRetVal = false; | 2602 | mRetVal = false; |
2644 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | 2603 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); |
2645 | deleteSocket(); | 2604 | deleteSocket(); |
2646 | return ; | 2605 | return ; |
2647 | 2606 | ||
2648 | } | 2607 | } |
2649 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 2608 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
2650 | QTextStream ts ( &file ); | 2609 | QTextStream ts ( &file ); |
2651 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2610 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2652 | qDebug("finish "); | ||
2653 | ts << mFileString; | 2611 | ts << mFileString; |
2654 | file.close(); | 2612 | file.close(); |
2655 | mFileString = ""; | 2613 | mFileString = ""; |
2656 | mRetVal = true; | 2614 | mRetVal = true; |
2657 | mSocket->close(); | 2615 | mSocket->close(); |
2658 | // if state is not idle, deleteSocket(); is called via | 2616 | // if state is not idle, deleteSocket(); is called via |
2659 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2617 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2660 | if ( mSocket->state() == QSocket::Idle ) | 2618 | if ( mSocket->state() == QSocket::Idle ) |
2661 | deleteSocket(); | 2619 | deleteSocket(); |
2662 | } | 2620 | } |
2663 | 2621 | ||
2664 | void KCommandSocket::deleteSocket() | 2622 | void KCommandSocket::deleteSocket() |
2665 | { | 2623 | { |
2666 | if ( mTimerSocket->isActive () ) { | 2624 | if ( mTimerSocket->isActive () ) { |
2667 | mTimerSocket->stop(); | 2625 | mTimerSocket->stop(); |
2668 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 2626 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
2669 | mRetVal = false; | 2627 | mRetVal = false; |
2670 | } | 2628 | } |
2671 | qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 2629 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
2672 | if ( mSocket) | 2630 | if ( mSocket) |
2673 | delete mSocket; | 2631 | delete mSocket; |
2674 | mSocket = 0; | 2632 | mSocket = 0; |
2675 | emit commandFinished( this, mRetVal ); | 2633 | emit commandFinished( this, mRetVal ); |
2676 | } | 2634 | } |
2677 | 2635 | ||
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 5a67765..f8b2334 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -22,188 +22,188 @@ class KSyncProfile; | |||
22 | #endif | 22 | #endif |
23 | class QPEToolBar; | 23 | class QPEToolBar; |
24 | #include <qserversocket.h> | 24 | #include <qserversocket.h> |
25 | #include <qsocket.h> | 25 | #include <qsocket.h> |
26 | #include <qnetworkprotocol.h> | 26 | #include <qnetworkprotocol.h> |
27 | 27 | ||
28 | class KServerSocket : public QServerSocket | 28 | class KServerSocket : public QServerSocket |
29 | { | 29 | { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | 31 | ||
32 | public: | 32 | public: |
33 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | 33 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
34 | 34 | ||
35 | void newConnection ( int socket ) ; | 35 | void newConnection ( int socket ) ; |
36 | void setFileName( QString fn ) {mFileName = fn;}; | 36 | void setFileName( QString fn ) {mFileName = fn;}; |
37 | 37 | ||
38 | signals: | 38 | signals: |
39 | //void sendFile(QSocket*); | 39 | //void sendFile(QSocket*); |
40 | //void getFile(QSocket*); | 40 | //void getFile(QSocket*); |
41 | void file_received( bool ); | 41 | void file_received( bool ); |
42 | //void file_sent(); | 42 | //void file_sent(); |
43 | void saveFile(); | 43 | void saveFile(); |
44 | void endConnect(); | 44 | void endConnect(); |
45 | private slots: | 45 | private slots: |
46 | void discardClient(); | 46 | void discardClient(); |
47 | void readClient(); | 47 | void readClient(); |
48 | void readBackFileFromSocket(); | 48 | void readBackFileFromSocket(); |
49 | private : | 49 | private : |
50 | void send_file(); | 50 | void send_file(); |
51 | void get_file(); | 51 | void get_file(); |
52 | void end_connect(); | 52 | void end_connect(); |
53 | QDialog* mSyncActionDialog; | 53 | QDialog* mSyncActionDialog; |
54 | QSocket* mSocket; | 54 | QSocket* mSocket; |
55 | QString mPassWord; | 55 | QString mPassWord; |
56 | QString mFileName; | 56 | QString mFileName; |
57 | QTime piTime; | 57 | QTime piTime; |
58 | QString piFileString; | 58 | QString piFileString; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | class KCommandSocket : public QObject | 61 | class KCommandSocket : public QObject |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | 64 | ||
65 | public: | 65 | public: |
66 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 66 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
67 | void readFile( QString ); | 67 | void readFile( QString ); |
68 | void writeFile( QString ); | 68 | void writeFile( QString ); |
69 | void sendStop(); | 69 | void sendStop(); |
70 | 70 | ||
71 | 71 | ||
72 | signals: | 72 | signals: |
73 | void commandFinished( KCommandSocket*, bool ); | 73 | void commandFinished( KCommandSocket*, bool ); |
74 | private slots: | 74 | private slots: |
75 | void startReadFileFromSocket(); | 75 | void startReadFileFromSocket(); |
76 | void readFileFromSocket(); | 76 | void readFileFromSocket(); |
77 | void deleteSocket(); | 77 | void deleteSocket(); |
78 | private : | 78 | private : |
79 | QSocket* mSocket; | 79 | QSocket* mSocket; |
80 | QString mPassWord; | 80 | QString mPassWord; |
81 | Q_UINT16 mPort; | 81 | Q_UINT16 mPort; |
82 | QString mHost; | 82 | QString mHost; |
83 | QString mFileName; | 83 | QString mFileName; |
84 | QTimer* mTimerSocket; | 84 | QTimer* mTimerSocket; |
85 | bool mRetVal; | 85 | bool mRetVal; |
86 | QTime mTime; | 86 | QTime mTime; |
87 | QString mFileString; | 87 | QString mFileString; |
88 | bool mFirst; | 88 | bool mFirst; |
89 | }; | 89 | }; |
90 | 90 | ||
91 | namespace KCal { | 91 | namespace KCal { |
92 | class CalendarLocal; | 92 | class CalendarLocal; |
93 | } | 93 | } |
94 | 94 | ||
95 | using namespace KCal; | 95 | using namespace KCal; |
96 | 96 | ||
97 | class MainWindow : public QMainWindow | 97 | class MainWindow : public QMainWindow |
98 | { | 98 | { |
99 | Q_OBJECT | 99 | Q_OBJECT |
100 | public: | 100 | public: |
101 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 101 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
102 | ~MainWindow(); | 102 | ~MainWindow(); |
103 | public slots: | 103 | public slots: |
104 | virtual void showMaximized (); | 104 | virtual void showMaximized (); |
105 | void configureAgenda( int ); | 105 | void configureAgenda( int ); |
106 | void recieve( const QCString& msg, const QByteArray& data ); | 106 | void recieve( const QCString& msg, const QByteArray& data ); |
107 | static QString defaultFileName(); | 107 | static QString defaultFileName(); |
108 | static QString resourcePath(); | 108 | static QString resourcePath(); |
109 | protected slots: | 109 | protected slots: |
110 | void setCaptionToDates(); | 110 | void setCaptionToDates(); |
111 | int ringSync(); | 111 | int ringSync(); |
112 | void multiSync( bool askforPrefs = false ); | 112 | void multiSync( bool askforPrefs = false ); |
113 | void about(); | 113 | void about(); |
114 | void licence(); | 114 | void licence(); |
115 | void faq(); | 115 | void faq(); |
116 | void usertrans(); | 116 | void usertrans(); |
117 | void features(); | 117 | void features(); |
118 | void synchowto(); | 118 | void synchowto(); |
119 | void whatsNew(); | 119 | void whatsNew(); |
120 | void keyBindings(); | 120 | void keyBindings(); |
121 | void aboutAutoSaving();; | 121 | void aboutAutoSaving();; |
122 | void aboutKnownBugs(); | 122 | void aboutKnownBugs(); |
123 | 123 | ||
124 | void processIncidenceSelection( Incidence * ); | 124 | void processIncidenceSelection( Incidence * ); |
125 | 125 | ||
126 | void importQtopia(); | 126 | void importQtopia(); |
127 | void importBday(); | 127 | void importBday(); |
128 | void importOL(); | 128 | void importOL(); |
129 | void importIcal(); | 129 | void importIcal(); |
130 | void importFile( QString, bool ); | 130 | void importFile( QString, bool ); |
131 | void quickImportIcal(); | 131 | void quickImportIcal(); |
132 | 132 | ||
133 | void slotModifiedChanged( bool ); | 133 | void slotModifiedChanged( bool ); |
134 | 134 | ||
135 | void save(); | 135 | void save(); |
136 | void configureToolBar( int ); | 136 | void configureToolBar( int ); |
137 | void printSel(); | 137 | void printSel(); |
138 | void printCal(); | 138 | void printCal(); |
139 | void saveCalendar(); | 139 | void saveCalendar(); |
140 | void loadCalendar(); | 140 | void loadCalendar(); |
141 | void exportVCalendar(); | 141 | void exportVCalendar(); |
142 | void fillFilterMenu(); | 142 | void fillFilterMenu(); |
143 | void selectFilter( int ); | 143 | void selectFilter( int ); |
144 | 144 | ||
145 | void slotSyncMenu( int ); | 145 | void slotSyncMenu( int ); |
146 | void syncSSH(); | 146 | void syncSSH(); |
147 | void confSync(); | 147 | void confSync(); |
148 | void syncSharp(); | 148 | void syncSharp(); |
149 | void syncPhone(); | 149 | void syncPhone(); |
150 | void syncPi(); | ||
150 | void syncLocalFile(); | 151 | void syncLocalFile(); |
151 | bool syncWithFile( QString, bool ); | 152 | bool syncWithFile( QString, bool ); |
152 | void quickSyncLocalFile(); | 153 | void quickSyncLocalFile(); |
153 | 154 | ||
154 | 155 | ||
155 | protected: | 156 | protected: |
156 | void displayText( QString, QString); | 157 | void displayText( QString, QString); |
157 | void displayFile( QString, QString); | 158 | void displayFile( QString, QString); |
158 | 159 | ||
159 | void enableIncidenceActions( bool ); | 160 | void enableIncidenceActions( bool ); |
160 | 161 | ||
161 | private slots: | 162 | private slots: |
162 | QSocket* piSocket; | 163 | QSocket* piSocket; |
163 | QString piFileString; | 164 | QString piFileString; |
164 | QTime piTime; | 165 | QTime piTime; |
165 | void deleteCommandSocket(KCommandSocket* s, bool success); | 166 | void deleteCommandSocket(KCommandSocket* s, bool success); |
166 | void deleteCommandSocketFinish(KCommandSocket* s, bool success); | 167 | void deleteCommandSocketFinish(KCommandSocket* s, bool success); |
167 | void fillSyncMenu(); | 168 | void fillSyncMenu(); |
168 | void getFile( bool ); | 169 | void getFile( bool ); |
169 | void readFileFromSocket(); | 170 | void readFileFromSocket(); |
170 | private: | 171 | private: |
171 | //QTimer* mTimerCommandSocket; | 172 | //QTimer* mTimerCommandSocket; |
172 | QString mPassWordPiSync; | 173 | QString mPassWordPiSync; |
173 | KServerSocket * mServerSocket; | 174 | KServerSocket * mServerSocket; |
174 | bool mClosed; | 175 | bool mClosed; |
175 | void saveOnClose(); | 176 | void saveOnClose(); |
176 | int mCurrentSyncProfile; | 177 | int mCurrentSyncProfile; |
177 | void enableQuick(); | 178 | void enableQuick(); |
178 | void performQuick(); | ||
179 | void performQuickQuick(); | 179 | void performQuickQuick(); |
180 | void syncRemote( KSyncProfile* , bool ask = true); | 180 | void syncRemote( KSyncProfile* , bool ask = true); |
181 | bool mFlagKeyPressed; | 181 | bool mFlagKeyPressed; |
182 | bool mBlockAtStartup; | 182 | bool mBlockAtStartup; |
183 | QPEToolBar *iconToolBar; | 183 | QPEToolBar *iconToolBar; |
184 | void initActions(); | 184 | void initActions(); |
185 | void setDefaultPreferences(); | 185 | void setDefaultPreferences(); |
186 | void keyPressEvent ( QKeyEvent * ) ; | 186 | void keyPressEvent ( QKeyEvent * ) ; |
187 | void keyReleaseEvent ( QKeyEvent * ) ; | 187 | void keyReleaseEvent ( QKeyEvent * ) ; |
188 | QPopupMenu *configureToolBarMenu; | 188 | QPopupMenu *configureToolBarMenu; |
189 | QPopupMenu *selectFilterMenu; | 189 | QPopupMenu *selectFilterMenu; |
190 | QPopupMenu *configureAgendaMenu, *syncMenu; | 190 | QPopupMenu *configureAgendaMenu, *syncMenu; |
191 | CalendarLocal *mCalendar; | 191 | CalendarLocal *mCalendar; |
192 | CalendarView *mView; | 192 | CalendarView *mView; |
193 | QString getPassword(); | 193 | QString getPassword(); |
194 | QAction *mNewSubTodoAction; | 194 | QAction *mNewSubTodoAction; |
195 | 195 | ||
196 | QAction *mShowAction; | 196 | QAction *mShowAction; |
197 | QAction *mEditAction; | 197 | QAction *mEditAction; |
198 | QAction *mDeleteAction; | 198 | QAction *mDeleteAction; |
199 | void closeEvent( QCloseEvent* ce ); | 199 | void closeEvent( QCloseEvent* ce ); |
200 | SimpleAlarmClient mAlarmClient; | 200 | SimpleAlarmClient mAlarmClient; |
201 | QTimer mSaveTimer; | 201 | QTimer mSaveTimer; |
202 | bool mBlockSaveFlag; | 202 | bool mBlockSaveFlag; |
203 | bool mCalendarModifiedFlag; | 203 | bool mCalendarModifiedFlag; |
204 | QPixmap loadPixmap( QString ); | 204 | QPixmap loadPixmap( QString ); |
205 | QDialog * mSyncActionDialog; | 205 | QDialog * mSyncActionDialog; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | #endif | 209 | #endif |