summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp27
-rw-r--r--kabc/addressbook.h3
-rw-r--r--kabc/addressee.cpp6
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp2
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp79
-rw-r--r--kaddressbook/kabcore.cpp58
-rw-r--r--korganizer/calendarview.cpp44
7 files changed, 153 insertions, 66 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 86dc7c2..17b9ba2 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -543,40 +543,39 @@ void AddressBook::removeAddressee( const Addressee &a )
543 } 543 }
544 } 544 }
545 } 545 }
546 546
547 } 547 }
548 } 548 }
549 549
550 if ( found ) 550 if ( found )
551 removeAddressee( it2 ); 551 removeAddressee( it2 );
552 552
553} 553}
554 554
555void AddressBook::removeDeletedAddressees() 555void AddressBook::removeSyncAddressees( bool removeDeleted )
556{ 556{
557 deleteRemovedAddressees();
558 Iterator it = begin(); 557 Iterator it = begin();
559 Iterator it2 ; 558 Iterator it2 ;
560 QDateTime dt ( QDate( 2004,1,1) ); 559 QDateTime dt ( QDate( 2004,1,1) );
561 while ( it != end() ) { 560 while ( it != end() ) {
562 (*it).setRevision( dt ); 561 (*it).setRevision( dt );
563 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 562 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
564 (*it).setIDStr(""); 563 (*it).setIDStr("");
565 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 564 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
566 it2 = it; 565 it2 = it;
567 //qDebug("removing %s ",(*it).uid().latin1() ); 566 //qDebug("removing %s ",(*it).uid().latin1() );
568 ++it; 567 ++it;
569 removeAddressee( it2 ); 568 removeAddressee( it2 );
570 } else { 569 } else {
571 //qDebug("skipping %s ",(*it).uid().latin1() ); 570 //qDebug("skipping %s ",(*it).uid().latin1() );
572 ++it; 571 ++it;
573 } 572 }
574 } 573 }
575 deleteRemovedAddressees(); 574 deleteRemovedAddressees();
576} 575}
577 576
578void AddressBook::removeAddressee( const Iterator &it ) 577void AddressBook::removeAddressee( const Iterator &it )
579{ 578{
580 d->mRemovedAddressees.append( (*it) ); 579 d->mRemovedAddressees.append( (*it) );
581 d->mAddressees.remove( it.d->mIt ); 580 d->mAddressees.remove( it.d->mIt );
582} 581}
@@ -608,60 +607,76 @@ void AddressBook::preExternSync( AddressBook* aBook, const QString& csd )
608 AddressBook::Iterator it; 607 AddressBook::Iterator it;
609 for ( it = begin(); it != end(); ++it ) { 608 for ( it = begin(); it != end(); ++it ) {
610 (*it).setID( csd, (*it).externalUID() ); 609 (*it).setID( csd, (*it).externalUID() );
611 (*it).computeCsum( csd ); 610 (*it).computeCsum( csd );
612 } 611 }
613 mergeAB( aBook ,csd ); 612 mergeAB( aBook ,csd );
614} 613}
615void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 614void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
616{ 615{
617 qDebug("AddressBook::postExternSync "); 616 qDebug("AddressBook::postExternSync ");
618 AddressBook::Iterator it; 617 AddressBook::Iterator it;
619 for ( it = begin(); it != end(); ++it ) { 618 for ( it = begin(); it != end(); ++it ) {
619 qDebug("check uid %s ", (*it).uid().latin1() );
620 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 620 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
621 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 621 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
622 Addressee ad = aBook->findByUid( ( (*it).uid() )); 622 Addressee ad = aBook->findByUid( ( (*it).uid() ));
623 if ( ad.isEmpty() ) { 623 if ( ad.isEmpty() ) {
624 qDebug("ERROR ad empty "); 624 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
625 } else { 625 } else {
626 (*it).computeCsum( csd ); 626 (*it).computeCsum( csd );
627 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 627 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
628 ad.setID( csd, (*it).externalUID() ); 628 ad.setID( csd, (*it).externalUID() );
629 ad.setCsum( csd, (*it).getCsum( csd ) ); 629 ad.setCsum( csd, (*it).getCsum( csd ) );
630 aBook->insertAddressee( ad ); 630 aBook->insertAddressee( ad );
631 } 631 }
632 } 632 }
633 } 633 }
634} 634}
635 635
636 636bool AddressBook::containsExternalUid( const QString& uid )
637{
638 Iterator it;
639 for ( it = begin(); it != end(); ++it ) {
640 if ( uid == (*it).externalUID( ) )
641 return true;
642 }
643 return false;
644}
637Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 645Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
638{ 646{
639 Iterator it; 647 Iterator it;
640 for ( it = begin(); it != end(); ++it ) { 648 for ( it = begin(); it != end(); ++it ) {
641 if ( uid == (*it).getID( profile ) ) 649 if ( uid == (*it).getID( profile ) )
642 return (*it); 650 return (*it);
643 } 651 }
644 return Addressee(); 652 return Addressee();
645} 653}
646void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) 654void AddressBook::mergeAB( AddressBook *aBook, const QString& profile )
647{ 655{
648 Iterator it; 656 Iterator it;
649 Addressee ad; 657 Addressee ad;
650 for ( it = begin(); it != end(); ++it ) { 658 for ( it = begin(); it != end(); ++it ) {
651 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 659 ad = aBook->findByExternUid( (*it).externalUID(), profile );
652 if ( !ad.isEmpty() ) { 660 if ( !ad.isEmpty() ) {
653 (*it).mergeContact( ad ); 661 (*it).mergeContact( ad );
654 } 662 }
655 } 663 }
664#if 0
665 // test only
666 for ( it = begin(); it != end(); ++it ) {
667
668 qDebug("uid %s ", (*it).uid().latin1());
669 }
670#endif
656} 671}
657 672
658#if 0 673#if 0
659Addressee::List AddressBook::getExternLastSyncAddressees() 674Addressee::List AddressBook::getExternLastSyncAddressees()
660{ 675{
661 Addressee::List results; 676 Addressee::List results;
662 677
663 Iterator it; 678 Iterator it;
664 for ( it = begin(); it != end(); ++it ) { 679 for ( it = begin(); it != end(); ++it ) {
665 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 680 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
666 if ( (*it).familyName().left(4) == "!E: " ) 681 if ( (*it).familyName().left(4) == "!E: " )
667 results.append( *it ); 682 results.append( *it );
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 157dc56..8f62f0d 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -283,27 +283,28 @@ class AddressBook : public QObject
283 */ 283 */
284 void error( const QString& ); 284 void error( const QString& );
285 285
286 /** 286 /**
287 Query all resources to clean up their lock files 287 Query all resources to clean up their lock files
288 */ 288 */
289 void cleanUp(); 289 void cleanUp();
290 290
291 // sync stuff 291 // sync stuff
292 //Addressee::List getExternLastSyncAddressees(); 292 //Addressee::List getExternLastSyncAddressees();
293 void resetTempSyncStat(); 293 void resetTempSyncStat();
294 QStringList uidList(); 294 QStringList uidList();
295 void removeDeletedAddressees(); 295 void removeSyncAddressees( bool removeDeleted = false );
296 void mergeAB( AddressBook *aBook, const QString& profile ); 296 void mergeAB( AddressBook *aBook, const QString& profile );
297 Addressee findByExternUid( const QString& uid , const QString& profile ); 297 Addressee findByExternUid( const QString& uid , const QString& profile );
298 bool containsExternalUid( const QString& uid );
298 299
299 void preExternSync( AddressBook* aBook, const QString& csd ); 300 void preExternSync( AddressBook* aBook, const QString& csd );
300 void postExternSync( AddressBook* aBook, const QString& csd ); 301 void postExternSync( AddressBook* aBook, const QString& csd );
301 signals: 302 signals:
302 /** 303 /**
303 Emitted, when the address book has changed on disk. 304 Emitted, when the address book has changed on disk.
304 */ 305 */
305 void addressBookChanged( AddressBook * ); 306 void addressBookChanged( AddressBook * );
306 307
307 /** 308 /**
308 Emitted, when the address book has been locked for writing. 309 Emitted, when the address book has been locked for writing.
309 */ 310 */
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index fda62f1..e241281 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -86,25 +86,25 @@ struct Addressee::AddresseeData : public KShared
86 86
87 bool empty :1; 87 bool empty :1;
88 bool changed :1; 88 bool changed :1;
89}; 89};
90 90
91Addressee::Addressee() 91Addressee::Addressee()
92{ 92{
93 mData = new AddresseeData; 93 mData = new AddresseeData;
94 mData->empty = true; 94 mData->empty = true;
95 mData->changed = false; 95 mData->changed = false;
96 mData->resource = 0; 96 mData->resource = 0;
97 mData->mExternalId = ":"; 97 mData->mExternalId = ":";
98 mData->revision = QDateTime ( QDate( 2004,1,1)); 98 mData->revision = QDateTime ( QDate( 2003,1,1));
99 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 99 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
100} 100}
101 101
102Addressee::~Addressee() 102Addressee::~Addressee()
103{ 103{
104} 104}
105 105
106Addressee::Addressee( const Addressee &a ) 106Addressee::Addressee( const Addressee &a )
107{ 107{
108 mData = a.mData; 108 mData = a.mData;
109} 109}
110 110
@@ -299,24 +299,26 @@ void Addressee::mergeContact( const Addressee& ad )
299 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 299 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
300 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 300 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
301 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 301 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
302 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 302 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
303 303
304 // pending: 304 // pending:
305 // merging phonenumbers 305 // merging phonenumbers
306 // merging addresses 306 // merging addresses
307 // merging emails; 307 // merging emails;
308 // merging categories; 308 // merging categories;
309 // merging custom; 309 // merging custom;
310 // merging keys 310 // merging keys
311 qDebug("merge contact %s ", ad.uid().latin1());
312 setUid( ad.uid() );
311} 313}
312 314
313void Addressee::removeID(const QString &prof) 315void Addressee::removeID(const QString &prof)
314{ 316{
315 detach(); 317 detach();
316 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 318 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
317 319
318} 320}
319void Addressee::setID( const QString & prof , const QString & id ) 321void Addressee::setID( const QString & prof , const QString & id )
320{ 322{
321 detach(); 323 detach();
322 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 324 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
@@ -370,36 +372,38 @@ void Addressee::setExternalUID( const QString &id )
370 mData->externalUID = id; 372 mData->externalUID = id;
371} 373}
372 374
373QString Addressee::externalUID() const 375QString Addressee::externalUID() const
374{ 376{
375 return mData->externalUID; 377 return mData->externalUID;
376} 378}
377void Addressee::setOriginalExternalUID( const QString &id ) 379void Addressee::setOriginalExternalUID( const QString &id )
378{ 380{
379 if ( id == mData->originalExternalUID ) return; 381 if ( id == mData->originalExternalUID ) return;
380 detach(); 382 detach();
381 mData->empty = false; 383 mData->empty = false;
384 qDebug("*******Set orig uid %s ", id.latin1());
382 mData->originalExternalUID = id; 385 mData->originalExternalUID = id;
383} 386}
384 387
385QString Addressee::originalExternalUID() const 388QString Addressee::originalExternalUID() const
386{ 389{
387 return mData->originalExternalUID; 390 return mData->originalExternalUID;
388} 391}
389 392
390void Addressee::setUid( const QString &id ) 393void Addressee::setUid( const QString &id )
391{ 394{
392 if ( id == mData->uid ) return; 395 if ( id == mData->uid ) return;
393 detach(); 396 detach();
397 qDebug("****setuid %s ", id.latin1());
394 mData->empty = false; 398 mData->empty = false;
395 mData->uid = id; 399 mData->uid = id;
396} 400}
397 401
398QString Addressee::uid() const 402QString Addressee::uid() const
399{ 403{
400 if ( mData->uid.isEmpty() ) 404 if ( mData->uid.isEmpty() )
401 mData->uid = KApplication::randomString( 10 ); 405 mData->uid = KApplication::randomString( 10 );
402 406
403 return mData->uid; 407 return mData->uid;
404} 408}
405 409
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp
index de45e63..430c7b3 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.cpp
+++ b/kabc/plugins/qtopia/qtopiaconverter.cpp
@@ -77,25 +77,25 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a
77 addr.setPrefix( contact.nameTitle() ); 77 addr.setPrefix( contact.nameTitle() );
78 addr.setSuffix( contact.suffix() ); 78 addr.setSuffix( contact.suffix() );
79 79
80 addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 80 addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
81 QString exuid = contact.uid().toString(); 81 QString exuid = contact.uid().toString();
82 addr.setOriginalExternalUID( exuid ); 82 addr.setOriginalExternalUID( exuid );
83 int ente = exuid.find( "-0000"); 83 int ente = exuid.find( "-0000");
84 if ( exuid.left(1) == "{" ) 84 if ( exuid.left(1) == "{" )
85 exuid = exuid.mid(1); 85 exuid = exuid.mid(1);
86 if ( ente > -1 ) 86 if ( ente > -1 )
87 exuid = exuid.left( ente-1 ); 87 exuid = exuid.left( ente-1 );
88 addr.setExternalUID( exuid ); 88 addr.setExternalUID( exuid );
89 //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() ); 89 qDebug("QtopiaConverter:set %s uid %s ",addr.originalExternalUID().latin1(),addr.externalUID().latin1() );
90 90
91 // email 91 // email
92 QStringList emails = contact.emailList(); 92 QStringList emails = contact.emailList();
93 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 93 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
94 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); 94 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
95 } 95 }
96 96
97 if (!contact.defaultEmail().isEmpty()) 97 if (!contact.defaultEmail().isEmpty())
98 addr.insertEmail(contact.defaultEmail(), true); 98 addr.insertEmail(contact.defaultEmail(), true);
99 99
100 // home 100 // home
101 if ((!contact.homeStreet().isEmpty()) || 101 if ((!contact.homeStreet().isEmpty()) ||
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 935a1cf..1f90fcb 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -188,65 +188,124 @@ bool ResourceQtopia::load()
188 188
189 return true; 189 return true;
190} 190}
191 191
192bool ResourceQtopia::save( Ticket *ticket ) 192bool ResourceQtopia::save( Ticket *ticket )
193{ 193{
194 qDebug("ResourceQtopia::save: %s", fileName().latin1()); 194 qDebug("ResourceQtopia::save: %s", fileName().latin1());
195 195
196 mDirWatch.stopScan(); 196 mDirWatch.stopScan();
197 197
198 KABC::AddressBook::Iterator it; 198 KABC::AddressBook::Iterator it;
199 bool res; 199 bool res;
200 200 KABC::Addressee::List changedAddressees;
201 QStringList addedUID;
201 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 202 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
202 //KABC::Addressee addressee = (*it); 203 //KABC::Addressee addressee = (*it);
204 // qDebug("AAAfor uid %s ", (*it).originalExternalUID().latin1() );
203 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 205 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
204 QUuid uid( (*it).originalExternalUID() ); 206 QUuid uid( (*it).originalExternalUID() );
205 bool ok; 207 bool ok;
206 PimContact c = mAccess->contactForId( uid, &ok ); 208 PimContact c = mAccess->contactForId( uid, &ok );
209 qDebug("ResourceQtopia::save:Found %d for uid %s ", ok,(*it).originalExternalUID().latin1() );
207 res = mConverter->addresseeToQtopia( *it, c ); 210 res = mConverter->addresseeToQtopia( *it, c );
208 if (res == true) { 211 if (res == true) {
209 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { 212 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
210 mAccess->addContact(c); 213 qDebug("skipping adding of contact ");
211 KABC::Addressee addressee; 214 continue;
212 mConverter->qtopiaToAddressee( c, addressee ); 215 PimContact e;
213 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 216 AddressBookAccess Access2;
214 addressBook()->insertAddressee( addressee ); 217 Access2.addContact(e);
218 const PimContact* contact;
219 bool res;
220 QString uid2, Ouid;
221 AddressBookIterator itt(Access2);
222 for (contact=itt.toFirst(); itt.current(); ++itt)
223 {
224 contact = itt.current();
225 QString exuid = contact->uid().toString();
226 Ouid =exuid;
227 int ente = exuid.find( "-0000");
228 if ( exuid.left(1) == "{" )
229 exuid = exuid.mid(1);
230 if ( ente > -1 )
231 exuid = exuid.left( ente-1 );
232 uid2 = exuid;
233 qDebug("trying find uid ");
234 if ( !addressBook()->containsExternalUid( uid2 ) ) {
235 qDebug("ab not contains ");
236 if ( !addedUID.contains( uid2 )) {
237 qDebug("list not contains ");
238 break;
239 }
240 }
241
242 }
243 if ( !itt.current()) {
244 qDebug("ERROR uid ");
245 continue;
246 }
247 else
248 qDebug("ADD uid detected ");
249
250
251 QUuid uid3( Ouid);
252 PimContact d = Access2.contactForId( uid3, &ok );
253 if ( ! ok ) {
254 qDebug("ADD: Error getting new uid ");
255 } else {
256 qDebug("NEW UID found ");
257 PimContact g = mAccess->contactForId( c.uid(), &ok );
258 KABC::Addressee addressee;
259 mConverter->qtopiaToAddressee( g, addressee );
260 addressee.setUid((*it).uid() );
261 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
262 changedAddressees.append( addressee );
263 addedUID.append( uid2 );
264 }
265
215 266
216 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 267 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
268 qDebug("Remove contact ");
217 if ( ok ) 269 if ( ok )
218 mAccess->removeContact(c); 270 mAccess->removeContact(c);
219 else 271 else
220 qDebug("Error revoe contact from qtopia "); 272 qDebug("Error remove contact from qtopia ");
221 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 273 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
222 if ( ok ) { 274 if ( ok ) {
275 qDebug("Update contact ");
223 mAccess->updateContact(c); 276 mAccess->updateContact(c);
277 PimContact g = mAccess->contactForId( c.uid(), &ok );
224 KABC::Addressee addressee; 278 KABC::Addressee addressee;
225 mConverter->qtopiaToAddressee( c, addressee ); 279 mConverter->qtopiaToAddressee( g, addressee );
280 addressee.setUid((*it).uid() );
226 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); 281 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
227 addressBook()->insertAddressee( addressee ); 282 changedAddressees.append( addressee );
228 } 283 }
229 else 284 else
230 qDebug("Error update contact from qtopia "); 285 qDebug("Error update contact from qtopia ");
231 286
232 } 287 }
233 288
234 } else { 289 } else {
235 qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1()); 290 qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1());
236 } 291 }
237 } 292 }
238 } 293 }
239 294
240 // mAccess->addressBookUpdated(); 295 KABC::Addressee::List::Iterator it2;
296 for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 )
297 addressBook()->insertAddressee((*it2));
298
299
241 300
242 mDirWatch.startScan(); 301 mDirWatch.startScan();
243 302
244 delete ticket; 303 delete ticket;
245 unlock( fileName() ); 304 unlock( fileName() );
246 305
247 return true; 306 return true;
248} 307}
249 308
250bool ResourceQtopia::lock( const QString &lockfileName ) 309bool ResourceQtopia::lock( const QString &lockfileName )
251{ 310{
252 qDebug("ResourceQtopia::lock: %s", fileName().latin1()); 311 qDebug("ResourceQtopia::lock: %s", fileName().latin1());
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 8f3ca9b..f8683e7 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2540,110 +2540,112 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
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 QDateTime localMod = local->revision();
2553 QDateTime remoteMod = remote->revision();
2552 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2554 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2553 bool remCh, locCh; 2555 bool remCh, locCh;
2554 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2556 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2555 2557
2556 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2558 qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2557 locCh = ( local->revision() > mLastAddressbookSync ); 2559 locCh = ( localMod > mLastAddressbookSync );
2558 if ( !remCh && ! locCh ) { 2560 if ( !remCh && ! locCh ) {
2559 //qDebug("both not changed "); 2561 qDebug("both not changed ");
2560 lastSync = local->revision().addDays(1); 2562 lastSync = localMod.addDays(1);
2561 if ( mode <= SYNC_PREF_ASK ) 2563 if ( mode <= SYNC_PREF_ASK )
2562 return 0; 2564 return 0;
2563 } else { 2565 } else {
2564 if ( locCh ) { 2566 if ( locCh ) {
2565 //qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); 2567 qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2566 lastSync = local->revision().addDays( -1 ); 2568 lastSync = localMod.addDays( -1 );
2567 if ( !remCh ) 2569 if ( !remCh )
2568 remote->setRevision( lastSync.addDays( -1 ) ); 2570 remoteMod =( lastSync.addDays( -1 ) );
2569 } else { 2571 } else {
2570 //qDebug(" not loc changed "); 2572 //qDebug(" not loc changed ");
2571 lastSync = local->revision().addDays( 1 ); 2573 lastSync = localMod.addDays( 1 );
2572 if ( remCh ) 2574 if ( remCh )
2573 remote->setRevision( lastSync.addDays( 1 ) ); 2575 remoteMod =( lastSync.addDays( 1 ) );
2574 2576
2575 } 2577 }
2576 } 2578 }
2577 full = true; 2579 full = true;
2578 if ( mode < SYNC_PREF_ASK ) 2580 if ( mode < SYNC_PREF_ASK )
2579 mode = SYNC_PREF_ASK; 2581 mode = SYNC_PREF_ASK;
2580 } else { 2582 } else {
2581 if ( local->revision() == remote->revision() ) 2583 if ( localMod == remoteMod )
2582 return 0; 2584 return 0;
2583 2585
2584 } 2586 }
2585 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2587 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2586 2588
2587 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 2589 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2588 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2590 //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 2591 //full = true; //debug only
2590 if ( full ) { 2592 if ( full ) {
2591 bool equ = ( (*local) == (*remote) ); 2593 bool equ = ( (*local) == (*remote) );
2592 if ( equ ) { 2594 if ( equ ) {
2593 //qDebug("equal "); 2595 //qDebug("equal ");
2594 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2596 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2595 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2597 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2596 } 2598 }
2597 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2599 if ( mode < SYNC_PREF_FORCE_LOCAL )
2598 return 0; 2600 return 0;
2599 2601
2600 }//else //debug only 2602 }//else //debug only
2601 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2603 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2602 } 2604 }
2603 int result; 2605 int result;
2604 bool localIsNew; 2606 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() ); 2607 //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 2608
2607 if ( full && mode < SYNC_PREF_NEWEST ) 2609 if ( full && mode < SYNC_PREF_NEWEST )
2608 mode = SYNC_PREF_ASK; 2610 mode = SYNC_PREF_ASK;
2609 2611
2610 switch( mode ) { 2612 switch( mode ) {
2611 case SYNC_PREF_LOCAL: 2613 case SYNC_PREF_LOCAL:
2612 if ( lastSync > remote->revision() ) 2614 if ( lastSync > remoteMod )
2613 return 1; 2615 return 1;
2614 if ( lastSync > local->revision() ) 2616 if ( lastSync > localMod )
2615 return 2; 2617 return 2;
2616 return 1; 2618 return 1;
2617 break; 2619 break;
2618 case SYNC_PREF_REMOTE: 2620 case SYNC_PREF_REMOTE:
2619 if ( lastSync > remote->revision() ) 2621 if ( lastSync > remoteMod )
2620 return 1; 2622 return 1;
2621 if ( lastSync > local->revision() ) 2623 if ( lastSync > localMod )
2622 return 2; 2624 return 2;
2623 return 2; 2625 return 2;
2624 break; 2626 break;
2625 case SYNC_PREF_NEWEST: 2627 case SYNC_PREF_NEWEST:
2626 if ( local->revision() > remote->revision() ) 2628 if ( localMod > remoteMod )
2627 return 1; 2629 return 1;
2628 else 2630 else
2629 return 2; 2631 return 2;
2630 break; 2632 break;
2631 case SYNC_PREF_ASK: 2633 case SYNC_PREF_ASK:
2632 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); 2634 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2633 if ( lastSync > remote->revision() ) 2635 if ( lastSync > remoteMod )
2634 return 1; 2636 return 1;
2635 if ( lastSync > local->revision() ) 2637 if ( lastSync > localMod )
2636 return 2; 2638 return 2;
2637 localIsNew = local->revision() >= remote->revision(); 2639 localIsNew = localMod >= remoteMod;
2638 //qDebug("conflict! ************************************** "); 2640 //qDebug("conflict! ************************************** ");
2639 { 2641 {
2640 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2642 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2641 result = acd.executeD(localIsNew); 2643 result = acd.executeD(localIsNew);
2642 return result; 2644 return result;
2643 } 2645 }
2644 break; 2646 break;
2645 case SYNC_PREF_FORCE_LOCAL: 2647 case SYNC_PREF_FORCE_LOCAL:
2646 return 1; 2648 return 1;
2647 break; 2649 break;
2648 case SYNC_PREF_FORCE_REMOTE: 2650 case SYNC_PREF_FORCE_REMOTE:
2649 return 2; 2651 return 2;
@@ -2777,24 +2779,28 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2777 inR = inL; 2779 inR = inL;
2778 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2780 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2779 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2781 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2780 inR.setOriginalExternalUID( OidS ); 2782 inR.setOriginalExternalUID( OidS );
2781 inR.setExternalUID( idS ); 2783 inR.setExternalUID( idS );
2782 } else { 2784 } else {
2783 inR.setIDStr( idS ); 2785 inR.setIDStr( idS );
2784 } 2786 }
2785 inR.setResource( 0 ); 2787 inR.setResource( 0 );
2786 remote->insertAddressee( inR , false); 2788 remote->insertAddressee( inR , false);
2787 ++changedRemote; 2789 ++changedRemote;
2788 } else { // take == 2 take remote 2790 } else { // take == 2 take remote
2791 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2792 if ( inR.revision().date().year() < 2004 )
2793 inR.setRevision( modifiedCalendar );
2794 }
2789 idS = inL.IDStr(); 2795 idS = inL.IDStr();
2790 local->removeAddressee( inL ); 2796 local->removeAddressee( inL );
2791 inL = inR; 2797 inL = inR;
2792 inL.setIDStr( idS ); 2798 inL.setIDStr( idS );
2793 inL.setResource( 0 ); 2799 inL.setResource( 0 );
2794 local->insertAddressee( inL , false ); 2800 local->insertAddressee( inL , false );
2795 ++changedLocal; 2801 ++changedLocal;
2796 } 2802 }
2797 } 2803 }
2798 } else { // no conflict 2804 } else { // no conflict
2799 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2805 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2800 QString des = addresseeLSync.note(); 2806 QString des = addresseeLSync.note();
@@ -2916,39 +2922,39 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2916 2922
2917bool KABCore::syncAB(QString filename, int mode) 2923bool KABCore::syncAB(QString filename, int mode)
2918{ 2924{
2919 2925
2920 //pending prepare addresseeview for output 2926 //pending prepare addresseeview for output
2921 //pending detect, if remote file has REV field. if not switch to external sync 2927 //pending detect, if remote file has REV field. if not switch to external sync
2922 mGlobalSyncMode = SYNC_MODE_NORMAL; 2928 mGlobalSyncMode = SYNC_MODE_NORMAL;
2923 AddressBook abLocal(filename,"syncContact"); 2929 AddressBook abLocal(filename,"syncContact");
2924 bool syncOK = false; 2930 bool syncOK = false;
2925 if ( abLocal.load() ) { 2931 if ( abLocal.load() ) {
2926 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2932 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2927 bool external = false; 2933 bool external = false;
2928 2934 bool isXML = false;
2929 if ( filename.right(4) == ".xml") { 2935 if ( filename.right(4) == ".xml") {
2930 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2936 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2937 isXML = true;
2931 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2938 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2932 } else { 2939 } else {
2933 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2940 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2934 if ( ! lse.isEmpty() ) { 2941 if ( ! lse.isEmpty() ) {
2935 if ( lse.familyName().left(4) == "!E: " ) 2942 if ( lse.familyName().left(4) == "!E: " )
2936 external = true; 2943 external = true;
2937 } else { 2944 } else {
2938 bool found = false; 2945 bool found = false;
2939 QDateTime dt( QDate( 2004,1,1));
2940 AddressBook::Iterator it; 2946 AddressBook::Iterator it;
2941 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2947 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2942 if ( (*it).revision() != dt ) { 2948 if ( (*it).revision().date().year() > 2003 ) {
2943 found = true; 2949 found = true;
2944 break; 2950 break;
2945 } 2951 }
2946 } 2952 }
2947 external = ! found; 2953 external = ! found;
2948 } 2954 }
2949 2955
2950 if ( external ) { 2956 if ( external ) {
2951 qDebug("Setting vcf mode to external "); 2957 qDebug("Setting vcf mode to external ");
2952 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2958 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2953 AddressBook::Iterator it; 2959 AddressBook::Iterator it;
2954 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2960 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
@@ -2957,29 +2963,29 @@ bool KABCore::syncAB(QString filename, int mode)
2957 } 2963 }
2958 } 2964 }
2959 } 2965 }
2960 //AddressBook::Iterator it; 2966 //AddressBook::Iterator it;
2961 //QStringList vcards; 2967 //QStringList vcards;
2962 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2968 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2963 // qDebug("Name %s ", (*it).familyName().latin1()); 2969 // qDebug("Name %s ", (*it).familyName().latin1());
2964 //} 2970 //}
2965 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2971 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2966 if ( syncOK ) { 2972 if ( syncOK ) {
2967 if ( KABPrefs::instance()->mWriteBackFile ) 2973 if ( KABPrefs::instance()->mWriteBackFile )
2968 { 2974 {
2969 if ( external && filename.right(4) != ".xml") 2975 if ( external )
2970 abLocal.removeDeletedAddressees(); 2976 abLocal.removeSyncAddressees( !isXML);
2971 qDebug("Saving remote AB "); 2977 qDebug("Saving remote AB ");
2972 abLocal.saveAB(); 2978 abLocal.saveAB();
2973 if ( external && filename.right(4) == ".xml") { 2979 if ( isXML ) {
2974 // afterwrite processing 2980 // afterwrite processing
2975 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2981 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2976 } 2982 }
2977 } 2983 }
2978 } 2984 }
2979 setModified(); 2985 setModified();
2980 2986
2981 } 2987 }
2982 if ( syncOK ) 2988 if ( syncOK )
2983 mViewManager->refreshView(); 2989 mViewManager->refreshView();
2984 return syncOK; 2990 return syncOK;
2985#if 0 2991#if 0
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 0c75632..8e83723 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -717,119 +717,121 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
717 717
718 //void setZaurusId(int id); 718 //void setZaurusId(int id);
719 // int zaurusId() const; 719 // int zaurusId() const;
720 // void setZaurusUid(int id); 720 // void setZaurusUid(int id);
721 // int zaurusUid() const; 721 // int zaurusUid() const;
722 // void setZaurusStat(int id); 722 // void setZaurusStat(int id);
723 // int zaurusStat() const; 723 // int zaurusStat() const;
724 // 0 equal 724 // 0 equal
725 // 1 take local 725 // 1 take local
726 // 2 take remote 726 // 2 take remote
727 // 3 cancel 727 // 3 cancel
728 QDateTime lastSync = mLastCalendarSync; 728 QDateTime lastSync = mLastCalendarSync;
729 QDateTime localMod = local->lastModified();
730 QDateTime remoteMod = remote->lastModified();
729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 731 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
730 bool remCh, locCh; 732 bool remCh, locCh;
731 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 733 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
732 //if ( remCh ) 734 //if ( remCh )
733 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 735 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
734 locCh = ( local->lastModified() > mLastCalendarSync ); 736 locCh = ( localMod > mLastCalendarSync );
735 if ( !remCh && ! locCh ) { 737 if ( !remCh && ! locCh ) {
736 //qDebug("both not changed "); 738 //qDebug("both not changed ");
737 lastSync = local->lastModified().addDays(1); 739 lastSync = localMod.addDays(1);
738 if ( mode <= SYNC_PREF_ASK ) 740 if ( mode <= SYNC_PREF_ASK )
739 return 0; 741 return 0;
740 } else { 742 } else {
741 if ( locCh ) { 743 if ( locCh ) {
742 //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); 744 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
743 lastSync = local->lastModified().addDays( -1 ); 745 lastSync = localMod.addDays( -1 );
744 if ( !remCh ) 746 if ( !remCh )
745 remote->setLastModified( lastSync.addDays( -1 ) ); 747 remoteMod = ( lastSync.addDays( -1 ) );
746 } else { 748 } else {
747 //qDebug(" not loc changed "); 749 //qDebug(" not loc changed ");
748 lastSync = local->lastModified().addDays( 1 ); 750 lastSync = localMod.addDays( 1 );
749 if ( remCh ) 751 if ( remCh )
750 remote->setLastModified( lastSync.addDays( 1 ) ); 752 remoteMod =( lastSync.addDays( 1 ) );
751 753
752 } 754 }
753 } 755 }
754 full = true; 756 full = true;
755 if ( mode < SYNC_PREF_ASK ) 757 if ( mode < SYNC_PREF_ASK )
756 mode = SYNC_PREF_ASK; 758 mode = SYNC_PREF_ASK;
757 } else { 759 } else {
758 if ( local->lastModified() == remote->lastModified() ) 760 if ( localMod == remoteMod )
759 if ( local->revision() == remote->revision() ) 761 if ( local->revision() == remote->revision() )
760 return 0; 762 return 0;
761 763
762 } 764 }
763 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 765 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
764 766
765 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 767 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
766 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 768 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
767 //full = true; //debug only 769 //full = true; //debug only
768 if ( full ) { 770 if ( full ) {
769 bool equ = false; 771 bool equ = false;
770 if ( local->type() == "Event" ) { 772 if ( local->type() == "Event" ) {
771 equ = (*((Event*) local) == *((Event*) remote)); 773 equ = (*((Event*) local) == *((Event*) remote));
772 } 774 }
773 else if ( local->type() =="Todo" ) 775 else if ( local->type() =="Todo" )
774 equ = (*((Todo*) local) == (*(Todo*) remote)); 776 equ = (*((Todo*) local) == (*(Todo*) remote));
775 else if ( local->type() =="Journal" ) 777 else if ( local->type() =="Journal" )
776 equ = (*((Journal*) local) == *((Journal*) remote)); 778 equ = (*((Journal*) local) == *((Journal*) remote));
777 if ( equ ) { 779 if ( equ ) {
778 //qDebug("equal "); 780 //qDebug("equal ");
779 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 781 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
780 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 782 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
781 } 783 }
782 if ( mode < SYNC_PREF_FORCE_LOCAL ) 784 if ( mode < SYNC_PREF_FORCE_LOCAL )
783 return 0; 785 return 0;
784 786
785 }//else //debug only 787 }//else //debug only
786 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 788 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
787 } 789 }
788 int result; 790 int result;
789 bool localIsNew; 791 bool localIsNew;
790 //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() ); 792 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
791 793
792 if ( full && mode < SYNC_PREF_NEWEST ) 794 if ( full && mode < SYNC_PREF_NEWEST )
793 mode = SYNC_PREF_ASK; 795 mode = SYNC_PREF_ASK;
794 796
795 switch( mode ) { 797 switch( mode ) {
796 case SYNC_PREF_LOCAL: 798 case SYNC_PREF_LOCAL:
797 if ( lastSync > remote->lastModified() ) 799 if ( lastSync > remoteMod )
798 return 1; 800 return 1;
799 if ( lastSync > local->lastModified() ) 801 if ( lastSync > localMod )
800 return 2; 802 return 2;
801 return 1; 803 return 1;
802 break; 804 break;
803 case SYNC_PREF_REMOTE: 805 case SYNC_PREF_REMOTE:
804 if ( lastSync > remote->lastModified() ) 806 if ( lastSync > remoteMod )
805 return 1; 807 return 1;
806 if ( lastSync > local->lastModified() ) 808 if ( lastSync > localMod )
807 return 2; 809 return 2;
808 return 2; 810 return 2;
809 break; 811 break;
810 case SYNC_PREF_NEWEST: 812 case SYNC_PREF_NEWEST:
811 if ( local->lastModified() > remote->lastModified() ) 813 if ( localMod > remoteMod )
812 return 1; 814 return 1;
813 else 815 else
814 return 2; 816 return 2;
815 break; 817 break;
816 case SYNC_PREF_ASK: 818 case SYNC_PREF_ASK:
817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 819 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
818 if ( lastSync > remote->lastModified() ) 820 if ( lastSync > remoteMod )
819 return 1; 821 return 1;
820 if ( lastSync > local->lastModified() ) 822 if ( lastSync > localMod )
821 return 2; 823 return 2;
822 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 824 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
823 localIsNew = local->lastModified() >= remote->lastModified(); 825 localIsNew = localMod >= remoteMod;
824 if ( localIsNew ) 826 if ( localIsNew )
825 getEventViewerDialog()->setColorMode( 1 ); 827 getEventViewerDialog()->setColorMode( 1 );
826 else 828 else
827 getEventViewerDialog()->setColorMode( 2 ); 829 getEventViewerDialog()->setColorMode( 2 );
828 getEventViewerDialog()->setIncidence(local); 830 getEventViewerDialog()->setIncidence(local);
829 if ( localIsNew ) 831 if ( localIsNew )
830 getEventViewerDialog()->setColorMode( 2 ); 832 getEventViewerDialog()->setColorMode( 2 );
831 else 833 else
832 getEventViewerDialog()->setColorMode( 1 ); 834 getEventViewerDialog()->setColorMode( 1 );
833 getEventViewerDialog()->addIncidence(remote); 835 getEventViewerDialog()->addIncidence(remote);
834 getEventViewerDialog()->setColorMode( 0 ); 836 getEventViewerDialog()->setColorMode( 0 );
835 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 837 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );