author | zautrix <zautrix> | 2004-09-21 10:08:57 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-21 10:08:57 (UTC) |
commit | 19f445f0b6e7d4591db46b89e877ed9f4332ecd4 (patch) (unidiff) | |
tree | fd21a5dc32332060197d792552ef1eb469e92175 | |
parent | 1cf4cc6e7bf25ee309852c7c97155de86917289f (diff) | |
download | kdepimpi-19f445f0b6e7d4591db46b89e877ed9f4332ecd4.zip kdepimpi-19f445f0b6e7d4591db46b89e877ed9f4332ecd4.tar.gz kdepimpi-19f445f0b6e7d4591db46b89e877ed9f4332ecd4.tar.bz2 |
more sync fixes
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 3 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 48 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.cpp | 17 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 5 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 4 |
5 files changed, 70 insertions, 7 deletions
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index b8c32d5..6cd63fd 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp | |||
@@ -150,64 +150,65 @@ Ticket *ResourceFile::requestSaveTicket() | |||
150 | 150 | ||
151 | if ( !addressBook() ) return 0; | 151 | if ( !addressBook() ) return 0; |
152 | 152 | ||
153 | #ifdef ALLOW_LOCKING | 153 | #ifdef ALLOW_LOCKING |
154 | if ( !lock( mFileName ) ) { | 154 | if ( !lock( mFileName ) ) { |
155 | qDebug("unablt to lock file "); | 155 | qDebug("unablt to lock file "); |
156 | return 0; | 156 | return 0; |
157 | } | 157 | } |
158 | #endif | 158 | #endif |
159 | return createTicket( this ); | 159 | return createTicket( this ); |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | bool ResourceFile::doOpen() | 163 | bool ResourceFile::doOpen() |
164 | { | 164 | { |
165 | QFile file( mFileName ); | 165 | QFile file( mFileName ); |
166 | qDebug("ResourceFile::openfile %s ", mFileName.latin1()); | ||
166 | 167 | ||
167 | if ( !file.exists() ) { | 168 | if ( !file.exists() ) { |
168 | // try to create the file | 169 | // try to create the file |
169 | bool ok = file.open( IO_WriteOnly ); | 170 | bool ok = file.open( IO_WriteOnly ); |
170 | if ( ok ) | 171 | if ( ok ) |
171 | file.close(); | 172 | file.close(); |
172 | 173 | ||
173 | return ok; | 174 | return ok; |
174 | } else { | 175 | } else { |
175 | if ( !file.open( IO_ReadWrite ) ) | 176 | if ( !file.open( IO_ReadWrite ) ) |
176 | return false; | 177 | return false; |
177 | 178 | ||
178 | if ( file.size() == 0 ) { | 179 | if ( file.size() == 0 ) { |
179 | file.close(); | 180 | file.close(); |
180 | return true; | 181 | return true; |
181 | } | 182 | } |
182 | 183 | ||
183 | bool ok = mFormat->checkFormat( &file ); | 184 | bool ok = mFormat->checkFormat( &file ); |
184 | file.close(); | 185 | file.close(); |
185 | 186 | ||
186 | return ok; | 187 | return ok; |
187 | } | 188 | } |
188 | } | 189 | } |
189 | 190 | ||
190 | void ResourceFile::doClose() | 191 | void ResourceFile::doClose() |
191 | { | 192 | { |
192 | } | 193 | } |
193 | 194 | ||
194 | bool ResourceFile::load() | 195 | bool ResourceFile::load() |
195 | { | 196 | { |
196 | 197 | ||
197 | 198 | qDebug("ResourceFile::loadfile %s ", mFileName.latin1()); | |
198 | QFile file( mFileName ); | 199 | QFile file( mFileName ); |
199 | if ( !file.open( IO_ReadOnly ) ) { | 200 | if ( !file.open( IO_ReadOnly ) ) { |
200 | addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); | 201 | addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); |
201 | return false; | 202 | return false; |
202 | } | 203 | } |
203 | 204 | ||
204 | // qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 205 | // qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
205 | 206 | ||
206 | return mFormat->loadAll( addressBook(), this, &file ); | 207 | return mFormat->loadAll( addressBook(), this, &file ); |
207 | } | 208 | } |
208 | 209 | ||
209 | bool ResourceFile::save( Ticket *ticket ) | 210 | bool ResourceFile::save( Ticket *ticket ) |
210 | { | 211 | { |
211 | // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 212 | // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
212 | 213 | ||
213 | 214 | ||
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index 48d3985..437bda8 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -191,112 +191,154 @@ bool ResourceSharpDTM::load() | |||
191 | addressBook()->insertAddressee( addressee ); | 191 | addressBook()->insertAddressee( addressee ); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | return true; | 195 | return true; |
196 | } | 196 | } |
197 | 197 | ||
198 | bool ResourceSharpDTM::save( Ticket *ticket ) | 198 | bool ResourceSharpDTM::save( Ticket *ticket ) |
199 | { | 199 | { |
200 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); | 200 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); |
201 | 201 | ||
202 | mDirWatch.stopScan(); | 202 | mDirWatch.stopScan(); |
203 | 203 | ||
204 | KABC::AddressBook::Iterator it; | 204 | KABC::AddressBook::Iterator it; |
205 | bool res; | 205 | bool res; |
206 | KABC::Addressee::List changedAddressees; | 206 | KABC::Addressee::List changedAddressees; |
207 | typedef QMap<int,QString> AddresseeMap; | ||
208 | AddresseeMap map; | ||
209 | CardId id ; | ||
207 | 210 | ||
208 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 211 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
209 | 212 | ||
210 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 213 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
211 | QString uid = (*it).originalExternalUID(); | 214 | QString uid = (*it).originalExternalUID(); |
212 | CardId id ; | ||
213 | bool res; | 215 | bool res; |
214 | if ( uid.isEmpty() ) | 216 | if ( uid.isEmpty() ) |
215 | id = 0; | 217 | id = 0; |
216 | else | 218 | else |
217 | id = uid.toUInt(); | 219 | id = uid.toUInt(); |
218 | KABC::Addressee addressee = (*it); | 220 | KABC::Addressee addressee = (*it); |
219 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { | 221 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { |
220 | res = mAccess->startEditCard(id); | 222 | res = mAccess->startEditCard(id); |
221 | if (res == true) | 223 | if (res == true) |
222 | { | 224 | { |
223 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); | 225 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); |
224 | if (res == true) | 226 | if (res == true) |
225 | { | 227 | { |
228 | res = mAccess->finishEditCard(&id); | ||
229 | //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
230 | //(*it).setExternalUID( QString::number( id ) ); | ||
231 | //(*it).setOriginalExternalUID( QString::number( id ) ); | ||
232 | map.insert(id,(*it).uid()); | ||
233 | |||
234 | #if 0 | ||
226 | KABC::Addressee addressee; | 235 | KABC::Addressee addressee; |
227 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 236 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
228 | addressee.setUid((*it).uid() ); | 237 | addressee.setUid((*it).uid() ); |
229 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 238 | (it*).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
230 | res = mAccess->finishEditCard(&id); | 239 | res = mAccess->finishEditCard(&id); |
231 | //qDebug("2NEW id is %d", id); | 240 | //qDebug("2NEW id is %d", id); |
232 | addressee.setExternalUID( QString::number( id ) ); | 241 | addressee.setExternalUID( QString::number( id ) ); |
233 | addressee.setOriginalExternalUID( QString::number( id ) ); | 242 | addressee.setOriginalExternalUID( QString::number( id ) ); |
234 | changedAddressees.append( addressee ); | 243 | changedAddressees.append( addressee ); |
244 | #endif | ||
235 | 245 | ||
236 | if (res == false) | 246 | if (res == false) |
237 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | 247 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); |
238 | 248 | ||
239 | } | 249 | } |
240 | else | 250 | else |
241 | { | 251 | { |
242 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | 252 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); |
243 | mAccess->cancelEditCard(); | 253 | mAccess->cancelEditCard(); |
244 | } | 254 | } |
245 | } | 255 | } |
246 | 256 | ||
247 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 257 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
248 | res = mAccess->deleteCard(&id); | 258 | res = mAccess->deleteCard(&id); |
249 | if ( res ) | 259 | if ( res ) |
250 | qDebug("delete success "); | 260 | qDebug("delete success "); |
251 | else | 261 | else |
252 | qDebug("delete error "); | 262 | qDebug("delete error "); |
253 | 263 | ||
254 | 264 | ||
255 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 265 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
256 | //changed | 266 | //changed |
257 | qDebug("changed ****"); | 267 | qDebug("changed ****"); |
258 | res = mAccess->startEditCard(id); | 268 | res = mAccess->startEditCard(id); |
259 | if (res == true) | 269 | if (res == true) |
260 | { | 270 | { |
261 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); | 271 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); |
262 | if (res == true) | 272 | if (res == true) |
263 | { | 273 | { |
274 | res = mAccess->finishEditCard(&id); | ||
275 | //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | ||
276 | map.insert(id,(*it).uid()); | ||
277 | |||
278 | #if 0 | ||
264 | KABC::Addressee addressee; | 279 | KABC::Addressee addressee; |
265 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 280 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
266 | addressee.setUid((*it).uid() ); | 281 | addressee.setUid((*it).uid() ); |
267 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | 282 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); |
268 | changedAddressees.append( addressee ); | 283 | changedAddressees.append( addressee ); |
269 | res = mAccess->finishEditCard(&id); | 284 | res = mAccess->finishEditCard(&id); |
285 | #endif | ||
270 | if (res == false) | 286 | if (res == false) |
271 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | 287 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); |
272 | 288 | ||
273 | } | 289 | } |
274 | else | 290 | else |
275 | { | 291 | { |
276 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | 292 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); |
277 | mAccess->cancelEditCard(); | 293 | mAccess->cancelEditCard(); |
278 | } | 294 | } |
279 | } | 295 | } |
280 | } | 296 | } |
281 | } | 297 | } |
282 | 298 | ||
283 | } | 299 | } |
300 | AddresseeMap::Iterator itam; | ||
301 | res; | ||
302 | for ( res=mAccess->first(); res == true; res=mAccess->next()) | ||
303 | { | ||
304 | id = mAccess->cardId(); | ||
305 | int idint = id; | ||
306 | itam = map.find( idint ); | ||
307 | if ( itam != map.end() ) { | ||
308 | KABC::Addressee addressee; | ||
309 | qDebug("found change %d %s ", idint, itam.data().latin1()); | ||
310 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | ||
311 | |||
312 | if ( !addressee.isEmpty() && res ) | ||
313 | { | ||
314 | addressee.setResource( this ); | ||
315 | addressee.setUid( itam.data() ); | ||
316 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
317 | addressBook()->insertAddressee( addressee , false ); | ||
318 | } | ||
319 | } | ||
320 | } | ||
321 | #if 0 | ||
284 | KABC::Addressee::List::Iterator it2; | 322 | KABC::Addressee::List::Iterator it2; |
285 | for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) | 323 | for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) { |
324 | (*it2).computeCsum( "Sharp_DTM" ); | ||
325 | qDebug("CSUM: %s ",(*it2).getCsum( "Sharp_DTM" ).latin1() ); | ||
286 | addressBook()->insertAddressee((*it2)); | 326 | addressBook()->insertAddressee((*it2)); |
327 | } | ||
328 | #endif | ||
287 | //US mAccess->save(); | 329 | //US mAccess->save(); |
288 | 330 | ||
289 | mDirWatch.startScan(); | 331 | mDirWatch.startScan(); |
290 | delete ticket; | 332 | delete ticket; |
291 | unlock( fileName() ); | 333 | unlock( fileName() ); |
292 | 334 | ||
293 | return true; | 335 | return true; |
294 | } | 336 | } |
295 | 337 | ||
296 | bool ResourceSharpDTM::lock( const QString &lockfileName ) | 338 | bool ResourceSharpDTM::lock( const QString &lockfileName ) |
297 | { | 339 | { |
298 | #ifdef ALLOW_LOCKING | 340 | #ifdef ALLOW_LOCKING |
299 | qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); | 341 | qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); |
300 | 342 | ||
301 | kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; | 343 | kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; |
302 | 344 | ||
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp index f3bf2c5..fccf625 100644 --- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp | |||
@@ -273,34 +273,45 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
273 | } | 273 | } |
274 | 274 | ||
275 | return true; | 275 | return true; |
276 | } | 276 | } |
277 | 277 | ||
278 | bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) | 278 | bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) |
279 | { | 279 | { |
280 | bool cellHome = false, cellWork = false; | 280 | bool cellHome = false, cellWork = false; |
281 | // name | 281 | // name |
282 | database->writeField(ZdbAdrs::LastName, addr.familyName()); | 282 | database->writeField(ZdbAdrs::LastName, addr.familyName()); |
283 | database->writeField(ZdbAdrs::FirstName, addr.givenName()); | 283 | database->writeField(ZdbAdrs::FirstName, addr.givenName()); |
284 | database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); | 284 | database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); |
285 | database->writeField(ZdbAdrs::Title, addr.prefix()); | 285 | database->writeField(ZdbAdrs::Title, addr.prefix()); |
286 | database->writeField(ZdbAdrs::Suffix, addr.suffix()); | 286 | database->writeField(ZdbAdrs::Suffix, addr.suffix()); |
287 | 287 | ||
288 | //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); | 288 | //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); |
289 | database->writeField(ZdbAdrs::FileAs, addr.formattedName()); | 289 | QString formattedName = addr.formattedName(); |
290 | database->writeField(ZdbAdrs::FullName, addr.formattedName()); | 290 | if ( formattedName.isEmpty() ) { |
291 | if ( !addr.familyName().isEmpty() ) { | ||
292 | formattedName = addr.familyName(); | ||
293 | if ( !addr.givenName().isEmpty() ) { | ||
294 | formattedName += ", "; | ||
295 | formattedName += addr.givenName(); | ||
296 | } | ||
297 | } else | ||
298 | formattedName = addr.givenName(); | ||
299 | } | ||
300 | database->writeField(ZdbAdrs::FileAs, formattedName); | ||
301 | database->writeField(ZdbAdrs::FullName, formattedName); | ||
291 | 302 | ||
292 | 303 | ||
293 | //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); | 304 | //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); |
294 | //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); | 305 | //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); |
295 | QString emails = addr.emails().join(" "); | 306 | QString emails = addr.emails().join(" "); |
296 | database->writeField(ZdbAdrs::Emails, emails ); | 307 | database->writeField(ZdbAdrs::Emails, emails ); |
297 | 308 | ||
298 | database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); | 309 | database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); |
299 | 310 | ||
300 | 311 | ||
301 | // home | 312 | // home |
302 | const Address homeaddress = addr.address(Address::Home); | 313 | const Address homeaddress = addr.address(Address::Home); |
303 | if (!homeaddress.isEmpty()) { | 314 | if (!homeaddress.isEmpty()) { |
304 | database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); | 315 | database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); |
305 | database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); | 316 | database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); |
306 | database->writeField(ZdbAdrs::HomeState, homeaddress.region()); | 317 | database->writeField(ZdbAdrs::HomeState, homeaddress.region()); |
@@ -336,33 +347,33 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
336 | } | 347 | } |
337 | 348 | ||
338 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); | 349 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); |
339 | if (!businessphone.number().isEmpty()) | 350 | if (!businessphone.number().isEmpty()) |
340 | database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); | 351 | database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); |
341 | 352 | ||
342 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); | 353 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); |
343 | if (!businessfax.number().isEmpty()) | 354 | if (!businessfax.number().isEmpty()) |
344 | database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); | 355 | database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); |
345 | 356 | ||
346 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); | 357 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); |
347 | if (!businessmobile.number().isEmpty()) { | 358 | if (!businessmobile.number().isEmpty()) { |
348 | cellWork = true; | 359 | cellWork = true; |
349 | database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); | 360 | database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); |
350 | } | 361 | } |
351 | PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); | 362 | PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); |
352 | if (!businessmobile.number().isEmpty()) { | 363 | if (! mobile.number().isEmpty()) { |
353 | if ( ! cellHome ) | 364 | if ( ! cellHome ) |
354 | database->writeField(ZdbAdrs::HomeMobile, mobile.number()); | 365 | database->writeField(ZdbAdrs::HomeMobile, mobile.number()); |
355 | else if (! cellWork ) | 366 | else if (! cellWork ) |
356 | database->writeField(ZdbAdrs::BusinessMobile, mobile.number()); | 367 | database->writeField(ZdbAdrs::BusinessMobile, mobile.number()); |
357 | } | 368 | } |
358 | 369 | ||
359 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); | 370 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); |
360 | if (!businesspager.number().isEmpty()) | 371 | if (!businesspager.number().isEmpty()) |
361 | database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); | 372 | database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); |
362 | 373 | ||
363 | database->writeField(ZdbAdrs::JobTitle, addr.role()); | 374 | database->writeField(ZdbAdrs::JobTitle, addr.role()); |
364 | database->writeField(ZdbAdrs::Company, addr.organization()); | 375 | database->writeField(ZdbAdrs::Company, addr.organization()); |
365 | 376 | ||
366 | database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); | 377 | database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); |
367 | database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); | 378 | database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); |
368 | database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); | 379 | database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index c1ead9d..c2f031a 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2756,59 +2756,64 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2756 | skipIncidence = true; | 2756 | skipIncidence = true; |
2757 | QString idS,OidS; | 2757 | QString idS,OidS; |
2758 | qApp->processEvents(); | 2758 | qApp->processEvents(); |
2759 | if ( !skipIncidence ) { | 2759 | if ( !skipIncidence ) { |
2760 | inL = local->findByUid( uid ); | 2760 | inL = local->findByUid( uid ); |
2761 | inR = remote->findByUid( uid ); | 2761 | inR = remote->findByUid( uid ); |
2762 | //inL.setResource( 0 ); | 2762 | //inL.setResource( 0 ); |
2763 | //inR.setResource( 0 ); | 2763 | //inR.setResource( 0 ); |
2764 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2764 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2765 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2765 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2766 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2766 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2767 | if ( take == 3 ) | 2767 | if ( take == 3 ) |
2768 | return false; | 2768 | return false; |
2769 | if ( take == 1 ) {// take local | 2769 | if ( take == 1 ) {// take local |
2770 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2770 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2771 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2771 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2772 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | ||
2772 | local->insertAddressee( inL, false ); | 2773 | local->insertAddressee( inL, false ); |
2773 | idS = inR.externalUID(); | 2774 | idS = inR.externalUID(); |
2774 | OidS = inR.originalExternalUID(); | 2775 | OidS = inR.originalExternalUID(); |
2775 | } | 2776 | } |
2776 | else | 2777 | else |
2777 | idS = inR.IDStr(); | 2778 | idS = inR.IDStr(); |
2778 | remote->removeAddressee( inR ); | 2779 | remote->removeAddressee( inR ); |
2779 | inR = inL; | 2780 | inR = inL; |
2780 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2781 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2781 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2782 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2782 | inR.setOriginalExternalUID( OidS ); | 2783 | inR.setOriginalExternalUID( OidS ); |
2783 | inR.setExternalUID( idS ); | 2784 | inR.setExternalUID( idS ); |
2784 | } else { | 2785 | } else { |
2785 | inR.setIDStr( idS ); | 2786 | inR.setIDStr( idS ); |
2786 | } | 2787 | } |
2787 | inR.setResource( 0 ); | 2788 | inR.setResource( 0 ); |
2788 | remote->insertAddressee( inR , false); | 2789 | remote->insertAddressee( inR , false); |
2789 | ++changedRemote; | 2790 | ++changedRemote; |
2790 | } else { // take == 2 take remote | 2791 | } else { // take == 2 take remote |
2791 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2792 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2792 | if ( inR.revision().date().year() < 2004 ) | 2793 | if ( inR.revision().date().year() < 2004 ) |
2793 | inR.setRevision( modifiedCalendar ); | 2794 | inR.setRevision( modifiedCalendar ); |
2794 | } | 2795 | } |
2795 | idS = inL.IDStr(); | 2796 | idS = inL.IDStr(); |
2796 | local->removeAddressee( inL ); | 2797 | local->removeAddressee( inL ); |
2797 | inL = inR; | 2798 | inL = inR; |
2798 | inL.setIDStr( idS ); | 2799 | inL.setIDStr( idS ); |
2800 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | ||
2801 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | ||
2802 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | ||
2803 | } | ||
2799 | inL.setResource( 0 ); | 2804 | inL.setResource( 0 ); |
2800 | local->insertAddressee( inL , false ); | 2805 | local->insertAddressee( inL , false ); |
2801 | ++changedLocal; | 2806 | ++changedLocal; |
2802 | } | 2807 | } |
2803 | } | 2808 | } |
2804 | } else { // no conflict | 2809 | } else { // no conflict |
2805 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2810 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2806 | QString des = addresseeLSync.note(); | 2811 | QString des = addresseeLSync.note(); |
2807 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2812 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2808 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2813 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2809 | remote->insertAddressee( inR, false ); | 2814 | remote->insertAddressee( inR, false ); |
2810 | ++deletedAddresseeR; | 2815 | ++deletedAddresseeR; |
2811 | } else { | 2816 | } else { |
2812 | inR.setRevision( modifiedCalendar ); | 2817 | inR.setRevision( modifiedCalendar ); |
2813 | remote->insertAddressee( inR, false ); | 2818 | remote->insertAddressee( inR, false ); |
2814 | inL = inR; | 2819 | inL = inR; |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index bbed05b..7fae4a9 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1036,32 +1036,36 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1036 | remote->deleteIncidence( inR ); | 1036 | remote->deleteIncidence( inR ); |
1037 | if ( inL->revision() < maxrev ) | 1037 | if ( inL->revision() < maxrev ) |
1038 | inL->setRevision( maxrev ); | 1038 | inL->setRevision( maxrev ); |
1039 | inR = inL->clone(); | 1039 | inR = inL->clone(); |
1040 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1040 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1041 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1041 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1042 | inR->setIDStr( idS ); | 1042 | inR->setIDStr( idS ); |
1043 | remote->addIncidence( inR ); | 1043 | remote->addIncidence( inR ); |
1044 | ++changedRemote; | 1044 | ++changedRemote; |
1045 | } else { | 1045 | } else { |
1046 | if ( inR->revision() < maxrev ) | 1046 | if ( inR->revision() < maxrev ) |
1047 | inR->setRevision( maxrev ); | 1047 | inR->setRevision( maxrev ); |
1048 | idS = inL->IDStr(); | 1048 | idS = inL->IDStr(); |
1049 | local->deleteIncidence( inL ); | 1049 | local->deleteIncidence( inL ); |
1050 | inL = inR->clone(); | 1050 | inL = inR->clone(); |
1051 | inL->setIDStr( idS ); | 1051 | inL->setIDStr( idS ); |
1052 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | ||
1053 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | ||
1054 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | ||
1055 | } | ||
1052 | local->addIncidence( inL ); | 1056 | local->addIncidence( inL ); |
1053 | ++changedLocal; | 1057 | ++changedLocal; |
1054 | } | 1058 | } |
1055 | } | 1059 | } |
1056 | } else { // no conflict | 1060 | } else { // no conflict |
1057 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1061 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1058 | QString des = eventLSync->description(); | 1062 | QString des = eventLSync->description(); |
1059 | QString pref = "e"; | 1063 | QString pref = "e"; |
1060 | if ( inR->type() == "Todo" ) | 1064 | if ( inR->type() == "Todo" ) |
1061 | pref = "t"; | 1065 | pref = "t"; |
1062 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1066 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1063 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1067 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1064 | //remote->deleteIncidence( inR ); | 1068 | //remote->deleteIncidence( inR ); |
1065 | ++deletedEventR; | 1069 | ++deletedEventR; |
1066 | } else { | 1070 | } else { |
1067 | inR->setLastModified( modifiedCalendar ); | 1071 | inR->setLastModified( modifiedCalendar ); |