summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-29 09:03:54 (UTC)
committer zautrix <zautrix>2004-10-29 09:03:54 (UTC)
commit6500d6ebb080f1de58fe676aa0a730d47fcf64f5 (patch) (unidiff)
tree41841e05bf1e6b88e6e55f42011dce5f6bed85b4
parent41e3625b8c38ff45e70b59416a519d59a5f4d937 (diff)
downloadkdepimpi-6500d6ebb080f1de58fe676aa0a730d47fcf64f5.zip
kdepimpi-6500d6ebb080f1de58fe676aa0a730d47fcf64f5.tar.gz
kdepimpi-6500d6ebb080f1de58fe676aa0a730d47fcf64f5.tar.bz2
sync fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile619
-rw-r--r--kabc/addressbook.cpp26
-rw-r--r--kabc/addressee.cpp25
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp4
-rw-r--r--kaddressbook/kabcore.cpp25
-rw-r--r--korganizer/calendarview.cpp1
-rw-r--r--libkdepim/ksyncmanager.cpp4
7 files changed, 301 insertions, 403 deletions
diff --git a/Makefile b/Makefile
index 467710f..e6f955c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,368 +1,253 @@
1export KDEPIMDIR = $(shell pwd) 1#############################################################################
2 2# Makefile for building: kdepim-desktop
3export KDEPIM_VERSION=$(shell sed -e 's/.*\"\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/' < version) 3# Generated by qmake (1.07a) (Qt 3.3.1) on: Thu Oct 28 23:52:22 2004
4 4# Project: kdepim-desktop.pro
5ifeq ($(PLATFORM) , zaurus) 5# Template: subdirs
6 BUILD_NO_LDAP_PLUGIN=1 6# Command: $(QMAKE) -o Makefile kdepim-desktop.pro
7endif 7#############################################################################
8 8
9ifneq ($(PLATFORM) , zaurus) 9 MAKEFILE =Makefile
10 BUILD_NO_SHARP_PLUGIN=1 10 QMAKE =qmake
11endif 11DEL_FILE = rm -f
12 12CHK_DIR_EXISTS= test -d
13#opie plugin is deprecated. The qtopia plugin handles the task from now on. 13MKDIR = mkdir -p
14BUILD_NO_OPIE_PLUGIN=1 14 SUBTARGETS = \
15 15 sub-gammu-emb-common \
16SUBDIRS_MICROKDE = \ 16 sub-gammu-emb-gammu \
17 libical/src/libical \ 17 sub-libical \
18 libical/src/libicalss \ 18 sub-libkcal \
19 qtcompat \ 19 sub-microkde \
20 microkde \ 20 sub-libkdepim \
21 libkcal \ 21 sub-kabc \
22 libkdepim \ 22 sub-korganizer \
23 kabc \ 23 sub-kaddressbook \
24 kabc/formats/binary \ 24 sub-kabc-plugins-file \
25 kabc/plugins/file \ 25 sub-kabc-plugins-dir \
26 kabc/plugins/dir \ 26 sub-kabc-plugins-file \
27 korganizer \ 27 sub-kabc-plugins-qtopia \
28 kalarmd \ 28 sub-pwmanager-libcrypt-cipher \
29 kaddressbook 29 sub-pwmanager-libcrypt-error \
30 30 sub-pwmanager-libcrypt-mpi \
31SUBDIRS_QTOPIA_PLUGIN = \ 31 sub-pwmanager-libcrypt-zlib \
32 kabc/plugins/qtopia 32 sub-pwmanager-pwmanager
33 33
34SUBDIRS_OPIE_PLUGIN = \ 34first: all
35 kabc/plugins/opie 35
36 36all: Makefile $(SUBTARGETS)
37SUBDIRS_SHARP_PLUGIN = \ 37
38 kabc/plugins/sharpdtm 38gammu/emb/common/$(MAKEFILE):
39 39 @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common"
40SUBDIRS_LDAP_PLUGIN = \ 40 cd gammu/emb/common && $(QMAKE) common.pro -o $(MAKEFILE)
41 kabc/plugins/ldap 41sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE
42 42 cd gammu/emb/common && $(MAKE) -f $(MAKEFILE)
43SUBDIRS_MICROMAIL = \ 43
44 kmicromail/libetpan \ 44gammu/emb/gammu/$(MAKEFILE):
45 kmicromail/libmailwrapper \ 45 @$(CHK_DIR_EXISTS) "gammu/emb/gammu" || $(MKDIR) "gammu/emb/gammu"
46 kmicromail 46 cd gammu/emb/gammu && $(QMAKE) gammu.pro -o $(MAKEFILE)
47 47sub-gammu-emb-gammu: gammu/emb/gammu/$(MAKEFILE) FORCE
48SUBDIRS_GAMMU = \ 48 cd gammu/emb/gammu && $(MAKE) -f $(MAKEFILE)
49 gammu/emb/common \ 49
50 gammu/emb/gammu 50libical/$(MAKEFILE):
51 51 @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical"
52SUBDIRS_PWMANAGER = \ 52 cd libical && $(QMAKE) libical.pro -o $(MAKEFILE)
53 pwmanager/libcrypt/mpi \ 53sub-libical: libical/$(MAKEFILE) FORCE
54 pwmanager/libcrypt/error \ 54 cd libical && $(MAKE) -f $(MAKEFILE)
55 pwmanager/libcrypt/cipher \ 55
56 pwmanager/libcrypt/zlib \ 56libkcal/$(MAKEFILE):
57 pwmanager/pwmanager 57 @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal"
58 58 cd libkcal && $(QMAKE) libkcal.pro -o $(MAKEFILE)
59SUBDIRS = \ 59sub-libkcal: libkcal/$(MAKEFILE) FORCE
60 $(SUBDIRS_MICROKDE) \ 60 cd libkcal && $(MAKE) -f $(MAKEFILE)
61 $(SUBDIRS_QTOPIA_PLUGIN) \ 61
62 $(SUBDIRS_OPIE_PLUGIN) \ 62microkde/$(MAKEFILE):
63 $(SUBDIRS_SHARP_PLUGIN) \ 63 @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde"
64 $(SUBDIRS_LDAP_PLUGIN) \ 64 cd microkde && $(QMAKE) microkde.pro -o $(MAKEFILE)
65 $(SUBDIRS_MICROMAIL) \ 65sub-microkde: microkde/$(MAKEFILE) FORCE
66 $(SUBDIRS_GAMMU) \ 66 cd microkde && $(MAKE) -f $(MAKEFILE)
67 $(SUBDIRS_PWMANAGER) 67
68 68libkdepim/$(MAKEFILE):
69 69 @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim"
70all: build_microkde \ 70 cd libkdepim && $(QMAKE) libkdepim.pro -o $(MAKEFILE)
71 build_qtopia_plugin \ 71sub-libkdepim: libkdepim/$(MAKEFILE) FORCE
72 build_opie_plugin \ 72 cd libkdepim && $(MAKE) -f $(MAKEFILE)
73 build_sharp_plugin \ 73
74 build_ldap_plugin \ 74kabc/$(MAKEFILE):
75 build_micromail \ 75 @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc"
76 build_gammu \ 76 cd kabc && $(QMAKE) kabc.pro -o $(MAKEFILE)
77 build_pwmanager 77sub-kabc: kabc/$(MAKEFILE) FORCE
78 78 cd kabc && $(MAKE) -f $(MAKEFILE)
79 79
80build_microkde: variable_test tmake 80korganizer/$(MAKEFILE):
81 for i in $(SUBDIRS_MICROKDE); do pushd $$i; \ 81 @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer"
82 make -f Makefile$(PLATFORM) || exit 1; popd; \ 82 cd korganizer && $(QMAKE) korganizer.pro -o $(MAKEFILE)
83 done 83sub-korganizer: korganizer/$(MAKEFILE) FORCE
84 84 cd korganizer && $(MAKE) -f $(MAKEFILE)
85build_qtopia_plugin: build_microkde 85
86 ifdef BUILD_NO_QTOPIA_PLUGIN 86kaddressbook/$(MAKEFILE):
87 @echo == qtopia plugin not build. 87 @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook"
88 else 88 cd kaddressbook && $(QMAKE) kaddressbook.pro -o $(MAKEFILE)
89 for i in $(SUBDIRS_QTOPIA_PLUGIN); do pushd $$i; \ 89sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE
90 make -f Makefile$(PLATFORM) || exit 1; popd; \ 90 cd kaddressbook && $(MAKE) -f $(MAKEFILE)
91 done 91
92 endif 92kabc/plugins/file/$(MAKEFILE):
93 93 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file"
94build_opie_plugin: build_microkde 94 cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE)
95 ifdef BUILD_NO_OPIE_PLUGIN 95sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE
96 @echo == opie plugin not build. 96 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE)
97 else 97
98 for i in $(SUBDIRS_OPIE_PLUGIN); do pushd $$i; \ 98kabc/plugins/dir/$(MAKEFILE):
99 make -f Makefile$(PLATFORM) || exit 1; popd; \ 99 @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir"
100 done 100 cd kabc/plugins/dir && $(QMAKE) dir.pro -o $(MAKEFILE)
101 endif 101sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE
102 102 cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE)
103build_sharp_plugin: build_microkde 103
104 ifdef BUILD_NO_SHARP_PLUGIN 104kabc/plugins/file/$(MAKEFILE):
105 @echo == ldap plugin not build. 105 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file"
106 else 106 cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE)
107 for i in $(SUBDIRS_SHARP_PLUGIN); do pushd $$i; \ 107sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE
108 make -f Makefile$(PLATFORM) || exit 1; popd; \ 108 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE)
109 done 109
110 endif 110kabc/plugins/qtopia/$(MAKEFILE):
111 111 @$(CHK_DIR_EXISTS) "kabc/plugins/qtopia" || $(MKDIR) "kabc/plugins/qtopia"
112build_ldap_plugin: build_microkde 112 cd kabc/plugins/qtopia && $(QMAKE) qtopia.pro -o $(MAKEFILE)
113 ifdef BUILD_NO_LDAP_PLUGIN 113sub-kabc-plugins-qtopia: kabc/plugins/qtopia/$(MAKEFILE) FORCE
114 @echo == ldap plugin not build. 114 cd kabc/plugins/qtopia && $(MAKE) -f $(MAKEFILE)
115 else 115
116 for i in $(SUBDIRS_LDAP_PLUGIN); do pushd $$i; \ 116pwmanager/libcrypt/cipher/$(MAKEFILE):
117 make -f Makefile$(PLATFORM) || exit 1; popd; \ 117 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/cipher" || $(MKDIR) "pwmanager/libcrypt/cipher"
118 done 118 cd pwmanager/libcrypt/cipher && $(QMAKE) cipher.pro -o $(MAKEFILE)
119 endif 119sub-pwmanager-libcrypt-cipher: pwmanager/libcrypt/cipher/$(MAKEFILE) FORCE
120 120 cd pwmanager/libcrypt/cipher && $(MAKE) -f $(MAKEFILE)
121 121
122build_micromail: build_microkde 122pwmanager/libcrypt/error/$(MAKEFILE):
123 ifdef BUILD_NO_MICROMAIL 123 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/error" || $(MKDIR) "pwmanager/libcrypt/error"
124 @echo == kmicromail not build. 124 cd pwmanager/libcrypt/error && $(QMAKE) error.pro -o $(MAKEFILE)
125 else 125sub-pwmanager-libcrypt-error: pwmanager/libcrypt/error/$(MAKEFILE) FORCE
126 for i in $(SUBDIRS_MICROMAIL); do pushd $$i; \ 126 cd pwmanager/libcrypt/error && $(MAKE) -f $(MAKEFILE)
127 make -f Makefile$(PLATFORM) || exit 1; popd; \ 127
128 done 128pwmanager/libcrypt/mpi/$(MAKEFILE):
129 endif 129 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/mpi" || $(MKDIR) "pwmanager/libcrypt/mpi"
130 130 cd pwmanager/libcrypt/mpi && $(QMAKE) mpi.pro -o $(MAKEFILE)
131build_gammu: variable_test tmake 131sub-pwmanager-libcrypt-mpi: pwmanager/libcrypt/mpi/$(MAKEFILE) FORCE
132 ifdef BUILD_NO_GAMMU 132 cd pwmanager/libcrypt/mpi && $(MAKE) -f $(MAKEFILE)
133 @echo == gammu not build. 133
134 else 134pwmanager/libcrypt/zlib/$(MAKEFILE):
135 for i in $(SUBDIRS_GAMMU); do pushd $$i; \ 135 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/zlib" || $(MKDIR) "pwmanager/libcrypt/zlib"
136 make -f Makefile$(PLATFORM) || exit 1; popd; \ 136 cd pwmanager/libcrypt/zlib && $(QMAKE) zlib.pro -o $(MAKEFILE)
137 done 137sub-pwmanager-libcrypt-zlib: pwmanager/libcrypt/zlib/$(MAKEFILE) FORCE
138 endif 138 cd pwmanager/libcrypt/zlib && $(MAKE) -f $(MAKEFILE)
139 139
140build_pwmanager: build_microkde 140pwmanager/pwmanager/$(MAKEFILE):
141 ifdef BUILD_NO_PWMANAGER 141 @$(CHK_DIR_EXISTS) "pwmanager/pwmanager" || $(MKDIR) "pwmanager/pwmanager"
142 @echo == pwmanager not build. 142 cd pwmanager/pwmanager && $(QMAKE) pwmanager.pro -o $(MAKEFILE)
143 else 143sub-pwmanager-pwmanager: pwmanager/pwmanager/$(MAKEFILE) FORCE
144 for i in $(SUBDIRS_PWMANAGER); do pushd $$i; \ 144 cd pwmanager/pwmanager && $(MAKE) -f $(MAKEFILE)
145 make -f Makefile$(PLATFORM) || exit 1; popd; \ 145
146 done 146Makefile: kdepim-desktop.pro /usr/lib/qt3/mkspecs/default/qmake.conf
147 endif 147 $(QMAKE) -o Makefile kdepim-desktop.pro
148 148qmake: qmake_all
149 149 @$(QMAKE) -o Makefile kdepim-desktop.pro
150variable_info: 150
151 @echo -------------------------------------- 151all: $(SUBTARGETS)
152 @echo KDEPIM buildsystem, variableinfo... 152qmake_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) kabc/plugins/file/$(MAKEFILE) kabc/plugins/qtopia/$(MAKEFILE) pwmanager/libcrypt/cipher/$(MAKEFILE) pwmanager/libcrypt/error/$(MAKEFILE) pwmanager/libcrypt/mpi/$(MAKEFILE) pwmanager/libcrypt/zlib/$(MAKEFILE) pwmanager/pwmanager/$(MAKEFILE)
153 @echo KDEPIMDIR=$(KDEPIMDIR) 153 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
154 @echo QTDIR=$(QTDIR) 154 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
155 @echo QPEDIR=$(QPEDIR) 155 ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
156 @echo OPIEDIR=$(OPIEDIR) 156 ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
157 @echo PLATFORM=$(PLATFORM) 157 ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
158 @echo RELEASE_DEBUG=$(RELEASE_DEBUG) 158 ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
159 @echo BUILD_NO_MICROMAIL=$(BUILD_NO_MICROMAIL) 159 ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
160 @echo BUILD_NO_LDAP_PLUGIN=$(BUILD_NO_LDAP_PLUGIN) 160 ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
161 @echo BUILD_NO_OPIE_PLUGIN=$(BUILD_NO_OPIE_PLUGIN) 161 ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
162 @echo BUILD_NO_QTOPIA_PLUGIN=$(BUILD_NO_QTOPIA_PLUGIN) 162 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
163 @echo BUILD_NO_SHARP_PLUGIN=$(BUILD_NO_SHARP_PLUGIN) 163 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
164 ifndef BUILD_NO_SHARP_PLUGIN 164 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
165 @echo SHARPDTMSDK=$(SHARPDTMSDK) 165 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
166 endif 166 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
167 @echo BUILD_NO_GAMMU=$(BUILD_NO_GAMMU) 167 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
168 @echo BUILD_NO_PWMANAGER=$(BUILD_NO_PWMANAGER) 168 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
169 @echo -------------------------------------- 169 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
170 170 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
171variable_test: variable_info 171clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE
172 @echo KDEPIM buildsystem, variablecheck... 172 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; ) || true
173 ifndef KDEPIMDIR 173 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; ) || true
174 @echo KDEPIMDIR is not defined. 174 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true
175 $(error KDEPIMDIR is not defined) 175 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true
176 endif 176 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true
177 ifndef PLATFORM 177 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true
178 @echo PLATFORM is not defined. 178 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true
179 $(error PLATFORM is not defined) 179 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true
180 endif 180 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true
181 ifdef BUILD_NO_LDAP_PLUGIN 181 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true
182 @echo LDAP PLUGIN will not be build, because BUILD_NO_LDAP_PLUGIN is set to $(BUILD_NO_LDAP_PLUGIN) 182 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true
183 endif 183 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true
184 ifdef BUILD_NO_OPIE_PLUGIN 184 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) $@; ) || true
185 @echo OPIE PLUGIN will not be build, because BUILD_NO_OPIE_PLUGIN is set to $(BUILD_NO_OPIE_PLUGIN) 185 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) $@; ) || true
186 endif 186 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) $@; ) || true
187 ifdef BUILD_NO_QTOPIA_PLUGIN 187 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) $@; ) || true
188 @echo QTOPIA PLUGIN will not be build, because BUILD_NO__QTOPIA_PLUGIN is set to $(BUILD_NO__QTOPIA_PLUGIN) 188 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) $@; ) || true
189 endif 189 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) $@; ) || true
190 ifdef BUILD_NO_MICROMAIL 190uninstall_subdirs: qmake_all FORCE
191 @echo MICROMAIL will not be build, because BUILD_NO_MICROMAIL is set to $(BUILD_NO_MICROMAIL) 191 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
192 endif 192 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
193 ifdef BUILD_NO_SHARP_PLUGIN 193 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
194 @echo SHARP PLUGIN will not be build, because BUILD_NO_SHARP_PLUGIN is set to $(BUILD_NO_SHARP_PLUGIN) 194 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
195 else 195 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
196 ifndef SHARPDTMSDK 196 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
197 @echo SHARP PLUGIN can not be build, because SHARPDTMSDK is set to $(SHARPDTMSDK) 197 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
198 $(error SHARPDTMSDK is not defined) 198 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
199 endif 199 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
200 endif 200 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
201 ifdef BUILD_NO_GAMMU 201 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
202 @echo GAMMU will not be build, because BUILD_NO_GAMMU is set to $(BUILD_NO_GAMMU) 202 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
203 endif 203 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
204 ifdef BUILD_NO_PWMANAGER 204 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
205 @echo PWMANAGER will not be build, because BUILD_NO_PWMANAGER is set to $(BUILD_NO_PWMANAGER) 205 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
206 endif 206 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
207 @echo -------------------------------------- 207 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
208 208 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
209 209install_subdirs: qmake_all FORCE
210objects: 210 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) install; ) || true
211 for i in $(SUBDIRS); do mkdir -p $$i/obj/$(PLATFORM); done 211 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) install; ) || true
212 for i in $(SUBDIRS); do mkdir -p $$i/moc/$(PLATFORM); done 212 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true
213 mkdir -p libical/lib/$(PLATFORM) 213 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true
214 mkdir -p pwmanager/libcrypt/$(PLATFORM) 214 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true
215 215 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true
216clean: 216 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true
217 rm -rf libical/lib/$(PLATFORM)/*; 217 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true
218 rm -rf pwmanager/libcrypt/$(PLATFORM)/*; 218 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true
219 for i in $(SUBDIRS); do pushd $$i; make clean; rm -f *~;\ 219 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true
220 rm -f obj/$(PLATFORM)/*; rm -f moc/$(PLATFORM)/*; rm Makefile$(PLATFORM); popd; \ 220 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true
221 done 221 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true
222 222 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) install; ) || true
223install: 223 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) install; ) || true
224 224 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) install; ) || true
225 cd bin/kdepim; make install 225 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) install; ) || true
226 cp -r Pim $(QPEDIR)/apps 226 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) install; ) || true
227 cp db2file/db2file $(QPEDIR)/bin/db2file 227 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) install; ) || true
228 cp korganizer/korganizer.desktop $(QPEDIR)/apps/Pim/korganizer.desktop 228distclean: qmake_all FORCE
229 cp kaddressbook/kaddressbook.desktop $(QPEDIR)/apps/Pim/kaddressbook.desktop 229 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
230 cp kmicromail/kmicromail.desktop $(QPEDIR)/apps/Pim/kopiemail.desktop 230 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
231 cp pwmanager/pwmanager/pwmanager.desktop $(QPEDIR)/apps/Pim/pwmanager.desktop 231 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
232 232 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
233dist: 233 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
234 @echo Dont forget to do "make install" before "make dist" 234 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
235 rm -f *arm.ipk 235 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
236 rm -f *~ 236 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
237 cd ..; tar czf kdepimpi-$(KDEPIM_VERSION).tar.gz --exclude=obj --exclude=moc --exclude=CVS --exclude=Makefilezaurus --exclude=Makefileqtopia kdepim 237 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
238 mkipks kmicrokdelibs.control 238 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
239 mkipks korganizer.control 239 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
240 mkipks kaddressbook.control 240 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
241 ifndef BUILD_NO_MICROMAIL 241 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
242 mkipks kopiemail.control 242 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
243 endif 243 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
244 ifndef BUILD_NO_SHARP_PLUGIN 244 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
245 mkipks ksharpPIM-DTMaccess.control 245 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
246 endif 246 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
247 mkipks korganizer-alarm.control 247
248 ifndef BUILD_NO_GAMMU 248install: install_subdirs
249 mkipks kmobilephoneaccess.control 249
250 endif 250uninstall: uninstall_subdirs
251 ifndef BUILD_NO_PWMANAGER 251
252 mkipks pwmanager.control 252FORCE:
253 endif
254 mkipks pimTABicon.control
255
256tmake: objects \
257 qtcompat/Makefile$(PLATFORM) \
258 microkde/Makefile$(PLATFORM) \
259 libkcal/Makefile$(PLATFORM) \
260 libkdepim/Makefile$(PLATFORM) \
261 korganizer/Makefile$(PLATFORM) \
262 kalarmd/Makefile$(PLATFORM) \
263 libical/src/libical/Makefile$(PLATFORM) \
264 libical/src/libicalss/Makefile$(PLATFORM) \
265 kabc/Makefile$(PLATFORM) \
266 kabc/formats/binary/Makefile$(PLATFORM) \
267 kabc/plugins/file/Makefile$(PLATFORM) \
268 kabc/plugins/dir/Makefile$(PLATFORM) \
269 kabc/plugins/ldap/Makefile$(PLATFORM) \
270 kabc/plugins/opie/Makefile$(PLATFORM) \
271 kabc/plugins/qtopia/Makefile$(PLATFORM) \
272 kabc/plugins/sharpdtm/Makefile$(PLATFORM) \
273 kaddressbook/Makefile$(PLATFORM) \
274 kmicromail/Makefile$(PLATFORM) \
275 kmicromail/libetpan/Makefile$(PLATFORM) \
276 kmicromail/libmailwrapper/Makefile$(PLATFORM) \
277 gammu/emb/common/Makefile$(PLATFORM) \
278 gammu/emb/gammu/Makefile$(PLATFORM) \
279 pwmanager/pwmanager/Makefile$(PLATFORM) \
280 pwmanager/libcrypt/mpi/Makefile$(PLATFORM) \
281 pwmanager/libcrypt/error/Makefile$(PLATFORM) \
282 pwmanager/libcrypt/cipher/Makefile$(PLATFORM) \
283 pwmanager/libcrypt/zlib/Makefile$(PLATFORM)
284
285qtcompat/Makefile$(PLATFORM): qtcompat/qtcompat.pro
286 cd qtcompat; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" qtcompat.pro -o Makefile$(PLATFORM)
287
288microkde/Makefile$(PLATFORM): microkde/microkdeE.pro
289 cd microkde; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" microkdeE.pro -o Makefile$(PLATFORM)
290
291libkcal/Makefile$(PLATFORM): libkcal/libkcalE.pro
292 cd libkcal; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libkcalE.pro -o Makefile$(PLATFORM)
293
294
295libkdepim/Makefile$(PLATFORM): libkdepim/libkdepimE.pro
296 cd libkdepim; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libkdepimE.pro -o Makefile$(PLATFORM)
297
298kalarmd/Makefile$(PLATFORM): kalarmd/kalarmdE.pro
299 cd kalarmd; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kalarmdE.pro -o Makefile$(PLATFORM)
300
301korganizer/Makefile$(PLATFORM): korganizer/korganizerE.pro
302 cd korganizer; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" korganizerE.pro -o Makefile$(PLATFORM)
303
304libical/src/libical/Makefile$(PLATFORM): libical/src/libical/libicalE.pro
305 cd libical/src/libical; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libicalE.pro -o Makefile$(PLATFORM)
306
307libical/src/libicalss/Makefile$(PLATFORM): libical/src/libicalss/libicalssE.pro
308 cd libical/src/libicalss; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libicalssE.pro -o Makefile$(PLATFORM)
309
310kabc/Makefile$(PLATFORM): kabc/kabcE.pro
311 cd kabc; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kabcE.pro -o Makefile$(PLATFORM)
312
313kabc/formats/binary/Makefile$(PLATFORM): kabc/formats/binary/kabcformat_binaryE.pro
314 cd kabc/formats/binary; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kabcformat_binaryE.pro -o Makefile$(PLATFORM)
315
316kabc/plugins/file/Makefile$(PLATFORM): kabc/plugins/file/fileE.pro
317 cd kabc/plugins/file; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" fileE.pro -o Makefile$(PLATFORM)
318
319kabc/plugins/dir/Makefile$(PLATFORM): kabc/plugins/dir/dirE.pro
320 cd kabc/plugins/dir; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" dirE.pro -o Makefile$(PLATFORM)
321
322kabc/plugins/ldap/Makefile$(PLATFORM): kabc/plugins/ldap/ldapE.pro
323 cd kabc/plugins/ldap; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" ldapE.pro -o Makefile$(PLATFORM)
324
325kabc/plugins/opie/Makefile$(PLATFORM): kabc/plugins/opie/opieE.pro
326 cd kabc/plugins/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" opieE.pro -o Makefile$(PLATFORM)
327
328kabc/plugins/qtopia/Makefile$(PLATFORM): kabc/plugins/qtopia/qtopiaE.pro
329 cd kabc/plugins/qtopia; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" qtopiaE.pro -o Makefile$(PLATFORM)
330
331kabc/plugins/sharpdtm/Makefile$(PLATFORM): kabc/plugins/sharpdtm/sharpdtmE.pro
332 cd kabc/plugins/sharpdtm; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" sharpdtmE.pro -o Makefile$(PLATFORM)
333
334kaddressbook/Makefile$(PLATFORM): kaddressbook/kaddressbookE.pro
335 cd kaddressbook; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kaddressbookE.pro -o Makefile$(PLATFORM)
336
337kmicromail/Makefile$(PLATFORM): kmicromail/kmicromailE.pro
338 cd kmicromail; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kmicromailE.pro -o Makefile$(PLATFORM)
339
340kmicromail/libetpan/Makefile$(PLATFORM): kmicromail/libetpan/libetpanE.pro
341 cd kmicromail/libetpan; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libetpanE.pro -o Makefile$(PLATFORM)
342
343kmicromail/libmailwrapper/Makefile$(PLATFORM): kmicromail/libmailwrapper/libmailwrapperE.pro
344 cd kmicromail/libmailwrapper; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libmailwrapperE.pro -o Makefile$(PLATFORM)
345
346gammu/emb/common/Makefile$(PLATFORM): gammu/emb/common/commonE.pro
347 cd gammu/emb/common; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" commonE.pro -o Makefile$(PLATFORM)
348
349gammu/emb/gammu/Makefile$(PLATFORM): gammu/emb/gammu/gammuE.pro
350 cd gammu/emb/gammu; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" gammuE.pro -o Makefile$(PLATFORM)
351
352pwmanager/pwmanager/Makefile$(PLATFORM): pwmanager/pwmanager/pwmanagerE.pro
353 cd pwmanager/pwmanager; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" pwmanagerE.pro -o Makefile$(PLATFORM)
354
355
356pwmanager/libcrypt/mpi/Makefile$(PLATFORM): pwmanager/libcrypt/mpi/mpi.pro
357 cd pwmanager/libcrypt/mpi;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" mpi.pro -o Makefile$(PLATFORM)
358
359pwmanager/libcrypt/error/Makefile$(PLATFORM): pwmanager/libcrypt/error/error.pro
360 cd pwmanager/libcrypt/error;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" error.pro -o Makefile$(PLATFORM)
361
362pwmanager/libcrypt/cipher/Makefile$(PLATFORM): pwmanager/libcrypt/cipher/cipher.pro
363 cd pwmanager/libcrypt/cipher;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" cipher.pro -o Makefile$(PLATFORM)
364
365pwmanager/libcrypt/zlib/Makefile$(PLATFORM): pwmanager/libcrypt/zlib/zlib.pro
366 cd pwmanager/libcrypt/zlib;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" zlib.pro -o Makefile$(PLATFORM)
367
368 253
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 6194d6d..4c4ae09 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -309,895 +309,889 @@ void AddressBook::init(const QString &config, const QString &family )
309 "X-AssistantsName", "KADDRESSBOOK" ); 309 "X-AssistantsName", "KADDRESSBOOK" );
310 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 310 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
311 "X-ManagersName", "KADDRESSBOOK" ); 311 "X-ManagersName", "KADDRESSBOOK" );
312 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 312 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
313 "X-SpousesName", "KADDRESSBOOK" ); 313 "X-SpousesName", "KADDRESSBOOK" );
314 addCustomField( i18n( "Office" ), KABC::Field::Personal, 314 addCustomField( i18n( "Office" ), KABC::Field::Personal,
315 "X-Office", "KADDRESSBOOK" ); 315 "X-Office", "KADDRESSBOOK" );
316 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 316 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
317 "X-IMAddress", "KADDRESSBOOK" ); 317 "X-IMAddress", "KADDRESSBOOK" );
318 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 318 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
319 "X-Anniversary", "KADDRESSBOOK" ); 319 "X-Anniversary", "KADDRESSBOOK" );
320 320
321 //US added this field to become compatible with Opie/qtopia addressbook 321 //US added this field to become compatible with Opie/qtopia addressbook
322 // values can be "female" or "male" or "". An empty field represents undefined. 322 // values can be "female" or "male" or "". An empty field represents undefined.
323 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 323 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
324 "X-Gender", "KADDRESSBOOK" ); 324 "X-Gender", "KADDRESSBOOK" );
325 addCustomField( i18n( "Children" ), KABC::Field::Personal, 325 addCustomField( i18n( "Children" ), KABC::Field::Personal,
326 "X-Children", "KADDRESSBOOK" ); 326 "X-Children", "KADDRESSBOOK" );
327 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 327 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
328 "X-FreeBusyUrl", "KADDRESSBOOK" ); 328 "X-FreeBusyUrl", "KADDRESSBOOK" );
329 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 329 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
330 "X-ExternalID", "KADDRESSBOOK" ); 330 "X-ExternalID", "KADDRESSBOOK" );
331} 331}
332 332
333AddressBook::~AddressBook() 333AddressBook::~AddressBook()
334{ 334{
335 delete d->mConfig; d->mConfig = 0; 335 delete d->mConfig; d->mConfig = 0;
336 delete d->mManager; d->mManager = 0; 336 delete d->mManager; d->mManager = 0;
337//US delete d->mErrorHandler; d->mErrorHandler = 0; 337//US delete d->mErrorHandler; d->mErrorHandler = 0;
338 delete d; d = 0; 338 delete d; d = 0;
339} 339}
340 340
341bool AddressBook::load() 341bool AddressBook::load()
342{ 342{
343 343
344 clear(); 344 clear();
345 KRES::Manager<Resource>::ActiveIterator it; 345 KRES::Manager<Resource>::ActiveIterator it;
346 bool ok = true; 346 bool ok = true;
347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
348 if ( !(*it)->load() ) { 348 if ( !(*it)->load() ) {
349 qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 349 qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
350 ok = false; 350 ok = false;
351 } else { 351 } else {
352 qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); 352 qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) );
353 } 353 }
354 // mark all addressees as unchanged 354 // mark all addressees as unchanged
355 Addressee::List::Iterator addrIt; 355 Addressee::List::Iterator addrIt;
356 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 356 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
357 (*addrIt).setChanged( false ); 357 (*addrIt).setChanged( false );
358 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 358 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
359 if ( !id.isEmpty() ) { 359 if ( !id.isEmpty() ) {
360 //qDebug("setId aa %s ", id.latin1()); 360 //qDebug("setId aa %s ", id.latin1());
361 (*addrIt).setIDStr(id ); 361 (*addrIt).setIDStr(id );
362 } 362 }
363 } 363 }
364 blockLSEchange = true; 364 blockLSEchange = true;
365 return ok; 365 return ok;
366} 366}
367 367
368bool AddressBook::save( Ticket *ticket ) 368bool AddressBook::save( Ticket *ticket )
369{ 369{
370 kdDebug(5700) << "AddressBook::save()"<< endl; 370 kdDebug(5700) << "AddressBook::save()"<< endl;
371 371
372 if ( ticket->resource() ) { 372 if ( ticket->resource() ) {
373 deleteRemovedAddressees(); 373 deleteRemovedAddressees();
374 return ticket->resource()->save( ticket ); 374 return ticket->resource()->save( ticket );
375 } 375 }
376 376
377 return false; 377 return false;
378} 378}
379// exports all Addressees, which are syncable 379// exports all Addressees, which are syncable
380void AddressBook::export2File( QString fileName ) 380void AddressBook::export2File( QString fileName )
381{ 381{
382 382
383 QFile outFile( fileName ); 383 QFile outFile( fileName );
384 if ( !outFile.open( IO_WriteOnly ) ) { 384 if ( !outFile.open( IO_WriteOnly ) ) {
385 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 385 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
386 KMessageBox::error( 0, text.arg( fileName ) ); 386 KMessageBox::error( 0, text.arg( fileName ) );
387 return ; 387 return ;
388 } 388 }
389 QTextStream t( &outFile ); 389 QTextStream t( &outFile );
390 t.setEncoding( QTextStream::UnicodeUTF8 ); 390 t.setEncoding( QTextStream::UnicodeUTF8 );
391 Iterator it; 391 Iterator it;
392 KABC::VCardConverter::Version version; 392 KABC::VCardConverter::Version version;
393 version = KABC::VCardConverter::v3_0; 393 version = KABC::VCardConverter::v3_0;
394 for ( it = begin(); it != end(); ++it ) { 394 for ( it = begin(); it != end(); ++it ) {
395 if ( (*it).resource() && (*it).resource()->includeInSync() ) { 395 if ( (*it).resource() && (*it).resource()->includeInSync() ) {
396 if ( !(*it).IDStr().isEmpty() ) { 396 if ( !(*it).IDStr().isEmpty() ) {
397 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 397 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
398 } 398 }
399 KABC::VCardConverter converter; 399 KABC::VCardConverter converter;
400 QString vcard; 400 QString vcard;
401 //Resource *resource() const; 401 //Resource *resource() const;
402 converter.addresseeToVCard( *it, vcard, version ); 402 converter.addresseeToVCard( *it, vcard, version );
403 t << vcard << "\r\n"; 403 t << vcard << "\r\n";
404 } 404 }
405 } 405 }
406 t << "\r\n\r\n"; 406 t << "\r\n\r\n";
407 outFile.close(); 407 outFile.close();
408} 408}
409// if QStringList uids is empty, all are exported 409// if QStringList uids is empty, all are exported
410bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) 410bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName )
411{ 411{
412 KABC::VCardConverter converter; 412 KABC::VCardConverter converter;
413 QString datastream; 413 QString datastream;
414 Iterator it; 414 Iterator it;
415 bool all = uids.isEmpty(); 415 bool all = uids.isEmpty();
416 for ( it = begin(); it != end(); ++it ) { 416 for ( it = begin(); it != end(); ++it ) {
417 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 417 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
418 if ( ! all ) { 418 if ( ! all ) {
419 if ( ! ( uids.contains((*it).uid() ) )) 419 if ( ! ( uids.contains((*it).uid() ) ))
420 continue; 420 continue;
421 } 421 }
422 KABC::Addressee a = ( *it ); 422 KABC::Addressee a = ( *it );
423 if ( a.isEmpty() ) 423 if ( a.isEmpty() )
424 continue; 424 continue;
425 if ( all && a.resource() && !a.resource()->includeInSync() ) 425 if ( all && a.resource() && !a.resource()->includeInSync() )
426 continue; 426 continue;
427 a.simplifyEmails(); 427 a.simplifyEmails();
428 a.simplifyPhoneNumbers(); 428 a.simplifyPhoneNumbers();
429 a.simplifyPhoneNumberTypes(); 429 a.simplifyPhoneNumberTypes();
430 a.simplifyAddresses(); 430 a.simplifyAddresses();
431 431
432 QString vcard; 432 QString vcard;
433 QString vcardnew; 433 QString vcardnew;
434 converter.addresseeToVCard( a, vcard ); 434 converter.addresseeToVCard( a, vcard );
435 int start = 0; 435 int start = 0;
436 int next; 436 int next;
437 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 437 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
438 int semi = vcard.find(";", next); 438 int semi = vcard.find(";", next);
439 int dopp = vcard.find(":", next); 439 int dopp = vcard.find(":", next);
440 int sep; 440 int sep;
441 if ( semi < dopp && semi >= 0 ) 441 if ( semi < dopp && semi >= 0 )
442 sep = semi ; 442 sep = semi ;
443 else 443 else
444 sep = dopp; 444 sep = dopp;
445 vcardnew +=vcard.mid( start, next - start); 445 vcardnew +=vcard.mid( start, next - start);
446 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); 446 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
447 start = sep; 447 start = sep;
448 } 448 }
449 vcardnew += vcard.mid( start,vcard.length() ); 449 vcardnew += vcard.mid( start,vcard.length() );
450 vcard = ""; 450 vcard = "";
451 start = 0; 451 start = 0;
452 while ( (next = vcardnew.find("ADR", start) )>= 0 ) { 452 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
453 int sep = vcardnew.find(":", next); 453 int sep = vcardnew.find(":", next);
454 vcard +=vcardnew.mid( start, next - start+3); 454 vcard +=vcardnew.mid( start, next - start+3);
455 start = sep; 455 start = sep;
456 } 456 }
457 vcard += vcardnew.mid( start,vcardnew.length() ); 457 vcard += vcardnew.mid( start,vcardnew.length() );
458 vcard.replace ( QRegExp(";;;") , "" ); 458 vcard.replace ( QRegExp(";;;") , "" );
459 vcard.replace ( QRegExp(";;") , "" ); 459 vcard.replace ( QRegExp(";;") , "" );
460 datastream += vcard; 460 datastream += vcard;
461 461
462 } 462 }
463 463
464 QFile outFile(fileName); 464 QFile outFile(fileName);
465 if ( outFile.open(IO_WriteOnly) ) { 465 if ( outFile.open(IO_WriteOnly) ) {
466 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 466 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
467 QTextStream t( &outFile ); // use a text stream 467 QTextStream t( &outFile ); // use a text stream
468 t.setEncoding( QTextStream::UnicodeUTF8 ); 468 t.setEncoding( QTextStream::UnicodeUTF8 );
469 t <<datastream; 469 t <<datastream;
470 t << "\r\n\r\n"; 470 t << "\r\n\r\n";
471 outFile.close(); 471 outFile.close();
472 472
473 } else { 473 } else {
474 qDebug("Error open temp file "); 474 qDebug("Error open temp file ");
475 return false; 475 return false;
476 } 476 }
477 return true; 477 return true;
478 478
479} 479}
480int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) 480int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld )
481{ 481{
482 482
483 if ( removeOld ) 483 if ( removeOld )
484 setUntagged( true ); 484 setUntagged( true );
485 KABC::Addressee::List list; 485 KABC::Addressee::List list;
486 QFile file( fileName ); 486 QFile file( fileName );
487 file.open( IO_ReadOnly ); 487 file.open( IO_ReadOnly );
488 QByteArray rawData = file.readAll(); 488 QByteArray rawData = file.readAll();
489 file.close(); 489 file.close();
490 QString data; 490 QString data;
491 if ( replaceLabel ) { 491 if ( replaceLabel ) {
492 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); 492 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
493 data.replace ( QRegExp("LABEL") , "ADR" ); 493 data.replace ( QRegExp("LABEL") , "ADR" );
494 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); 494 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
495 } else 495 } else
496 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 496 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
497 KABC::VCardTool tool; 497 KABC::VCardTool tool;
498 list = tool.parseVCards( data ); 498 list = tool.parseVCards( data );
499 KABC::Addressee::List::Iterator it; 499 KABC::Addressee::List::Iterator it;
500 for ( it = list.begin(); it != list.end(); ++it ) { 500 for ( it = list.begin(); it != list.end(); ++it ) {
501 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 501 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
502 if ( !id.isEmpty() ) 502 if ( !id.isEmpty() )
503 (*it).setIDStr(id ); 503 (*it).setIDStr(id );
504 (*it).setResource( 0 ); 504 (*it).setResource( 0 );
505 if ( replaceLabel ) 505 if ( replaceLabel )
506 (*it).removeVoice(); 506 (*it).removeVoice();
507 if ( removeOld ) 507 if ( removeOld )
508 (*it).setTagged( true ); 508 (*it).setTagged( true );
509 insertAddressee( (*it), false, true ); 509 insertAddressee( (*it), false, true );
510 } 510 }
511 if ( removeOld ) 511 if ( removeOld )
512 removeUntagged(); 512 removeUntagged();
513 return list.count(); 513 return list.count();
514} 514}
515void AddressBook::setUntagged(bool setNonSyncTagged) // = false) 515void AddressBook::setUntagged(bool setNonSyncTagged) // = false)
516{ 516{
517 Iterator ait; 517 Iterator ait;
518 for ( ait = begin(); ait != end(); ++ait ) { 518 for ( ait = begin(); ait != end(); ++ait ) {
519 if ( setNonSyncTagged ) { 519 if ( setNonSyncTagged ) {
520 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { 520 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) {
521 (*ait).setTagged( true ); 521 (*ait).setTagged( true );
522 } else 522 } else
523 (*ait).setTagged( false ); 523 (*ait).setTagged( false );
524 } else 524 } else
525 (*ait).setTagged( false ); 525 (*ait).setTagged( false );
526 } 526 }
527} 527}
528void AddressBook::removeUntagged() 528void AddressBook::removeUntagged()
529{ 529{
530 Iterator ait; 530 Iterator ait;
531 bool todelete = false; 531 bool todelete = false;
532 Iterator todel; 532 Iterator todel;
533 for ( ait = begin(); ait != end(); ++ait ) { 533 for ( ait = begin(); ait != end(); ++ait ) {
534 if ( todelete ) 534 if ( todelete )
535 removeAddressee( todel ); 535 removeAddressee( todel );
536 if (!(*ait).tagged()) { 536 if (!(*ait).tagged()) {
537 todelete = true; 537 todelete = true;
538 todel = ait; 538 todel = ait;
539 } else 539 } else
540 todelete = false; 540 todelete = false;
541 } 541 }
542 if ( todelete ) 542 if ( todelete )
543 removeAddressee( todel ); 543 removeAddressee( todel );
544 deleteRemovedAddressees(); 544 deleteRemovedAddressees();
545} 545}
546void AddressBook::smplifyAddressees() 546void AddressBook::smplifyAddressees()
547{ 547{
548 Iterator ait; 548 Iterator ait;
549 for ( ait = begin(); ait != end(); ++ait ) { 549 for ( ait = begin(); ait != end(); ++ait ) {
550 (*ait).simplifyEmails(); 550 (*ait).simplifyEmails();
551 (*ait).simplifyPhoneNumbers(); 551 (*ait).simplifyPhoneNumbers();
552 (*ait).simplifyPhoneNumberTypes(); 552 (*ait).simplifyPhoneNumberTypes();
553 (*ait).simplifyAddresses(); 553 (*ait).simplifyAddresses();
554 } 554 }
555} 555}
556void AddressBook::removeSyncInfo( QString syncProfile) 556void AddressBook::removeSyncInfo( QString syncProfile)
557{ 557{
558 Iterator ait; 558 Iterator ait;
559 for ( ait = begin(); ait != end(); ++ait ) { 559 for ( ait = begin(); ait != end(); ++ait ) {
560 (*ait).removeID( syncProfile ); 560 (*ait).removeID( syncProfile );
561 } 561 }
562 if ( syncProfile.isEmpty() ) { 562 if ( syncProfile.isEmpty() ) {
563 Iterator it = begin(); 563 Iterator it = begin();
564 Iterator it2 ; 564 Iterator it2 ;
565 QDateTime dt ( QDate( 2004,1,1) );
566 while ( it != end() ) { 565 while ( it != end() ) {
567 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 566 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
568 it2 = it; 567 it2 = it;
569 //qDebug("removing %s ",(*it).uid().latin1() ); 568 //qDebug("removing %s ",(*it).uid().latin1() );
570 ++it; 569 ++it;
571 removeAddressee( it2 ); 570 removeAddressee( it2 );
572 } else { 571 } else {
573 //qDebug("skipping %s ",(*it).uid().latin1() ); 572 //qDebug("skipping %s ",(*it).uid().latin1() );
574 ++it; 573 ++it;
575 } 574 }
576 } 575 }
577 } else { 576 } else {
578 Addressee lse; 577 Addressee lse;
579 lse = findByUid( "last-syncAddressee-"+ syncProfile ); 578 lse = findByUid( "last-syncAddressee-"+ syncProfile );
580 if ( ! lse.isEmpty() ) 579 if ( ! lse.isEmpty() )
581 removeAddressee( lse ); 580 removeAddressee( lse );
582 } 581 }
583 582
584} 583}
585void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) 584void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync )
586{ 585{
587 Iterator ait; 586 Iterator ait;
588 for ( ait = begin(); ait != end(); ++ait ) { 587 for ( ait = begin(); ait != end(); ++ait ) {
589 QString id = (*ait).IDStr(); 588 QString id = (*ait).IDStr();
590 (*ait).setIDStr( ":"); 589 (*ait).setIDStr( ":");
591 (*ait).setExternalUID( id ); 590 (*ait).setExternalUID( id );
592 (*ait).setOriginalExternalUID( id ); 591 (*ait).setOriginalExternalUID( id );
593 if ( isPreSync ) 592 if ( isPreSync )
594 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 593 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
595 else { 594 else {
596 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 595 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
597 (*ait).setID( currentSyncDevice,id ); 596 (*ait).setID( currentSyncDevice,id );
598 597
599 } 598 }
600 } 599 }
601} 600}
602void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) 601void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice )
603{ 602{
604 603
605 setUntagged(); 604 setUntagged();
606 KABC::Addressee::List list; 605 KABC::Addressee::List list;
607 QFile file( fileName ); 606 QFile file( fileName );
608 file.open( IO_ReadOnly ); 607 file.open( IO_ReadOnly );
609 QByteArray rawData = file.readAll(); 608 QByteArray rawData = file.readAll();
610 file.close(); 609 file.close();
611 QString data; 610 QString data;
612 611
613 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 612 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
614 KABC::VCardTool tool; 613 KABC::VCardTool tool;
615 list = tool.parseVCards( data ); 614 list = tool.parseVCards( data );
616 KABC::Addressee::List::Iterator it; 615 KABC::Addressee::List::Iterator it;
617 for ( it = list.begin(); it != list.end(); ++it ) { 616 for ( it = list.begin(); it != list.end(); ++it ) {
618 Iterator ait; 617 Iterator ait;
619 for ( ait = begin(); ait != end(); ++ait ) { 618 for ( ait = begin(); ait != end(); ++ait ) {
620 if ( !(*ait).tagged() ) { 619 if ( !(*ait).tagged() ) {
621 if ( (*ait).containsAdr(*it)) { 620 if ( (*ait).containsAdr(*it)) {
622 (*ait).setTagged(true); 621 (*ait).setTagged(true);
623 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 622 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
624 (*it).setIDStr( ":"); 623 (*it).setIDStr( ":");
625 (*it).setID( currentSyncDevice,id ); 624 (*it).setID( currentSyncDevice,id );
626 (*it).setExternalUID( id ); 625 (*it).setExternalUID( id );
627 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 626 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
628 (*it).setUid( ( (*ait).uid() )); 627 (*it).setUid( ( (*ait).uid() ));
629 break; 628 break;
630 } 629 }
631 } 630 }
632 631
633 } 632 }
634 if ( ait == end() ) 633 if ( ait == end() )
635 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); 634 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1());
636 } 635 }
637 clear(); 636 clear();
638 for ( it = list.begin(); it != list.end(); ++it ) { 637 for ( it = list.begin(); it != list.end(); ++it ) {
639 insertAddressee( (*it) ); 638 insertAddressee( (*it) );
640 } 639 }
641} 640}
642 641
643bool AddressBook::saveABphone( QString fileName ) 642bool AddressBook::saveABphone( QString fileName )
644{ 643{
645 //smplifyAddressees(); 644 //smplifyAddressees();
646 qDebug("saveABphone:: saving AB... "); 645 qDebug("saveABphone:: saving AB... ");
647 if ( ! export2PhoneFormat( QStringList() ,fileName ) ) 646 if ( ! export2PhoneFormat( QStringList() ,fileName ) )
648 return false; 647 return false;
649 qDebug("saveABphone:: writing to phone... "); 648 qDebug("saveABphone:: writing to phone... ");
650 if ( !PhoneAccess::writeToPhone( fileName) ) { 649 if ( !PhoneAccess::writeToPhone( fileName) ) {
651 return false; 650 return false;
652 } 651 }
653 qDebug("saveABphone:: re-reading from phone... "); 652 qDebug("saveABphone:: re-reading from phone... ");
654 if ( !PhoneAccess::readFromPhone( fileName) ) { 653 if ( !PhoneAccess::readFromPhone( fileName) ) {
655 return false; 654 return false;
656 } 655 }
657 return true; 656 return true;
658} 657}
659bool AddressBook::saveAB() 658bool AddressBook::saveAB()
660{ 659{
661 bool ok = true; 660 bool ok = true;
662 661
663 deleteRemovedAddressees(); 662 deleteRemovedAddressees();
664 Iterator ait; 663 Iterator ait;
665 for ( ait = begin(); ait != end(); ++ait ) { 664 for ( ait = begin(); ait != end(); ++ait ) {
666 if ( !(*ait).IDStr().isEmpty() ) { 665 if ( !(*ait).IDStr().isEmpty() ) {
667 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 666 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
668 } 667 }
669 } 668 }
670 KRES::Manager<Resource>::ActiveIterator it; 669 KRES::Manager<Resource>::ActiveIterator it;
671 KRES::Manager<Resource> *manager = d->mManager; 670 KRES::Manager<Resource> *manager = d->mManager;
672 qDebug("SaveAB::saving..." ); 671 qDebug("SaveAB::saving..." );
673 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 672 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
674 qDebug("SaveAB::checking resource..." ); 673 qDebug("SaveAB::checking resource..." );
675 if ( (*it)->readOnly() ) 674 if ( (*it)->readOnly() )
676 qDebug("resource is readonly." ); 675 qDebug("resource is readonly." );
677 if ( (*it)->isOpen() ) 676 if ( (*it)->isOpen() )
678 qDebug("resource is open" ); 677 qDebug("resource is open" );
679 678
680 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 679 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
681 Ticket *ticket = requestSaveTicket( *it ); 680 Ticket *ticket = requestSaveTicket( *it );
682 qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 681 qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
683 if ( !ticket ) { 682 if ( !ticket ) {
684 qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) 683 qDebug( i18n( "Unable to save to resource '%1'. It is locked." )
685 .arg( (*it)->resourceName() ) ); 684 .arg( (*it)->resourceName() ) );
686 return false; 685 return false;
687 } 686 }
688 687
689 //if ( !save( ticket ) ) 688 //if ( !save( ticket ) )
690 if ( ticket->resource() ) { 689 if ( ticket->resource() ) {
691 QString name = ticket->resource()->resourceName(); 690 QString name = ticket->resource()->resourceName();
692 if ( ! ticket->resource()->save( ticket ) ) 691 if ( ! ticket->resource()->save( ticket ) )
693 ok = false; 692 ok = false;
694 else 693 else
695 qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); 694 qDebug("StdAddressBook::resource saved '%s'", name.latin1() );
696 695
697 } else 696 } else
698 ok = false; 697 ok = false;
699 698
700 } 699 }
701 } 700 }
702 return ok; 701 return ok;
703} 702}
704 703
705AddressBook::Iterator AddressBook::begin() 704AddressBook::Iterator AddressBook::begin()
706{ 705{
707 Iterator it = Iterator(); 706 Iterator it = Iterator();
708 it.d->mIt = d->mAddressees.begin(); 707 it.d->mIt = d->mAddressees.begin();
709 return it; 708 return it;
710} 709}
711 710
712AddressBook::ConstIterator AddressBook::begin() const 711AddressBook::ConstIterator AddressBook::begin() const
713{ 712{
714 ConstIterator it = ConstIterator(); 713 ConstIterator it = ConstIterator();
715 it.d->mIt = d->mAddressees.begin(); 714 it.d->mIt = d->mAddressees.begin();
716 return it; 715 return it;
717} 716}
718 717
719AddressBook::Iterator AddressBook::end() 718AddressBook::Iterator AddressBook::end()
720{ 719{
721 Iterator it = Iterator(); 720 Iterator it = Iterator();
722 it.d->mIt = d->mAddressees.end(); 721 it.d->mIt = d->mAddressees.end();
723 return it; 722 return it;
724} 723}
725 724
726AddressBook::ConstIterator AddressBook::end() const 725AddressBook::ConstIterator AddressBook::end() const
727{ 726{
728 ConstIterator it = ConstIterator(); 727 ConstIterator it = ConstIterator();
729 it.d->mIt = d->mAddressees.end(); 728 it.d->mIt = d->mAddressees.end();
730 return it; 729 return it;
731} 730}
732 731
733void AddressBook::clear() 732void AddressBook::clear()
734{ 733{
735 d->mAddressees.clear(); 734 d->mAddressees.clear();
736} 735}
737 736
738Ticket *AddressBook::requestSaveTicket( Resource *resource ) 737Ticket *AddressBook::requestSaveTicket( Resource *resource )
739{ 738{
740 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 739 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
741 740
742 if ( !resource ) 741 if ( !resource )
743 { 742 {
744 qDebug("AddressBook::requestSaveTicket no resource" ); 743 qDebug("AddressBook::requestSaveTicket no resource" );
745 resource = standardResource(); 744 resource = standardResource();
746 } 745 }
747 746
748 KRES::Manager<Resource>::ActiveIterator it; 747 KRES::Manager<Resource>::ActiveIterator it;
749 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 748 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
750 if ( (*it) == resource ) { 749 if ( (*it) == resource ) {
751 if ( (*it)->readOnly() || !(*it)->isOpen() ) 750 if ( (*it)->readOnly() || !(*it)->isOpen() )
752 return 0; 751 return 0;
753 else 752 else
754 return (*it)->requestSaveTicket(); 753 return (*it)->requestSaveTicket();
755 } 754 }
756 } 755 }
757 756
758 return 0; 757 return 0;
759} 758}
760//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 759//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
761void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 760void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
762{ 761{
763 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 762 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
764 //qDebug("block insert "); 763 //qDebug("block insert ");
765 return; 764 return;
766 } 765 }
767 //qDebug("inserting.... %s ",a.uid().latin1() ); 766 //qDebug("inserting.... %s ",a.uid().latin1() );
768 bool found = false; 767 bool found = false;
769 Addressee::List::Iterator it; 768 Addressee::List::Iterator it;
770 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 769 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
771 if ( a.uid() == (*it).uid() ) { 770 if ( a.uid() == (*it).uid() ) {
772 771
773 bool changed = false; 772 bool changed = false;
774 Addressee addr = a; 773 Addressee addr = a;
775 if ( addr != (*it) ) 774 if ( addr != (*it) )
776 changed = true; 775 changed = true;
777 776
778 if ( takeResource ) { 777 if ( takeResource ) {
779 Resource * res = (*it).resource(); 778 Resource * res = (*it).resource();
780 (*it) = a; 779 (*it) = a;
781 (*it).setResource( res ); 780 (*it).setResource( res );
782 } else { 781 } else {
783 (*it) = a; 782 (*it) = a;
784 if ( (*it).resource() == 0 ) 783 if ( (*it).resource() == 0 )
785 (*it).setResource( standardResource() ); 784 (*it).setResource( standardResource() );
786 } 785 }
787 if ( changed ) { 786 if ( changed ) {
788 if ( setRev ) { 787 if ( setRev ) {
789 788 (*it).setRevision( QDateTime::currentDateTime() );
790 // get rid of micro seconds
791 QDateTime dt = QDateTime::currentDateTime();
792 QTime t = dt.time();
793 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
794 (*it).setRevision( dt );
795 } 789 }
796 (*it).setChanged( true ); 790 (*it).setChanged( true );
797 } 791 }
798 792
799 found = true; 793 found = true;
800 } else { 794 } else {
801 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 795 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
802 QString name = (*it).uid().mid( 19 ); 796 QString name = (*it).uid().mid( 19 );
803 Addressee b = a; 797 Addressee b = a;
804 QString id = b.getID( name ); 798 QString id = b.getID( name );
805 if ( ! id.isEmpty() ) { 799 if ( ! id.isEmpty() ) {
806 QString des = (*it).note(); 800 QString des = (*it).note();
807 int startN; 801 int startN;
808 if( (startN = des.find( id ) ) >= 0 ) { 802 if( (startN = des.find( id ) ) >= 0 ) {
809 int endN = des.find( ",", startN+1 ); 803 int endN = des.find( ",", startN+1 );
810 des = des.left( startN ) + des.mid( endN+1 ); 804 des = des.left( startN ) + des.mid( endN+1 );
811 (*it).setNote( des ); 805 (*it).setNote( des );
812 } 806 }
813 } 807 }
814 } 808 }
815 } 809 }
816 } 810 }
817 if ( found ) 811 if ( found )
818 return; 812 return;
813
819 d->mAddressees.append( a ); 814 d->mAddressees.append( a );
820 Addressee& addr = d->mAddressees.last(); 815 Addressee& addr = d->mAddressees.last();
821 if ( addr.resource() == 0 ) 816 if ( addr.resource() == 0 )
822 addr.setResource( standardResource() ); 817 addr.setResource( standardResource() );
823
824 addr.setChanged( true ); 818 addr.setChanged( true );
825} 819}
826 820
827void AddressBook::removeAddressee( const Addressee &a ) 821void AddressBook::removeAddressee( const Addressee &a )
828{ 822{
829 Iterator it; 823 Iterator it;
830 Iterator it2; 824 Iterator it2;
831 bool found = false; 825 bool found = false;
832 for ( it = begin(); it != end(); ++it ) { 826 for ( it = begin(); it != end(); ++it ) {
833 if ( a.uid() == (*it).uid() ) { 827 if ( a.uid() == (*it).uid() ) {
834 found = true; 828 found = true;
835 it2 = it; 829 it2 = it;
836 } else { 830 } else {
837 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 831 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
838 QString name = (*it).uid().mid( 19 ); 832 QString name = (*it).uid().mid( 19 );
839 Addressee b = a; 833 Addressee b = a;
840 QString id = b.getID( name ); 834 QString id = b.getID( name );
841 if ( ! id.isEmpty() ) { 835 if ( ! id.isEmpty() ) {
842 QString des = (*it).note(); 836 QString des = (*it).note();
843 if( des.find( id ) < 0 ) { 837 if( des.find( id ) < 0 ) {
844 des += id + ","; 838 des += id + ",";
845 (*it).setNote( des ); 839 (*it).setNote( des );
846 } 840 }
847 } 841 }
848 } 842 }
849 843
850 } 844 }
851 } 845 }
852 846
853 if ( found ) 847 if ( found )
854 removeAddressee( it2 ); 848 removeAddressee( it2 );
855 849
856} 850}
857 851
858void AddressBook::removeSyncAddressees( bool removeDeleted ) 852void AddressBook::removeSyncAddressees( bool removeDeleted )
859{ 853{
860 Iterator it = begin(); 854 Iterator it = begin();
861 Iterator it2 ; 855 Iterator it2 ;
862 QDateTime dt ( QDate( 2004,1,1) ); 856 QDateTime dt ( QDate( 2003,1,1) );
863 while ( it != end() ) { 857 while ( it != end() ) {
864 (*it).setRevision( dt ); 858 (*it).setRevision( dt );
865 if (( *it).IDStr() != "changed" ) { 859 if (( *it).IDStr() != "changed" ) {
866 // "changed" is used for tagging changed addressees when syncing with KDE or OL 860 // "changed" is used for tagging changed addressees when syncing with KDE or OL
867 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 861 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
868 (*it).setIDStr(""); 862 (*it).setIDStr(":");
869 } 863 }
870 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 864 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
871 it2 = it; 865 it2 = it;
872 //qDebug("removing %s ",(*it).uid().latin1() ); 866 //qDebug("removing %s ",(*it).uid().latin1() );
873 ++it; 867 ++it;
874 removeAddressee( it2 ); 868 removeAddressee( it2 );
875 } else { 869 } else {
876 //qDebug("skipping %s ",(*it).uid().latin1() ); 870 //qDebug("skipping %s ",(*it).uid().latin1() );
877 if ( removeDeleted ) { 871 if ( removeDeleted ) {
878 // we have no postprocessing in the resource, we have to do it here 872 // we have no postprocessing in the resource, we have to do it here
879 // we have to compute csum for all, because it could be the first sync 873 // we have to compute csum for all, because it could be the first sync
880 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 874 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
881
882
883 } 875 }
884 ++it; 876 ++it;
885 } 877 }
886 } 878 }
887 deleteRemovedAddressees(); 879 deleteRemovedAddressees();
888} 880}
889 881
890void AddressBook::removeAddressee( const Iterator &it ) 882void AddressBook::removeAddressee( const Iterator &it )
891{ 883{
892 d->mRemovedAddressees.append( (*it) ); 884 d->mRemovedAddressees.append( (*it) );
893 d->mAddressees.remove( it.d->mIt ); 885 d->mAddressees.remove( it.d->mIt );
894} 886}
895 887
896AddressBook::Iterator AddressBook::find( const Addressee &a ) 888AddressBook::Iterator AddressBook::find( const Addressee &a )
897{ 889{
898 Iterator it; 890 Iterator it;
899 for ( it = begin(); it != end(); ++it ) { 891 for ( it = begin(); it != end(); ++it ) {
900 if ( a.uid() == (*it).uid() ) { 892 if ( a.uid() == (*it).uid() ) {
901 return it; 893 return it;
902 } 894 }
903 } 895 }
904 return end(); 896 return end();
905} 897}
906 898
907Addressee AddressBook::findByUid( const QString &uid ) 899Addressee AddressBook::findByUid( const QString &uid )
908{ 900{
909 Iterator it; 901 Iterator it;
910 for ( it = begin(); it != end(); ++it ) { 902 for ( it = begin(); it != end(); ++it ) {
911 if ( uid == (*it).uid() ) { 903 if ( uid == (*it).uid() ) {
912 return *it; 904 return *it;
913 } 905 }
914 } 906 }
915 return Addressee(); 907 return Addressee();
916} 908}
917void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) 909void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
918{ 910{
919 //qDebug("AddressBook::preExternSync "); 911 //qDebug("AddressBook::preExternSync ");
920 AddressBook::Iterator it; 912 AddressBook::Iterator it;
921 for ( it = begin(); it != end(); ++it ) { 913 for ( it = begin(); it != end(); ++it ) {
922 (*it).setID( csd, (*it).externalUID() ); 914 (*it).setID( csd, (*it).externalUID() );
923 (*it).computeCsum( csd ); 915 (*it).computeCsum( csd );
924 } 916 }
925 mergeAB( aBook ,csd, isSubset ); 917 mergeAB( aBook ,csd, isSubset );
926} 918}
927void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) 919void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID)
928{ 920{
929 //qDebug("AddressBook::postExternSync "); 921 //qDebug("AddressBook::postExternSync ");
930 AddressBook::Iterator it; 922 AddressBook::Iterator it;
931 for ( it = begin(); it != end(); ++it ) { 923 for ( it = begin(); it != end(); ++it ) {
932 //qDebug("check uid %s ", (*it).uid().latin1() ); 924 //qDebug("check uid %s ", (*it).uid().latin1() );
933 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 925 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
934 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 926 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ||
927 (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) {
935 Addressee ad = aBook->findByUid( ( (*it).uid() )); 928 Addressee ad = aBook->findByUid( ( (*it).uid() ));
936 if ( ad.isEmpty() ) { 929 if ( ad.isEmpty() ) {
937 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 930 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
938 } else { 931 } else {
939 (*it).setIDStr(":"); 932 (*it).setIDStr(":");
940 (*it).computeCsum( csd );
941 if ( setID ) { 933 if ( setID ) {
942 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 934 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
943 ad.setID( csd, (*it).externalUID() ); 935 ad.setID( csd, (*it).externalUID() );
944 } else 936 } else
945 ad.setID( csd, (*it).uid() ); 937 ad.setID( csd, (*it).uid() );
938 (*it).computeCsum( csd );
946 ad.setCsum( csd, (*it).getCsum( csd ) ); 939 ad.setCsum( csd, (*it).getCsum( csd ) );
947 aBook->insertAddressee( ad ); 940 //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() );
941 aBook->insertAddressee( ad , false);
948 } 942 }
949 } 943 }
950 } 944 }
951} 945}
952 946
953bool AddressBook::containsExternalUid( const QString& uid ) 947bool AddressBook::containsExternalUid( const QString& uid )
954{ 948{
955 Iterator it; 949 Iterator it;
956 for ( it = begin(); it != end(); ++it ) { 950 for ( it = begin(); it != end(); ++it ) {
957 if ( uid == (*it).externalUID( ) ) 951 if ( uid == (*it).externalUID( ) )
958 return true; 952 return true;
959 } 953 }
960 return false; 954 return false;
961} 955}
962Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 956Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
963{ 957{
964 Iterator it; 958 Iterator it;
965 for ( it = begin(); it != end(); ++it ) { 959 for ( it = begin(); it != end(); ++it ) {
966 if ( uid == (*it).getID( profile ) ) 960 if ( uid == (*it).getID( profile ) )
967 return (*it); 961 return (*it);
968 } 962 }
969 return Addressee(); 963 return Addressee();
970} 964}
971void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) 965void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset )
972{ 966{
973 Iterator it; 967 Iterator it;
974 Addressee ad; 968 Addressee ad;
975 for ( it = begin(); it != end(); ++it ) { 969 for ( it = begin(); it != end(); ++it ) {
976 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 970 ad = aBook->findByExternUid( (*it).externalUID(), profile );
977 if ( !ad.isEmpty() ) { 971 if ( !ad.isEmpty() ) {
978 (*it).mergeContact( ad ,isSubset); 972 (*it).mergeContact( ad ,isSubset);
979 } 973 }
980 } 974 }
981#if 0 975#if 0
982 // test only 976 // test only
983 for ( it = begin(); it != end(); ++it ) { 977 for ( it = begin(); it != end(); ++it ) {
984 978
985 qDebug("uid %s ", (*it).uid().latin1()); 979 qDebug("uid %s ", (*it).uid().latin1());
986 } 980 }
987#endif 981#endif
988} 982}
989 983
990#if 0 984#if 0
991Addressee::List AddressBook::getExternLastSyncAddressees() 985Addressee::List AddressBook::getExternLastSyncAddressees()
992{ 986{
993 Addressee::List results; 987 Addressee::List results;
994 988
995 Iterator it; 989 Iterator it;
996 for ( it = begin(); it != end(); ++it ) { 990 for ( it = begin(); it != end(); ++it ) {
997 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 991 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
998 if ( (*it).familyName().left(4) == "!E: " ) 992 if ( (*it).familyName().left(4) == "!E: " )
999 results.append( *it ); 993 results.append( *it );
1000 } 994 }
1001 } 995 }
1002 996
1003 return results; 997 return results;
1004} 998}
1005#endif 999#endif
1006void AddressBook::resetTempSyncStat() 1000void AddressBook::resetTempSyncStat()
1007{ 1001{
1008 Iterator it; 1002 Iterator it;
1009 for ( it = begin(); it != end(); ++it ) { 1003 for ( it = begin(); it != end(); ++it ) {
1010 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 1004 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
1011 } 1005 }
1012 1006
1013} 1007}
1014 1008
1015QStringList AddressBook:: uidList() 1009QStringList AddressBook:: uidList()
1016{ 1010{
1017 QStringList results; 1011 QStringList results;
1018 Iterator it; 1012 Iterator it;
1019 for ( it = begin(); it != end(); ++it ) { 1013 for ( it = begin(); it != end(); ++it ) {
1020 results.append( (*it).uid() ); 1014 results.append( (*it).uid() );
1021 } 1015 }
1022 return results; 1016 return results;
1023} 1017}
1024 1018
1025 1019
1026Addressee::List AddressBook::allAddressees() 1020Addressee::List AddressBook::allAddressees()
1027{ 1021{
1028 return d->mAddressees; 1022 return d->mAddressees;
1029 1023
1030} 1024}
1031 1025
1032Addressee::List AddressBook::findByName( const QString &name ) 1026Addressee::List AddressBook::findByName( const QString &name )
1033{ 1027{
1034 Addressee::List results; 1028 Addressee::List results;
1035 1029
1036 Iterator it; 1030 Iterator it;
1037 for ( it = begin(); it != end(); ++it ) { 1031 for ( it = begin(); it != end(); ++it ) {
1038 if ( name == (*it).realName() ) { 1032 if ( name == (*it).realName() ) {
1039 results.append( *it ); 1033 results.append( *it );
1040 } 1034 }
1041 } 1035 }
1042 1036
1043 return results; 1037 return results;
1044} 1038}
1045 1039
1046Addressee::List AddressBook::findByEmail( const QString &email ) 1040Addressee::List AddressBook::findByEmail( const QString &email )
1047{ 1041{
1048 Addressee::List results; 1042 Addressee::List results;
1049 QStringList mailList; 1043 QStringList mailList;
1050 1044
1051 Iterator it; 1045 Iterator it;
1052 for ( it = begin(); it != end(); ++it ) { 1046 for ( it = begin(); it != end(); ++it ) {
1053 mailList = (*it).emails(); 1047 mailList = (*it).emails();
1054 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 1048 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
1055 if ( email == (*ite) ) { 1049 if ( email == (*ite) ) {
1056 results.append( *it ); 1050 results.append( *it );
1057 } 1051 }
1058 } 1052 }
1059 } 1053 }
1060 1054
1061 return results; 1055 return results;
1062} 1056}
1063 1057
1064Addressee::List AddressBook::findByCategory( const QString &category ) 1058Addressee::List AddressBook::findByCategory( const QString &category )
1065{ 1059{
1066 Addressee::List results; 1060 Addressee::List results;
1067 1061
1068 Iterator it; 1062 Iterator it;
1069 for ( it = begin(); it != end(); ++it ) { 1063 for ( it = begin(); it != end(); ++it ) {
1070 if ( (*it).hasCategory( category) ) { 1064 if ( (*it).hasCategory( category) ) {
1071 results.append( *it ); 1065 results.append( *it );
1072 } 1066 }
1073 } 1067 }
1074 1068
1075 return results; 1069 return results;
1076} 1070}
1077 1071
1078void AddressBook::dump() const 1072void AddressBook::dump() const
1079{ 1073{
1080 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 1074 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
1081 1075
1082 ConstIterator it; 1076 ConstIterator it;
1083 for( it = begin(); it != end(); ++it ) { 1077 for( it = begin(); it != end(); ++it ) {
1084 (*it).dump(); 1078 (*it).dump();
1085 } 1079 }
1086 1080
1087 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 1081 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
1088} 1082}
1089 1083
1090QString AddressBook::identifier() 1084QString AddressBook::identifier()
1091{ 1085{
1092 QStringList identifier; 1086 QStringList identifier;
1093 1087
1094 1088
1095 KRES::Manager<Resource>::ActiveIterator it; 1089 KRES::Manager<Resource>::ActiveIterator it;
1096 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 1090 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
1097 if ( !(*it)->identifier().isEmpty() ) 1091 if ( !(*it)->identifier().isEmpty() )
1098 identifier.append( (*it)->identifier() ); 1092 identifier.append( (*it)->identifier() );
1099 } 1093 }
1100 1094
1101 return identifier.join( ":" ); 1095 return identifier.join( ":" );
1102} 1096}
1103 1097
1104Field::List AddressBook::fields( int category ) 1098Field::List AddressBook::fields( int category )
1105{ 1099{
1106 if ( d->mAllFields.isEmpty() ) { 1100 if ( d->mAllFields.isEmpty() ) {
1107 d->mAllFields = Field::allFields(); 1101 d->mAllFields = Field::allFields();
1108 } 1102 }
1109 1103
1110 if ( category == Field::All ) return d->mAllFields; 1104 if ( category == Field::All ) return d->mAllFields;
1111 1105
1112 Field::List result; 1106 Field::List result;
1113 Field::List::ConstIterator it; 1107 Field::List::ConstIterator it;
1114 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 1108 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
1115 if ( (*it)->category() & category ) result.append( *it ); 1109 if ( (*it)->category() & category ) result.append( *it );
1116 } 1110 }
1117 1111
1118 return result; 1112 return result;
1119} 1113}
1120 1114
1121bool AddressBook::addCustomField( const QString &label, int category, 1115bool AddressBook::addCustomField( const QString &label, int category,
1122 const QString &key, const QString &app ) 1116 const QString &key, const QString &app )
1123{ 1117{
1124 if ( d->mAllFields.isEmpty() ) { 1118 if ( d->mAllFields.isEmpty() ) {
1125 d->mAllFields = Field::allFields(); 1119 d->mAllFields = Field::allFields();
1126 } 1120 }
1127//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 1121//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
1128 QString a = app.isNull() ? KGlobal::getAppName() : app; 1122 QString a = app.isNull() ? KGlobal::getAppName() : app;
1129 1123
1130 QString k = key.isNull() ? label : key; 1124 QString k = key.isNull() ? label : key;
1131 1125
1132 Field *field = Field::createCustomField( label, category, k, a ); 1126 Field *field = Field::createCustomField( label, category, k, a );
1133 1127
1134 if ( !field ) return false; 1128 if ( !field ) return false;
1135 1129
1136 d->mAllFields.append( field ); 1130 d->mAllFields.append( field );
1137 1131
1138 return true; 1132 return true;
1139} 1133}
1140 1134
1141QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 1135QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
1142{ 1136{
1143 if (!ab.d) return s; 1137 if (!ab.d) return s;
1144 1138
1145 return s << ab.d->mAddressees; 1139 return s << ab.d->mAddressees;
1146} 1140}
1147 1141
1148QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 1142QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
1149{ 1143{
1150 if (!ab.d) return s; 1144 if (!ab.d) return s;
1151 1145
1152 s >> ab.d->mAddressees; 1146 s >> ab.d->mAddressees;
1153 1147
1154 return s; 1148 return s;
1155} 1149}
1156 1150
1157bool AddressBook::addResource( Resource *resource ) 1151bool AddressBook::addResource( Resource *resource )
1158{ 1152{
1159 if ( !resource->open() ) { 1153 if ( !resource->open() ) {
1160 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; 1154 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
1161 return false; 1155 return false;
1162 } 1156 }
1163 1157
1164 resource->setAddressBook( this ); 1158 resource->setAddressBook( this );
1165 1159
1166 d->mManager->add( resource ); 1160 d->mManager->add( resource );
1167 return true; 1161 return true;
1168} 1162}
1169 1163
1170bool AddressBook::removeResource( Resource *resource ) 1164bool AddressBook::removeResource( Resource *resource )
1171{ 1165{
1172 resource->close(); 1166 resource->close();
1173 1167
1174 if ( resource == standardResource() ) 1168 if ( resource == standardResource() )
1175 d->mManager->setStandardResource( 0 ); 1169 d->mManager->setStandardResource( 0 );
1176 1170
1177 resource->setAddressBook( 0 ); 1171 resource->setAddressBook( 0 );
1178 1172
1179 d->mManager->remove( resource ); 1173 d->mManager->remove( resource );
1180 return true; 1174 return true;
1181} 1175}
1182 1176
1183QPtrList<Resource> AddressBook::resources() 1177QPtrList<Resource> AddressBook::resources()
1184{ 1178{
1185 QPtrList<Resource> list; 1179 QPtrList<Resource> list;
1186 1180
1187// qDebug("AddressBook::resources() 1"); 1181// qDebug("AddressBook::resources() 1");
1188 1182
1189 KRES::Manager<Resource>::ActiveIterator it; 1183 KRES::Manager<Resource>::ActiveIterator it;
1190 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 1184 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
1191 list.append( *it ); 1185 list.append( *it );
1192 1186
1193 return list; 1187 return list;
1194} 1188}
1195 1189
1196/*US 1190/*US
1197void AddressBook::setErrorHandler( ErrorHandler *handler ) 1191void AddressBook::setErrorHandler( ErrorHandler *handler )
1198{ 1192{
1199 delete d->mErrorHandler; 1193 delete d->mErrorHandler;
1200 d->mErrorHandler = handler; 1194 d->mErrorHandler = handler;
1201} 1195}
1202*/ 1196*/
1203 1197
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index d5a110a..3d4992c 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,525 +1,535 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern ); 47static bool matchBinaryPatternP( int value, int pattern );
48 48
49struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
50{ 50{
51 QString uid; 51 QString uid;
52 QString name; 52 QString name;
53 QString formattedName; 53 QString formattedName;
54 QString familyName; 54 QString familyName;
55 QString givenName; 55 QString givenName;
56 QString additionalName; 56 QString additionalName;
57 QString prefix; 57 QString prefix;
58 QString suffix; 58 QString suffix;
59 QString nickName; 59 QString nickName;
60 QDateTime birthday; 60 QDateTime birthday;
61 QString mailer; 61 QString mailer;
62 TimeZone timeZone; 62 TimeZone timeZone;
63 Geo geo; 63 Geo geo;
64 QString title; 64 QString title;
65 QString role; 65 QString role;
66 QString organization; 66 QString organization;
67 QString note; 67 QString note;
68 QString productId; 68 QString productId;
69 QDateTime revision; 69 QDateTime revision;
70 QString sortString; 70 QString sortString;
71 QString externalUID; 71 QString externalUID;
72 QString originalExternalUID; 72 QString originalExternalUID;
73 KURL url; 73 KURL url;
74 Secrecy secrecy; 74 Secrecy secrecy;
75 Picture logo; 75 Picture logo;
76 Picture photo; 76 Picture photo;
77 Sound sound; 77 Sound sound;
78 Agent agent; 78 Agent agent;
79 QString mExternalId; 79 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 81 Address::List addresses;
82 Key::List keys; 82 Key::List keys;
83 QStringList emails; 83 QStringList emails;
84 QStringList categories; 84 QStringList categories;
85 QStringList custom; 85 QStringList custom;
86 int mTempSyncStat; 86 int mTempSyncStat;
87 Resource *resource; 87 Resource *resource;
88 88
89 bool empty :1; 89 bool empty :1;
90 bool changed :1; 90 bool changed :1;
91 bool tagged :1; 91 bool tagged :1;
92}; 92};
93 93
94Addressee::Addressee() 94Addressee::Addressee()
95{ 95{
96 mData = new AddresseeData; 96 mData = new AddresseeData;
97 mData->empty = true; 97 mData->empty = true;
98 mData->changed = false; 98 mData->changed = false;
99 mData->resource = 0; 99 mData->resource = 0;
100 mData->mExternalId = ":"; 100 mData->mExternalId = ":";
101 mData->revision = QDateTime ( QDate( 2003,1,1)); 101 mData->revision = QDateTime ( QDate( 2003,1,1));
102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
103} 103}
104 104
105Addressee::~Addressee() 105Addressee::~Addressee()
106{ 106{
107} 107}
108 108
109Addressee::Addressee( const Addressee &a ) 109Addressee::Addressee( const Addressee &a )
110{ 110{
111 mData = a.mData; 111 mData = a.mData;
112} 112}
113 113
114Addressee &Addressee::operator=( const Addressee &a ) 114Addressee &Addressee::operator=( const Addressee &a )
115{ 115{
116 mData = a.mData; 116 mData = a.mData;
117 return (*this); 117 return (*this);
118} 118}
119 119
120Addressee Addressee::copy() 120Addressee Addressee::copy()
121{ 121{
122 Addressee a; 122 Addressee a;
123 *(a.mData) = *mData; 123 *(a.mData) = *mData;
124 return a; 124 return a;
125} 125}
126 126
127void Addressee::detach() 127void Addressee::detach()
128{ 128{
129 if ( mData.count() == 1 ) return; 129 if ( mData.count() == 1 ) return;
130 *this = copy(); 130 *this = copy();
131} 131}
132 132
133bool Addressee::operator==( const Addressee &a ) const 133bool Addressee::operator==( const Addressee &a ) const
134{ 134{
135 if ( uid() != a.uid() ) return false; 135 if ( uid() != a.uid() ) return false;
136 if ( mData->name != a.mData->name ) return false; 136 if ( mData->name != a.mData->name ) return false;
137 if ( mData->formattedName != a.mData->formattedName ) return false; 137 if ( mData->formattedName != a.mData->formattedName ) return false;
138 if ( mData->familyName != a.mData->familyName ) return false; 138 if ( mData->familyName != a.mData->familyName ) return false;
139 if ( mData->givenName != a.mData->givenName ) return false; 139 if ( mData->givenName != a.mData->givenName ) return false;
140 if ( mData->additionalName != a.mData->additionalName ) return false; 140 if ( mData->additionalName != a.mData->additionalName ) return false;
141 if ( mData->prefix != a.mData->prefix ) return false; 141 if ( mData->prefix != a.mData->prefix ) return false;
142 if ( mData->suffix != a.mData->suffix ) return false; 142 if ( mData->suffix != a.mData->suffix ) return false;
143 if ( mData->nickName != a.mData->nickName ) return false; 143 if ( mData->nickName != a.mData->nickName ) return false;
144 if ( mData->birthday != a.mData->birthday ) return false; 144 if ( mData->birthday != a.mData->birthday ) return false;
145 if ( mData->mailer != a.mData->mailer ) return false; 145 if ( mData->mailer != a.mData->mailer ) return false;
146 if ( mData->timeZone != a.mData->timeZone ) return false; 146 if ( mData->timeZone != a.mData->timeZone ) return false;
147 if ( mData->geo != a.mData->geo ) return false; 147 if ( mData->geo != a.mData->geo ) return false;
148 if ( mData->title != a.mData->title ) return false; 148 if ( mData->title != a.mData->title ) return false;
149 if ( mData->role != a.mData->role ) return false; 149 if ( mData->role != a.mData->role ) return false;
150 if ( mData->organization != a.mData->organization ) return false; 150 if ( mData->organization != a.mData->organization ) return false;
151 if ( mData->note != a.mData->note ) return false; 151 if ( mData->note != a.mData->note ) return false;
152 if ( mData->productId != a.mData->productId ) return false; 152 if ( mData->productId != a.mData->productId ) return false;
153 //if ( mData->revision != a.mData->revision ) return false; 153 //if ( mData->revision != a.mData->revision ) return false;
154 if ( mData->sortString != a.mData->sortString ) return false; 154 if ( mData->sortString != a.mData->sortString ) return false;
155 if ( mData->secrecy != a.mData->secrecy ) return false; 155 if ( mData->secrecy != a.mData->secrecy ) return false;
156 if ( mData->logo != a.mData->logo ) return false; 156 if ( mData->logo != a.mData->logo ) return false;
157 if ( mData->photo != a.mData->photo ) return false; 157 if ( mData->photo != a.mData->photo ) return false;
158 if ( mData->sound != a.mData->sound ) return false; 158 if ( mData->sound != a.mData->sound ) return false;
159 if ( mData->agent != a.mData->agent ) return false; 159 if ( mData->agent != a.mData->agent ) return false;
160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
161 ( mData->url != a.mData->url ) ) return false; 161 ( mData->url != a.mData->url ) ) return false;
162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
163 if ( mData->addresses != a.mData->addresses ) return false; 163 if ( mData->addresses != a.mData->addresses ) return false;
164 if ( mData->keys != a.mData->keys ) return false; 164 if ( mData->keys != a.mData->keys ) return false;
165 if ( mData->emails != a.mData->emails ) return false; 165 if ( mData->emails != a.mData->emails ) return false;
166 if ( mData->categories != a.mData->categories ) return false; 166 if ( mData->categories != a.mData->categories ) return false;
167 if ( mData->custom != a.mData->custom ) return false; 167 if ( mData->custom != a.mData->custom ) return false;
168 168
169 return true; 169 return true;
170} 170}
171 171
172bool Addressee::operator!=( const Addressee &a ) const 172bool Addressee::operator!=( const Addressee &a ) const
173{ 173{
174 return !( a == *this ); 174 return !( a == *this );
175} 175}
176 176
177bool Addressee::isEmpty() const 177bool Addressee::isEmpty() const
178{ 178{
179 return mData->empty; 179 return mData->empty;
180} 180}
181ulong Addressee::getCsum4List( const QStringList & attList) 181ulong Addressee::getCsum4List( const QStringList & attList)
182{ 182{
183 int max = attList.count(); 183 int max = attList.count();
184 ulong cSum = 0; 184 ulong cSum = 0;
185 int j,k,i; 185 int j,k,i;
186 int add; 186 int add;
187 for ( i = 0; i < max ; ++i ) { 187 for ( i = 0; i < max ; ++i ) {
188 QString s = attList[i]; 188 QString s = attList[i];
189 if ( ! s.isEmpty() ){ 189 if ( ! s.isEmpty() ){
190 j = s.length(); 190 j = s.length();
191 for ( k = 0; k < j; ++k ) { 191 for ( k = 0; k < j; ++k ) {
192 int mul = k +1; 192 int mul = k +1;
193 add = s[k].unicode (); 193 add = s[k].unicode ();
194 if ( k < 16 ) 194 if ( k < 16 )
195 mul = mul * mul; 195 mul = mul * mul;
196 int ii = i+1; 196 int ii = i+1;
197 add = add * mul *ii*ii*ii; 197 add = add * mul *ii*ii*ii;
198 cSum += add; 198 cSum += add;
199 } 199 }
200 } 200 }
201 201
202 } 202 }
203 //QString dump = attList.join(","); 203 //QString dump = attList.join(",");
204 //qDebug("csum: %d %s", cSum,dump.latin1()); 204 //qDebug("csum: %d %s", cSum,dump.latin1());
205 205
206 return cSum; 206 return cSum;
207 207
208} 208}
209void Addressee::computeCsum(const QString &dev) 209void Addressee::computeCsum(const QString &dev)
210{ 210{
211 QStringList l; 211 QStringList l;
212 if ( !mData->name.isEmpty() ) l.append(mData->name); 212 //if ( !mData->name.isEmpty() ) l.append(mData->name);
213 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 213 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
216 if ( !mData->additionalName ) l.append( mData->additionalName ); 216 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
224 if ( !mData->title .isEmpty() ) l.append( mData->title ); 224 if ( !mData->title .isEmpty() ) l.append( mData->title );
225 if ( !mData->role.isEmpty() ) l.append( mData->role ); 225 if ( !mData->role.isEmpty() ) l.append( mData->role );
226 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 226 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
227 if ( !mData->note.isEmpty() ) l.append( mData->note ); 227 if ( !mData->note.isEmpty() ) l.append( mData->note );
228 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 228 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 231 // if ( !mData->logo.isEmpty() ) l.append( );
232 //if ( !mData->photo.isEmpty() ) l.append( ); 232 //if ( !mData->photo.isEmpty() ) l.append( );
233 //if ( !mData->sound.isEmpty() ) l.append( ); 233 //if ( !mData->sound.isEmpty() ) l.append( );
234 //if ( !mData->agent.isEmpty() ) l.append( ); 234 //if ( !mData->agent.isEmpty() ) l.append( );
235 if ( mData->url.isValid() ) 235 if ( mData->url.isValid() )
236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
237 KABC::PhoneNumber::List phoneNumbers; 237 KABC::PhoneNumber::List phoneNumbers;
238 KABC::PhoneNumber::List::Iterator phoneIter; 238 KABC::PhoneNumber::List::Iterator phoneIter;
239 239
240 QStringList t; 240 QStringList t;
241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
242 ++phoneIter ) 242 ++phoneIter )
243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
244 t.sort(); 244 t.sort();
245 uint iii; 245 uint iii;
246 for ( iii = 0; iii < t.count(); ++iii) 246 for ( iii = 0; iii < t.count(); ++iii)
247 l.append( t[iii] ); 247 l.append( t[iii] );
248 t = mData->emails; 248 t = mData->emails;
249 t.sort(); 249 t.sort();
250 for ( iii = 0; iii < t.count(); ++iii) 250 for ( iii = 0; iii < t.count(); ++iii)
251 l.append( t[iii] ); 251 l.append( t[iii] );
252 t = mData->categories; 252 t = mData->categories;
253 t.sort(); 253 t.sort();
254 for ( iii = 0; iii < t.count(); ++iii) 254 for ( iii = 0; iii < t.count(); ++iii)
255 l.append( t[iii] ); 255 l.append( t[iii] );
256 t = mData->custom; 256 t = mData->custom;
257 t.sort(); 257 t.sort();
258 for ( iii = 0; iii < t.count(); ++iii) 258 for ( iii = 0; iii < t.count(); ++iii)
259 l.append( t[iii] ); 259 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
260 int find = t[iii].find (':')+1;
261 //qDebug("lennnn %d %d ", find, t[iii].length());
262 if ( find < t[iii].length())
263 l.append( t[iii] );
264
265 }
260 KABC::Address::List::Iterator addressIter; 266 KABC::Address::List::Iterator addressIter;
261 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
262 ++addressIter ) { 268 ++addressIter ) {
263 t = (*addressIter).asList(); 269 t = (*addressIter).asList();
264 t.sort(); 270 t.sort();
265 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
266 l.append( t[iii] ); 272 l.append( t[iii] );
267 } 273 }
268 uint cs = getCsum4List(l); 274 uint cs = getCsum4List(l);
269 //qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 275#if 1
276 for ( iii = 0; iii < l.count(); ++iii)
277 qDebug("%d***%s***",iii,l[iii].latin1());
278 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
279#endif
270 setCsum( dev, QString::number (cs )); 280 setCsum( dev, QString::number (cs ));
271} 281}
272 282
273void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 283void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
274{ 284{
275 285
276 detach(); 286 detach();
277 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 287 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
278 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 288 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
279 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 289 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
280 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 290 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
281 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 291 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
282 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 292 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
283 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 293 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
284 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 294 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
285 if ( !mData->birthday.isValid() ) 295 if ( !mData->birthday.isValid() )
286 if ( ad.mData->birthday.isValid()) 296 if ( ad.mData->birthday.isValid())
287 mData->birthday = ad.mData->birthday; 297 mData->birthday = ad.mData->birthday;
288 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 298 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
289 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 299 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
290 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 300 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
291 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 301 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
292 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 302 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
293 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 303 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
294 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 304 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
295 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 305 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
296 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 306 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
297 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 307 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
298 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 308 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
299 QStringList t; 309 QStringList t;
300 QStringList tAD; 310 QStringList tAD;
301 uint iii; 311 uint iii;
302 312
303 // ********** phone numbers 313 // ********** phone numbers
304 PhoneNumber::List phoneAD = ad.phoneNumbers(); 314 PhoneNumber::List phoneAD = ad.phoneNumbers();
305 PhoneNumber::List::Iterator phoneItAD; 315 PhoneNumber::List::Iterator phoneItAD;
306 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 316 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
307 bool found = false; 317 bool found = false;
308 PhoneNumber::List::Iterator it; 318 PhoneNumber::List::Iterator it;
309 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 319 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
310 if ( ( *phoneItAD ).contains( (*it) ) ) { 320 if ( ( *phoneItAD ).contains( (*it) ) ) {
311 found = true; 321 found = true;
312 (*it).setType( ( *phoneItAD ).type() ); 322 (*it).setType( ( *phoneItAD ).type() );
313 (*it).setNumber( ( *phoneItAD ).number() ); 323 (*it).setNumber( ( *phoneItAD ).number() );
314 break; 324 break;
315 } 325 }
316 } 326 }
317 if ( isSubSet && ! found ) 327 if ( isSubSet && ! found )
318 mData->phoneNumbers.append( *phoneItAD ); 328 mData->phoneNumbers.append( *phoneItAD );
319 } 329 }
320 if ( isSubSet ) { 330 if ( isSubSet ) {
321 // ************* emails; 331 // ************* emails;
322 t = mData->emails; 332 t = mData->emails;
323 tAD = ad.mData->emails; 333 tAD = ad.mData->emails;
324 for ( iii = 0; iii < tAD.count(); ++iii) 334 for ( iii = 0; iii < tAD.count(); ++iii)
325 if ( !t.contains(tAD[iii] ) ) 335 if ( !t.contains(tAD[iii] ) )
326 mData->emails.append( tAD[iii] ); 336 mData->emails.append( tAD[iii] );
327 } 337 }
328 338
329 // ************* categories; 339 // ************* categories;
330 t = mData->categories; 340 t = mData->categories;
331 tAD = ad.mData->categories; 341 tAD = ad.mData->categories;
332 for ( iii = 0; iii < tAD.count(); ++iii) 342 for ( iii = 0; iii < tAD.count(); ++iii)
333 if ( !t.contains(tAD[iii] ) ) 343 if ( !t.contains(tAD[iii] ) )
334 mData->categories.append( tAD[iii] ); 344 mData->categories.append( tAD[iii] );
335 QStringList::ConstIterator it; 345 QStringList::ConstIterator it;
336 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 346 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
337 QString qualifiedName = (*it).left( (*it).find( ":" )); 347 QString qualifiedName = (*it).left( (*it).find( ":" ));
338 bool found = false; 348 bool found = false;
339 QStringList::ConstIterator itL; 349 QStringList::ConstIterator itL;
340 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 350 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
341 if ( (*itL).startsWith( qualifiedName ) ) { 351 if ( (*itL).startsWith( qualifiedName ) ) {
342 found = true; 352 found = true;
343 break; 353 break;
344 } 354 }
345 } 355 }
346 if ( ! found ) { 356 if ( ! found ) {
347 mData->custom.append( *it ); 357 mData->custom.append( *it );
348 } 358 }
349 } 359 }
350 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 360 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
351 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 361 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
352 if ( !mData->sound.isIntern() ) { 362 if ( !mData->sound.isIntern() ) {
353 if ( mData->sound.url().isEmpty() ) { 363 if ( mData->sound.url().isEmpty() ) {
354 mData->sound = ad.mData->sound; 364 mData->sound = ad.mData->sound;
355 } 365 }
356 } 366 }
357 if ( !mData->agent.isIntern() ) { 367 if ( !mData->agent.isIntern() ) {
358 if ( mData->agent.url().isEmpty() ) { 368 if ( mData->agent.url().isEmpty() ) {
359 mData->agent = ad.mData->agent; 369 mData->agent = ad.mData->agent;
360 } 370 }
361 } 371 }
362 { 372 {
363 Key::List::Iterator itA; 373 Key::List::Iterator itA;
364 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 374 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
365 bool found = false; 375 bool found = false;
366 Key::List::Iterator it; 376 Key::List::Iterator it;
367 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 377 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
368 if ( (*it) == (*itA)) { 378 if ( (*it) == (*itA)) {
369 found = true; 379 found = true;
370 break; 380 break;
371 381
372 } 382 }
373 } 383 }
374 if ( ! found ) { 384 if ( ! found ) {
375 mData->keys.append( *itA ); 385 mData->keys.append( *itA );
376 } 386 }
377 } 387 }
378 } 388 }
379 KABC::Address::List::Iterator addressIterA; 389 KABC::Address::List::Iterator addressIterA;
380 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 390 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
381 bool found = false; 391 bool found = false;
382 KABC::Address::List::Iterator addressIter; 392 KABC::Address::List::Iterator addressIter;
383 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 393 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
384 ++addressIter ) { 394 ++addressIter ) {
385 if ( (*addressIter) == (*addressIterA)) { 395 if ( (*addressIter) == (*addressIterA)) {
386 found = true; 396 found = true;
387 (*addressIter).setType( (*addressIterA).type() ); 397 (*addressIter).setType( (*addressIterA).type() );
388 break; 398 break;
389 } 399 }
390 400
391 } 401 }
392 if ( isSubSet && ! found ) { 402 if ( isSubSet && ! found ) {
393 mData->addresses.append( *addressIterA ); 403 mData->addresses.append( *addressIterA );
394 } 404 }
395 } 405 }
396 //qDebug("merge contact %s ", ad.uid().latin1()); 406 //qDebug("merge contact %s ", ad.uid().latin1());
397 setUid( ad.uid() ); 407 setUid( ad.uid() );
398 setRevision( ad.revision() ); 408 setRevision( ad.revision() );
399} 409}
400 410
401bool Addressee::removeVoice() 411bool Addressee::removeVoice()
402{ 412{
403 PhoneNumber::List phoneN = phoneNumbers(); 413 PhoneNumber::List phoneN = phoneNumbers();
404 PhoneNumber::List::Iterator phoneIt; 414 PhoneNumber::List::Iterator phoneIt;
405 bool found = false; 415 bool found = false;
406 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 416 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
407 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 417 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
408 if ((*phoneIt).type() - PhoneNumber::Voice ) { 418 if ((*phoneIt).type() - PhoneNumber::Voice ) {
409 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 419 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
410 insertPhoneNumber( (*phoneIt) ); 420 insertPhoneNumber( (*phoneIt) );
411 found = true; 421 found = true;
412 } 422 }
413 } 423 }
414 424
415 } 425 }
416 return found; 426 return found;
417} 427}
418 428
419bool Addressee::containsAdr(const Addressee& ad ) 429bool Addressee::containsAdr(const Addressee& ad )
420{ 430{
421 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 431 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
422 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 432 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
423 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 433 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
424 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 434 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
425 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 435 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
426 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 436 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
427 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 437 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
428 438
429 // compare phone numbers 439 // compare phone numbers
430 PhoneNumber::List phoneN = ad.phoneNumbers(); 440 PhoneNumber::List phoneN = ad.phoneNumbers();
431 PhoneNumber::List::Iterator phoneIt; 441 PhoneNumber::List::Iterator phoneIt;
432 bool found = false; 442 bool found = false;
433 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 443 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
434 bool found = false; 444 bool found = false;
435 PhoneNumber::List phoneL = ad.phoneNumbers(); 445 PhoneNumber::List phoneL = ad.phoneNumbers();
436 PhoneNumber::List::Iterator phoneItL; 446 PhoneNumber::List::Iterator phoneItL;
437 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 447 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
438 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 448 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
439 found = true; 449 found = true;
440 break; 450 break;
441 } 451 }
442 } 452 }
443 if ( ! found ) 453 if ( ! found )
444 return false; 454 return false;
445 } 455 }
446 return true; 456 return true;
447 457
448} 458}
449void Addressee::simplifyAddresses() 459void Addressee::simplifyAddresses()
450{ 460{
451 461
452 462
453 Address::List list; 463 Address::List list;
454 Address::List::Iterator it; 464 Address::List::Iterator it;
455 Address::List::Iterator it2; 465 Address::List::Iterator it2;
456 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 466 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
457 it2 = it; 467 it2 = it;
458 ++it2; 468 ++it2;
459 for( ; it2 != mData->addresses.end(); ++it2 ) { 469 for( ; it2 != mData->addresses.end(); ++it2 ) {
460 if ( (*it) == (*it2) ) { 470 if ( (*it) == (*it2) ) {
461 list.append( *it ); 471 list.append( *it );
462 break; 472 break;
463 } 473 }
464 } 474 }
465 } 475 }
466 for( it = list.begin(); it != list.end(); ++it ) { 476 for( it = list.begin(); it != list.end(); ++it ) {
467 removeAddress( (*it) ); 477 removeAddress( (*it) );
468 } 478 }
469 479
470 list.clear(); 480 list.clear();
471 int max = 2; 481 int max = 2;
472 if ( mData->url.isValid() ) 482 if ( mData->url.isValid() )
473 max = 1; 483 max = 1;
474 if ( mData->addresses.count() <= max ) return ; 484 if ( mData->addresses.count() <= max ) return ;
475 int count = 0; 485 int count = 0;
476 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 486 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
477 if ( count >= max ) 487 if ( count >= max )
478 list.append( *it ); 488 list.append( *it );
479 ++count; 489 ++count;
480 } 490 }
481 for( it = list.begin(); it != list.end(); ++it ) { 491 for( it = list.begin(); it != list.end(); ++it ) {
482 removeAddress( (*it) ); 492 removeAddress( (*it) );
483 } 493 }
484} 494}
485 495
486// removes all emails but the first 496// removes all emails but the first
487// needed by phone sync 497// needed by phone sync
488void Addressee::simplifyEmails() 498void Addressee::simplifyEmails()
489{ 499{
490 if ( mData->emails.count() == 0 ) return ; 500 if ( mData->emails.count() == 0 ) return ;
491 QString email = mData->emails.first(); 501 QString email = mData->emails.first();
492 detach(); 502 detach();
493 mData->emails.clear(); 503 mData->emails.clear();
494 mData->emails.append( email ); 504 mData->emails.append( email );
495} 505}
496 506
497void Addressee::simplifyPhoneNumbers() 507void Addressee::simplifyPhoneNumbers()
498{ 508{
499 int max = 4; 509 int max = 4;
500 int inList = mData->phoneNumbers.count(); 510 int inList = mData->phoneNumbers.count();
501 KABC::PhoneNumber::List removeNumbers; 511 KABC::PhoneNumber::List removeNumbers;
502 KABC::PhoneNumber::List::Iterator phoneIter; 512 KABC::PhoneNumber::List::Iterator phoneIter;
503 if ( inList > max ) { 513 if ( inList > max ) {
504 // delete non-preferred numbers 514 // delete non-preferred numbers
505 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 515 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
506 ++phoneIter ) { 516 ++phoneIter ) {
507 if ( inList > max ) { 517 if ( inList > max ) {
508 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 518 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
509 removeNumbers.append( ( *phoneIter ) ); 519 removeNumbers.append( ( *phoneIter ) );
510 --inList; 520 --inList;
511 } 521 }
512 } else 522 } else
513 break; 523 break;
514 } 524 }
515 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 525 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
516 ++phoneIter ) { 526 ++phoneIter ) {
517 removePhoneNumber(( *phoneIter )); 527 removePhoneNumber(( *phoneIter ));
518 } 528 }
519 // delete preferred numbers 529 // delete preferred numbers
520 if ( inList > max ) { 530 if ( inList > max ) {
521 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 531 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
522 ++phoneIter ) { 532 ++phoneIter ) {
523 if ( inList > max ) { 533 if ( inList > max ) {
524 removeNumbers.append( ( *phoneIter ) ); 534 removeNumbers.append( ( *phoneIter ) );
525 --inList; 535 --inList;
@@ -858,513 +868,516 @@ QString Addressee::homeAddressLabelLabel()
858{ 868{
859 return i18n("Home Address Label"); 869 return i18n("Home Address Label");
860} 870}
861 871
862 872
863QString Addressee::businessAddressStreetLabel() 873QString Addressee::businessAddressStreetLabel()
864{ 874{
865 return i18n("Business Address Street"); 875 return i18n("Business Address Street");
866} 876}
867 877
868 878
869QString Addressee::businessAddressLocalityLabel() 879QString Addressee::businessAddressLocalityLabel()
870{ 880{
871 return i18n("Business Address Locality"); 881 return i18n("Business Address Locality");
872} 882}
873 883
874 884
875QString Addressee::businessAddressRegionLabel() 885QString Addressee::businessAddressRegionLabel()
876{ 886{
877 return i18n("Business Address Region"); 887 return i18n("Business Address Region");
878} 888}
879 889
880 890
881QString Addressee::businessAddressPostalCodeLabel() 891QString Addressee::businessAddressPostalCodeLabel()
882{ 892{
883 return i18n("Business Address Postal Code"); 893 return i18n("Business Address Postal Code");
884} 894}
885 895
886 896
887QString Addressee::businessAddressCountryLabel() 897QString Addressee::businessAddressCountryLabel()
888{ 898{
889 return i18n("Business Address Country"); 899 return i18n("Business Address Country");
890} 900}
891 901
892 902
893QString Addressee::businessAddressLabelLabel() 903QString Addressee::businessAddressLabelLabel()
894{ 904{
895 return i18n("Business Address Label"); 905 return i18n("Business Address Label");
896} 906}
897 907
898 908
899QString Addressee::homePhoneLabel() 909QString Addressee::homePhoneLabel()
900{ 910{
901 return i18n("Home Phone"); 911 return i18n("Home Phone");
902} 912}
903 913
904 914
905QString Addressee::businessPhoneLabel() 915QString Addressee::businessPhoneLabel()
906{ 916{
907 return i18n("Business Phone"); 917 return i18n("Business Phone");
908} 918}
909 919
910 920
911QString Addressee::mobilePhoneLabel() 921QString Addressee::mobilePhoneLabel()
912{ 922{
913 return i18n("Mobile Phone"); 923 return i18n("Mobile Phone");
914} 924}
915 925
916 926
917QString Addressee::homeFaxLabel() 927QString Addressee::homeFaxLabel()
918{ 928{
919 return i18n("Home Fax"); 929 return i18n("Home Fax");
920} 930}
921 931
922 932
923QString Addressee::businessFaxLabel() 933QString Addressee::businessFaxLabel()
924{ 934{
925 return i18n("Business Fax"); 935 return i18n("Business Fax");
926} 936}
927 937
928 938
929QString Addressee::carPhoneLabel() 939QString Addressee::carPhoneLabel()
930{ 940{
931 return i18n("Car Phone"); 941 return i18n("Car Phone");
932} 942}
933 943
934 944
935QString Addressee::isdnLabel() 945QString Addressee::isdnLabel()
936{ 946{
937 return i18n("ISDN"); 947 return i18n("ISDN");
938} 948}
939 949
940 950
941QString Addressee::pagerLabel() 951QString Addressee::pagerLabel()
942{ 952{
943 return i18n("Pager"); 953 return i18n("Pager");
944} 954}
945 955
946QString Addressee::sipLabel() 956QString Addressee::sipLabel()
947{ 957{
948 return i18n("SIP"); 958 return i18n("SIP");
949} 959}
950 960
951QString Addressee::emailLabel() 961QString Addressee::emailLabel()
952{ 962{
953 return i18n("Email Address"); 963 return i18n("Email Address");
954} 964}
955 965
956 966
957void Addressee::setMailer( const QString &mailer ) 967void Addressee::setMailer( const QString &mailer )
958{ 968{
959 if ( mailer == mData->mailer ) return; 969 if ( mailer == mData->mailer ) return;
960 detach(); 970 detach();
961 mData->empty = false; 971 mData->empty = false;
962 mData->mailer = mailer; 972 mData->mailer = mailer;
963} 973}
964 974
965QString Addressee::mailer() const 975QString Addressee::mailer() const
966{ 976{
967 return mData->mailer; 977 return mData->mailer;
968} 978}
969 979
970QString Addressee::mailerLabel() 980QString Addressee::mailerLabel()
971{ 981{
972 return i18n("Mail Client"); 982 return i18n("Mail Client");
973} 983}
974 984
975 985
976void Addressee::setTimeZone( const TimeZone &timeZone ) 986void Addressee::setTimeZone( const TimeZone &timeZone )
977{ 987{
978 if ( timeZone == mData->timeZone ) return; 988 if ( timeZone == mData->timeZone ) return;
979 detach(); 989 detach();
980 mData->empty = false; 990 mData->empty = false;
981 mData->timeZone = timeZone; 991 mData->timeZone = timeZone;
982} 992}
983 993
984TimeZone Addressee::timeZone() const 994TimeZone Addressee::timeZone() const
985{ 995{
986 return mData->timeZone; 996 return mData->timeZone;
987} 997}
988 998
989QString Addressee::timeZoneLabel() 999QString Addressee::timeZoneLabel()
990{ 1000{
991 return i18n("Time Zone"); 1001 return i18n("Time Zone");
992} 1002}
993 1003
994 1004
995void Addressee::setGeo( const Geo &geo ) 1005void Addressee::setGeo( const Geo &geo )
996{ 1006{
997 if ( geo == mData->geo ) return; 1007 if ( geo == mData->geo ) return;
998 detach(); 1008 detach();
999 mData->empty = false; 1009 mData->empty = false;
1000 mData->geo = geo; 1010 mData->geo = geo;
1001} 1011}
1002 1012
1003Geo Addressee::geo() const 1013Geo Addressee::geo() const
1004{ 1014{
1005 return mData->geo; 1015 return mData->geo;
1006} 1016}
1007 1017
1008QString Addressee::geoLabel() 1018QString Addressee::geoLabel()
1009{ 1019{
1010 return i18n("Geographic Position"); 1020 return i18n("Geographic Position");
1011} 1021}
1012 1022
1013 1023
1014void Addressee::setTitle( const QString &title ) 1024void Addressee::setTitle( const QString &title )
1015{ 1025{
1016 if ( title == mData->title ) return; 1026 if ( title == mData->title ) return;
1017 detach(); 1027 detach();
1018 mData->empty = false; 1028 mData->empty = false;
1019 mData->title = title; 1029 mData->title = title;
1020} 1030}
1021 1031
1022QString Addressee::title() const 1032QString Addressee::title() const
1023{ 1033{
1024 return mData->title; 1034 return mData->title;
1025} 1035}
1026 1036
1027QString Addressee::titleLabel() 1037QString Addressee::titleLabel()
1028{ 1038{
1029 return i18n("Title"); 1039 return i18n("Title");
1030} 1040}
1031 1041
1032 1042
1033void Addressee::setRole( const QString &role ) 1043void Addressee::setRole( const QString &role )
1034{ 1044{
1035 if ( role == mData->role ) return; 1045 if ( role == mData->role ) return;
1036 detach(); 1046 detach();
1037 mData->empty = false; 1047 mData->empty = false;
1038 mData->role = role; 1048 mData->role = role;
1039} 1049}
1040 1050
1041QString Addressee::role() const 1051QString Addressee::role() const
1042{ 1052{
1043 return mData->role; 1053 return mData->role;
1044} 1054}
1045 1055
1046QString Addressee::roleLabel() 1056QString Addressee::roleLabel()
1047{ 1057{
1048 return i18n("Role"); 1058 return i18n("Role");
1049} 1059}
1050 1060
1051 1061
1052void Addressee::setOrganization( const QString &organization ) 1062void Addressee::setOrganization( const QString &organization )
1053{ 1063{
1054 if ( organization == mData->organization ) return; 1064 if ( organization == mData->organization ) return;
1055 detach(); 1065 detach();
1056 mData->empty = false; 1066 mData->empty = false;
1057 mData->organization = organization; 1067 mData->organization = organization;
1058} 1068}
1059 1069
1060QString Addressee::organization() const 1070QString Addressee::organization() const
1061{ 1071{
1062 return mData->organization; 1072 return mData->organization;
1063} 1073}
1064 1074
1065QString Addressee::organizationLabel() 1075QString Addressee::organizationLabel()
1066{ 1076{
1067 return i18n("Organization"); 1077 return i18n("Organization");
1068} 1078}
1069 1079
1070 1080
1071void Addressee::setNote( const QString &note ) 1081void Addressee::setNote( const QString &note )
1072{ 1082{
1073 if ( note == mData->note ) return; 1083 if ( note == mData->note ) return;
1074 detach(); 1084 detach();
1075 mData->empty = false; 1085 mData->empty = false;
1076 mData->note = note; 1086 mData->note = note;
1077} 1087}
1078 1088
1079QString Addressee::note() const 1089QString Addressee::note() const
1080{ 1090{
1081 return mData->note; 1091 return mData->note;
1082} 1092}
1083 1093
1084QString Addressee::noteLabel() 1094QString Addressee::noteLabel()
1085{ 1095{
1086 return i18n("Note"); 1096 return i18n("Note");
1087} 1097}
1088 1098
1089 1099
1090void Addressee::setProductId( const QString &productId ) 1100void Addressee::setProductId( const QString &productId )
1091{ 1101{
1092 if ( productId == mData->productId ) return; 1102 if ( productId == mData->productId ) return;
1093 detach(); 1103 detach();
1094 mData->empty = false; 1104 mData->empty = false;
1095 mData->productId = productId; 1105 mData->productId = productId;
1096} 1106}
1097 1107
1098QString Addressee::productId() const 1108QString Addressee::productId() const
1099{ 1109{
1100 return mData->productId; 1110 return mData->productId;
1101} 1111}
1102 1112
1103QString Addressee::productIdLabel() 1113QString Addressee::productIdLabel()
1104{ 1114{
1105 return i18n("Product Identifier"); 1115 return i18n("Product Identifier");
1106} 1116}
1107 1117
1108 1118
1109void Addressee::setRevision( const QDateTime &revision ) 1119void Addressee::setRevision( const QDateTime &revision )
1110{ 1120{
1111 if ( revision == mData->revision ) return; 1121 if ( revision == mData->revision ) return;
1112 detach(); 1122 detach();
1113 mData->empty = false; 1123 mData->empty = false;
1114 mData->revision = revision; 1124 mData->revision = QDateTime( revision.date(),
1125 QTime (revision.time().hour(),
1126 revision.time().minute(),
1127 revision.time().second()));
1115} 1128}
1116 1129
1117QDateTime Addressee::revision() const 1130QDateTime Addressee::revision() const
1118{ 1131{
1119 return mData->revision; 1132 return mData->revision;
1120} 1133}
1121 1134
1122QString Addressee::revisionLabel() 1135QString Addressee::revisionLabel()
1123{ 1136{
1124 return i18n("Revision Date"); 1137 return i18n("Revision Date");
1125} 1138}
1126 1139
1127 1140
1128void Addressee::setSortString( const QString &sortString ) 1141void Addressee::setSortString( const QString &sortString )
1129{ 1142{
1130 if ( sortString == mData->sortString ) return; 1143 if ( sortString == mData->sortString ) return;
1131 detach(); 1144 detach();
1132 mData->empty = false; 1145 mData->empty = false;
1133 mData->sortString = sortString; 1146 mData->sortString = sortString;
1134} 1147}
1135 1148
1136QString Addressee::sortString() const 1149QString Addressee::sortString() const
1137{ 1150{
1138 return mData->sortString; 1151 return mData->sortString;
1139} 1152}
1140 1153
1141QString Addressee::sortStringLabel() 1154QString Addressee::sortStringLabel()
1142{ 1155{
1143 return i18n("Sort String"); 1156 return i18n("Sort String");
1144} 1157}
1145 1158
1146 1159
1147void Addressee::setUrl( const KURL &url ) 1160void Addressee::setUrl( const KURL &url )
1148{ 1161{
1149 if ( url == mData->url ) return; 1162 if ( url == mData->url ) return;
1150 detach(); 1163 detach();
1151 mData->empty = false; 1164 mData->empty = false;
1152 mData->url = url; 1165 mData->url = url;
1153} 1166}
1154 1167
1155KURL Addressee::url() const 1168KURL Addressee::url() const
1156{ 1169{
1157 return mData->url; 1170 return mData->url;
1158} 1171}
1159 1172
1160QString Addressee::urlLabel() 1173QString Addressee::urlLabel()
1161{ 1174{
1162 return i18n("URL"); 1175 return i18n("URL");
1163} 1176}
1164 1177
1165 1178
1166void Addressee::setSecrecy( const Secrecy &secrecy ) 1179void Addressee::setSecrecy( const Secrecy &secrecy )
1167{ 1180{
1168 if ( secrecy == mData->secrecy ) return; 1181 if ( secrecy == mData->secrecy ) return;
1169 detach(); 1182 detach();
1170 mData->empty = false; 1183 mData->empty = false;
1171 mData->secrecy = secrecy; 1184 mData->secrecy = secrecy;
1172} 1185}
1173 1186
1174Secrecy Addressee::secrecy() const 1187Secrecy Addressee::secrecy() const
1175{ 1188{
1176 return mData->secrecy; 1189 return mData->secrecy;
1177} 1190}
1178 1191
1179QString Addressee::secrecyLabel() 1192QString Addressee::secrecyLabel()
1180{ 1193{
1181 return i18n("Security Class"); 1194 return i18n("Security Class");
1182} 1195}
1183 1196
1184 1197
1185void Addressee::setLogo( const Picture &logo ) 1198void Addressee::setLogo( const Picture &logo )
1186{ 1199{
1187 if ( logo == mData->logo ) return; 1200 if ( logo == mData->logo ) return;
1188 detach(); 1201 detach();
1189 mData->empty = false; 1202 mData->empty = false;
1190 mData->logo = logo; 1203 mData->logo = logo;
1191} 1204}
1192 1205
1193Picture Addressee::logo() const 1206Picture Addressee::logo() const
1194{ 1207{
1195 return mData->logo; 1208 return mData->logo;
1196} 1209}
1197 1210
1198QString Addressee::logoLabel() 1211QString Addressee::logoLabel()
1199{ 1212{
1200 return i18n("Logo"); 1213 return i18n("Logo");
1201} 1214}
1202 1215
1203 1216
1204void Addressee::setPhoto( const Picture &photo ) 1217void Addressee::setPhoto( const Picture &photo )
1205{ 1218{
1206 if ( photo == mData->photo ) return; 1219 if ( photo == mData->photo ) return;
1207 detach(); 1220 detach();
1208 mData->empty = false; 1221 mData->empty = false;
1209 mData->photo = photo; 1222 mData->photo = photo;
1210} 1223}
1211 1224
1212Picture Addressee::photo() const 1225Picture Addressee::photo() const
1213{ 1226{
1214 return mData->photo; 1227 return mData->photo;
1215} 1228}
1216 1229
1217QString Addressee::photoLabel() 1230QString Addressee::photoLabel()
1218{ 1231{
1219 return i18n("Photo"); 1232 return i18n("Photo");
1220} 1233}
1221 1234
1222 1235
1223void Addressee::setSound( const Sound &sound ) 1236void Addressee::setSound( const Sound &sound )
1224{ 1237{
1225 if ( sound == mData->sound ) return; 1238 if ( sound == mData->sound ) return;
1226 detach(); 1239 detach();
1227 mData->empty = false; 1240 mData->empty = false;
1228 mData->sound = sound; 1241 mData->sound = sound;
1229} 1242}
1230 1243
1231Sound Addressee::sound() const 1244Sound Addressee::sound() const
1232{ 1245{
1233 return mData->sound; 1246 return mData->sound;
1234} 1247}
1235 1248
1236QString Addressee::soundLabel() 1249QString Addressee::soundLabel()
1237{ 1250{
1238 return i18n("Sound"); 1251 return i18n("Sound");
1239} 1252}
1240 1253
1241 1254
1242void Addressee::setAgent( const Agent &agent ) 1255void Addressee::setAgent( const Agent &agent )
1243{ 1256{
1244 if ( agent == mData->agent ) return; 1257 if ( agent == mData->agent ) return;
1245 detach(); 1258 detach();
1246 mData->empty = false; 1259 mData->empty = false;
1247 mData->agent = agent; 1260 mData->agent = agent;
1248} 1261}
1249 1262
1250Agent Addressee::agent() const 1263Agent Addressee::agent() const
1251{ 1264{
1252 return mData->agent; 1265 return mData->agent;
1253} 1266}
1254 1267
1255QString Addressee::agentLabel() 1268QString Addressee::agentLabel()
1256{ 1269{
1257 return i18n("Agent"); 1270 return i18n("Agent");
1258} 1271}
1259 1272
1260 1273
1261 1274
1262void Addressee::setNameFromString( const QString &str ) 1275void Addressee::setNameFromString( const QString &str )
1263{ 1276{
1264 setFormattedName( str ); 1277 setFormattedName( str );
1265 setName( str ); 1278 setName( str );
1266 1279
1267 static bool first = true; 1280 static bool first = true;
1268 static QStringList titles; 1281 static QStringList titles;
1269 static QStringList suffixes; 1282 static QStringList suffixes;
1270 static QStringList prefixes; 1283 static QStringList prefixes;
1271 1284
1272 if ( first ) { 1285 if ( first ) {
1273 first = false; 1286 first = false;
1274 titles += i18n( "Dr." ); 1287 titles += i18n( "Dr." );
1275 titles += i18n( "Miss" ); 1288 titles += i18n( "Miss" );
1276 titles += i18n( "Mr." ); 1289 titles += i18n( "Mr." );
1277 titles += i18n( "Mrs." ); 1290 titles += i18n( "Mrs." );
1278 titles += i18n( "Ms." ); 1291 titles += i18n( "Ms." );
1279 titles += i18n( "Prof." ); 1292 titles += i18n( "Prof." );
1280 1293
1281 suffixes += i18n( "I" ); 1294 suffixes += i18n( "I" );
1282 suffixes += i18n( "II" ); 1295 suffixes += i18n( "II" );
1283 suffixes += i18n( "III" ); 1296 suffixes += i18n( "III" );
1284 suffixes += i18n( "Jr." ); 1297 suffixes += i18n( "Jr." );
1285 suffixes += i18n( "Sr." ); 1298 suffixes += i18n( "Sr." );
1286 1299
1287 prefixes += "van"; 1300 prefixes += "van";
1288 prefixes += "von"; 1301 prefixes += "von";
1289 prefixes += "de"; 1302 prefixes += "de";
1290 1303
1291 KConfig config( locateLocal( "config", "kabcrc") ); 1304 KConfig config( locateLocal( "config", "kabcrc") );
1292 config.setGroup( "General" ); 1305 config.setGroup( "General" );
1293 titles += config.readListEntry( "Prefixes" ); 1306 titles += config.readListEntry( "Prefixes" );
1294 titles.remove( "" ); 1307 titles.remove( "" );
1295 prefixes += config.readListEntry( "Inclusions" ); 1308 prefixes += config.readListEntry( "Inclusions" );
1296 prefixes.remove( "" ); 1309 prefixes.remove( "" );
1297 suffixes += config.readListEntry( "Suffixes" ); 1310 suffixes += config.readListEntry( "Suffixes" );
1298 suffixes.remove( "" ); 1311 suffixes.remove( "" );
1299 } 1312 }
1300 1313
1301 // clear all name parts 1314 // clear all name parts
1302 setPrefix( "" ); 1315 setPrefix( "" );
1303 setGivenName( "" ); 1316 setGivenName( "" );
1304 setAdditionalName( "" ); 1317 setAdditionalName( "" );
1305 setFamilyName( "" ); 1318 setFamilyName( "" );
1306 setSuffix( "" ); 1319 setSuffix( "" );
1307 1320
1308 if ( str.isEmpty() ) 1321 if ( str.isEmpty() )
1309 return; 1322 return;
1310 1323
1311 int i = str.find(','); 1324 int i = str.find(',');
1312 if( i < 0 ) { 1325 if( i < 0 ) {
1313 QStringList parts = QStringList::split( " ", str ); 1326 QStringList parts = QStringList::split( " ", str );
1314 int leftOffset = 0; 1327 int leftOffset = 0;
1315 int rightOffset = parts.count() - 1; 1328 int rightOffset = parts.count() - 1;
1316 1329
1317 QString suffix; 1330 QString suffix;
1318 while ( rightOffset >= 0 ) { 1331 while ( rightOffset >= 0 ) {
1319 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1332 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1320 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1333 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1321 rightOffset--; 1334 rightOffset--;
1322 } else 1335 } else
1323 break; 1336 break;
1324 } 1337 }
1325 setSuffix( suffix ); 1338 setSuffix( suffix );
1326 1339
1327 if ( rightOffset < 0 ) 1340 if ( rightOffset < 0 )
1328 return; 1341 return;
1329 1342
1330 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1343 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1331 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1344 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1332 rightOffset--; 1345 rightOffset--;
1333 } else 1346 } else
1334 setFamilyName( parts[ rightOffset ] ); 1347 setFamilyName( parts[ rightOffset ] );
1335 1348
1336 QString prefix; 1349 QString prefix;
1337 while ( leftOffset < rightOffset ) { 1350 while ( leftOffset < rightOffset ) {
1338 if ( titles.contains( parts[ leftOffset ] ) ) { 1351 if ( titles.contains( parts[ leftOffset ] ) ) {
1339 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1352 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1340 leftOffset++; 1353 leftOffset++;
1341 } else 1354 } else
1342 break; 1355 break;
1343 } 1356 }
1344 setPrefix( prefix ); 1357 setPrefix( prefix );
1345 1358
1346 if ( leftOffset < rightOffset ) { 1359 if ( leftOffset < rightOffset ) {
1347 setGivenName( parts[ leftOffset ] ); 1360 setGivenName( parts[ leftOffset ] );
1348 leftOffset++; 1361 leftOffset++;
1349 } 1362 }
1350 1363
1351 QString additionalName; 1364 QString additionalName;
1352 while ( leftOffset < rightOffset ) { 1365 while ( leftOffset < rightOffset ) {
1353 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1366 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1354 leftOffset++; 1367 leftOffset++;
1355 } 1368 }
1356 setAdditionalName( additionalName ); 1369 setAdditionalName( additionalName );
1357 } else { 1370 } else {
1358 QString part1 = str.left( i ); 1371 QString part1 = str.left( i );
1359 QString part2 = str.mid( i + 1 ); 1372 QString part2 = str.mid( i + 1 );
1360 1373
1361 QStringList parts = QStringList::split( " ", part1 ); 1374 QStringList parts = QStringList::split( " ", part1 );
1362 int leftOffset = 0; 1375 int leftOffset = 0;
1363 int rightOffset = parts.count() - 1; 1376 int rightOffset = parts.count() - 1;
1364 1377
1365 QString suffix; 1378 QString suffix;
1366 while ( rightOffset >= 0 ) { 1379 while ( rightOffset >= 0 ) {
1367 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1380 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1368 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1381 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1369 rightOffset--; 1382 rightOffset--;
1370 } else 1383 } else
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
index 012780b..3397e06 100644
--- a/kaddressbook/addresseeeditorwidget.cpp
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -807,513 +807,515 @@ void AddresseeEditorWidget::setupTab2_1()
807 layout->addWidget( label, 5, 1 ); 807 layout->addWidget( label, 5, 1 );
808 mSpouseEdit = new KLineEdit( tab2 ); 808 mSpouseEdit = new KLineEdit( tab2 );
809 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), 809 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
810 SLOT( textChanged( const QString& ) ) ); 810 SLOT( textChanged( const QString& ) ) );
811 label->setBuddy( mSpouseEdit ); 811 label->setBuddy( mSpouseEdit );
812 layout->addWidget( mSpouseEdit, 5, 2 ); 812 layout->addWidget( mSpouseEdit, 5, 2 );
813 813
814 label = new QLabel( i18n( "Birthday:" ), tab2 ); 814 label = new QLabel( i18n( "Birthday:" ), tab2 );
815 layout->addWidget( label, 4, 3 ); 815 layout->addWidget( label, 4, 3 );
816 mBirthdayPicker = new KDateEdit( tab2 ); 816 mBirthdayPicker = new KDateEdit( tab2 );
817 mBirthdayPicker->setHandleInvalid( true ); 817 mBirthdayPicker->setHandleInvalid( true );
818 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), 818 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ),
819 SLOT( dateChanged( QDate ) ) ); 819 SLOT( dateChanged( QDate ) ) );
820 connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), 820 connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ),
821 SLOT( invalidDate() ) ); 821 SLOT( invalidDate() ) );
822 connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), 822 connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ),
823 SLOT( emitModified() ) ); 823 SLOT( emitModified() ) );
824 label->setBuddy( mBirthdayPicker ); 824 label->setBuddy( mBirthdayPicker );
825 layout->addWidget( mBirthdayPicker, 4, 4 ); 825 layout->addWidget( mBirthdayPicker, 4, 4 );
826 826
827 label = new QLabel( i18n( "Anniversary:" ), tab2 ); 827 label = new QLabel( i18n( "Anniversary:" ), tab2 );
828 layout->addWidget( label, 5, 3 ); 828 layout->addWidget( label, 5, 3 );
829 mAnniversaryPicker = new KDateEdit( tab2 ); 829 mAnniversaryPicker = new KDateEdit( tab2 );
830 mAnniversaryPicker->setHandleInvalid( true ); 830 mAnniversaryPicker->setHandleInvalid( true );
831 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), 831 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ),
832 SLOT( dateChanged( QDate ) ) ); 832 SLOT( dateChanged( QDate ) ) );
833 connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), 833 connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ),
834 SLOT( invalidDate() ) ); 834 SLOT( invalidDate() ) );
835 connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), 835 connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ),
836 SLOT( emitModified() ) ); 836 SLOT( emitModified() ) );
837 label->setBuddy( mAnniversaryPicker ); 837 label->setBuddy( mAnniversaryPicker );
838 layout->addWidget( mAnniversaryPicker, 5, 4 ); 838 layout->addWidget( mAnniversaryPicker, 5, 4 );
839 839
840 bar = new KSeparator( KSeparator::HLine, tab2 ); 840 bar = new KSeparator( KSeparator::HLine, tab2 );
841 layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); 841 layout->addMultiCellWidget( bar, 6, 6, 0, 5 );
842*/ 842*/
843 ////////////////////////////////////// 843 //////////////////////////////////////
844 // Notes 844 // Notes
845 label = new QLabel( i18n( "Note:" ), tab2_2 ); 845 label = new QLabel( i18n( "Note:" ), tab2_2 );
846 label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); 846 label->setAlignment( Qt::AlignTop | Qt::AlignLeft );
847//US layout->addWidget( label, 7, 0 ); 847//US layout->addWidget( label, 7, 0 );
848 layout->addWidget( label, 0, 0 ); 848 layout->addWidget( label, 0, 0 );
849#ifndef KAB_EMBEDDED 849#ifndef KAB_EMBEDDED
850 mNoteEdit = new QTextEdit( tab2_2 ); 850 mNoteEdit = new QTextEdit( tab2_2 );
851 mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); 851 mNoteEdit->setWordWrap( QTextEdit::WidgetWidth );
852 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); 852 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() );
853#else //KAB_EMBEDDED 853#else //KAB_EMBEDDED
854 mNoteEdit = new QMultiLineEdit( tab2_2 ); 854 mNoteEdit = new QMultiLineEdit( tab2_2 );
855 mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth ); 855 mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth );
856 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); 856 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() );
857#endif //KAB_EMBEDDED 857#endif //KAB_EMBEDDED
858 858
859 connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); 859 connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) );
860 label->setBuddy( mNoteEdit ); 860 label->setBuddy( mNoteEdit );
861//US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); 861//US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 );
862 layout->addWidget( mNoteEdit, 1, 0); 862 layout->addWidget( mNoteEdit, 1, 0);
863 863
864 // Build the layout and add to the tab widget 864 // Build the layout and add to the tab widget
865 layout->activate(); // required 865 layout->activate(); // required
866 866
867 mTabWidget->addTab( tab2_2, i18n( "&Notes" ) ); 867 mTabWidget->addTab( tab2_2, i18n( "&Notes" ) );
868} 868}
869 869
870 870
871 871
872void AddresseeEditorWidget::setupTab3() 872void AddresseeEditorWidget::setupTab3()
873{ 873{
874 // This is the Misc tab 874 // This is the Misc tab
875 QWidget *tab3 = new QWidget( mTabWidget ); 875 QWidget *tab3 = new QWidget( mTabWidget );
876 876
877 QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); 877 QGridLayout *layout = new QGridLayout( tab3, 1, 1 );
878 layout->setMargin( KDialogBase::marginHintSmall() ); 878 layout->setMargin( KDialogBase::marginHintSmall() );
879 layout->setSpacing( KDialogBase::spacingHintSmall() ); 879 layout->setSpacing( KDialogBase::spacingHintSmall() );
880//US layout->setColStretch( 2, 1 ); 880//US layout->setColStretch( 2, 1 );
881 881
882 ////////////////////////////////////// 882 //////////////////////////////////////
883 // Geo 883 // Geo
884 mGeoWidget = new GeoWidget( tab3 ); 884 mGeoWidget = new GeoWidget( tab3 );
885 // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); 885 // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() );
886 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 886 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
887 layout->addWidget( mGeoWidget, 0, 0 ); 887 layout->addWidget( mGeoWidget, 0, 0 );
888/*US 888/*US
889 ////////////////////////////////////// 889 //////////////////////////////////////
890 // Sound 890 // Sound
891#ifndef KAB_EMBEDDED 891#ifndef KAB_EMBEDDED
892 mSoundWidget = new SoundWidget( tab3 ); 892 mSoundWidget = new SoundWidget( tab3 );
893 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); 893 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() );
894 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 894 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
895 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); 895 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop );
896#else //KAB_EMBEDDED 896#else //KAB_EMBEDDED
897qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); 897qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed");
898#endif //KAB_EMBEDDED 898#endif //KAB_EMBEDDED
899 899
900 ////////////////////////////////////// 900 //////////////////////////////////////
901 // Images 901 // Images
902 mImageWidget = new ImageWidget( tab3 ); 902 mImageWidget = new ImageWidget( tab3 );
903 mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); 903 mImageWidget->setMinimumSize( mImageWidget->sizeHint() );
904 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 904 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
905 layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop ); 905 layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop );
906*/ 906*/
907//US 907//US
908/* 908/*
909 KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 ); 909 KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 );
910 layout->addMultiCellWidget( bar, 1, 1, 0, 0 ); 910 layout->addMultiCellWidget( bar, 1, 1, 0, 0 );
911*/ 911*/
912 ////////////////////////////////////// 912 //////////////////////////////////////
913 // Keys 913 // Keys
914 mKeyWidget = new KeyWidget( tab3 ); 914 mKeyWidget = new KeyWidget( tab3 );
915 //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); 915 //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() );
916 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 916 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
917//US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); 917//US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop );
918 layout->addWidget( mKeyWidget, 1, 0 ); 918 layout->addWidget( mKeyWidget, 1, 0 );
919 919
920 mTabWidget->addTab( tab3, i18n( "&Misc" ) ); 920 mTabWidget->addTab( tab3, i18n( "&Misc" ) );
921} 921}
922 922
923void AddresseeEditorWidget::setupTab3_1() 923void AddresseeEditorWidget::setupTab3_1()
924{ 924{
925 // This is the Misc tab 925 // This is the Misc tab
926 QWidget *tab3 = new QWidget( mTabWidget ); 926 QWidget *tab3 = new QWidget( mTabWidget );
927 927
928//US QGridLayout *layout = new QGridLayout( tab3, 2, 3 ); 928//US QGridLayout *layout = new QGridLayout( tab3, 2, 3 );
929 QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); 929 QGridLayout *layout = new QGridLayout( tab3, 1, 1 );
930 layout->setMargin( KDialogBase::marginHint() ); 930 layout->setMargin( KDialogBase::marginHint() );
931 layout->setSpacing( KDialogBase::spacingHint() ); 931 layout->setSpacing( KDialogBase::spacingHint() );
932//US layout->setColStretch( 2, 1 ); 932//US layout->setColStretch( 2, 1 );
933 933
934/*US 934/*US
935 ////////////////////////////////////// 935 //////////////////////////////////////
936 // Geo 936 // Geo
937 mGeoWidget = new GeoWidget( tab3 ); 937 mGeoWidget = new GeoWidget( tab3 );
938 mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); 938 mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() );
939 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 939 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
940 layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop ); 940 layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop );
941*/ 941*/
942 ////////////////////////////////////// 942 //////////////////////////////////////
943 // Sound 943 // Sound
944#ifndef KAB_EMBEDDED 944#ifndef KAB_EMBEDDED
945 mSoundWidget = new SoundWidget( tab3 ); 945 mSoundWidget = new SoundWidget( tab3 );
946 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); 946 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() );
947 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 947 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
948 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); 948 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop );
949#else //KAB_EMBEDDED 949#else //KAB_EMBEDDED
950//US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); 950//US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed");
951#endif //KAB_EMBEDDED 951#endif //KAB_EMBEDDED
952 952
953 ////////////////////////////////////// 953 //////////////////////////////////////
954 // Images 954 // Images
955 mImageWidget = new ImageWidget( tab3 ); 955 mImageWidget = new ImageWidget( tab3 );
956 mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); 956 mImageWidget->setMinimumSize( mImageWidget->sizeHint() );
957 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 957 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
958 layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop ); 958 layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop );
959/*US 959/*US
960 ////////////////////////////////////// 960 //////////////////////////////////////
961 // Keys 961 // Keys
962 mKeyWidget = new KeyWidget( tab3 ); 962 mKeyWidget = new KeyWidget( tab3 );
963 mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); 963 mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() );
964 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 964 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
965 layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); 965 layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop );
966*/ 966*/
967 mTabWidget->addTab( tab3, i18n( "&Images" ) ); 967 mTabWidget->addTab( tab3, i18n( "&Images" ) );
968} 968}
969 969
970 970
971void AddresseeEditorWidget::load() 971void AddresseeEditorWidget::load()
972{ 972{
973 973
974 // Block signals in case anything tries to emit modified 974 // Block signals in case anything tries to emit modified
975 // CS: This doesn't seem to work. 975 // CS: This doesn't seem to work.
976 bool block = signalsBlocked(); 976 bool block = signalsBlocked();
977 blockSignals( true ); 977 blockSignals( true );
978 mBlockSignals = true; // used for internal signal blocking 978 mBlockSignals = true; // used for internal signal blocking
979 979
980 mNameEdit->setText( mAddressee.assembledName() ); 980 mNameEdit->setText( mAddressee.assembledName() );
981 981
982 if ( mAddressee.formattedName().isEmpty() ) { 982 if ( mAddressee.formattedName().isEmpty() ) {
983//US KConfig config( "kaddressbookrc" ); 983//US KConfig config( "kaddressbookrc" );
984 KConfig config( locateLocal("config", "kaddressbookrc") ); 984 KConfig config( locateLocal("config", "kaddressbookrc") );
985 config.setGroup( "General" ); 985 config.setGroup( "General" );
986 mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); 986 mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 );
987 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 987 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
988 } else { 988 } else {
989 if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) 989 if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) )
990 mFormattedNameType = NameEditDialog::SimpleName; 990 mFormattedNameType = NameEditDialog::SimpleName;
991 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) 991 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) )
992 mFormattedNameType = NameEditDialog::FullName; 992 mFormattedNameType = NameEditDialog::FullName;
993 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) 993 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) )
994 mFormattedNameType = NameEditDialog::ReverseName; 994 mFormattedNameType = NameEditDialog::ReverseName;
995 else 995 else
996 mFormattedNameType = NameEditDialog::CustomName; 996 mFormattedNameType = NameEditDialog::CustomName;
997 } 997 }
998 998
999 mFormattedNameLabel->setText( mAddressee.formattedName() ); 999 mFormattedNameLabel->setText( mAddressee.formattedName() );
1000 1000
1001 mRoleEdit->setText( mAddressee.role() ); 1001 mRoleEdit->setText( mAddressee.role() );
1002 mOrgEdit->setText( mAddressee.organization() ); 1002 mOrgEdit->setText( mAddressee.organization() );
1003 1003
1004//US mURLEdit->setURL( mAddressee.url().url() ); 1004//US mURLEdit->setURL( mAddressee.url().url() );
1005 mURLEdit->setText( mAddressee.url().prettyURL() ); 1005 mURLEdit->setText( mAddressee.url().prettyURL() );
1006//US?? mURLEdit->home( false ); 1006//US?? mURLEdit->home( false );
1007 1007
1008 // mNoteEdit->setText( mAddressee.note() ); 1008 // mNoteEdit->setText( mAddressee.note() );
1009 mNoteEdit->setText( mAddressee.note() ); 1009 mNoteEdit->setText( mAddressee.note() );
1010 mEmailWidget->setEmails( mAddressee.emails() ); 1010 mEmailWidget->setEmails( mAddressee.emails() );
1011 mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); 1011 mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() );
1012 mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); 1012 mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() );
1013 mBirthdayPicker->setDate( mAddressee.birthday().date() ); 1013 mBirthdayPicker->setDate( mAddressee.birthday().date() );
1014 1014
1015//US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( 1015//US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom(
1016//US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); 1016//US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) );
1017 QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), 1017 QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ),
1018 "%Y-%m-%d"); // = Qt::ISODate 1018 "%Y-%m-%d"); // = Qt::ISODate
1019 mAnniversaryPicker->setDate( dt ); 1019 mAnniversaryPicker->setDate( dt );
1020 1020
1021 1021
1022 mNicknameEdit->setText( mAddressee.nickName() ); 1022 mNicknameEdit->setText( mAddressee.nickName() );
1023 mCategoryEdit->setText( mAddressee.categories().join( "," ) ); 1023 mCategoryEdit->setText( mAddressee.categories().join( "," ) );
1024 1024
1025 mGeoWidget->setGeo( mAddressee.geo() ); 1025 mGeoWidget->setGeo( mAddressee.geo() );
1026 mImageWidget->setPhoto( mAddressee.photo() ); 1026 mImageWidget->setPhoto( mAddressee.photo() );
1027 mImageWidget->setLogo( mAddressee.logo() ); 1027 mImageWidget->setLogo( mAddressee.logo() );
1028 mKeyWidget->setKeys( mAddressee.keys() ); 1028 mKeyWidget->setKeys( mAddressee.keys() );
1029 mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); 1029 mSecrecyWidget->setSecrecy( mAddressee.secrecy() );
1030#ifndef KAB_EMBEDDED 1030#ifndef KAB_EMBEDDED
1031 mSoundWidget->setSound( mAddressee.sound() ); 1031 mSoundWidget->setSound( mAddressee.sound() );
1032#else //KAB_EMBEDDED 1032#else //KAB_EMBEDDED
1033//US qDebug("AddresseeEditorWidget::load has to be changed 2"); 1033//US qDebug("AddresseeEditorWidget::load has to be changed 2");
1034#endif //KAB_EMBEDDED 1034#endif //KAB_EMBEDDED
1035 1035
1036 // Load customs 1036 // Load customs
1037 mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); 1037 mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) );
1038 mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); 1038 mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) );
1039 mChildEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Children" ) ); 1039 mChildEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Children" ) );
1040 mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); 1040 mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) );
1041 mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); 1041 mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) );
1042 mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); 1042 mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) );
1043 mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); 1043 mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) );
1044 mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); 1044 mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) );
1045 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); 1045 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
1046 if ( gen == "female" ) 1046 if ( gen == "female" )
1047 mGenderBox->setCurrentItem ( 1 ); 1047 mGenderBox->setCurrentItem ( 1 );
1048 else if ( gen == "male" ) 1048 else if ( gen == "male" )
1049 mGenderBox->setCurrentItem ( 2 ); 1049 mGenderBox->setCurrentItem ( 2 );
1050 else 1050 else
1051 mGenderBox->setCurrentItem ( 0 ); 1051 mGenderBox->setCurrentItem ( 0 );
1052 blockSignals( block ); 1052 blockSignals( block );
1053 mBlockSignals = false; 1053 mBlockSignals = false;
1054 1054
1055 mDirty = false; 1055 mDirty = false;
1056} 1056}
1057 1057
1058void AddresseeEditorWidget::save() 1058void AddresseeEditorWidget::save()
1059{ 1059{
1060 if ( !dirty() ) { 1060 if ( !dirty() ) {
1061 return; 1061 return;
1062 } 1062 }
1063 1063
1064 mAddressee.setRevision( QDateTime::currentDateTime() );
1065
1064 mAddressee.setRole( mRoleEdit->text() ); 1066 mAddressee.setRole( mRoleEdit->text() );
1065 mAddressee.setOrganization( mOrgEdit->text() ); 1067 mAddressee.setOrganization( mOrgEdit->text() );
1066 mAddressee.setUrl( KURL( mURLEdit->text() ) ); 1068 mAddressee.setUrl( KURL( mURLEdit->text() ) );
1067 mAddressee.setNote( mNoteEdit->text() ); 1069 mAddressee.setNote( mNoteEdit->text() );
1068 if ( mBirthdayPicker->inputIsValid() ) { 1070 if ( mBirthdayPicker->inputIsValid() ) {
1069 QDate da = mBirthdayPicker->date(); 1071 QDate da = mBirthdayPicker->date();
1070 if ( da > QDate::currentDate() ) 1072 if ( da > QDate::currentDate() )
1071 da.setYMD(da.year()-100, da.month(), da.day() ); 1073 da.setYMD(da.year()-100, da.month(), da.day() );
1072 mAddressee.setBirthday( QDateTime( da ) ); 1074 mAddressee.setBirthday( QDateTime( da ) );
1073 //qDebug("bday %s ",da.toString().latin1()); 1075 //qDebug("bday %s ",da.toString().latin1());
1074 } 1076 }
1075 else { 1077 else {
1076 mAddressee.setBirthday( QDateTime() ); 1078 mAddressee.setBirthday( QDateTime() );
1077 mBirthdayPicker->clear(); 1079 mBirthdayPicker->clear();
1078 } 1080 }
1079 mAddressee.setNickName( mNicknameEdit->text() ); 1081 mAddressee.setNickName( mNicknameEdit->text() );
1080 mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); 1082 mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) );
1081 1083
1082 mAddressee.setGeo( mGeoWidget->geo() ); 1084 mAddressee.setGeo( mGeoWidget->geo() );
1083 mAddressee.setPhoto( mImageWidget->photo() ); 1085 mAddressee.setPhoto( mImageWidget->photo() );
1084 mAddressee.setLogo( mImageWidget->logo() ); 1086 mAddressee.setLogo( mImageWidget->logo() );
1085 mAddressee.setKeys( mKeyWidget->keys() ); 1087 mAddressee.setKeys( mKeyWidget->keys() );
1086#ifndef KAB_EMBEDDED 1088#ifndef KAB_EMBEDDED
1087 mAddressee.setSound( mSoundWidget->sound() ); 1089 mAddressee.setSound( mSoundWidget->sound() );
1088#else //KAB_EMBEDDED 1090#else //KAB_EMBEDDED
1089//US qDebug("AddresseeEditorWidget::save sound not supported"); 1091//US qDebug("AddresseeEditorWidget::save sound not supported");
1090#endif //KAB_EMBEDDED 1092#endif //KAB_EMBEDDED
1091 mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); 1093 mAddressee.setSecrecy( mSecrecyWidget->secrecy() );
1092 1094
1093 // save custom fields 1095 // save custom fields
1094 mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); 1096 mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() );
1095 mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); 1097 mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() );
1096 mAddressee.insertCustom( "KADDRESSBOOK", "X-Children", mChildEdit->text() ); 1098 mAddressee.insertCustom( "KADDRESSBOOK", "X-Children", mChildEdit->text() );
1097 mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); 1099 mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() );
1098 mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); 1100 mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() );
1099 mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); 1101 mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() );
1100 mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); 1102 mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() );
1101 mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); 1103 mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() );
1102 if ( mAnniversaryPicker->inputIsValid() ) { 1104 if ( mAnniversaryPicker->inputIsValid() ) {
1103 QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate); 1105 QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate);
1104 mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 1106 mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
1105 } 1107 }
1106 else { 1108 else {
1107 mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); 1109 mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" );
1108 mAnniversaryPicker->clear(); 1110 mAnniversaryPicker->clear();
1109 } 1111 }
1110 int gen = mGenderBox->currentItem (); 1112 int gen = mGenderBox->currentItem ();
1111 if ( gen == 1 ) 1113 if ( gen == 1 )
1112 mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); 1114 mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
1113 else if ( gen == 2 ) 1115 else if ( gen == 2 )
1114 mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); 1116 mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
1115 else 1117 else
1116 mAddressee.removeCustom( "KADDRESSBOOK", "X-Gender" ); 1118 mAddressee.removeCustom( "KADDRESSBOOK", "X-Gender" );
1117 1119
1118 // Save the email addresses 1120 // Save the email addresses
1119 QStringList emails = mAddressee.emails(); 1121 QStringList emails = mAddressee.emails();
1120 QStringList::Iterator iter; 1122 QStringList::Iterator iter;
1121 for ( iter = emails.begin(); iter != emails.end(); ++iter ) 1123 for ( iter = emails.begin(); iter != emails.end(); ++iter )
1122 mAddressee.removeEmail( *iter ); 1124 mAddressee.removeEmail( *iter );
1123 1125
1124 emails = mEmailWidget->emails(); 1126 emails = mEmailWidget->emails();
1125 bool first = true; 1127 bool first = true;
1126 for ( iter = emails.begin(); iter != emails.end(); ++iter ) { 1128 for ( iter = emails.begin(); iter != emails.end(); ++iter ) {
1127 mAddressee.insertEmail( *iter, first ); 1129 mAddressee.insertEmail( *iter, first );
1128 first = false; 1130 first = false;
1129 } 1131 }
1130 1132
1131 // Save the phone numbers 1133 // Save the phone numbers
1132 KABC::PhoneNumber::List phoneNumbers; 1134 KABC::PhoneNumber::List phoneNumbers;
1133 KABC::PhoneNumber::List::Iterator phoneIter; 1135 KABC::PhoneNumber::List::Iterator phoneIter;
1134 phoneNumbers = mAddressee.phoneNumbers(); 1136 phoneNumbers = mAddressee.phoneNumbers();
1135 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); 1137 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
1136 ++phoneIter ) 1138 ++phoneIter )
1137 mAddressee.removePhoneNumber( *phoneIter ); 1139 mAddressee.removePhoneNumber( *phoneIter );
1138 1140
1139 phoneNumbers = mPhoneEditWidget->phoneNumbers(); 1141 phoneNumbers = mPhoneEditWidget->phoneNumbers();
1140 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); 1142 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
1141 ++phoneIter ) 1143 ++phoneIter )
1142 mAddressee.insertPhoneNumber( *phoneIter ); 1144 mAddressee.insertPhoneNumber( *phoneIter );
1143 1145
1144 // Save the addresses 1146 // Save the addresses
1145 KABC::Address::List addresses; 1147 KABC::Address::List addresses;
1146 KABC::Address::List::Iterator addressIter; 1148 KABC::Address::List::Iterator addressIter;
1147 addresses = mAddressee.addresses(); 1149 addresses = mAddressee.addresses();
1148 for ( addressIter = addresses.begin(); addressIter != addresses.end(); 1150 for ( addressIter = addresses.begin(); addressIter != addresses.end();
1149 ++addressIter ) 1151 ++addressIter )
1150 mAddressee.removeAddress( *addressIter ); 1152 mAddressee.removeAddress( *addressIter );
1151 1153
1152 addresses = mAddressEditWidget->addresses(); 1154 addresses = mAddressEditWidget->addresses();
1153 for ( addressIter = addresses.begin(); addressIter != addresses.end(); 1155 for ( addressIter = addresses.begin(); addressIter != addresses.end();
1154 ++addressIter ) 1156 ++addressIter )
1155 mAddressee.insertAddress( *addressIter ); 1157 mAddressee.insertAddress( *addressIter );
1156 mDirty = false; 1158 mDirty = false;
1157} 1159}
1158 1160
1159bool AddresseeEditorWidget::dirty() 1161bool AddresseeEditorWidget::dirty()
1160{ 1162{
1161 1163
1162 if ( ! mDirty ) { 1164 if ( ! mDirty ) {
1163 if ( mBirthdayPicker->inputIsValid() ) { 1165 if ( mBirthdayPicker->inputIsValid() ) {
1164 QDate da = mBirthdayPicker->date(); 1166 QDate da = mBirthdayPicker->date();
1165 if ( !(da == mAddressee.birthday().date())) 1167 if ( !(da == mAddressee.birthday().date()))
1166 mDirty = true; 1168 mDirty = true;
1167 } 1169 }
1168 else { 1170 else {
1169 mBirthdayPicker->clear(); 1171 mBirthdayPicker->clear();
1170 } 1172 }
1171 if ( mAnniversaryPicker->inputIsValid() ) { 1173 if ( mAnniversaryPicker->inputIsValid() ) {
1172 QDate da = mAnniversaryPicker->date(); 1174 QDate da = mAnniversaryPicker->date();
1173 if ( da != KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), 1175 if ( da != KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ),
1174 "%Y-%m-%d")) 1176 "%Y-%m-%d"))
1175 mDirty = true; 1177 mDirty = true;
1176 } 1178 }
1177 else { 1179 else {
1178 mAnniversaryPicker->clear(); 1180 mAnniversaryPicker->clear();
1179 } 1181 }
1180 } 1182 }
1181 return mDirty; 1183 return mDirty;
1182} 1184}
1183 1185
1184void AddresseeEditorWidget::nameTextChanged( const QString &text ) 1186void AddresseeEditorWidget::nameTextChanged( const QString &text )
1185{ 1187{
1186 // use the addressee class to parse the name for us 1188 // use the addressee class to parse the name for us
1187 mAConfig->setUid( mAddressee.uid() ); 1189 mAConfig->setUid( mAddressee.uid() );
1188 if ( mAConfig->automaticNameParsing() ) { 1190 if ( mAConfig->automaticNameParsing() ) {
1189 if ( !mAddressee.formattedName().isEmpty() ) { 1191 if ( !mAddressee.formattedName().isEmpty() ) {
1190 QString fn = mAddressee.formattedName(); 1192 QString fn = mAddressee.formattedName();
1191 mAddressee.setNameFromString( text ); 1193 mAddressee.setNameFromString( text );
1192 mAddressee.setFormattedName( fn ); 1194 mAddressee.setFormattedName( fn );
1193 } else { 1195 } else {
1194 // use extra addressee to avoid a formatted name assignment 1196 // use extra addressee to avoid a formatted name assignment
1195 Addressee addr; 1197 Addressee addr;
1196 addr.setNameFromString( text ); 1198 addr.setNameFromString( text );
1197 mAddressee.setPrefix( addr.prefix() ); 1199 mAddressee.setPrefix( addr.prefix() );
1198 mAddressee.setGivenName( addr.givenName() ); 1200 mAddressee.setGivenName( addr.givenName() );
1199 mAddressee.setAdditionalName( addr.additionalName() ); 1201 mAddressee.setAdditionalName( addr.additionalName() );
1200 mAddressee.setFamilyName( addr.familyName() ); 1202 mAddressee.setFamilyName( addr.familyName() );
1201 mAddressee.setSuffix( addr.suffix() ); 1203 mAddressee.setSuffix( addr.suffix() );
1202 } 1204 }
1203 } 1205 }
1204 1206
1205 nameBoxChanged(); 1207 nameBoxChanged();
1206 1208
1207 emitModified(); 1209 emitModified();
1208} 1210}
1209 1211
1210void AddresseeEditorWidget::nameBoxChanged() 1212void AddresseeEditorWidget::nameBoxChanged()
1211{ 1213{
1212 KABC::Addressee addr; 1214 KABC::Addressee addr;
1213 mAConfig->setUid( mAddressee.uid() ); 1215 mAConfig->setUid( mAddressee.uid() );
1214 if ( mAConfig->automaticNameParsing() ) { 1216 if ( mAConfig->automaticNameParsing() ) {
1215 addr.setNameFromString( mNameEdit->text() ); 1217 addr.setNameFromString( mNameEdit->text() );
1216 mNameLabel->hide(); 1218 mNameLabel->hide();
1217 mNameEdit->show(); 1219 mNameEdit->show();
1218 } else { 1220 } else {
1219 addr = mAddressee; 1221 addr = mAddressee;
1220 mNameEdit->hide(); 1222 mNameEdit->hide();
1221 mNameLabel->setText( mNameEdit->text() ); 1223 mNameLabel->setText( mNameEdit->text() );
1222 mNameLabel->show(); 1224 mNameLabel->show();
1223 } 1225 }
1224 1226
1225 if ( mFormattedNameType != NameEditDialog::CustomName ) { 1227 if ( mFormattedNameType != NameEditDialog::CustomName ) {
1226 mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 1228 mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
1227 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 1229 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
1228 } 1230 }
1229} 1231}
1230 1232
1231void AddresseeEditorWidget::nameButtonClicked() 1233void AddresseeEditorWidget::nameButtonClicked()
1232{ 1234{
1233 // show the name dialog. 1235 // show the name dialog.
1234 NameEditDialog dialog( mAddressee, mFormattedNameType, this ); 1236 NameEditDialog dialog( mAddressee, mFormattedNameType, this );
1235 1237
1236 if ( KApplication::execDialog( &dialog) ) { 1238 if ( KApplication::execDialog( &dialog) ) {
1237 if ( dialog.changed() ) { 1239 if ( dialog.changed() ) {
1238 mAddressee.setFamilyName( dialog.familyName() ); 1240 mAddressee.setFamilyName( dialog.familyName() );
1239 mAddressee.setGivenName( dialog.givenName() ); 1241 mAddressee.setGivenName( dialog.givenName() );
1240 mAddressee.setPrefix( dialog.prefix() ); 1242 mAddressee.setPrefix( dialog.prefix() );
1241 mAddressee.setSuffix( dialog.suffix() ); 1243 mAddressee.setSuffix( dialog.suffix() );
1242 mAddressee.setAdditionalName( dialog.additionalName() ); 1244 mAddressee.setAdditionalName( dialog.additionalName() );
1243 mFormattedNameType = dialog.formattedNameType(); 1245 mFormattedNameType = dialog.formattedNameType();
1244 if ( mFormattedNameType == NameEditDialog::CustomName ) { 1246 if ( mFormattedNameType == NameEditDialog::CustomName ) {
1245 mFormattedNameLabel->setText( dialog.customFormattedName() ); 1247 mFormattedNameLabel->setText( dialog.customFormattedName() );
1246 mAddressee.setFormattedName( dialog.customFormattedName() ); 1248 mAddressee.setFormattedName( dialog.customFormattedName() );
1247 } 1249 }
1248 // Update the name edit. 1250 // Update the name edit.
1249 bool block = mNameEdit->signalsBlocked(); 1251 bool block = mNameEdit->signalsBlocked();
1250 mNameEdit->blockSignals( true ); 1252 mNameEdit->blockSignals( true );
1251 mNameEdit->setText( mAddressee.assembledName() ); 1253 mNameEdit->setText( mAddressee.assembledName() );
1252 mNameEdit->blockSignals( block ); 1254 mNameEdit->blockSignals( block );
1253 1255
1254 // Update the combo box. 1256 // Update the combo box.
1255 nameBoxChanged(); 1257 nameBoxChanged();
1256 1258
1257 emitModified(); 1259 emitModified();
1258 } 1260 }
1259 } 1261 }
1260} 1262}
1261 1263
1262void AddresseeEditorWidget::categoryButtonClicked() 1264void AddresseeEditorWidget::categoryButtonClicked()
1263{ 1265{
1264 // Show the category dialog 1266 // Show the category dialog
1265 if ( mCategoryDialog == 0 ) { 1267 if ( mCategoryDialog == 0 ) {
1266 mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this ); 1268 mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this );
1267 connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ), 1269 connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ),
1268 SLOT(categoriesSelected( const QStringList& ) ) ); 1270 SLOT(categoriesSelected( const QStringList& ) ) );
1269 connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) ); 1271 connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) );
1270 } 1272 }
1271 1273
1272 mCategoryDialog->setCategories(); 1274 mCategoryDialog->setCategories();
1273 mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) ); 1275 mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) );
1274 mCategoryDialog->show(); 1276 mCategoryDialog->show();
1275 mCategoryDialog->raise(); 1277 mCategoryDialog->raise();
1276} 1278}
1277 1279
1278void AddresseeEditorWidget::categoriesSelected( const QStringList &list ) 1280void AddresseeEditorWidget::categoriesSelected( const QStringList &list )
1279{ 1281{
1280 mCategoryEdit->setText( list.join( "," ) ); 1282 mCategoryEdit->setText( list.join( "," ) );
1281} 1283}
1282 1284
1283void AddresseeEditorWidget::editCategories() 1285void AddresseeEditorWidget::editCategories()
1284{ 1286{
1285 if ( mCategoryEditDialog == 0 ) { 1287 if ( mCategoryEditDialog == 0 ) {
1286 mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this ); 1288 mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this );
1287 connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ), 1289 connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ),
1288 SLOT( categoryButtonClicked() ) ); 1290 SLOT( categoryButtonClicked() ) );
1289 } 1291 }
1290 1292
1291 mCategoryEditDialog->show(); 1293 mCategoryEditDialog->show();
1292 mCategoryEditDialog->raise(); 1294 mCategoryEditDialog->raise();
1293} 1295}
1294 1296
1295void AddresseeEditorWidget::emitModified() 1297void AddresseeEditorWidget::emitModified()
1296{ 1298{
1297 mDirty = true; 1299 mDirty = true;
1298 1300
1299 KABC::Addressee::List list; 1301 KABC::Addressee::List list;
1300 1302
1301 if ( mIsExtension && !mBlockSignals ) { 1303 if ( mIsExtension && !mBlockSignals ) {
1302 save(); 1304 save();
1303 list.append( mAddressee ); 1305 list.append( mAddressee );
1304 } 1306 }
1305 1307
1306 emit modified( list ); 1308 emit modified( list );
1307} 1309}
1308 1310
1309void AddresseeEditorWidget::dateChanged( QDate ) 1311void AddresseeEditorWidget::dateChanged( QDate )
1310{ 1312{
1311 emitModified(); 1313 emitModified();
1312} 1314}
1313 1315
1314//US invalid dates are handdled by the KDateEdit widget itself 1316//US invalid dates are handdled by the KDateEdit widget itself
1315void AddresseeEditorWidget::invalidDate() 1317void AddresseeEditorWidget::invalidDate()
1316{ 1318{
1317 KMessageBox::sorry( this, i18n( "You must specify a valid date" ) ); 1319 KMessageBox::sorry( this, i18n( "You must specify a valid date" ) );
1318} 1320}
1319 1321
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 273d435..6e482b5 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2153,819 +2153,820 @@ void KABCore::configureResources()
2153{ 2153{
2154 KRES::KCMKResources dlg( this, "" , 0 ); 2154 KRES::KCMKResources dlg( this, "" , 0 );
2155 2155
2156 if ( !dlg.exec() ) 2156 if ( !dlg.exec() )
2157 return; 2157 return;
2158 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2158 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2159} 2159}
2160#endif //KAB_EMBEDDED 2160#endif //KAB_EMBEDDED
2161 2161
2162 2162
2163/* this method will be called through the QCop interface from Ko/Pi to select addresses 2163/* this method will be called through the QCop interface from Ko/Pi to select addresses
2164 * for the attendees list of an event. 2164 * for the attendees list of an event.
2165 */ 2165 */
2166void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2166void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2167{ 2167{
2168 QStringList nameList; 2168 QStringList nameList;
2169 QStringList emailList; 2169 QStringList emailList;
2170 QStringList uidList; 2170 QStringList uidList;
2171 2171
2172 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2172 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2173 uint i=0; 2173 uint i=0;
2174 for (i=0; i < list.count(); i++) 2174 for (i=0; i < list.count(); i++)
2175 { 2175 {
2176 nameList.append(list[i].realName()); 2176 nameList.append(list[i].realName());
2177 emailList.append(list[i].preferredEmail()); 2177 emailList.append(list[i].preferredEmail());
2178 uidList.append(list[i].uid()); 2178 uidList.append(list[i].uid());
2179 } 2179 }
2180 2180
2181 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2181 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2182 2182
2183} 2183}
2184 2184
2185/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2185/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2186 * to put them into the calendar. 2186 * to put them into the calendar.
2187 */ 2187 */
2188void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2188void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2189{ 2189{
2190 // qDebug("KABCore::requestForBirthdayList"); 2190 // qDebug("KABCore::requestForBirthdayList");
2191 QStringList birthdayList; 2191 QStringList birthdayList;
2192 QStringList anniversaryList; 2192 QStringList anniversaryList;
2193 QStringList realNameList; 2193 QStringList realNameList;
2194 QStringList preferredEmailList; 2194 QStringList preferredEmailList;
2195 QStringList assembledNameList; 2195 QStringList assembledNameList;
2196 QStringList uidList; 2196 QStringList uidList;
2197 2197
2198 KABC::AddressBook::Iterator it; 2198 KABC::AddressBook::Iterator it;
2199 2199
2200 int count = 0; 2200 int count = 0;
2201 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2201 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2202 ++count; 2202 ++count;
2203 } 2203 }
2204 QProgressBar bar(count,0 ); 2204 QProgressBar bar(count,0 );
2205 int w = 300; 2205 int w = 300;
2206 if ( QApplication::desktop()->width() < 320 ) 2206 if ( QApplication::desktop()->width() < 320 )
2207 w = 220; 2207 w = 220;
2208 int h = bar.sizeHint().height() ; 2208 int h = bar.sizeHint().height() ;
2209 int dw = QApplication::desktop()->width(); 2209 int dw = QApplication::desktop()->width();
2210 int dh = QApplication::desktop()->height(); 2210 int dh = QApplication::desktop()->height();
2211 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2211 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2212 bar.show(); 2212 bar.show();
2213 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2213 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2214 qApp->processEvents(); 2214 qApp->processEvents();
2215 2215
2216 QDate bday; 2216 QDate bday;
2217 QString anni; 2217 QString anni;
2218 QString formattedbday; 2218 QString formattedbday;
2219 2219
2220 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2220 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2221 { 2221 {
2222 if ( ! bar.isVisible() ) 2222 if ( ! bar.isVisible() )
2223 return; 2223 return;
2224 bar.setProgress( count++ ); 2224 bar.setProgress( count++ );
2225 qApp->processEvents(); 2225 qApp->processEvents();
2226 bday = (*it).birthday().date(); 2226 bday = (*it).birthday().date();
2227 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2227 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2228 2228
2229 if ( bday.isValid() || !anni.isEmpty()) 2229 if ( bday.isValid() || !anni.isEmpty())
2230 { 2230 {
2231 if (bday.isValid()) 2231 if (bday.isValid())
2232 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2232 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2233 else 2233 else
2234 formattedbday = "NOTVALID"; 2234 formattedbday = "NOTVALID";
2235 if (anni.isEmpty()) 2235 if (anni.isEmpty())
2236 anni = "INVALID"; 2236 anni = "INVALID";
2237 2237
2238 birthdayList.append(formattedbday); 2238 birthdayList.append(formattedbday);
2239 anniversaryList.append(anni); //should be ISODate 2239 anniversaryList.append(anni); //should be ISODate
2240 realNameList.append((*it).realName()); 2240 realNameList.append((*it).realName());
2241 preferredEmailList.append((*it).preferredEmail()); 2241 preferredEmailList.append((*it).preferredEmail());
2242 assembledNameList.append((*it).assembledName()); 2242 assembledNameList.append((*it).assembledName());
2243 uidList.append((*it).uid()); 2243 uidList.append((*it).uid());
2244 2244
2245 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2245 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2246 } 2246 }
2247 } 2247 }
2248 2248
2249 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2249 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2250 2250
2251} 2251}
2252 2252
2253/* this method will be called through the QCop interface from other apps to show details of a contact. 2253/* this method will be called through the QCop interface from other apps to show details of a contact.
2254 */ 2254 */
2255void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2255void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2256{ 2256{
2257 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2257 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2258 2258
2259 QString foundUid = QString::null; 2259 QString foundUid = QString::null;
2260 if ( ! uid.isEmpty() ) { 2260 if ( ! uid.isEmpty() ) {
2261 Addressee adrr = mAddressBook->findByUid( uid ); 2261 Addressee adrr = mAddressBook->findByUid( uid );
2262 if ( !adrr.isEmpty() ) { 2262 if ( !adrr.isEmpty() ) {
2263 foundUid = uid; 2263 foundUid = uid;
2264 } 2264 }
2265 if ( email == "sendbacklist" ) { 2265 if ( email == "sendbacklist" ) {
2266 //qDebug("ssssssssssssssssssssssend "); 2266 //qDebug("ssssssssssssssssssssssend ");
2267 QStringList nameList; 2267 QStringList nameList;
2268 QStringList emailList; 2268 QStringList emailList;
2269 QStringList uidList; 2269 QStringList uidList;
2270 nameList.append(adrr.realName()); 2270 nameList.append(adrr.realName());
2271 emailList = adrr.emails(); 2271 emailList = adrr.emails();
2272 uidList.append( adrr.preferredEmail()); 2272 uidList.append( adrr.preferredEmail());
2273 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2273 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2274 return; 2274 return;
2275 } 2275 }
2276 2276
2277 } 2277 }
2278 2278
2279 if ( email == "sendbacklist" ) 2279 if ( email == "sendbacklist" )
2280 return; 2280 return;
2281 if (foundUid.isEmpty()) 2281 if (foundUid.isEmpty())
2282 { 2282 {
2283 //find the uid of the person first 2283 //find the uid of the person first
2284 Addressee::List namelist; 2284 Addressee::List namelist;
2285 Addressee::List emaillist; 2285 Addressee::List emaillist;
2286 2286
2287 if (!name.isEmpty()) 2287 if (!name.isEmpty())
2288 namelist = mAddressBook->findByName( name ); 2288 namelist = mAddressBook->findByName( name );
2289 2289
2290 if (!email.isEmpty()) 2290 if (!email.isEmpty())
2291 emaillist = mAddressBook->findByEmail( email ); 2291 emaillist = mAddressBook->findByEmail( email );
2292 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2292 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2293 //check if we have a match in Namelist and Emaillist 2293 //check if we have a match in Namelist and Emaillist
2294 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2294 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2295 foundUid = emaillist[0].uid(); 2295 foundUid = emaillist[0].uid();
2296 } 2296 }
2297 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2297 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2298 foundUid = namelist[0].uid(); 2298 foundUid = namelist[0].uid();
2299 else 2299 else
2300 { 2300 {
2301 for (int i = 0; i < namelist.count(); i++) 2301 for (int i = 0; i < namelist.count(); i++)
2302 { 2302 {
2303 for (int j = 0; j < emaillist.count(); j++) 2303 for (int j = 0; j < emaillist.count(); j++)
2304 { 2304 {
2305 if (namelist[i] == emaillist[j]) 2305 if (namelist[i] == emaillist[j])
2306 { 2306 {
2307 foundUid = namelist[i].uid(); 2307 foundUid = namelist[i].uid();
2308 } 2308 }
2309 } 2309 }
2310 } 2310 }
2311 } 2311 }
2312 } 2312 }
2313 else 2313 else
2314 { 2314 {
2315 foundUid = uid; 2315 foundUid = uid;
2316 } 2316 }
2317 2317
2318 if (!foundUid.isEmpty()) 2318 if (!foundUid.isEmpty())
2319 { 2319 {
2320 2320
2321 // raise Ka/Pi if it is in the background 2321 // raise Ka/Pi if it is in the background
2322#ifndef DESKTOP_VERSION 2322#ifndef DESKTOP_VERSION
2323#ifndef KORG_NODCOP 2323#ifndef KORG_NODCOP
2324 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2324 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2325#endif 2325#endif
2326#endif 2326#endif
2327 2327
2328 mMainWindow->showMaximized(); 2328 mMainWindow->showMaximized();
2329 mMainWindow-> raise(); 2329 mMainWindow-> raise();
2330 2330
2331 mViewManager->setSelected( "", false); 2331 mViewManager->setSelected( "", false);
2332 mViewManager->refreshView( "" ); 2332 mViewManager->refreshView( "" );
2333 mViewManager->setSelected( foundUid, true ); 2333 mViewManager->setSelected( foundUid, true );
2334 mViewManager->refreshView( foundUid ); 2334 mViewManager->refreshView( foundUid );
2335 2335
2336 if ( !mMultipleViewsAtOnce ) 2336 if ( !mMultipleViewsAtOnce )
2337 { 2337 {
2338 setDetailsVisible( true ); 2338 setDetailsVisible( true );
2339 mActionDetails->setChecked(true); 2339 mActionDetails->setChecked(true);
2340 } 2340 }
2341 } 2341 }
2342} 2342}
2343 2343
2344void KABCore::whatsnew() 2344void KABCore::whatsnew()
2345{ 2345{
2346 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2346 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2347} 2347}
2348void KABCore::synchowto() 2348void KABCore::synchowto()
2349{ 2349{
2350 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2350 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2351} 2351}
2352void KABCore::kdesynchowto() 2352void KABCore::kdesynchowto()
2353{ 2353{
2354 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2354 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2355} 2355}
2356void KABCore::multisynchowto() 2356void KABCore::multisynchowto()
2357{ 2357{
2358 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2358 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2359} 2359}
2360void KABCore::faq() 2360void KABCore::faq()
2361{ 2361{
2362 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2362 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2363} 2363}
2364 2364
2365#include <libkcal/syncdefines.h> 2365#include <libkcal/syncdefines.h>
2366 2366
2367KABC::Addressee KABCore::getLastSyncAddressee() 2367KABC::Addressee KABCore::getLastSyncAddressee()
2368{ 2368{
2369 Addressee lse; 2369 Addressee lse;
2370 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2370 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2371 2371
2372 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2372 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2373 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2373 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2374 if (lse.isEmpty()) { 2374 if (lse.isEmpty()) {
2375 qDebug("Creating new last-syncAddressee "); 2375 qDebug("Creating new last-syncAddressee ");
2376 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2376 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2377 QString sum = ""; 2377 QString sum = "";
2378 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2378 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2379 sum = "E: "; 2379 sum = "E: ";
2380 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2380 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2381 lse.setRevision( mLastAddressbookSync ); 2381 lse.setRevision( mLastAddressbookSync );
2382 lse.setCategories( i18n("SyncEvent") ); 2382 lse.setCategories( i18n("SyncEvent") );
2383 mAddressBook->insertAddressee( lse ); 2383 mAddressBook->insertAddressee( lse );
2384 } 2384 }
2385 return lse; 2385 return lse;
2386} 2386}
2387int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2387int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2388{ 2388{
2389 2389
2390 //void setZaurusId(int id); 2390 //void setZaurusId(int id);
2391 // int zaurusId() const; 2391 // int zaurusId() const;
2392 // void setZaurusUid(int id); 2392 // void setZaurusUid(int id);
2393 // int zaurusUid() const; 2393 // int zaurusUid() const;
2394 // void setZaurusStat(int id); 2394 // void setZaurusStat(int id);
2395 // int zaurusStat() const; 2395 // int zaurusStat() const;
2396 // 0 equal 2396 // 0 equal
2397 // 1 take local 2397 // 1 take local
2398 // 2 take remote 2398 // 2 take remote
2399 // 3 cancel 2399 // 3 cancel
2400 QDateTime lastSync = mLastAddressbookSync; 2400 QDateTime lastSync = mLastAddressbookSync;
2401 QDateTime localMod = local->revision(); 2401 QDateTime localMod = local->revision();
2402 QDateTime remoteMod = remote->revision(); 2402 QDateTime remoteMod = remote->revision();
2403 2403
2404 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2404 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2405 2405
2406 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2406 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2407 bool remCh, locCh; 2407 bool remCh, locCh;
2408 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2408 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2409 2409 qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2410 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2411 locCh = ( localMod > mLastAddressbookSync ); 2410 locCh = ( localMod > mLastAddressbookSync );
2412 if ( !remCh && ! locCh ) { 2411 if ( !remCh && ! locCh ) {
2413 //qDebug("both not changed "); 2412 qDebug("both not changed ");
2414 lastSync = localMod.addDays(1); 2413 lastSync = localMod.addDays(1);
2415 if ( mode <= SYNC_PREF_ASK ) 2414 if ( mode <= SYNC_PREF_ASK )
2416 return 0; 2415 return 0;
2417 } else { 2416 } else {
2418 if ( locCh ) { 2417 if ( locCh ) {
2419 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2418 qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2420 lastSync = localMod.addDays( -1 ); 2419 lastSync = localMod.addDays( -1 );
2421 if ( !remCh ) 2420 if ( !remCh )
2422 remoteMod =( lastSync.addDays( -1 ) ); 2421 remoteMod =( lastSync.addDays( -1 ) );
2423 } else { 2422 } else {
2424 //qDebug(" not loc changed "); 2423 qDebug(" not loc changed ");
2425 lastSync = localMod.addDays( 1 ); 2424 lastSync = localMod.addDays( 1 );
2426 if ( remCh ) 2425 if ( remCh ) {
2426 qDebug("rem changed ");
2427 remoteMod =( lastSync.addDays( 1 ) ); 2427 remoteMod =( lastSync.addDays( 1 ) );
2428 }
2428 2429
2429 } 2430 }
2430 } 2431 }
2431 full = true; 2432 full = true;
2432 if ( mode < SYNC_PREF_ASK ) 2433 if ( mode < SYNC_PREF_ASK )
2433 mode = SYNC_PREF_ASK; 2434 mode = SYNC_PREF_ASK;
2434 } else { 2435 } else {
2435 if ( localMod == remoteMod ) 2436 if ( localMod == remoteMod )
2436 return 0; 2437 return 0;
2437 2438
2438 } 2439 }
2439 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2440 qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2440 2441 qDebug("lastsync %s ", lastSync.toString().latin1() );
2441 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2442 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2443 //full = true; //debug only 2442 //full = true; //debug only
2444 if ( full ) { 2443 if ( full ) {
2445 bool equ = ( (*local) == (*remote) ); 2444 bool equ = ( (*local) == (*remote) );
2446 if ( equ ) { 2445 if ( equ ) {
2447 //qDebug("equal "); 2446 qDebug("equal ");
2448 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2447 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2449 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2448 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2450 } 2449 }
2451 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2450 if ( mode < SYNC_PREF_FORCE_LOCAL )
2452 return 0; 2451 return 0;
2453 2452
2454 }//else //debug only 2453 }//else //debug only
2455 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2454 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2456 } 2455 }
2457 int result; 2456 int result;
2458 bool localIsNew; 2457 bool localIsNew;
2459 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2458 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2460 2459
2461 if ( full && mode < SYNC_PREF_NEWEST ) 2460 if ( full && mode < SYNC_PREF_NEWEST )
2462 mode = SYNC_PREF_ASK; 2461 mode = SYNC_PREF_ASK;
2463 2462
2464 switch( mode ) { 2463 switch( mode ) {
2465 case SYNC_PREF_LOCAL: 2464 case SYNC_PREF_LOCAL:
2466 if ( lastSync > remoteMod ) 2465 if ( lastSync > remoteMod )
2467 return 1; 2466 return 1;
2468 if ( lastSync > localMod ) 2467 if ( lastSync > localMod )
2469 return 2; 2468 return 2;
2470 return 1; 2469 return 1;
2471 break; 2470 break;
2472 case SYNC_PREF_REMOTE: 2471 case SYNC_PREF_REMOTE:
2473 if ( lastSync > remoteMod ) 2472 if ( lastSync > remoteMod )
2474 return 1; 2473 return 1;
2475 if ( lastSync > localMod ) 2474 if ( lastSync > localMod )
2476 return 2; 2475 return 2;
2477 return 2; 2476 return 2;
2478 break; 2477 break;
2479 case SYNC_PREF_NEWEST: 2478 case SYNC_PREF_NEWEST:
2480 if ( localMod > remoteMod ) 2479 if ( localMod > remoteMod )
2481 return 1; 2480 return 1;
2482 else 2481 else
2483 return 2; 2482 return 2;
2484 break; 2483 break;
2485 case SYNC_PREF_ASK: 2484 case SYNC_PREF_ASK:
2486 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2485 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2487 if ( lastSync > remoteMod ) 2486 if ( lastSync > remoteMod )
2488 return 1; 2487 return 1;
2489 if ( lastSync > localMod ) 2488 if ( lastSync > localMod )
2490 return 2; 2489 return 2;
2491 localIsNew = localMod >= remoteMod; 2490 localIsNew = localMod >= remoteMod;
2492 //qDebug("conflict! ************************************** "); 2491 //qDebug("conflict! ************************************** ");
2493 { 2492 {
2494 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2493 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2495 result = acd.executeD(localIsNew); 2494 result = acd.executeD(localIsNew);
2496 return result; 2495 return result;
2497 } 2496 }
2498 break; 2497 break;
2499 case SYNC_PREF_FORCE_LOCAL: 2498 case SYNC_PREF_FORCE_LOCAL:
2500 return 1; 2499 return 1;
2501 break; 2500 break;
2502 case SYNC_PREF_FORCE_REMOTE: 2501 case SYNC_PREF_FORCE_REMOTE:
2503 return 2; 2502 return 2;
2504 break; 2503 break;
2505 2504
2506 default: 2505 default:
2507 // SYNC_PREF_TAKE_BOTH not implemented 2506 // SYNC_PREF_TAKE_BOTH not implemented
2508 break; 2507 break;
2509 } 2508 }
2510 return 0; 2509 return 0;
2511} 2510}
2512 2511
2513 2512
2514bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2513bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2515{ 2514{
2516 bool syncOK = true; 2515 bool syncOK = true;
2517 int addedAddressee = 0; 2516 int addedAddressee = 0;
2518 int addedAddresseeR = 0; 2517 int addedAddresseeR = 0;
2519 int deletedAddresseeR = 0; 2518 int deletedAddresseeR = 0;
2520 int deletedAddresseeL = 0; 2519 int deletedAddresseeL = 0;
2521 int changedLocal = 0; 2520 int changedLocal = 0;
2522 int changedRemote = 0; 2521 int changedRemote = 0;
2523 2522
2524 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2523 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2525 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2524 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2526 2525
2527 //QPtrList<Addressee> el = local->rawAddressees(); 2526 //QPtrList<Addressee> el = local->rawAddressees();
2528 Addressee addresseeR; 2527 Addressee addresseeR;
2529 QString uid; 2528 QString uid;
2530 int take; 2529 int take;
2531 Addressee addresseeL; 2530 Addressee addresseeL;
2532 Addressee addresseeRSync; 2531 Addressee addresseeRSync;
2533 Addressee addresseeLSync; 2532 Addressee addresseeLSync;
2534 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2533 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2535 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2534 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2536 bool fullDateRange = false; 2535 bool fullDateRange = false;
2537 local->resetTempSyncStat(); 2536 local->resetTempSyncStat();
2538 mLastAddressbookSync = QDateTime::currentDateTime(); 2537 mLastAddressbookSync = QDateTime::currentDateTime();
2539 if ( syncManager->syncWithDesktop() ) { 2538 if ( syncManager->syncWithDesktop() ) {
2540 // remote->removeSyncInfo( QString());//remove all info 2539 // remote->removeSyncInfo( QString());//remove all info
2541 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2540 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2542 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2541 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2543 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2542 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2544 } else { 2543 } else {
2545 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2544 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2546 } 2545 }
2547 } 2546 }
2548 QDateTime modifiedCalendar = mLastAddressbookSync; 2547 QDateTime modifiedCalendar = mLastAddressbookSync;
2549 addresseeLSync = getLastSyncAddressee(); 2548 addresseeLSync = getLastSyncAddressee();
2550 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2549 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2551 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2550 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2552 if ( !addresseeR.isEmpty() ) { 2551 if ( !addresseeR.isEmpty() ) {
2553 addresseeRSync = addresseeR; 2552 addresseeRSync = addresseeR;
2554 remote->removeAddressee(addresseeR ); 2553 remote->removeAddressee(addresseeR );
2555 2554
2556 } else { 2555 } else {
2557 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2556 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2558 addresseeRSync = addresseeLSync ; 2557 addresseeRSync = addresseeLSync ;
2559 } else { 2558 } else {
2560 qDebug("FULLDATE 1"); 2559 qDebug("FULLDATE 1");
2561 fullDateRange = true; 2560 fullDateRange = true;
2562 Addressee newAdd; 2561 Addressee newAdd;
2563 addresseeRSync = newAdd; 2562 addresseeRSync = newAdd;
2564 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2563 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2565 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2564 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2566 addresseeRSync.setRevision( mLastAddressbookSync ); 2565 addresseeRSync.setRevision( mLastAddressbookSync );
2567 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2566 addresseeRSync.setCategories( i18n("SyncAddressee") );
2568 } 2567 }
2569 } 2568 }
2570 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2569 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2571 qDebug("FULLDATE 2"); 2570 qDebug("FULLDATE 2");
2572 fullDateRange = true; 2571 fullDateRange = true;
2573 } 2572 }
2574 if ( ! fullDateRange ) { 2573 if ( ! fullDateRange ) {
2575 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2574 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2576 2575
2577 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2576 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2578 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2577 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2579 fullDateRange = true; 2578 fullDateRange = true;
2580 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2579 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2581 } 2580 }
2582 } 2581 }
2583 // fullDateRange = true; // debug only! 2582 // fullDateRange = true; // debug only!
2584 if ( fullDateRange ) 2583 if ( fullDateRange )
2585 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2584 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2586 else 2585 else
2587 mLastAddressbookSync = addresseeLSync.revision(); 2586 mLastAddressbookSync = addresseeLSync.revision();
2588 // for resyncing if own file has changed 2587 // for resyncing if own file has changed
2589 // PENDING fixme later when implemented 2588 // PENDING fixme later when implemented
2590#if 0 2589#if 0
2591 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2590 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2592 mLastAddressbookSync = loadedFileVersion; 2591 mLastAddressbookSync = loadedFileVersion;
2593 qDebug("setting mLastAddressbookSync "); 2592 qDebug("setting mLastAddressbookSync ");
2594 } 2593 }
2595#endif 2594#endif
2596 2595
2597 //qDebug("*************************** "); 2596 //qDebug("*************************** ");
2598 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2597 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2599 QStringList er = remote->uidList(); 2598 QStringList er = remote->uidList();
2600 Addressee inR ;//= er.first(); 2599 Addressee inR ;//= er.first();
2601 Addressee inL; 2600 Addressee inL;
2602 2601
2603 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2602 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2604 2603
2605 int modulo = (er.count()/10)+1; 2604 int modulo = (er.count()/10)+1;
2606 int incCounter = 0; 2605 int incCounter = 0;
2607 while ( incCounter < er.count()) { 2606 while ( incCounter < er.count()) {
2608 if (syncManager->isProgressBarCanceled()) 2607 if (syncManager->isProgressBarCanceled())
2609 return false; 2608 return false;
2610 if ( incCounter % modulo == 0 ) 2609 if ( incCounter % modulo == 0 )
2611 syncManager->showProgressBar(incCounter); 2610 syncManager->showProgressBar(incCounter);
2612 2611
2613 uid = er[ incCounter ]; 2612 uid = er[ incCounter ];
2614 bool skipIncidence = false; 2613 bool skipIncidence = false;
2615 if ( uid.left(19) == QString("last-syncAddressee-") ) 2614 if ( uid.left(19) == QString("last-syncAddressee-") )
2616 skipIncidence = true; 2615 skipIncidence = true;
2617 QString idS,OidS; 2616 QString idS,OidS;
2618 qApp->processEvents(); 2617 qApp->processEvents();
2619 if ( !skipIncidence ) { 2618 if ( !skipIncidence ) {
2620 inL = local->findByUid( uid ); 2619 inL = local->findByUid( uid );
2621 inR = remote->findByUid( uid ); 2620 inR = remote->findByUid( uid );
2622 //inL.setResource( 0 ); 2621 //inL.setResource( 0 );
2623 //inR.setResource( 0 ); 2622 //inR.setResource( 0 );
2624 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2623 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2625 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2624 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2626 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2625 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2627 //qDebug("take %d %s ", take, inL.summary().latin1()); 2626 //qDebug("take %d %s ", take, inL.summary().latin1());
2628 if ( take == 3 ) 2627 if ( take == 3 )
2629 return false; 2628 return false;
2630 if ( take == 1 ) {// take local ********************** 2629 if ( take == 1 ) {// take local **********************
2631 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2630 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2632 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2631 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2633 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2632 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2634 local->insertAddressee( inL, false ); 2633 local->insertAddressee( inL, false );
2635 idS = inR.externalUID(); 2634 idS = inR.externalUID();
2636 OidS = inR.originalExternalUID(); 2635 OidS = inR.originalExternalUID();
2637 } 2636 }
2638 else 2637 else
2639 idS = inR.IDStr(); 2638 idS = inR.IDStr();
2640 remote->removeAddressee( inR ); 2639 remote->removeAddressee( inR );
2641 inR = inL; 2640 inR = inL;
2642 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2641 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2643 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2642 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2644 inR.setOriginalExternalUID( OidS ); 2643 inR.setOriginalExternalUID( OidS );
2645 inR.setExternalUID( idS ); 2644 inR.setExternalUID( idS );
2646 if ( syncManager->syncWithDesktop() ) 2645 if ( syncManager->syncWithDesktop() ) {
2647 inR.setIDStr("changed" ); 2646 inR.setIDStr("changed" );
2647 }
2648 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2648 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2649 } else { 2649 } else {
2650 inR.setIDStr( idS ); 2650 inR.setIDStr( idS );
2651 } 2651 }
2652 inR.setResource( 0 ); 2652 inR.setResource( 0 );
2653 remote->insertAddressee( inR , false); 2653 remote->insertAddressee( inR , false);
2654 ++changedRemote; 2654 ++changedRemote;
2655 } else { // take == 2 take remote ********************** 2655 } else { // take == 2 take remote **********************
2656 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2656 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2657 if ( inR.revision().date().year() < 2004 ) 2657 if ( inR.revision().date().year() < 2004 )
2658 inR.setRevision( modifiedCalendar ); 2658 inR.setRevision( modifiedCalendar );
2659 } 2659 }
2660 idS = inL.IDStr(); 2660 idS = inL.IDStr();
2661 local->removeAddressee( inL ); 2661 local->removeAddressee( inL );
2662 inL = inR; 2662 inL = inR;
2663 inL.setIDStr( idS ); 2663 inL.setIDStr( idS );
2664 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2664 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2665 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2665 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2666 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2666 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2667 } 2667 }
2668 inL.setResource( 0 ); 2668 inL.setResource( 0 );
2669 local->insertAddressee( inL , false ); 2669 local->insertAddressee( inL , false );
2670 ++changedLocal; 2670 ++changedLocal;
2671 } 2671 }
2672 } 2672 }
2673 } 2673 }
2674 } else { // no conflict ********** add or delete remote 2674 } else { // no conflict ********** add or delete remote
2675 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2675 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2676 QString des = addresseeLSync.note(); 2676 QString des = addresseeLSync.note();
2677 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2677 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2678 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2678 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2679 remote->insertAddressee( inR, false ); 2679 remote->insertAddressee( inR, false );
2680 ++deletedAddresseeR; 2680 ++deletedAddresseeR;
2681 } else { 2681 } else {
2682 inR.setRevision( modifiedCalendar ); 2682 inR.setRevision( modifiedCalendar );
2683 remote->insertAddressee( inR, false ); 2683 remote->insertAddressee( inR, false );
2684 inL = inR; 2684 inL = inR;
2685 inL.setIDStr( ":" ); 2685 inL.setIDStr( ":" );
2686 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2686 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2687 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2687 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2688 inL.setResource( 0 ); 2688 inL.setResource( 0 );
2689 local->insertAddressee( inL , false); 2689 local->insertAddressee( inL , false);
2690 ++addedAddressee; 2690 ++addedAddressee;
2691 } 2691 }
2692 } else { 2692 } else {
2693 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2693 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2694 inR.setRevision( modifiedCalendar ); 2694 inR.setRevision( modifiedCalendar );
2695 remote->insertAddressee( inR, false ); 2695 remote->insertAddressee( inR, false );
2696 inR.setResource( 0 ); 2696 inR.setResource( 0 );
2697 local->insertAddressee( inR, false ); 2697 local->insertAddressee( inR, false );
2698 ++addedAddressee; 2698 ++addedAddressee;
2699 } else { 2699 } else {
2700 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2700 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2701 remote->removeAddressee( inR ); 2701 remote->removeAddressee( inR );
2702 ++deletedAddresseeR; 2702 ++deletedAddresseeR;
2703 } 2703 }
2704 } 2704 }
2705 } 2705 }
2706 } 2706 }
2707 ++incCounter; 2707 ++incCounter;
2708 } 2708 }
2709 er.clear(); 2709 er.clear();
2710 QStringList el = local->uidList(); 2710 QStringList el = local->uidList();
2711 modulo = (el.count()/10)+1; 2711 modulo = (el.count()/10)+1;
2712 2712
2713 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2713 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2714 incCounter = 0; 2714 incCounter = 0;
2715 while ( incCounter < el.count()) { 2715 while ( incCounter < el.count()) {
2716 qApp->processEvents(); 2716 qApp->processEvents();
2717 if (syncManager->isProgressBarCanceled()) 2717 if (syncManager->isProgressBarCanceled())
2718 return false; 2718 return false;
2719 if ( incCounter % modulo == 0 ) 2719 if ( incCounter % modulo == 0 )
2720 syncManager->showProgressBar(incCounter); 2720 syncManager->showProgressBar(incCounter);
2721 uid = el[ incCounter ]; 2721 uid = el[ incCounter ];
2722 bool skipIncidence = false; 2722 bool skipIncidence = false;
2723 if ( uid.left(19) == QString("last-syncAddressee-") ) 2723 if ( uid.left(19) == QString("last-syncAddressee-") )
2724 skipIncidence = true; 2724 skipIncidence = true;
2725 if ( !skipIncidence ) { 2725 if ( !skipIncidence ) {
2726 inL = local->findByUid( uid ); 2726 inL = local->findByUid( uid );
2727 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2727 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2728 inR = remote->findByUid( uid ); 2728 inR = remote->findByUid( uid );
2729 if ( inR.isEmpty() ) { // no conflict ********** add or delete local 2729 if ( inR.isEmpty() ) { // no conflict ********** add or delete local
2730 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2730 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2731 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2731 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2732 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2732 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2733 local->removeAddressee( inL ); 2733 local->removeAddressee( inL );
2734 ++deletedAddresseeL; 2734 ++deletedAddresseeL;
2735 } else { 2735 } else {
2736 if ( ! syncManager->mWriteBackExistingOnly ) { 2736 if ( ! syncManager->mWriteBackExistingOnly ) {
2737 inL.removeID(mCurrentSyncDevice ); 2737 inL.removeID(mCurrentSyncDevice );
2738 ++addedAddresseeR; 2738 ++addedAddresseeR;
2739 inL.setRevision( modifiedCalendar ); 2739 inL.setRevision( modifiedCalendar );
2740 local->insertAddressee( inL, false ); 2740 local->insertAddressee( inL, false );
2741 inR = inL; 2741 inR = inL;
2742 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2742 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2743 inR.setResource( 0 ); 2743 inR.setResource( 0 );
2744 remote->insertAddressee( inR, false ); 2744 remote->insertAddressee( inR, false );
2745 } 2745 }
2746 } 2746 }
2747 } else { 2747 } else {
2748 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2748 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2749 //qDebug("data %s ", inL.revision().toString().latin1());
2749 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2750 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2750 local->removeAddressee( inL ); 2751 local->removeAddressee( inL );
2751 ++deletedAddresseeL; 2752 ++deletedAddresseeL;
2752 } else { 2753 } else {
2753 if ( ! syncManager->mWriteBackExistingOnly ) { 2754 if ( ! syncManager->mWriteBackExistingOnly ) {
2754 ++addedAddresseeR; 2755 ++addedAddresseeR;
2755 inL.setRevision( modifiedCalendar ); 2756 inL.setRevision( modifiedCalendar );
2756 local->insertAddressee( inL, false ); 2757 local->insertAddressee( inL, false );
2757 inR = inL; 2758 inR = inL;
2758 inR.setIDStr( ":" ); 2759 inR.setIDStr( ":" );
2759 inR.setResource( 0 ); 2760 inR.setResource( 0 );
2760 remote->insertAddressee( inR, false ); 2761 remote->insertAddressee( inR, false );
2761 } 2762 }
2762 } 2763 }
2763 } 2764 }
2764 } 2765 }
2765 } 2766 }
2766 } 2767 }
2767 ++incCounter; 2768 ++incCounter;
2768 } 2769 }
2769 el.clear(); 2770 el.clear();
2770 syncManager->hideProgressBar(); 2771 syncManager->hideProgressBar();
2771 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2772 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2772 // get rid of micro seconds 2773 // get rid of micro seconds
2773 QTime t = mLastAddressbookSync.time(); 2774 QTime t = mLastAddressbookSync.time();
2774 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2775 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2775 addresseeLSync.setRevision( mLastAddressbookSync ); 2776 addresseeLSync.setRevision( mLastAddressbookSync );
2776 addresseeRSync.setRevision( mLastAddressbookSync ); 2777 addresseeRSync.setRevision( mLastAddressbookSync );
2777 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2778 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2778 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2779 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2779 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2780 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2780 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2781 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2781 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2782 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2782 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2783 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2783 addresseeRSync.setNote( "" ) ; 2784 addresseeRSync.setNote( "" ) ;
2784 addresseeLSync.setNote( "" ); 2785 addresseeLSync.setNote( "" );
2785 2786
2786 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2787 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2787 remote->insertAddressee( addresseeRSync, false ); 2788 remote->insertAddressee( addresseeRSync, false );
2788 local->insertAddressee( addresseeLSync, false ); 2789 local->insertAddressee( addresseeLSync, false );
2789 QString mes; 2790 QString mes;
2790 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2791 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2791 qDebug( mes ); 2792 qDebug( mes );
2792 mes = i18n("Local addressbook changed!\n") +mes; 2793 mes = i18n("Local addressbook changed!\n") +mes;
2793 if ( syncManager->mShowSyncSummary ) { 2794 if ( syncManager->mShowSyncSummary ) {
2794 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 2795 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
2795 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 2796 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
2796 qDebug("cancelled "); 2797 qDebug("cancelled ");
2797 return false; 2798 return false;
2798 } 2799 }
2799 } 2800 }
2800 return syncOK; 2801 return syncOK;
2801} 2802}
2802 2803
2803 2804
2804//this is a overwritten callbackmethods from the syncinterface 2805//this is a overwritten callbackmethods from the syncinterface
2805bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2806bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2806{ 2807{
2807 2808
2808 //pending prepare addresseeview for output 2809 //pending prepare addresseeview for output
2809 //pending detect, if remote file has REV field. if not switch to external sync 2810 //pending detect, if remote file has REV field. if not switch to external sync
2810 mGlobalSyncMode = SYNC_MODE_NORMAL; 2811 mGlobalSyncMode = SYNC_MODE_NORMAL;
2811 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2812 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2812 2813
2813 AddressBook abLocal(filename,"syncContact"); 2814 AddressBook abLocal(filename,"syncContact");
2814 bool syncOK = false; 2815 bool syncOK = false;
2815 if ( abLocal.load() ) { 2816 if ( abLocal.load() ) {
2816 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2817 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2817 bool external = false; 2818 bool external = false;
2818 bool isXML = false; 2819 bool isXML = false;
2819 if ( filename.right(4) == ".xml") { 2820 if ( filename.right(4) == ".xml") {
2820 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2821 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2821 isXML = true; 2822 isXML = true;
2822 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2823 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2823 } else { 2824 } else {
2824 external = !manager->mIsKapiFile; 2825 external = !manager->mIsKapiFile;
2825 if ( external ) { 2826 if ( external ) {
2826 qDebug("Setting vcf mode to external "); 2827 qDebug("Setting vcf mode to external ");
2827 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2828 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2828 AddressBook::Iterator it; 2829 AddressBook::Iterator it;
2829 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2830 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2830 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2831 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2831 (*it).computeCsum( mCurrentSyncDevice ); 2832 (*it).computeCsum( mCurrentSyncDevice );
2832 } 2833 }
2833 } 2834 }
2834 } 2835 }
2835 //AddressBook::Iterator it; 2836 //AddressBook::Iterator it;
2836 //QStringList vcards; 2837 //QStringList vcards;
2837 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2838 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2838 // qDebug("Name %s ", (*it).familyName().latin1()); 2839 // qDebug("Name %s ", (*it).familyName().latin1());
2839 //} 2840 //}
2840 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2841 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2841 if ( syncOK ) { 2842 if ( syncOK ) {
2842 if ( syncManager->mWriteBackFile ) 2843 if ( syncManager->mWriteBackFile )
2843 { 2844 {
2844 if ( external ) 2845 if ( external )
2845 abLocal.removeSyncAddressees( !isXML); 2846 abLocal.removeSyncAddressees( !isXML);
2846 qDebug("Saving remote AB "); 2847 qDebug("Saving remote AB ");
2847 if ( ! abLocal.saveAB()) 2848 if ( ! abLocal.saveAB())
2848 qDebug("Error writing back AB to file "); 2849 qDebug("Error writing back AB to file ");
2849 if ( external ) { 2850 if ( external ) {
2850 // afterwrite processing 2851 // afterwrite processing
2851 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 2852 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
2852 } 2853 }
2853 } 2854 }
2854 } 2855 }
2855 setModified(); 2856 setModified();
2856 2857
2857 } 2858 }
2858 if ( syncOK ) 2859 if ( syncOK )
2859 mViewManager->refreshView(); 2860 mViewManager->refreshView();
2860 return syncOK; 2861 return syncOK;
2861 2862
2862} 2863}
2863void KABCore::removeSyncInfo( QString syncProfile) 2864void KABCore::removeSyncInfo( QString syncProfile)
2864{ 2865{
2865 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 2866 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
2866 mAddressBook->removeSyncInfo( syncProfile ); 2867 mAddressBook->removeSyncInfo( syncProfile );
2867 setModified(); 2868 setModified();
2868} 2869}
2869 2870
2870 2871
2871//this is a overwritten callbackmethods from the syncinterface 2872//this is a overwritten callbackmethods from the syncinterface
2872bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2873bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2873{ 2874{
2874 if ( resource == "phone" ) 2875 if ( resource == "phone" )
2875 return syncPhone(); 2876 return syncPhone();
2876 disableBR( true ); 2877 disableBR( true );
2877 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2878 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2878 2879
2879 AddressBook abLocal( resource,"syncContact"); 2880 AddressBook abLocal( resource,"syncContact");
2880 bool syncOK = false; 2881 bool syncOK = false;
2881 if ( abLocal.load() ) { 2882 if ( abLocal.load() ) {
2882 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2883 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2883 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2884 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2884 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 2885 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
2885 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2886 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2886 if ( syncOK ) { 2887 if ( syncOK ) {
2887 if ( syncManager->mWriteBackFile ) { 2888 if ( syncManager->mWriteBackFile ) {
2888 abLocal.removeSyncAddressees( false ); 2889 abLocal.removeSyncAddressees( false );
2889 abLocal.saveAB(); 2890 abLocal.saveAB();
2890 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 2891 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
2891 } 2892 }
2892 } else 2893 } else
2893 message( i18n("Sync cancelled or failed.") ); 2894 message( i18n("Sync cancelled or failed.") );
2894 setModified(); 2895 setModified();
2895 } 2896 }
2896 if ( syncOK ) 2897 if ( syncOK )
2897 mViewManager->refreshView(); 2898 mViewManager->refreshView();
2898 disableBR( false ); 2899 disableBR( false );
2899 return syncOK; 2900 return syncOK;
2900 2901
2901} 2902}
2902void KABCore::message( QString m ) 2903void KABCore::message( QString m )
2903{ 2904{
2904 topLevelWidget()->setCaption( m ); 2905 topLevelWidget()->setCaption( m );
2905 mMessageTimer->start( 15000, true ); 2906 mMessageTimer->start( 15000, true );
2906} 2907}
2907bool KABCore::syncPhone() 2908bool KABCore::syncPhone()
2908{ 2909{
2909 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2910 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2910 QString fileName = getPhoneFile(); 2911 QString fileName = getPhoneFile();
2911 if ( !PhoneAccess::readFromPhone( fileName) ) { 2912 if ( !PhoneAccess::readFromPhone( fileName) ) {
2912 message(i18n("Phone access failed!")); 2913 message(i18n("Phone access failed!"));
2913 return false; 2914 return false;
2914 } 2915 }
2915 AddressBook abLocal( fileName,"syncContact"); 2916 AddressBook abLocal( fileName,"syncContact");
2916 bool syncOK = false; 2917 bool syncOK = false;
2917 { 2918 {
2918 abLocal.importFromFile( fileName ); 2919 abLocal.importFromFile( fileName );
2919 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2920 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2920 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2921 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2921 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2922 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2922 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2923 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2923 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2924 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2924 if ( syncOK ) { 2925 if ( syncOK ) {
2925 if ( syncManager->mWriteBackFile ) { 2926 if ( syncManager->mWriteBackFile ) {
2926 abLocal.removeSyncAddressees( true ); 2927 abLocal.removeSyncAddressees( true );
2927 abLocal.saveABphone( fileName ); 2928 abLocal.saveABphone( fileName );
2928 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 2929 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2929 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2930 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2930 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 2931 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
2931 } 2932 }
2932 } 2933 }
2933 setModified(); 2934 setModified();
2934 } 2935 }
2935 if ( syncOK ) 2936 if ( syncOK )
2936 mViewManager->refreshView(); 2937 mViewManager->refreshView();
2937 return syncOK; 2938 return syncOK;
2938} 2939}
2939void KABCore::getFile( bool success ) 2940void KABCore::getFile( bool success )
2940{ 2941{
2941 if ( ! success ) { 2942 if ( ! success ) {
2942 message( i18n("Error receiving file. Nothing changed!") ); 2943 message( i18n("Error receiving file. Nothing changed!") );
2943 return; 2944 return;
2944 } 2945 }
2945 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 2946 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
2946 if ( count ) 2947 if ( count )
2947 setModified( true ); 2948 setModified( true );
2948 message( i18n("Pi-Sync successful!") ); 2949 message( i18n("Pi-Sync successful!") );
2949 mViewManager->refreshView(); 2950 mViewManager->refreshView();
2950} 2951}
2951void KABCore::syncFileRequest() 2952void KABCore::syncFileRequest()
2952{ 2953{
2953 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 2954 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
2954 syncManager->slotSyncMenu( 999 ); 2955 syncManager->slotSyncMenu( 999 );
2955 } 2956 }
2956 mAddressBook->export2File( sentSyncFile() ); 2957 mAddressBook->export2File( sentSyncFile() );
2957} 2958}
2958QString KABCore::sentSyncFile() 2959QString KABCore::sentSyncFile()
2959{ 2960{
2960#ifdef DESKTOP_VERSION 2961#ifdef DESKTOP_VERSION
2961 return locateLocal( "tmp", "copysyncab.vcf" ); 2962 return locateLocal( "tmp", "copysyncab.vcf" );
2962#else 2963#else
2963 return QString( "/tmp/copysyncab.vcf" ); 2964 return QString( "/tmp/copysyncab.vcf" );
2964#endif 2965#endif
2965} 2966}
2966 2967
2967void KABCore::setCaptionBack() 2968void KABCore::setCaptionBack()
2968{ 2969{
2969 mMessageTimer->stop(); 2970 mMessageTimer->stop();
2970 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2971 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2971} 2972}
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 59f3b40..f8d752a 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -932,512 +932,513 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
934 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 934 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
935 } else { 935 } else {
936 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 936 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
937 } 937 }
938 } 938 }
939 QDateTime modifiedCalendar = mLastCalendarSync; 939 QDateTime modifiedCalendar = mLastCalendarSync;
940 eventLSync = getLastSyncEvent(); 940 eventLSync = getLastSyncEvent();
941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
942 if ( eventR ) { 942 if ( eventR ) {
943 eventRSync = (Event*) eventR->clone(); 943 eventRSync = (Event*) eventR->clone();
944 remote->deleteEvent(eventR ); 944 remote->deleteEvent(eventR );
945 945
946 } else { 946 } else {
947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
948 eventRSync = (Event*)eventLSync->clone(); 948 eventRSync = (Event*)eventLSync->clone();
949 } else { 949 } else {
950 fullDateRange = true; 950 fullDateRange = true;
951 eventRSync = new Event(); 951 eventRSync = new Event();
952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
954 eventRSync->setDtStart( mLastCalendarSync ); 954 eventRSync->setDtStart( mLastCalendarSync );
955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
956 eventRSync->setCategories( i18n("SyncEvent") ); 956 eventRSync->setCategories( i18n("SyncEvent") );
957 } 957 }
958 } 958 }
959 if ( eventLSync->dtStart() == mLastCalendarSync ) 959 if ( eventLSync->dtStart() == mLastCalendarSync )
960 fullDateRange = true; 960 fullDateRange = true;
961 961
962 if ( ! fullDateRange ) { 962 if ( ! fullDateRange ) {
963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
964 964
965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
967 fullDateRange = true; 967 fullDateRange = true;
968 } 968 }
969 } 969 }
970 if ( mSyncManager->syncWithDesktop() ) { 970 if ( mSyncManager->syncWithDesktop() ) {
971 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 971 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
972 } 972 }
973 if ( fullDateRange ) 973 if ( fullDateRange )
974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
975 else 975 else
976 mLastCalendarSync = eventLSync->dtStart(); 976 mLastCalendarSync = eventLSync->dtStart();
977 // for resyncing if own file has changed 977 // for resyncing if own file has changed
978 if ( mCurrentSyncDevice == "deleteaftersync" ) { 978 if ( mCurrentSyncDevice == "deleteaftersync" ) {
979 mLastCalendarSync = loadedFileVersion; 979 mLastCalendarSync = loadedFileVersion;
980 //qDebug("setting mLastCalendarSync "); 980 //qDebug("setting mLastCalendarSync ");
981 } 981 }
982 //qDebug("*************************** "); 982 //qDebug("*************************** ");
983 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 983 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
984 QPtrList<Incidence> er = remote->rawIncidences(); 984 QPtrList<Incidence> er = remote->rawIncidences();
985 Incidence* inR = er.first(); 985 Incidence* inR = er.first();
986 Incidence* inL; 986 Incidence* inL;
987 QProgressBar bar( er.count(),0 ); 987 QProgressBar bar( er.count(),0 );
988 bar.setCaption (i18n("Syncing - close to abort!") ); 988 bar.setCaption (i18n("Syncing - close to abort!") );
989 989
990 int w = 300; 990 int w = 300;
991 if ( QApplication::desktop()->width() < 320 ) 991 if ( QApplication::desktop()->width() < 320 )
992 w = 220; 992 w = 220;
993 int h = bar.sizeHint().height() ; 993 int h = bar.sizeHint().height() ;
994 int dw = QApplication::desktop()->width(); 994 int dw = QApplication::desktop()->width();
995 int dh = QApplication::desktop()->height(); 995 int dh = QApplication::desktop()->height();
996 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 996 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
997 bar.show(); 997 bar.show();
998 int modulo = (er.count()/10)+1; 998 int modulo = (er.count()/10)+1;
999 int incCounter = 0; 999 int incCounter = 0;
1000 while ( inR ) { 1000 while ( inR ) {
1001 if ( ! bar.isVisible() ) 1001 if ( ! bar.isVisible() )
1002 return false; 1002 return false;
1003 if ( incCounter % modulo == 0 ) 1003 if ( incCounter % modulo == 0 )
1004 bar.setProgress( incCounter ); 1004 bar.setProgress( incCounter );
1005 ++incCounter; 1005 ++incCounter;
1006 uid = inR->uid(); 1006 uid = inR->uid();
1007 bool skipIncidence = false; 1007 bool skipIncidence = false;
1008 if ( uid.left(15) == QString("last-syncEvent-") ) 1008 if ( uid.left(15) == QString("last-syncEvent-") )
1009 skipIncidence = true; 1009 skipIncidence = true;
1010 QString idS; 1010 QString idS;
1011 qApp->processEvents(); 1011 qApp->processEvents();
1012 if ( !skipIncidence ) { 1012 if ( !skipIncidence ) {
1013 inL = local->incidence( uid ); 1013 inL = local->incidence( uid );
1014 if ( inL ) { // maybe conflict - same uid in both calendars 1014 if ( inL ) { // maybe conflict - same uid in both calendars
1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1016 //qDebug("take %d %s ", take, inL->summary().latin1()); 1016 //qDebug("take %d %s ", take, inL->summary().latin1());
1017 if ( take == 3 ) 1017 if ( take == 3 )
1018 return false; 1018 return false;
1019 if ( take == 1 ) {// take local ********************** 1019 if ( take == 1 ) {// take local **********************
1020 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1020 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1021 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1021 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1022 else 1022 else
1023 idS = inR->IDStr(); 1023 idS = inR->IDStr();
1024 remote->deleteIncidence( inR ); 1024 remote->deleteIncidence( inR );
1025 inR = inL->clone(); 1025 inR = inL->clone();
1026 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1026 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1027 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1027 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1028 inR->setIDStr( idS ); 1028 inR->setIDStr( idS );
1029 remote->addIncidence( inR ); 1029 remote->addIncidence( inR );
1030 if ( mSyncManager->syncWithDesktop() ) 1030 if ( mSyncManager->syncWithDesktop() )
1031 inR->setPilotId( 2 ); 1031 inR->setPilotId( 2 );
1032 ++changedRemote; 1032 ++changedRemote;
1033 } else {// take remote ********************** 1033 } else {// take remote **********************
1034 idS = inL->IDStr(); 1034 idS = inL->IDStr();
1035 int pid = inL->pilotId(); 1035 int pid = inL->pilotId();
1036 local->deleteIncidence( inL ); 1036 local->deleteIncidence( inL );
1037 inL = inR->clone(); 1037 inL = inR->clone();
1038 if ( mSyncManager->syncWithDesktop() ) 1038 if ( mSyncManager->syncWithDesktop() )
1039 inL->setPilotId( pid ); 1039 inL->setPilotId( pid );
1040 inL->setIDStr( idS ); 1040 inL->setIDStr( idS );
1041 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1041 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1042 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1042 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1043 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1043 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1044 } 1044 }
1045 local->addIncidence( inL ); 1045 local->addIncidence( inL );
1046 ++changedLocal; 1046 ++changedLocal;
1047 } 1047 }
1048 } 1048 }
1049 } else { // no conflict ********** add or delete remote 1049 } else { // no conflict ********** add or delete remote
1050 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1050 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1051 QString des = eventLSync->description(); 1051 QString des = eventLSync->description();
1052 QString pref = "e"; 1052 QString pref = "e";
1053 if ( inR->type() == "Todo" ) 1053 if ( inR->type() == "Todo" )
1054 pref = "t"; 1054 pref = "t";
1055 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1055 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1056 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1056 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1057 //remote->deleteIncidence( inR ); 1057 //remote->deleteIncidence( inR );
1058 ++deletedEventR; 1058 ++deletedEventR;
1059 } else { 1059 } else {
1060 inR->setLastModified( modifiedCalendar ); 1060 inR->setLastModified( modifiedCalendar );
1061 inL = inR->clone(); 1061 inL = inR->clone();
1062 inL->setIDStr( ":" ); 1062 inL->setIDStr( ":" );
1063 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1063 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1064 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1064 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1065 local->addIncidence( inL ); 1065 local->addIncidence( inL );
1066 ++addedEvent; 1066 ++addedEvent;
1067 } 1067 }
1068 } else { 1068 } else {
1069 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1069 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1070 inR->setLastModified( modifiedCalendar ); 1070 inR->setLastModified( modifiedCalendar );
1071 inL = inR->clone(); 1071 inL = inR->clone();
1072 inL->setIDStr( ":" ); 1072 inL->setIDStr( ":" );
1073 local->addIncidence( inL ); 1073 local->addIncidence( inL );
1074 ++addedEvent; 1074 ++addedEvent;
1075 } else { 1075 } else {
1076 checkExternSyncEvent(eventRSyncSharp, inR); 1076 checkExternSyncEvent(eventRSyncSharp, inR);
1077 remote->deleteIncidence( inR ); 1077 remote->deleteIncidence( inR );
1078 ++deletedEventR; 1078 ++deletedEventR;
1079 } 1079 }
1080 } 1080 }
1081 } 1081 }
1082 } 1082 }
1083 inR = er.next(); 1083 inR = er.next();
1084 } 1084 }
1085 QPtrList<Incidence> el = local->rawIncidences(); 1085 QPtrList<Incidence> el = local->rawIncidences();
1086 inL = el.first(); 1086 inL = el.first();
1087 modulo = (el.count()/10)+1; 1087 modulo = (el.count()/10)+1;
1088 bar.setCaption (i18n("Add / remove events") ); 1088 bar.setCaption (i18n("Add / remove events") );
1089 bar.setTotalSteps ( el.count() ) ; 1089 bar.setTotalSteps ( el.count() ) ;
1090 bar.show(); 1090 bar.show();
1091 incCounter = 0; 1091 incCounter = 0;
1092 1092
1093 while ( inL ) { 1093 while ( inL ) {
1094 1094
1095 qApp->processEvents(); 1095 qApp->processEvents();
1096 if ( ! bar.isVisible() ) 1096 if ( ! bar.isVisible() )
1097 return false; 1097 return false;
1098 if ( incCounter % modulo == 0 ) 1098 if ( incCounter % modulo == 0 )
1099 bar.setProgress( incCounter ); 1099 bar.setProgress( incCounter );
1100 ++incCounter; 1100 ++incCounter;
1101 uid = inL->uid(); 1101 uid = inL->uid();
1102 bool skipIncidence = false; 1102 bool skipIncidence = false;
1103 if ( uid.left(15) == QString("last-syncEvent-") ) 1103 if ( uid.left(15) == QString("last-syncEvent-") )
1104 skipIncidence = true; 1104 skipIncidence = true;
1105 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1105 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1106 skipIncidence = true; 1106 skipIncidence = true;
1107 if ( !skipIncidence ) { 1107 if ( !skipIncidence ) {
1108 inR = remote->incidence( uid ); 1108 inR = remote->incidence( uid );
1109 if ( ! inR ) { // no conflict ********** add or delete local 1109 if ( ! inR ) { // no conflict ********** add or delete local
1110 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1110 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1111 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1111 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1112 checkExternSyncEvent(eventLSyncSharp, inL); 1112 checkExternSyncEvent(eventLSyncSharp, inL);
1113 local->deleteIncidence( inL ); 1113 local->deleteIncidence( inL );
1114 ++deletedEventL; 1114 ++deletedEventL;
1115 } else { 1115 } else {
1116 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1116 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1117 inL->removeID(mCurrentSyncDevice ); 1117 inL->removeID(mCurrentSyncDevice );
1118 ++addedEventR; 1118 ++addedEventR;
1119 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1119 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1120 inL->setLastModified( modifiedCalendar ); 1120 inL->setLastModified( modifiedCalendar );
1121 inR = inL->clone(); 1121 inR = inL->clone();
1122 inR->setIDStr( ":" ); 1122 inR->setIDStr( ":" );
1123 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1123 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1124 remote->addIncidence( inR ); 1124 remote->addIncidence( inR );
1125 } 1125 }
1126 } 1126 }
1127 } else { 1127 } else {
1128 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1128 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1129 checkExternSyncEvent(eventLSyncSharp, inL); 1129 checkExternSyncEvent(eventLSyncSharp, inL);
1130 local->deleteIncidence( inL ); 1130 local->deleteIncidence( inL );
1131 ++deletedEventL; 1131 ++deletedEventL;
1132 } else { 1132 } else {
1133 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1133 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1134 ++addedEventR; 1134 ++addedEventR;
1135 inL->setLastModified( modifiedCalendar ); 1135 inL->setLastModified( modifiedCalendar );
1136 inR = inL->clone(); 1136 inR = inL->clone();
1137 inR->setIDStr( ":" ); 1137 inR->setIDStr( ":" );
1138 remote->addIncidence( inR ); 1138 remote->addIncidence( inR );
1139 } 1139 }
1140 } 1140 }
1141 } 1141 }
1142 } 1142 }
1143 } 1143 }
1144 inL = el.next(); 1144 inL = el.next();
1145 } 1145 }
1146 int delFut = 0; 1146 int delFut = 0;
1147 int remRem = 0; 1147 int remRem = 0;
1148 if ( mSyncManager->mWriteBackInFuture ) { 1148 if ( mSyncManager->mWriteBackInFuture ) {
1149 er = remote->rawIncidences(); 1149 er = remote->rawIncidences();
1150 remRem = er.count(); 1150 remRem = er.count();
1151 inR = er.first(); 1151 inR = er.first();
1152 QDateTime dt; 1152 QDateTime dt;
1153 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1153 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1154 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); 1154 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
1155 while ( inR ) { 1155 while ( inR ) {
1156 if ( inR->type() == "Todo" ) { 1156 if ( inR->type() == "Todo" ) {
1157 Todo * t = (Todo*)inR; 1157 Todo * t = (Todo*)inR;
1158 if ( t->hasDueDate() ) 1158 if ( t->hasDueDate() )
1159 dt = t->dtDue(); 1159 dt = t->dtDue();
1160 else 1160 else
1161 dt = cur.addSecs( 62 ); 1161 dt = cur.addSecs( 62 );
1162 } 1162 }
1163 else if (inR->type() == "Event" ) { 1163 else if (inR->type() == "Event" ) {
1164 bool ok; 1164 bool ok;
1165 dt = inR->getNextOccurence( cur, &ok ); 1165 dt = inR->getNextOccurence( cur, &ok );
1166 if ( !ok ) 1166 if ( !ok )
1167 dt = cur.addSecs( -62 ); 1167 dt = cur.addSecs( -62 );
1168 } 1168 }
1169 else 1169 else
1170 dt = inR->dtStart(); 1170 dt = inR->dtStart();
1171 if ( dt < cur || dt > end ) { 1171 if ( dt < cur || dt > end ) {
1172 remote->deleteIncidence( inR ); 1172 remote->deleteIncidence( inR );
1173 ++delFut; 1173 ++delFut;
1174 } 1174 }
1175 inR = er.next(); 1175 inR = er.next();
1176 } 1176 }
1177 } 1177 }
1178 bar.hide(); 1178 bar.hide();
1179 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1179 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1180 eventLSync->setReadOnly( false ); 1180 eventLSync->setReadOnly( false );
1181 eventLSync->setDtStart( mLastCalendarSync ); 1181 eventLSync->setDtStart( mLastCalendarSync );
1182 eventRSync->setDtStart( mLastCalendarSync ); 1182 eventRSync->setDtStart( mLastCalendarSync );
1183 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1183 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1184 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1184 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1185 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1185 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1186 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1186 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1187 eventLSync->setReadOnly( true ); 1187 eventLSync->setReadOnly( true );
1188 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() );
1188 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1189 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1189 remote->addEvent( eventRSync ); 1190 remote->addEvent( eventRSync );
1190 else 1191 else
1191 delete eventRSync; 1192 delete eventRSync;
1192 QString mes; 1193 QString mes;
1193 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1194 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1194 QString delmess; 1195 QString delmess;
1195 if ( delFut ) { 1196 if ( delFut ) {
1196 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); 1197 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut);
1197 mes += delmess; 1198 mes += delmess;
1198 } 1199 }
1199 mes = i18n("Local calendar changed!\n") +mes; 1200 mes = i18n("Local calendar changed!\n") +mes;
1200 mCalendar->checkAlarmForIncidence( 0, true ); 1201 mCalendar->checkAlarmForIncidence( 0, true );
1201 qDebug( mes ); 1202 qDebug( mes );
1202 if ( mSyncManager->mShowSyncSummary ) { 1203 if ( mSyncManager->mShowSyncSummary ) {
1203 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1204 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1204 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1205 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1205 qDebug("cancelled "); 1206 qDebug("cancelled ");
1206 return false; 1207 return false;
1207 } 1208 }
1208 } 1209 }
1209 return syncOK; 1210 return syncOK;
1210} 1211}
1211 1212
1212void CalendarView::setSyncDevice( QString s ) 1213void CalendarView::setSyncDevice( QString s )
1213{ 1214{
1214 mCurrentSyncDevice= s; 1215 mCurrentSyncDevice= s;
1215} 1216}
1216void CalendarView::setSyncName( QString s ) 1217void CalendarView::setSyncName( QString s )
1217{ 1218{
1218 mCurrentSyncName= s; 1219 mCurrentSyncName= s;
1219} 1220}
1220bool CalendarView::syncCalendar(QString filename, int mode) 1221bool CalendarView::syncCalendar(QString filename, int mode)
1221{ 1222{
1222 //qDebug("syncCalendar %s ", filename.latin1()); 1223 //qDebug("syncCalendar %s ", filename.latin1());
1223 mGlobalSyncMode = SYNC_MODE_NORMAL; 1224 mGlobalSyncMode = SYNC_MODE_NORMAL;
1224 CalendarLocal* calendar = new CalendarLocal(); 1225 CalendarLocal* calendar = new CalendarLocal();
1225 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1226 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1226 FileStorage* storage = new FileStorage( calendar ); 1227 FileStorage* storage = new FileStorage( calendar );
1227 bool syncOK = false; 1228 bool syncOK = false;
1228 storage->setFileName( filename ); 1229 storage->setFileName( filename );
1229 // qDebug("loading ... "); 1230 // qDebug("loading ... ");
1230 if ( storage->load() ) { 1231 if ( storage->load() ) {
1231 getEventViewerDialog()->setSyncMode( true ); 1232 getEventViewerDialog()->setSyncMode( true );
1232 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1233 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1233 getEventViewerDialog()->setSyncMode( false ); 1234 getEventViewerDialog()->setSyncMode( false );
1234 if ( syncOK ) { 1235 if ( syncOK ) {
1235 if ( mSyncManager->mWriteBackFile ) 1236 if ( mSyncManager->mWriteBackFile )
1236 { 1237 {
1237 storage->setSaveFormat( new ICalFormat() ); 1238 storage->setSaveFormat( new ICalFormat() );
1238 storage->save(); 1239 storage->save();
1239 } 1240 }
1240 } 1241 }
1241 setModified( true ); 1242 setModified( true );
1242 } 1243 }
1243 delete storage; 1244 delete storage;
1244 delete calendar; 1245 delete calendar;
1245 if ( syncOK ) 1246 if ( syncOK )
1246 updateView(); 1247 updateView();
1247 return syncOK; 1248 return syncOK;
1248} 1249}
1249 1250
1250void CalendarView::syncExternal( int mode ) 1251void CalendarView::syncExternal( int mode )
1251{ 1252{
1252 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1253 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1253 1254
1254 qApp->processEvents(); 1255 qApp->processEvents();
1255 CalendarLocal* calendar = new CalendarLocal(); 1256 CalendarLocal* calendar = new CalendarLocal();
1256 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1257 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1257 bool syncOK = false; 1258 bool syncOK = false;
1258 bool loadSuccess = false; 1259 bool loadSuccess = false;
1259 PhoneFormat* phoneFormat = 0; 1260 PhoneFormat* phoneFormat = 0;
1260 emit tempDisableBR(true); 1261 emit tempDisableBR(true);
1261#ifndef DESKTOP_VERSION 1262#ifndef DESKTOP_VERSION
1262 SharpFormat* sharpFormat = 0; 1263 SharpFormat* sharpFormat = 0;
1263 if ( mode == 0 ) { // sharp 1264 if ( mode == 0 ) { // sharp
1264 sharpFormat = new SharpFormat () ; 1265 sharpFormat = new SharpFormat () ;
1265 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1266 loadSuccess = sharpFormat->load( calendar, mCalendar );
1266 1267
1267 } else 1268 } else
1268#endif 1269#endif
1269 if ( mode == 1 ) { // phone 1270 if ( mode == 1 ) { // phone
1270 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1271 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1271 mSyncManager->mPhoneDevice, 1272 mSyncManager->mPhoneDevice,
1272 mSyncManager->mPhoneConnection, 1273 mSyncManager->mPhoneConnection,
1273 mSyncManager->mPhoneModel); 1274 mSyncManager->mPhoneModel);
1274 loadSuccess = phoneFormat->load( calendar,mCalendar); 1275 loadSuccess = phoneFormat->load( calendar,mCalendar);
1275 1276
1276 } else { 1277 } else {
1277 emit tempDisableBR(false); 1278 emit tempDisableBR(false);
1278 return; 1279 return;
1279 } 1280 }
1280 if ( loadSuccess ) { 1281 if ( loadSuccess ) {
1281 getEventViewerDialog()->setSyncMode( true ); 1282 getEventViewerDialog()->setSyncMode( true );
1282 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1283 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1283 getEventViewerDialog()->setSyncMode( false ); 1284 getEventViewerDialog()->setSyncMode( false );
1284 qApp->processEvents(); 1285 qApp->processEvents();
1285 if ( syncOK ) { 1286 if ( syncOK ) {
1286 if ( mSyncManager->mWriteBackFile ) 1287 if ( mSyncManager->mWriteBackFile )
1287 { 1288 {
1288 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1289 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1289 Incidence* inc = iL.first(); 1290 Incidence* inc = iL.first();
1290 if ( phoneFormat ) { 1291 if ( phoneFormat ) {
1291 while ( inc ) { 1292 while ( inc ) {
1292 inc->removeID(mCurrentSyncDevice); 1293 inc->removeID(mCurrentSyncDevice);
1293 inc = iL.next(); 1294 inc = iL.next();
1294 } 1295 }
1295 } 1296 }
1296#ifndef DESKTOP_VERSION 1297#ifndef DESKTOP_VERSION
1297 if ( sharpFormat ) 1298 if ( sharpFormat )
1298 sharpFormat->save(calendar); 1299 sharpFormat->save(calendar);
1299#endif 1300#endif
1300 if ( phoneFormat ) 1301 if ( phoneFormat )
1301 phoneFormat->save(calendar); 1302 phoneFormat->save(calendar);
1302 iL = calendar->rawIncidences(); 1303 iL = calendar->rawIncidences();
1303 inc = iL.first(); 1304 inc = iL.first();
1304 Incidence* loc; 1305 Incidence* loc;
1305 while ( inc ) { 1306 while ( inc ) {
1306 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1307 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1307 loc = mCalendar->incidence(inc->uid() ); 1308 loc = mCalendar->incidence(inc->uid() );
1308 if ( loc ) { 1309 if ( loc ) {
1309 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1310 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1310 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1311 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1311 } 1312 }
1312 } 1313 }
1313 inc = iL.next(); 1314 inc = iL.next();
1314 } 1315 }
1315 Incidence* lse = getLastSyncEvent(); 1316 Incidence* lse = getLastSyncEvent();
1316 if ( lse ) { 1317 if ( lse ) {
1317 lse->setReadOnly( false ); 1318 lse->setReadOnly( false );
1318 lse->setDescription( "" ); 1319 lse->setDescription( "" );
1319 lse->setReadOnly( true ); 1320 lse->setReadOnly( true );
1320 } 1321 }
1321 } 1322 }
1322 } else { 1323 } else {
1323 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1324 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1324 } 1325 }
1325 setModified( true ); 1326 setModified( true );
1326 } else { 1327 } else {
1327 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1328 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1328 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1329 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1329 question, i18n("Ok")) ; 1330 question, i18n("Ok")) ;
1330 1331
1331 } 1332 }
1332 delete calendar; 1333 delete calendar;
1333 updateView(); 1334 updateView();
1334 emit tempDisableBR(false); 1335 emit tempDisableBR(false);
1335 return ;//syncOK; 1336 return ;//syncOK;
1336 1337
1337} 1338}
1338 1339
1339bool CalendarView::importBday() 1340bool CalendarView::importBday()
1340{ 1341{
1341#ifndef KORG_NOKABC 1342#ifndef KORG_NOKABC
1342 1343
1343#ifdef DESKTOP_VERSION 1344#ifdef DESKTOP_VERSION
1344 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1345 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1345 KABC::AddressBook::Iterator it; 1346 KABC::AddressBook::Iterator it;
1346 int count = 0; 1347 int count = 0;
1347 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1348 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1348 ++count; 1349 ++count;
1349 } 1350 }
1350 QProgressBar bar(count,0 ); 1351 QProgressBar bar(count,0 );
1351 int w = 300; 1352 int w = 300;
1352 if ( QApplication::desktop()->width() < 320 ) 1353 if ( QApplication::desktop()->width() < 320 )
1353 w = 220; 1354 w = 220;
1354 int h = bar.sizeHint().height() ; 1355 int h = bar.sizeHint().height() ;
1355 int dw = QApplication::desktop()->width(); 1356 int dw = QApplication::desktop()->width();
1356 int dh = QApplication::desktop()->height(); 1357 int dh = QApplication::desktop()->height();
1357 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1358 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1358 bar.show(); 1359 bar.show();
1359 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1360 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1360 qApp->processEvents(); 1361 qApp->processEvents();
1361 count = 0; 1362 count = 0;
1362 int addCount = 0; 1363 int addCount = 0;
1363 KCal::Attendee* a = 0; 1364 KCal::Attendee* a = 0;
1364 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1365 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1365 if ( ! bar.isVisible() ) 1366 if ( ! bar.isVisible() )
1366 return false; 1367 return false;
1367 bar.setProgress( count++ ); 1368 bar.setProgress( count++ );
1368 qApp->processEvents(); 1369 qApp->processEvents();
1369 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1370 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1370 if ( (*it).birthday().date().isValid() ){ 1371 if ( (*it).birthday().date().isValid() ){
1371 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1372 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1372 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1373 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1373 ++addCount; 1374 ++addCount;
1374 } 1375 }
1375 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1376 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1376 if ( anni.isValid() ){ 1377 if ( anni.isValid() ){
1377 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1378 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1378 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1379 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1379 ++addCount; 1380 ++addCount;
1380 } 1381 }
1381 } 1382 }
1382 updateView(); 1383 updateView();
1383 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1384 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1384#else //DESKTOP_VERSION 1385#else //DESKTOP_VERSION
1385 1386
1386 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1387 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1387 // the result should now arrive through method insertBirthdays 1388 // the result should now arrive through method insertBirthdays
1388 1389
1389#endif //DESKTOP_VERSION 1390#endif //DESKTOP_VERSION
1390 1391
1391#endif //KORG_NOKABC 1392#endif //KORG_NOKABC
1392 1393
1393 1394
1394 return true; 1395 return true;
1395} 1396}
1396 1397
1397// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1398// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1398void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1399void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1399 const QStringList& anniversaryList, const QStringList& realNameList, 1400 const QStringList& anniversaryList, const QStringList& realNameList,
1400 const QStringList& emailList, const QStringList& assembledNameList, 1401 const QStringList& emailList, const QStringList& assembledNameList,
1401 const QStringList& uidList) 1402 const QStringList& uidList)
1402{ 1403{
1403 qDebug("CalendarView::insertBirthdays"); 1404 qDebug("CalendarView::insertBirthdays");
1404 if (uid == this->name()) 1405 if (uid == this->name())
1405 { 1406 {
1406 int count = birthdayList.count(); 1407 int count = birthdayList.count();
1407 int addCount = 0; 1408 int addCount = 0;
1408 KCal::Attendee* a = 0; 1409 KCal::Attendee* a = 0;
1409 1410
1410 qDebug("CalView 1 %i", count); 1411 qDebug("CalView 1 %i", count);
1411 1412
1412 QProgressBar bar(count,0 ); 1413 QProgressBar bar(count,0 );
1413 int w = 300; 1414 int w = 300;
1414 if ( QApplication::desktop()->width() < 320 ) 1415 if ( QApplication::desktop()->width() < 320 )
1415 w = 220; 1416 w = 220;
1416 int h = bar.sizeHint().height() ; 1417 int h = bar.sizeHint().height() ;
1417 int dw = QApplication::desktop()->width(); 1418 int dw = QApplication::desktop()->width();
1418 int dh = QApplication::desktop()->height(); 1419 int dh = QApplication::desktop()->height();
1419 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1420 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1420 bar.show(); 1421 bar.show();
1421 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1422 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1422 qApp->processEvents(); 1423 qApp->processEvents();
1423 1424
1424 QDate birthday; 1425 QDate birthday;
1425 QDate anniversary; 1426 QDate anniversary;
1426 QString realName; 1427 QString realName;
1427 QString email; 1428 QString email;
1428 QString assembledName; 1429 QString assembledName;
1429 QString uid; 1430 QString uid;
1430 bool ok = true; 1431 bool ok = true;
1431 for ( int i = 0; i < count; i++) 1432 for ( int i = 0; i < count; i++)
1432 { 1433 {
1433 if ( ! bar.isVisible() ) 1434 if ( ! bar.isVisible() )
1434 return; 1435 return;
1435 bar.setProgress( i ); 1436 bar.setProgress( i );
1436 qApp->processEvents(); 1437 qApp->processEvents();
1437 1438
1438 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1439 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1439 if (!ok) { 1440 if (!ok) {
1440 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1441 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1441 } 1442 }
1442 1443
1443 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1444 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 21af295..c12ba1c 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -284,546 +284,548 @@ void KSyncManager::slotSyncMenu( int action )
284 case (PWMPI): 284 case (PWMPI):
285 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 285 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
286 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 286 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
287 break; 287 break;
288 default: 288 default:
289 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 289 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
290 break; 290 break;
291 291
292 } 292 }
293 } else { 293 } else {
294 if ( temp->getIsPhoneSync() ) { 294 if ( temp->getIsPhoneSync() ) {
295 mPhoneDevice = temp->getPhoneDevice( ) ; 295 mPhoneDevice = temp->getPhoneDevice( ) ;
296 mPhoneConnection = temp->getPhoneConnection( ); 296 mPhoneConnection = temp->getPhoneConnection( );
297 mPhoneModel = temp->getPhoneModel( ); 297 mPhoneModel = temp->getPhoneModel( );
298 syncPhone(); 298 syncPhone();
299 } else if ( temp->getIsPiSync() ) { 299 } else if ( temp->getIsPiSync() ) {
300 if ( mTargetApp == KAPI ) { 300 if ( mTargetApp == KAPI ) {
301 mPassWordPiSync = temp->getRemotePwAB(); 301 mPassWordPiSync = temp->getRemotePwAB();
302 mActiveSyncPort = temp->getRemotePortAB(); 302 mActiveSyncPort = temp->getRemotePortAB();
303 mActiveSyncIP = temp->getRemoteIPAB(); 303 mActiveSyncIP = temp->getRemoteIPAB();
304 } else if ( mTargetApp == KOPI ) { 304 } else if ( mTargetApp == KOPI ) {
305 mPassWordPiSync = temp->getRemotePw(); 305 mPassWordPiSync = temp->getRemotePw();
306 mActiveSyncPort = temp->getRemotePort(); 306 mActiveSyncPort = temp->getRemotePort();
307 mActiveSyncIP = temp->getRemoteIP(); 307 mActiveSyncIP = temp->getRemoteIP();
308 } else { 308 } else {
309 mPassWordPiSync = temp->getRemotePwPWM(); 309 mPassWordPiSync = temp->getRemotePwPWM();
310 mActiveSyncPort = temp->getRemotePortPWM(); 310 mActiveSyncPort = temp->getRemotePortPWM();
311 mActiveSyncIP = temp->getRemoteIPPWM(); 311 mActiveSyncIP = temp->getRemoteIPPWM();
312 } 312 }
313 syncPi(); 313 syncPi();
314 while ( !mPisyncFinished ) { 314 while ( !mPisyncFinished ) {
315 //qDebug("waiting "); 315 //qDebug("waiting ");
316 qApp->processEvents(); 316 qApp->processEvents();
317 } 317 }
318 } else 318 } else
319 syncRemote( temp ); 319 syncRemote( temp );
320 320
321 } 321 }
322 } 322 }
323 delete temp; 323 delete temp;
324 setBlockSave(false); 324 setBlockSave(false);
325} 325}
326 326
327void KSyncManager::enableQuick( bool ask ) 327void KSyncManager::enableQuick( bool ask )
328{ 328{
329 bool autoStart; 329 bool autoStart;
330 bool changed = false; 330 bool changed = false;
331 if ( ask ) { 331 if ( ask ) {
332 QDialog dia ( 0, "input-dialog", true ); 332 QDialog dia ( 0, "input-dialog", true );
333 QLineEdit lab ( &dia ); 333 QLineEdit lab ( &dia );
334 QVBoxLayout lay( &dia ); 334 QVBoxLayout lay( &dia );
335 lab.setText( mPrefs->mPassiveSyncPort ); 335 lab.setText( mPrefs->mPassiveSyncPort );
336 lay.setMargin(7); 336 lay.setMargin(7);
337 lay.setSpacing(7); 337 lay.setSpacing(7);
338 int po = 9197+mTargetApp; 338 int po = 9197+mTargetApp;
339 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 339 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
340 lay.addWidget( &label); 340 lay.addWidget( &label);
341 lay.addWidget( &lab); 341 lay.addWidget( &lab);
342 342
343 QLineEdit lepw ( &dia ); 343 QLineEdit lepw ( &dia );
344 lepw.setText( mPrefs->mPassiveSyncPw ); 344 lepw.setText( mPrefs->mPassiveSyncPw );
345 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 345 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
346 lay.addWidget( &label2); 346 lay.addWidget( &label2);
347 lay.addWidget( &lepw); 347 lay.addWidget( &lepw);
348 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 348 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
349 lay.addWidget( &autostart); 349 lay.addWidget( &autostart);
350 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 350 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
351#ifdef DESKTOP_VERSION 351#ifdef DESKTOP_VERSION
352#ifdef _WIN32_ 352#ifdef _WIN32_
353 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 353 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
354 syncdesktop.hide();// not implemented! 354 syncdesktop.hide();// not implemented!
355#else 355#else
356 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 356 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
357#endif 357#endif
358 lay.addWidget( &syncdesktop); 358 lay.addWidget( &syncdesktop);
359#else 359#else
360 mPrefs->mPassiveSyncWithDesktop = false; 360 mPrefs->mPassiveSyncWithDesktop = false;
361 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 361 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
362 syncdesktop.hide(); 362 syncdesktop.hide();
363#endif 363#endif
364 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 364 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
365 365
366 dia.setFixedSize( 230,120 ); 366 dia.setFixedSize( 230,120 );
367 dia.setCaption( i18n("Enter port for Pi-Sync") ); 367 dia.setCaption( i18n("Enter port for Pi-Sync") );
368 QPushButton pb ( "OK", &dia); 368 QPushButton pb ( "OK", &dia);
369 lay.addWidget( &pb ); 369 lay.addWidget( &pb );
370 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 370 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
371 dia.show(); 371 dia.show();
372 if ( ! dia.exec() ) 372 if ( ! dia.exec() )
373 return; 373 return;
374 dia.hide(); 374 dia.hide();
375 qApp->processEvents(); 375 qApp->processEvents();
376 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 376 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
377 changed = true; 377 changed = true;
378 mPrefs->mPassiveSyncPw = lepw.text(); 378 mPrefs->mPassiveSyncPw = lepw.text();
379 } 379 }
380 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 380 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
381 mPrefs->mPassiveSyncPort = lab.text(); 381 mPrefs->mPassiveSyncPort = lab.text();
382 changed = true; 382 changed = true;
383 } 383 }
384 autoStart = autostart.isChecked(); 384 autoStart = autostart.isChecked();
385 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 385 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
386 changed = true; 386 changed = true;
387 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 387 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
388 } 388 }
389 } 389 }
390 else 390 else
391 autoStart = mPrefs->mPassiveSyncAutoStart; 391 autoStart = mPrefs->mPassiveSyncAutoStart;
392 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 392 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
393 changed = true; 393 changed = true;
394 bool ok; 394 bool ok;
395 mPrefs->mPassiveSyncAutoStart = false; 395 mPrefs->mPassiveSyncAutoStart = false;
396 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 396 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
397 if ( ! ok ) { 397 if ( ! ok ) {
398 KMessageBox::information( 0, i18n("No valid port")); 398 KMessageBox::information( 0, i18n("No valid port"));
399 return; 399 return;
400 } 400 }
401 //qDebug("port %d ", port); 401 //qDebug("port %d ", port);
402 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 402 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
403 mServerSocket->setFileName( defaultFileName() ); 403 mServerSocket->setFileName( defaultFileName() );
404 //qDebug("connected "); 404 //qDebug("connected ");
405 if ( !mServerSocket->ok() ) { 405 if ( !mServerSocket->ok() ) {
406 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 406 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
407 delete mServerSocket; 407 delete mServerSocket;
408 mServerSocket = 0; 408 mServerSocket = 0;
409 return; 409 return;
410 } 410 }
411 mPrefs->mPassiveSyncAutoStart = autoStart; 411 mPrefs->mPassiveSyncAutoStart = autoStart;
412 if ( changed ) { 412 if ( changed ) {
413 mPrefs->writeConfig(); 413 mPrefs->writeConfig();
414 } 414 }
415 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 415 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
416 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 416 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
417} 417}
418 418
419void KSyncManager::syncLocalFile() 419void KSyncManager::syncLocalFile()
420{ 420{
421 421
422 QString fn =mPrefs->mLastSyncedLocalFile; 422 QString fn =mPrefs->mLastSyncedLocalFile;
423 QString ext; 423 QString ext;
424 424
425 switch(mTargetApp) 425 switch(mTargetApp)
426 { 426 {
427 case (KAPI): 427 case (KAPI):
428 ext = "(*.vcf)"; 428 ext = "(*.vcf)";
429 break; 429 break;
430 case (KOPI): 430 case (KOPI):
431 ext = "(*.ics/*.vcs)"; 431 ext = "(*.ics/*.vcs)";
432 break; 432 break;
433 case (PWMPI): 433 case (PWMPI):
434 ext = "(*.pwm)"; 434 ext = "(*.pwm)";
435 break; 435 break;
436 default: 436 default:
437 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 437 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
438 break; 438 break;
439 439
440 } 440 }
441 441
442 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 442 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
443 if ( fn == "" ) 443 if ( fn == "" )
444 return; 444 return;
445 if ( syncWithFile( fn, false ) ) { 445 if ( syncWithFile( fn, false ) ) {
446 qDebug("syncLocalFile() successful "); 446 qDebug("syncLocalFile() successful ");
447 } 447 }
448 448
449} 449}
450 450
451bool KSyncManager::syncWithFile( QString fn , bool quick ) 451bool KSyncManager::syncWithFile( QString fn , bool quick )
452{ 452{
453 bool ret = false; 453 bool ret = false;
454 QFileInfo info; 454 QFileInfo info;
455 info.setFile( fn ); 455 info.setFile( fn );
456 QString mess; 456 QString mess;
457 bool loadbup = true; 457 bool loadbup = true;
458 if ( !info. exists() ) { 458 if ( !info. exists() ) {
459 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 459 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
460 int result = QMessageBox::warning( mParent, i18n("Warning!"), 460 int result = QMessageBox::warning( mParent, i18n("Warning!"),
461 mess ); 461 mess );
462 return ret; 462 return ret;
463 } 463 }
464 int result = 0; 464 int result = 0;
465 if ( !quick ) { 465 if ( !quick ) {
466 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 466 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
467 result = QMessageBox::warning( mParent, i18n("Warning!"), 467 result = QMessageBox::warning( mParent, i18n("Warning!"),
468 mess, 468 mess,
469 i18n("Sync"), i18n("Cancel"), 0, 469 i18n("Sync"), i18n("Cancel"), 0,
470 0, 1 ); 470 0, 1 );
471 if ( result ) 471 if ( result )
472 return false; 472 return false;
473 } 473 }
474 if ( mAskForPreferences ) 474 if ( mAskForPreferences )
475 if ( !edit_sync_options()) { 475 if ( !edit_sync_options()) {
476 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 476 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
477 return false; 477 return false;
478 } 478 }
479 if ( result == 0 ) { 479 if ( result == 0 ) {
480 //qDebug("Now sycing ... "); 480 //qDebug("Now sycing ... ");
481 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 481 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
482 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 482 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
483 else 483 else
484 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 484 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
485 if ( ! quick ) 485 if ( ! quick )
486 mPrefs->mLastSyncedLocalFile = fn; 486 mPrefs->mLastSyncedLocalFile = fn;
487 } 487 }
488 return ret; 488 return ret;
489} 489}
490 490
491void KSyncManager::quickSyncLocalFile() 491void KSyncManager::quickSyncLocalFile()
492{ 492{
493 493
494 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 494 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
495 qDebug("quick syncLocalFile() successful "); 495 qDebug("quick syncLocalFile() successful ");
496 496
497 } 497 }
498} 498}
499 499
500void KSyncManager::multiSync( bool askforPrefs ) 500void KSyncManager::multiSync( bool askforPrefs )
501{ 501{
502 if (blockSave()) 502 if (blockSave())
503 return; 503 return;
504 setBlockSave(true); 504 setBlockSave(true);
505 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 505 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
506 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 506 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
507 question, 507 question,
508 i18n("Yes"), i18n("No"), 508 i18n("Yes"), i18n("No"),
509 0, 0 ) != 0 ) { 509 0, 0 ) != 0 ) {
510 setBlockSave(false); 510 setBlockSave(false);
511 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 511 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
512 return; 512 return;
513 } 513 }
514 mCurrentSyncDevice = i18n("Multiple profiles") ; 514 mCurrentSyncDevice = i18n("Multiple profiles") ;
515 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 515 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
516 if ( askforPrefs ) { 516 if ( askforPrefs ) {
517 if ( !edit_sync_options()) { 517 if ( !edit_sync_options()) {
518 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 518 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
519 return; 519 return;
520 } 520 }
521 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 521 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
522 } 522 }
523 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 523 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
524 qApp->processEvents(); 524 qApp->processEvents();
525 int num = ringSync() ; 525 int num = ringSync() ;
526 if ( num > 1 ) 526 if ( num > 1 )
527 ringSync(); 527 ringSync();
528 setBlockSave(false); 528 setBlockSave(false);
529 if ( num ) 529 if ( num )
530 emit save(); 530 emit save();
531 if ( num ) 531 if ( num )
532 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 532 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
533 else 533 else
534 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 534 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
535 return; 535 return;
536} 536}
537 537
538int KSyncManager::ringSync() 538int KSyncManager::ringSync()
539{ 539{
540
540 int syncedProfiles = 0; 541 int syncedProfiles = 0;
541 unsigned int i; 542 unsigned int i;
542 QTime timer; 543 QTime timer;
543 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 544 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
544 QStringList syncProfileNames = mSyncProfileNames; 545 QStringList syncProfileNames = mSyncProfileNames;
545 KSyncProfile* temp = new KSyncProfile (); 546 KSyncProfile* temp = new KSyncProfile ();
546 mAskForPreferences = false; 547 mAskForPreferences = false;
547 for ( i = 0; i < syncProfileNames.count(); ++i ) { 548 for ( i = 0; i < syncProfileNames.count(); ++i ) {
548 mCurrentSyncProfile = i; 549 mCurrentSyncProfile = i;
549 temp->setName(syncProfileNames[mCurrentSyncProfile]); 550 temp->setName(syncProfileNames[mCurrentSyncProfile]);
550 temp->readConfig(&config); 551 temp->readConfig(&config);
551 552
552 bool includeInRingSync; 553 bool includeInRingSync;
553 switch(mTargetApp) 554 switch(mTargetApp)
554 { 555 {
555 case (KAPI): 556 case (KAPI):
556 includeInRingSync = temp->getIncludeInRingSyncAB(); 557 includeInRingSync = temp->getIncludeInRingSyncAB();
557 break; 558 break;
558 case (KOPI): 559 case (KOPI):
559 includeInRingSync = temp->getIncludeInRingSync(); 560 includeInRingSync = temp->getIncludeInRingSync();
560 break; 561 break;
561 case (PWMPI): 562 case (PWMPI):
562 includeInRingSync = temp->getIncludeInRingSyncPWM(); 563 includeInRingSync = temp->getIncludeInRingSyncPWM();
563 break; 564 break;
564 default: 565 default:
565 qDebug("KSyncManager::ringSync: invalid apptype selected"); 566 qDebug("KSyncManager::ringSync: invalid apptype selected");
566 break; 567 break;
567 568
568 } 569 }
569 570
570 571
571 if ( includeInRingSync && ( i < 1 || i > 2 )) { 572 if ( includeInRingSync && ( i < 1 || i > 2 )) {
572 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 573 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
573 ++syncedProfiles; 574 ++syncedProfiles;
575 mSyncWithDesktop = false;
574 // mAskForPreferences = temp->getAskForPreferences(); 576 // mAskForPreferences = temp->getAskForPreferences();
575 mWriteBackFile = temp->getWriteBackFile(); 577 mWriteBackFile = temp->getWriteBackFile();
576 mWriteBackExistingOnly = temp->getWriteBackExisting(); 578 mWriteBackExistingOnly = temp->getWriteBackExisting();
577 mIsKapiFile = temp->getIsKapiFile(); 579 mIsKapiFile = temp->getIsKapiFile();
578 mWriteBackInFuture = 0; 580 mWriteBackInFuture = 0;
579 if ( temp->getWriteBackFuture() ) 581 if ( temp->getWriteBackFuture() )
580 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 582 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
581 mShowSyncSummary = false; 583 mShowSyncSummary = false;
582 mCurrentSyncDevice = syncProfileNames[i] ; 584 mCurrentSyncDevice = syncProfileNames[i] ;
583 mCurrentSyncName = mLocalMachineName; 585 mCurrentSyncName = mLocalMachineName;
584 if ( i == 0 ) { 586 if ( i == 0 ) {
585 mIsKapiFile = false; 587 mIsKapiFile = false;
586#ifdef DESKTOP_VERSION 588#ifdef DESKTOP_VERSION
587 syncKDE(); 589 syncKDE();
588#else 590#else
589 syncSharp(); 591 syncSharp();
590#endif 592#endif
591 } else { 593 } else {
592 if ( temp->getIsLocalFileSync() ) { 594 if ( temp->getIsLocalFileSync() ) {
593 switch(mTargetApp) 595 switch(mTargetApp)
594 { 596 {
595 case (KAPI): 597 case (KAPI):
596 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 598 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
597 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 599 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
598 break; 600 break;
599 case (KOPI): 601 case (KOPI):
600 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 602 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
601 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 603 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
602 break; 604 break;
603 case (PWMPI): 605 case (PWMPI):
604 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 606 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
605 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 607 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
606 break; 608 break;
607 default: 609 default:
608 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 610 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
609 break; 611 break;
610 } 612 }
611 } else { 613 } else {
612 if ( temp->getIsPhoneSync() ) { 614 if ( temp->getIsPhoneSync() ) {
613 mPhoneDevice = temp->getPhoneDevice( ) ; 615 mPhoneDevice = temp->getPhoneDevice( ) ;
614 mPhoneConnection = temp->getPhoneConnection( ); 616 mPhoneConnection = temp->getPhoneConnection( );
615 mPhoneModel = temp->getPhoneModel( ); 617 mPhoneModel = temp->getPhoneModel( );
616 syncPhone(); 618 syncPhone();
617 } else if ( temp->getIsPiSync() ) { 619 } else if ( temp->getIsPiSync() ) {
618 if ( mTargetApp == KAPI ) { 620 if ( mTargetApp == KAPI ) {
619 mPassWordPiSync = temp->getRemotePwAB(); 621 mPassWordPiSync = temp->getRemotePwAB();
620 mActiveSyncPort = temp->getRemotePortAB(); 622 mActiveSyncPort = temp->getRemotePortAB();
621 mActiveSyncIP = temp->getRemoteIPAB(); 623 mActiveSyncIP = temp->getRemoteIPAB();
622 } else if ( mTargetApp == KOPI ) { 624 } else if ( mTargetApp == KOPI ) {
623 mPassWordPiSync = temp->getRemotePw(); 625 mPassWordPiSync = temp->getRemotePw();
624 mActiveSyncPort = temp->getRemotePort(); 626 mActiveSyncPort = temp->getRemotePort();
625 mActiveSyncIP = temp->getRemoteIP(); 627 mActiveSyncIP = temp->getRemoteIP();
626 } else { 628 } else {
627 mPassWordPiSync = temp->getRemotePwPWM(); 629 mPassWordPiSync = temp->getRemotePwPWM();
628 mActiveSyncPort = temp->getRemotePortPWM(); 630 mActiveSyncPort = temp->getRemotePortPWM();
629 mActiveSyncIP = temp->getRemoteIPPWM(); 631 mActiveSyncIP = temp->getRemoteIPPWM();
630 } 632 }
631 syncPi(); 633 syncPi();
632 while ( !mPisyncFinished ) { 634 while ( !mPisyncFinished ) {
633 //qDebug("waiting "); 635 //qDebug("waiting ");
634 qApp->processEvents(); 636 qApp->processEvents();
635 } 637 }
636 timer.start(); 638 timer.start();
637 while ( timer.elapsed () < 2000 ) { 639 while ( timer.elapsed () < 2000 ) {
638 qApp->processEvents(); 640 qApp->processEvents();
639 } 641 }
640 } else 642 } else
641 syncRemote( temp, false ); 643 syncRemote( temp, false );
642 644
643 } 645 }
644 } 646 }
645 timer.start(); 647 timer.start();
646 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 648 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
647 while ( timer.elapsed () < 2000 ) { 649 while ( timer.elapsed () < 2000 ) {
648 qApp->processEvents(); 650 qApp->processEvents();
649#ifndef _WIN32_ 651#ifndef _WIN32_
650 sleep (1); 652 sleep (1);
651#endif 653#endif
652 } 654 }
653 655
654 } 656 }
655 657
656 } 658 }
657 delete temp; 659 delete temp;
658 return syncedProfiles; 660 return syncedProfiles;
659} 661}
660 662
661void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 663void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
662{ 664{
663 QString question; 665 QString question;
664 if ( ask ) { 666 if ( ask ) {
665 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 667 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
666 if ( QMessageBox::information( mParent, i18n("Sync"), 668 if ( QMessageBox::information( mParent, i18n("Sync"),
667 question, 669 question,
668 i18n("Yes"), i18n("No"), 670 i18n("Yes"), i18n("No"),
669 0, 0 ) != 0 ) 671 0, 0 ) != 0 )
670 return; 672 return;
671 } 673 }
672 674
673 QString preCommand; 675 QString preCommand;
674 QString localTempFile; 676 QString localTempFile;
675 QString postCommand; 677 QString postCommand;
676 678
677 switch(mTargetApp) 679 switch(mTargetApp)
678 { 680 {
679 case (KAPI): 681 case (KAPI):
680 preCommand = prof->getPreSyncCommandAB(); 682 preCommand = prof->getPreSyncCommandAB();
681 postCommand = prof->getPostSyncCommandAB(); 683 postCommand = prof->getPostSyncCommandAB();
682 localTempFile = prof->getLocalTempFileAB(); 684 localTempFile = prof->getLocalTempFileAB();
683 break; 685 break;
684 case (KOPI): 686 case (KOPI):
685 preCommand = prof->getPreSyncCommand(); 687 preCommand = prof->getPreSyncCommand();
686 postCommand = prof->getPostSyncCommand(); 688 postCommand = prof->getPostSyncCommand();
687 localTempFile = prof->getLocalTempFile(); 689 localTempFile = prof->getLocalTempFile();
688 break; 690 break;
689 case (PWMPI): 691 case (PWMPI):
690 preCommand = prof->getPreSyncCommandPWM(); 692 preCommand = prof->getPreSyncCommandPWM();
691 postCommand = prof->getPostSyncCommandPWM(); 693 postCommand = prof->getPostSyncCommandPWM();
692 localTempFile = prof->getLocalTempFilePWM(); 694 localTempFile = prof->getLocalTempFilePWM();
693 break; 695 break;
694 default: 696 default:
695 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 697 qDebug("KSyncManager::syncRemote: invalid apptype selected");
696 break; 698 break;
697 } 699 }
698 700
699 701
700 int fi; 702 int fi;
701 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 703 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
702 QString pwd = getPassword(); 704 QString pwd = getPassword();
703 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 705 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
704 706
705 } 707 }
706 int maxlen = 30; 708 int maxlen = 30;
707 if ( QApplication::desktop()->width() > 320 ) 709 if ( QApplication::desktop()->width() > 320 )
708 maxlen += 25; 710 maxlen += 25;
709 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 711 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
710 int fileSize = 0; 712 int fileSize = 0;
711 int result = system ( preCommand ); 713 int result = system ( preCommand );
712 // 0 : okay 714 // 0 : okay
713 // 256: no such file or dir 715 // 256: no such file or dir
714 // 716 //
715 qDebug("Sync: Remote copy result(0 = okay): %d ",result ); 717 qDebug("Sync: Remote copy result(0 = okay): %d ",result );
716 if ( result != 0 ) { 718 if ( result != 0 ) {
717 unsigned int len = maxlen; 719 unsigned int len = maxlen;
718 while ( len < preCommand.length() ) { 720 while ( len < preCommand.length() ) {
719 preCommand.insert( len , "\n" ); 721 preCommand.insert( len , "\n" );
720 len += maxlen +2; 722 len += maxlen +2;
721 } 723 }
722 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) ; 724 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) ;
723 QMessageBox::information( mParent, i18n("Sync - ERROR"), 725 QMessageBox::information( mParent, i18n("Sync - ERROR"),
724 question, 726 question,
725 i18n("Okay!")) ; 727 i18n("Okay!")) ;
726 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 728 mParent->topLevelWidget()->setCaption ("KDE-Pim");
727 return; 729 return;
728 } 730 }
729 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 731 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
730 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 732 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
731 733
732 if ( syncWithFile( localTempFile, true ) ) { 734 if ( syncWithFile( localTempFile, true ) ) {
733 735
734 if ( mWriteBackFile ) { 736 if ( mWriteBackFile ) {
735 int fi; 737 int fi;
736 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 738 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
737 QString pwd = getPassword(); 739 QString pwd = getPassword();
738 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 740 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
739 741
740 } 742 }
741 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 743 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
742 result = system ( postCommand ); 744 result = system ( postCommand );
743 qDebug("Sync:Writing back file result: %d ", result); 745 qDebug("Sync:Writing back file result: %d ", result);
744 if ( result != 0 ) { 746 if ( result != 0 ) {
745 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 747 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
746 return; 748 return;
747 } else { 749 } else {
748 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 750 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
749 } 751 }
750 } 752 }
751 } 753 }
752 return; 754 return;
753} 755}
754bool KSyncManager::edit_pisync_options() 756bool KSyncManager::edit_pisync_options()
755{ 757{
756 QDialog dia( mParent, "dia", true ); 758 QDialog dia( mParent, "dia", true );
757 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 759 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
758 QVBoxLayout lay ( &dia ); 760 QVBoxLayout lay ( &dia );
759 lay.setSpacing( 5 ); 761 lay.setSpacing( 5 );
760 lay.setMargin( 3 ); 762 lay.setMargin( 3 );
761 QLabel lab1 ( i18n("Password for remote access:"), &dia); 763 QLabel lab1 ( i18n("Password for remote access:"), &dia);
762 lay.addWidget( &lab1 ); 764 lay.addWidget( &lab1 );
763 QLineEdit le1 (&dia ); 765 QLineEdit le1 (&dia );
764 lay.addWidget( &le1 ); 766 lay.addWidget( &le1 );
765 QLabel lab2 ( i18n("Remote IP address:"), &dia); 767 QLabel lab2 ( i18n("Remote IP address:"), &dia);
766 lay.addWidget( &lab2 ); 768 lay.addWidget( &lab2 );
767 QLineEdit le2 (&dia ); 769 QLineEdit le2 (&dia );
768 lay.addWidget( &le2 ); 770 lay.addWidget( &le2 );
769 QLabel lab3 ( i18n("Remote port number:"), &dia); 771 QLabel lab3 ( i18n("Remote port number:"), &dia);
770 lay.addWidget( &lab3 ); 772 lay.addWidget( &lab3 );
771 QLineEdit le3 (&dia ); 773 QLineEdit le3 (&dia );
772 lay.addWidget( &le3 ); 774 lay.addWidget( &le3 );
773 QPushButton pb ( "OK", &dia); 775 QPushButton pb ( "OK", &dia);
774 lay.addWidget( &pb ); 776 lay.addWidget( &pb );
775 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 777 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
776 le1.setText( mPassWordPiSync ); 778 le1.setText( mPassWordPiSync );
777 le2.setText( mActiveSyncIP ); 779 le2.setText( mActiveSyncIP );
778 le3.setText( mActiveSyncPort ); 780 le3.setText( mActiveSyncPort );
779 if ( dia.exec() ) { 781 if ( dia.exec() ) {
780 mPassWordPiSync = le1.text(); 782 mPassWordPiSync = le1.text();
781 mActiveSyncPort = le3.text(); 783 mActiveSyncPort = le3.text();
782 mActiveSyncIP = le2.text(); 784 mActiveSyncIP = le2.text();
783 return true; 785 return true;
784 } 786 }
785 return false; 787 return false;
786} 788}
787bool KSyncManager::edit_sync_options() 789bool KSyncManager::edit_sync_options()
788{ 790{
789 791
790 QDialog dia( mParent, "dia", true ); 792 QDialog dia( mParent, "dia", true );
791 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 793 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
792 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 794 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
793 QVBoxLayout lay ( &dia ); 795 QVBoxLayout lay ( &dia );
794 lay.setSpacing( 2 ); 796 lay.setSpacing( 2 );
795 lay.setMargin( 3 ); 797 lay.setMargin( 3 );
796 lay.addWidget(&gr); 798 lay.addWidget(&gr);
797 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 799 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
798 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 800 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
799 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 801 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
800 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 802 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
801 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 803 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
802 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 804 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
803 //QRadioButton both( i18n("Take both on conflict"), &gr ); 805 //QRadioButton both( i18n("Take both on conflict"), &gr );
804 QPushButton pb ( "OK", &dia); 806 QPushButton pb ( "OK", &dia);
805 lay.addWidget( &pb ); 807 lay.addWidget( &pb );
806 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 808 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
807 switch ( mSyncAlgoPrefs ) { 809 switch ( mSyncAlgoPrefs ) {
808 case 0: 810 case 0:
809 loc.setChecked( true); 811 loc.setChecked( true);
810 break; 812 break;
811 case 1: 813 case 1:
812 rem.setChecked( true ); 814 rem.setChecked( true );
813 break; 815 break;
814 case 2: 816 case 2:
815 newest.setChecked( true); 817 newest.setChecked( true);
816 break; 818 break;
817 case 3: 819 case 3:
818 ask.setChecked( true); 820 ask.setChecked( true);
819 break; 821 break;
820 case 4: 822 case 4:
821 f_loc.setChecked( true); 823 f_loc.setChecked( true);
822 break; 824 break;
823 case 5: 825 case 5:
824 f_rem.setChecked( true); 826 f_rem.setChecked( true);
825 break; 827 break;
826 case 6: 828 case 6:
827 // both.setChecked( true); 829 // both.setChecked( true);
828 break; 830 break;
829 default: 831 default: