summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/addressbook.cpp11
-rw-r--r--kabc/addressbook.h1
-rw-r--r--kabc/addressee.cpp2
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp137
-rw-r--r--kabc/tmpaddressbook.cpp9
-rw-r--r--kaddressbook/kabcore.cpp31
6 files changed, 39 insertions, 152 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 4c4ae09..8487ff3 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1162,2 +1162,13 @@ bool AddressBook::addResource( Resource *resource )
}
+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);
+ }
+}
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 75f8b51..2351add 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -276,2 +276,3 @@ class AddressBook : public QObject
*/
+ void removeResources();
bool removeResource( Resource * );
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 3d4992c..028d3bb 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -274,3 +274,3 @@ void Addressee::computeCsum(const QString &dev)
uint cs = getCsum4List(l);
-#if 1
+#if 0
for ( iii = 0; iii < l.count(); ++iii)
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
@@ -69,3 +69,3 @@ ResourceSharpDTM::ResourceSharpDTM( const KConfig *config )
// we can not choose the filename. Therefore use the default to display
-
+ mAccess = 0;
QString fileName = SlZDataBase::addressbookFileName();
@@ -77,2 +77,3 @@ ResourceSharpDTM::ResourceSharpDTM( const QString &fileName )
{
+ mAccess = 0;
init( fileName );
@@ -82,7 +83,2 @@ 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 );
@@ -107,3 +103,2 @@ Ticket *ResourceSharpDTM::requestSaveTicket()
-
qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1());
@@ -111,9 +106,2 @@ Ticket *ResourceSharpDTM::requestSaveTicket()
if ( !addressBook() ) return 0;
-
-#ifdef ALLOW_LOCKING
- if ( !lock( fileName() ) ) {
- qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file ");
- return 0;
- }
-#endif
return createTicket( this );
@@ -124,4 +112,5 @@ bool ResourceSharpDTM::doOpen()
{
- qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1());
+ qDebug("%xResourceSharpDTM::doOpen: %s", this,fileName().latin1());
+ if ( ! mAccess ) {
// the last parameter in the SlZDataBase constructor means "readonly"
@@ -130,3 +119,3 @@ bool ResourceSharpDTM::doOpen()
NULL, false);
-
+ }
if ( !mAccess ) {
@@ -135,5 +124,3 @@ bool ResourceSharpDTM::doOpen()
}
-
- if (mConverter == 0)
- {
+ if (mConverter == 0) {
mConverter = new SharpDTMConverter();
@@ -143,3 +130,2 @@ bool ResourceSharpDTM::doOpen()
QString msg("Unable to initialize sharp converter. Most likely a problem with the category file");
-
qDebug(msg);
@@ -150,3 +136,2 @@ bool ResourceSharpDTM::doOpen()
}
-
return true;
@@ -156,12 +141,2 @@ 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;
@@ -171,8 +146,5 @@ bool ResourceSharpDTM::load()
{
- qDebug("ResourceSharpDTM::load: %s", fileName().latin1());
-
+ qDebug("%xResourceSharpDTM::load: %s",this, fileName().latin1());
bool res = false;
-
CardId id;
-
for (bool res=mAccess->first(); res == true; res=mAccess->next())
@@ -180,7 +152,4 @@ bool ResourceSharpDTM::load()
id = mAccess->cardId();
-
KABC::Addressee addressee;
-
res = mConverter->sharpToAddressee( id, mAccess, addressee );
-
if ( !addressee.isEmpty() && res )
@@ -191,3 +160,2 @@ bool ResourceSharpDTM::load()
}
-
return true;
@@ -198,5 +166,2 @@ bool ResourceSharpDTM::save( Ticket *ticket )
qDebug("ResourceSharpDTM::save: %s", fileName().latin1());
-
- mDirWatch.stopScan();
-
KABC::AddressBook::Iterator it;
@@ -207,3 +172,2 @@ bool ResourceSharpDTM::save( Ticket *ticket )
CardId id ;
-
for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
@@ -225,6 +189,3 @@ bool ResourceSharpDTM::save( Ticket *ticket )
{
- 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());
@@ -256,3 +217,2 @@ bool ResourceSharpDTM::save( Ticket *ticket )
res = mAccess->finishEditCard(&id);
- //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
map.insert(id,(*it).uid());
@@ -260,3 +220,2 @@ bool ResourceSharpDTM::save( Ticket *ticket )
qDebug("Unable to append Contact: %s", addressee.formattedName().latin1());
-
}
@@ -291,8 +250,3 @@ bool ResourceSharpDTM::save( Ticket *ticket )
}
-
- //US mAccess->save();
-
- mDirWatch.startScan();
delete ticket;
- unlock( fileName() );
@@ -303,51 +257,2 @@ 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
}
@@ -356,13 +261,3 @@ 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
}
@@ -371,10 +266,3 @@ void ResourceSharpDTM::setFileName( const QString &newFileName )
{
- mDirWatch.stopScan();
- mDirWatch.removeFile( fileName() );
-
Resource::setFileName( newFileName );
-
- mDirWatch.addFile( fileName() );
- mDirWatch.startScan();
-
}
@@ -383,12 +271,3 @@ 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();
- }
}
diff --git a/kabc/tmpaddressbook.cpp b/kabc/tmpaddressbook.cpp
index 6e24302..cfa57e3 100644
--- a/kabc/tmpaddressbook.cpp
+++ b/kabc/tmpaddressbook.cpp
@@ -46,10 +46,3 @@ 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
@@ -2244,3 +2244,3 @@ void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString
- 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() );
}
@@ -2256,3 +2256,3 @@ void KABCore::requestForDetails(const QString& sourceChannel, const QString& ses
{
- 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());
@@ -2291,3 +2291,3 @@ void KABCore::requestForDetails(const QString& sourceChannel, const QString& ses
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
@@ -2408,6 +2408,6 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
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);
@@ -2417,3 +2417,3 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
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 );
@@ -2422,6 +2422,6 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
} 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 ) );
@@ -2439,4 +2439,4 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
}
- 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
@@ -2445,3 +2445,3 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
if ( equ ) {
- qDebug("equal ");
+ //qDebug("equal ");
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
@@ -2558,3 +2558,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
} else {
- qDebug("FULLDATE 1");
+ //qDebug("FULLDATE 1");
fullDateRange = true;
@@ -2569,3 +2569,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
if ( addresseeLSync.revision() == mLastAddressbookSync ) {
- qDebug("FULLDATE 2");
+ // qDebug("FULLDATE 2");
fullDateRange = true;
@@ -2578,3 +2578,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
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() );
}
@@ -2858,2 +2858,3 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
}
+ abLocal.removeResources();
if ( syncOK )
@@ -2896,2 +2897,3 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
}
+ abLocal.removeResources();
if ( syncOK )
@@ -2935,2 +2937,3 @@ bool KABCore::syncPhone()
}
+ abLocal.removeResources();
if ( syncOK )