author | zautrix <zautrix> | 2004-10-29 14:01:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-29 14:01:58 (UTC) |
commit | 102cc4a711e303372efea9797623ee2d9f27f63c (patch) (side-by-side diff) | |
tree | 32e56b436e52b5b1bab701839a24fc175288d57c | |
parent | 8c55eb6afe84ef69bb284d384a0c9f1ef1484ad8 (diff) | |
download | kdepimpi-102cc4a711e303372efea9797623ee2d9f27f63c.zip kdepimpi-102cc4a711e303372efea9797623ee2d9f27f63c.tar.gz kdepimpi-102cc4a711e303372efea9797623ee2d9f27f63c.tar.bz2 |
removed debug output
-rw-r--r-- | kabc/addressbook.cpp | 11 | ||||
-rw-r--r-- | kabc/addressbook.h | 1 | ||||
-rw-r--r-- | kabc/addressee.cpp | 2 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 215 | ||||
-rw-r--r-- | kabc/tmpaddressbook.cpp | 9 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 31 |
6 files changed, 78 insertions, 191 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 4c4ae09..8487ff3 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -1155,16 +1155,27 @@ bool AddressBook::addResource( Resource *resource ) return false; } resource->setAddressBook( this ); d->mManager->add( resource ); return true; } +void AddressBook::removeResources() +{ + //remove all possible resources. This should cleanup the configfile. + QPtrList<KABC::Resource> mResources = resources(); + + QPtrListIterator<KABC::Resource> it(mResources); + for ( ; it.current(); ++it ) { + KABC::Resource *res = it.current(); + removeResource(res); + } +} bool AddressBook::removeResource( Resource *resource ) { resource->close(); if ( resource == standardResource() ) d->mManager->setStandardResource( 0 ); diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 75f8b51..2351add 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h @@ -269,16 +269,17 @@ class AddressBook : public QObject /** Add address book resource. */ bool addResource( Resource * ); /** Remove address book resource. */ + void removeResources(); bool removeResource( Resource * ); /** Return pointer list of all resources. */ QPtrList<Resource> resources(); /** diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 3d4992c..028d3bb 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -267,17 +267,17 @@ void Addressee::computeCsum(const QString &dev) 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); -#if 1 +#if 0 for ( iii = 0; iii < l.count(); ++iii) qDebug("%d***%s***",iii,l[iii].latin1()); qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); #endif setCsum( dev, QString::number (cs )); } void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index ba17c50..48b7d91 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp @@ -62,34 +62,30 @@ extern "C" return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig>(); } } ResourceSharpDTM::ResourceSharpDTM( const KConfig *config ) : Resource( config ), mConverter (0) { // we can not choose the filename. Therefore use the default to display - - QString fileName = SlZDataBase::addressbookFileName(); - init( fileName ); + mAccess = 0; + QString fileName = SlZDataBase::addressbookFileName(); + init( fileName ); } ResourceSharpDTM::ResourceSharpDTM( const QString &fileName ) : Resource( 0 ) { - init( fileName ); + mAccess = 0; + init( fileName ); } void ResourceSharpDTM::init( const QString &fileName ) { - - connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); - connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); - connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); - setFileName( fileName ); } ResourceSharpDTM::~ResourceSharpDTM() { if (mConverter != 0) delete mConverter; @@ -99,118 +95,86 @@ ResourceSharpDTM::~ResourceSharpDTM() void ResourceSharpDTM::writeConfig( KConfig *config ) { Resource::writeConfig( config ); } Ticket *ResourceSharpDTM::requestSaveTicket() { - qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); if ( !addressBook() ) return 0; - -#ifdef ALLOW_LOCKING - if ( !lock( fileName() ) ) { - qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file "); - return 0; - } -#endif return createTicket( this ); } bool ResourceSharpDTM::doOpen() { - qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1()); - - // the last parameter in the SlZDataBase constructor means "readonly" - mAccess = new SlZDataBase(fileName(), - SlZDataBase::addressbookItems(), - NULL, false); + qDebug("%xResourceSharpDTM::doOpen: %s", this,fileName().latin1()); - if ( !mAccess ) { - qDebug("Unable to load file() %s", fileName().latin1()); - return false; - } - - if (mConverter == 0) - { - mConverter = new SharpDTMConverter(); - bool res = mConverter->init(); - if ( !res ) - { - QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); - - qDebug(msg); - delete mAccess; - mAccess = 0; - return false; + if ( ! mAccess ) { + // the last parameter in the SlZDataBase constructor means "readonly" + mAccess = new SlZDataBase(fileName(), + SlZDataBase::addressbookItems(), + NULL, false); } - } - - return true; + if ( !mAccess ) { + qDebug("Unable to load file() %s", fileName().latin1()); + return false; + } + if (mConverter == 0) { + mConverter = new SharpDTMConverter(); + bool res = mConverter->init(); + if ( !res ) + { + QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); + qDebug(msg); + delete mAccess; + mAccess = 0; + return false; + } + } + return true; } void ResourceSharpDTM::doClose() { - qDebug("ResourceSharpDTM::doClose: %s", fileName().latin1()); - - if(mAccess) - { - delete mAccess; - mAccess = 0; - } - // it seems so, that deletion of access deletes backend as well - //delete backend; - return; } bool ResourceSharpDTM::load() { - qDebug("ResourceSharpDTM::load: %s", fileName().latin1()); - - bool res = false; - - CardId id; - - for (bool res=mAccess->first(); res == true; res=mAccess->next()) - { - id = mAccess->cardId(); - - KABC::Addressee addressee; - - res = mConverter->sharpToAddressee( id, mAccess, addressee ); - - if ( !addressee.isEmpty() && res ) - { - addressee.setResource( this ); - addressBook()->insertAddressee( addressee ); - } - } - - return true; + qDebug("%xResourceSharpDTM::load: %s",this, fileName().latin1()); + bool res = false; + CardId id; + for (bool res=mAccess->first(); res == true; res=mAccess->next()) + { + id = mAccess->cardId(); + KABC::Addressee addressee; + res = mConverter->sharpToAddressee( id, mAccess, addressee ); + if ( !addressee.isEmpty() && res ) + { + addressee.setResource( this ); + addressBook()->insertAddressee( addressee ); + } + } + return true; } bool ResourceSharpDTM::save( Ticket *ticket ) { qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); - - mDirWatch.stopScan(); - KABC::AddressBook::Iterator it; bool res; KABC::Addressee::List changedAddressees; typedef QMap<int,QString> AddresseeMap; AddresseeMap map; CardId id ; - for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { QString uid = (*it).originalExternalUID(); bool res; if ( uid.isEmpty() ) id = 0; else @@ -218,20 +182,17 @@ bool ResourceSharpDTM::save( Ticket *ticket ) KABC::Addressee addressee = (*it); if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { res = mAccess->startEditCard(id); if (res == true) { res = mConverter->addresseeToSharp( (*it), mAccess, id ); if (res == true) { - res = mAccess->finishEditCard(&id); - //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); - //(*it).setExternalUID( QString::number( id ) ); - //(*it).setOriginalExternalUID( QString::number( id ) ); + res = mAccess->finishEditCard(&id);; map.insert(id,(*it).uid()); if (res == false) qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); } else { qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); @@ -249,21 +210,19 @@ bool ResourceSharpDTM::save( Ticket *ticket ) //changed res = mAccess->startEditCard(id); if (res == true) { res = mConverter->addresseeToSharp( (*it), mAccess, id ); if (res == true) { res = mAccess->finishEditCard(&id); - //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); map.insert(id,(*it).uid()); if (res == false) - qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); - + qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); } else { qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); mAccess->cancelEditCard(); } } } @@ -284,118 +243,38 @@ bool ResourceSharpDTM::save( Ticket *ticket ) { addressee.setResource( this ); addressee.setUid( itam.data() ); addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); addressBook()->insertAddressee( addressee , false ); } } } - - //US mAccess->save(); - - mDirWatch.startScan(); delete ticket; - unlock( fileName() ); return true; } bool ResourceSharpDTM::lock( const QString &lockfileName ) { -#ifdef ALLOW_LOCKING - qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); - - kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; - - QString fn = lockfileName; - - KURL url(fn); - QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); - - kdDebug(5700) << "-- lock name: " << lockName << endl; - - if (QFile::exists( lockName )) - { - qDebug("ResourceSharpDTM::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName()); - return false; - } - - - QString lockUniqueName; - lockUniqueName = fn + KApplication::randomString( 8 ); - - url = lockUniqueName; -//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); - mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); - kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; - - // Create unique file - QFile file( mLockUniqueName ); - file.open( IO_WriteOnly ); - file.close(); - - // Create lock file - int result = 0; -#ifndef _WIN32_ - result = ::link( QFile::encodeName( mLockUniqueName ), - QFile::encodeName( lockName ) ); -#endif - if ( result == 0 ) { - addressBook()->emitAddressBookLocked(); - return true; - } - - // TODO: check stat - - return false; -#else - return true; -#endif } void ResourceSharpDTM::unlock( const QString &fileName ) { -#ifdef ALLOW_LOCKING - qDebug("ResourceSharpDTM::unlock() %s", fileName.latin1()); - QString fn = fileName; - KURL url(fn); - QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); - - QFile::remove( lockName ); - QFile::remove( mLockUniqueName ); - addressBook()->emitAddressBookUnlocked(); -#endif } void ResourceSharpDTM::setFileName( const QString &newFileName ) { - mDirWatch.stopScan(); - mDirWatch.removeFile( fileName() ); - - Resource::setFileName( newFileName ); - - mDirWatch.addFile( fileName() ); - mDirWatch.startScan(); - + Resource::setFileName( newFileName ); } void ResourceSharpDTM::fileChanged() { - // There is a small theoretical chance that KDirWatch calls us before - // we are fully constructed - if (!addressBook()) - return; - - QString text( i18n( "Sharp DTM resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) ); - if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { - load(); - addressBook()->emitAddressBookChanged(); - } + } void ResourceSharpDTM::removeAddressee( const Addressee &addr ) { } void ResourceSharpDTM::cleanUp() { diff --git a/kabc/tmpaddressbook.cpp b/kabc/tmpaddressbook.cpp index 6e24302..cfa57e3 100644 --- a/kabc/tmpaddressbook.cpp +++ b/kabc/tmpaddressbook.cpp @@ -39,18 +39,11 @@ TmpAddressBook::TmpAddressBook() TmpAddressBook::TmpAddressBook( const QString &config ) : AddressBook( config, "tmpcontact" ) { } TmpAddressBook::~TmpAddressBook() { - //remove all possible resources. This should cleanup the configfile. - QPtrList<KABC::Resource> mResources = resources(); - - QPtrListIterator<KABC::Resource> it(mResources); - for ( ; it.current(); ++it ) { - KABC::Resource *res = it.current(); - removeResource(res); - } + removeResources(); } diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 6e482b5..e6bdde9 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -2237,29 +2237,29 @@ void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString birthdayList.append(formattedbday); anniversaryList.append(anni); //should be ISODate realNameList.append((*it).realName()); preferredEmailList.append((*it).preferredEmail()); assembledNameList.append((*it).assembledName()); uidList.append((*it).uid()); - qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); + //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); } } bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); } /* this method will be called through the QCop interface from other apps to show details of a contact. */ void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) { - qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); + //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); QString foundUid = QString::null; if ( ! uid.isEmpty() ) { Addressee adrr = mAddressBook->findByUid( uid ); if ( !adrr.isEmpty() ) { foundUid = uid; } if ( email == "sendbacklist" ) { @@ -2284,17 +2284,17 @@ void KABCore::requestForDetails(const QString& sourceChannel, const QString& ses Addressee::List namelist; Addressee::List emaillist; if (!name.isEmpty()) namelist = mAddressBook->findByName( name ); if (!email.isEmpty()) emaillist = mAddressBook->findByEmail( email ); - qDebug("count %d %d ", namelist.count(),emaillist.count() ); + //qDebug("count %d %d ", namelist.count(),emaillist.count() ); //check if we have a match in Namelist and Emaillist if ((namelist.count() == 0) && (emaillist.count() > 0)) { foundUid = emaillist[0].uid(); } else if ((namelist.count() > 0) && (emaillist.count() == 0)) foundUid = namelist[0].uid(); else { @@ -2401,54 +2401,54 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i QDateTime localMod = local->revision(); QDateTime remoteMod = remote->revision(); QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 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() ); + //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); locCh = ( localMod > mLastAddressbookSync ); if ( !remCh && ! locCh ) { - qDebug("both not changed "); + //qDebug("both not changed "); lastSync = localMod.addDays(1); if ( mode <= SYNC_PREF_ASK ) return 0; } else { if ( locCh ) { - qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); + //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); lastSync = localMod.addDays( -1 ); if ( !remCh ) remoteMod =( lastSync.addDays( -1 ) ); } else { - qDebug(" not loc changed "); + //qDebug(" not loc changed "); lastSync = localMod.addDays( 1 ); if ( remCh ) { - qDebug("rem changed "); + //qDebug("rem changed "); remoteMod =( lastSync.addDays( 1 ) ); } } } full = true; if ( mode < SYNC_PREF_ASK ) mode = SYNC_PREF_ASK; } else { if ( localMod == remoteMod ) return 0; } - qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); - qDebug("lastsync %s ", lastSync.toString().latin1() ); + //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); + //qDebug("lastsync %s ", lastSync.toString().latin1() ); //full = true; //debug only if ( full ) { bool equ = ( (*local) == (*remote) ); if ( equ ) { - qDebug("equal "); + //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()); @@ -2551,37 +2551,37 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo if ( !addresseeR.isEmpty() ) { addresseeRSync = addresseeR; remote->removeAddressee(addresseeR ); } else { if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { addresseeRSync = addresseeLSync ; } else { - qDebug("FULLDATE 1"); + //qDebug("FULLDATE 1"); fullDateRange = true; Addressee newAdd; addresseeRSync = newAdd; addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); addresseeRSync.setRevision( mLastAddressbookSync ); addresseeRSync.setCategories( i18n("SyncAddressee") ); } } if ( addresseeLSync.revision() == mLastAddressbookSync ) { - qDebug("FULLDATE 2"); + // qDebug("FULLDATE 2"); fullDateRange = true; } 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() ); + //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 @@ -2851,16 +2851,17 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) // afterwrite processing abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); } } } setModified(); } + abLocal.removeResources(); if ( syncOK ) mViewManager->refreshView(); return syncOK; } void KABCore::removeSyncInfo( QString syncProfile) { qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); @@ -2889,16 +2890,17 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource) abLocal.removeSyncAddressees( false ); abLocal.saveAB(); abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); } } else message( i18n("Sync cancelled or failed.") ); setModified(); } + abLocal.removeResources(); if ( syncOK ) mViewManager->refreshView(); disableBR( false ); return syncOK; } void KABCore::message( QString m ) { @@ -2928,16 +2930,17 @@ bool KABCore::syncPhone() abLocal.saveABphone( fileName ); abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); } } setModified(); } + abLocal.removeResources(); if ( syncOK ) mViewManager->refreshView(); return syncOK; } void KABCore::getFile( bool success ) { if ( ! success ) { message( i18n("Error receiving file. Nothing changed!") ); |