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
v3.5.13-sru
tpearson 14 years ago
parent 6d83f2c4e3
commit 8f37a4f755

@ -877,6 +877,16 @@ void KABCore::save()
}
}
void KABCore::load()
{
TQPtrList<KABC::Resource> resources = mAddressBook->resources();
TQPtrListIterator<KABC::Resource> it( resources );
while ( it.current() ) {
mAddressBook->load();
++it;
}
}
void KABCore::setJumpButtonBarVisible( bool visible )
{
if ( visible ) {

@ -331,6 +331,11 @@ class KDE_EXPORT KABCore : public KAB::Core
*/
void save();
/**
Loads the contents of the AddressBook from disk.
*/
void load();
/**
Shows the edit dialog for the given uid. If the uid is TQString::null,
the method will try to find a selected addressee in the view.

@ -154,6 +154,12 @@ bool KAddressbookPart::handleCommandLine()
return mCore->handleCommandLine( this );
}
void KAddressbookPart::syncAllResources()
{
mCore->save();
mCore->load();
}
void KAddressbookPart::guiActivateEvent( KParts::GUIActivateEvent *e )
{
kdDebug(5720) << "KAddressbookPart::guiActivateEvent" << endl;

@ -59,6 +59,7 @@ class KAddressbookPart: public KParts::ReadOnlyPart, virtual public KAddressBook
virtual void exit();
virtual bool openURL( const KURL &url );
virtual bool handleCommandLine();
virtual void syncAllResources();
protected:
virtual bool openFile();

@ -67,6 +67,8 @@ class KDE_EXPORT KAddressBookIface : virtual public DCOPObject
virtual void loadProfile( const TQString& path ) = 0;
virtual void saveToProfile( const TQString& path ) const = 0;
virtual void syncAllResources() = 0;
};
#endif

@ -129,6 +129,12 @@ bool KAddressBookMain::handleCommandLine()
return mCore->handleCommandLine( this );
}
void KAddressBookMain::syncAllResources()
{
mCore->save();
mCore->load();
}
void KAddressBookMain::saveProperties( KConfig* )
{
}

@ -61,6 +61,7 @@ class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface
virtual void save();
virtual void exit();
virtual bool handleCommandLine();
virtual void syncAllResources();
protected:
void initActions();

@ -120,8 +120,8 @@ void KAddressbookPlugin::slotNewDistributionList()
void KAddressbookPlugin::slotSyncContacts()
{
DCOPRef ref( "kmail", "KMailICalIface" );
ref.send( "triggerSync", TQString("Contact") );
DCOPRef ref( "kaddressbook", "KAddressBookIface" );
ref.send( "syncAllResources" );
}
bool KAddressbookPlugin::createDCOPInterface( const TQString& serviceType )

@ -132,8 +132,8 @@ void KOrganizerPlugin::slotNewEvent()
void KOrganizerPlugin::slotSyncEvents()
{
DCOPRef ref( "kmail", "KMailICalIface" );
ref.send( "triggerSync", TQString("Calendar") );
DCOPRef ref( "korganizer", "KOrganizerIface" );
ref.send( "syncAllResources" );
}
bool KOrganizerPlugin::createDCOPInterface( const TQString& serviceType )

@ -1860,6 +1860,17 @@ bool ActionManager::saveResourceCalendar()
return true;
}
void ActionManager::loadResourceCalendar()
{
if ( !mCalendarResources ) return;
CalendarResourceManager *m = mCalendarResources->resourceManager();
CalendarResourceManager::ActiveIterator it;
for ( it = m->activeBegin(); it != m->activeEnd(); ++it ) {
(*it)->load();
}
}
void ActionManager::importCalendar( const KURL &url )
{
if ( !url.isValid() ) {

@ -106,6 +106,11 @@ class KDE_EXPORT ActionManager : public TQObject, public KCalendarIface
*/
bool saveResourceCalendar();
/**
Load the resource based calendar.
*/
void loadResourceCalendar();
public slots:
/** Add a new resource */
bool addResource( const KURL &mUrl );

@ -36,6 +36,7 @@ class KOrganizerIface : virtual public DCOPObject
virtual TQString getCurrentURLasString() const = 0;
virtual bool editIncidence(const TQString &uid) = 0;
virtual bool deleteIncidence(const TQString &uid) = 0;
virtual void syncAllResources() = 0;
/**
Delete the incidence with the given unique ID from the active calendar.
@param uid The incidence's unique ID.

@ -60,6 +60,12 @@ void KOrganizerIfaceImpl::closeURL()
return mActionManager->closeURL();
}
void KOrganizerIfaceImpl::syncAllResources()
{
mActionManager->saveResourceCalendar();
mActionManager->loadResourceCalendar();
}
bool KOrganizerIfaceImpl::saveURL()
{
return mActionManager->saveURL();

@ -52,6 +52,7 @@ public:
bool canQueryClose();
bool saveAsURL( const TQString &url );
TQString getCurrentURLasString() const;
void syncAllResources();
bool editIncidence( const TQString &uid );
/** @reimp from KOrganizerIface::deleteIncidence() */

@ -119,9 +119,6 @@ CardDavReloadConfig::CardDavReloadConfig( TQWidget *parent )
vbox->addWidget(automaticReloadOnStartup);
vbox->addWidget(noAutomaticReload);
vbox->addStretch(1);
// FIXME KABC
groupBox->hide();
}
CardDavReloadConfig::~CardDavReloadConfig()
@ -131,16 +128,14 @@ CardDavReloadConfig::~CardDavReloadConfig()
void CardDavReloadConfig::loadSettings( ResourceCached *resource )
{
// FIXME KABC
//d->mIntervalSpin->setValue( resource->reloadInterval() );
//d->mGroup->setButton( resource->reloadPolicy() );
d->mIntervalSpin->setValue( resource->reloadInterval() );
d->mGroup->setButton( resource->reloadPolicy() );
}
void CardDavReloadConfig::saveSettings( ResourceCached *resource )
{
// FIXME KABC
//resource->setReloadInterval( d->mIntervalSpin->value() );
//resource->setReloadPolicy( d->mGroup->selectedId() );
resource->setReloadInterval( d->mIntervalSpin->value() );
resource->setReloadPolicy( d->mGroup->selectedId() );
}
void CardDavReloadConfig::slotIntervalToggled( bool checked )
@ -219,9 +214,6 @@ CardDavSaveConfig::CardDavSaveConfig( TQWidget *parent )
vbox->addWidget(onExit);
vbox->addWidget(never);
vbox->addStretch(1);
// FIXME KABC
groupBox->hide();
}
CardDavSaveConfig::~CardDavSaveConfig()
@ -231,16 +223,14 @@ CardDavSaveConfig::~CardDavSaveConfig()
void CardDavSaveConfig::loadSettings( ResourceCached *resource )
{
// FIXME KABC
//d->mIntervalSpin->setValue( resource->saveInterval() );
//d->mGroup->setButton( resource->savePolicy() );
d->mIntervalSpin->setValue( resource->saveInterval() );
d->mGroup->setButton( resource->savePolicy() );
}
void CardDavSaveConfig::saveSettings( ResourceCached *resource )
{
// FIXME KABC
//resource->setSaveInterval( d->mIntervalSpin->value() );
//resource->setSavePolicy( d->mGroup->selectedId() );
resource->setSaveInterval( d->mIntervalSpin->value() );
resource->setSavePolicy( d->mGroup->selectedId() );
}
void CardDavSaveConfig::slotIntervalToggled( bool checked )

@ -54,8 +54,8 @@ const int ResourceCardDav::CACHE_DAYS = 90;
const int ResourceCardDav::DEFAULT_RELOAD_INTERVAL = 10;
const int ResourceCardDav::DEFAULT_SAVE_INTERVAL = 10;
//const int ResourceCardDav::DEFAULT_RELOAD_POLICY = ResourceCached::ReloadInterval;
//const int ResourceCardDav::DEFAULT_SAVE_POLICY = ResourceCached::SaveDelayed;
const int ResourceCardDav::DEFAULT_RELOAD_POLICY = ResourceCached::ReloadInterval;
const int ResourceCardDav::DEFAULT_SAVE_POLICY = ResourceCached::SaveDelayed;
/*=========================================================================
| UTILITY
@ -237,7 +237,7 @@ CardDavPrefs* ResourceCardDav::createPrefs() const {
}
void ResourceCardDav::init() {
// default settings
// // default settings
// setReloadInterval(DEFAULT_RELOAD_INTERVAL);
// setReloadPolicy(DEFAULT_RELOAD_POLICY);
// setSaveInterval(DEFAULT_SAVE_INTERVAL);
@ -338,10 +338,6 @@ void ResourceCardDav::loadingQueuePop() {
mLoader->setType(0);
mLoader->setUseURI(mPrefs->getUseURI());
//TQDateTime dt(TQDate::currentDate());
//mLoader->setRange(dt.addDays(-CACHE_DAYS), dt.addDays(CACHE_DAYS));
//mLoader->setGetAll();
mLoadingQueueReady = false;
log("starting actual download job");

@ -782,7 +782,7 @@ TQString AddresseeView::strippedNumber( const TQString &number )
for ( uint i = 0; i < number.length(); ++i ) {
TQChar c = number[ i ];
if ( c.isDigit() || c == '*' || c == '#' || c == '+' && i == 0 )
if ( (c.isDigit() || (c == '*') || (c == '#') || (c == '+')) && (i == 0) )
retval.append( c );
}

@ -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

@ -24,6 +24,9 @@
#include <kabc/resource.h>
#include <kdepimmacros.h>
#include <tqdatetime.h>
#include <tqtimer.h>
#include "libemailfunctions/idmapper.h"
namespace KABC {
@ -33,11 +36,86 @@ class KDE_EXPORT ResourceCached : public Resource
Q_OBJECT
public:
/**
Reload policy.
@see setReloadPolicy(), reloadPolicy()
*/
enum { ReloadNever, ReloadOnStartup, ReloadInterval };
/**
Save policy.
@see setSavePolicy(), savePolicy()
*/
enum { SaveNever, SaveOnExit, SaveInterval, SaveDelayed, SaveAlways };
ResourceCached( const KConfig* );
~ResourceCached();
/**
Writes the resource specific config to file.
Set reload policy. This controls when the cache is refreshed.
ReloadNever never reload
ReloadOnStartup reload when resource is started
ReloadInterval reload regularly after given interval
*/
void setReloadPolicy( int policy );
/**
Return reload policy.
@see setReloadPolicy()
*/
int reloadPolicy() const;
/**
Set reload interval in minutes which is used when reload policy is
ReloadInterval.
*/
void setReloadInterval( int minutes );
/**
Return reload interval in minutes.
*/
int reloadInterval() const;
/**
Set save policy. This controls when the cache is refreshed.
SaveNever never save
SaveOnExit save when resource is exited
SaveInterval save regularly after given interval
SaveDelayed save after small delay
SaveAlways save on every change
*/
void setSavePolicy( int policy );
/**
Return save policy.
@see setsavePolicy()
*/
int savePolicy() const;
/**
Set save interval in minutes which is used when save policy is
SaveInterval.
*/
void setSaveInterval( int minutes );
/**
Return save interval in minutes.
*/
int saveInterval() const;
void setupSaveTimer();
void setupReloadTimer();
/**
Reads the resource specific config from disk.
*/
virtual void readConfig( KConfig *config );
/**
Writes the resource specific config to disk.
*/
virtual void writeConfig( KConfig *config );
@ -85,14 +163,30 @@ class KDE_EXPORT ResourceCached : public Resource
void setIdMapperIdentifier();
private:
KPIM::IdMapper mIdMapper;
TQMap<TQString, KABC::Addressee> mAddedAddressees;
TQMap<TQString, KABC::Addressee> mChangedAddressees;
TQMap<TQString, KABC::Addressee> mDeletedAddressees;
KPIM::IdMapper mIdMapper;
class ResourceCachedPrivate;
ResourceCachedPrivate *d;
int mReloadPolicy;
int mReloadInterval;
TQTimer mKABCReloadTimer;
bool mReloaded;
int mSavePolicy;
int mSaveInterval;
TQTimer mKABCSaveTimer;
TQDateTime mLastLoad;
TQDateTime mLastSave;
protected slots:
void slotKABCReload();
void slotKABCSave();
};
}

Loading…
Cancel
Save