summaryrefslogtreecommitdiffabout
path: root/microkde/kresources/managerimpl.cpp
Unidiff
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,5 +1,5 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
@@ -22,4 +22,11 @@
22*/ 22*/
23 23
24/*
25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk
27
28$Id$
29*/
30
24#include <kglobal.h> 31#include <kglobal.h>
25 32
@@ -35,12 +42,12 @@
35using namespace KRES; 42using namespace KRES;
36 43
37ManagerImpl::ManagerImpl( const QString &family ) 44ManagerImpl::ManagerImpl( const QString &family, bool syncable )
38 : mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ), 45 : mFamily( family ), mSyncable(syncable), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ),
39 mFactory( 0 ) 46 mFactory( 0 )
40 47
41{ 48{
42 kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl; 49 kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl;
43 50
44 51
45} 52}
46 53
@@ -53,5 +60,5 @@ ManagerImpl::~ManagerImpl()
53 delete *it; 60 delete *it;
54 } 61 }
55 62
56 delete mStdConfig; 63 delete mStdConfig;
57} 64}
@@ -60,9 +67,9 @@ void ManagerImpl::createStandardConfig()
60{ 67{
61 if ( !mStdConfig ) { 68 if ( !mStdConfig ) {
62 QString file = locateLocal( "data", KGlobal::getAppName() 69 QString file = locateLocal( "data", KGlobal::getAppName()
63 + "/kresources/" + mFamily + "rc" ); 70 + "/kresources/" + mFamily + "rc" );
64 mStdConfig = new KConfig( file ); 71 mStdConfig = new KConfig( file );
65 } 72 }
66 73
67 mConfig = mStdConfig; 74 mConfig = mStdConfig;
68} 75}
@@ -80,5 +87,5 @@ void ManagerImpl::readConfig( KConfig *cfg )
80 mConfig = cfg; 87 mConfig = cfg;
81 } 88 }
82 89
83 mStandard = 0; 90 mStandard = 0;
84 91
@@ -93,12 +100,12 @@ void ManagerImpl::readConfig( KConfig *cfg )
93 readResourceConfig( *it, false ); 100 readResourceConfig( *it, false );
94 } 101 }
95 102
96} 103}
97 104
98void ManagerImpl::writeConfig( KConfig *cfg ) 105void ManagerImpl::writeConfig( KConfig *cfg )
99{ 106{
100//USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg); 107//USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg);
101 108
102 109
103 kdDebug(5650) << "ManagerImpl::writeConfig()" << endl; 110 kdDebug(5650) << "ManagerImpl::writeConfig()" << endl;
104 111
@@ -108,5 +115,5 @@ void ManagerImpl::writeConfig( KConfig *cfg )
108 mConfig = cfg; 115 mConfig = cfg;
109 } 116 }
110 117
111 QStringList activeKeys; 118 QStringList activeKeys;
112 QStringList passiveKeys; 119 QStringList passiveKeys;
@@ -130,5 +137,5 @@ void ManagerImpl::writeConfig( KConfig *cfg )
130 mConfig->writeEntry( "ResourceKeys", activeKeys ); 137 mConfig->writeEntry( "ResourceKeys", activeKeys );
131 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); 138 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys );
132 if ( mStandard ) 139 if ( mStandard )
133 mConfig->writeEntry( "Standard", mStandard->identifier() ); 140 mConfig->writeEntry( "Standard", mStandard->identifier() );
134 else 141 else
@@ -137,13 +144,13 @@ void ManagerImpl::writeConfig( KConfig *cfg )
137 mConfig->sync(); 144 mConfig->sync();
138 kdDebug(5650) << "ManagerImpl::save() finished" << endl; 145 kdDebug(5650) << "ManagerImpl::save() finished" << endl;
139 146
140//US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg); 147//US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg);
141 148
142} 149}
143 150
144void ManagerImpl::add( Resource *resource, bool useDCOP ) 151void ManagerImpl::add( Resource *resource, bool useDCOP )
145{ 152{
146qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource); 153qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource);
147 154
148 resource->setActive( true ); 155 resource->setActive( true );
149 156
@@ -156,5 +163,5 @@ qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource);
156 writeResourceConfig( resource, true ); 163 writeResourceConfig( resource, true );
157 164
158 qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource); 165 qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource);
159 166
160} 167}
@@ -179,10 +186,10 @@ void ManagerImpl::setActive( Resource *resource, bool active )
179} 186}
180 187
181Resource *ManagerImpl::standardResource() 188Resource *ManagerImpl::standardResource()
182{ 189{
183 return mStandard; 190 return mStandard;
184} 191}
185 192
186void ManagerImpl::setStandardResource( Resource *resource ) 193void ManagerImpl::setStandardResource( Resource *resource )
187{ 194{
188 mStandard = resource; 195 mStandard = resource;
@@ -250,5 +257,5 @@ Resource* ManagerImpl::readResourceConfig( const QString& identifier,
250{ 257{
251 kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; 258 kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl;
252 259
253// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); 260// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1());
254 261
@@ -262,5 +269,5 @@ Resource* ManagerImpl::readResourceConfig( const QString& identifier,
262 QString type = mConfig->readEntry( "ResourceType" ); 269 QString type = mConfig->readEntry( "ResourceType" );
263 QString name = mConfig->readEntry( "ResourceName" ); 270 QString name = mConfig->readEntry( "ResourceName" );
264 Resource *resource = mFactory->resource( type, mConfig ); 271 Resource *resource = mFactory->resource( type, mConfig, mSyncable );
265 if ( !resource ) { 272 if ( !resource ) {
266 qDebug("Failed to create resource with id %s ",identifier.latin1() ); 273 qDebug("Failed to create resource with id %s ",identifier.latin1() );
@@ -306,5 +313,5 @@ void ManagerImpl::writeResourceConfig( Resource *resource,
306 else if ( resource != mStandard && standardKey == key ) 313 else if ( resource != mStandard && standardKey == key )
307 mConfig->writeEntry( "Standard", "" ); 314 mConfig->writeEntry( "Standard", "" );
308 315
309 if ( checkActive ) { 316 if ( checkActive ) {
310 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 317 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
@@ -326,5 +333,5 @@ void ManagerImpl::removeResource( Resource *resource )
326 333
327 if ( !mConfig ) createStandardConfig(); 334 if ( !mConfig ) createStandardConfig();
328 335
329 mConfig->setGroup( "General" ); 336 mConfig->setGroup( "General" );
330 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 337 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
@@ -357,2 +364,11 @@ Resource* ManagerImpl::getResource( const QString& identifier )
357 return 0; 364 return 0;
358} 365}
366
367/**
368 Return true, if the manager manages syncable resources.
369*/
370bool ManagerImpl::manageSyncable() const
371{
372 return mSyncable;
373}
374