diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-08-17 02:27:43 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-08-17 02:27:43 +0000 |
commit | 8f37a4f755113e7440ae985111d36985d500cc95 (patch) | |
tree | 3750f2ad5f3ffaac64a98b5fc1a0389838296669 /libkdepim/kabcresourcecached.cpp | |
parent | 6d83f2c4e31c985122f6de9dab69d9f1d727b48a (diff) | |
download | tdepim-8f37a4f755113e7440ae985111d36985d500cc95.tar.gz tdepim-8f37a4f755113e7440ae985111d36985d500cc95.zip |
Slew of fixes and upgrades, including:
Added kaddressbook automatic sync
Added carddav autosync options
Added DCOP calls for kaddressbook and korganizer manual resync
Repaired Kontact refresh button through above mentioned DCOP calls
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1164528 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkdepim/kabcresourcecached.cpp')
-rw-r--r-- | libkdepim/kabcresourcecached.cpp | 122 |
1 files changed, 121 insertions, 1 deletions
diff --git a/libkdepim/kabcresourcecached.cpp b/libkdepim/kabcresourcecached.cpp index 88d83dcf8..26648e762 100644 --- a/libkdepim/kabcresourcecached.cpp +++ b/libkdepim/kabcresourcecached.cpp @@ -30,19 +30,139 @@ using namespace KABC; ResourceCached::ResourceCached( const KConfig *config ) - : KABC::Resource( config ), mIdMapper( "kabc/uidmaps/" ) + : KABC::Resource( config ), mIdMapper( "kabc/uidmaps/" ), + mReloadPolicy( ReloadInterval ), mReloadInterval( 10 ), + mKABCReloadTimer( 0, "mKABCReloadTimer" ), mReloaded( false ), + mSavePolicy( SaveDelayed ), mSaveInterval( 10 ), + mKABCSaveTimer( 0, "mKABCSaveTimer" ) { + connect( &mKABCReloadTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( slotKABCReload() ) ); + connect( &mKABCSaveTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( slotKABCSave() ) ); + + if (config) + this->readConfig(const_cast<KConfig *>(config)); } ResourceCached::~ResourceCached() { } +void ResourceCached::setReloadPolicy( int i ) +{ + mReloadPolicy = i; + + setupReloadTimer(); +} + +int ResourceCached::reloadPolicy() const +{ + return mReloadPolicy; +} + +void ResourceCached::setReloadInterval( int minutes ) +{ + mReloadInterval = minutes; +} + +int ResourceCached::reloadInterval() const +{ + return mReloadInterval; +} + +void ResourceCached::setSavePolicy( int i ) +{ + mSavePolicy = i; + + setupSaveTimer(); +} + +int ResourceCached::savePolicy() const +{ + return mSavePolicy; +} + +void ResourceCached::setSaveInterval( int minutes ) +{ + mSaveInterval = minutes; +} + +int ResourceCached::saveInterval() const +{ + return mSaveInterval; +} + void ResourceCached::writeConfig( KConfig *config ) { + config->writeEntry( "ReloadPolicy", mReloadPolicy ); + config->writeEntry( "ReloadInterval", mReloadInterval ); + + config->writeEntry( "SavePolicy", mSavePolicy ); + config->writeEntry( "SaveInterval", mSaveInterval ); + + config->writeEntry( "LastLoad", mLastLoad ); + config->writeEntry( "LastSave", mLastSave ); + KABC::Resource::writeConfig( config ); } +void ResourceCached::readConfig( KConfig *config ) +{ + mReloadPolicy = config->readNumEntry( "ReloadPolicy", ReloadNever ); + mReloadInterval = config->readNumEntry( "ReloadInterval", 10 ); + + mSaveInterval = config->readNumEntry( "SaveInterval", 10 ); + mSavePolicy = config->readNumEntry( "SavePolicy", SaveNever ); + + mLastLoad = config->readDateTimeEntry( "LastLoad" ); + mLastSave = config->readDateTimeEntry( "LastSave" ); + + setupSaveTimer(); + setupReloadTimer(); +} + +void ResourceCached::setupSaveTimer() +{ + if ( mSavePolicy == SaveInterval ) { + kdDebug(5800) << "ResourceCached::setSavePolicy(): start save timer (interval " + << mSaveInterval << " minutes)." << endl; + mKABCSaveTimer.start( mSaveInterval * 60 * 1000 ); // n minutes + } else { + mKABCSaveTimer.stop(); + } +} + +void ResourceCached::setupReloadTimer() +{ + if ( mReloadPolicy == ReloadInterval ) { + kdDebug(5800) << "ResourceCached::setSavePolicy(): start reload timer " + "(interval " << mReloadInterval << " minutes)" << endl; + mKABCReloadTimer.start( mReloadInterval * 60 * 1000 ); // n minutes + } else { + mKABCReloadTimer.stop(); + } +} + +void ResourceCached::slotKABCReload() +{ + if ( !isActive() ) return; + + kdDebug(5800) << "ResourceCached::slotKABCReload()" << endl; + + load(); +} + +void ResourceCached::slotKABCSave() +{ + if ( !isActive() ) return; + + kdDebug(5800) << "ResourceCached::slotKABCSave()" << endl; + + KABC::Ticket *ticket = requestSaveTicket(); + if ( ticket ) { + save( ticket ); + } +} + void ResourceCached::insertAddressee( const Addressee &addr ) { if ( !mAddrMap.contains( addr.uid() ) ) { // new contact |