-rw-r--r-- | libkdepim/ksyncmanager.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index c6e06f8..8851097 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -592,387 +592,390 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | |||
592 | 592 | ||
593 | int fi; | 593 | int fi; |
594 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 594 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
595 | QString pwd = getPassword(); | 595 | QString pwd = getPassword(); |
596 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 596 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
597 | 597 | ||
598 | } | 598 | } |
599 | int maxlen = 30; | 599 | int maxlen = 30; |
600 | if ( QApplication::desktop()->width() > 320 ) | 600 | if ( QApplication::desktop()->width() > 320 ) |
601 | maxlen += 25; | 601 | maxlen += 25; |
602 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 602 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
603 | int fileSize = 0; | 603 | int fileSize = 0; |
604 | int result = system ( preCommand ); | 604 | int result = system ( preCommand ); |
605 | // 0 : okay | 605 | // 0 : okay |
606 | // 256: no such file or dir | 606 | // 256: no such file or dir |
607 | // | 607 | // |
608 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); | 608 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); |
609 | if ( result != 0 ) { | 609 | if ( result != 0 ) { |
610 | unsigned int len = maxlen; | 610 | unsigned int len = maxlen; |
611 | while ( len < preCommand.length() ) { | 611 | while ( len < preCommand.length() ) { |
612 | preCommand.insert( len , "\n" ); | 612 | preCommand.insert( len , "\n" ); |
613 | len += maxlen +2; | 613 | len += maxlen +2; |
614 | } | 614 | } |
615 | 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) ; | 615 | 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) ; |
616 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 616 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
617 | question, | 617 | question, |
618 | i18n("Okay!")) ; | 618 | i18n("Okay!")) ; |
619 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 619 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
620 | return; | 620 | return; |
621 | } | 621 | } |
622 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 622 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
623 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 623 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
624 | 624 | ||
625 | if ( syncWithFile( localTempFile, true ) ) { | 625 | if ( syncWithFile( localTempFile, true ) ) { |
626 | 626 | ||
627 | if ( mWriteBackFile ) { | 627 | if ( mWriteBackFile ) { |
628 | int fi; | 628 | int fi; |
629 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 629 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
630 | QString pwd = getPassword(); | 630 | QString pwd = getPassword(); |
631 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 631 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
632 | 632 | ||
633 | } | 633 | } |
634 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 634 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
635 | result = system ( postCommand ); | 635 | result = system ( postCommand ); |
636 | qDebug("Sync:Writing back file result: %d ", result); | 636 | qDebug("Sync:Writing back file result: %d ", result); |
637 | if ( result != 0 ) { | 637 | if ( result != 0 ) { |
638 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 638 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
639 | return; | 639 | return; |
640 | } else { | 640 | } else { |
641 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 641 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
642 | } | 642 | } |
643 | } | 643 | } |
644 | } | 644 | } |
645 | return; | 645 | return; |
646 | } | 646 | } |
647 | void KSyncManager::edit_pisync_options() | 647 | void KSyncManager::edit_pisync_options() |
648 | { | 648 | { |
649 | QDialog dia( mParent, "dia", true ); | 649 | QDialog dia( mParent, "dia", true ); |
650 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 650 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
651 | QVBoxLayout lay ( &dia ); | 651 | QVBoxLayout lay ( &dia ); |
652 | lay.setSpacing( 5 ); | 652 | lay.setSpacing( 5 ); |
653 | lay.setMargin( 3 ); | 653 | lay.setMargin( 3 ); |
654 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 654 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
655 | lay.addWidget( &lab1 ); | 655 | lay.addWidget( &lab1 ); |
656 | QLineEdit le1 (&dia ); | 656 | QLineEdit le1 (&dia ); |
657 | lay.addWidget( &le1 ); | 657 | lay.addWidget( &le1 ); |
658 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 658 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
659 | lay.addWidget( &lab2 ); | 659 | lay.addWidget( &lab2 ); |
660 | QLineEdit le2 (&dia ); | 660 | QLineEdit le2 (&dia ); |
661 | lay.addWidget( &le2 ); | 661 | lay.addWidget( &le2 ); |
662 | QLabel lab3 ( i18n("Remote port number:"), &dia); | 662 | QLabel lab3 ( i18n("Remote port number:"), &dia); |
663 | lay.addWidget( &lab3 ); | 663 | lay.addWidget( &lab3 ); |
664 | QLineEdit le3 (&dia ); | 664 | QLineEdit le3 (&dia ); |
665 | lay.addWidget( &le3 ); | 665 | lay.addWidget( &le3 ); |
666 | QPushButton pb ( "OK", &dia); | 666 | QPushButton pb ( "OK", &dia); |
667 | lay.addWidget( &pb ); | 667 | lay.addWidget( &pb ); |
668 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 668 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
669 | le1.setText( mPassWordPiSync ); | 669 | le1.setText( mPassWordPiSync ); |
670 | le2.setText( mActiveSyncIP ); | 670 | le2.setText( mActiveSyncIP ); |
671 | le3.setText( mActiveSyncPort ); | 671 | le3.setText( mActiveSyncPort ); |
672 | if ( dia.exec() ) { | 672 | if ( dia.exec() ) { |
673 | mPassWordPiSync = le1.text(); | 673 | mPassWordPiSync = le1.text(); |
674 | mActiveSyncPort = le3.text(); | 674 | mActiveSyncPort = le3.text(); |
675 | mActiveSyncIP = le2.text(); | 675 | mActiveSyncIP = le2.text(); |
676 | } | 676 | } |
677 | 677 | ||
678 | } | 678 | } |
679 | void KSyncManager::edit_sync_options() | 679 | void KSyncManager::edit_sync_options() |
680 | { | 680 | { |
681 | 681 | ||
682 | QDialog dia( mParent, "dia", true ); | 682 | QDialog dia( mParent, "dia", true ); |
683 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 683 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
684 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 684 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
685 | QVBoxLayout lay ( &dia ); | 685 | QVBoxLayout lay ( &dia ); |
686 | lay.setSpacing( 2 ); | 686 | lay.setSpacing( 2 ); |
687 | lay.setMargin( 3 ); | 687 | lay.setMargin( 3 ); |
688 | lay.addWidget(&gr); | 688 | lay.addWidget(&gr); |
689 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 689 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
690 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 690 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
691 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 691 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
692 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 692 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
693 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 693 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
694 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 694 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
695 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 695 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
696 | QPushButton pb ( "OK", &dia); | 696 | QPushButton pb ( "OK", &dia); |
697 | lay.addWidget( &pb ); | 697 | lay.addWidget( &pb ); |
698 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 698 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
699 | switch ( mSyncAlgoPrefs ) { | 699 | switch ( mSyncAlgoPrefs ) { |
700 | case 0: | 700 | case 0: |
701 | loc.setChecked( true); | 701 | loc.setChecked( true); |
702 | break; | 702 | break; |
703 | case 1: | 703 | case 1: |
704 | rem.setChecked( true ); | 704 | rem.setChecked( true ); |
705 | break; | 705 | break; |
706 | case 2: | 706 | case 2: |
707 | newest.setChecked( true); | 707 | newest.setChecked( true); |
708 | break; | 708 | break; |
709 | case 3: | 709 | case 3: |
710 | ask.setChecked( true); | 710 | ask.setChecked( true); |
711 | break; | 711 | break; |
712 | case 4: | 712 | case 4: |
713 | f_loc.setChecked( true); | 713 | f_loc.setChecked( true); |
714 | break; | 714 | break; |
715 | case 5: | 715 | case 5: |
716 | f_rem.setChecked( true); | 716 | f_rem.setChecked( true); |
717 | break; | 717 | break; |
718 | case 6: | 718 | case 6: |
719 | // both.setChecked( true); | 719 | // both.setChecked( true); |
720 | break; | 720 | break; |
721 | default: | 721 | default: |
722 | break; | 722 | break; |
723 | } | 723 | } |
724 | if ( dia.exec() ) { | 724 | if ( dia.exec() ) { |
725 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 725 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
726 | } | 726 | } |
727 | 727 | ||
728 | 728 | ||
729 | } | 729 | } |
730 | 730 | ||
731 | QString KSyncManager::getPassword( ) | 731 | QString KSyncManager::getPassword( ) |
732 | { | 732 | { |
733 | QString retfile = ""; | 733 | QString retfile = ""; |
734 | QDialog dia ( mParent, "input-dialog", true ); | 734 | QDialog dia ( mParent, "input-dialog", true ); |
735 | QLineEdit lab ( &dia ); | 735 | QLineEdit lab ( &dia ); |
736 | lab.setEchoMode( QLineEdit::Password ); | 736 | lab.setEchoMode( QLineEdit::Password ); |
737 | QVBoxLayout lay( &dia ); | 737 | QVBoxLayout lay( &dia ); |
738 | lay.setMargin(7); | 738 | lay.setMargin(7); |
739 | lay.setSpacing(7); | 739 | lay.setSpacing(7); |
740 | lay.addWidget( &lab); | 740 | lay.addWidget( &lab); |
741 | dia.setFixedSize( 230,50 ); | 741 | dia.setFixedSize( 230,50 ); |
742 | dia.setCaption( i18n("Enter password") ); | 742 | dia.setCaption( i18n("Enter password") ); |
743 | QPushButton pb ( "OK", &dia); | 743 | QPushButton pb ( "OK", &dia); |
744 | lay.addWidget( &pb ); | 744 | lay.addWidget( &pb ); |
745 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 745 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
746 | dia.show(); | 746 | dia.show(); |
747 | int res = dia.exec(); | 747 | int res = dia.exec(); |
748 | if ( res ) | 748 | if ( res ) |
749 | retfile = lab.text(); | 749 | retfile = lab.text(); |
750 | dia.hide(); | 750 | dia.hide(); |
751 | qApp->processEvents(); | 751 | qApp->processEvents(); |
752 | return retfile; | 752 | return retfile; |
753 | 753 | ||
754 | } | 754 | } |
755 | 755 | ||
756 | 756 | ||
757 | void KSyncManager::confSync() | 757 | void KSyncManager::confSync() |
758 | { | 758 | { |
759 | static KSyncPrefsDialog* sp = 0; | 759 | static KSyncPrefsDialog* sp = 0; |
760 | if ( ! sp ) { | 760 | if ( ! sp ) { |
761 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 761 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
762 | } | 762 | } |
763 | sp->usrReadConfig(); | 763 | sp->usrReadConfig(); |
764 | #ifndef DESKTOP_VERSION | 764 | #ifndef DESKTOP_VERSION |
765 | sp->showMaximized(); | 765 | sp->showMaximized(); |
766 | #else | 766 | #else |
767 | sp->show(); | 767 | sp->show(); |
768 | #endif | 768 | #endif |
769 | sp->exec(); | 769 | sp->exec(); |
770 | mSyncProfileNames = sp->getSyncProfileNames(); | 770 | mSyncProfileNames = sp->getSyncProfileNames(); |
771 | mLocalMachineName = sp->getLocalMachineName (); | 771 | mLocalMachineName = sp->getLocalMachineName (); |
772 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 772 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
773 | } | 773 | } |
774 | void KSyncManager::syncKDE() | 774 | void KSyncManager::syncKDE() |
775 | { | 775 | { |
776 | emit save(); | 776 | emit save(); |
777 | switch(mTargetApp) | 777 | switch(mTargetApp) |
778 | { | 778 | { |
779 | case (KAPI): | 779 | case (KAPI): |
780 | 780 | ||
781 | break; | 781 | break; |
782 | case (KOPI): | 782 | case (KOPI): |
783 | { | 783 | { |
784 | QString command ="./kdecaldump"; | 784 | QString command = qApp->applicationDirPath () + "/kdecaldump"; |
785 | if ( ! QFile::exists ( command ) ) | ||
786 | command = "kdecaldump"; | ||
787 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | ||
785 | system ( command.latin1()); | 788 | system ( command.latin1()); |
786 | if ( syncWithFile( "/tmp/kdedumpall.ics",true ) ) { | 789 | if ( syncWithFile( fileName,true ) ) { |
787 | if ( mWriteBackFile ) { | 790 | if ( mWriteBackFile ) { |
788 | command += " --read"; | 791 | command += " --read"; |
789 | system ( command.latin1()); | 792 | system ( command.latin1()); |
790 | } | 793 | } |
791 | } | 794 | } |
792 | 795 | ||
793 | } | 796 | } |
794 | break; | 797 | break; |
795 | case (PWMPI): | 798 | case (PWMPI): |
796 | 799 | ||
797 | break; | 800 | break; |
798 | default: | 801 | default: |
799 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 802 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
800 | break; | 803 | break; |
801 | 804 | ||
802 | } | 805 | } |
803 | } | 806 | } |
804 | 807 | ||
805 | void KSyncManager::syncSharp() | 808 | void KSyncManager::syncSharp() |
806 | { | 809 | { |
807 | 810 | ||
808 | if ( ! syncExternalApplication("sharp") ) | 811 | if ( ! syncExternalApplication("sharp") ) |
809 | qDebug("ERROR sync sharp "); | 812 | qDebug("ERROR sync sharp "); |
810 | } | 813 | } |
811 | 814 | ||
812 | bool KSyncManager::syncExternalApplication(QString resource) | 815 | bool KSyncManager::syncExternalApplication(QString resource) |
813 | { | 816 | { |
814 | 817 | ||
815 | emit save(); | 818 | emit save(); |
816 | 819 | ||
817 | if ( mAskForPreferences ) | 820 | if ( mAskForPreferences ) |
818 | edit_sync_options(); | 821 | edit_sync_options(); |
819 | 822 | ||
820 | qDebug("Sync extern %s", resource.latin1()); | 823 | qDebug("Sync extern %s", resource.latin1()); |
821 | 824 | ||
822 | bool syncOK = mImplementation->syncExternal(this, resource); | 825 | bool syncOK = mImplementation->syncExternal(this, resource); |
823 | 826 | ||
824 | return syncOK; | 827 | return syncOK; |
825 | 828 | ||
826 | } | 829 | } |
827 | 830 | ||
828 | void KSyncManager::syncPhone() | 831 | void KSyncManager::syncPhone() |
829 | { | 832 | { |
830 | 833 | ||
831 | syncExternalApplication("phone"); | 834 | syncExternalApplication("phone"); |
832 | 835 | ||
833 | } | 836 | } |
834 | 837 | ||
835 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 838 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
836 | { | 839 | { |
837 | if (!bar->isVisible()) | 840 | if (!bar->isVisible()) |
838 | { | 841 | { |
839 | bar->setCaption (caption); | 842 | bar->setCaption (caption); |
840 | bar->setTotalSteps ( total ) ; | 843 | bar->setTotalSteps ( total ) ; |
841 | 844 | ||
842 | bar->show(); | 845 | bar->show(); |
843 | } | 846 | } |
844 | 847 | ||
845 | bar->setProgress( percentage ); | 848 | bar->setProgress( percentage ); |
846 | } | 849 | } |
847 | 850 | ||
848 | void KSyncManager::hideProgressBar() | 851 | void KSyncManager::hideProgressBar() |
849 | { | 852 | { |
850 | bar->hide(); | 853 | bar->hide(); |
851 | } | 854 | } |
852 | 855 | ||
853 | bool KSyncManager::isProgressBarCanceled() | 856 | bool KSyncManager::isProgressBarCanceled() |
854 | { | 857 | { |
855 | return !bar->isVisible(); | 858 | return !bar->isVisible(); |
856 | } | 859 | } |
857 | 860 | ||
858 | QString KSyncManager::syncFileName() | 861 | QString KSyncManager::syncFileName() |
859 | { | 862 | { |
860 | 863 | ||
861 | QString fn = "tempfile"; | 864 | QString fn = "tempfile"; |
862 | switch(mTargetApp) | 865 | switch(mTargetApp) |
863 | { | 866 | { |
864 | case (KAPI): | 867 | case (KAPI): |
865 | fn = "tempsyncab.vcf"; | 868 | fn = "tempsyncab.vcf"; |
866 | break; | 869 | break; |
867 | case (KOPI): | 870 | case (KOPI): |
868 | fn = "tempsynccal.ics"; | 871 | fn = "tempsynccal.ics"; |
869 | break; | 872 | break; |
870 | case (PWMPI): | 873 | case (PWMPI): |
871 | fn = "tempsyncpw.pwm"; | 874 | fn = "tempsyncpw.pwm"; |
872 | break; | 875 | break; |
873 | default: | 876 | default: |
874 | break; | 877 | break; |
875 | } | 878 | } |
876 | #ifdef _WIN32_ | 879 | #ifdef _WIN32_ |
877 | return locateLocal( "tmp", fn ); | 880 | return locateLocal( "tmp", fn ); |
878 | #else | 881 | #else |
879 | return (QString( "/tmp/" )+ fn ); | 882 | return (QString( "/tmp/" )+ fn ); |
880 | #endif | 883 | #endif |
881 | } | 884 | } |
882 | 885 | ||
883 | void KSyncManager::syncPi() | 886 | void KSyncManager::syncPi() |
884 | { | 887 | { |
885 | mPisyncFinished = false; | 888 | mPisyncFinished = false; |
886 | qApp->processEvents(); | 889 | qApp->processEvents(); |
887 | if ( mAskForPreferences ) | 890 | if ( mAskForPreferences ) |
888 | edit_pisync_options(); | 891 | edit_pisync_options(); |
889 | bool ok; | 892 | bool ok; |
890 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 893 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
891 | if ( ! ok ) { | 894 | if ( ! ok ) { |
892 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 895 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
893 | return; | 896 | return; |
894 | } | 897 | } |
895 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 898 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
896 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 899 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
897 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 900 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
898 | commandSocket->readFile( syncFileName() ); | 901 | commandSocket->readFile( syncFileName() ); |
899 | } | 902 | } |
900 | 903 | ||
901 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 904 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
902 | { | 905 | { |
903 | //enum { success, errorW, errorR, quiet }; | 906 | //enum { success, errorW, errorR, quiet }; |
904 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 907 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
905 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 908 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
906 | delete s; | 909 | delete s; |
907 | if ( state == KCommandSocket::errorR ) { | 910 | if ( state == KCommandSocket::errorR ) { |
908 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 911 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
909 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 912 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
910 | commandSocket->sendStop(); | 913 | commandSocket->sendStop(); |
911 | } | 914 | } |
912 | mPisyncFinished = true; | 915 | mPisyncFinished = true; |
913 | return; | 916 | return; |
914 | 917 | ||
915 | } else if ( state == KCommandSocket::errorW ) { | 918 | } else if ( state == KCommandSocket::errorW ) { |
916 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 919 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
917 | mPisyncFinished = true; | 920 | mPisyncFinished = true; |
918 | 921 | ||
919 | } else if ( state == KCommandSocket::successR ) { | 922 | } else if ( state == KCommandSocket::successR ) { |
920 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 923 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
921 | 924 | ||
922 | } else if ( state == KCommandSocket::successW ) { | 925 | } else if ( state == KCommandSocket::successW ) { |
923 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 926 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
924 | mPisyncFinished = true; | 927 | mPisyncFinished = true; |
925 | } | 928 | } |
926 | 929 | ||
927 | delete s; | 930 | delete s; |
928 | } | 931 | } |
929 | 932 | ||
930 | void KSyncManager::readFileFromSocket() | 933 | void KSyncManager::readFileFromSocket() |
931 | { | 934 | { |
932 | QString fileName = syncFileName(); | 935 | QString fileName = syncFileName(); |
933 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 936 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
934 | if ( ! syncWithFile( fileName , true ) ) { | 937 | if ( ! syncWithFile( fileName , true ) ) { |
935 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 938 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
936 | mPisyncFinished = true; | 939 | mPisyncFinished = true; |
937 | return; | 940 | return; |
938 | } | 941 | } |
939 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 942 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
940 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 943 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
941 | if ( mWriteBackFile ) | 944 | if ( mWriteBackFile ) |
942 | commandSocket->writeFile( fileName ); | 945 | commandSocket->writeFile( fileName ); |
943 | else { | 946 | else { |
944 | commandSocket->sendStop(); | 947 | commandSocket->sendStop(); |
945 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 948 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
946 | mPisyncFinished = true; | 949 | mPisyncFinished = true; |
947 | } | 950 | } |
948 | } | 951 | } |
949 | 952 | ||
950 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 953 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
951 | { | 954 | { |
952 | mPassWord = pw; | 955 | mPassWord = pw; |
953 | mSocket = 0; | 956 | mSocket = 0; |
954 | mSyncActionDialog = 0; | 957 | mSyncActionDialog = 0; |
955 | blockRC = false; | 958 | blockRC = false; |
956 | }; | 959 | }; |
957 | 960 | ||
958 | void KServerSocket::newConnection ( int socket ) | 961 | void KServerSocket::newConnection ( int socket ) |
959 | { | 962 | { |
960 | // qDebug("KServerSocket:New connection %d ", socket); | 963 | // qDebug("KServerSocket:New connection %d ", socket); |
961 | if ( mSocket ) { | 964 | if ( mSocket ) { |
962 | qDebug("KServerSocket::newConnection Socket deleted! "); | 965 | qDebug("KServerSocket::newConnection Socket deleted! "); |
963 | delete mSocket; | 966 | delete mSocket; |
964 | mSocket = 0; | 967 | mSocket = 0; |
965 | } | 968 | } |
966 | mSocket = new QSocket( this ); | 969 | mSocket = new QSocket( this ); |
967 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 970 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
968 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 971 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
969 | mSocket->setSocket( socket ); | 972 | mSocket->setSocket( socket ); |
970 | } | 973 | } |
971 | 974 | ||
972 | void KServerSocket::discardClient() | 975 | void KServerSocket::discardClient() |
973 | { | 976 | { |
974 | //qDebug(" KServerSocket::discardClient()"); | 977 | //qDebug(" KServerSocket::discardClient()"); |
975 | if ( mSocket ) { | 978 | if ( mSocket ) { |
976 | delete mSocket; | 979 | delete mSocket; |
977 | mSocket = 0; | 980 | mSocket = 0; |
978 | } | 981 | } |