-rw-r--r-- | libkdepim/ksyncmanager.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 8851097..40d8e47 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -656,257 +656,261 @@ void KSyncManager::edit_pisync_options() | |||
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 = qApp->applicationDirPath () + "/kdecaldump"; | 784 | #ifdef DESKTOP_VERSION |
785 | QString command = qApp->applicationDirPath () + "/kdecaldump"; | ||
786 | #else | ||
787 | QString command = "kdecaldump"; | ||
788 | #endif | ||
785 | if ( ! QFile::exists ( command ) ) | 789 | if ( ! QFile::exists ( command ) ) |
786 | command = "kdecaldump"; | 790 | command = "kdecaldump"; |
787 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 791 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
788 | system ( command.latin1()); | 792 | system ( command.latin1()); |
789 | if ( syncWithFile( fileName,true ) ) { | 793 | if ( syncWithFile( fileName,true ) ) { |
790 | if ( mWriteBackFile ) { | 794 | if ( mWriteBackFile ) { |
791 | command += " --read"; | 795 | command += " --read"; |
792 | system ( command.latin1()); | 796 | system ( command.latin1()); |
793 | } | 797 | } |
794 | } | 798 | } |
795 | 799 | ||
796 | } | 800 | } |
797 | break; | 801 | break; |
798 | case (PWMPI): | 802 | case (PWMPI): |
799 | 803 | ||
800 | break; | 804 | break; |
801 | default: | 805 | default: |
802 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 806 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
803 | break; | 807 | break; |
804 | 808 | ||
805 | } | 809 | } |
806 | } | 810 | } |
807 | 811 | ||
808 | void KSyncManager::syncSharp() | 812 | void KSyncManager::syncSharp() |
809 | { | 813 | { |
810 | 814 | ||
811 | if ( ! syncExternalApplication("sharp") ) | 815 | if ( ! syncExternalApplication("sharp") ) |
812 | qDebug("ERROR sync sharp "); | 816 | qDebug("ERROR sync sharp "); |
813 | } | 817 | } |
814 | 818 | ||
815 | bool KSyncManager::syncExternalApplication(QString resource) | 819 | bool KSyncManager::syncExternalApplication(QString resource) |
816 | { | 820 | { |
817 | 821 | ||
818 | emit save(); | 822 | emit save(); |
819 | 823 | ||
820 | if ( mAskForPreferences ) | 824 | if ( mAskForPreferences ) |
821 | edit_sync_options(); | 825 | edit_sync_options(); |
822 | 826 | ||
823 | qDebug("Sync extern %s", resource.latin1()); | 827 | qDebug("Sync extern %s", resource.latin1()); |
824 | 828 | ||
825 | bool syncOK = mImplementation->syncExternal(this, resource); | 829 | bool syncOK = mImplementation->syncExternal(this, resource); |
826 | 830 | ||
827 | return syncOK; | 831 | return syncOK; |
828 | 832 | ||
829 | } | 833 | } |
830 | 834 | ||
831 | void KSyncManager::syncPhone() | 835 | void KSyncManager::syncPhone() |
832 | { | 836 | { |
833 | 837 | ||
834 | syncExternalApplication("phone"); | 838 | syncExternalApplication("phone"); |
835 | 839 | ||
836 | } | 840 | } |
837 | 841 | ||
838 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 842 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
839 | { | 843 | { |
840 | if (!bar->isVisible()) | 844 | if (!bar->isVisible()) |
841 | { | 845 | { |
842 | bar->setCaption (caption); | 846 | bar->setCaption (caption); |
843 | bar->setTotalSteps ( total ) ; | 847 | bar->setTotalSteps ( total ) ; |
844 | 848 | ||
845 | bar->show(); | 849 | bar->show(); |
846 | } | 850 | } |
847 | 851 | ||
848 | bar->setProgress( percentage ); | 852 | bar->setProgress( percentage ); |
849 | } | 853 | } |
850 | 854 | ||
851 | void KSyncManager::hideProgressBar() | 855 | void KSyncManager::hideProgressBar() |
852 | { | 856 | { |
853 | bar->hide(); | 857 | bar->hide(); |
854 | } | 858 | } |
855 | 859 | ||
856 | bool KSyncManager::isProgressBarCanceled() | 860 | bool KSyncManager::isProgressBarCanceled() |
857 | { | 861 | { |
858 | return !bar->isVisible(); | 862 | return !bar->isVisible(); |
859 | } | 863 | } |
860 | 864 | ||
861 | QString KSyncManager::syncFileName() | 865 | QString KSyncManager::syncFileName() |
862 | { | 866 | { |
863 | 867 | ||
864 | QString fn = "tempfile"; | 868 | QString fn = "tempfile"; |
865 | switch(mTargetApp) | 869 | switch(mTargetApp) |
866 | { | 870 | { |
867 | case (KAPI): | 871 | case (KAPI): |
868 | fn = "tempsyncab.vcf"; | 872 | fn = "tempsyncab.vcf"; |
869 | break; | 873 | break; |
870 | case (KOPI): | 874 | case (KOPI): |
871 | fn = "tempsynccal.ics"; | 875 | fn = "tempsynccal.ics"; |
872 | break; | 876 | break; |
873 | case (PWMPI): | 877 | case (PWMPI): |
874 | fn = "tempsyncpw.pwm"; | 878 | fn = "tempsyncpw.pwm"; |
875 | break; | 879 | break; |
876 | default: | 880 | default: |
877 | break; | 881 | break; |
878 | } | 882 | } |
879 | #ifdef _WIN32_ | 883 | #ifdef _WIN32_ |
880 | return locateLocal( "tmp", fn ); | 884 | return locateLocal( "tmp", fn ); |
881 | #else | 885 | #else |
882 | return (QString( "/tmp/" )+ fn ); | 886 | return (QString( "/tmp/" )+ fn ); |
883 | #endif | 887 | #endif |
884 | } | 888 | } |
885 | 889 | ||
886 | void KSyncManager::syncPi() | 890 | void KSyncManager::syncPi() |
887 | { | 891 | { |
888 | mPisyncFinished = false; | 892 | mPisyncFinished = false; |
889 | qApp->processEvents(); | 893 | qApp->processEvents(); |
890 | if ( mAskForPreferences ) | 894 | if ( mAskForPreferences ) |
891 | edit_pisync_options(); | 895 | edit_pisync_options(); |
892 | bool ok; | 896 | bool ok; |
893 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 897 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
894 | if ( ! ok ) { | 898 | if ( ! ok ) { |
895 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 899 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
896 | return; | 900 | return; |
897 | } | 901 | } |
898 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 902 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
899 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 903 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
900 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 904 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
901 | commandSocket->readFile( syncFileName() ); | 905 | commandSocket->readFile( syncFileName() ); |
902 | } | 906 | } |
903 | 907 | ||
904 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 908 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
905 | { | 909 | { |
906 | //enum { success, errorW, errorR, quiet }; | 910 | //enum { success, errorW, errorR, quiet }; |
907 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 911 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
908 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 912 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
909 | delete s; | 913 | delete s; |
910 | if ( state == KCommandSocket::errorR ) { | 914 | if ( state == KCommandSocket::errorR ) { |
911 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 915 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
912 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 916 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |