author | zautrix <zautrix> | 2006-02-24 18:49:56 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2006-02-24 18:49:56 (UTC) |
commit | d7738fdfc685192eb2f8317db6ffad3c246001c8 (patch) (unidiff) | |
tree | d9aae6ca97851fd1b53c4d9e74740a5ee2b69ea9 /libkdepim | |
parent | 987757f168bbae56100f2aff763b865e81ceec18 (diff) | |
download | kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.zip kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.gz kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.bz2 |
kapi sync
-rw-r--r-- | libkdepim/externalapphandler.cpp | 2 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 71 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 3 | ||||
-rw-r--r-- | libkdepim/libkdepim.pro | 15 |
4 files changed, 87 insertions, 4 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 59be506..f376e6c 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -722,256 +722,258 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS | |||
722 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2; | 722 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2; |
723 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 723 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
724 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2; | 724 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2; |
725 | } | 725 | } |
726 | else | 726 | else |
727 | { | 727 | { |
728 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 728 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
729 | if (!dai) | 729 | if (!dai) |
730 | { | 730 | { |
731 | qDebug("could not find configured email application."); | 731 | qDebug("could not find configured email application."); |
732 | return false; | 732 | return false; |
733 | } | 733 | } |
734 | channel = dai->_channel; | 734 | channel = dai->_channel; |
735 | message2 = dai->_message2; | 735 | message2 = dai->_message2; |
736 | parameters2 = dai->_parameters2; | 736 | parameters2 = dai->_parameters2; |
737 | message = dai->_message; | 737 | message = dai->_message; |
738 | parameters = dai->_parameters; | 738 | parameters = dai->_parameters; |
739 | } | 739 | } |
740 | 740 | ||
741 | //first check if one of the mailers need the emails right in the message. | 741 | //first check if one of the mailers need the emails right in the message. |
742 | message2 = translateMessage(message2, emails, urls); | 742 | message2 = translateMessage(message2, emails, urls); |
743 | #ifdef DEBUG_EXT_APP_HANDLER | 743 | #ifdef DEBUG_EXT_APP_HANDLER |
744 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 744 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); |
745 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | 745 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); |
746 | #endif | 746 | #endif |
747 | qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); | 747 | qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); |
748 | //KMessageBox::sorry( 0, message2 ); | 748 | //KMessageBox::sorry( 0, message2 ); |
749 | QProcess * proc = new QProcess( this ); | 749 | QProcess * proc = new QProcess( this ); |
750 | int i = 0; | 750 | int i = 0; |
751 | proc->addArgument( channel ); | 751 | proc->addArgument( channel ); |
752 | 752 | ||
753 | if ( message.find (" " ) > 0 ) { | 753 | if ( message.find (" " ) > 0 ) { |
754 | QStringList list = QStringList::split( " ", message ); | 754 | QStringList list = QStringList::split( " ", message ); |
755 | int i = 0; | 755 | int i = 0; |
756 | while ( i < list.count ( ) ) { | 756 | while ( i < list.count ( ) ) { |
757 | //qDebug("add%sdd ",list[i].latin1() ); | 757 | //qDebug("add%sdd ",list[i].latin1() ); |
758 | proc->addArgument( list[i] ); | 758 | proc->addArgument( list[i] ); |
759 | //KMessageBox::sorry( 0,list[i]); | 759 | //KMessageBox::sorry( 0,list[i]); |
760 | ++i; | 760 | ++i; |
761 | } | 761 | } |
762 | } else { | 762 | } else { |
763 | proc->addArgument(message ); | 763 | proc->addArgument(message ); |
764 | //KMessageBox::sorry( 0, message ); | 764 | //KMessageBox::sorry( 0, message ); |
765 | 765 | ||
766 | } | 766 | } |
767 | 767 | ||
768 | parameters2 = translateMessage(parameters2, urls, "" ); | 768 | parameters2 = translateMessage(parameters2, urls, "" ); |
769 | QString arg = "to='%1'"; | 769 | QString arg = "to='%1'"; |
770 | arg = arg.arg( emails ) + ","+parameters2;; | 770 | arg = arg.arg( emails ) + ","+parameters2;; |
771 | 771 | ||
772 | //KMessageBox::sorry( 0,arg ); | 772 | //KMessageBox::sorry( 0,arg ); |
773 | //qDebug("2add%sdd ",arg.latin1() ); | 773 | //qDebug("2add%sdd ",arg.latin1() ); |
774 | proc->addArgument( arg); | 774 | proc->addArgument( arg); |
775 | proc->launch(""); | 775 | proc->launch(""); |
776 | #endif | 776 | #endif |
777 | 777 | ||
778 | return true; | 778 | return true; |
779 | } | 779 | } |
780 | 780 | ||
781 | /************************************************************************** | 781 | /************************************************************************** |
782 | * | 782 | * |
783 | **************************************************************************/ | 783 | **************************************************************************/ |
784 | 784 | ||
785 | 785 | ||
786 | //calls the emailapplication and creates a mail with parameter emails as recipients | 786 | //calls the emailapplication and creates a mail with parameter emails as recipients |
787 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 787 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
788 | { | 788 | { |
789 | 789 | ||
790 | QString channel; | 790 | QString channel; |
791 | QString message; | 791 | QString message; |
792 | QString parameters; | 792 | QString parameters; |
793 | 793 | ||
794 | 794 | ||
795 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 795 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
796 | if (client == KPimGlobalPrefs::OTHER_EMC) | 796 | if (client == KPimGlobalPrefs::OTHER_EMC) |
797 | { | 797 | { |
798 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 798 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
799 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 799 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
800 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 800 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
801 | } | 801 | } |
802 | else | 802 | else |
803 | { | 803 | { |
804 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | 804 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); |
805 | if (!dai) | 805 | if (!dai) |
806 | { | 806 | { |
807 | qDebug("could not find configured email application."); | 807 | qDebug("could not find configured email application."); |
808 | return false; | 808 | return false; |
809 | } | 809 | } |
810 | channel = dai->_channel; | 810 | channel = dai->_channel; |
811 | message = dai->_message; | 811 | message = dai->_message; |
812 | parameters = dai->_parameters; | 812 | parameters = dai->_parameters; |
813 | } | 813 | } |
814 | 814 | ||
815 | #ifdef DESKTOP_VERSION | 815 | #ifdef DESKTOP_VERSION |
816 | //message = channel + " " +message + " \""+ parameters + "\""; | 816 | //message = channel + " " +message + " \""+ parameters + "\""; |
817 | #endif | 817 | #endif |
818 | //first check if one of the mailers need the emails right in the message. | 818 | //first check if one of the mailers need the emails right in the message. |
819 | message = translateMessage(message, name, emailadress); | 819 | message = translateMessage(message, name, emailadress); |
820 | 820 | ||
821 | #ifdef DEBUG_EXT_APP_HANDLER | 821 | #ifdef DEBUG_EXT_APP_HANDLER |
822 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 822 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
823 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); | 823 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); |
824 | #endif | 824 | #endif |
825 | 825 | ||
826 | #ifndef DESKTOP_VERSION | 826 | #ifndef DESKTOP_VERSION |
827 | QCopEnvelope e(channel.latin1(), message.latin1()); | 827 | QCopEnvelope e(channel.latin1(), message.latin1()); |
828 | //US we need no names in the To field. The emailadresses are enough | 828 | //US we need no names in the To field. The emailadresses are enough |
829 | 829 | ||
830 | passParameters(&e, parameters, name, emailadress); | 830 | passParameters(&e, parameters, name, emailadress); |
831 | #else // DESKTOP_VERSION | 831 | #else // DESKTOP_VERSION |
832 | 832 | ||
833 | //KMessageBox::sorry( 0,channel ); | 833 | //KMessageBox::sorry( 0,channel ); |
834 | QProcess * proc = new QProcess( this ); | 834 | QProcess * proc = new QProcess( this ); |
835 | proc->addArgument( channel ); | 835 | proc->addArgument( channel ); |
836 | if ( message.find (" " ) > 0 ) { | 836 | if ( message.find (" " ) > 0 ) { |
837 | QStringList list = QStringList::split( " ", message ); | 837 | QStringList list = QStringList::split( " ", message ); |
838 | int i = 0; | 838 | int i = 0; |
839 | while ( i < list.count ( ) ) { | 839 | while ( i < list.count ( ) ) { |
840 | //qDebug("add%sdd ",list[i].latin1() ); | 840 | //qDebug("add%sdd ",list[i].latin1() ); |
841 | proc->addArgument( list[i] ); | 841 | proc->addArgument( list[i] ); |
842 | //KMessageBox::sorry( 0,list[i]); | 842 | //KMessageBox::sorry( 0,list[i]); |
843 | ++i; | 843 | ++i; |
844 | } | 844 | } |
845 | } else { | 845 | } else { |
846 | proc->addArgument(message ); | 846 | proc->addArgument(message ); |
847 | 847 | ||
848 | } | 848 | } |
849 | parameters = translateMessage(parameters, name, emailadress); | 849 | parameters = translateMessage(parameters, name, emailadress); |
850 | |||
851 | //KMessageBox::information(0,parameters); | ||
850 | proc->addArgument( parameters ); | 852 | proc->addArgument( parameters ); |
851 | proc->launch(""); | 853 | proc->launch(""); |
852 | #endif | 854 | #endif |
853 | 855 | ||
854 | return true; | 856 | return true; |
855 | } | 857 | } |
856 | 858 | ||
857 | /************************************************************************** | 859 | /************************************************************************** |
858 | * | 860 | * |
859 | **************************************************************************/ | 861 | **************************************************************************/ |
860 | 862 | ||
861 | //calls the emailapplication and creates a mail with parameter as recipients | 863 | //calls the emailapplication and creates a mail with parameter as recipients |
862 | // parameters format is | 864 | // parameters format is |
863 | // NAME <EMAIL>:SUBJECT | 865 | // NAME <EMAIL>:SUBJECT |
864 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) | 866 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) |
865 | { | 867 | { |
866 | QString line = adressline; | 868 | QString line = adressline; |
867 | 869 | ||
868 | int first = line.find( "<"); | 870 | int first = line.find( "<"); |
869 | int last = line.find( ">"); | 871 | int last = line.find( ">"); |
870 | QString name = line.left(first); | 872 | QString name = line.left(first); |
871 | QString emailadress = line.mid(first+1, last-first-1); | 873 | QString emailadress = line.mid(first+1, last-first-1); |
872 | 874 | ||
873 | //Subject can not be handled right now. | 875 | //Subject can not be handled right now. |
874 | return mailToOneContact( name, emailadress ); | 876 | return mailToOneContact( name, emailadress ); |
875 | 877 | ||
876 | } | 878 | } |
877 | 879 | ||
878 | 880 | ||
879 | /************************************************************************** | 881 | /************************************************************************** |
880 | * | 882 | * |
881 | **************************************************************************/ | 883 | **************************************************************************/ |
882 | 884 | ||
883 | //calls the phoneapplication with the number | 885 | //calls the phoneapplication with the number |
884 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | 886 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) |
885 | { | 887 | { |
886 | #ifndef DESKTOP_VERSION | 888 | #ifndef DESKTOP_VERSION |
887 | QString channel; | 889 | QString channel; |
888 | QString message; | 890 | QString message; |
889 | QString parameters; | 891 | QString parameters; |
890 | 892 | ||
891 | 893 | ||
892 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 894 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
893 | if (client == KPimGlobalPrefs::OTHER_PHC) | 895 | if (client == KPimGlobalPrefs::OTHER_PHC) |
894 | { | 896 | { |
895 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; | 897 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; |
896 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; | 898 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; |
897 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; | 899 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; |
898 | } | 900 | } |
899 | else | 901 | else |
900 | { | 902 | { |
901 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | 903 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); |
902 | if (!dai) | 904 | if (!dai) |
903 | { | 905 | { |
904 | qDebug("could not find configured phone application."); | 906 | qDebug("could not find configured phone application."); |
905 | return false; | 907 | return false; |
906 | } | 908 | } |
907 | channel = dai->_channel; | 909 | channel = dai->_channel; |
908 | message = dai->_message; | 910 | message = dai->_message; |
909 | parameters = dai->_parameters; | 911 | parameters = dai->_parameters; |
910 | } | 912 | } |
911 | 913 | ||
912 | 914 | ||
913 | //first check if one of the mailers need the emails right in the message. | 915 | //first check if one of the mailers need the emails right in the message. |
914 | message = translateMessage(message, phonenumber, ""); | 916 | message = translateMessage(message, phonenumber, ""); |
915 | 917 | ||
916 | 918 | ||
917 | #ifdef DEBUG_EXT_APP_HANDLER | 919 | #ifdef DEBUG_EXT_APP_HANDLER |
918 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 920 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
919 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 921 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
920 | #endif | 922 | #endif |
921 | 923 | ||
922 | QCopEnvelope e(channel.latin1(), message.latin1()); | 924 | QCopEnvelope e(channel.latin1(), message.latin1()); |
923 | //US we need no names in the To field. The emailadresses are enough | 925 | //US we need no names in the To field. The emailadresses are enough |
924 | 926 | ||
925 | passParameters(&e, parameters, phonenumber, ""); | 927 | passParameters(&e, parameters, phonenumber, ""); |
926 | 928 | ||
927 | 929 | ||
928 | #else | 930 | #else |
929 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); | 931 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); |
930 | #endif | 932 | #endif |
931 | 933 | ||
932 | 934 | ||
933 | return true; | 935 | return true; |
934 | } | 936 | } |
935 | 937 | ||
936 | /************************************************************************** | 938 | /************************************************************************** |
937 | * | 939 | * |
938 | **************************************************************************/ | 940 | **************************************************************************/ |
939 | 941 | ||
940 | //calls the smsapplication with the number | 942 | //calls the smsapplication with the number |
941 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 943 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) |
942 | { | 944 | { |
943 | #ifndef DESKTOP_VERSION | 945 | #ifndef DESKTOP_VERSION |
944 | QString channel; | 946 | QString channel; |
945 | QString message; | 947 | QString message; |
946 | QString parameters; | 948 | QString parameters; |
947 | 949 | ||
948 | 950 | ||
949 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 951 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
950 | if (client == KPimGlobalPrefs::OTHER_SMC) | 952 | if (client == KPimGlobalPrefs::OTHER_SMC) |
951 | { | 953 | { |
952 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; | 954 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; |
953 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; | 955 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; |
954 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; | 956 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; |
955 | } | 957 | } |
956 | else | 958 | else |
957 | { | 959 | { |
958 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); | 960 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); |
959 | if (!dai) | 961 | if (!dai) |
960 | { | 962 | { |
961 | qDebug("could not find configured sms application."); | 963 | qDebug("could not find configured sms application."); |
962 | return false; | 964 | return false; |
963 | } | 965 | } |
964 | channel = dai->_channel; | 966 | channel = dai->_channel; |
965 | message = dai->_message; | 967 | message = dai->_message; |
966 | parameters = dai->_parameters; | 968 | parameters = dai->_parameters; |
967 | } | 969 | } |
968 | 970 | ||
969 | 971 | ||
970 | //first check if one of the mailers need the emails right in the message. | 972 | //first check if one of the mailers need the emails right in the message. |
971 | message = translateMessage(message, phonenumber, ""); | 973 | message = translateMessage(message, phonenumber, ""); |
972 | 974 | ||
973 | 975 | ||
974 | #ifdef DEBUG_EXT_APP_HANDLER | 976 | #ifdef DEBUG_EXT_APP_HANDLER |
975 | qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 977 | qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
976 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 978 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
977 | #endif | 979 | #endif |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index b7929ec..5708dfc 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,274 +1,274 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | #include <qapplication.h> | 52 | #include <qapplication.h> |
53 | 53 | ||
54 | #include <klocale.h> | 54 | #include <klocale.h> |
55 | #include <kglobal.h> | 55 | #include <kglobal.h> |
56 | #include <kconfig.h> | 56 | #include <kconfig.h> |
57 | #include <kfiledialog.h> | 57 | #include <kfiledialog.h> |
58 | 58 | ||
59 | QDateTime KSyncManager::mRequestedSyncEvent; | 59 | QDateTime KSyncManager::mRequestedSyncEvent; |
60 | 60 | ||
61 | 61 | ||
62 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 62 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
63 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) | 63 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) |
64 | { | 64 | { |
65 | mServerSocket = 0; | 65 | mServerSocket = 0; |
66 | bar = new QProgressBar ( 1, 0 ); | 66 | bar = new QProgressBar ( 1, 0 ); |
67 | bar->setCaption (""); | 67 | bar->setCaption (""); |
68 | mWriteBackInPast = 2; | 68 | mWriteBackInPast = 2; |
69 | 69 | ||
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
73 | KSyncManager::~KSyncManager() | 73 | KSyncManager::~KSyncManager() |
74 | { | 74 | { |
75 | delete bar; | 75 | delete bar; |
76 | } | 76 | } |
77 | 77 | ||
78 | void KSyncManager::setDefaultFileName( QString s) | 78 | void KSyncManager::setDefaultFileName( QString s) |
79 | { | 79 | { |
80 | mDefFileName = s ; | 80 | mDefFileName = s ; |
81 | if ( mPrefs->mPassiveSyncAutoStart ) | 81 | if ( mPrefs->mPassiveSyncAutoStart ) |
82 | enableQuick( false ); | 82 | enableQuick( false ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void KSyncManager::fillSyncMenu() | 85 | void KSyncManager::fillSyncMenu() |
86 | { | 86 | { |
87 | if ( mSyncMenu->count() ) | 87 | if ( mSyncMenu->count() ) |
88 | mSyncMenu->clear(); | 88 | mSyncMenu->clear(); |
89 | 89 | ||
90 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 90 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
91 | mSyncMenu->insertSeparator(); | 91 | mSyncMenu->insertSeparator(); |
92 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 92 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
93 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 93 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
94 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | 94 | clearMenu->insertItem( i18n("For all profiles"), 1 ); |
95 | clearMenu->insertSeparator(); | 95 | clearMenu->insertSeparator(); |
96 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | 96 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); |
97 | mSyncMenu->insertSeparator(); | 97 | mSyncMenu->insertSeparator(); |
98 | if ( mServerSocket == 0 ) { | 98 | if ( mServerSocket == 0 ) { |
99 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 99 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
100 | } else { | 100 | } else { |
101 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 101 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
102 | } | 102 | } |
103 | mSyncMenu->insertSeparator(); | 103 | mSyncMenu->insertSeparator(); |
104 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 104 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
105 | mSyncMenu->insertSeparator(); | 105 | mSyncMenu->insertSeparator(); |
106 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 106 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
107 | config.setGroup("General"); | 107 | config.setGroup("General"); |
108 | QStringList prof = config.readListEntry("SyncProfileNames"); | 108 | QStringList prof = config.readListEntry("SyncProfileNames"); |
109 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 109 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
110 | if ( prof.count() < 2 ) { | 110 | if ( prof.count() < 2 ) { |
111 | prof.clear(); | 111 | prof.clear(); |
112 | QString externalName; | 112 | QString externalName; |
113 | #ifdef DESKTOP_VERSION | 113 | #ifdef DESKTOP_VERSION |
114 | #ifdef _WIN32_ | 114 | #ifdef _WIN32_ |
115 | externalName = "OutLook(not_implemented)"; | 115 | externalName = "OutLook"; |
116 | #else | 116 | #else |
117 | externalName = "KDE_Desktop"; | 117 | externalName = "KDE_Desktop"; |
118 | #endif | 118 | #endif |
119 | #else | 119 | #else |
120 | externalName = "Sharp_DTM"; | 120 | externalName = "Sharp_DTM"; |
121 | #endif | 121 | #endif |
122 | prof << externalName; | 122 | prof << externalName; |
123 | prof << i18n("Local_file"); | 123 | prof << i18n("Local_file"); |
124 | prof << i18n("Last_file"); | 124 | prof << i18n("Last_file"); |
125 | KSyncProfile* temp = new KSyncProfile (); | 125 | KSyncProfile* temp = new KSyncProfile (); |
126 | temp->setName( prof[0] ); | 126 | temp->setName( prof[0] ); |
127 | temp->writeConfig(&config); | 127 | temp->writeConfig(&config); |
128 | temp->setName( prof[1] ); | 128 | temp->setName( prof[1] ); |
129 | temp->writeConfig(&config); | 129 | temp->writeConfig(&config); |
130 | temp->setName( prof[2] ); | 130 | temp->setName( prof[2] ); |
131 | temp->writeConfig(&config); | 131 | temp->writeConfig(&config); |
132 | config.setGroup("General"); | 132 | config.setGroup("General"); |
133 | config.writeEntry("SyncProfileNames",prof); | 133 | config.writeEntry("SyncProfileNames",prof); |
134 | config.writeEntry("ExternSyncProfiles",externalName); | 134 | config.writeEntry("ExternSyncProfiles",externalName); |
135 | config.sync(); | 135 | config.sync(); |
136 | delete temp; | 136 | delete temp; |
137 | } | 137 | } |
138 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 138 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
139 | mSyncProfileNames = prof; | 139 | mSyncProfileNames = prof; |
140 | unsigned int i; | 140 | unsigned int i; |
141 | for ( i = 0; i < prof.count(); ++i ) { | 141 | for ( i = 0; i < prof.count(); ++i ) { |
142 | QString insertText = prof[i]; | 142 | QString insertText = prof[i]; |
143 | if ( i == 0 ) { | 143 | if ( i == 0 ) { |
144 | #ifdef DESKTOP_VERSION | 144 | #ifdef DESKTOP_VERSION |
145 | #ifdef _WIN32_ | 145 | #ifdef _WIN32_ |
146 | insertText = "OutLook(not_implemented)"; | 146 | insertText = "OutLook"; |
147 | #else | 147 | #else |
148 | insertText = "KDE_Desktop"; | 148 | insertText = "KDE_Desktop"; |
149 | #endif | 149 | #endif |
150 | #else | 150 | #else |
151 | insertText = "Sharp_DTM"; | 151 | insertText = "Sharp_DTM"; |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | mSyncMenu->insertItem( insertText, 1000+i ); | 154 | mSyncMenu->insertItem( insertText, 1000+i ); |
155 | clearMenu->insertItem( insertText, 1000+i ); | 155 | clearMenu->insertItem( insertText, 1000+i ); |
156 | if ( i == 2 ) | 156 | if ( i == 2 ) |
157 | mSyncMenu->insertSeparator(); | 157 | mSyncMenu->insertSeparator(); |
158 | } | 158 | } |
159 | QDir app_dir; | 159 | QDir app_dir; |
160 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 160 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
161 | if ( mTargetApp == PWMPI) { | 161 | if ( mTargetApp == PWMPI) { |
162 | mSyncMenu->removeItem( 1000 ); | 162 | mSyncMenu->removeItem( 1000 ); |
163 | clearMenu->removeItem( 1000 ); | 163 | clearMenu->removeItem( 1000 ); |
164 | } | 164 | } |
165 | #ifndef DESKTOP_VERSION | 165 | #ifndef DESKTOP_VERSION |
166 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 166 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
167 | mSyncMenu->removeItem( 1000 ); | 167 | mSyncMenu->removeItem( 1000 ); |
168 | clearMenu->removeItem( 1000 ); | 168 | clearMenu->removeItem( 1000 ); |
169 | } | 169 | } |
170 | #endif | 170 | #endif |
171 | mSyncMenu->removeItem( 1002 ); | 171 | mSyncMenu->removeItem( 1002 ); |
172 | clearMenu->removeItem( 1002 ); | 172 | clearMenu->removeItem( 1002 ); |
173 | } | 173 | } |
174 | void KSyncManager::slotClearMenu( int action ) | 174 | void KSyncManager::slotClearMenu( int action ) |
175 | { | 175 | { |
176 | QString syncDevice; | 176 | QString syncDevice; |
177 | if ( action > 999 ) { | 177 | if ( action > 999 ) { |
178 | syncDevice = mSyncProfileNames[action - 1000] ; | 178 | syncDevice = mSyncProfileNames[action - 1000] ; |
179 | } | 179 | } |
180 | 180 | ||
181 | 181 | ||
182 | 182 | ||
183 | int result = 0; | 183 | int result = 0; |
184 | QString sd; | 184 | QString sd; |
185 | if ( syncDevice.isEmpty() ) | 185 | if ( syncDevice.isEmpty() ) |
186 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 186 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
187 | else | 187 | else |
188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
189 | 189 | ||
190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
191 | 0, 1 ); | 191 | 0, 1 ); |
192 | if ( result ) | 192 | if ( result ) |
193 | return; | 193 | return; |
194 | mImplementation->removeSyncInfo( syncDevice ); | 194 | mImplementation->removeSyncInfo( syncDevice ); |
195 | } | 195 | } |
196 | void KSyncManager::slotSyncMenu( int action ) | 196 | void KSyncManager::slotSyncMenu( int action ) |
197 | { | 197 | { |
198 | qDebug("KSM::syncaction %d ", action); | 198 | qDebug("KSM::syncaction %d ", action); |
199 | mCurrentResourceLocal = ""; | 199 | mCurrentResourceLocal = ""; |
200 | emit multiResourceSyncStart( false ); | 200 | emit multiResourceSyncStart( false ); |
201 | if ( action == 5000 ) | 201 | if ( action == 5000 ) |
202 | return; | 202 | return; |
203 | mSyncWithDesktop = false; | 203 | mSyncWithDesktop = false; |
204 | if ( action == 0 ) { | 204 | if ( action == 0 ) { |
205 | 205 | ||
206 | // seems to be a Qt2 event handling bug | 206 | // seems to be a Qt2 event handling bug |
207 | // syncmenu.clear causes a segfault at first time | 207 | // syncmenu.clear causes a segfault at first time |
208 | // when we call it after the main event loop, it is ok | 208 | // when we call it after the main event loop, it is ok |
209 | // same behaviour when calling OM/Pi via QCOP for the first time | 209 | // same behaviour when calling OM/Pi via QCOP for the first time |
210 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 210 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
211 | //confSync(); | 211 | //confSync(); |
212 | 212 | ||
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | if ( action == 1 ) { | 215 | if ( action == 1 ) { |
216 | multiSync( true ); | 216 | multiSync( true ); |
217 | return; | 217 | return; |
218 | } | 218 | } |
219 | if ( action == 2 ) { | 219 | if ( action == 2 ) { |
220 | enableQuick(); | 220 | enableQuick(); |
221 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 221 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
222 | return; | 222 | return; |
223 | } | 223 | } |
224 | if ( action == 3 ) { | 224 | if ( action == 3 ) { |
225 | delete mServerSocket; | 225 | delete mServerSocket; |
226 | mServerSocket = 0; | 226 | mServerSocket = 0; |
227 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 227 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
228 | return; | 228 | return; |
229 | } | 229 | } |
230 | 230 | ||
231 | if (blockSave()) | 231 | if (blockSave()) |
232 | return; | 232 | return; |
233 | 233 | ||
234 | setBlockSave(true); | 234 | setBlockSave(true); |
235 | bool silent = false; | 235 | bool silent = false; |
236 | if ( action == 999 ) { | 236 | if ( action == 999 ) { |
237 | //special mode for silent syncing | 237 | //special mode for silent syncing |
238 | action = 1000; | 238 | action = 1000; |
239 | silent = true; | 239 | silent = true; |
240 | } | 240 | } |
241 | 241 | ||
242 | mCurrentSyncProfile = action - 1000 ; | 242 | mCurrentSyncProfile = action - 1000 ; |
243 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 243 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
244 | mCurrentSyncName = mLocalMachineName ; | 244 | mCurrentSyncName = mLocalMachineName ; |
245 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 245 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
246 | KSyncProfile* temp = new KSyncProfile (); | 246 | KSyncProfile* temp = new KSyncProfile (); |
247 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 247 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
248 | temp->readConfig(&config); | 248 | temp->readConfig(&config); |
249 | if (silent) { | 249 | if (silent) { |
250 | mAskForPreferences = false; | 250 | mAskForPreferences = false; |
251 | mShowSyncSummary = false; | 251 | mShowSyncSummary = false; |
252 | mWriteBackFile = true; | 252 | mWriteBackFile = true; |
253 | mSyncAlgoPrefs = 2;// take newest | 253 | mSyncAlgoPrefs = 2;// take newest |
254 | } | 254 | } |
255 | else { | 255 | else { |
256 | mAskForPreferences = temp->getAskForPreferences(); | 256 | mAskForPreferences = temp->getAskForPreferences(); |
257 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 257 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
258 | mWriteBackFile = temp->getWriteBackFile(); | 258 | mWriteBackFile = temp->getWriteBackFile(); |
259 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 259 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
260 | } | 260 | } |
261 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 261 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
262 | mIsKapiFile = temp->getIsKapiFile(); | 262 | mIsKapiFile = temp->getIsKapiFile(); |
263 | mWriteBackInFuture = 0; | 263 | mWriteBackInFuture = 0; |
264 | if ( temp->getWriteBackFuture() ) { | 264 | if ( temp->getWriteBackFuture() ) { |
265 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 265 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
266 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 266 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
267 | } | 267 | } |
268 | mFilterInCal = temp->getFilterInCal(); | 268 | mFilterInCal = temp->getFilterInCal(); |
269 | mFilterOutCal = temp->getFilterOutCal(); | 269 | mFilterOutCal = temp->getFilterOutCal(); |
270 | mFilterInAB = temp->getFilterInAB(); | 270 | mFilterInAB = temp->getFilterInAB(); |
271 | mFilterOutAB = temp->getFilterOutAB(); | 271 | mFilterOutAB = temp->getFilterOutAB(); |
272 | 272 | ||
273 | if ( action == 1000 ) { | 273 | if ( action == 1000 ) { |
274 | mIsKapiFile = false; | 274 | mIsKapiFile = false; |
@@ -809,354 +809,421 @@ bool KSyncManager::edit_pisync_options() | |||
809 | lay.setMargin( 3 ); | 809 | lay.setMargin( 3 ); |
810 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 810 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
811 | lay.addWidget( &lab1 ); | 811 | lay.addWidget( &lab1 ); |
812 | QLineEdit le1 (&dia ); | 812 | QLineEdit le1 (&dia ); |
813 | lay.addWidget( &le1 ); | 813 | lay.addWidget( &le1 ); |
814 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 814 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
815 | lay.addWidget( &lab2 ); | 815 | lay.addWidget( &lab2 ); |
816 | QLineEdit le2 (&dia ); | 816 | QLineEdit le2 (&dia ); |
817 | lay.addWidget( &le2 ); | 817 | lay.addWidget( &le2 ); |
818 | QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); | 818 | QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); |
819 | lay.addWidget( &lab3 ); | 819 | lay.addWidget( &lab3 ); |
820 | QLineEdit le3 (&dia ); | 820 | QLineEdit le3 (&dia ); |
821 | lay.addWidget( &le3 ); | 821 | lay.addWidget( &le3 ); |
822 | QPushButton pb ( "OK", &dia); | 822 | QPushButton pb ( "OK", &dia); |
823 | lay.addWidget( &pb ); | 823 | lay.addWidget( &pb ); |
824 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 824 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
825 | le1.setText( mPassWordPiSync ); | 825 | le1.setText( mPassWordPiSync ); |
826 | le2.setText( mActiveSyncIP ); | 826 | le2.setText( mActiveSyncIP ); |
827 | le3.setText( mActiveSyncPort ); | 827 | le3.setText( mActiveSyncPort ); |
828 | if ( dia.exec() ) { | 828 | if ( dia.exec() ) { |
829 | mPassWordPiSync = le1.text(); | 829 | mPassWordPiSync = le1.text(); |
830 | mActiveSyncPort = le3.text(); | 830 | mActiveSyncPort = le3.text(); |
831 | mActiveSyncIP = le2.text(); | 831 | mActiveSyncIP = le2.text(); |
832 | return true; | 832 | return true; |
833 | } | 833 | } |
834 | return false; | 834 | return false; |
835 | } | 835 | } |
836 | bool KSyncManager::edit_sync_options() | 836 | bool KSyncManager::edit_sync_options() |
837 | { | 837 | { |
838 | 838 | ||
839 | QDialog dia( mParent, "dia", true ); | 839 | QDialog dia( mParent, "dia", true ); |
840 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 840 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
841 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 841 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
842 | QVBoxLayout lay ( &dia ); | 842 | QVBoxLayout lay ( &dia ); |
843 | lay.setSpacing( 2 ); | 843 | lay.setSpacing( 2 ); |
844 | lay.setMargin( 3 ); | 844 | lay.setMargin( 3 ); |
845 | lay.addWidget(&gr); | 845 | lay.addWidget(&gr); |
846 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 846 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
847 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 847 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
848 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 848 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
849 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 849 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
850 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 850 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
851 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 851 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
852 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 852 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
853 | QPushButton pb ( "OK", &dia); | 853 | QPushButton pb ( "OK", &dia); |
854 | lay.addWidget( &pb ); | 854 | lay.addWidget( &pb ); |
855 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 855 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
856 | switch ( mSyncAlgoPrefs ) { | 856 | switch ( mSyncAlgoPrefs ) { |
857 | case 0: | 857 | case 0: |
858 | loc.setChecked( true); | 858 | loc.setChecked( true); |
859 | break; | 859 | break; |
860 | case 1: | 860 | case 1: |
861 | rem.setChecked( true ); | 861 | rem.setChecked( true ); |
862 | break; | 862 | break; |
863 | case 2: | 863 | case 2: |
864 | newest.setChecked( true); | 864 | newest.setChecked( true); |
865 | break; | 865 | break; |
866 | case 3: | 866 | case 3: |
867 | ask.setChecked( true); | 867 | ask.setChecked( true); |
868 | break; | 868 | break; |
869 | case 4: | 869 | case 4: |
870 | f_loc.setChecked( true); | 870 | f_loc.setChecked( true); |
871 | break; | 871 | break; |
872 | case 5: | 872 | case 5: |
873 | f_rem.setChecked( true); | 873 | f_rem.setChecked( true); |
874 | break; | 874 | break; |
875 | case 6: | 875 | case 6: |
876 | // both.setChecked( true); | 876 | // both.setChecked( true); |
877 | break; | 877 | break; |
878 | default: | 878 | default: |
879 | break; | 879 | break; |
880 | } | 880 | } |
881 | if ( dia.exec() ) { | 881 | if ( dia.exec() ) { |
882 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 882 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
883 | return true; | 883 | return true; |
884 | } | 884 | } |
885 | return false; | 885 | return false; |
886 | } | 886 | } |
887 | 887 | ||
888 | QString KSyncManager::getPassword( ) | 888 | QString KSyncManager::getPassword( ) |
889 | { | 889 | { |
890 | QString retfile = ""; | 890 | QString retfile = ""; |
891 | QDialog dia ( mParent, "input-dialog", true ); | 891 | QDialog dia ( mParent, "input-dialog", true ); |
892 | QLineEdit lab ( &dia ); | 892 | QLineEdit lab ( &dia ); |
893 | lab.setEchoMode( QLineEdit::Password ); | 893 | lab.setEchoMode( QLineEdit::Password ); |
894 | QVBoxLayout lay( &dia ); | 894 | QVBoxLayout lay( &dia ); |
895 | lay.setMargin(7); | 895 | lay.setMargin(7); |
896 | lay.setSpacing(7); | 896 | lay.setSpacing(7); |
897 | lay.addWidget( &lab); | 897 | lay.addWidget( &lab); |
898 | dia.setFixedSize( 230,50 ); | 898 | dia.setFixedSize( 230,50 ); |
899 | dia.setCaption( i18n("Enter password") ); | 899 | dia.setCaption( i18n("Enter password") ); |
900 | QPushButton pb ( "OK", &dia); | 900 | QPushButton pb ( "OK", &dia); |
901 | lay.addWidget( &pb ); | 901 | lay.addWidget( &pb ); |
902 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 902 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
903 | dia.show(); | 903 | dia.show(); |
904 | int res = dia.exec(); | 904 | int res = dia.exec(); |
905 | if ( res ) | 905 | if ( res ) |
906 | retfile = lab.text(); | 906 | retfile = lab.text(); |
907 | dia.hide(); | 907 | dia.hide(); |
908 | qApp->processEvents(); | 908 | qApp->processEvents(); |
909 | return retfile; | 909 | return retfile; |
910 | 910 | ||
911 | } | 911 | } |
912 | 912 | ||
913 | 913 | ||
914 | void KSyncManager::confSync() | 914 | void KSyncManager::confSync() |
915 | { | 915 | { |
916 | static KSyncPrefsDialog* sp = 0; | 916 | static KSyncPrefsDialog* sp = 0; |
917 | if ( ! sp ) { | 917 | if ( ! sp ) { |
918 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 918 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
919 | } | 919 | } |
920 | sp->usrReadConfig(); | 920 | sp->usrReadConfig(); |
921 | #ifndef DESKTOP_VERSION | 921 | #ifndef DESKTOP_VERSION |
922 | sp->showMaximized(); | 922 | sp->showMaximized(); |
923 | #else | 923 | #else |
924 | sp->show(); | 924 | sp->show(); |
925 | #endif | 925 | #endif |
926 | sp->exec(); | 926 | sp->exec(); |
927 | QStringList oldSyncProfileNames = mSyncProfileNames; | 927 | QStringList oldSyncProfileNames = mSyncProfileNames; |
928 | mSyncProfileNames = sp->getSyncProfileNames(); | 928 | mSyncProfileNames = sp->getSyncProfileNames(); |
929 | mLocalMachineName = sp->getLocalMachineName (); | 929 | mLocalMachineName = sp->getLocalMachineName (); |
930 | uint ii; | 930 | uint ii; |
931 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 931 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
932 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 932 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
933 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 933 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
934 | } | 934 | } |
935 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 935 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
936 | } | 936 | } |
937 | void KSyncManager::syncOL() | ||
938 | { | ||
939 | mSyncWithDesktop = true; | ||
940 | emit save(); | ||
941 | switch(mTargetApp) | ||
942 | { | ||
943 | case (KAPI): | ||
944 | { | ||
945 | syncExternalApplication("ol"); | ||
946 | } | ||
947 | break; | ||
948 | case (KOPI): | ||
949 | { | ||
950 | #ifdef DESKTOP_VERSION | ||
951 | QString command = "kdecaldump33"; | ||
952 | QString commandfile = "kdecaldump33"; | ||
953 | QString commandpath = qApp->applicationDirPath () + "/"; | ||
954 | #else | ||
955 | QString command = "kdecaldump33"; | ||
956 | QString commandfile = "kdecaldump33"; | ||
957 | QString commandpath = QDir::homeDirPath ()+"/"; | ||
958 | #endif | ||
959 | if ( ! QFile::exists ( commandpath+commandfile ) ) | ||
960 | command = commandfile; | ||
961 | else | ||
962 | command = commandpath+commandfile; | ||
963 | |||
964 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | ||
965 | int result = system ( command.latin1()); | ||
966 | qDebug("Cal dump 33 command call result result: %d ", result); | ||
967 | if ( result != 0 ) { | ||
968 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); | ||
969 | commandfile = "kdecaldump34"; | ||
970 | if ( ! QFile::exists ( commandpath+commandfile ) ) | ||
971 | command = commandfile; | ||
972 | else | ||
973 | command = commandpath+commandfile; | ||
974 | result = system ( command.latin1()); | ||
975 | qDebug("Cal dump 34 command call result result: %d ", result); | ||
976 | if ( result != 0 ) { | ||
977 | 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 )); | ||
978 | return; | ||
979 | } | ||
980 | } | ||
981 | if ( syncWithFile( fileName,true ) ) { | ||
982 | if ( mWriteBackFile ) { | ||
983 | command += " --read"; | ||
984 | system ( command.latin1()); | ||
985 | } | ||
986 | } | ||
987 | |||
988 | } | ||
989 | break; | ||
990 | case (PWMPI): | ||
991 | |||
992 | break; | ||
993 | default: | ||
994 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | ||
995 | break; | ||
996 | |||
997 | } | ||
998 | } | ||
937 | void KSyncManager::syncKDE() | 999 | void KSyncManager::syncKDE() |
938 | { | 1000 | { |
1001 | #ifdef _WIN32_ | ||
1002 | syncOL(); | ||
1003 | #else | ||
1004 | |||
939 | mSyncWithDesktop = true; | 1005 | mSyncWithDesktop = true; |
940 | emit save(); | 1006 | emit save(); |
941 | switch(mTargetApp) | 1007 | switch(mTargetApp) |
942 | { | 1008 | { |
943 | case (KAPI): | 1009 | case (KAPI): |
944 | { | 1010 | { |
945 | #ifdef DESKTOP_VERSION | 1011 | #ifdef DESKTOP_VERSION |
946 | QString command = "kdeabdump33"; | 1012 | QString command = "kdeabdump33"; |
947 | QString commandfile = "kdeabdump33"; | 1013 | QString commandfile = "kdeabdump33"; |
948 | QString commandpath = qApp->applicationDirPath () + "/"; | 1014 | QString commandpath = qApp->applicationDirPath () + "/"; |
949 | #else | 1015 | #else |
950 | QString command = "kdeabdump33"; | 1016 | QString command = "kdeabdump33"; |
951 | QString commandfile = "kdeabdump33"; | 1017 | QString commandfile = "kdeabdump33"; |
952 | QString commandpath = QDir::homeDirPath ()+"/"; | 1018 | QString commandpath = QDir::homeDirPath ()+"/"; |
953 | #endif | 1019 | #endif |
954 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 1020 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
955 | command = commandfile; | 1021 | command = commandfile; |
956 | else | 1022 | else |
957 | command = commandpath+commandfile; | 1023 | command = commandpath+commandfile; |
958 | 1024 | ||
959 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 1025 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
960 | int result = system ( command.latin1()); | 1026 | int result = system ( command.latin1()); |
961 | qDebug("AB dump 33 command call result: %d ", result); | 1027 | qDebug("AB dump 33 command call result: %d ", result); |
962 | if ( result != 0 ) { | 1028 | if ( result != 0 ) { |
963 | qDebug("Calling AB dump version 33 failed. Trying 34... "); | 1029 | qDebug("Calling AB dump version 33 failed. Trying 34... "); |
964 | commandfile = "kdeabdump34"; | 1030 | commandfile = "kdeabdump34"; |
965 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 1031 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
966 | command = commandfile; | 1032 | command = commandfile; |
967 | else | 1033 | else |
968 | command = commandpath+commandfile; | 1034 | command = commandpath+commandfile; |
969 | result = system ( command.latin1()); | 1035 | result = system ( command.latin1()); |
970 | qDebug("AB dump 34 command call result: %d ", result); | 1036 | qDebug("AB dump 34 command call result: %d ", result); |
971 | if ( result != 0 ) { | 1037 | if ( result != 0 ) { |
972 | 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 )); | 1038 | 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 )); |
973 | return; | 1039 | return; |
974 | } | 1040 | } |
975 | } | 1041 | } |
976 | if ( syncWithFile( fileName,true ) ) { | 1042 | if ( syncWithFile( fileName,true ) ) { |
977 | if ( mWriteBackFile ) { | 1043 | if ( mWriteBackFile ) { |
978 | command += " --read"; | 1044 | command += " --read"; |
979 | system ( command.latin1()); | 1045 | system ( command.latin1()); |
980 | } | 1046 | } |
981 | } | 1047 | } |
982 | 1048 | ||
983 | } | 1049 | } |
984 | break; | 1050 | break; |
985 | case (KOPI): | 1051 | case (KOPI): |
986 | { | 1052 | { |
987 | #ifdef DESKTOP_VERSION | 1053 | #ifdef DESKTOP_VERSION |
988 | QString command = "kdecaldump33"; | 1054 | QString command = "kdecaldump33"; |
989 | QString commandfile = "kdecaldump33"; | 1055 | QString commandfile = "kdecaldump33"; |
990 | QString commandpath = qApp->applicationDirPath () + "/"; | 1056 | QString commandpath = qApp->applicationDirPath () + "/"; |
991 | #else | 1057 | #else |
992 | QString command = "kdecaldump33"; | 1058 | QString command = "kdecaldump33"; |
993 | QString commandfile = "kdecaldump33"; | 1059 | QString commandfile = "kdecaldump33"; |
994 | QString commandpath = QDir::homeDirPath ()+"/"; | 1060 | QString commandpath = QDir::homeDirPath ()+"/"; |
995 | #endif | 1061 | #endif |
996 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 1062 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
997 | command = commandfile; | 1063 | command = commandfile; |
998 | else | 1064 | else |
999 | command = commandpath+commandfile; | 1065 | command = commandpath+commandfile; |
1000 | 1066 | ||
1001 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 1067 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
1002 | int result = system ( command.latin1()); | 1068 | int result = system ( command.latin1()); |
1003 | qDebug("Cal dump 33 command call result result: %d ", result); | 1069 | qDebug("Cal dump 33 command call result result: %d ", result); |
1004 | if ( result != 0 ) { | 1070 | if ( result != 0 ) { |
1005 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); | 1071 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); |
1006 | commandfile = "kdecaldump34"; | 1072 | commandfile = "kdecaldump34"; |
1007 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 1073 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
1008 | command = commandfile; | 1074 | command = commandfile; |
1009 | else | 1075 | else |
1010 | command = commandpath+commandfile; | 1076 | command = commandpath+commandfile; |
1011 | result = system ( command.latin1()); | 1077 | result = system ( command.latin1()); |
1012 | qDebug("Cal dump 34 command call result result: %d ", result); | 1078 | qDebug("Cal dump 34 command call result result: %d ", result); |
1013 | if ( result != 0 ) { | 1079 | if ( result != 0 ) { |
1014 | 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 )); | 1080 | 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 )); |
1015 | return; | 1081 | return; |
1016 | } | 1082 | } |
1017 | } | 1083 | } |
1018 | if ( syncWithFile( fileName,true ) ) { | 1084 | if ( syncWithFile( fileName,true ) ) { |
1019 | if ( mWriteBackFile ) { | 1085 | if ( mWriteBackFile ) { |
1020 | command += " --read"; | 1086 | command += " --read"; |
1021 | system ( command.latin1()); | 1087 | system ( command.latin1()); |
1022 | } | 1088 | } |
1023 | } | 1089 | } |
1024 | 1090 | ||
1025 | } | 1091 | } |
1026 | break; | 1092 | break; |
1027 | case (PWMPI): | 1093 | case (PWMPI): |
1028 | 1094 | ||
1029 | break; | 1095 | break; |
1030 | default: | 1096 | default: |
1031 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 1097 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
1032 | break; | 1098 | break; |
1033 | 1099 | ||
1034 | } | 1100 | } |
1101 | #endif | ||
1035 | } | 1102 | } |
1036 | 1103 | ||
1037 | void KSyncManager::syncSharp() | 1104 | void KSyncManager::syncSharp() |
1038 | { | 1105 | { |
1039 | 1106 | ||
1040 | if ( ! syncExternalApplication("sharp") ) | 1107 | if ( ! syncExternalApplication("sharp") ) |
1041 | qDebug("KSM::ERROR sync sharp "); | 1108 | qDebug("KSM::ERROR sync sharp "); |
1042 | } | 1109 | } |
1043 | 1110 | ||
1044 | bool KSyncManager::syncExternalApplication(QString resource) | 1111 | bool KSyncManager::syncExternalApplication(QString resource) |
1045 | { | 1112 | { |
1046 | 1113 | ||
1047 | emit save(); | 1114 | emit save(); |
1048 | 1115 | ||
1049 | if ( mAskForPreferences ) | 1116 | if ( mAskForPreferences ) |
1050 | if ( !edit_sync_options()) { | 1117 | if ( !edit_sync_options()) { |
1051 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1118 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1052 | return false; | 1119 | return false; |
1053 | } | 1120 | } |
1054 | 1121 | ||
1055 | qDebug("KSM::Sync extern %s", resource.latin1()); | 1122 | qDebug("KSM::Sync extern %s", resource.latin1()); |
1056 | 1123 | ||
1057 | bool syncOK = mImplementation->syncExternal(this, resource); | 1124 | bool syncOK = mImplementation->syncExternal(this, resource); |
1058 | 1125 | ||
1059 | return syncOK; | 1126 | return syncOK; |
1060 | 1127 | ||
1061 | } | 1128 | } |
1062 | 1129 | ||
1063 | void KSyncManager::syncPhone() | 1130 | void KSyncManager::syncPhone() |
1064 | { | 1131 | { |
1065 | 1132 | ||
1066 | syncExternalApplication("phone"); | 1133 | syncExternalApplication("phone"); |
1067 | 1134 | ||
1068 | } | 1135 | } |
1069 | 1136 | ||
1070 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 1137 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
1071 | { | 1138 | { |
1072 | if (!bar->isVisible()) | 1139 | if (!bar->isVisible()) |
1073 | { | 1140 | { |
1074 | int w = 300; | 1141 | int w = 300; |
1075 | if ( QApplication::desktop()->width() < 320 ) | 1142 | if ( QApplication::desktop()->width() < 320 ) |
1076 | w = 220; | 1143 | w = 220; |
1077 | int h = bar->sizeHint().height() ; | 1144 | int h = bar->sizeHint().height() ; |
1078 | int dw = QApplication::desktop()->width(); | 1145 | int dw = QApplication::desktop()->width(); |
1079 | int dh = QApplication::desktop()->height(); | 1146 | int dh = QApplication::desktop()->height(); |
1080 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1147 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1081 | bar->setCaption (caption); | 1148 | bar->setCaption (caption); |
1082 | bar->setTotalSteps ( total ) ; | 1149 | bar->setTotalSteps ( total ) ; |
1083 | bar->show(); | 1150 | bar->show(); |
1084 | } | 1151 | } |
1085 | bar->raise(); | 1152 | bar->raise(); |
1086 | bar->setProgress( percentage ); | 1153 | bar->setProgress( percentage ); |
1087 | qApp->processEvents(); | 1154 | qApp->processEvents(); |
1088 | } | 1155 | } |
1089 | 1156 | ||
1090 | void KSyncManager::hideProgressBar() | 1157 | void KSyncManager::hideProgressBar() |
1091 | { | 1158 | { |
1092 | bar->hide(); | 1159 | bar->hide(); |
1093 | qApp->processEvents(); | 1160 | qApp->processEvents(); |
1094 | } | 1161 | } |
1095 | 1162 | ||
1096 | bool KSyncManager::isProgressBarCanceled() | 1163 | bool KSyncManager::isProgressBarCanceled() |
1097 | { | 1164 | { |
1098 | return !bar->isVisible(); | 1165 | return !bar->isVisible(); |
1099 | } | 1166 | } |
1100 | 1167 | ||
1101 | QString KSyncManager::syncFileName() | 1168 | QString KSyncManager::syncFileName() |
1102 | { | 1169 | { |
1103 | 1170 | ||
1104 | QString fn = "tempfile"; | 1171 | QString fn = "tempfile"; |
1105 | switch(mTargetApp) | 1172 | switch(mTargetApp) |
1106 | { | 1173 | { |
1107 | case (KAPI): | 1174 | case (KAPI): |
1108 | fn = "tempsyncab.vcf"; | 1175 | fn = "tempsyncab.vcf"; |
1109 | break; | 1176 | break; |
1110 | case (KOPI): | 1177 | case (KOPI): |
1111 | fn = "tempsynccal.ics"; | 1178 | fn = "tempsynccal.ics"; |
1112 | break; | 1179 | break; |
1113 | case (PWMPI): | 1180 | case (PWMPI): |
1114 | fn = "tempsyncpw.pwm"; | 1181 | fn = "tempsyncpw.pwm"; |
1115 | break; | 1182 | break; |
1116 | default: | 1183 | default: |
1117 | break; | 1184 | break; |
1118 | } | 1185 | } |
1119 | #ifdef DESKTOP_VERSION | 1186 | #ifdef DESKTOP_VERSION |
1120 | return locateLocal( "tmp", fn ); | 1187 | return locateLocal( "tmp", fn ); |
1121 | #else | 1188 | #else |
1122 | return (QString( "/tmp/" )+ fn ); | 1189 | return (QString( "/tmp/" )+ fn ); |
1123 | #endif | 1190 | #endif |
1124 | } | 1191 | } |
1125 | 1192 | ||
1126 | void KSyncManager::syncPi() | 1193 | void KSyncManager::syncPi() |
1127 | { | 1194 | { |
1128 | mIsKapiFile = true; | 1195 | mIsKapiFile = true; |
1129 | mPisyncFinished = false; | 1196 | mPisyncFinished = false; |
1130 | qApp->processEvents(); | 1197 | qApp->processEvents(); |
1131 | if ( mAskForPreferences ) | 1198 | if ( mAskForPreferences ) |
1132 | if ( !edit_pisync_options()) { | 1199 | if ( !edit_pisync_options()) { |
1133 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1200 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1134 | mPisyncFinished = true; | 1201 | mPisyncFinished = true; |
1135 | return; | 1202 | return; |
1136 | } | 1203 | } |
1137 | bool ok; | 1204 | bool ok; |
1138 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1205 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1139 | if ( ! ok ) { | 1206 | if ( ! ok ) { |
1140 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1207 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1141 | mPisyncFinished = true; | 1208 | mPisyncFinished = true; |
1142 | return; | 1209 | return; |
1143 | } | 1210 | } |
1144 | mCurrentResourceLocal = ""; | 1211 | mCurrentResourceLocal = ""; |
1145 | mCurrentResourceRemote = ""; | 1212 | mCurrentResourceRemote = ""; |
1146 | if ( mSpecificResources.count() ) { | 1213 | if ( mSpecificResources.count() ) { |
1147 | uint lastSyncRes = mSpecificResources.count()/2; | 1214 | uint lastSyncRes = mSpecificResources.count()/2; |
1148 | int ccc = mSpecificResources.count()-1; | 1215 | int ccc = mSpecificResources.count()-1; |
1149 | while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { | 1216 | while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { |
1150 | --ccc; | 1217 | --ccc; |
1151 | --lastSyncRes; | 1218 | --lastSyncRes; |
1152 | //qDebug ( "KSM: sync pi %d",ccc ); | 1219 | //qDebug ( "KSM: sync pi %d",ccc ); |
1153 | } | 1220 | } |
1154 | uint startLocal = 0; | 1221 | uint startLocal = 0; |
1155 | uint startRemote = mSpecificResources.count()/2; | 1222 | uint startRemote = mSpecificResources.count()/2; |
1156 | emit multiResourceSyncStart( true ); | 1223 | emit multiResourceSyncStart( true ); |
1157 | while ( startLocal < mSpecificResources.count()/2 ) { | 1224 | while ( startLocal < mSpecificResources.count()/2 ) { |
1158 | if ( startLocal+1 >= lastSyncRes ) | 1225 | if ( startLocal+1 >= lastSyncRes ) |
1159 | emit multiResourceSyncStart( false ); | 1226 | emit multiResourceSyncStart( false ); |
1160 | mPisyncFinished = false; | 1227 | mPisyncFinished = false; |
1161 | mCurrentResourceLocal = mSpecificResources[ startLocal ]; | 1228 | mCurrentResourceLocal = mSpecificResources[ startLocal ]; |
1162 | mCurrentResourceRemote = mSpecificResources[ startRemote ]; | 1229 | mCurrentResourceRemote = mSpecificResources[ startRemote ]; |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 04cdade..71d17e9 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -78,172 +78,171 @@ class KServerSocket : public QServerSocket | |||
78 | QString mPassWord; | 78 | QString mPassWord; |
79 | QString mFileName; | 79 | QString mFileName; |
80 | QTime piTime; | 80 | QTime piTime; |
81 | QString piFileString; | 81 | QString piFileString; |
82 | }; | 82 | }; |
83 | 83 | ||
84 | class KCommandSocket : public QObject | 84 | class KCommandSocket : public QObject |
85 | { | 85 | { |
86 | Q_OBJECT | 86 | Q_OBJECT |
87 | public: | 87 | public: |
88 | enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; | 88 | enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; |
89 | KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); | 89 | KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); |
90 | void readFile( QString ); | 90 | void readFile( QString ); |
91 | void writeFile( QString ); | 91 | void writeFile( QString ); |
92 | void sendStop(); | 92 | void sendStop(); |
93 | 93 | ||
94 | private slots : | 94 | private slots : |
95 | void sendFileRequest(); | 95 | void sendFileRequest(); |
96 | void updateConnectDialog(); | 96 | void updateConnectDialog(); |
97 | 97 | ||
98 | signals: | 98 | signals: |
99 | void commandFinished( KCommandSocket*, int ); | 99 | void commandFinished( KCommandSocket*, int ); |
100 | private slots: | 100 | private slots: |
101 | void startReadFileFromSocket(); | 101 | void startReadFileFromSocket(); |
102 | void readFileFromSocket(); | 102 | void readFileFromSocket(); |
103 | void deleteSocket(); | 103 | void deleteSocket(); |
104 | void writeFileToSocket(); | 104 | void writeFileToSocket(); |
105 | private : | 105 | private : |
106 | QString mRemoteResource; | 106 | QString mRemoteResource; |
107 | int mConnectCount; | 107 | int mConnectCount; |
108 | int mConnectMax; | 108 | int mConnectMax; |
109 | KProgressDialog mConnectProgress; | 109 | KProgressDialog mConnectProgress; |
110 | QWidget* tlw; | 110 | QWidget* tlw; |
111 | QSocket* mSocket; | 111 | QSocket* mSocket; |
112 | QString mPassWord; | 112 | QString mPassWord; |
113 | Q_UINT16 mPort; | 113 | Q_UINT16 mPort; |
114 | QString mHost; | 114 | QString mHost; |
115 | QString mFileName; | 115 | QString mFileName; |
116 | QTimer* mTimerSocket; | 116 | QTimer* mTimerSocket; |
117 | int mRetVal; | 117 | int mRetVal; |
118 | QTime mTime; | 118 | QTime mTime; |
119 | QString mFileString; | 119 | QString mFileString; |
120 | bool mFirst; | 120 | bool mFirst; |
121 | bool mFirstLine; | 121 | bool mFirstLine; |
122 | }; | 122 | }; |
123 | 123 | ||
124 | 124 | ||
125 | class KSyncManager : public QObject | 125 | class KSyncManager : public QObject |
126 | { | 126 | { |
127 | Q_OBJECT | 127 | Q_OBJECT |
128 | 128 | ||
129 | public: | 129 | public: |
130 | enum TargetApp { | 130 | enum TargetApp { |
131 | KOPI = 0, | 131 | KOPI = 0, |
132 | KAPI = 1, | 132 | KAPI = 1, |
133 | PWMPI = 2 }; | 133 | PWMPI = 2 }; |
134 | 134 | ||
135 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 135 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
136 | ~KSyncManager() ; | 136 | ~KSyncManager() ; |
137 | 137 | ||
138 | void multiSync( bool askforPrefs ); | 138 | void multiSync( bool askforPrefs ); |
139 | bool blockSave() { return mBlockSaveFlag; } | 139 | bool blockSave() { return mBlockSaveFlag; } |
140 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 140 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
141 | void setDefaultFileName( QString s) ; | 141 | void setDefaultFileName( QString s) ; |
142 | QString defaultFileName() { return mDefFileName ;} | 142 | QString defaultFileName() { return mDefFileName ;} |
143 | QString syncFileName(); | 143 | QString syncFileName(); |
144 | void enableQuick( bool ask = true); | 144 | void enableQuick( bool ask = true); |
145 | 145 | ||
146 | bool syncWithDesktop () { return mSyncWithDesktop;} | 146 | bool syncWithDesktop () { return mSyncWithDesktop;} |
147 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 147 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
148 | QString getCurrentSyncName() { return mCurrentSyncName; } | 148 | QString getCurrentSyncName() { return mCurrentSyncName; } |
149 | 149 | ||
150 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 150 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
151 | void hideProgressBar(); | 151 | void hideProgressBar(); |
152 | bool isProgressBarCanceled(); | 152 | bool isProgressBarCanceled(); |
153 | 153 | ||
154 | // sync stuff | 154 | // sync stuff |
155 | QString mLocalMachineName; | 155 | QString mLocalMachineName; |
156 | QStringList mExternSyncProfiles; | 156 | QStringList mExternSyncProfiles; |
157 | QStringList mSyncProfileNames; | 157 | QStringList mSyncProfileNames; |
158 | bool mAskForPreferences; | 158 | bool mAskForPreferences; |
159 | bool mShowSyncSummary; | 159 | bool mShowSyncSummary; |
160 | bool mIsKapiFile; | 160 | bool mIsKapiFile; |
161 | bool mWriteBackExistingOnly; | 161 | bool mWriteBackExistingOnly; |
162 | int mSyncAlgoPrefs; | 162 | int mSyncAlgoPrefs; |
163 | bool mWriteBackFile; | 163 | bool mWriteBackFile; |
164 | int mWriteBackInFuture; | 164 | int mWriteBackInFuture; |
165 | int mWriteBackInPast; | 165 | int mWriteBackInPast; |
166 | QString mPhoneDevice; | 166 | QString mPhoneDevice; |
167 | QString mPhoneConnection; | 167 | QString mPhoneConnection; |
168 | QString mPhoneModel; | 168 | QString mPhoneModel; |
169 | QString mPassWordPiSync; | 169 | QString mPassWordPiSync; |
170 | QString mActiveSyncPort; | 170 | QString mActiveSyncPort; |
171 | QString mActiveSyncIP ; | 171 | QString mActiveSyncIP ; |
172 | QString mFilterInCal; | 172 | QString mFilterInCal; |
173 | QString mFilterOutCal; | 173 | QString mFilterOutCal; |
174 | QString mFilterInAB; | 174 | QString mFilterInAB; |
175 | QString mFilterOutAB; | 175 | QString mFilterOutAB; |
176 | static QDateTime mRequestedSyncEvent; | 176 | static QDateTime mRequestedSyncEvent; |
177 | 177 | ||
178 | signals: | 178 | signals: |
179 | void save(); | 179 | void save(); |
180 | void request_file(); | 180 | void request_file(); |
181 | void getFile( bool ); | 181 | void getFile( bool ); |
182 | void getFile( bool, const QString &); | 182 | void getFile( bool, const QString &); |
183 | void request_file(const QString &); | 183 | void request_file(const QString &); |
184 | void multiResourceSyncStart( bool ); | 184 | void multiResourceSyncStart( bool ); |
185 | 185 | ||
186 | public slots: | 186 | public slots: |
187 | void slotSyncMenu( int ); | 187 | void slotSyncMenu( int ); |
188 | void slotClearMenu( int action ); | 188 | void slotClearMenu( int action ); |
189 | void deleteCommandSocket(KCommandSocket*s, int state); | 189 | void deleteCommandSocket(KCommandSocket*s, int state); |
190 | void readFileFromSocket(); | 190 | void readFileFromSocket(); |
191 | void fillSyncMenu(); | 191 | void fillSyncMenu(); |
192 | 192 | ||
193 | private: | 193 | private: |
194 | void syncPi(); | 194 | void syncPi(); |
195 | KServerSocket * mServerSocket; | 195 | KServerSocket * mServerSocket; |
196 | KPimPrefs* mPrefs; | 196 | KPimPrefs* mPrefs; |
197 | QString mDefFileName; | 197 | QString mDefFileName; |
198 | QString mCurrentSyncDevice; | 198 | QString mCurrentSyncDevice; |
199 | QString mCurrentSyncName; | 199 | QString mCurrentSyncName; |
200 | void quickSyncLocalFile(); | 200 | void quickSyncLocalFile(); |
201 | bool syncWithFile( QString fn , bool quick ); | 201 | bool syncWithFile( QString fn , bool quick ); |
202 | void syncLocalFile(); | 202 | void syncLocalFile(); |
203 | void syncPhone(); | 203 | void syncPhone(); |
204 | void syncSharp(); | 204 | void syncSharp(); |
205 | void syncKDE(); | 205 | void syncKDE(); |
206 | void syncOL(); | ||
206 | bool syncExternalApplication(QString); | 207 | bool syncExternalApplication(QString); |
207 | int mCurrentSyncProfile ; | 208 | int mCurrentSyncProfile ; |
208 | void syncRemote( KSyncProfile* prof, bool ask = true); | 209 | void syncRemote( KSyncProfile* prof, bool ask = true); |
209 | bool edit_sync_options(); | 210 | bool edit_sync_options(); |
210 | bool edit_pisync_options(); | 211 | bool edit_pisync_options(); |
211 | int ringSync(); | 212 | int ringSync(); |
212 | QString getPassword( ); | 213 | QString getPassword( ); |
213 | bool mPisyncFinished; | 214 | bool mPisyncFinished; |
214 | QStringList mSpecificResources; | 215 | QStringList mSpecificResources; |
215 | QString mCurrentResourceLocal; | 216 | QString mCurrentResourceLocal; |
216 | QString mCurrentResourceRemote; | 217 | QString mCurrentResourceRemote; |
217 | bool mBlockSaveFlag; | 218 | bool mBlockSaveFlag; |
218 | QWidget* mParent; | 219 | QWidget* mParent; |
219 | KSyncInterface* mImplementation; | 220 | KSyncInterface* mImplementation; |
220 | TargetApp mTargetApp; | 221 | TargetApp mTargetApp; |
221 | QPopupMenu* mSyncMenu; | 222 | QPopupMenu* mSyncMenu; |
222 | QProgressBar* bar; | 223 | QProgressBar* bar; |
223 | bool mSyncWithDesktop; | 224 | bool mSyncWithDesktop; |
224 | 225 | ||
225 | private slots: | 226 | private slots: |
226 | void displayErrorPort(); | 227 | void displayErrorPort(); |
227 | void confSync(); | 228 | void confSync(); |
228 | 229 | ||
229 | 230 | ||
230 | }; | 231 | }; |
231 | 232 | ||
232 | 233 | ||
233 | class KSyncInterface | 234 | class KSyncInterface |
234 | { | 235 | { |
235 | public : | 236 | public : |
236 | virtual void removeSyncInfo( QString syncProfile) = 0; | 237 | virtual void removeSyncInfo( QString syncProfile) = 0; |
237 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; | 238 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; |
238 | virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/) | 239 | virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/) |
239 | { | 240 | { |
240 | // empty implementation, because some syncable applications do not | 241 | // empty implementation, because some syncable applications do not |
241 | // have an external(sharpdtm) syncmode, like pwmanager. | 242 | // have an external(sharpdtm) syncmode, like pwmanager. |
242 | return false; | 243 | return false; |
243 | } | 244 | } |
244 | |||
245 | |||
246 | }; | 245 | }; |
247 | 246 | ||
248 | 247 | ||
249 | #endif | 248 | #endif |
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro index 84af7ad..7160d0e 100644 --- a/libkdepim/libkdepim.pro +++ b/libkdepim/libkdepim.pro | |||
@@ -1,61 +1,76 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG = qt warn_on | 2 | CONFIG = qt warn_on |
3 | DEFINES +=KORG_NOKABC | 3 | DEFINES +=KORG_NOKABC |
4 | TARGET = microkdepim | 4 | TARGET = microkdepim |
5 | INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. | 5 | INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. |
6 | DESTDIR=../bin | 6 | DESTDIR=../bin |
7 | 7 | ||
8 | DEFINES += DESKTOP_VERSION | 8 | DEFINES += DESKTOP_VERSION |
9 | include( ../variables.pri ) | 9 | include( ../variables.pri ) |
10 | unix : { | 10 | unix : { |
11 | OBJECTS_DIR = obj/unix | 11 | OBJECTS_DIR = obj/unix |
12 | MOC_DIR = moc/unix | 12 | MOC_DIR = moc/unix |
13 | } | 13 | } |
14 | win32: { | 14 | win32: { |
15 | DEFINES += _WIN32_ | 15 | DEFINES += _WIN32_ |
16 | OBJECTS_DIR = obj/win | 16 | OBJECTS_DIR = obj/win |
17 | MOC_DIR = moc/win | 17 | MOC_DIR = moc/win |
18 | } | 18 | } |
19 | INTERFACES = \ | 19 | INTERFACES = \ |
20 | 20 | ||
21 | HEADERS = \ | 21 | HEADERS = \ |
22 | categoryeditdialog.h \ | 22 | categoryeditdialog.h \ |
23 | categoryeditdialog_base.h \ | 23 | categoryeditdialog_base.h \ |
24 | categoryselectdialog.h \ | 24 | categoryselectdialog.h \ |
25 | categoryselectdialog_base.h \ | 25 | categoryselectdialog_base.h \ |
26 | externalapphandler.h \ | 26 | externalapphandler.h \ |
27 | kdateedit.h \ | 27 | kdateedit.h \ |
28 | kdatepicker.h \ | 28 | kdatepicker.h \ |
29 | kinputdialog.h \ | 29 | kinputdialog.h \ |
30 | kpimprefs.h \ | 30 | kpimprefs.h \ |
31 | kpimglobalprefs.h \ | 31 | kpimglobalprefs.h \ |
32 | kprefsdialog.h \ | 32 | kprefsdialog.h \ |
33 | kprefswidget.h \ | 33 | kprefswidget.h \ |
34 | ksyncmanager.h \ | 34 | ksyncmanager.h \ |
35 | ksyncprofile.h \ | 35 | ksyncprofile.h \ |
36 | ksyncprefsdialog.h \ | 36 | ksyncprefsdialog.h \ |
37 | kcmconfigs/kcmkdepimconfig.h \ | 37 | kcmconfigs/kcmkdepimconfig.h \ |
38 | kcmconfigs/kdepimconfigwidget.h \ | 38 | kcmconfigs/kdepimconfigwidget.h \ |
39 | phoneaccess.h | 39 | phoneaccess.h |
40 | 40 | ||
41 | SOURCES = \ | 41 | SOURCES = \ |
42 | categoryeditdialog.cpp \ | 42 | categoryeditdialog.cpp \ |
43 | categoryeditdialog_base.cpp \ | 43 | categoryeditdialog_base.cpp \ |
44 | categoryselectdialog.cpp \ | 44 | categoryselectdialog.cpp \ |
45 | categoryselectdialog_base.cpp \ | 45 | categoryselectdialog_base.cpp \ |
46 | externalapphandler.cpp \ | 46 | externalapphandler.cpp \ |
47 | kdateedit.cpp \ | 47 | kdateedit.cpp \ |
48 | kdatepicker.cpp \ | 48 | kdatepicker.cpp \ |
49 | kinputdialog.cpp \ | 49 | kinputdialog.cpp \ |
50 | kpimprefs.cpp \ | 50 | kpimprefs.cpp \ |
51 | kpimglobalprefs.cpp \ | 51 | kpimglobalprefs.cpp \ |
52 | kprefsdialog.cpp \ | 52 | kprefsdialog.cpp \ |
53 | kprefswidget.cpp \ | 53 | kprefswidget.cpp \ |
54 | ksyncmanager.cpp \ | 54 | ksyncmanager.cpp \ |
55 | ksyncprofile.cpp \ | 55 | ksyncprofile.cpp \ |
56 | ksyncprefsdialog.cpp \ | 56 | ksyncprefsdialog.cpp \ |
57 | kcmconfigs/kcmkdepimconfig.cpp \ | 57 | kcmconfigs/kcmkdepimconfig.cpp \ |
58 | kcmconfigs/kdepimconfigwidget.cpp \ | 58 | kcmconfigs/kdepimconfigwidget.cpp \ |
59 | phoneaccess.cpp | 59 | phoneaccess.cpp |
60 | 60 | ||
61 | win32: { | ||
61 | 62 | ||
63 | #olimport section | ||
64 | importol { | ||
65 | debug: { | ||
66 | LIBS += mfc71ud.lib | ||
67 | } | ||
68 | release: { | ||
69 | LIBS += mfc71u.lib | ||
70 | } | ||
71 | DEFINES += _OL_IMPORT_ | ||
72 | HEADERS += ol_access.h | ||
73 | SOURCES += ol_access.cpp | ||
74 | #olimport section end | ||
75 | } | ||
76 | } | ||