-rw-r--r-- | libkdepim/ksyncmanager.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 0109c02..28c48fe 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -660,364 +660,363 @@ int KSyncManager::ringSync() | |||
660 | syncPhone(); | 660 | syncPhone(); |
661 | } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { | 661 | } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { |
662 | mSpecificResources.clear(); | 662 | mSpecificResources.clear(); |
663 | if ( mTargetApp == KAPI ) { | 663 | if ( mTargetApp == KAPI ) { |
664 | mPassWordPiSync = temp->getRemotePwAB(); | 664 | mPassWordPiSync = temp->getRemotePwAB(); |
665 | mActiveSyncPort = temp->getRemotePortAB(); | 665 | mActiveSyncPort = temp->getRemotePortAB(); |
666 | mActiveSyncIP = temp->getRemoteIPAB(); | 666 | mActiveSyncIP = temp->getRemoteIPAB(); |
667 | } else if ( mTargetApp == KOPI ) { | 667 | } else if ( mTargetApp == KOPI ) { |
668 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); | 668 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); |
669 | mPassWordPiSync = temp->getRemotePw(); | 669 | mPassWordPiSync = temp->getRemotePw(); |
670 | mActiveSyncPort = temp->getRemotePort(); | 670 | mActiveSyncPort = temp->getRemotePort(); |
671 | mActiveSyncIP = temp->getRemoteIP(); | 671 | mActiveSyncIP = temp->getRemoteIP(); |
672 | } else { | 672 | } else { |
673 | mPassWordPiSync = temp->getRemotePwPWM(); | 673 | mPassWordPiSync = temp->getRemotePwPWM(); |
674 | mActiveSyncPort = temp->getRemotePortPWM(); | 674 | mActiveSyncPort = temp->getRemotePortPWM(); |
675 | mActiveSyncIP = temp->getRemoteIPPWM(); | 675 | mActiveSyncIP = temp->getRemoteIPPWM(); |
676 | } | 676 | } |
677 | syncPi(); | 677 | syncPi(); |
678 | while ( !mPisyncFinished ) { | 678 | while ( !mPisyncFinished ) { |
679 | //qDebug("waiting "); | 679 | //qDebug("waiting "); |
680 | qApp->processEvents(); | 680 | qApp->processEvents(); |
681 | } | 681 | } |
682 | timer.start(); | 682 | timer.start(); |
683 | while ( timer.elapsed () < 2000 ) { | 683 | while ( timer.elapsed () < 2000 ) { |
684 | qApp->processEvents(); | 684 | qApp->processEvents(); |
685 | } | 685 | } |
686 | } else | 686 | } else |
687 | syncRemote( temp, false ); | 687 | syncRemote( temp, false ); |
688 | 688 | ||
689 | } | 689 | } |
690 | } | 690 | } |
691 | timer.start(); | 691 | timer.start(); |
692 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 692 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
693 | while ( timer.elapsed () < 2000 ) { | 693 | while ( timer.elapsed () < 2000 ) { |
694 | qApp->processEvents(); | 694 | qApp->processEvents(); |
695 | #ifndef _WIN32_ | 695 | #ifndef _WIN32_ |
696 | sleep (1); | 696 | sleep (1); |
697 | #endif | 697 | #endif |
698 | } | 698 | } |
699 | 699 | ||
700 | } | 700 | } |
701 | 701 | ||
702 | } | 702 | } |
703 | delete temp; | 703 | delete temp; |
704 | return syncedProfiles; | 704 | return syncedProfiles; |
705 | } | 705 | } |
706 | 706 | ||
707 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 707 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
708 | { | 708 | { |
709 | QString question; | 709 | QString question; |
710 | if ( ask ) { | 710 | if ( ask ) { |
711 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 711 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
712 | if ( QMessageBox::information( mParent, i18n("Sync"), | 712 | if ( QMessageBox::information( mParent, i18n("Sync"), |
713 | question, | 713 | question, |
714 | i18n("Yes"), i18n("No"), | 714 | i18n("Yes"), i18n("No"), |
715 | 0, 0 ) != 0 ) | 715 | 0, 0 ) != 0 ) |
716 | return; | 716 | return; |
717 | } | 717 | } |
718 | 718 | ||
719 | QString preCommand; | 719 | QString preCommand; |
720 | QString localTempFile; | 720 | QString localTempFile; |
721 | QString postCommand; | 721 | QString postCommand; |
722 | 722 | ||
723 | switch(mTargetApp) | 723 | switch(mTargetApp) |
724 | { | 724 | { |
725 | case (KAPI): | 725 | case (KAPI): |
726 | preCommand = prof->getPreSyncCommandAB(); | 726 | preCommand = prof->getPreSyncCommandAB(); |
727 | postCommand = prof->getPostSyncCommandAB(); | 727 | postCommand = prof->getPostSyncCommandAB(); |
728 | localTempFile = prof->getLocalTempFileAB(); | 728 | localTempFile = prof->getLocalTempFileAB(); |
729 | break; | 729 | break; |
730 | case (KOPI): | 730 | case (KOPI): |
731 | preCommand = prof->getPreSyncCommand(); | 731 | preCommand = prof->getPreSyncCommand(); |
732 | postCommand = prof->getPostSyncCommand(); | 732 | postCommand = prof->getPostSyncCommand(); |
733 | localTempFile = prof->getLocalTempFile(); | 733 | localTempFile = prof->getLocalTempFile(); |
734 | break; | 734 | break; |
735 | case (PWMPI): | 735 | case (PWMPI): |
736 | preCommand = prof->getPreSyncCommandPWM(); | 736 | preCommand = prof->getPreSyncCommandPWM(); |
737 | postCommand = prof->getPostSyncCommandPWM(); | 737 | postCommand = prof->getPostSyncCommandPWM(); |
738 | localTempFile = prof->getLocalTempFilePWM(); | 738 | localTempFile = prof->getLocalTempFilePWM(); |
739 | break; | 739 | break; |
740 | default: | 740 | default: |
741 | qDebug("KSM::syncRemote: invalid apptype selected"); | 741 | qDebug("KSM::syncRemote: invalid apptype selected"); |
742 | break; | 742 | break; |
743 | } | 743 | } |
744 | 744 | ||
745 | 745 | ||
746 | int fi; | 746 | int fi; |
747 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 747 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
748 | QString pwd = getPassword(); | 748 | QString pwd = getPassword(); |
749 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 749 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
750 | 750 | ||
751 | } | 751 | } |
752 | int maxlen = 30; | 752 | int maxlen = 30; |
753 | if ( QApplication::desktop()->width() > 320 ) | 753 | if ( QApplication::desktop()->width() > 320 ) |
754 | maxlen += 25; | 754 | maxlen += 25; |
755 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 755 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
756 | int fileSize = 0; | ||
757 | int result = system ( preCommand ); | 756 | int result = system ( preCommand ); |
758 | // 0 : okay | 757 | // 0 : okay |
759 | // 256: no such file or dir | 758 | // 256: no such file or dir |
760 | // | 759 | // |
761 | qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); | 760 | qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); |
762 | if ( result != 0 ) { | 761 | if ( result != 0 ) { |
763 | unsigned int len = maxlen; | 762 | unsigned int len = maxlen; |
764 | while ( len < preCommand.length() ) { | 763 | while ( len < preCommand.length() ) { |
765 | preCommand.insert( len , "\n" ); | 764 | preCommand.insert( len , "\n" ); |
766 | len += maxlen +2; | 765 | len += maxlen +2; |
767 | } | 766 | } |
768 | 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 (preCommand) ; | 767 | 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 (preCommand) ; |
769 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 768 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
770 | question, | 769 | question, |
771 | i18n("Okay!")) ; | 770 | i18n("Okay!")) ; |
772 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 771 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
773 | return; | 772 | return; |
774 | } | 773 | } |
775 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 774 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
776 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 775 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
777 | 776 | ||
778 | if ( syncWithFile( localTempFile, true ) ) { | 777 | if ( syncWithFile( localTempFile, true ) ) { |
779 | 778 | ||
780 | if ( mWriteBackFile ) { | 779 | if ( mWriteBackFile ) { |
781 | int fi; | 780 | int fi; |
782 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 781 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
783 | QString pwd = getPassword(); | 782 | QString pwd = getPassword(); |
784 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 783 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
785 | 784 | ||
786 | } | 785 | } |
787 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 786 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
788 | result = system ( postCommand ); | 787 | result = system ( postCommand ); |
789 | qDebug("KSM::Sync:Writing back file result: %d ", result); | 788 | qDebug("KSM::Sync:Writing back file result: %d ", result); |
790 | if ( result != 0 ) { | 789 | if ( result != 0 ) { |
791 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 790 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
792 | return; | 791 | return; |
793 | } else { | 792 | } else { |
794 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 793 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
795 | } | 794 | } |
796 | } | 795 | } |
797 | } | 796 | } |
798 | return; | 797 | return; |
799 | } | 798 | } |
800 | bool KSyncManager::edit_pisync_options() | 799 | bool KSyncManager::edit_pisync_options() |
801 | { | 800 | { |
802 | QDialog dia( mParent, "dia", true ); | 801 | QDialog dia( mParent, "dia", true ); |
803 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 802 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
804 | QVBoxLayout lay ( &dia ); | 803 | QVBoxLayout lay ( &dia ); |
805 | lay.setSpacing( 5 ); | 804 | lay.setSpacing( 5 ); |
806 | lay.setMargin( 3 ); | 805 | lay.setMargin( 3 ); |
807 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 806 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
808 | lay.addWidget( &lab1 ); | 807 | lay.addWidget( &lab1 ); |
809 | QLineEdit le1 (&dia ); | 808 | QLineEdit le1 (&dia ); |
810 | lay.addWidget( &le1 ); | 809 | lay.addWidget( &le1 ); |
811 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 810 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
812 | lay.addWidget( &lab2 ); | 811 | lay.addWidget( &lab2 ); |
813 | QLineEdit le2 (&dia ); | 812 | QLineEdit le2 (&dia ); |
814 | lay.addWidget( &le2 ); | 813 | lay.addWidget( &le2 ); |
815 | QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); | 814 | QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); |
816 | lay.addWidget( &lab3 ); | 815 | lay.addWidget( &lab3 ); |
817 | QLineEdit le3 (&dia ); | 816 | QLineEdit le3 (&dia ); |
818 | lay.addWidget( &le3 ); | 817 | lay.addWidget( &le3 ); |
819 | QPushButton pb ( "OK", &dia); | 818 | QPushButton pb ( "OK", &dia); |
820 | lay.addWidget( &pb ); | 819 | lay.addWidget( &pb ); |
821 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 820 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
822 | le1.setText( mPassWordPiSync ); | 821 | le1.setText( mPassWordPiSync ); |
823 | le2.setText( mActiveSyncIP ); | 822 | le2.setText( mActiveSyncIP ); |
824 | le3.setText( mActiveSyncPort ); | 823 | le3.setText( mActiveSyncPort ); |
825 | if ( dia.exec() ) { | 824 | if ( dia.exec() ) { |
826 | mPassWordPiSync = le1.text(); | 825 | mPassWordPiSync = le1.text(); |
827 | mActiveSyncPort = le3.text(); | 826 | mActiveSyncPort = le3.text(); |
828 | mActiveSyncIP = le2.text(); | 827 | mActiveSyncIP = le2.text(); |
829 | return true; | 828 | return true; |
830 | } | 829 | } |
831 | return false; | 830 | return false; |
832 | } | 831 | } |
833 | bool KSyncManager::edit_sync_options() | 832 | bool KSyncManager::edit_sync_options() |
834 | { | 833 | { |
835 | 834 | ||
836 | QDialog dia( mParent, "dia", true ); | 835 | QDialog dia( mParent, "dia", true ); |
837 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 836 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
838 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 837 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
839 | QVBoxLayout lay ( &dia ); | 838 | QVBoxLayout lay ( &dia ); |
840 | lay.setSpacing( 2 ); | 839 | lay.setSpacing( 2 ); |
841 | lay.setMargin( 3 ); | 840 | lay.setMargin( 3 ); |
842 | lay.addWidget(&gr); | 841 | lay.addWidget(&gr); |
843 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 842 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
844 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 843 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
845 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 844 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
846 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 845 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
847 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 846 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
848 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 847 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
849 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 848 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
850 | QPushButton pb ( "OK", &dia); | 849 | QPushButton pb ( "OK", &dia); |
851 | lay.addWidget( &pb ); | 850 | lay.addWidget( &pb ); |
852 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 851 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
853 | switch ( mSyncAlgoPrefs ) { | 852 | switch ( mSyncAlgoPrefs ) { |
854 | case 0: | 853 | case 0: |
855 | loc.setChecked( true); | 854 | loc.setChecked( true); |
856 | break; | 855 | break; |
857 | case 1: | 856 | case 1: |
858 | rem.setChecked( true ); | 857 | rem.setChecked( true ); |
859 | break; | 858 | break; |
860 | case 2: | 859 | case 2: |
861 | newest.setChecked( true); | 860 | newest.setChecked( true); |
862 | break; | 861 | break; |
863 | case 3: | 862 | case 3: |
864 | ask.setChecked( true); | 863 | ask.setChecked( true); |
865 | break; | 864 | break; |
866 | case 4: | 865 | case 4: |
867 | f_loc.setChecked( true); | 866 | f_loc.setChecked( true); |
868 | break; | 867 | break; |
869 | case 5: | 868 | case 5: |
870 | f_rem.setChecked( true); | 869 | f_rem.setChecked( true); |
871 | break; | 870 | break; |
872 | case 6: | 871 | case 6: |
873 | // both.setChecked( true); | 872 | // both.setChecked( true); |
874 | break; | 873 | break; |
875 | default: | 874 | default: |
876 | break; | 875 | break; |
877 | } | 876 | } |
878 | if ( dia.exec() ) { | 877 | if ( dia.exec() ) { |
879 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 878 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
880 | return true; | 879 | return true; |
881 | } | 880 | } |
882 | return false; | 881 | return false; |
883 | } | 882 | } |
884 | 883 | ||
885 | QString KSyncManager::getPassword( ) | 884 | QString KSyncManager::getPassword( ) |
886 | { | 885 | { |
887 | QString retfile = ""; | 886 | QString retfile = ""; |
888 | QDialog dia ( mParent, "input-dialog", true ); | 887 | QDialog dia ( mParent, "input-dialog", true ); |
889 | QLineEdit lab ( &dia ); | 888 | QLineEdit lab ( &dia ); |
890 | lab.setEchoMode( QLineEdit::Password ); | 889 | lab.setEchoMode( QLineEdit::Password ); |
891 | QVBoxLayout lay( &dia ); | 890 | QVBoxLayout lay( &dia ); |
892 | lay.setMargin(7); | 891 | lay.setMargin(7); |
893 | lay.setSpacing(7); | 892 | lay.setSpacing(7); |
894 | lay.addWidget( &lab); | 893 | lay.addWidget( &lab); |
895 | dia.setFixedSize( 230,50 ); | 894 | dia.setFixedSize( 230,50 ); |
896 | dia.setCaption( i18n("Enter password") ); | 895 | dia.setCaption( i18n("Enter password") ); |
897 | QPushButton pb ( "OK", &dia); | 896 | QPushButton pb ( "OK", &dia); |
898 | lay.addWidget( &pb ); | 897 | lay.addWidget( &pb ); |
899 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 898 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
900 | dia.show(); | 899 | dia.show(); |
901 | int res = dia.exec(); | 900 | int res = dia.exec(); |
902 | if ( res ) | 901 | if ( res ) |
903 | retfile = lab.text(); | 902 | retfile = lab.text(); |
904 | dia.hide(); | 903 | dia.hide(); |
905 | qApp->processEvents(); | 904 | qApp->processEvents(); |
906 | return retfile; | 905 | return retfile; |
907 | 906 | ||
908 | } | 907 | } |
909 | 908 | ||
910 | 909 | ||
911 | void KSyncManager::confSync() | 910 | void KSyncManager::confSync() |
912 | { | 911 | { |
913 | static KSyncPrefsDialog* sp = 0; | 912 | static KSyncPrefsDialog* sp = 0; |
914 | if ( ! sp ) { | 913 | if ( ! sp ) { |
915 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 914 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
916 | } | 915 | } |
917 | sp->usrReadConfig(); | 916 | sp->usrReadConfig(); |
918 | #ifndef DESKTOP_VERSION | 917 | #ifndef DESKTOP_VERSION |
919 | sp->showMaximized(); | 918 | sp->showMaximized(); |
920 | #else | 919 | #else |
921 | sp->show(); | 920 | sp->show(); |
922 | #endif | 921 | #endif |
923 | sp->exec(); | 922 | sp->exec(); |
924 | QStringList oldSyncProfileNames = mSyncProfileNames; | 923 | QStringList oldSyncProfileNames = mSyncProfileNames; |
925 | mSyncProfileNames = sp->getSyncProfileNames(); | 924 | mSyncProfileNames = sp->getSyncProfileNames(); |
926 | mLocalMachineName = sp->getLocalMachineName (); | 925 | mLocalMachineName = sp->getLocalMachineName (); |
927 | int ii; | 926 | uint ii; |
928 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 927 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
929 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 928 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
930 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 929 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
931 | } | 930 | } |
932 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 931 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
933 | } | 932 | } |
934 | void KSyncManager::syncKDE() | 933 | void KSyncManager::syncKDE() |
935 | { | 934 | { |
936 | mSyncWithDesktop = true; | 935 | mSyncWithDesktop = true; |
937 | emit save(); | 936 | emit save(); |
938 | switch(mTargetApp) | 937 | switch(mTargetApp) |
939 | { | 938 | { |
940 | case (KAPI): | 939 | case (KAPI): |
941 | { | 940 | { |
942 | #ifdef DESKTOP_VERSION | 941 | #ifdef DESKTOP_VERSION |
943 | QString command = "kdeabdump33"; | 942 | QString command = "kdeabdump33"; |
944 | QString commandfile = "kdeabdump33"; | 943 | QString commandfile = "kdeabdump33"; |
945 | QString commandpath = qApp->applicationDirPath () + "/"; | 944 | QString commandpath = qApp->applicationDirPath () + "/"; |
946 | #else | 945 | #else |
947 | QString command = "kdeabdump33"; | 946 | QString command = "kdeabdump33"; |
948 | QString commandfile = "kdeabdump33"; | 947 | QString commandfile = "kdeabdump33"; |
949 | QString commandpath = QDir::homeDirPath ()+"/"; | 948 | QString commandpath = QDir::homeDirPath ()+"/"; |
950 | #endif | 949 | #endif |
951 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 950 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
952 | command = commandfile; | 951 | command = commandfile; |
953 | else | 952 | else |
954 | command = commandpath+commandfile; | 953 | command = commandpath+commandfile; |
955 | 954 | ||
956 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 955 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
957 | int result = system ( command.latin1()); | 956 | int result = system ( command.latin1()); |
958 | qDebug("AB dump 33 command call result: %d ", result); | 957 | qDebug("AB dump 33 command call result: %d ", result); |
959 | if ( result != 0 ) { | 958 | if ( result != 0 ) { |
960 | qDebug("Calling AB dump version 33 failed. Trying 34... "); | 959 | qDebug("Calling AB dump version 33 failed. Trying 34... "); |
961 | commandfile = "kdeabdump34"; | 960 | commandfile = "kdeabdump34"; |
962 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 961 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
963 | command = commandfile; | 962 | command = commandfile; |
964 | else | 963 | else |
965 | command = commandpath+commandfile; | 964 | command = commandpath+commandfile; |
966 | result = system ( command.latin1()); | 965 | result = system ( command.latin1()); |
967 | qDebug("AB dump 34 command call result: %d ", result); | 966 | qDebug("AB dump 34 command call result: %d ", result); |
968 | if ( result != 0 ) { | 967 | if ( result != 0 ) { |
969 | KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); | 968 | KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); |
970 | return; | 969 | return; |
971 | } | 970 | } |
972 | } | 971 | } |
973 | if ( syncWithFile( fileName,true ) ) { | 972 | if ( syncWithFile( fileName,true ) ) { |
974 | if ( mWriteBackFile ) { | 973 | if ( mWriteBackFile ) { |
975 | command += " --read"; | 974 | command += " --read"; |
976 | system ( command.latin1()); | 975 | system ( command.latin1()); |
977 | } | 976 | } |
978 | } | 977 | } |
979 | 978 | ||
980 | } | 979 | } |
981 | break; | 980 | break; |
982 | case (KOPI): | 981 | case (KOPI): |
983 | { | 982 | { |
984 | #ifdef DESKTOP_VERSION | 983 | #ifdef DESKTOP_VERSION |
985 | QString command = "kdecaldump33"; | 984 | QString command = "kdecaldump33"; |
986 | QString commandfile = "kdecaldump33"; | 985 | QString commandfile = "kdecaldump33"; |
987 | QString commandpath = qApp->applicationDirPath () + "/"; | 986 | QString commandpath = qApp->applicationDirPath () + "/"; |
988 | #else | 987 | #else |
989 | QString command = "kdecaldump33"; | 988 | QString command = "kdecaldump33"; |
990 | QString commandfile = "kdecaldump33"; | 989 | QString commandfile = "kdecaldump33"; |
991 | QString commandpath = QDir::homeDirPath ()+"/"; | 990 | QString commandpath = QDir::homeDirPath ()+"/"; |
992 | #endif | 991 | #endif |
993 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 992 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
994 | command = commandfile; | 993 | command = commandfile; |
995 | else | 994 | else |
996 | command = commandpath+commandfile; | 995 | command = commandpath+commandfile; |
997 | 996 | ||
998 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 997 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
999 | int result = system ( command.latin1()); | 998 | int result = system ( command.latin1()); |
1000 | qDebug("Cal dump 33 command call result result: %d ", result); | 999 | qDebug("Cal dump 33 command call result result: %d ", result); |
1001 | if ( result != 0 ) { | 1000 | if ( result != 0 ) { |
1002 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); | 1001 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); |
1003 | commandfile = "kdecaldump34"; | 1002 | commandfile = "kdecaldump34"; |
1004 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 1003 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
1005 | command = commandfile; | 1004 | command = commandfile; |
1006 | else | 1005 | else |
1007 | command = commandpath+commandfile; | 1006 | command = commandpath+commandfile; |
1008 | result = system ( command.latin1()); | 1007 | result = system ( command.latin1()); |
1009 | qDebug("Cal dump 34 command call result result: %d ", result); | 1008 | qDebug("Cal dump 34 command call result result: %d ", result); |
1010 | if ( result != 0 ) { | 1009 | if ( result != 0 ) { |
1011 | KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); | 1010 | KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); |
1012 | return; | 1011 | return; |
1013 | } | 1012 | } |
1014 | } | 1013 | } |
1015 | if ( syncWithFile( fileName,true ) ) { | 1014 | if ( syncWithFile( fileName,true ) ) { |
1016 | if ( mWriteBackFile ) { | 1015 | if ( mWriteBackFile ) { |
1017 | command += " --read"; | 1016 | command += " --read"; |
1018 | system ( command.latin1()); | 1017 | system ( command.latin1()); |
1019 | } | 1018 | } |
1020 | } | 1019 | } |
1021 | 1020 | ||
1022 | } | 1021 | } |
1023 | break; | 1022 | break; |
@@ -1048,201 +1047,201 @@ bool KSyncManager::syncExternalApplication(QString resource) | |||
1048 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1047 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1049 | return false; | 1048 | return false; |
1050 | } | 1049 | } |
1051 | 1050 | ||
1052 | qDebug("KSM::Sync extern %s", resource.latin1()); | 1051 | qDebug("KSM::Sync extern %s", resource.latin1()); |
1053 | 1052 | ||
1054 | bool syncOK = mImplementation->syncExternal(this, resource); | 1053 | bool syncOK = mImplementation->syncExternal(this, resource); |
1055 | 1054 | ||
1056 | return syncOK; | 1055 | return syncOK; |
1057 | 1056 | ||
1058 | } | 1057 | } |
1059 | 1058 | ||
1060 | void KSyncManager::syncPhone() | 1059 | void KSyncManager::syncPhone() |
1061 | { | 1060 | { |
1062 | 1061 | ||
1063 | syncExternalApplication("phone"); | 1062 | syncExternalApplication("phone"); |
1064 | 1063 | ||
1065 | } | 1064 | } |
1066 | 1065 | ||
1067 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 1066 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
1068 | { | 1067 | { |
1069 | if (!bar->isVisible()) | 1068 | if (!bar->isVisible()) |
1070 | { | 1069 | { |
1071 | int w = 300; | 1070 | int w = 300; |
1072 | if ( QApplication::desktop()->width() < 320 ) | 1071 | if ( QApplication::desktop()->width() < 320 ) |
1073 | w = 220; | 1072 | w = 220; |
1074 | int h = bar->sizeHint().height() ; | 1073 | int h = bar->sizeHint().height() ; |
1075 | int dw = QApplication::desktop()->width(); | 1074 | int dw = QApplication::desktop()->width(); |
1076 | int dh = QApplication::desktop()->height(); | 1075 | int dh = QApplication::desktop()->height(); |
1077 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1076 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1078 | bar->setCaption (caption); | 1077 | bar->setCaption (caption); |
1079 | bar->setTotalSteps ( total ) ; | 1078 | bar->setTotalSteps ( total ) ; |
1080 | bar->show(); | 1079 | bar->show(); |
1081 | } | 1080 | } |
1082 | bar->raise(); | 1081 | bar->raise(); |
1083 | bar->setProgress( percentage ); | 1082 | bar->setProgress( percentage ); |
1084 | qApp->processEvents(); | 1083 | qApp->processEvents(); |
1085 | } | 1084 | } |
1086 | 1085 | ||
1087 | void KSyncManager::hideProgressBar() | 1086 | void KSyncManager::hideProgressBar() |
1088 | { | 1087 | { |
1089 | bar->hide(); | 1088 | bar->hide(); |
1090 | qApp->processEvents(); | 1089 | qApp->processEvents(); |
1091 | } | 1090 | } |
1092 | 1091 | ||
1093 | bool KSyncManager::isProgressBarCanceled() | 1092 | bool KSyncManager::isProgressBarCanceled() |
1094 | { | 1093 | { |
1095 | return !bar->isVisible(); | 1094 | return !bar->isVisible(); |
1096 | } | 1095 | } |
1097 | 1096 | ||
1098 | QString KSyncManager::syncFileName() | 1097 | QString KSyncManager::syncFileName() |
1099 | { | 1098 | { |
1100 | 1099 | ||
1101 | QString fn = "tempfile"; | 1100 | QString fn = "tempfile"; |
1102 | switch(mTargetApp) | 1101 | switch(mTargetApp) |
1103 | { | 1102 | { |
1104 | case (KAPI): | 1103 | case (KAPI): |
1105 | fn = "tempsyncab.vcf"; | 1104 | fn = "tempsyncab.vcf"; |
1106 | break; | 1105 | break; |
1107 | case (KOPI): | 1106 | case (KOPI): |
1108 | fn = "tempsynccal.ics"; | 1107 | fn = "tempsynccal.ics"; |
1109 | break; | 1108 | break; |
1110 | case (PWMPI): | 1109 | case (PWMPI): |
1111 | fn = "tempsyncpw.pwm"; | 1110 | fn = "tempsyncpw.pwm"; |
1112 | break; | 1111 | break; |
1113 | default: | 1112 | default: |
1114 | break; | 1113 | break; |
1115 | } | 1114 | } |
1116 | #ifdef DESKTOP_VERSION | 1115 | #ifdef DESKTOP_VERSION |
1117 | return locateLocal( "tmp", fn ); | 1116 | return locateLocal( "tmp", fn ); |
1118 | #else | 1117 | #else |
1119 | return (QString( "/tmp/" )+ fn ); | 1118 | return (QString( "/tmp/" )+ fn ); |
1120 | #endif | 1119 | #endif |
1121 | } | 1120 | } |
1122 | 1121 | ||
1123 | void KSyncManager::syncPi() | 1122 | void KSyncManager::syncPi() |
1124 | { | 1123 | { |
1125 | mIsKapiFile = true; | 1124 | mIsKapiFile = true; |
1126 | mPisyncFinished = false; | 1125 | mPisyncFinished = false; |
1127 | qApp->processEvents(); | 1126 | qApp->processEvents(); |
1128 | if ( mAskForPreferences ) | 1127 | if ( mAskForPreferences ) |
1129 | if ( !edit_pisync_options()) { | 1128 | if ( !edit_pisync_options()) { |
1130 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1129 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1131 | mPisyncFinished = true; | 1130 | mPisyncFinished = true; |
1132 | return; | 1131 | return; |
1133 | } | 1132 | } |
1134 | bool ok; | 1133 | bool ok; |
1135 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1134 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1136 | if ( ! ok ) { | 1135 | if ( ! ok ) { |
1137 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1136 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1138 | mPisyncFinished = true; | 1137 | mPisyncFinished = true; |
1139 | return; | 1138 | return; |
1140 | } | 1139 | } |
1141 | mCurrentResourceLocal = ""; | 1140 | mCurrentResourceLocal = ""; |
1142 | mCurrentResourceRemote = ""; | 1141 | mCurrentResourceRemote = ""; |
1143 | if ( mSpecificResources.count() ) { | 1142 | if ( mSpecificResources.count() ) { |
1144 | int lastSyncRes = mSpecificResources.count()/2; | 1143 | uint lastSyncRes = mSpecificResources.count()/2; |
1145 | int ccc = mSpecificResources.count()-1; | 1144 | int ccc = mSpecificResources.count()-1; |
1146 | while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { | 1145 | while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { |
1147 | --ccc; | 1146 | --ccc; |
1148 | --lastSyncRes; | 1147 | --lastSyncRes; |
1149 | //qDebug ( "KSM: sync pi %d",ccc ); | 1148 | //qDebug ( "KSM: sync pi %d",ccc ); |
1150 | } | 1149 | } |
1151 | int startLocal = 0; | 1150 | uint startLocal = 0; |
1152 | int startRemote = mSpecificResources.count()/2; | 1151 | uint startRemote = mSpecificResources.count()/2; |
1153 | emit multiResourceSyncStart( true ); | 1152 | emit multiResourceSyncStart( true ); |
1154 | while ( startLocal < mSpecificResources.count()/2 ) { | 1153 | while ( startLocal < mSpecificResources.count()/2 ) { |
1155 | if ( startLocal+1 >= lastSyncRes ) | 1154 | if ( startLocal+1 >= lastSyncRes ) |
1156 | emit multiResourceSyncStart( false ); | 1155 | emit multiResourceSyncStart( false ); |
1157 | mPisyncFinished = false; | 1156 | mPisyncFinished = false; |
1158 | mCurrentResourceLocal = mSpecificResources[ startLocal ]; | 1157 | mCurrentResourceLocal = mSpecificResources[ startLocal ]; |
1159 | mCurrentResourceRemote = mSpecificResources[ startRemote ]; | 1158 | mCurrentResourceRemote = mSpecificResources[ startRemote ]; |
1160 | //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); | 1159 | //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); |
1161 | if ( !mCurrentResourceRemote.isEmpty() ) { | 1160 | if ( !mCurrentResourceRemote.isEmpty() ) { |
1162 | qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); | 1161 | qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); |
1163 | 1162 | ||
1164 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | 1163 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); |
1165 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1164 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1166 | commandSocket->readFile( syncFileName() ); | 1165 | commandSocket->readFile( syncFileName() ); |
1167 | mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) ); | 1166 | mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) ); |
1168 | while ( !mPisyncFinished ) { | 1167 | while ( !mPisyncFinished ) { |
1169 | //qDebug("waiting "); | 1168 | //qDebug("waiting "); |
1170 | qApp->processEvents(); | 1169 | qApp->processEvents(); |
1171 | } | 1170 | } |
1172 | if ( startLocal+1 < mSpecificResources.count()/2 ) { | 1171 | if ( startLocal+1 < mSpecificResources.count()/2 ) { |
1173 | mParent->topLevelWidget()->setCaption( i18n("Waiting 2 secs before syncing next resource...") ); | 1172 | mParent->topLevelWidget()->setCaption( i18n("Waiting 2 secs before syncing next resource...") ); |
1174 | QTime timer; | 1173 | QTime timer; |
1175 | timer.start(); | 1174 | timer.start(); |
1176 | while ( timer.elapsed () < 2000 ) { | 1175 | while ( timer.elapsed () < 2000 ) { |
1177 | qApp->processEvents(); | 1176 | qApp->processEvents(); |
1178 | } | 1177 | } |
1179 | } | 1178 | } |
1180 | } | 1179 | } |
1181 | ++startRemote; | 1180 | ++startRemote; |
1182 | ++startLocal; | 1181 | ++startLocal; |
1183 | mAskForPreferences = false; | 1182 | mAskForPreferences = false; |
1184 | } | 1183 | } |
1185 | mPisyncFinished = true; | 1184 | mPisyncFinished = true; |
1186 | } else { | 1185 | } else { |
1187 | KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | 1186 | KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); |
1188 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1187 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1189 | commandSocket->readFile( syncFileName() ); | 1188 | commandSocket->readFile( syncFileName() ); |
1190 | } | 1189 | } |
1191 | } | 1190 | } |
1192 | 1191 | ||
1193 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1192 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1194 | { | 1193 | { |
1195 | //enum { success, errorW, errorR, quiet }; | 1194 | //enum { success, errorW, errorR, quiet }; |
1196 | 1195 | ||
1197 | 1196 | ||
1198 | 1197 | ||
1199 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || | 1198 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || |
1200 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { | 1199 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { |
1201 | if ( state == KCommandSocket::errorPW ) | 1200 | if ( state == KCommandSocket::errorPW ) |
1202 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); | 1201 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); |
1203 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) | 1202 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) |
1204 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1203 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1205 | else if ( state == KCommandSocket::errorCA ) | 1204 | else if ( state == KCommandSocket::errorCA ) |
1206 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); | 1205 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); |
1207 | else if ( state == KCommandSocket::errorFI ) | 1206 | else if ( state == KCommandSocket::errorFI ) |
1208 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); | 1207 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); |
1209 | else if ( state == KCommandSocket::errorED ) | 1208 | else if ( state == KCommandSocket::errorED ) |
1210 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); | 1209 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); |
1211 | else if ( state == KCommandSocket::errorUN ) | 1210 | else if ( state == KCommandSocket::errorUN ) |
1212 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); | 1211 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); |
1213 | delete s; | 1212 | delete s; |
1214 | if ( state == KCommandSocket::errorR ) { | 1213 | if ( state == KCommandSocket::errorR ) { |
1215 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); | 1214 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); |
1216 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1215 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1217 | commandSocket->sendStop(); | 1216 | commandSocket->sendStop(); |
1218 | } | 1217 | } |
1219 | mPisyncFinished = true; | 1218 | mPisyncFinished = true; |
1220 | return; | 1219 | return; |
1221 | 1220 | ||
1222 | } else if ( state == KCommandSocket::errorW ) { | 1221 | } else if ( state == KCommandSocket::errorW ) { |
1223 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1222 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1224 | mPisyncFinished = true; | 1223 | mPisyncFinished = true; |
1225 | 1224 | ||
1226 | } else if ( state == KCommandSocket::successR ) { | 1225 | } else if ( state == KCommandSocket::successR ) { |
1227 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1226 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1228 | 1227 | ||
1229 | } else if ( state == KCommandSocket::successW ) { | 1228 | } else if ( state == KCommandSocket::successW ) { |
1230 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 1229 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); |
1231 | mPisyncFinished = true; | 1230 | mPisyncFinished = true; |
1232 | } else if ( state == KCommandSocket::quiet ){ | 1231 | } else if ( state == KCommandSocket::quiet ){ |
1233 | qDebug("KSS: quiet "); | 1232 | qDebug("KSS: quiet "); |
1234 | mPisyncFinished = true; | 1233 | mPisyncFinished = true; |
1235 | } else { | 1234 | } else { |
1236 | qDebug("KSS: Error: unknown state: %d ", state); | 1235 | qDebug("KSS: Error: unknown state: %d ", state); |
1237 | mPisyncFinished = true; | 1236 | mPisyncFinished = true; |
1238 | } | 1237 | } |
1239 | 1238 | ||
1240 | delete s; | 1239 | delete s; |
1241 | } | 1240 | } |
1242 | 1241 | ||
1243 | void KSyncManager::readFileFromSocket() | 1242 | void KSyncManager::readFileFromSocket() |
1244 | { | 1243 | { |
1245 | QString fileName = syncFileName(); | 1244 | QString fileName = syncFileName(); |
1246 | bool syncOK = true; | 1245 | bool syncOK = true; |
1247 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1246 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1248 | if ( ! syncWithFile( fileName , true ) ) { | 1247 | if ( ! syncWithFile( fileName , true ) ) { |