summaryrefslogtreecommitdiffabout
path: root/microkde/kresources/managerimpl.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kresources/managerimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/managerimpl.cpp70
1 files changed, 43 insertions, 27 deletions
diff --git a/microkde/kresources/managerimpl.cpp b/microkde/kresources/managerimpl.cpp
index 785b6b4..3655f50 100644
--- a/microkde/kresources/managerimpl.cpp
+++ b/microkde/kresources/managerimpl.cpp
@@ -1,6 +1,6 @@
/*
This file is part of libkresources.
-
+
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
@@ -21,6 +21,13 @@
Boston, MA 02111-1307, USA.
*/
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
#include <kglobal.h>
#include <kapplication.h>
@@ -34,14 +41,14 @@
using namespace KRES;
-ManagerImpl::ManagerImpl( const QString &family )
- : mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ),
+ManagerImpl::ManagerImpl( const QString &family, bool syncable )
+ : mFamily( family ), mSyncable(syncable), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ),
mFactory( 0 )
{
kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl;
-
-
+
+
}
ManagerImpl::~ManagerImpl()
@@ -52,18 +59,18 @@ ManagerImpl::~ManagerImpl()
for ( it = mResources.begin(); it != mResources.end(); ++it ) {
delete *it;
}
-
+
delete mStdConfig;
}
void ManagerImpl::createStandardConfig()
{
if ( !mStdConfig ) {
- QString file = locateLocal( "data", KGlobal::getAppName()
+ QString file = locateLocal( "data", KGlobal::getAppName()
+ "/kresources/" + mFamily + "rc" );
mStdConfig = new KConfig( file );
}
-
+
mConfig = mStdConfig;
}
@@ -79,7 +86,7 @@ void ManagerImpl::readConfig( KConfig *cfg )
} else {
mConfig = cfg;
}
-
+
mStandard = 0;
mConfig->setGroup( "General" );
@@ -92,14 +99,14 @@ void ManagerImpl::readConfig( KConfig *cfg )
for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) {
readResourceConfig( *it, false );
}
-
+
}
void ManagerImpl::writeConfig( KConfig *cfg )
{
-//USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg);
-
-
+//USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg);
+
+
kdDebug(5650) << "ManagerImpl::writeConfig()" << endl;
if ( !cfg ) {
@@ -107,7 +114,7 @@ void ManagerImpl::writeConfig( KConfig *cfg )
} else {
mConfig = cfg;
}
-
+
QStringList activeKeys;
QStringList passiveKeys;
@@ -129,22 +136,22 @@ void ManagerImpl::writeConfig( KConfig *cfg )
mConfig->setGroup( "General" );
mConfig->writeEntry( "ResourceKeys", activeKeys );
mConfig->writeEntry( "PassiveResourceKeys", passiveKeys );
- if ( mStandard )
+ if ( mStandard )
mConfig->writeEntry( "Standard", mStandard->identifier() );
else
mConfig->writeEntry( "Standard", "" );
mConfig->sync();
kdDebug(5650) << "ManagerImpl::save() finished" << endl;
-
-//US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg);
-
+
+//US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg);
+
}
void ManagerImpl::add( Resource *resource, bool useDCOP )
{
-qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource);
-
+qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource);
+
resource->setActive( true );
if ( mResources.isEmpty() ) {
@@ -155,7 +162,7 @@ qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource);
writeResourceConfig( resource, true );
- qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource);
+ qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource);
}
@@ -178,12 +185,12 @@ void ManagerImpl::setActive( Resource *resource, bool active )
}
}
-Resource *ManagerImpl::standardResource()
+Resource *ManagerImpl::standardResource()
{
return mStandard;
}
-void ManagerImpl::setStandardResource( Resource *resource )
+void ManagerImpl::setStandardResource( Resource *resource )
{
mStandard = resource;
}
@@ -249,7 +256,7 @@ Resource* ManagerImpl::readResourceConfig( const QString& identifier,
bool checkActive )
{
kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl;
-
+
// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1());
mConfig->setGroup( "Resource_" + identifier );
@@ -261,7 +268,7 @@ Resource* ManagerImpl::readResourceConfig( const QString& identifier,
#endif
QString type = mConfig->readEntry( "ResourceType" );
QString name = mConfig->readEntry( "ResourceName" );
- Resource *resource = mFactory->resource( type, mConfig );
+ Resource *resource = mFactory->resource( type, mConfig, mSyncable );
if ( !resource ) {
qDebug("Failed to create resource with id %s ",identifier.latin1() );
return 0;
@@ -305,7 +312,7 @@ void ManagerImpl::writeResourceConfig( Resource *resource,
mConfig->writeEntry( "Standard", resource->identifier() );
else if ( resource != mStandard && standardKey == key )
mConfig->writeEntry( "Standard", "" );
-
+
if ( checkActive ) {
QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
if ( resource->isActive() && !activeKeys.contains( key ) ) {
@@ -325,7 +332,7 @@ void ManagerImpl::removeResource( Resource *resource )
QString key = resource->identifier();
if ( !mConfig ) createStandardConfig();
-
+
mConfig->setGroup( "General" );
QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
if ( activeKeys.contains( key ) ) {
@@ -356,3 +363,12 @@ Resource* ManagerImpl::getResource( const QString& identifier )
}
return 0;
}
+
+/**
+ Return true, if the manager manages syncable resources.
+*/
+bool ManagerImpl::manageSyncable() const
+{
+ return mSyncable;
+}
+