author | zautrix <zautrix> | 2004-09-19 09:11:04 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-19 09:11:04 (UTC) |
commit | 953277a85e6ec5630ab0d64b4d68815e4e4f9906 (patch) (side-by-side diff) | |
tree | 0a6acbc3ecd65784c1e875159b720849bc27dc48 | |
parent | 787181d34f0d195ad72c9cf6aedbc317b6dd713e (diff) | |
download | kdepimpi-953277a85e6ec5630ab0d64b4d68815e4e4f9906.zip kdepimpi-953277a85e6ec5630ab0d64b4d68815e4e4f9906.tar.gz kdepimpi-953277a85e6ec5630ab0d64b4d68815e4e4f9906.tar.bz2 |
More AB sync
-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 @@ -247,86 +247,85 @@ void Addressee::computeCsum(const QString &dev) uint iii; for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); t = mData->emails; t.sort(); for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); t = mData->categories; t.sort(); for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); t = mData->custom; t.sort(); for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); KABC::Address::List::Iterator addressIter; for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); ++addressIter ) { t = (*addressIter).asList(); t.sort(); for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); } uint cs = getCsum4List(l); - qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); + // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); setCsum( dev, QString::number (cs )); } void Addressee::removeID(const QString &prof) { detach(); mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); } void Addressee::setID( const QString & prof , const QString & id ) { detach(); - qDebug("setID1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); - qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); + //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); } void Addressee::setTempSyncStat( int id ) { if ( mData->mTempSyncStat == id ) return; detach(); mData->mTempSyncStat = id; } int Addressee::tempSyncStat() const { return mData->mTempSyncStat; } QString Addressee::getID( const QString & prof) { return KIdManager::getId ( mData->mExternalId, prof ); } void Addressee::setCsum( const QString & prof , const QString & id ) { detach(); - qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); + //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); - qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); + //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); } QString Addressee::getCsum( const QString & prof) { return KIdManager::getCsum ( mData->mExternalId, prof ); } void Addressee::setIDStr( const QString & s ) { detach(); mData->mExternalId = s; } QString Addressee::IDStr() const { return mData->mExternalId; } void Addressee::setUid( const QString &id ) { if ( id == mData->uid ) return; detach(); 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 @@ -2531,59 +2531,59 @@ KABC::Addressee KABCore::getLastSyncAddressee() lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); lse.setRevision( mLastAddressbookSync ); lse.setCategories( i18n("SyncEvent") ); mAddressBook->insertAddressee( lse ); } return lse; } int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) { //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; 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() ); + + //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); locCh = ( local->revision() > mLastAddressbookSync ); if ( !remCh && ! locCh ) { - qDebug("both not changed "); + //qDebug("both not changed "); lastSync = local->revision().addDays(1); if ( mode <= SYNC_PREF_ASK ) return 0; } else { if ( locCh ) { - qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); + //qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); lastSync = local->revision().addDays( -1 ); if ( !remCh ) remote->setRevision( lastSync.addDays( -1 ) ); } else { //qDebug(" not loc changed "); lastSync = local->revision().addDays( 1 ); if ( remCh ) remote->setRevision( lastSync.addDays( 1 ) ); } } full = true; if ( mode < SYNC_PREF_ASK ) mode = SYNC_PREF_ASK; } else { 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() ); //full = true; //debug only @@ -2705,49 +2705,49 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo if ( ! fullDateRange ) { if ( addresseeLSync.revision() != addresseeRSync.revision() ) { // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); fullDateRange = true; qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); } } // fullDateRange = true; // debug only! if ( fullDateRange ) mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); else mLastAddressbookSync = addresseeLSync.revision(); // for resyncing if own file has changed // PENDING fixme later when implemented #if 0 if ( mCurrentSyncDevice == "deleteaftersync" ) { mLastAddressbookSync = loadedFileVersion; qDebug("setting mLastAddressbookSync "); } #endif //qDebug("*************************** "); - qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); + // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); QStringList er = remote->uidList(); Addressee inR ;//= er.first(); Addressee inL; QProgressBar bar( er.count(),0 ); bar.setCaption (i18n("Syncing - close to abort!") ); int w = 300; if ( QApplication::desktop()->width() < 320 ) w = 220; int h = bar.sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); int modulo = (er.count()/10)+1; int incCounter = 0; while ( incCounter < er.count()) { if ( ! bar.isVisible() ) return false; if ( incCounter % modulo == 0 ) bar.setProgress( incCounter ); uid = er[ incCounter ]; bool skipIncidence = false; if ( uid.left(19) == QString("last-syncAddressee-") ) @@ -2896,88 +2896,88 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo addresseeRSync.setNote( "" ) ; addresseeLSync.setNote( "" ); if ( mGlobalSyncMode == SYNC_MODE_NORMAL) remote->insertAddressee( addresseeRSync, false ); local->insertAddressee( addresseeLSync, false ); QString mes; 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 ); if ( KABPrefs::instance()->mShowSyncSummary ) { KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); } qDebug( mes ); return syncOK; } 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 mode %d",filename.latin1(), mode ); + qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); bool external = false; 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 ) { found = true; break; } } external = ! found; } if ( external ) { - qDebug("**********Setting vcf mode to external "); + qDebug("Setting vcf mode to external "); mGlobalSyncMode = SYNC_MODE_EXTERNAL; AddressBook::Iterator it; for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { (*it).setID( mCurrentSyncDevice, (*it).uid() ); (*it).computeCsum( mCurrentSyncDevice ); } } //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 ) abLocal.removeDeletedAddressees(); - qDebug("saving remote AB "); + qDebug("Saving remote AB "); abLocal.saveAB(); } } setModified(); } if ( syncOK ) mViewManager->refreshView(); return syncOK; #if 0 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { getEventViewerDialog()->setSyncMode( true ); syncOK = synchronizeCalendar( mCalendar, calendar, mode ); getEventViewerDialog()->setSyncMode( false ); if ( syncOK ) { if ( KOPrefs::instance()->mWriteBackFile ) { storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); storage->save(); } } setModified(); } |