-rw-r--r-- | Makefile | 529 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 6 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 57 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 4 |
4 files changed, 219 insertions, 377 deletions
@@ -1,362 +1,169 @@ -export KDEPIMDIR = $(shell pwd) - -export KDEPIM_VERSION=$(shell sed -e 's/.*\"\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/' < version) - -ifeq ($(PLATFORM) , zaurus) - BUILD_NO_LDAP_PLUGIN=1 -endif - -ifneq ($(PLATFORM) , zaurus) - BUILD_NO_SHARP_PLUGIN=1 -endif - -SUBDIRS_MICROKDE = \ - libical/src/libical \ - libical/src/libicalss \ - qtcompat \ - microkde \ - libkcal \ - libkdepim \ - kabc \ - kabc/formats/binary \ - kabc/plugins/file \ - kabc/plugins/dir \ - korganizer \ - kalarmd \ - kaddressbook - -SUBDIRS_QTOPIA_PLUGIN = \ - kabc/plugins/qtopia - -SUBDIRS_OPIE_PLUGIN = \ - kabc/plugins/opie - -SUBDIRS_SHARP_PLUGIN = \ - kabc/plugins/sharpdtm - -SUBDIRS_LDAP_PLUGIN = \ - kabc/plugins/ldap - -SUBDIRS_MICROMAIL = \ - kmicromail/libetpan \ - kmicromail/libmailwrapper \ - kmicromail - -SUBDIRS_GAMMU = \ - gammu/emb/common \ - gammu/emb/gammu - -SUBDIRS_PWMANAGER = \ - pwmanager/libcrypt/mpi \ - pwmanager/libcrypt/error \ - pwmanager/libcrypt/cipher \ - pwmanager/libcrypt/zlib \ - pwmanager/pwmanager - -SUBDIRS = \ - $(SUBDIRS_MICROKDE) \ - $(SUBDIRS_QTOPIA_PLUGIN) \ - $(SUBDIRS_OPIE_PLUGIN) \ - $(SUBDIRS_SHARP_PLUGIN) \ - $(SUBDIRS_LDAP_PLUGIN) \ - $(SUBDIRS_MICROMAIL) \ - $(SUBDIRS_GAMMU) \ - $(SUBDIRS_PWMANAGER) - - -all: build_microkde \ - build_qtopia_plugin \ - build_opie_plugin \ - build_sharp_plugin \ - build_ldap_plugin \ - build_micromail \ - build_gammu \ - build_pwmanager - - -build_microkde: variable_test tmake - for i in $(SUBDIRS_MICROKDE); do pushd $$i; \ - make -f Makefile$(PLATFORM) || exit 1; popd; \ - done - -build_qtopia_plugin: build_microkde - ifdef BUILD_NO_QTOPIA_PLUGIN - @echo == qtopia plugin not build. - else - for i in $(SUBDIRS_QTOPIA_PLUGIN); do pushd $$i; \ - make -f Makefile$(PLATFORM) || exit 1; popd; \ - done - endif - -build_opie_plugin: build_microkde - ifdef BUILD_NO_OPIE_PLUGIN - @echo == opie plugin not build. - else - for i in $(SUBDIRS_OPIE_PLUGIN); do pushd $$i; \ - make -f Makefile$(PLATFORM) || exit 1; popd; \ - done - endif - -build_sharp_plugin: build_microkde - ifdef BUILD_NO_SHARP_PLUGIN - @echo == ldap plugin not build. - else - for i in $(SUBDIRS_SHARP_PLUGIN); do pushd $$i; \ - make -f Makefile$(PLATFORM) || exit 1; popd; \ - done - endif - -build_ldap_plugin: build_microkde - ifdef BUILD_NO_LDAP_PLUGIN - @echo == ldap plugin not build. - else - for i in $(SUBDIRS_LDAP_PLUGIN); do pushd $$i; \ - make -f Makefile$(PLATFORM) || exit 1; popd; \ - done - endif - - -build_micromail: build_microkde - ifdef BUILD_NO_MICROMAIL - @echo == kmicromail not build. - else - for i in $(SUBDIRS_MICROMAIL); do pushd $$i; \ - make -f Makefile$(PLATFORM) || exit 1; popd; \ - done - endif - -build_gammu: variable_test tmake - ifdef BUILD_NO_GAMMU - @echo == gammu not build. - else - for i in $(SUBDIRS_GAMMU); do pushd $$i; \ - make -f Makefile$(PLATFORM) || exit 1; popd; \ - done - endif - -build_pwmanager: build_microkde - ifdef BUILD_NO_PWMANAGER - @echo == pwmanager not build. - else - for i in $(SUBDIRS_PWMANAGER); do pushd $$i; \ - make -f Makefile$(PLATFORM) || exit 1; popd; \ - done - endif - - -variable_info: - @echo -------------------------------------- - @echo KDEPIM buildsystem, variableinfo... - @echo KDEPIMDIR=$(KDEPIMDIR) - @echo QTDIR=$(QTDIR) - @echo QPEDIR=$(QPEDIR) - @echo OPIEDIR=$(OPIEDIR) - @echo PLATFORM=$(PLATFORM) - @echo RELEASE_DEBUG=$(RELEASE_DEBUG) - @echo BUILD_NO_MICROMAIL=$(BUILD_NO_MICROMAIL) - @echo BUILD_NO_LDAP_PLUGIN=$(BUILD_NO_LDAP_PLUGIN) - @echo BUILD_NO_OPIE_PLUGIN=$(BUILD_NO_OPIE_PLUGIN) - @echo BUILD_NO_QTOPIA_PLUGIN=$(BUILD_NO_QTOPIA_PLUGIN) - @echo BUILD_NO_SHARP_PLUGIN=$(BUILD_NO_SHARP_PLUGIN) - ifndef BUILD_NO_SHARP_PLUGIN - @echo SHARPDTMSDK=$(SHARPDTMSDK) - endif - @echo BUILD_NO_GAMMU=$(BUILD_NO_GAMMU) - @echo BUILD_NO_PWMANAGER=$(BUILD_NO_PWMANAGER) - @echo -------------------------------------- - -variable_test: variable_info - @echo KDEPIM buildsystem, variablecheck... - ifndef KDEPIMDIR - @echo KDEPIMDIR is not defined. - $(error KDEPIMDIR is not defined) - endif - ifndef PLATFORM - @echo PLATFORM is not defined. - $(error PLATFORM is not defined) - endif - ifdef BUILD_NO_LDAP_PLUGIN - @echo LDAP PLUGIN will not be build, because BUILD_NO_LDAP_PLUGIN is set to $(BUILD_NO_LDAP_PLUGIN) - endif - ifdef BUILD_NO_OPIE_PLUGIN - @echo OPIE PLUGIN will not be build, because BUILD_NO_OPIE_PLUGIN is set to $(BUILD_NO_OPIE_PLUGIN) - endif - ifdef BUILD_NO_QTOPIA_PLUGIN - @echo QTOPIA PLUGIN will not be build, because BUILD_NO__QTOPIA_PLUGIN is set to $(BUILD_NO__QTOPIA_PLUGIN) - endif - ifdef BUILD_NO_MICROMAIL - @echo MICROMAIL will not be build, because BUILD_NO_MICROMAIL is set to $(BUILD_NO_MICROMAIL) - endif - ifdef BUILD_NO_SHARP_PLUGIN - @echo SHARP PLUGIN will not be build, because BUILD_NO_SHARP_PLUGIN is set to $(BUILD_NO_SHARP_PLUGIN) - else - ifndef SHARPDTMSDK - @echo SHARP PLUGIN can not be build, because SHARPDTMSDK is set to $(SHARPDTMSDK) - $(error SHARPDTMSDK is not defined) - endif - endif - ifdef BUILD_NO_GAMMU - @echo GAMMU will not be build, because BUILD_NO_GAMMU is set to $(BUILD_NO_GAMMU) - endif - ifdef BUILD_NO_PWMANAGER - @echo PWMANAGER will not be build, because BUILD_NO_PWMANAGER is set to $(BUILD_NO_PWMANAGER) - endif - @echo -------------------------------------- - - -objects: - for i in $(SUBDIRS); do mkdir -p $$i/obj/$(PLATFORM); done - for i in $(SUBDIRS); do mkdir -p $$i/moc/$(PLATFORM); done - mkdir -p libical/lib/$(PLATFORM) - mkdir -p pwmanager/libcrypt/$(PLATFORM) - -clean: - rm -rf libical/lib/$(PLATFORM)/*; - rm -rf pwmanager/libcrypt/$(PLATFORM)/*; - for i in $(SUBDIRS); do pushd $$i; make clean; rm -f *~;\ - rm -f obj/$(PLATFORM)/*; rm -f moc/$(PLATFORM)/*; rm Makefile$(PLATFORM); popd; \ - done - -install: - - cd bin/kdepim; make install - cp -r Pim $(QPEDIR)/apps - cp db2file/db2file $(QPEDIR)/bin/db2file - cp korganizer/korganizer.desktop $(QPEDIR)/apps/Pim/korganizer.desktop - cp kaddressbook/kaddressbook.desktop $(QPEDIR)/apps/Pim/kaddressbook.desktop - cp kmicromail/kmicromail.desktop $(QPEDIR)/apps/Pim/kopiemail.desktop - cp pwmanager/pwmanager/pwmanager.desktop $(QPEDIR)/apps/Pim/pwmanager.desktop - -dist: - @echo Dont forget to do "make install" before "make dist" - rm -f *arm.ipk - rm -f *~ - cd ..; tar czf kdepim.src.tar.gz --exclude=obj --exclude=moc --exclude=CVS --exclude=Makefilezaurus --exclude=Makefileqtopia kdepim - mkipks kmicrokdelibs.control - mkipks korganizer.control - mkipks kaddressbook.control - ifndef BUILD_NO_MICROMAIL - mkipks kopiemail.control - endif - mkipks korganizer-alarm.control - ifndef BUILD_NO_GAMMU - mkipks phoneaccess.control - endif - ifndef BUILD_NO_PWMANAGER - mkipks pwmanager.control - endif - mkipks pim_TAB_icon.control - -tmake: objects \ - qtcompat/Makefile$(PLATFORM) \ - microkde/Makefile$(PLATFORM) \ - libkcal/Makefile$(PLATFORM) \ - libkdepim/Makefile$(PLATFORM) \ - korganizer/Makefile$(PLATFORM) \ - kalarmd/Makefile$(PLATFORM) \ - libical/src/libical/Makefile$(PLATFORM) \ - libical/src/libicalss/Makefile$(PLATFORM) \ - kabc/Makefile$(PLATFORM) \ - kabc/formats/binary/Makefile$(PLATFORM) \ - kabc/plugins/file/Makefile$(PLATFORM) \ - kabc/plugins/dir/Makefile$(PLATFORM) \ - kabc/plugins/ldap/Makefile$(PLATFORM) \ - kabc/plugins/opie/Makefile$(PLATFORM) \ - kabc/plugins/qtopia/Makefile$(PLATFORM) \ - kabc/plugins/sharpdtm/Makefile$(PLATFORM) \ - kaddressbook/Makefile$(PLATFORM) \ - kmicromail/Makefile$(PLATFORM) \ - kmicromail/libetpan/Makefile$(PLATFORM) \ - kmicromail/libmailwrapper/Makefile$(PLATFORM) \ - gammu/emb/common/Makefile$(PLATFORM) \ - gammu/emb/gammu/Makefile$(PLATFORM) \ - pwmanager/pwmanager/Makefile$(PLATFORM) \ - pwmanager/libcrypt/mpi/Makefile$(PLATFORM) \ - pwmanager/libcrypt/error/Makefile$(PLATFORM) \ - pwmanager/libcrypt/cipher/Makefile$(PLATFORM) \ - pwmanager/libcrypt/zlib/Makefile$(PLATFORM) - -qtcompat/Makefile$(PLATFORM): qtcompat/qtcompat.pro - cd qtcompat; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" qtcompat.pro -o Makefile$(PLATFORM) - -microkde/Makefile$(PLATFORM): microkde/microkdeE.pro - cd microkde; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" microkdeE.pro -o Makefile$(PLATFORM) - -libkcal/Makefile$(PLATFORM): libkcal/libkcalE.pro - cd libkcal; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libkcalE.pro -o Makefile$(PLATFORM) - - -libkdepim/Makefile$(PLATFORM): libkdepim/libkdepimE.pro - cd libkdepim; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libkdepimE.pro -o Makefile$(PLATFORM) - -kalarmd/Makefile$(PLATFORM): kalarmd/kalarmdE.pro - cd kalarmd; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kalarmdE.pro -o Makefile$(PLATFORM) - -korganizer/Makefile$(PLATFORM): korganizer/korganizerE.pro - cd korganizer; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" korganizerE.pro -o Makefile$(PLATFORM) - -libical/src/libical/Makefile$(PLATFORM): libical/src/libical/libicalE.pro - cd libical/src/libical; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libicalE.pro -o Makefile$(PLATFORM) - -libical/src/libicalss/Makefile$(PLATFORM): libical/src/libicalss/libicalssE.pro - cd libical/src/libicalss; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libicalssE.pro -o Makefile$(PLATFORM) - -kabc/Makefile$(PLATFORM): kabc/kabcE.pro - cd kabc; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kabcE.pro -o Makefile$(PLATFORM) - -kabc/formats/binary/Makefile$(PLATFORM): kabc/formats/binary/kabcformat_binaryE.pro - cd kabc/formats/binary; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kabcformat_binaryE.pro -o Makefile$(PLATFORM) - -kabc/plugins/file/Makefile$(PLATFORM): kabc/plugins/file/fileE.pro - cd kabc/plugins/file; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" fileE.pro -o Makefile$(PLATFORM) - -kabc/plugins/dir/Makefile$(PLATFORM): kabc/plugins/dir/dirE.pro - cd kabc/plugins/dir; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" dirE.pro -o Makefile$(PLATFORM) - -kabc/plugins/ldap/Makefile$(PLATFORM): kabc/plugins/ldap/ldapE.pro - cd kabc/plugins/ldap; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" ldapE.pro -o Makefile$(PLATFORM) - -kabc/plugins/opie/Makefile$(PLATFORM): kabc/plugins/opie/opieE.pro - cd kabc/plugins/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" opieE.pro -o Makefile$(PLATFORM) - -kabc/plugins/qtopia/Makefile$(PLATFORM): kabc/plugins/qtopia/qtopiaE.pro - cd kabc/plugins/qtopia; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" qtopiaE.pro -o Makefile$(PLATFORM) - -kabc/plugins/sharpdtm/Makefile$(PLATFORM): kabc/plugins/sharpdtm/sharpdtmE.pro - cd kabc/plugins/sharpdtm; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" sharpdtmE.pro -o Makefile$(PLATFORM) - -kaddressbook/Makefile$(PLATFORM): kaddressbook/kaddressbookE.pro - cd kaddressbook; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kaddressbookE.pro -o Makefile$(PLATFORM) - -kmicromail/Makefile$(PLATFORM): kmicromail/kmicromailE.pro - cd kmicromail; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kmicromailE.pro -o Makefile$(PLATFORM) - -kmicromail/libetpan/Makefile$(PLATFORM): kmicromail/libetpan/libetpanE.pro - cd kmicromail/libetpan; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libetpanE.pro -o Makefile$(PLATFORM) - -kmicromail/libmailwrapper/Makefile$(PLATFORM): kmicromail/libmailwrapper/libmailwrapperE.pro - cd kmicromail/libmailwrapper; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libmailwrapperE.pro -o Makefile$(PLATFORM) - -gammu/emb/common/Makefile$(PLATFORM): gammu/emb/common/commonE.pro - cd gammu/emb/common; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" commonE.pro -o Makefile$(PLATFORM) - -gammu/emb/gammu/Makefile$(PLATFORM): gammu/emb/gammu/gammuE.pro - cd gammu/emb/gammu; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" gammuE.pro -o Makefile$(PLATFORM) - -pwmanager/pwmanager/Makefile$(PLATFORM): pwmanager/pwmanager/pwmanagerE.pro - cd pwmanager/pwmanager; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" pwmanagerE.pro -o Makefile$(PLATFORM) - - -pwmanager/libcrypt/mpi/Makefile$(PLATFORM): pwmanager/libcrypt/mpi/mpi.pro - cd pwmanager/libcrypt/mpi;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" mpi.pro -o Makefile$(PLATFORM) - -pwmanager/libcrypt/error/Makefile$(PLATFORM): pwmanager/libcrypt/error/error.pro - cd pwmanager/libcrypt/error;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" error.pro -o Makefile$(PLATFORM) - -pwmanager/libcrypt/cipher/Makefile$(PLATFORM): pwmanager/libcrypt/cipher/cipher.pro - cd pwmanager/libcrypt/cipher;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" cipher.pro -o Makefile$(PLATFORM) - -pwmanager/libcrypt/zlib/Makefile$(PLATFORM): pwmanager/libcrypt/zlib/zlib.pro - cd pwmanager/libcrypt/zlib;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" zlib.pro -o Makefile$(PLATFORM) - +############################################################################# +# Makefile for building: kdepim-desktop +# Generated by qmake (1.07a) (Qt 3.3.1) on: Wed Oct 20 16:51:16 2004 +# Project: kdepim-desktop.pro +# Template: subdirs +# Command: $(QMAKE) -o Makefile kdepim-desktop.pro +############################################################################# + +MAKEFILE = Makefile +QMAKE = qmake +DEL_FILE = rm -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p +SUBTARGETS = \ + sub-gammu-emb-common \ + sub-gammu-emb-gammu \ + sub-libical \ + sub-libkcal \ + sub-microkde \ + sub-libkdepim \ + sub-kabc \ + sub-korganizer \ + sub-kaddressbook \ + sub-kabc-plugins-file \ + sub-kabc-plugins-dir + +first: all + +all: Makefile $(SUBTARGETS) + +gammu/emb/common/$(MAKEFILE): + @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common" + cd gammu/emb/common && $(QMAKE) common.pro -o $(MAKEFILE) +sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE + cd gammu/emb/common && $(MAKE) -f $(MAKEFILE) + +gammu/emb/gammu/$(MAKEFILE): + @$(CHK_DIR_EXISTS) "gammu/emb/gammu" || $(MKDIR) "gammu/emb/gammu" + cd gammu/emb/gammu && $(QMAKE) gammu.pro -o $(MAKEFILE) +sub-gammu-emb-gammu: gammu/emb/gammu/$(MAKEFILE) FORCE + cd gammu/emb/gammu && $(MAKE) -f $(MAKEFILE) + +libical/$(MAKEFILE): + @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical" + cd libical && $(QMAKE) libical.pro -o $(MAKEFILE) +sub-libical: libical/$(MAKEFILE) FORCE + cd libical && $(MAKE) -f $(MAKEFILE) + +libkcal/$(MAKEFILE): + @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal" + cd libkcal && $(QMAKE) libkcal.pro -o $(MAKEFILE) +sub-libkcal: libkcal/$(MAKEFILE) FORCE + cd libkcal && $(MAKE) -f $(MAKEFILE) + +microkde/$(MAKEFILE): + @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde" + cd microkde && $(QMAKE) microkde.pro -o $(MAKEFILE) +sub-microkde: microkde/$(MAKEFILE) FORCE + cd microkde && $(MAKE) -f $(MAKEFILE) + +libkdepim/$(MAKEFILE): + @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim" + cd libkdepim && $(QMAKE) libkdepim.pro -o $(MAKEFILE) +sub-libkdepim: libkdepim/$(MAKEFILE) FORCE + cd libkdepim && $(MAKE) -f $(MAKEFILE) + +kabc/$(MAKEFILE): + @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc" + cd kabc && $(QMAKE) kabc.pro -o $(MAKEFILE) +sub-kabc: kabc/$(MAKEFILE) FORCE + cd kabc && $(MAKE) -f $(MAKEFILE) + +korganizer/$(MAKEFILE): + @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer" + cd korganizer && $(QMAKE) korganizer.pro -o $(MAKEFILE) +sub-korganizer: korganizer/$(MAKEFILE) FORCE + cd korganizer && $(MAKE) -f $(MAKEFILE) + +kaddressbook/$(MAKEFILE): + @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook" + cd kaddressbook && $(QMAKE) kaddressbook.pro -o $(MAKEFILE) +sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE + cd kaddressbook && $(MAKE) -f $(MAKEFILE) + +kabc/plugins/file/$(MAKEFILE): + @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file" + cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE) +sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE + cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE) + +kabc/plugins/dir/$(MAKEFILE): + @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir" + cd kabc/plugins/dir && $(QMAKE) dir.pro -o $(MAKEFILE) +sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE + cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE) + +Makefile: kdepim-desktop.pro /usr/lib/qt3/mkspecs/default/qmake.conf + $(QMAKE) -o Makefile kdepim-desktop.pro +qmake: qmake_all + @$(QMAKE) -o Makefile kdepim-desktop.pro + +all: $(SUBTARGETS) +qmake_all: gammu/emb/common/$(MAKEFILE) gammu/emb/gammu/$(MAKEFILE) libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE) + ( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true + ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true + ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true + ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true + ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true + ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true + ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true + ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true + ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true + ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true + ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true +clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE + ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; ) || true + ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; ) || true + ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true + ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true + ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true + ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true + ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true + ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true + ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true + ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true + ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true +uninstall_subdirs: qmake_all FORCE + ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true + ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true + ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true + ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true + ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true + ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true + ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true + ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true + ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true + ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true + ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true +install_subdirs: qmake_all FORCE + ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) install; ) || true + ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) install; ) || true + ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true + ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true + ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true + ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true + ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true + ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true + ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true + ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true + ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true +distclean: qmake_all FORCE + ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true + ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true + ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true + ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true + ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true + ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true + ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true + ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true + ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true + ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true + ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true + +install: install_subdirs + +uninstall: uninstall_subdirs + +FORCE: diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 63484d6..e3dad94 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -1099,790 +1099,796 @@ void MainWindow::setDefaultPreferences() // p->mEnableQuickTodo = false; } QString MainWindow::resourcePath() { return KGlobal::iconLoader()->iconPath(); } void MainWindow::displayText( QString text ,QString cap ) { QDialog dia( this, "name", true ); ; dia.setCaption( cap ); QVBoxLayout* lay = new QVBoxLayout( &dia ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QTextBrowser tb ( &dia ); lay->addWidget( &tb ); tb.setText( text ); #ifdef DESKTOP_VERSION dia.resize( 640, 480); #else dia.showMaximized(); #endif dia.exec(); } void MainWindow::displayFile( QString fn, QString cap ) { QString fileName = resourcePath() + fn; QString text; QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { return ; } QTextStream ts( &file ); text = ts.read(); file.close(); displayText( text, cap); } void MainWindow::features() { displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); } void MainWindow::usertrans() { displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); } void MainWindow::synchowto() { KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); } void MainWindow::faq() { displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); } void MainWindow::whatsNew() { KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); } void MainWindow::licence() { KApplication::showLicence(); } void MainWindow::about() { QString version; #include <../version> QMessageBox::about( this, i18n("About KOrganizer/Pi"), i18n("KOrganizer/Platform-independent\n") + "(KO/Pi) " + version + " - " + #ifdef DESKTOP_VERSION i18n("Desktop Edition\n") + #else i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + #endif i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); } void MainWindow::keyBindings() { QString cap = i18n("Key bindings KOrganizer/Pi"); QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ i18n("<p><h3>In agenda view:</h3></p>\n") + i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ i18n("<p><h3>In todo view:</h3></p>\n") + i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ i18n("<p><h3>In list view:</h3></p>\n") + i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ i18n("<p><b>return</b>: Select item+one step down</p>\n")+ i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ i18n("<p><h3>In event/todo viewer:</h3></p>\n") + i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ i18n("<p><b>A</b>: Show agenda view.</p>\n")+ i18n("<p><b>E</b>: Edit item</p>\n") + i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + i18n("<p><b>White</b>: Item readonly</p>\n"); displayText( text, cap); } void MainWindow::aboutAutoSaving() { QMessageBox* msg; msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); msg->exec(); delete msg; } void MainWindow::aboutKnownBugs() { QMessageBox* msg; msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + i18n("\nor report them in the bugtracker on\n") + i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), QMessageBox::NoIcon, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); msg->exec(); delete msg; } QString MainWindow::defaultFileName() { return locateLocal( "data", "korganizer/mycalendar.ics" ); } QString MainWindow::syncFileName() { #ifdef DESKTOP_VERSION return locateLocal( "tmp", "synccalendar.ics" ); #else return QString( "/tmp/synccalendar.ics" ); #endif } void MainWindow::processIncidenceSelection( Incidence *incidence ) { if ( !incidence ) { enableIncidenceActions( false ); mNewSubTodoAction->setEnabled( false ); setCaptionToDates(); return; } //KGlobal::locale()->formatDateTime(nextA, true); QString startString = ""; if ( incidence->type() != "Todo" ) { if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { if ( incidence->doesFloat() ) { startString += ": "+incidence->dtStartDateStr( true ); startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); } else { startString = ": "+incidence->dtStartStr(true); startString += " --- "+((Event*)incidence)->dtEndStr(true); } } else { if ( incidence->dtStart().time() != incidence->dtEnd().time() ) startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); } } else startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); if ( !incidence->location().isEmpty() ) startString += " (" +incidence->location()+")"; setCaption( incidence->summary()+startString); enableIncidenceActions( true ); if ( incidence->type() == "Event" ) { mShowAction->setText( i18n("Show Event...") ); mEditAction->setText( i18n("Edit Event...") ); mDeleteAction->setText( i18n("Delete Event...") ); mNewSubTodoAction->setEnabled( false ); } else if ( incidence->type() == "Todo" ) { mShowAction->setText( i18n("Show Todo...") ); mEditAction->setText( i18n("Edit Todo...") ); mDeleteAction->setText( i18n("Delete Todo...") ); mNewSubTodoAction->setEnabled( true ); } else { mShowAction->setText( i18n("Show...") ); mShowAction->setText( i18n("Edit...") ); mShowAction->setText( i18n("Delete...") ); mNewSubTodoAction->setEnabled( false ); } } void MainWindow::enableIncidenceActions( bool enabled ) { mShowAction->setEnabled( enabled ); mEditAction->setEnabled( enabled ); mDeleteAction->setEnabled( enabled ); mCloneAction->setEnabled( enabled ); mMoveAction->setEnabled( enabled ); mBeamAction->setEnabled( enabled ); mCancelAction->setEnabled( enabled ); } void MainWindow::importOL() { #ifdef _WIN32_ KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); id->exec(); delete id; mView->updateView(); #endif } void MainWindow::importBday() { int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), i18n("Import!"), i18n("Cancel"), 0, 0, 1 ); if ( result == 0 ) { mView->importBday(); } } void MainWindow::importQtopia() { #ifndef DESKTOP_VERSION int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), i18n("Import!"), i18n("Cancel"), 0, 0, 1 ); if ( result == 0 ) { QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; mView->importQtopia( categories, datebook, todolist ); } #else int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), i18n("Not supported \non desktop!\n"), i18n("Ok"), i18n("Cancel"), 0, 0, 1 ); #endif } void MainWindow::saveOnClose() { KOPrefs *p = KOPrefs::instance(); p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); p->mToolBarUp = iconToolBar->x() > width()/2 || iconToolBar->y() > height()/2; mView->writeSettings(); if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) save(); } void MainWindow::slotModifiedChanged( bool changed ) { if ( mBlockAtStartup ) return; int msec; // we store the changes after 1 minute, // and for safety reasons after 10 minutes again if ( !mSyncManager->blockSave() ) msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; else msec = 1000 * 600; mSaveTimer.start( msec, true ); // 1 minute qDebug("KO: Saving File in %d secs!", msec/1000); mCalendarModifiedFlag = true; } void MainWindow::save() { if ( mSyncManager->blockSave() ) return; mSyncManager->setBlockSave(true); if ( mView->checkFileVersion( defaultFileName()) ) { QTime neededSaveTime = QDateTime::currentDateTime().time(); setCaption(i18n("KO/Pi:Saving Data to File ..." )); qDebug("KO: Start saving data to file!"); mView->saveCalendar( defaultFileName() ); int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); qDebug("KO: Needed %d ms for saving.",msNeeded ); QString savemes; savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); setCaption(savemes); } else setCaption(i18n("Saving cancelled!")); mCalendarModifiedFlag = false; mSyncManager->setBlockSave( false ); } void MainWindow::keyReleaseEvent ( QKeyEvent * e) { if ( !e->isAutoRepeat() ) { mFlagKeyPressed = false; } } void MainWindow::keyPressEvent ( QKeyEvent * e ) { qApp->processEvents(); if ( e->isAutoRepeat() && !mFlagKeyPressed ) { e->ignore(); // qDebug(" ignore %d",e->isAutoRepeat() ); return; } if (! e->isAutoRepeat() ) mFlagKeyPressed = true; KOPrefs *p = KOPrefs::instance(); bool showSelectedDates = false; int size; int pro = 0; //qDebug("MainWindow::keyPressEvent "); switch ( e->key() ) { case Qt::Key_Right: if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) mView->goNextMonth(); else mView->goNext(); showSelectedDates = true; break; case Qt::Key_Left: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) mView->goPreviousMonth(); else mView->goPrevious(); showSelectedDates = true; break; case Qt::Key_Down: mView->viewManager()->agendaView()->scrollOneHourDown(); break; case Qt::Key_Up: mView->viewManager()->agendaView()->scrollOneHourUp(); break; case Qt::Key_I: mView->showIncidence(); break; case Qt::Key_Delete: case Qt::Key_Backspace: mView->deleteIncidence(); break; case Qt::Key_D: mView->viewManager()->showDayView(); showSelectedDates = true; break; case Qt::Key_O: mView->toggleFilerEnabled( ); break; case Qt::Key_0: case Qt::Key_1: case Qt::Key_2: case Qt::Key_3: case Qt::Key_4: case Qt::Key_5: case Qt::Key_6: case Qt::Key_7: case Qt::Key_8: case Qt::Key_9: pro = e->key()-48; if ( pro == 0 ) pro = 10; if ( e->state() == Qt::ControlButton) pro += 10; break; case Qt::Key_M: mView->viewManager()->showMonthView(); showSelectedDates = true; break; case Qt::Key_Insert: mView->newEvent(); break; case Qt::Key_S : if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) mView->newSubTodo(); else mView->dialogManager()->showSearchDialog(); break; case Qt::Key_Y : case Qt::Key_Z : mView->viewManager()->showWorkWeekView(); showSelectedDates = true; break; case Qt::Key_U : mView->viewManager()->showWeekView(); showSelectedDates = true; break; case Qt::Key_H : keyBindings(); break; case Qt::Key_W: mView->viewManager()->showWhatsNextView(); break; case Qt::Key_L: mView->viewManager()->showListView(); break; case Qt::Key_N: mView->viewManager()->showNextXView(); showSelectedDates = true; break; case Qt::Key_V: mView->viewManager()->showTodoView(); break; case Qt::Key_C: mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); break; case Qt::Key_P: mView->showDatePicker( ); break; case Qt::Key_F: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) mView->editFilters(); else mView->toggleFilter(); break; case Qt::Key_X: mView->toggleDateNavigatorWidget(); break; case Qt::Key_Space: mView->toggleExpand(); break; case Qt::Key_A: mView->toggleAllDaySize(); break; case Qt::Key_T: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) mView->newTodo(); else { mView->goToday(); showSelectedDates = true; } break; case Qt::Key_J: mView->viewManager()->showJournalView(); break; case Qt::Key_B: mView->editIncidenceDescription();; break; // case Qt::Key_Return: case Qt::Key_E: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) mView->newEvent(); else mView->editIncidence(); break; case Qt::Key_Plus: size = p->mHourSize +2; if ( size <= 18 ) configureAgenda( size ); break; case Qt::Key_Minus: size = p->mHourSize - 2; if ( size >= 4 ) configureAgenda( size ); break; default: e->ignore(); } if ( pro > 0 ) { mView->selectFilter( pro-1 ); } if ( showSelectedDates ) { ;// setCaptionToDates(); } } void MainWindow::fillFilterMenu() { selectFilterMenu->clear(); bool disable = false; if ( mView->filterView()->filtersEnabled() ) { selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); } else { selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); disable = true; } selectFilterMenu->insertSeparator(); QPtrList<CalFilter> fili = mView->filters(); CalFilter *curfilter = mView->filterView()->selectedFilter(); CalFilter *filter = fili.first(); int iii = 1; while(filter) { selectFilterMenu->insertItem( filter->name(), iii ); if ( filter == curfilter) selectFilterMenu->setItemChecked( iii, true ); if ( disable ) selectFilterMenu->setItemEnabled( iii, false ); filter = fili.next(); ++iii; } } void MainWindow::selectFilter( int fil ) { if ( fil == 0 ) { mView->toggleFilerEnabled( ); } else { mView->selectFilter( fil-1 ); } } void MainWindow::configureToolBar( int item ) { configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); KOPrefs *p = KOPrefs::instance(); p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); // initActions(); } void MainWindow::setCaptionToDates() { QString selDates; selDates = KGlobal::locale()->formatDate(mView->startDate(), true); if (mView->startDate() < mView->endDate() ) selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); setCaption( i18n("Dates: ") + selDates ); } // parameter item == 0: reinit void MainWindow::configureAgenda( int item ) { KOPrefs *p = KOPrefs::instance(); int i; if ( item == 1 ) { mView->toggleAllDaySize(); return; } // do not allow 4 for widgets higher than 480 // if ( QApplication::desktop()->height() > 480 ) { // if ( item == 4 ) // item = 6; // } for ( i = 4; i <= 18; i= i+2 ) configureAgendaMenu->setItemChecked( i, false ); configureAgendaMenu->setItemChecked( item, true ); if ( p->mHourSize == item ) return; p->mHourSize=item; mView->viewManager()->agendaView()->updateConfig(); } void MainWindow::saveCalendar() { QString fn = KOPrefs::instance()->mLastSaveFile; fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); if ( fn == "" ) return; QFileInfo info; info.setFile( fn ); QString mes; bool createbup = true; if ( info. exists() ) { mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, i18n("Overwrite!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { createbup = false; } } if ( createbup ) { mView->saveCalendar( fn ); mes = i18n("KO/Pi:Saved %1").arg(fn); KOPrefs::instance()->mLastSaveFile = fn; setCaption(mes); } } void MainWindow::loadCalendar() { QString fn = KOPrefs::instance()->mLastLoadFile; fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); if ( fn == "" ) return; QFileInfo info; info.setFile( fn ); QString mess; bool loadbup = true; if ( info. exists() ) { mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); int result = QMessageBox::warning( this, "KO/Pi: Warning!", mess, i18n("Load!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { loadbup = false; } } else { QMessageBox::warning( this, i18n("KO/Pi: Warning!"), i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 0, 1 ); return; } if ( loadbup ) { mView->openCalendar( fn ); KOPrefs::instance()->mLastLoadFile = fn; mess = i18n("KO/Pi:Loaded %1").arg(fn) ; setCaption(mess); } } void MainWindow::quickImportIcal() { importFile( KOPrefs::instance()->mLastImportFile, false ); } void MainWindow::importFile( QString fn, bool quick ) { QFileInfo info; info.setFile( fn ); QString mess; bool loadbup = true; if ( !info. exists() ) { mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), mess ); return; } int result = 0; if ( !quick ) { mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); result = QMessageBox::warning( this, "KO/Pi: Warning!", mess, "Import", "Cancel", 0, 0, 1 ); } if ( result == 0 ) { if ( mView->openCalendar( fn, true )) { KOPrefs::instance()->mLastImportFile = fn; setCaption(i18n("Imported file successfully")); } else { setCaption(i18n("Error importing file")); } } } void MainWindow::importIcal() { QString fn =KOPrefs::instance()->mLastImportFile; fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); if ( fn == "" ) return; importFile( fn, true ); } void MainWindow::exportVCalendar() { QString fn = KOPrefs::instance()->mLastVcalFile; fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); if ( fn == "" ) return; QFileInfo info; info.setFile( fn ); QString mes; bool createbup = true; if ( info. exists() ) { mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, i18n("Overwrite!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { createbup = false; } } if ( createbup ) { if ( mView->exportVCalendar( fn ) ) { KOPrefs::instance()->mLastVcalFile = fn; if ( fn.length() > 20 ) mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; else mes = i18n("KO/Pi:Exported to %1").arg(fn ); setCaption(mes); } } } void MainWindow::syncFileRequest() { + if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { + mSyncManager->slotSyncMenu( 999 ); + } save(); } void MainWindow::getFile( bool success ) { if ( ! success ) { setCaption( i18n("Error receiving file. Nothing changed!") ); return; } mView->openCalendar( defaultFileName() ); + if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { + mSyncManager->slotSyncMenu( 999 ); + } setCaption( i18n("Pi-Sync successful!") ); } void MainWindow::printSel( ) { mView->viewManager()->agendaView()->agenda()->printSelection(); } void MainWindow::printCal() { mView->print();//mCp->showDialog(); } diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 7ca3ee0..554c6e5 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -1,1327 +1,1356 @@ /* This file is part of KDE-Pim/Pi. Copyright (c) 2004 Ulf Schenk This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // $Id$ #include "ksyncmanager.h" #include <stdlib.h> #ifndef _WIN32_ #include <unistd.h> #endif #include "ksyncprofile.h" #include "ksyncprefsdialog.h" #include "kpimprefs.h" #include <kmessagebox.h> #include <qdir.h> #include <qprogressbar.h> #include <qpopupmenu.h> #include <qpushbutton.h> #include <qradiobutton.h> #include <qbuttongroup.h> #include <qtimer.h> #include <qmessagebox.h> #include <qapplication.h> #include <qlineedit.h> #include <qdialog.h> #include <qlayout.h> #include <qtextcodec.h> #include <qlabel.h> #include <qcheckbox.h> #include <klocale.h> #include <kglobal.h> #include <kconfig.h> #include <kfiledialog.h> KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) { mServerSocket = 0; bar = new QProgressBar ( 1, 0 ); bar->setCaption (""); int w = 300; if ( QApplication::desktop()->width() < 320 ) w = 220; int h = bar->sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); if ( mPrefs->mPassiveSyncAutoStart ) enableQuick( false ); } KSyncManager::~KSyncManager() { delete bar; } void KSyncManager::fillSyncMenu() { if ( mSyncMenu->count() ) mSyncMenu->clear(); mSyncMenu->insertItem( i18n("Configure..."), 0 ); mSyncMenu->insertSeparator(); if ( mServerSocket == 0 ) { mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); } else { mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); } mSyncMenu->insertSeparator(); mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); mSyncMenu->insertSeparator(); KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); config.setGroup("General"); QStringList prof = config.readListEntry("SyncProfileNames"); mLocalMachineName = config.readEntry("LocalMachineName","undefined"); if ( prof.count() < 2 ) { prof.clear(); #ifdef DESKTOP_VERSION #ifdef _WIN32_ prof << i18n("OutLook(not_implemented)"); #else prof << i18n("KDE_Desktop"); #endif #else prof << i18n("Sharp_DTM"); #endif prof << i18n("Local_file"); prof << i18n("Last_file"); KSyncProfile* temp = new KSyncProfile (); temp->setName( prof[0] ); temp->writeConfig(&config); temp->setName( prof[1] ); temp->writeConfig(&config); temp->setName( prof[2] ); temp->writeConfig(&config); config.setGroup("General"); config.writeEntry("SyncProfileNames",prof); config.writeEntry("ExternSyncProfiles","Sharp_DTM"); config.sync(); delete temp; } mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); mSyncProfileNames = prof; unsigned int i; for ( i = 0; i < prof.count(); ++i ) { mSyncMenu->insertItem( prof[i], 1000+i ); if ( i == 2 ) mSyncMenu->insertSeparator(); } QDir app_dir; //US do not display SharpDTM if app is pwmpi, or no sharpfiles available if ( mTargetApp == PWMPI) { mSyncMenu->removeItem( 1000 ); } #ifndef DESKTOP_VERSION else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { mSyncMenu->removeItem( 1000 ); } #endif mSyncMenu->removeItem( 1002 ); } void KSyncManager::slotSyncMenu( int action ) { qDebug("syncaction %d ", action); if ( action == 0 ) { // seems to be a Qt2 event handling bug // syncmenu.clear causes a segfault at first time // when we call it after the main event loop, it is ok // same behaviour when calling OM/Pi via QCOP for the first time QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); //confSync(); return; } if ( action == 1 ) { multiSync( true ); return; } if ( action == 2 ) { enableQuick(); QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); return; } if ( action == 3 ) { delete mServerSocket; mServerSocket = 0; QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); return; } if (blockSave()) return; setBlockSave(true); + bool silent = false; + if ( action == 999 ) { + //special mode for silent syncing + action = 1000; + silent = true; + } mCurrentSyncProfile = action - 1000 ; mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; mCurrentSyncName = mLocalMachineName ; KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); KSyncProfile* temp = new KSyncProfile (); temp->setName(mSyncProfileNames[mCurrentSyncProfile]); temp->readConfig(&config); + if (silent) { + mAskForPreferences = false; + mShowSyncSummary = false; + mWriteBackFile = true; + mSyncAlgoPrefs = 2;// take newest + } + else { mAskForPreferences = temp->getAskForPreferences(); - mSyncAlgoPrefs = temp->getSyncPrefs(); + mShowSyncSummary = temp->getShowSummaryAfterSync(); mWriteBackFile = temp->getWriteBackFile(); + mSyncAlgoPrefs = temp->getSyncPrefs(); + } mWriteBackExistingOnly = temp->getWriteBackExisting(); mIsKapiFile = temp->getIsKapiFile(); mWriteBackInFuture = 0; if ( temp->getWriteBackFuture() ) mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); - mShowSyncSummary = temp->getShowSummaryAfterSync(); + if ( action == 1000 ) { #ifdef DESKTOP_VERSION syncKDE(); #else syncSharp(); #endif } else if ( action == 1001 ) { syncLocalFile(); } else if ( action == 1002 ) { mWriteBackFile = false; mAskForPreferences = false; mShowSyncSummary = false; mSyncAlgoPrefs = 3; quickSyncLocalFile(); } else if ( action >= 1003 ) { if ( temp->getIsLocalFileSync() ) { switch(mTargetApp) { case (KAPI): if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); break; case (KOPI): if ( syncWithFile( temp->getRemoteFileName( ), false ) ) mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); break; case (PWMPI): if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); break; default: qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); break; } } else { if ( temp->getIsPhoneSync() ) { mPhoneDevice = temp->getPhoneDevice( ) ; mPhoneConnection = temp->getPhoneConnection( ); mPhoneModel = temp->getPhoneModel( ); syncPhone(); } else if ( temp->getIsPiSync() ) { if ( mTargetApp == KAPI ) { mPassWordPiSync = temp->getRemotePwAB(); mActiveSyncPort = temp->getRemotePortAB(); mActiveSyncIP = temp->getRemoteIPAB(); } else if ( mTargetApp == KOPI ) { mPassWordPiSync = temp->getRemotePw(); mActiveSyncPort = temp->getRemotePort(); mActiveSyncIP = temp->getRemoteIP(); } else { mPassWordPiSync = temp->getRemotePwPWM(); mActiveSyncPort = temp->getRemotePortPWM(); mActiveSyncIP = temp->getRemoteIPPWM(); } syncPi(); while ( !mPisyncFinished ) { //qDebug("waiting "); qApp->processEvents(); } } else syncRemote( temp ); } } delete temp; setBlockSave(false); } void KSyncManager::enableQuick( bool ask ) { bool autoStart; bool changed = false; if ( ask ) { QDialog dia ( 0, "input-dialog", true ); QLineEdit lab ( &dia ); QVBoxLayout lay( &dia ); lab.setText( mPrefs->mPassiveSyncPort ); lay.setMargin(7); lay.setSpacing(7); int po = 9197+mTargetApp; QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); lay.addWidget( &label); lay.addWidget( &lab); QLineEdit lepw ( &dia ); lepw.setText( mPrefs->mPassiveSyncPw ); QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); lay.addWidget( &label2); lay.addWidget( &lepw); QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); lay.addWidget( &autostart); autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); #ifdef DESKTOP_VERSION #ifdef _WIN32_ QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); #else QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); #endif lay.addWidget( &syncdesktop); #else + mPrefs->mPassiveSyncWithDesktop = false; QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); syncdesktop.hide(); #endif syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); dia.setFixedSize( 230,120 ); dia.setCaption( i18n("Enter port for Pi-Sync") ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); dia.show(); if ( ! dia.exec() ) return; dia.hide(); qApp->processEvents(); if ( mPrefs->mPassiveSyncPw != lepw.text() ) { changed = true; mPrefs->mPassiveSyncPw = lepw.text(); } if ( mPrefs->mPassiveSyncPort != lab.text() ) { mPrefs->mPassiveSyncPort = lab.text(); changed = true; } autoStart = autostart.isChecked(); if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { changed = true; mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); } } else autoStart = mPrefs->mPassiveSyncAutoStart; if ( autoStart != mPrefs->mPassiveSyncAutoStart ) changed = true; bool ok; mPrefs->mPassiveSyncAutoStart = false; Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); if ( ! ok ) { KMessageBox::information( 0, i18n("No valid port")); return; } //qDebug("port %d ", port); mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); mServerSocket->setFileName( defaultFileName() ); //qDebug("connected "); if ( !mServerSocket->ok() ) { KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); delete mServerSocket; mServerSocket = 0; return; } mPrefs->mPassiveSyncAutoStart = autoStart; if ( changed ) { mPrefs->writeConfig(); } connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); } void KSyncManager::syncLocalFile() { QString fn =mPrefs->mLastSyncedLocalFile; QString ext; switch(mTargetApp) { case (KAPI): ext = "(*.vcf)"; break; case (KOPI): ext = "(*.ics/*.vcs)"; break; case (PWMPI): ext = "(*.pwm)"; break; default: qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); break; } fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); if ( fn == "" ) return; if ( syncWithFile( fn, false ) ) { qDebug("syncLocalFile() successful "); } } bool KSyncManager::syncWithFile( QString fn , bool quick ) { bool ret = false; QFileInfo info; info.setFile( fn ); QString mess; bool loadbup = true; if ( !info. exists() ) { mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); int result = QMessageBox::warning( mParent, i18n("Warning!"), mess ); return ret; } int result = 0; if ( !quick ) { mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); result = QMessageBox::warning( mParent, i18n("Warning!"), mess, i18n("Sync"), i18n("Cancel"), 0, 0, 1 ); if ( result ) return false; } if ( mAskForPreferences ) - edit_sync_options(); + if ( !edit_sync_options()) { + mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); + return false; + } if ( result == 0 ) { //qDebug("Now sycing ... "); if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); else mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); if ( ! quick ) mPrefs->mLastSyncedLocalFile = fn; } return ret; } void KSyncManager::quickSyncLocalFile() { if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { qDebug("quick syncLocalFile() successful "); } } void KSyncManager::multiSync( bool askforPrefs ) { if (blockSave()) return; setBlockSave(true); QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), question, i18n("Yes"), i18n("No"), 0, 0 ) != 0 ) { setBlockSave(false); mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); return; } mCurrentSyncDevice = i18n("Multiple profiles") ; mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; if ( askforPrefs ) { - edit_sync_options(); + if ( !edit_sync_options()) { + mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); + return; + } mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; } mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); qApp->processEvents(); int num = ringSync() ; if ( num > 1 ) ringSync(); setBlockSave(false); if ( num ) emit save(); if ( num ) mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); else mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); return; } int KSyncManager::ringSync() { int syncedProfiles = 0; unsigned int i; QTime timer; KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); QStringList syncProfileNames = mSyncProfileNames; KSyncProfile* temp = new KSyncProfile (); mAskForPreferences = false; for ( i = 0; i < syncProfileNames.count(); ++i ) { mCurrentSyncProfile = i; temp->setName(syncProfileNames[mCurrentSyncProfile]); temp->readConfig(&config); bool includeInRingSync; switch(mTargetApp) { case (KAPI): includeInRingSync = temp->getIncludeInRingSyncAB(); break; case (KOPI): includeInRingSync = temp->getIncludeInRingSync(); break; case (PWMPI): includeInRingSync = temp->getIncludeInRingSyncPWM(); break; default: qDebug("KSyncManager::ringSync: invalid apptype selected"); break; } if ( includeInRingSync && ( i < 1 || i > 2 )) { mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); ++syncedProfiles; // mAskForPreferences = temp->getAskForPreferences(); mWriteBackFile = temp->getWriteBackFile(); mWriteBackExistingOnly = temp->getWriteBackExisting(); mWriteBackInFuture = 0; if ( temp->getWriteBackFuture() ) mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); mShowSyncSummary = false; mCurrentSyncDevice = syncProfileNames[i] ; mCurrentSyncName = mLocalMachineName; if ( i == 0 ) { #ifdef DESKTOP_VERSION syncKDE(); #else syncSharp(); #endif } else { if ( temp->getIsLocalFileSync() ) { switch(mTargetApp) { case (KAPI): if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); break; case (KOPI): if ( syncWithFile( temp->getRemoteFileName( ), false ) ) mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); break; case (PWMPI): if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); break; default: qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); break; } } else { if ( temp->getIsPhoneSync() ) { mPhoneDevice = temp->getPhoneDevice( ) ; mPhoneConnection = temp->getPhoneConnection( ); mPhoneModel = temp->getPhoneModel( ); syncPhone(); } else if ( temp->getIsPiSync() ) { if ( mTargetApp == KAPI ) { mPassWordPiSync = temp->getRemotePwAB(); mActiveSyncPort = temp->getRemotePortAB(); mActiveSyncIP = temp->getRemoteIPAB(); } else if ( mTargetApp == KOPI ) { mPassWordPiSync = temp->getRemotePw(); mActiveSyncPort = temp->getRemotePort(); mActiveSyncIP = temp->getRemoteIP(); } else { mPassWordPiSync = temp->getRemotePwPWM(); mActiveSyncPort = temp->getRemotePortPWM(); mActiveSyncIP = temp->getRemoteIPPWM(); } syncPi(); while ( !mPisyncFinished ) { //qDebug("waiting "); qApp->processEvents(); } timer.start(); while ( timer.elapsed () < 2000 ) { qApp->processEvents(); } } else syncRemote( temp, false ); } } timer.start(); mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); while ( timer.elapsed () < 2000 ) { qApp->processEvents(); #ifndef _WIN32_ sleep (1); #endif } } } delete temp; return syncedProfiles; } void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) { QString question; if ( ask ) { question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; if ( QMessageBox::information( mParent, i18n("Sync"), question, i18n("Yes"), i18n("No"), 0, 0 ) != 0 ) return; } QString preCommand; QString localTempFile; QString postCommand; switch(mTargetApp) { case (KAPI): preCommand = prof->getPreSyncCommandAB(); postCommand = prof->getPostSyncCommandAB(); localTempFile = prof->getLocalTempFileAB(); break; case (KOPI): preCommand = prof->getPreSyncCommand(); postCommand = prof->getPostSyncCommand(); localTempFile = prof->getLocalTempFile(); break; case (PWMPI): preCommand = prof->getPreSyncCommandPWM(); postCommand = prof->getPostSyncCommandPWM(); localTempFile = prof->getLocalTempFilePWM(); break; default: qDebug("KSyncManager::syncRemote: invalid apptype selected"); break; } int fi; if ( (fi = preCommand.find("$PWD$")) > 0 ) { QString pwd = getPassword(); preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); } int maxlen = 30; if ( QApplication::desktop()->width() > 320 ) maxlen += 25; mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); int fileSize = 0; int result = system ( preCommand ); // 0 : okay // 256: no such file or dir // qDebug("Sync: Remote copy result(0 = okay): %d ",result ); if ( result != 0 ) { unsigned int len = maxlen; while ( len < preCommand.length() ) { preCommand.insert( len , "\n" ); len += maxlen +2; } question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; QMessageBox::information( mParent, i18n("Sync - ERROR"), question, i18n("Okay!")) ; mParent->topLevelWidget()->setCaption ("KDE-Pim"); return; } mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); if ( syncWithFile( localTempFile, true ) ) { if ( mWriteBackFile ) { int fi; if ( (fi = postCommand.find("$PWD$")) > 0 ) { QString pwd = getPassword(); postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); } mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); result = system ( postCommand ); qDebug("Sync:Writing back file result: %d ", result); if ( result != 0 ) { mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); return; } else { mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); } } } return; } -void KSyncManager::edit_pisync_options() +bool KSyncManager::edit_pisync_options() { QDialog dia( mParent, "dia", true ); dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); QVBoxLayout lay ( &dia ); lay.setSpacing( 5 ); lay.setMargin( 3 ); QLabel lab1 ( i18n("Password for remote access:"), &dia); lay.addWidget( &lab1 ); QLineEdit le1 (&dia ); lay.addWidget( &le1 ); QLabel lab2 ( i18n("Remote IP address:"), &dia); lay.addWidget( &lab2 ); QLineEdit le2 (&dia ); lay.addWidget( &le2 ); QLabel lab3 ( i18n("Remote port number:"), &dia); lay.addWidget( &lab3 ); QLineEdit le3 (&dia ); lay.addWidget( &le3 ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); le1.setText( mPassWordPiSync ); le2.setText( mActiveSyncIP ); le3.setText( mActiveSyncPort ); if ( dia.exec() ) { mPassWordPiSync = le1.text(); mActiveSyncPort = le3.text(); mActiveSyncIP = le2.text(); + return true; } - + return false; } -void KSyncManager::edit_sync_options() +bool KSyncManager::edit_sync_options() { QDialog dia( mParent, "dia", true ); dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); QVBoxLayout lay ( &dia ); lay.setSpacing( 2 ); lay.setMargin( 3 ); lay.addWidget(&gr); QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); //QRadioButton both( i18n("Take both on conflict"), &gr ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); switch ( mSyncAlgoPrefs ) { case 0: loc.setChecked( true); break; case 1: rem.setChecked( true ); break; case 2: newest.setChecked( true); break; case 3: ask.setChecked( true); break; case 4: f_loc.setChecked( true); break; case 5: f_rem.setChecked( true); break; case 6: // both.setChecked( true); break; default: break; } if ( dia.exec() ) { mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; + return true; } - - + return false; } QString KSyncManager::getPassword( ) { QString retfile = ""; QDialog dia ( mParent, "input-dialog", true ); QLineEdit lab ( &dia ); lab.setEchoMode( QLineEdit::Password ); QVBoxLayout lay( &dia ); lay.setMargin(7); lay.setSpacing(7); lay.addWidget( &lab); dia.setFixedSize( 230,50 ); dia.setCaption( i18n("Enter password") ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); dia.show(); int res = dia.exec(); if ( res ) retfile = lab.text(); dia.hide(); qApp->processEvents(); return retfile; } void KSyncManager::confSync() { static KSyncPrefsDialog* sp = 0; if ( ! sp ) { sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); } sp->usrReadConfig(); #ifndef DESKTOP_VERSION sp->showMaximized(); #else sp->show(); #endif sp->exec(); mSyncProfileNames = sp->getSyncProfileNames(); mLocalMachineName = sp->getLocalMachineName (); QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); } void KSyncManager::syncKDE() { emit save(); switch(mTargetApp) { case (KAPI): break; case (KOPI): { #ifdef DESKTOP_VERSION QString command = qApp->applicationDirPath () + "/kdecaldump"; #else QString command = "kdecaldump"; #endif if ( ! QFile::exists ( command ) ) command = "kdecaldump"; QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; system ( command.latin1()); if ( syncWithFile( fileName,true ) ) { if ( mWriteBackFile ) { command += " --read"; system ( command.latin1()); } } } break; case (PWMPI): break; default: qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); break; } } void KSyncManager::syncSharp() { if ( ! syncExternalApplication("sharp") ) qDebug("ERROR sync sharp "); } bool KSyncManager::syncExternalApplication(QString resource) { emit save(); if ( mAskForPreferences ) - edit_sync_options(); + if ( !edit_sync_options()) { + mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); + return false; + } qDebug("Sync extern %s", resource.latin1()); bool syncOK = mImplementation->syncExternal(this, resource); return syncOK; } void KSyncManager::syncPhone() { syncExternalApplication("phone"); } void KSyncManager::showProgressBar(int percentage, QString caption, int total) { if (!bar->isVisible()) { bar->setCaption (caption); bar->setTotalSteps ( total ) ; bar->show(); } bar->setProgress( percentage ); } void KSyncManager::hideProgressBar() { bar->hide(); } bool KSyncManager::isProgressBarCanceled() { return !bar->isVisible(); } QString KSyncManager::syncFileName() { QString fn = "tempfile"; switch(mTargetApp) { case (KAPI): fn = "tempsyncab.vcf"; break; case (KOPI): fn = "tempsynccal.ics"; break; case (PWMPI): fn = "tempsyncpw.pwm"; break; default: break; } #ifdef _WIN32_ return locateLocal( "tmp", fn ); #else return (QString( "/tmp/" )+ fn ); #endif } void KSyncManager::syncPi() { mPisyncFinished = false; qApp->processEvents(); if ( mAskForPreferences ) - edit_pisync_options(); + if ( !edit_pisync_options()) { + mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); + return; + } bool ok; Q_UINT16 port = mActiveSyncPort.toUInt(&ok); if ( ! ok ) { mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); return; } KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); commandSocket->readFile( syncFileName() ); } void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) { //enum { success, errorW, errorR, quiet }; if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); delete s; if ( state == KCommandSocket::errorR ) { KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); commandSocket->sendStop(); } mPisyncFinished = true; return; } else if ( state == KCommandSocket::errorW ) { mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); mPisyncFinished = true; } else if ( state == KCommandSocket::successR ) { QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); } else if ( state == KCommandSocket::successW ) { mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); mPisyncFinished = true; } delete s; } void KSyncManager::readFileFromSocket() { QString fileName = syncFileName(); mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); if ( ! syncWithFile( fileName , true ) ) { mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); mPisyncFinished = true; return; } KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); if ( mWriteBackFile ) commandSocket->writeFile( fileName ); else { commandSocket->sendStop(); mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); mPisyncFinished = true; } } KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) { mPassWord = pw; mSocket = 0; mSyncActionDialog = 0; blockRC = false; }; void KServerSocket::newConnection ( int socket ) { // qDebug("KServerSocket:New connection %d ", socket); if ( mSocket ) { qDebug("KServerSocket::newConnection Socket deleted! "); delete mSocket; mSocket = 0; } mSocket = new QSocket( this ); connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); mSocket->setSocket( socket ); } void KServerSocket::discardClient() { //qDebug(" KServerSocket::discardClient()"); if ( mSocket ) { delete mSocket; mSocket = 0; } //emit endConnect(); } void KServerSocket::readClient() { if ( blockRC ) return; if ( mSocket == 0 ) { qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); return; } //qDebug("KServerSocket::readClient()"); if ( mSocket->canReadLine() ) { QString line = mSocket->readLine(); //qDebug("KServerSocket readline: %s ", line.latin1()); QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); if ( tokens[0] == "GET" ) { if ( tokens[1] == mPassWord ) //emit sendFile( mSocket ); send_file(); else { KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); } } if ( tokens[0] == "PUT" ) { if ( tokens[1] == mPassWord ) { //emit getFile( mSocket ); blockRC = true; get_file(); } else { KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); } } if ( tokens[0] == "STOP" ) { //emit endConnect(); end_connect(); } } } void KServerSocket::end_connect() { delete mSyncActionDialog; mSyncActionDialog = 0; } void KServerSocket::send_file() { //qDebug("MainWindow::sendFile(QSocket* s) "); if ( mSyncActionDialog ) delete mSyncActionDialog; mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); mSyncActionDialog->setCaption(i18n("Received sync request")); QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); lay->addWidget( label); lay->setMargin(7); lay->setSpacing(7); mSyncActionDialog->setFixedSize( 230, 120); mSyncActionDialog->show(); mSyncActionDialog->raise(); emit request_file(); qApp->processEvents(); QString fileName = mFileName; QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { delete mSyncActionDialog; mSyncActionDialog = 0; qDebug("KSS::error open file "); mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); return ; } mSyncActionDialog->setCaption( i18n("Sending file...") ); QTextStream ts( &file ); ts.setEncoding( QTextStream::Latin1 ); QTextStream os( mSocket ); os.setEncoding( QTextStream::Latin1 ); while ( ! ts.atEnd() ) { os << ts.readLine() << "\r\n"; } //os << ts.read(); file.close(); mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); } void KServerSocket::get_file() { mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); piTime.start(); piFileString = ""; QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); } void KServerSocket::readBackFileFromSocket() { //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); while ( mSocket->canReadLine () ) { piTime.restart(); QString line = mSocket->readLine (); piFileString += line; //qDebug("readline: %s ", line.latin1()); mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); } if ( piTime.elapsed () < 3000 ) { // wait for more //qDebug("waitformore "); QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); return; } QString fileName = mFileName; QFile file ( fileName ); if (!file.open( IO_WriteOnly ) ) { delete mSyncActionDialog; mSyncActionDialog = 0; qDebug("KSS:Error open read back file "); piFileString = ""; emit file_received( false ); blockRC = false; return ; } // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); QTextStream ts ( &file ); ts.setEncoding( QTextStream::Latin1 ); mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); ts << piFileString; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); file.close(); + piFileString = ""; + emit file_received( true ); delete mSyncActionDialog; mSyncActionDialog = 0; - piFileString = ""; blockRC = false; - emit file_received( true ); } KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) { mPassWord = password; mSocket = 0; mPort = port; mHost = host; mRetVal = quiet; mTimerSocket = new QTimer ( this ); connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); } void KCommandSocket::readFile( QString fn ) { if ( !mSocket ) { mSocket = new QSocket( this ); connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); } mFileString = ""; mFileName = fn; mFirst = true; mSocket->connectToHost( mHost, mPort ); QTextStream os( mSocket ); os.setEncoding( QTextStream::Latin1 ); os << "GET " << mPassWord << "\r\n"; - mTimerSocket->start( 10000 ); + mTimerSocket->start( 20000 ); } void KCommandSocket::writeFile( QString fileName ) { if ( !mSocket ) { mSocket = new QSocket( this ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); } mFileName = fileName ; mSocket->connectToHost( mHost, mPort ); } void KCommandSocket::writeFileToSocket() { QFile file2( mFileName ); if (!file2.open( IO_ReadOnly ) ) { mRetVal= errorW; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); return ; } QTextStream ts2( &file2 ); ts2.setEncoding( QTextStream::Latin1 ); QTextStream os2( mSocket ); os2.setEncoding( QTextStream::Latin1 ); os2 << "PUT " << mPassWord << "\r\n";; while ( ! ts2.atEnd() ) { os2 << ts2.readLine() << "\r\n"; } mRetVal= successW; file2.close(); mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); } void KCommandSocket::sendStop() { if ( !mSocket ) { mSocket = new QSocket( this ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); } mSocket->connectToHost( mHost, mPort ); QTextStream os2( mSocket ); os2.setEncoding( QTextStream::Latin1 ); os2 << "STOP\r\n"; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); } void KCommandSocket::startReadFileFromSocket() { if ( ! mFirst ) return; mFirst = false; mTimerSocket->stop(); mFileString = ""; mTime.start(); QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); } void KCommandSocket::readFileFromSocket() { //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); while ( mSocket->canReadLine () ) { mTime.restart(); QString line = mSocket->readLine (); mFileString += line; //qDebug("readline: %s ", line.latin1()); } if ( mTime.elapsed () < 3000 ) { // wait for more //qDebug("waitformore "); QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); return; } QString fileName = mFileName; QFile file ( fileName ); if (!file.open( IO_WriteOnly ) ) { mFileString = ""; mRetVal = errorR; qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); deleteSocket(); return ; } // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); QTextStream ts ( &file ); ts.setEncoding( QTextStream::Latin1 ); ts << mFileString; file.close(); mFileString = ""; mRetVal = successR; mSocket->close(); // if state is not idle, deleteSocket(); is called via // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); if ( mSocket->state() == QSocket::Idle ) deleteSocket(); } void KCommandSocket::deleteSocket() { //qDebug("KCommandSocket::deleteSocket() "); if ( mTimerSocket->isActive () ) { mTimerSocket->stop(); mRetVal = errorTO; qDebug("Connection to remote host timed out"); if ( mSocket ) { mSocket->close(); //if ( mSocket->state() == QSocket::Idle ) // deleteSocket(); delete mSocket; mSocket = 0; } KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); emit commandFinished( this, mRetVal ); return; } //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); if ( mSocket) delete mSocket; mSocket = 0; emit commandFinished( this, mRetVal ); } diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 7b9c499..4a610fa 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h @@ -1,211 +1,211 @@ /* This file is part of KDE-Pim/Pi. Copyright (c) 2004 Ulf Schenk This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. $Id$ */ #ifndef _KSYNCMANAGER_H #define _KSYNCMANAGER_H #include <qobject.h> #include <qstring.h> #include <qsocket.h> #include <qdatetime.h> #include <qserversocket.h> #include <qtextstream.h> #include <qregexp.h> class QPopupMenu; class KSyncProfile; class KPimPrefs; class QWidget; class KSyncManager; class KSyncInterface; class QProgressBar; class KServerSocket : public QServerSocket { Q_OBJECT public: KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); void newConnection ( int socket ) ; void setFileName( QString fn ) {mFileName = fn;}; signals: void file_received( bool ); void request_file(); void saveFile(); void endConnect(); private slots: void discardClient(); void readClient(); void readBackFileFromSocket(); private : bool blockRC; void send_file(); void get_file(); void end_connect(); QDialog* mSyncActionDialog; QSocket* mSocket; QString mPassWord; QString mFileName; QTime piTime; QString piFileString; }; class KCommandSocket : public QObject { Q_OBJECT public: enum state { successR, errorR, successW, errorW, errorTO, quiet }; KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); void readFile( QString ); void writeFile( QString ); void sendStop(); signals: void commandFinished( KCommandSocket*, int ); private slots: void startReadFileFromSocket(); void readFileFromSocket(); void deleteSocket(); void writeFileToSocket(); private : QSocket* mSocket; QString mPassWord; Q_UINT16 mPort; QString mHost; QString mFileName; QTimer* mTimerSocket; int mRetVal; QTime mTime; QString mFileString; bool mFirst; }; class KSyncManager : public QObject { Q_OBJECT public: enum TargetApp { KOPI = 0, KAPI = 1, PWMPI = 2 }; KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); ~KSyncManager() ; void multiSync( bool askforPrefs ); bool blockSave() { return mBlockSaveFlag; } void setBlockSave(bool sa) { mBlockSaveFlag = sa; } void setDefaultFileName( QString s) { mDefFileName = s ;} QString defaultFileName() { return mDefFileName ;} QString syncFileName(); void enableQuick( bool ask = true); QString getCurrentSyncDevice() { return mCurrentSyncDevice; } QString getCurrentSyncName() { return mCurrentSyncName; } void showProgressBar(int percentage, QString caption = QString::null, int total=100); void hideProgressBar(); bool isProgressBarCanceled(); // sync stuff QString mLocalMachineName; QStringList mExternSyncProfiles; QStringList mSyncProfileNames; bool mAskForPreferences; bool mShowSyncSummary; bool mIsKapiFile; bool mWriteBackExistingOnly; int mSyncAlgoPrefs; bool mWriteBackFile; int mWriteBackInFuture; QString mPhoneDevice; QString mPhoneConnection; QString mPhoneModel; QString mPassWordPiSync; QString mActiveSyncPort; QString mActiveSyncIP ; signals: void save(); void request_file(); void getFile( bool ); public slots: void slotSyncMenu( int ); void deleteCommandSocket(KCommandSocket*s, int state); void readFileFromSocket(); void fillSyncMenu(); private: void syncPi(); KServerSocket * mServerSocket; KPimPrefs* mPrefs; QString mDefFileName; QString mCurrentSyncDevice; QString mCurrentSyncName; void quickSyncLocalFile(); bool syncWithFile( QString fn , bool quick ); void syncLocalFile(); void syncPhone(); void syncSharp(); void syncKDE(); bool syncExternalApplication(QString); int mCurrentSyncProfile ; void syncRemote( KSyncProfile* prof, bool ask = true); - void edit_sync_options(); - void edit_pisync_options(); + bool edit_sync_options(); + bool edit_pisync_options(); int ringSync(); QString getPassword( ); bool mPisyncFinished; bool mBlockSaveFlag; QWidget* mParent; KSyncInterface* mImplementation; TargetApp mTargetApp; QPopupMenu* mSyncMenu; QProgressBar* bar; private slots: void confSync(); }; class KSyncInterface { public : virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; virtual bool syncExternal(KSyncManager* manager, QString resource) { // empty implementation, because some syncable applications do not // have an external(sharpdtm) syncmode, like pwmanager. return false; } }; #endif |