summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
authorzautrix <zautrix>2005-03-18 17:56:55 (UTC)
committer zautrix <zautrix>2005-03-18 17:56:55 (UTC)
commitd6438efc4c7cff39024b65bfd1d2f810212da544 (patch) (unidiff)
treebadb4c48d83477dd1027af1807cb2b6ed09db52a /libkdepim/ksyncmanager.cpp
parentf9f521c487143641b2cf077d04fe1c475001bce2 (diff)
downloadkdepimpi-d6438efc4c7cff39024b65bfd1d2f810212da544.zip
kdepimpi-d6438efc4c7cff39024b65bfd1d2f810212da544.tar.gz
kdepimpi-d6438efc4c7cff39024b65bfd1d2f810212da544.tar.bz2
kde sync fixes
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index d59f4a4..7319285 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -733,405 +733,415 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
733 // 0 : okay 733 // 0 : okay
734 // 256: no such file or dir 734 // 256: no such file or dir
735 // 735 //
736 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); 736 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result );
737 if ( result != 0 ) { 737 if ( result != 0 ) {
738 unsigned int len = maxlen; 738 unsigned int len = maxlen;
739 while ( len < preCommand.length() ) { 739 while ( len < preCommand.length() ) {
740 preCommand.insert( len , "\n" ); 740 preCommand.insert( len , "\n" );
741 len += maxlen +2; 741 len += maxlen +2;
742 } 742 }
743 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) ; 743 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) ;
744 QMessageBox::information( mParent, i18n("Sync - ERROR"), 744 QMessageBox::information( mParent, i18n("Sync - ERROR"),
745 question, 745 question,
746 i18n("Okay!")) ; 746 i18n("Okay!")) ;
747 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 747 mParent->topLevelWidget()->setCaption ("KDE-Pim");
748 return; 748 return;
749 } 749 }
750 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 750 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
751 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 751 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
752 752
753 if ( syncWithFile( localTempFile, true ) ) { 753 if ( syncWithFile( localTempFile, true ) ) {
754 754
755 if ( mWriteBackFile ) { 755 if ( mWriteBackFile ) {
756 int fi; 756 int fi;
757 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 757 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
758 QString pwd = getPassword(); 758 QString pwd = getPassword();
759 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 759 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
760 760
761 } 761 }
762 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 762 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
763 result = system ( postCommand ); 763 result = system ( postCommand );
764 qDebug("KSM::Sync:Writing back file result: %d ", result); 764 qDebug("KSM::Sync:Writing back file result: %d ", result);
765 if ( result != 0 ) { 765 if ( result != 0 ) {
766 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 766 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
767 return; 767 return;
768 } else { 768 } else {
769 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 769 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
770 } 770 }
771 } 771 }
772 } 772 }
773 return; 773 return;
774} 774}
775bool KSyncManager::edit_pisync_options() 775bool KSyncManager::edit_pisync_options()
776{ 776{
777 QDialog dia( mParent, "dia", true ); 777 QDialog dia( mParent, "dia", true );
778 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 778 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
779 QVBoxLayout lay ( &dia ); 779 QVBoxLayout lay ( &dia );
780 lay.setSpacing( 5 ); 780 lay.setSpacing( 5 );
781 lay.setMargin( 3 ); 781 lay.setMargin( 3 );
782 QLabel lab1 ( i18n("Password for remote access:"), &dia); 782 QLabel lab1 ( i18n("Password for remote access:"), &dia);
783 lay.addWidget( &lab1 ); 783 lay.addWidget( &lab1 );
784 QLineEdit le1 (&dia ); 784 QLineEdit le1 (&dia );
785 lay.addWidget( &le1 ); 785 lay.addWidget( &le1 );
786 QLabel lab2 ( i18n("Remote IP address:"), &dia); 786 QLabel lab2 ( i18n("Remote IP address:"), &dia);
787 lay.addWidget( &lab2 ); 787 lay.addWidget( &lab2 );
788 QLineEdit le2 (&dia ); 788 QLineEdit le2 (&dia );
789 lay.addWidget( &le2 ); 789 lay.addWidget( &le2 );
790 QLabel lab3 ( i18n("Remote port number:"), &dia); 790 QLabel lab3 ( i18n("Remote port number:"), &dia);
791 lay.addWidget( &lab3 ); 791 lay.addWidget( &lab3 );
792 QLineEdit le3 (&dia ); 792 QLineEdit le3 (&dia );
793 lay.addWidget( &le3 ); 793 lay.addWidget( &le3 );
794 QPushButton pb ( "OK", &dia); 794 QPushButton pb ( "OK", &dia);
795 lay.addWidget( &pb ); 795 lay.addWidget( &pb );
796 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 796 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
797 le1.setText( mPassWordPiSync ); 797 le1.setText( mPassWordPiSync );
798 le2.setText( mActiveSyncIP ); 798 le2.setText( mActiveSyncIP );
799 le3.setText( mActiveSyncPort ); 799 le3.setText( mActiveSyncPort );
800 if ( dia.exec() ) { 800 if ( dia.exec() ) {
801 mPassWordPiSync = le1.text(); 801 mPassWordPiSync = le1.text();
802 mActiveSyncPort = le3.text(); 802 mActiveSyncPort = le3.text();
803 mActiveSyncIP = le2.text(); 803 mActiveSyncIP = le2.text();
804 return true; 804 return true;
805 } 805 }
806 return false; 806 return false;
807} 807}
808bool KSyncManager::edit_sync_options() 808bool KSyncManager::edit_sync_options()
809{ 809{
810 810
811 QDialog dia( mParent, "dia", true ); 811 QDialog dia( mParent, "dia", true );
812 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 812 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
813 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 813 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
814 QVBoxLayout lay ( &dia ); 814 QVBoxLayout lay ( &dia );
815 lay.setSpacing( 2 ); 815 lay.setSpacing( 2 );
816 lay.setMargin( 3 ); 816 lay.setMargin( 3 );
817 lay.addWidget(&gr); 817 lay.addWidget(&gr);
818 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 818 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
819 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 819 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
820 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 820 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
821 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 821 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
822 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 822 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
823 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 823 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
824 //QRadioButton both( i18n("Take both on conflict"), &gr ); 824 //QRadioButton both( i18n("Take both on conflict"), &gr );
825 QPushButton pb ( "OK", &dia); 825 QPushButton pb ( "OK", &dia);
826 lay.addWidget( &pb ); 826 lay.addWidget( &pb );
827 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 827 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
828 switch ( mSyncAlgoPrefs ) { 828 switch ( mSyncAlgoPrefs ) {
829 case 0: 829 case 0:
830 loc.setChecked( true); 830 loc.setChecked( true);
831 break; 831 break;
832 case 1: 832 case 1:
833 rem.setChecked( true ); 833 rem.setChecked( true );
834 break; 834 break;
835 case 2: 835 case 2:
836 newest.setChecked( true); 836 newest.setChecked( true);
837 break; 837 break;
838 case 3: 838 case 3:
839 ask.setChecked( true); 839 ask.setChecked( true);
840 break; 840 break;
841 case 4: 841 case 4:
842 f_loc.setChecked( true); 842 f_loc.setChecked( true);
843 break; 843 break;
844 case 5: 844 case 5:
845 f_rem.setChecked( true); 845 f_rem.setChecked( true);
846 break; 846 break;
847 case 6: 847 case 6:
848 // both.setChecked( true); 848 // both.setChecked( true);
849 break; 849 break;
850 default: 850 default:
851 break; 851 break;
852 } 852 }
853 if ( dia.exec() ) { 853 if ( dia.exec() ) {
854 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 854 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
855 return true; 855 return true;
856 } 856 }
857 return false; 857 return false;
858} 858}
859 859
860QString KSyncManager::getPassword( ) 860QString KSyncManager::getPassword( )
861{ 861{
862 QString retfile = ""; 862 QString retfile = "";
863 QDialog dia ( mParent, "input-dialog", true ); 863 QDialog dia ( mParent, "input-dialog", true );
864 QLineEdit lab ( &dia ); 864 QLineEdit lab ( &dia );
865 lab.setEchoMode( QLineEdit::Password ); 865 lab.setEchoMode( QLineEdit::Password );
866 QVBoxLayout lay( &dia ); 866 QVBoxLayout lay( &dia );
867 lay.setMargin(7); 867 lay.setMargin(7);
868 lay.setSpacing(7); 868 lay.setSpacing(7);
869 lay.addWidget( &lab); 869 lay.addWidget( &lab);
870 dia.setFixedSize( 230,50 ); 870 dia.setFixedSize( 230,50 );
871 dia.setCaption( i18n("Enter password") ); 871 dia.setCaption( i18n("Enter password") );
872 QPushButton pb ( "OK", &dia); 872 QPushButton pb ( "OK", &dia);
873 lay.addWidget( &pb ); 873 lay.addWidget( &pb );
874 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 874 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
875 dia.show(); 875 dia.show();
876 int res = dia.exec(); 876 int res = dia.exec();
877 if ( res ) 877 if ( res )
878 retfile = lab.text(); 878 retfile = lab.text();
879 dia.hide(); 879 dia.hide();
880 qApp->processEvents(); 880 qApp->processEvents();
881 return retfile; 881 return retfile;
882 882
883} 883}
884 884
885 885
886void KSyncManager::confSync() 886void KSyncManager::confSync()
887{ 887{
888 static KSyncPrefsDialog* sp = 0; 888 static KSyncPrefsDialog* sp = 0;
889 if ( ! sp ) { 889 if ( ! sp ) {
890 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 890 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
891 } 891 }
892 sp->usrReadConfig(); 892 sp->usrReadConfig();
893#ifndef DESKTOP_VERSION 893#ifndef DESKTOP_VERSION
894 sp->showMaximized(); 894 sp->showMaximized();
895#else 895#else
896 sp->show(); 896 sp->show();
897#endif 897#endif
898 sp->exec(); 898 sp->exec();
899 QStringList oldSyncProfileNames = mSyncProfileNames; 899 QStringList oldSyncProfileNames = mSyncProfileNames;
900 mSyncProfileNames = sp->getSyncProfileNames(); 900 mSyncProfileNames = sp->getSyncProfileNames();
901 mLocalMachineName = sp->getLocalMachineName (); 901 mLocalMachineName = sp->getLocalMachineName ();
902 int ii; 902 int ii;
903 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 903 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
904 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 904 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
905 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 905 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
906 } 906 }
907 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 907 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
908} 908}
909void KSyncManager::syncKDE() 909void KSyncManager::syncKDE()
910{ 910{
911 mSyncWithDesktop = true; 911 mSyncWithDesktop = true;
912 emit save(); 912 emit save();
913 switch(mTargetApp) 913 switch(mTargetApp)
914 { 914 {
915 case (KAPI): 915 case (KAPI):
916 { 916 {
917#ifdef DESKTOP_VERSION 917#ifdef DESKTOP_VERSION
918 QString command = qApp->applicationDirPath () + "/kdeabdump"; 918 QString command = qApp->applicationDirPath () + "/kdeabdump";
919#else 919#else
920 QString command = "kdeabdump"; 920 QString command = "kdeabdump";
921#endif 921#endif
922 if ( ! QFile::exists ( command ) ) 922 if ( ! QFile::exists ( command ) )
923 command = "kdeabdump"; 923 command = "kdeabdump";
924 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 924 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
925 system ( command.latin1()); 925 int result = system ( command.latin1());
926 qDebug("AB dump command call result: %d ", result);
927 if ( result != 0 ) {
928 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n/opt/kdepimpi/kdeabdump\nexists.The standard version of this file\nis for syncing with KDE 3.4.x.\nIf you are running KDE 3.3.x please\ndownload the KDE 3.3.x version of this file\nat http://sourceforge.net/projects/kdepimpi/\nsection: general files for KDE/Pim."));
929 return;
930 }
926 if ( syncWithFile( fileName,true ) ) { 931 if ( syncWithFile( fileName,true ) ) {
927 if ( mWriteBackFile ) { 932 if ( mWriteBackFile ) {
928 command += " --read"; 933 command += " --read";
929 system ( command.latin1()); 934 system ( command.latin1());
930 } 935 }
931 } 936 }
932 937
933 } 938 }
934 break; 939 break;
935 case (KOPI): 940 case (KOPI):
936 { 941 {
937#ifdef DESKTOP_VERSION 942#ifdef DESKTOP_VERSION
938 QString command = qApp->applicationDirPath () + "/kdecaldump"; 943 QString command = qApp->applicationDirPath () + "/kdecaldump";
939#else 944#else
940 QString command = "kdecaldump"; 945 QString command = "kdecaldump";
941#endif 946#endif
942 if ( ! QFile::exists ( command ) ) 947 if ( ! QFile::exists ( command ) )
943 command = "kdecaldump"; 948 command = "kdecaldump";
944 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 949 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
945 system ( command.latin1()); 950 int result = system ( command.latin1());
951 qDebug("Cal dump command call result result: %d ", result);
952 if ( result != 0 ) {
953 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n/opt/kdepimpi/kdecaldump\nexists.The standard version of this file\nis for syncing with KDE 3.4.x.\nIf you are running KDE 3.3.x please\ndownload the KDE 3.3.x version of this file\nat http://sourceforge.net/projects/kdepimpi/\nsection: general files for KDE/Pim."));
954 return;
955 }
946 if ( syncWithFile( fileName,true ) ) { 956 if ( syncWithFile( fileName,true ) ) {
947 if ( mWriteBackFile ) { 957 if ( mWriteBackFile ) {
948 command += " --read"; 958 command += " --read";
949 system ( command.latin1()); 959 system ( command.latin1());
950 } 960 }
951 } 961 }
952 962
953 } 963 }
954 break; 964 break;
955 case (PWMPI): 965 case (PWMPI):
956 966
957 break; 967 break;
958 default: 968 default:
959 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 969 qDebug("KSM::slotSyncMenu: invalid apptype selected");
960 break; 970 break;
961 971
962 } 972 }
963} 973}
964 974
965void KSyncManager::syncSharp() 975void KSyncManager::syncSharp()
966{ 976{
967 977
968 if ( ! syncExternalApplication("sharp") ) 978 if ( ! syncExternalApplication("sharp") )
969 qDebug("KSM::ERROR sync sharp "); 979 qDebug("KSM::ERROR sync sharp ");
970} 980}
971 981
972bool KSyncManager::syncExternalApplication(QString resource) 982bool KSyncManager::syncExternalApplication(QString resource)
973{ 983{
974 984
975 emit save(); 985 emit save();
976 986
977 if ( mAskForPreferences ) 987 if ( mAskForPreferences )
978 if ( !edit_sync_options()) { 988 if ( !edit_sync_options()) {
979 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 989 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
980 return false; 990 return false;
981 } 991 }
982 992
983 qDebug("KSM::Sync extern %s", resource.latin1()); 993 qDebug("KSM::Sync extern %s", resource.latin1());
984 994
985 bool syncOK = mImplementation->syncExternal(this, resource); 995 bool syncOK = mImplementation->syncExternal(this, resource);
986 996
987 return syncOK; 997 return syncOK;
988 998
989} 999}
990 1000
991void KSyncManager::syncPhone() 1001void KSyncManager::syncPhone()
992{ 1002{
993 1003
994 syncExternalApplication("phone"); 1004 syncExternalApplication("phone");
995 1005
996} 1006}
997 1007
998void KSyncManager::showProgressBar(int percentage, QString caption, int total) 1008void KSyncManager::showProgressBar(int percentage, QString caption, int total)
999{ 1009{
1000 if (!bar->isVisible()) 1010 if (!bar->isVisible())
1001 { 1011 {
1002 bar->setCaption (caption); 1012 bar->setCaption (caption);
1003 bar->setTotalSteps ( total ) ; 1013 bar->setTotalSteps ( total ) ;
1004 bar->show(); 1014 bar->show();
1005 } 1015 }
1006 bar->raise(); 1016 bar->raise();
1007 bar->setProgress( percentage ); 1017 bar->setProgress( percentage );
1008 qApp->processEvents(); 1018 qApp->processEvents();
1009} 1019}
1010 1020
1011void KSyncManager::hideProgressBar() 1021void KSyncManager::hideProgressBar()
1012{ 1022{
1013 bar->hide(); 1023 bar->hide();
1014 qApp->processEvents(); 1024 qApp->processEvents();
1015} 1025}
1016 1026
1017bool KSyncManager::isProgressBarCanceled() 1027bool KSyncManager::isProgressBarCanceled()
1018{ 1028{
1019 return !bar->isVisible(); 1029 return !bar->isVisible();
1020} 1030}
1021 1031
1022QString KSyncManager::syncFileName() 1032QString KSyncManager::syncFileName()
1023{ 1033{
1024 1034
1025 QString fn = "tempfile"; 1035 QString fn = "tempfile";
1026 switch(mTargetApp) 1036 switch(mTargetApp)
1027 { 1037 {
1028 case (KAPI): 1038 case (KAPI):
1029 fn = "tempsyncab.vcf"; 1039 fn = "tempsyncab.vcf";
1030 break; 1040 break;
1031 case (KOPI): 1041 case (KOPI):
1032 fn = "tempsynccal.ics"; 1042 fn = "tempsynccal.ics";
1033 break; 1043 break;
1034 case (PWMPI): 1044 case (PWMPI):
1035 fn = "tempsyncpw.pwm"; 1045 fn = "tempsyncpw.pwm";
1036 break; 1046 break;
1037 default: 1047 default:
1038 break; 1048 break;
1039 } 1049 }
1040#ifdef _WIN32_ 1050#ifdef _WIN32_
1041 return locateLocal( "tmp", fn ); 1051 return locateLocal( "tmp", fn );
1042#else 1052#else
1043 return (QString( "/tmp/" )+ fn ); 1053 return (QString( "/tmp/" )+ fn );
1044#endif 1054#endif
1045} 1055}
1046 1056
1047void KSyncManager::syncPi() 1057void KSyncManager::syncPi()
1048{ 1058{
1049 mIsKapiFile = true; 1059 mIsKapiFile = true;
1050 mPisyncFinished = false; 1060 mPisyncFinished = false;
1051 qApp->processEvents(); 1061 qApp->processEvents();
1052 if ( mAskForPreferences ) 1062 if ( mAskForPreferences )
1053 if ( !edit_pisync_options()) { 1063 if ( !edit_pisync_options()) {
1054 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1064 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1055 mPisyncFinished = true; 1065 mPisyncFinished = true;
1056 return; 1066 return;
1057 } 1067 }
1058 bool ok; 1068 bool ok;
1059 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1069 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1060 if ( ! ok ) { 1070 if ( ! ok ) {
1061 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1071 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1062 mPisyncFinished = true; 1072 mPisyncFinished = true;
1063 return; 1073 return;
1064 } 1074 }
1065 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1075 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1066 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1076 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1067 commandSocket->readFile( syncFileName() ); 1077 commandSocket->readFile( syncFileName() );
1068} 1078}
1069 1079
1070void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1080void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1071{ 1081{
1072 //enum { success, errorW, errorR, quiet }; 1082 //enum { success, errorW, errorR, quiet };
1073 1083
1074 1084
1075 1085
1076 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || 1086 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
1077 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { 1087 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) {
1078 if ( state == KCommandSocket::errorPW ) 1088 if ( state == KCommandSocket::errorPW )
1079 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); 1089 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
1080 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) 1090 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
1081 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1091 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1082 else if ( state == KCommandSocket::errorCA ) 1092 else if ( state == KCommandSocket::errorCA )
1083 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); 1093 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
1084 else if ( state == KCommandSocket::errorFI ) 1094 else if ( state == KCommandSocket::errorFI )
1085 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); 1095 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
1086 else if ( state == KCommandSocket::errorED ) 1096 else if ( state == KCommandSocket::errorED )
1087 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); 1097 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") );
1088 else if ( state == KCommandSocket::errorUN ) 1098 else if ( state == KCommandSocket::errorUN )
1089 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); 1099 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
1090 delete s; 1100 delete s;
1091 if ( state == KCommandSocket::errorR ) { 1101 if ( state == KCommandSocket::errorR ) {
1092 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); 1102 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
1093 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1103 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1094 commandSocket->sendStop(); 1104 commandSocket->sendStop();
1095 } 1105 }
1096 mPisyncFinished = true; 1106 mPisyncFinished = true;
1097 return; 1107 return;
1098 1108
1099 } else if ( state == KCommandSocket::errorW ) { 1109 } else if ( state == KCommandSocket::errorW ) {
1100 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1110 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1101 mPisyncFinished = true; 1111 mPisyncFinished = true;
1102 1112
1103 } else if ( state == KCommandSocket::successR ) { 1113 } else if ( state == KCommandSocket::successR ) {
1104 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1114 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1105 1115
1106 } else if ( state == KCommandSocket::successW ) { 1116 } else if ( state == KCommandSocket::successW ) {
1107 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 1117 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
1108 mPisyncFinished = true; 1118 mPisyncFinished = true;
1109 } else if ( state == KCommandSocket::quiet ){ 1119 } else if ( state == KCommandSocket::quiet ){
1110 qDebug("KSS: quiet "); 1120 qDebug("KSS: quiet ");
1111 mPisyncFinished = true; 1121 mPisyncFinished = true;
1112 } else { 1122 } else {
1113 qDebug("KSS: Error: unknown state: %d ", state); 1123 qDebug("KSS: Error: unknown state: %d ", state);
1114 mPisyncFinished = true; 1124 mPisyncFinished = true;
1115 } 1125 }
1116 1126
1117 delete s; 1127 delete s;
1118} 1128}
1119 1129
1120void KSyncManager::readFileFromSocket() 1130void KSyncManager::readFileFromSocket()
1121{ 1131{
1122 QString fileName = syncFileName(); 1132 QString fileName = syncFileName();
1123 bool syncOK = true; 1133 bool syncOK = true;
1124 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1134 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1125 if ( ! syncWithFile( fileName , true ) ) { 1135 if ( ! syncWithFile( fileName , true ) ) {
1126 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1136 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1127 syncOK = false; 1137 syncOK = false;
1128 } 1138 }
1129 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1139 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1130 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1140 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1131 if ( mWriteBackFile && syncOK ) 1141 if ( mWriteBackFile && syncOK )
1132 commandSocket->writeFile( fileName ); 1142 commandSocket->writeFile( fileName );
1133 else { 1143 else {
1134 commandSocket->sendStop(); 1144 commandSocket->sendStop();
1135 if ( syncOK ) 1145 if ( syncOK )
1136 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1146 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1137 mPisyncFinished = true; 1147 mPisyncFinished = true;