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