-rw-r--r-- | kabc/addressee.cpp | 9 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 16 |
2 files changed, 12 insertions, 13 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index d6b70c4..c34f671 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -207,166 +207,165 @@ void Addressee::computeCsum(const QString &dev) | |||
207 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 207 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
208 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 208 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
209 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 209 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
210 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 210 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
211 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 211 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
212 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 212 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
213 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 213 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
214 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 214 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
215 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 215 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
216 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 216 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
217 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 217 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
218 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 218 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
219 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 219 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
220 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 220 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
221 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 221 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
222 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 222 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
223 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 223 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
224 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 224 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
225 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 225 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
226 | // if ( !mData->logo.isEmpty() ) l.append( ); | 226 | // if ( !mData->logo.isEmpty() ) l.append( ); |
227 | //if ( !mData->photo.isEmpty() ) l.append( ); | 227 | //if ( !mData->photo.isEmpty() ) l.append( ); |
228 | //if ( !mData->sound.isEmpty() ) l.append( ); | 228 | //if ( !mData->sound.isEmpty() ) l.append( ); |
229 | //if ( !mData->agent.isEmpty() ) l.append( ); | 229 | //if ( !mData->agent.isEmpty() ) l.append( ); |
230 | //if ( mData->url.isValid() ) l.append( ); | 230 | //if ( mData->url.isValid() ) l.append( ); |
231 | #if 0 | 231 | #if 0 |
232 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | 232 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); |
233 | if ( !mData->addresses.isEmpty() ) l.append( ); | 233 | if ( !mData->addresses.isEmpty() ) l.append( ); |
234 | //if ( !mData->keys.isEmpty() ) l.append( ); | 234 | //if ( !mData->keys.isEmpty() ) l.append( ); |
235 | if ( !mData->emails.isEmpty() ) l.append( ); | 235 | if ( !mData->emails.isEmpty() ) l.append( ); |
236 | if ( !mData->categories .isEmpty() ) l.append( ); | 236 | if ( !mData->categories .isEmpty() ) l.append( ); |
237 | if ( !mData->custom.isEmpty() ) l.append( ); | 237 | if ( !mData->custom.isEmpty() ) l.append( ); |
238 | #endif | 238 | #endif |
239 | KABC::PhoneNumber::List phoneNumbers; | 239 | KABC::PhoneNumber::List phoneNumbers; |
240 | KABC::PhoneNumber::List::Iterator phoneIter; | 240 | KABC::PhoneNumber::List::Iterator phoneIter; |
241 | 241 | ||
242 | QStringList t; | 242 | QStringList t; |
243 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 243 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
244 | ++phoneIter ) | 244 | ++phoneIter ) |
245 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 245 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
246 | t.sort(); | 246 | t.sort(); |
247 | uint iii; | 247 | uint iii; |
248 | for ( iii = 0; iii < t.count(); ++iii) | 248 | for ( iii = 0; iii < t.count(); ++iii) |
249 | l.append( t[iii] ); | 249 | l.append( t[iii] ); |
250 | t = mData->emails; | 250 | t = mData->emails; |
251 | t.sort(); | 251 | t.sort(); |
252 | for ( iii = 0; iii < t.count(); ++iii) | 252 | for ( iii = 0; iii < t.count(); ++iii) |
253 | l.append( t[iii] ); | 253 | l.append( t[iii] ); |
254 | t = mData->categories; | 254 | t = mData->categories; |
255 | t.sort(); | 255 | t.sort(); |
256 | for ( iii = 0; iii < t.count(); ++iii) | 256 | for ( iii = 0; iii < t.count(); ++iii) |
257 | l.append( t[iii] ); | 257 | l.append( t[iii] ); |
258 | t = mData->custom; | 258 | t = mData->custom; |
259 | t.sort(); | 259 | t.sort(); |
260 | for ( iii = 0; iii < t.count(); ++iii) | 260 | for ( iii = 0; iii < t.count(); ++iii) |
261 | l.append( t[iii] ); | 261 | l.append( t[iii] ); |
262 | KABC::Address::List::Iterator addressIter; | 262 | KABC::Address::List::Iterator addressIter; |
263 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 263 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
264 | ++addressIter ) { | 264 | ++addressIter ) { |
265 | t = (*addressIter).asList(); | 265 | t = (*addressIter).asList(); |
266 | t.sort(); | 266 | t.sort(); |
267 | for ( iii = 0; iii < t.count(); ++iii) | 267 | for ( iii = 0; iii < t.count(); ++iii) |
268 | l.append( t[iii] ); | 268 | l.append( t[iii] ); |
269 | } | 269 | } |
270 | uint cs = getCsum4List(l); | 270 | uint cs = getCsum4List(l); |
271 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 271 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
272 | setCsum( dev, QString::number (cs )); | 272 | setCsum( dev, QString::number (cs )); |
273 | } | 273 | } |
274 | void Addressee::removeID(const QString &prof) | 274 | void Addressee::removeID(const QString &prof) |
275 | { | 275 | { |
276 | detach(); | 276 | detach(); |
277 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 277 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
278 | 278 | ||
279 | } | 279 | } |
280 | void Addressee::setID( const QString & prof , const QString & id ) | 280 | void Addressee::setID( const QString & prof , const QString & id ) |
281 | { | 281 | { |
282 | detach(); | 282 | detach(); |
283 | qDebug("setID1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | ||
284 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 283 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
285 | qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 284 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
286 | } | 285 | } |
287 | void Addressee::setTempSyncStat( int id ) | 286 | void Addressee::setTempSyncStat( int id ) |
288 | { | 287 | { |
289 | if ( mData->mTempSyncStat == id ) return; | 288 | if ( mData->mTempSyncStat == id ) return; |
290 | detach(); | 289 | detach(); |
291 | mData->mTempSyncStat = id; | 290 | mData->mTempSyncStat = id; |
292 | } | 291 | } |
293 | int Addressee::tempSyncStat() const | 292 | int Addressee::tempSyncStat() const |
294 | { | 293 | { |
295 | return mData->mTempSyncStat; | 294 | return mData->mTempSyncStat; |
296 | } | 295 | } |
297 | 296 | ||
298 | QString Addressee::getID( const QString & prof) | 297 | QString Addressee::getID( const QString & prof) |
299 | { | 298 | { |
300 | return KIdManager::getId ( mData->mExternalId, prof ); | 299 | return KIdManager::getId ( mData->mExternalId, prof ); |
301 | } | 300 | } |
302 | 301 | ||
303 | void Addressee::setCsum( const QString & prof , const QString & id ) | 302 | void Addressee::setCsum( const QString & prof , const QString & id ) |
304 | { | 303 | { |
305 | detach(); | 304 | detach(); |
306 | qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 305 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
307 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 306 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
308 | qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 307 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
309 | } | 308 | } |
310 | 309 | ||
311 | QString Addressee::getCsum( const QString & prof) | 310 | QString Addressee::getCsum( const QString & prof) |
312 | { | 311 | { |
313 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 312 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
314 | } | 313 | } |
315 | 314 | ||
316 | void Addressee::setIDStr( const QString & s ) | 315 | void Addressee::setIDStr( const QString & s ) |
317 | { | 316 | { |
318 | detach(); | 317 | detach(); |
319 | mData->mExternalId = s; | 318 | mData->mExternalId = s; |
320 | } | 319 | } |
321 | 320 | ||
322 | QString Addressee::IDStr() const | 321 | QString Addressee::IDStr() const |
323 | { | 322 | { |
324 | return mData->mExternalId; | 323 | return mData->mExternalId; |
325 | } | 324 | } |
326 | 325 | ||
327 | 326 | ||
328 | void Addressee::setUid( const QString &id ) | 327 | void Addressee::setUid( const QString &id ) |
329 | { | 328 | { |
330 | if ( id == mData->uid ) return; | 329 | if ( id == mData->uid ) return; |
331 | detach(); | 330 | detach(); |
332 | mData->empty = false; | 331 | mData->empty = false; |
333 | mData->uid = id; | 332 | mData->uid = id; |
334 | } | 333 | } |
335 | 334 | ||
336 | QString Addressee::uid() const | 335 | QString Addressee::uid() const |
337 | { | 336 | { |
338 | if ( mData->uid.isEmpty() ) | 337 | if ( mData->uid.isEmpty() ) |
339 | mData->uid = KApplication::randomString( 10 ); | 338 | mData->uid = KApplication::randomString( 10 ); |
340 | 339 | ||
341 | return mData->uid; | 340 | return mData->uid; |
342 | } | 341 | } |
343 | 342 | ||
344 | QString Addressee::uidLabel() | 343 | QString Addressee::uidLabel() |
345 | { | 344 | { |
346 | return i18n("Unique Identifier"); | 345 | return i18n("Unique Identifier"); |
347 | } | 346 | } |
348 | 347 | ||
349 | void Addressee::setName( const QString &name ) | 348 | void Addressee::setName( const QString &name ) |
350 | { | 349 | { |
351 | if ( name == mData->name ) return; | 350 | if ( name == mData->name ) return; |
352 | detach(); | 351 | detach(); |
353 | mData->empty = false; | 352 | mData->empty = false; |
354 | mData->name = name; | 353 | mData->name = name; |
355 | } | 354 | } |
356 | 355 | ||
357 | QString Addressee::name() const | 356 | QString Addressee::name() const |
358 | { | 357 | { |
359 | return mData->name; | 358 | return mData->name; |
360 | } | 359 | } |
361 | 360 | ||
362 | QString Addressee::nameLabel() | 361 | QString Addressee::nameLabel() |
363 | { | 362 | { |
364 | return i18n("Name"); | 363 | return i18n("Name"); |
365 | } | 364 | } |
366 | 365 | ||
367 | 366 | ||
368 | void Addressee::setFormattedName( const QString &formattedName ) | 367 | void Addressee::setFormattedName( const QString &formattedName ) |
369 | { | 368 | { |
370 | if ( formattedName == mData->formattedName ) return; | 369 | if ( formattedName == mData->formattedName ) return; |
371 | detach(); | 370 | detach(); |
372 | mData->empty = false; | 371 | mData->empty = false; |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 56f6af2..fa0c51f 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2491,139 +2491,139 @@ void KABCore::edit_sync_options() | |||
2491 | 2491 | ||
2492 | 2492 | ||
2493 | } | 2493 | } |
2494 | QString KABCore::getPassword( ) | 2494 | QString KABCore::getPassword( ) |
2495 | { | 2495 | { |
2496 | QString retfile = ""; | 2496 | QString retfile = ""; |
2497 | QDialog dia ( this, "input-dialog", true ); | 2497 | QDialog dia ( this, "input-dialog", true ); |
2498 | QLineEdit lab ( &dia ); | 2498 | QLineEdit lab ( &dia ); |
2499 | lab.setEchoMode( QLineEdit::Password ); | 2499 | lab.setEchoMode( QLineEdit::Password ); |
2500 | QVBoxLayout lay( &dia ); | 2500 | QVBoxLayout lay( &dia ); |
2501 | lay.setMargin(7); | 2501 | lay.setMargin(7); |
2502 | lay.setSpacing(7); | 2502 | lay.setSpacing(7); |
2503 | lay.addWidget( &lab); | 2503 | lay.addWidget( &lab); |
2504 | dia.setFixedSize( 230,50 ); | 2504 | dia.setFixedSize( 230,50 ); |
2505 | dia.setCaption( i18n("Enter password") ); | 2505 | dia.setCaption( i18n("Enter password") ); |
2506 | QPushButton pb ( "OK", &dia); | 2506 | QPushButton pb ( "OK", &dia); |
2507 | lay.addWidget( &pb ); | 2507 | lay.addWidget( &pb ); |
2508 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2508 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2509 | dia.show(); | 2509 | dia.show(); |
2510 | int res = dia.exec(); | 2510 | int res = dia.exec(); |
2511 | if ( res ) | 2511 | if ( res ) |
2512 | retfile = lab.text(); | 2512 | retfile = lab.text(); |
2513 | dia.hide(); | 2513 | dia.hide(); |
2514 | qApp->processEvents(); | 2514 | qApp->processEvents(); |
2515 | return retfile; | 2515 | return retfile; |
2516 | 2516 | ||
2517 | } | 2517 | } |
2518 | #include <libkcal/syncdefines.h> | 2518 | #include <libkcal/syncdefines.h> |
2519 | 2519 | ||
2520 | KABC::Addressee KABCore::getLastSyncAddressee() | 2520 | KABC::Addressee KABCore::getLastSyncAddressee() |
2521 | { | 2521 | { |
2522 | Addressee lse; | 2522 | Addressee lse; |
2523 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2523 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2524 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2524 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2525 | if (lse.isEmpty()) { | 2525 | if (lse.isEmpty()) { |
2526 | qDebug("Creating new last-syncAddressee "); | 2526 | qDebug("Creating new last-syncAddressee "); |
2527 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2527 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2528 | QString sum = ""; | 2528 | QString sum = ""; |
2529 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2529 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2530 | sum = "E: "; | 2530 | sum = "E: "; |
2531 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2531 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2532 | lse.setRevision( mLastAddressbookSync ); | 2532 | lse.setRevision( mLastAddressbookSync ); |
2533 | lse.setCategories( i18n("SyncEvent") ); | 2533 | lse.setCategories( i18n("SyncEvent") ); |
2534 | mAddressBook->insertAddressee( lse ); | 2534 | mAddressBook->insertAddressee( lse ); |
2535 | } | 2535 | } |
2536 | return lse; | 2536 | return lse; |
2537 | } | 2537 | } |
2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2539 | { | 2539 | { |
2540 | 2540 | ||
2541 | //void setZaurusId(int id); | 2541 | //void setZaurusId(int id); |
2542 | // int zaurusId() const; | 2542 | // int zaurusId() const; |
2543 | // void setZaurusUid(int id); | 2543 | // void setZaurusUid(int id); |
2544 | // int zaurusUid() const; | 2544 | // int zaurusUid() const; |
2545 | // void setZaurusStat(int id); | 2545 | // void setZaurusStat(int id); |
2546 | // int zaurusStat() const; | 2546 | // int zaurusStat() const; |
2547 | // 0 equal | 2547 | // 0 equal |
2548 | // 1 take local | 2548 | // 1 take local |
2549 | // 2 take remote | 2549 | // 2 take remote |
2550 | // 3 cancel | 2550 | // 3 cancel |
2551 | QDateTime lastSync = mLastAddressbookSync; | 2551 | QDateTime lastSync = mLastAddressbookSync; |
2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2553 | bool remCh, locCh; | 2553 | bool remCh, locCh; |
2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2555 | if ( remCh ) | 2555 | |
2556 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2556 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2557 | locCh = ( local->revision() > mLastAddressbookSync ); | 2557 | locCh = ( local->revision() > mLastAddressbookSync ); |
2558 | if ( !remCh && ! locCh ) { | 2558 | if ( !remCh && ! locCh ) { |
2559 | qDebug("both not changed "); | 2559 | //qDebug("both not changed "); |
2560 | lastSync = local->revision().addDays(1); | 2560 | lastSync = local->revision().addDays(1); |
2561 | if ( mode <= SYNC_PREF_ASK ) | 2561 | if ( mode <= SYNC_PREF_ASK ) |
2562 | return 0; | 2562 | return 0; |
2563 | } else { | 2563 | } else { |
2564 | if ( locCh ) { | 2564 | if ( locCh ) { |
2565 | qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2565 | //qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2566 | lastSync = local->revision().addDays( -1 ); | 2566 | lastSync = local->revision().addDays( -1 ); |
2567 | if ( !remCh ) | 2567 | if ( !remCh ) |
2568 | remote->setRevision( lastSync.addDays( -1 ) ); | 2568 | remote->setRevision( lastSync.addDays( -1 ) ); |
2569 | } else { | 2569 | } else { |
2570 | //qDebug(" not loc changed "); | 2570 | //qDebug(" not loc changed "); |
2571 | lastSync = local->revision().addDays( 1 ); | 2571 | lastSync = local->revision().addDays( 1 ); |
2572 | if ( remCh ) | 2572 | if ( remCh ) |
2573 | remote->setRevision( lastSync.addDays( 1 ) ); | 2573 | remote->setRevision( lastSync.addDays( 1 ) ); |
2574 | 2574 | ||
2575 | } | 2575 | } |
2576 | } | 2576 | } |
2577 | full = true; | 2577 | full = true; |
2578 | if ( mode < SYNC_PREF_ASK ) | 2578 | if ( mode < SYNC_PREF_ASK ) |
2579 | mode = SYNC_PREF_ASK; | 2579 | mode = SYNC_PREF_ASK; |
2580 | } else { | 2580 | } else { |
2581 | if ( local->revision() == remote->revision() ) | 2581 | if ( local->revision() == remote->revision() ) |
2582 | return 0; | 2582 | return 0; |
2583 | 2583 | ||
2584 | } | 2584 | } |
2585 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2585 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2586 | 2586 | ||
2587 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 2587 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
2588 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2588 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2589 | //full = true; //debug only | 2589 | //full = true; //debug only |
2590 | if ( full ) { | 2590 | if ( full ) { |
2591 | bool equ = ( (*local) == (*remote) ); | 2591 | bool equ = ( (*local) == (*remote) ); |
2592 | if ( equ ) { | 2592 | if ( equ ) { |
2593 | //qDebug("equal "); | 2593 | //qDebug("equal "); |
2594 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2594 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2595 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2595 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2596 | } | 2596 | } |
2597 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2597 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2598 | return 0; | 2598 | return 0; |
2599 | 2599 | ||
2600 | }//else //debug only | 2600 | }//else //debug only |
2601 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2601 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2602 | } | 2602 | } |
2603 | int result; | 2603 | int result; |
2604 | bool localIsNew; | 2604 | bool localIsNew; |
2605 | //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() ); | 2605 | //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() ); |
2606 | 2606 | ||
2607 | if ( full && mode < SYNC_PREF_NEWEST ) | 2607 | if ( full && mode < SYNC_PREF_NEWEST ) |
2608 | mode = SYNC_PREF_ASK; | 2608 | mode = SYNC_PREF_ASK; |
2609 | 2609 | ||
2610 | switch( mode ) { | 2610 | switch( mode ) { |
2611 | case SYNC_PREF_LOCAL: | 2611 | case SYNC_PREF_LOCAL: |
2612 | if ( lastSync > remote->revision() ) | 2612 | if ( lastSync > remote->revision() ) |
2613 | return 1; | 2613 | return 1; |
2614 | if ( lastSync > local->revision() ) | 2614 | if ( lastSync > local->revision() ) |
2615 | return 2; | 2615 | return 2; |
2616 | return 1; | 2616 | return 1; |
2617 | break; | 2617 | break; |
2618 | case SYNC_PREF_REMOTE: | 2618 | case SYNC_PREF_REMOTE: |
2619 | if ( lastSync > remote->revision() ) | 2619 | if ( lastSync > remote->revision() ) |
2620 | return 1; | 2620 | return 1; |
2621 | if ( lastSync > local->revision() ) | 2621 | if ( lastSync > local->revision() ) |
2622 | return 2; | 2622 | return 2; |
2623 | return 2; | 2623 | return 2; |
2624 | break; | 2624 | break; |
2625 | case SYNC_PREF_NEWEST: | 2625 | case SYNC_PREF_NEWEST: |
2626 | if ( local->revision() > remote->revision() ) | 2626 | if ( local->revision() > remote->revision() ) |
2627 | return 1; | 2627 | return 1; |
2628 | else | 2628 | else |
2629 | return 2; | 2629 | return 2; |
@@ -2665,129 +2665,129 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2665 | int changedLocal = 0; | 2665 | int changedLocal = 0; |
2666 | int changedRemote = 0; | 2666 | int changedRemote = 0; |
2667 | //QPtrList<Addressee> el = local->rawAddressees(); | 2667 | //QPtrList<Addressee> el = local->rawAddressees(); |
2668 | Addressee addresseeR; | 2668 | Addressee addresseeR; |
2669 | QString uid; | 2669 | QString uid; |
2670 | int take; | 2670 | int take; |
2671 | Addressee addresseeL; | 2671 | Addressee addresseeL; |
2672 | Addressee addresseeRSync; | 2672 | Addressee addresseeRSync; |
2673 | Addressee addresseeLSync; | 2673 | Addressee addresseeLSync; |
2674 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2674 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2675 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2675 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2676 | bool fullDateRange = false; | 2676 | bool fullDateRange = false; |
2677 | local->resetTempSyncStat(); | 2677 | local->resetTempSyncStat(); |
2678 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2678 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2679 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2679 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2680 | addresseeLSync = getLastSyncAddressee(); | 2680 | addresseeLSync = getLastSyncAddressee(); |
2681 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2681 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2682 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2682 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2683 | if ( !addresseeR.isEmpty() ) { | 2683 | if ( !addresseeR.isEmpty() ) { |
2684 | addresseeRSync = addresseeR; | 2684 | addresseeRSync = addresseeR; |
2685 | remote->removeAddressee(addresseeR ); | 2685 | remote->removeAddressee(addresseeR ); |
2686 | 2686 | ||
2687 | } else { | 2687 | } else { |
2688 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2688 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2689 | addresseeRSync = addresseeLSync ; | 2689 | addresseeRSync = addresseeLSync ; |
2690 | } else { | 2690 | } else { |
2691 | qDebug("FULLDATE 1"); | 2691 | qDebug("FULLDATE 1"); |
2692 | fullDateRange = true; | 2692 | fullDateRange = true; |
2693 | Addressee newAdd; | 2693 | Addressee newAdd; |
2694 | addresseeRSync = newAdd; | 2694 | addresseeRSync = newAdd; |
2695 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2695 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2696 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2696 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2697 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2697 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2698 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2698 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2699 | } | 2699 | } |
2700 | } | 2700 | } |
2701 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2701 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2702 | qDebug("FULLDATE 2"); | 2702 | qDebug("FULLDATE 2"); |
2703 | fullDateRange = true; | 2703 | fullDateRange = true; |
2704 | } | 2704 | } |
2705 | if ( ! fullDateRange ) { | 2705 | if ( ! fullDateRange ) { |
2706 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2706 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2707 | 2707 | ||
2708 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2708 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2709 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2709 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2710 | fullDateRange = true; | 2710 | fullDateRange = true; |
2711 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2711 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2712 | } | 2712 | } |
2713 | } | 2713 | } |
2714 | // fullDateRange = true; // debug only! | 2714 | // fullDateRange = true; // debug only! |
2715 | if ( fullDateRange ) | 2715 | if ( fullDateRange ) |
2716 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2716 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2717 | else | 2717 | else |
2718 | mLastAddressbookSync = addresseeLSync.revision(); | 2718 | mLastAddressbookSync = addresseeLSync.revision(); |
2719 | // for resyncing if own file has changed | 2719 | // for resyncing if own file has changed |
2720 | // PENDING fixme later when implemented | 2720 | // PENDING fixme later when implemented |
2721 | #if 0 | 2721 | #if 0 |
2722 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2722 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2723 | mLastAddressbookSync = loadedFileVersion; | 2723 | mLastAddressbookSync = loadedFileVersion; |
2724 | qDebug("setting mLastAddressbookSync "); | 2724 | qDebug("setting mLastAddressbookSync "); |
2725 | } | 2725 | } |
2726 | #endif | 2726 | #endif |
2727 | 2727 | ||
2728 | //qDebug("*************************** "); | 2728 | //qDebug("*************************** "); |
2729 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2729 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2730 | QStringList er = remote->uidList(); | 2730 | QStringList er = remote->uidList(); |
2731 | Addressee inR ;//= er.first(); | 2731 | Addressee inR ;//= er.first(); |
2732 | Addressee inL; | 2732 | Addressee inL; |
2733 | QProgressBar bar( er.count(),0 ); | 2733 | QProgressBar bar( er.count(),0 ); |
2734 | bar.setCaption (i18n("Syncing - close to abort!") ); | 2734 | bar.setCaption (i18n("Syncing - close to abort!") ); |
2735 | 2735 | ||
2736 | int w = 300; | 2736 | int w = 300; |
2737 | if ( QApplication::desktop()->width() < 320 ) | 2737 | if ( QApplication::desktop()->width() < 320 ) |
2738 | w = 220; | 2738 | w = 220; |
2739 | int h = bar.sizeHint().height() ; | 2739 | int h = bar.sizeHint().height() ; |
2740 | int dw = QApplication::desktop()->width(); | 2740 | int dw = QApplication::desktop()->width(); |
2741 | int dh = QApplication::desktop()->height(); | 2741 | int dh = QApplication::desktop()->height(); |
2742 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2742 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2743 | bar.show(); | 2743 | bar.show(); |
2744 | int modulo = (er.count()/10)+1; | 2744 | int modulo = (er.count()/10)+1; |
2745 | int incCounter = 0; | 2745 | int incCounter = 0; |
2746 | while ( incCounter < er.count()) { | 2746 | while ( incCounter < er.count()) { |
2747 | if ( ! bar.isVisible() ) | 2747 | if ( ! bar.isVisible() ) |
2748 | return false; | 2748 | return false; |
2749 | if ( incCounter % modulo == 0 ) | 2749 | if ( incCounter % modulo == 0 ) |
2750 | bar.setProgress( incCounter ); | 2750 | bar.setProgress( incCounter ); |
2751 | uid = er[ incCounter ]; | 2751 | uid = er[ incCounter ]; |
2752 | bool skipIncidence = false; | 2752 | bool skipIncidence = false; |
2753 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2753 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2754 | skipIncidence = true; | 2754 | skipIncidence = true; |
2755 | QString idS; | 2755 | QString idS; |
2756 | qApp->processEvents(); | 2756 | qApp->processEvents(); |
2757 | if ( !skipIncidence ) { | 2757 | if ( !skipIncidence ) { |
2758 | inL = local->findByUid( uid ); | 2758 | inL = local->findByUid( uid ); |
2759 | inR = remote->findByUid( uid ); | 2759 | inR = remote->findByUid( uid ); |
2760 | //inL.setResource( 0 ); | 2760 | //inL.setResource( 0 ); |
2761 | //inR.setResource( 0 ); | 2761 | //inR.setResource( 0 ); |
2762 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2762 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2763 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2763 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2764 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2764 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2765 | if ( take == 3 ) | 2765 | if ( take == 3 ) |
2766 | return false; | 2766 | return false; |
2767 | if ( take == 1 ) {// take local | 2767 | if ( take == 1 ) {// take local |
2768 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2768 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2769 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2769 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2770 | local->insertAddressee( inL, false ); | 2770 | local->insertAddressee( inL, false ); |
2771 | } | 2771 | } |
2772 | else | 2772 | else |
2773 | idS = inR.IDStr(); | 2773 | idS = inR.IDStr(); |
2774 | remote->removeAddressee( inR ); | 2774 | remote->removeAddressee( inR ); |
2775 | inR = inL; | 2775 | inR = inL; |
2776 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2776 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2777 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 2777 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
2778 | inR.setIDStr( idS ); | 2778 | inR.setIDStr( idS ); |
2779 | inR.setResource( 0 ); | 2779 | inR.setResource( 0 ); |
2780 | remote->insertAddressee( inR , false); | 2780 | remote->insertAddressee( inR , false); |
2781 | ++changedRemote; | 2781 | ++changedRemote; |
2782 | } else { | 2782 | } else { |
2783 | idS = inL.IDStr(); | 2783 | idS = inL.IDStr(); |
2784 | local->removeAddressee( inL ); | 2784 | local->removeAddressee( inL ); |
2785 | inL = inR; | 2785 | inL = inR; |
2786 | inL.setIDStr( idS ); | 2786 | inL.setIDStr( idS ); |
2787 | inL.setResource( 0 ); | 2787 | inL.setResource( 0 ); |
2788 | local->insertAddressee( inL , false ); | 2788 | local->insertAddressee( inL , false ); |
2789 | ++changedLocal; | 2789 | ++changedLocal; |
2790 | } | 2790 | } |
2791 | } | 2791 | } |
2792 | } else { // no conflict | 2792 | } else { // no conflict |
2793 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2793 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
@@ -2856,167 +2856,167 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2856 | inR = inL; | 2856 | inR = inL; |
2857 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2857 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2858 | inR.setResource( 0 ); | 2858 | inR.setResource( 0 ); |
2859 | remote->insertAddressee( inR, false ); | 2859 | remote->insertAddressee( inR, false ); |
2860 | } | 2860 | } |
2861 | } | 2861 | } |
2862 | } else { | 2862 | } else { |
2863 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2863 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2864 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2864 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2865 | local->removeAddressee( inL ); | 2865 | local->removeAddressee( inL ); |
2866 | ++deletedAddresseeL; | 2866 | ++deletedAddresseeL; |
2867 | } else { | 2867 | } else { |
2868 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2868 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2869 | ++addedAddresseeR; | 2869 | ++addedAddresseeR; |
2870 | inL.setRevision( modifiedCalendar ); | 2870 | inL.setRevision( modifiedCalendar ); |
2871 | local->insertAddressee( inL, false ); | 2871 | local->insertAddressee( inL, false ); |
2872 | inR = inL; | 2872 | inR = inL; |
2873 | inR.setResource( 0 ); | 2873 | inR.setResource( 0 ); |
2874 | remote->insertAddressee( inR, false ); | 2874 | remote->insertAddressee( inR, false ); |
2875 | } | 2875 | } |
2876 | } | 2876 | } |
2877 | } | 2877 | } |
2878 | } | 2878 | } |
2879 | } | 2879 | } |
2880 | ++incCounter; | 2880 | ++incCounter; |
2881 | } | 2881 | } |
2882 | el.clear(); | 2882 | el.clear(); |
2883 | bar.hide(); | 2883 | bar.hide(); |
2884 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2884 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2885 | // get rid of micro seconds | 2885 | // get rid of micro seconds |
2886 | QTime t = mLastAddressbookSync.time(); | 2886 | QTime t = mLastAddressbookSync.time(); |
2887 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2887 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2888 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2888 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2889 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2889 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2890 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2890 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2891 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2891 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2892 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2892 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2893 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2893 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2894 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2894 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2895 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2895 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2896 | addresseeRSync.setNote( "" ) ; | 2896 | addresseeRSync.setNote( "" ) ; |
2897 | addresseeLSync.setNote( "" ); | 2897 | addresseeLSync.setNote( "" ); |
2898 | 2898 | ||
2899 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2899 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2900 | remote->insertAddressee( addresseeRSync, false ); | 2900 | remote->insertAddressee( addresseeRSync, false ); |
2901 | local->insertAddressee( addresseeLSync, false ); | 2901 | local->insertAddressee( addresseeLSync, false ); |
2902 | QString mes; | 2902 | QString mes; |
2903 | 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 ); | 2903 | 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 ); |
2904 | if ( KABPrefs::instance()->mShowSyncSummary ) { | 2904 | if ( KABPrefs::instance()->mShowSyncSummary ) { |
2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2906 | } | 2906 | } |
2907 | qDebug( mes ); | 2907 | qDebug( mes ); |
2908 | return syncOK; | 2908 | return syncOK; |
2909 | } | 2909 | } |
2910 | 2910 | ||
2911 | bool KABCore::syncAB(QString filename, int mode) | 2911 | bool KABCore::syncAB(QString filename, int mode) |
2912 | { | 2912 | { |
2913 | 2913 | ||
2914 | //pending prepare addresseeview for output | 2914 | //pending prepare addresseeview for output |
2915 | //pending detect, if remote file has REV field. if not switch to external sync | 2915 | //pending detect, if remote file has REV field. if not switch to external sync |
2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2917 | AddressBook abLocal(filename,"syncContact"); | 2917 | AddressBook abLocal(filename,"syncContact"); |
2918 | bool syncOK = false; | 2918 | bool syncOK = false; |
2919 | if ( abLocal.load() ) { | 2919 | if ( abLocal.load() ) { |
2920 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); | 2920 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2921 | bool external = false; | 2921 | bool external = false; |
2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2923 | if ( ! lse.isEmpty() ) { | 2923 | if ( ! lse.isEmpty() ) { |
2924 | if ( lse.familyName().left(4) == "!E: " ) | 2924 | if ( lse.familyName().left(4) == "!E: " ) |
2925 | external = true; | 2925 | external = true; |
2926 | } else { | 2926 | } else { |
2927 | bool found = false; | 2927 | bool found = false; |
2928 | QDateTime dt( QDate( 2004,1,1)); | 2928 | QDateTime dt( QDate( 2004,1,1)); |
2929 | AddressBook::Iterator it; | 2929 | AddressBook::Iterator it; |
2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2931 | if ( (*it).revision() != dt ) { | 2931 | if ( (*it).revision() != dt ) { |
2932 | found = true; | 2932 | found = true; |
2933 | break; | 2933 | break; |
2934 | } | 2934 | } |
2935 | } | 2935 | } |
2936 | external = ! found; | 2936 | external = ! found; |
2937 | } | 2937 | } |
2938 | 2938 | ||
2939 | if ( external ) { | 2939 | if ( external ) { |
2940 | qDebug("**********Setting vcf mode to external "); | 2940 | qDebug("Setting vcf mode to external "); |
2941 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2941 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2942 | AddressBook::Iterator it; | 2942 | AddressBook::Iterator it; |
2943 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2943 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2944 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2944 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2945 | (*it).computeCsum( mCurrentSyncDevice ); | 2945 | (*it).computeCsum( mCurrentSyncDevice ); |
2946 | } | 2946 | } |
2947 | } | 2947 | } |
2948 | //AddressBook::Iterator it; | 2948 | //AddressBook::Iterator it; |
2949 | //QStringList vcards; | 2949 | //QStringList vcards; |
2950 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2950 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2951 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2951 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2952 | //} | 2952 | //} |
2953 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2953 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2954 | if ( syncOK ) { | 2954 | if ( syncOK ) { |
2955 | if ( KABPrefs::instance()->mWriteBackFile ) | 2955 | if ( KABPrefs::instance()->mWriteBackFile ) |
2956 | { | 2956 | { |
2957 | if ( external ) | 2957 | if ( external ) |
2958 | abLocal.removeDeletedAddressees(); | 2958 | abLocal.removeDeletedAddressees(); |
2959 | qDebug("saving remote AB "); | 2959 | qDebug("Saving remote AB "); |
2960 | abLocal.saveAB(); | 2960 | abLocal.saveAB(); |
2961 | } | 2961 | } |
2962 | } | 2962 | } |
2963 | setModified(); | 2963 | setModified(); |
2964 | 2964 | ||
2965 | } | 2965 | } |
2966 | if ( syncOK ) | 2966 | if ( syncOK ) |
2967 | mViewManager->refreshView(); | 2967 | mViewManager->refreshView(); |
2968 | return syncOK; | 2968 | return syncOK; |
2969 | #if 0 | 2969 | #if 0 |
2970 | 2970 | ||
2971 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2971 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2972 | getEventViewerDialog()->setSyncMode( true ); | 2972 | getEventViewerDialog()->setSyncMode( true ); |
2973 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2973 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2974 | getEventViewerDialog()->setSyncMode( false ); | 2974 | getEventViewerDialog()->setSyncMode( false ); |
2975 | if ( syncOK ) { | 2975 | if ( syncOK ) { |
2976 | if ( KOPrefs::instance()->mWriteBackFile ) | 2976 | if ( KOPrefs::instance()->mWriteBackFile ) |
2977 | { | 2977 | { |
2978 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2978 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2979 | storage->save(); | 2979 | storage->save(); |
2980 | } | 2980 | } |
2981 | } | 2981 | } |
2982 | setModified(); | 2982 | setModified(); |
2983 | } | 2983 | } |
2984 | 2984 | ||
2985 | #endif | 2985 | #endif |
2986 | } | 2986 | } |
2987 | 2987 | ||
2988 | void KABCore::confSync() | 2988 | void KABCore::confSync() |
2989 | { | 2989 | { |
2990 | static KSyncPrefsDialog* sp = 0; | 2990 | static KSyncPrefsDialog* sp = 0; |
2991 | if ( ! sp ) { | 2991 | if ( ! sp ) { |
2992 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 2992 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
2993 | } | 2993 | } |
2994 | sp->usrReadConfig(); | 2994 | sp->usrReadConfig(); |
2995 | #ifndef DESKTOP_VERSION | 2995 | #ifndef DESKTOP_VERSION |
2996 | sp->showMaximized(); | 2996 | sp->showMaximized(); |
2997 | #else | 2997 | #else |
2998 | sp->show(); | 2998 | sp->show(); |
2999 | #endif | 2999 | #endif |
3000 | sp->exec(); | 3000 | sp->exec(); |
3001 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 3001 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
3002 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 3002 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
3003 | fillSyncMenu(); | 3003 | fillSyncMenu(); |
3004 | } | 3004 | } |
3005 | void KABCore::syncSharp() | 3005 | void KABCore::syncSharp() |
3006 | { | 3006 | { |
3007 | if ( mModified ) | 3007 | if ( mModified ) |
3008 | save(); | 3008 | save(); |
3009 | qDebug("pending syncSharp() "); | 3009 | qDebug("pending syncSharp() "); |
3010 | //mView->syncSharp(); | 3010 | //mView->syncSharp(); |
3011 | setModified(); | 3011 | setModified(); |
3012 | 3012 | ||
3013 | } | 3013 | } |
3014 | void KABCore::syncPhone() | 3014 | void KABCore::syncPhone() |
3015 | { | 3015 | { |
3016 | if ( mModified ) | 3016 | if ( mModified ) |
3017 | save(); | 3017 | save(); |
3018 | qDebug("pending syncPhone(); "); | 3018 | qDebug("pending syncPhone(); "); |
3019 | //mView->syncPhone(); | 3019 | //mView->syncPhone(); |
3020 | setModified(); | 3020 | setModified(); |
3021 | 3021 | ||
3022 | } | 3022 | } |