author | zautrix <zautrix> | 2004-09-20 00:12:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-20 00:12:42 (UTC) |
commit | b01b669d88fa195261d29ecf73b1c69e608a5ebc (patch) (side-by-side diff) | |
tree | c0e79d45242a764b49470d07a9c95be156c121cc | |
parent | 3da2cfeab2edbe64a17251662e56668fe143f7a3 (diff) | |
download | kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.zip kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.gz kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.bz2 |
more AB sync
-rw-r--r-- | kabc/addressbook.cpp | 25 | ||||
-rw-r--r-- | kabc/addressbook.h | 3 | ||||
-rw-r--r-- | kabc/addressee.cpp | 6 | ||||
-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.cpp | 2 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 75 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 58 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 44 |
7 files changed, 150 insertions, 63 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 86dc7c2..17b9ba2 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -543,35 +543,34 @@ void AddressBook::removeAddressee( const Addressee &a ) } } } } } if ( found ) removeAddressee( it2 ); } -void AddressBook::removeDeletedAddressees() +void AddressBook::removeSyncAddressees( bool removeDeleted ) { - deleteRemovedAddressees(); Iterator it = begin(); Iterator it2 ; QDateTime dt ( QDate( 2004,1,1) ); while ( it != end() ) { (*it).setRevision( dt ); (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); (*it).setIDStr(""); - if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { + if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { it2 = it; //qDebug("removing %s ",(*it).uid().latin1() ); ++it; removeAddressee( it2 ); } else { //qDebug("skipping %s ",(*it).uid().latin1() ); ++it; } } deleteRemovedAddressees(); } @@ -608,60 +607,76 @@ void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) AddressBook::Iterator it; for ( it = begin(); it != end(); ++it ) { (*it).setID( csd, (*it).externalUID() ); (*it).computeCsum( csd ); } mergeAB( aBook ,csd ); } void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) { qDebug("AddressBook::postExternSync "); AddressBook::Iterator it; for ( it = begin(); it != end(); ++it ) { + qDebug("check uid %s ", (*it).uid().latin1() ); if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { Addressee ad = aBook->findByUid( ( (*it).uid() )); if ( ad.isEmpty() ) { - qDebug("ERROR ad empty "); + qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); } else { (*it).computeCsum( csd ); if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) ad.setID( csd, (*it).externalUID() ); ad.setCsum( csd, (*it).getCsum( csd ) ); aBook->insertAddressee( ad ); } } } } - +bool AddressBook::containsExternalUid( const QString& uid ) +{ + Iterator it; + for ( it = begin(); it != end(); ++it ) { + if ( uid == (*it).externalUID( ) ) + return true; + } + return false; +} Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) { Iterator it; for ( it = begin(); it != end(); ++it ) { if ( uid == (*it).getID( profile ) ) return (*it); } return Addressee(); } void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) { Iterator it; Addressee ad; for ( it = begin(); it != end(); ++it ) { ad = aBook->findByExternUid( (*it).externalUID(), profile ); if ( !ad.isEmpty() ) { (*it).mergeContact( ad ); } } +#if 0 + // test only + for ( it = begin(); it != end(); ++it ) { + + qDebug("uid %s ", (*it).uid().latin1()); + } +#endif } #if 0 Addressee::List AddressBook::getExternLastSyncAddressees() { Addressee::List results; Iterator it; for ( it = begin(); it != end(); ++it ) { if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { if ( (*it).familyName().left(4) == "!E: " ) 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 */ void error( const QString& ); /** Query all resources to clean up their lock files */ void cleanUp(); // sync stuff //Addressee::List getExternLastSyncAddressees(); void resetTempSyncStat(); QStringList uidList(); - void removeDeletedAddressees(); + void removeSyncAddressees( bool removeDeleted = false ); void mergeAB( AddressBook *aBook, const QString& profile ); Addressee findByExternUid( const QString& uid , const QString& profile ); + bool containsExternalUid( const QString& uid ); void preExternSync( AddressBook* aBook, const QString& csd ); void postExternSync( AddressBook* aBook, const QString& csd ); signals: /** Emitted, when the address book has changed on disk. */ void addressBookChanged( AddressBook * ); /** Emitted, when the address book has been locked for writing. */ 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 bool empty :1; bool changed :1; }; Addressee::Addressee() { mData = new AddresseeData; mData->empty = true; mData->changed = false; mData->resource = 0; mData->mExternalId = ":"; - mData->revision = QDateTime ( QDate( 2004,1,1)); + mData->revision = QDateTime ( QDate( 2003,1,1)); mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; } Addressee::~Addressee() { } Addressee::Addressee( const Addressee &a ) { mData = a.mData; } @@ -299,24 +299,26 @@ void Addressee::mergeContact( const Addressee& ad ) if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; // pending: // merging phonenumbers // merging addresses // merging emails; // merging categories; // merging custom; // merging keys + qDebug("merge contact %s ", ad.uid().latin1()); + setUid( ad.uid() ); } void Addressee::removeID(const QString &prof) { detach(); mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); } void Addressee::setID( const QString & prof , const QString & id ) { detach(); mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); @@ -370,36 +372,38 @@ void Addressee::setExternalUID( const QString &id ) mData->externalUID = id; } QString Addressee::externalUID() const { return mData->externalUID; } void Addressee::setOriginalExternalUID( const QString &id ) { if ( id == mData->originalExternalUID ) return; detach(); mData->empty = false; + qDebug("*******Set orig uid %s ", id.latin1()); mData->originalExternalUID = id; } QString Addressee::originalExternalUID() const { return mData->originalExternalUID; } void Addressee::setUid( const QString &id ) { if ( id == mData->uid ) return; detach(); + qDebug("****setuid %s ", id.latin1()); mData->empty = false; mData->uid = id; } QString Addressee::uid() const { if ( mData->uid.isEmpty() ) mData->uid = KApplication::randomString( 10 ); return mData->uid; } 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 addr.setPrefix( contact.nameTitle() ); addr.setSuffix( contact.suffix() ); addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); QString exuid = contact.uid().toString(); addr.setOriginalExternalUID( exuid ); int ente = exuid.find( "-0000"); if ( exuid.left(1) == "{" ) exuid = exuid.mid(1); if ( ente > -1 ) exuid = exuid.left( ente-1 ); addr.setExternalUID( exuid ); - //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() ); + qDebug("QtopiaConverter:set %s uid %s ",addr.originalExternalUID().latin1(),addr.externalUID().latin1() ); // email QStringList emails = contact.emailList(); for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); } if (!contact.defaultEmail().isEmpty()) addr.insertEmail(contact.defaultEmail(), true); // home 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() return true; } bool ResourceQtopia::save( Ticket *ticket ) { qDebug("ResourceQtopia::save: %s", fileName().latin1()); mDirWatch.stopScan(); KABC::AddressBook::Iterator it; bool res; - + KABC::Addressee::List changedAddressees; + QStringList addedUID; for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { //KABC::Addressee addressee = (*it); + // qDebug("AAAfor uid %s ", (*it).originalExternalUID().latin1() ); if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { QUuid uid( (*it).originalExternalUID() ); bool ok; PimContact c = mAccess->contactForId( uid, &ok ); + qDebug("ResourceQtopia::save:Found %d for uid %s ", ok,(*it).originalExternalUID().latin1() ); res = mConverter->addresseeToQtopia( *it, c ); if (res == true) { if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { - mAccess->addContact(c); + qDebug("skipping adding of contact "); + continue; + PimContact e; + AddressBookAccess Access2; + Access2.addContact(e); + const PimContact* contact; + bool res; + QString uid2, Ouid; + AddressBookIterator itt(Access2); + for (contact=itt.toFirst(); itt.current(); ++itt) + { + contact = itt.current(); + QString exuid = contact->uid().toString(); + Ouid =exuid; + int ente = exuid.find( "-0000"); + if ( exuid.left(1) == "{" ) + exuid = exuid.mid(1); + if ( ente > -1 ) + exuid = exuid.left( ente-1 ); + uid2 = exuid; + qDebug("trying find uid "); + if ( !addressBook()->containsExternalUid( uid2 ) ) { + qDebug("ab not contains "); + if ( !addedUID.contains( uid2 )) { + qDebug("list not contains "); + break; + } + } + + } + if ( !itt.current()) { + qDebug("ERROR uid "); + continue; + } + else + qDebug("ADD uid detected "); + + + QUuid uid3( Ouid); + PimContact d = Access2.contactForId( uid3, &ok ); + if ( ! ok ) { + qDebug("ADD: Error getting new uid "); + } else { + qDebug("NEW UID found "); + PimContact g = mAccess->contactForId( c.uid(), &ok ); KABC::Addressee addressee; - mConverter->qtopiaToAddressee( c, addressee ); + mConverter->qtopiaToAddressee( g, addressee ); + addressee.setUid((*it).uid() ); addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); - addressBook()->insertAddressee( addressee ); + changedAddressees.append( addressee ); + addedUID.append( uid2 ); + } + } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { + qDebug("Remove contact "); if ( ok ) mAccess->removeContact(c); else - qDebug("Error revoe contact from qtopia "); + qDebug("Error remove contact from qtopia "); } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { if ( ok ) { + qDebug("Update contact "); mAccess->updateContact(c); + PimContact g = mAccess->contactForId( c.uid(), &ok ); KABC::Addressee addressee; - mConverter->qtopiaToAddressee( c, addressee ); + mConverter->qtopiaToAddressee( g, addressee ); + addressee.setUid((*it).uid() ); addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); - addressBook()->insertAddressee( addressee ); + changedAddressees.append( addressee ); } else qDebug("Error update contact from qtopia "); } } else { qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1()); } } } - // mAccess->addressBookUpdated(); + KABC::Addressee::List::Iterator it2; + for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) + addressBook()->insertAddressee((*it2)); + + mDirWatch.startScan(); delete ticket; unlock( fileName() ); return true; } bool ResourceQtopia::lock( const QString &lockfileName ) { 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 //void setZaurusId(int id); // int zaurusId() const; // void setZaurusUid(int id); // int zaurusUid() const; // void setZaurusStat(int id); // int zaurusStat() const; // 0 equal // 1 take local // 2 take remote // 3 cancel QDateTime lastSync = mLastAddressbookSync; + QDateTime localMod = local->revision(); + QDateTime remoteMod = remote->revision(); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { bool remCh, locCh; remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); - //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); - locCh = ( local->revision() > mLastAddressbookSync ); + qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); + locCh = ( localMod > mLastAddressbookSync ); if ( !remCh && ! locCh ) { - //qDebug("both not changed "); - lastSync = local->revision().addDays(1); + qDebug("both not changed "); + lastSync = localMod.addDays(1); if ( mode <= SYNC_PREF_ASK ) return 0; } else { if ( locCh ) { - //qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); - lastSync = local->revision().addDays( -1 ); + qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); + lastSync = localMod.addDays( -1 ); if ( !remCh ) - remote->setRevision( lastSync.addDays( -1 ) ); + remoteMod =( lastSync.addDays( -1 ) ); } else { //qDebug(" not loc changed "); - lastSync = local->revision().addDays( 1 ); + lastSync = localMod.addDays( 1 ); if ( remCh ) - remote->setRevision( lastSync.addDays( 1 ) ); + remoteMod =( lastSync.addDays( 1 ) ); } } full = true; if ( mode < SYNC_PREF_ASK ) mode = SYNC_PREF_ASK; } else { - if ( local->revision() == remote->revision() ) + if ( localMod == remoteMod ) return 0; } // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); - //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); + //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); //full = true; //debug only if ( full ) { bool equ = ( (*local) == (*remote) ); if ( equ ) { //qDebug("equal "); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); } if ( mode < SYNC_PREF_FORCE_LOCAL ) return 0; }//else //debug only //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); } int result; bool localIsNew; //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() ); if ( full && mode < SYNC_PREF_NEWEST ) mode = SYNC_PREF_ASK; switch( mode ) { case SYNC_PREF_LOCAL: - if ( lastSync > remote->revision() ) + if ( lastSync > remoteMod ) return 1; - if ( lastSync > local->revision() ) + if ( lastSync > localMod ) return 2; return 1; break; case SYNC_PREF_REMOTE: - if ( lastSync > remote->revision() ) + if ( lastSync > remoteMod ) return 1; - if ( lastSync > local->revision() ) + if ( lastSync > localMod ) return 2; return 2; break; case SYNC_PREF_NEWEST: - if ( local->revision() > remote->revision() ) + if ( localMod > remoteMod ) return 1; else return 2; break; case SYNC_PREF_ASK: - //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); - if ( lastSync > remote->revision() ) + //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); + if ( lastSync > remoteMod ) return 1; - if ( lastSync > local->revision() ) + if ( lastSync > localMod ) return 2; - localIsNew = local->revision() >= remote->revision(); + localIsNew = localMod >= remoteMod; //qDebug("conflict! ************************************** "); { KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); result = acd.executeD(localIsNew); return result; } break; case SYNC_PREF_FORCE_LOCAL: return 1; break; case SYNC_PREF_FORCE_REMOTE: return 2; @@ -2777,24 +2779,28 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo inR = inL; inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { inR.setOriginalExternalUID( OidS ); inR.setExternalUID( idS ); } else { inR.setIDStr( idS ); } inR.setResource( 0 ); remote->insertAddressee( inR , false); ++changedRemote; } else { // take == 2 take remote + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + if ( inR.revision().date().year() < 2004 ) + inR.setRevision( modifiedCalendar ); + } idS = inL.IDStr(); local->removeAddressee( inL ); inL = inR; inL.setIDStr( idS ); inL.setResource( 0 ); local->insertAddressee( inL , false ); ++changedLocal; } } } else { // no conflict if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { QString des = addresseeLSync.note(); @@ -2916,39 +2922,39 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo bool KABCore::syncAB(QString filename, int mode) { //pending prepare addresseeview for output //pending detect, if remote file has REV field. if not switch to external sync mGlobalSyncMode = SYNC_MODE_NORMAL; AddressBook abLocal(filename,"syncContact"); bool syncOK = false; if ( abLocal.load() ) { qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); bool external = false; - + bool isXML = false; if ( filename.right(4) == ".xml") { mGlobalSyncMode = SYNC_MODE_EXTERNAL; + isXML = true; abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); } else { Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); if ( ! lse.isEmpty() ) { if ( lse.familyName().left(4) == "!E: " ) external = true; } else { bool found = false; - QDateTime dt( QDate( 2004,1,1)); AddressBook::Iterator it; for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { - if ( (*it).revision() != dt ) { + if ( (*it).revision().date().year() > 2003 ) { found = true; break; } } external = ! found; } if ( external ) { qDebug("Setting vcf mode to external "); mGlobalSyncMode = SYNC_MODE_EXTERNAL; AddressBook::Iterator it; for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { @@ -2957,29 +2963,29 @@ bool KABCore::syncAB(QString filename, int mode) } } } //AddressBook::Iterator it; //QStringList vcards; //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { // qDebug("Name %s ", (*it).familyName().latin1()); //} syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); if ( syncOK ) { if ( KABPrefs::instance()->mWriteBackFile ) { - if ( external && filename.right(4) != ".xml") - abLocal.removeDeletedAddressees(); + if ( external ) + abLocal.removeSyncAddressees( !isXML); qDebug("Saving remote AB "); abLocal.saveAB(); - if ( external && filename.right(4) == ".xml") { + if ( isXML ) { // afterwrite processing abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); } } } setModified(); } if ( syncOK ) mViewManager->refreshView(); return syncOK; #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 //void setZaurusId(int id); // int zaurusId() const; // void setZaurusUid(int id); // int zaurusUid() const; // void setZaurusStat(int id); // int zaurusStat() const; // 0 equal // 1 take local // 2 take remote // 3 cancel QDateTime lastSync = mLastCalendarSync; + QDateTime localMod = local->lastModified(); + QDateTime remoteMod = remote->lastModified(); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { bool remCh, locCh; remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); //if ( remCh ) //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); - locCh = ( local->lastModified() > mLastCalendarSync ); + locCh = ( localMod > mLastCalendarSync ); if ( !remCh && ! locCh ) { //qDebug("both not changed "); - lastSync = local->lastModified().addDays(1); + lastSync = localMod.addDays(1); if ( mode <= SYNC_PREF_ASK ) return 0; } else { if ( locCh ) { - //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); - lastSync = local->lastModified().addDays( -1 ); + //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); + lastSync = localMod.addDays( -1 ); if ( !remCh ) - remote->setLastModified( lastSync.addDays( -1 ) ); + remoteMod = ( lastSync.addDays( -1 ) ); } else { //qDebug(" not loc changed "); - lastSync = local->lastModified().addDays( 1 ); + lastSync = localMod.addDays( 1 ); if ( remCh ) - remote->setLastModified( lastSync.addDays( 1 ) ); + remoteMod =( lastSync.addDays( 1 ) ); } } full = true; if ( mode < SYNC_PREF_ASK ) mode = SYNC_PREF_ASK; } else { - if ( local->lastModified() == remote->lastModified() ) + if ( localMod == remoteMod ) if ( local->revision() == remote->revision() ) return 0; } // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); - //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); - //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); + //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); + //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); //full = true; //debug only if ( full ) { bool equ = false; if ( local->type() == "Event" ) { equ = (*((Event*) local) == *((Event*) remote)); } else if ( local->type() =="Todo" ) equ = (*((Todo*) local) == (*(Todo*) remote)); else if ( local->type() =="Journal" ) equ = (*((Journal*) local) == *((Journal*) remote)); if ( equ ) { //qDebug("equal "); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); } if ( mode < SYNC_PREF_FORCE_LOCAL ) return 0; }//else //debug only //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); } int result; bool localIsNew; - //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() ); + //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() ); if ( full && mode < SYNC_PREF_NEWEST ) mode = SYNC_PREF_ASK; switch( mode ) { case SYNC_PREF_LOCAL: - if ( lastSync > remote->lastModified() ) + if ( lastSync > remoteMod ) return 1; - if ( lastSync > local->lastModified() ) + if ( lastSync > localMod ) return 2; return 1; break; case SYNC_PREF_REMOTE: - if ( lastSync > remote->lastModified() ) + if ( lastSync > remoteMod ) return 1; - if ( lastSync > local->lastModified() ) + if ( lastSync > localMod ) return 2; return 2; break; case SYNC_PREF_NEWEST: - if ( local->lastModified() > remote->lastModified() ) + if ( localMod > remoteMod ) return 1; else return 2; break; case SYNC_PREF_ASK: - //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); - if ( lastSync > remote->lastModified() ) + //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); + if ( lastSync > remoteMod ) return 1; - if ( lastSync > local->lastModified() ) + if ( lastSync > localMod ) return 2; - //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); - localIsNew = local->lastModified() >= remote->lastModified(); + //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); + localIsNew = localMod >= remoteMod; if ( localIsNew ) getEventViewerDialog()->setColorMode( 1 ); else getEventViewerDialog()->setColorMode( 2 ); getEventViewerDialog()->setIncidence(local); if ( localIsNew ) getEventViewerDialog()->setColorMode( 2 ); else getEventViewerDialog()->setColorMode( 1 ); getEventViewerDialog()->addIncidence(remote); getEventViewerDialog()->setColorMode( 0 ); //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |