author | zautrix <zautrix> | 2004-07-08 11:20:17 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-08 11:20:17 (UTC) |
commit | 3f84322a2da502f95be386372da9f75ed17df574 (patch) (unidiff) | |
tree | 9a4ccd4568c38d60bb1efa7a6713f4d0914aae86 /microkde/kresources | |
parent | 40cf8102d2f38b5e952b889ffbd19cb1d428fc9b (diff) | |
download | kdepimpi-3f84322a2da502f95be386372da9f75ed17df574.zip kdepimpi-3f84322a2da502f95be386372da9f75ed17df574.tar.gz kdepimpi-3f84322a2da502f95be386372da9f75ed17df574.tar.bz2 |
Fixes for resource plugin handling on wintendo
-rw-r--r-- | microkde/kresources/managerimpl.cpp | 11 | ||||
-rw-r--r-- | microkde/kresources/resource.cpp | 7 |
2 files changed, 15 insertions, 3 deletions
diff --git a/microkde/kresources/managerimpl.cpp b/microkde/kresources/managerimpl.cpp index 1baa6be..785b6b4 100644 --- a/microkde/kresources/managerimpl.cpp +++ b/microkde/kresources/managerimpl.cpp | |||
@@ -208,103 +208,108 @@ QStringList ManagerImpl::resourceNames() | |||
208 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { | 208 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { |
209 | result.append( (*it)->resourceName() ); | 209 | result.append( (*it)->resourceName() ); |
210 | } | 210 | } |
211 | return result; | 211 | return result; |
212 | } | 212 | } |
213 | 213 | ||
214 | Resource::List *ManagerImpl::resourceList() | 214 | Resource::List *ManagerImpl::resourceList() |
215 | { | 215 | { |
216 | return &mResources; | 216 | return &mResources; |
217 | } | 217 | } |
218 | 218 | ||
219 | QPtrList<Resource> ManagerImpl::resources() | 219 | QPtrList<Resource> ManagerImpl::resources() |
220 | { | 220 | { |
221 | QPtrList<Resource> result; | 221 | QPtrList<Resource> result; |
222 | 222 | ||
223 | Resource::List::ConstIterator it; | 223 | Resource::List::ConstIterator it; |
224 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { | 224 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { |
225 | result.append( *it ); | 225 | result.append( *it ); |
226 | } | 226 | } |
227 | return result; | 227 | return result; |
228 | } | 228 | } |
229 | 229 | ||
230 | QPtrList<Resource> ManagerImpl::resources( bool active ) | 230 | QPtrList<Resource> ManagerImpl::resources( bool active ) |
231 | { | 231 | { |
232 | QPtrList<Resource> result; | 232 | QPtrList<Resource> result; |
233 | 233 | ||
234 | Resource::List::ConstIterator it; | 234 | Resource::List::ConstIterator it; |
235 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { | 235 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { |
236 | if ( (*it)->isActive() == active ) { | 236 | if ( (*it)->isActive() == active ) { |
237 | result.append( *it ); | 237 | result.append( *it ); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | return result; | 240 | return result; |
241 | } | 241 | } |
242 | 242 | ||
243 | void ManagerImpl::setListener( ManagerImplListener *listener ) | 243 | void ManagerImpl::setListener( ManagerImplListener *listener ) |
244 | { | 244 | { |
245 | mListener = listener; | 245 | mListener = listener; |
246 | } | 246 | } |
247 | 247 | ||
248 | Resource* ManagerImpl::readResourceConfig( const QString& identifier, | 248 | Resource* ManagerImpl::readResourceConfig( const QString& identifier, |
249 | bool checkActive ) | 249 | bool checkActive ) |
250 | { | 250 | { |
251 | kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; | 251 | kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; |
252 | 252 | ||
253 | // qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); | 253 | // qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); |
254 | 254 | ||
255 | mConfig->setGroup( "Resource_" + identifier ); | 255 | mConfig->setGroup( "Resource_" + identifier ); |
256 | 256 | #ifdef _WIN32_ | |
257 | // we use plugins on win32. the group is stored in a static variable | ||
258 | // such that gourp info not avail on win32 plugins | ||
259 | // to fix that, it would be a looooot of work | ||
260 | mConfig->setTempGroup( "Resource_" + identifier ); | ||
261 | #endif | ||
257 | QString type = mConfig->readEntry( "ResourceType" ); | 262 | QString type = mConfig->readEntry( "ResourceType" ); |
258 | QString name = mConfig->readEntry( "ResourceName" ); | 263 | QString name = mConfig->readEntry( "ResourceName" ); |
259 | Resource *resource = mFactory->resource( type, mConfig ); | 264 | Resource *resource = mFactory->resource( type, mConfig ); |
260 | if ( !resource ) { | 265 | if ( !resource ) { |
261 | kdDebug(5650) << "Failed to create resource with id " << identifier << endl; | 266 | qDebug("Failed to create resource with id %s ",identifier.latin1() ); |
262 | return 0; | 267 | return 0; |
263 | } | 268 | } |
264 | 269 | ||
265 | if ( resource->identifier().isEmpty() ) | 270 | if ( resource->identifier().isEmpty() ) |
266 | resource->setIdentifier( identifier ); | 271 | resource->setIdentifier( identifier ); |
267 | 272 | ||
268 | mConfig->setGroup( "General" ); | 273 | mConfig->setGroup( "General" ); |
269 | 274 | ||
270 | QString standardKey = mConfig->readEntry( "Standard" ); | 275 | QString standardKey = mConfig->readEntry( "Standard" ); |
271 | if ( standardKey == identifier ) { | 276 | if ( standardKey == identifier ) { |
272 | mStandard = resource; | 277 | mStandard = resource; |
273 | } | 278 | } |
274 | 279 | ||
275 | if ( checkActive ) { | 280 | if ( checkActive ) { |
276 | QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); | 281 | QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); |
277 | resource->setActive( activeKeys.contains( identifier ) ); | 282 | resource->setActive( activeKeys.contains( identifier ) ); |
278 | } | 283 | } |
279 | mResources.append( resource ); | 284 | mResources.append( resource ); |
280 | 285 | ||
281 | return resource; | 286 | return resource; |
282 | } | 287 | } |
283 | 288 | ||
284 | void ManagerImpl::writeResourceConfig( Resource *resource, | 289 | void ManagerImpl::writeResourceConfig( Resource *resource, |
285 | bool checkActive ) | 290 | bool checkActive ) |
286 | { | 291 | { |
287 | QString key = resource->identifier(); | 292 | QString key = resource->identifier(); |
288 | 293 | ||
289 | kdDebug(5650) << "Saving resource " << key << endl; | 294 | kdDebug(5650) << "Saving resource " << key << endl; |
290 | 295 | ||
291 | if ( !mConfig ) createStandardConfig(); | 296 | if ( !mConfig ) createStandardConfig(); |
292 | 297 | ||
293 | mConfig->setGroup( "Resource_" + key ); | 298 | mConfig->setGroup( "Resource_" + key ); |
294 | resource->writeConfig( mConfig ); | 299 | resource->writeConfig( mConfig ); |
295 | 300 | ||
296 | mConfig->setGroup( "General" ); | 301 | mConfig->setGroup( "General" ); |
297 | QString standardKey = mConfig->readEntry( "Standard" ); | 302 | QString standardKey = mConfig->readEntry( "Standard" ); |
298 | 303 | ||
299 | if ( resource == mStandard && standardKey != key ) | 304 | if ( resource == mStandard && standardKey != key ) |
300 | mConfig->writeEntry( "Standard", resource->identifier() ); | 305 | mConfig->writeEntry( "Standard", resource->identifier() ); |
301 | else if ( resource != mStandard && standardKey == key ) | 306 | else if ( resource != mStandard && standardKey == key ) |
302 | mConfig->writeEntry( "Standard", "" ); | 307 | mConfig->writeEntry( "Standard", "" ); |
303 | 308 | ||
304 | if ( checkActive ) { | 309 | if ( checkActive ) { |
305 | QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); | 310 | QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); |
306 | if ( resource->isActive() && !activeKeys.contains( key ) ) { | 311 | if ( resource->isActive() && !activeKeys.contains( key ) ) { |
307 | activeKeys.append( resource->identifier() ); | 312 | activeKeys.append( resource->identifier() ); |
308 | mConfig->writeEntry( "ResourceKeys", activeKeys ); | 313 | mConfig->writeEntry( "ResourceKeys", activeKeys ); |
309 | } else if ( !resource->isActive() && activeKeys.contains( key ) ) { | 314 | } else if ( !resource->isActive() && activeKeys.contains( key ) ) { |
310 | activeKeys.remove( key ); | 315 | activeKeys.remove( key ); |
diff --git a/microkde/kresources/resource.cpp b/microkde/kresources/resource.cpp index 7827a67..991d53d 100644 --- a/microkde/kresources/resource.cpp +++ b/microkde/kresources/resource.cpp | |||
@@ -8,96 +8,103 @@ | |||
8 | This library is free software; you can redistribute it and/or | 8 | This library is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU Library General Public | 9 | modify it under the terms of the GNU Library General Public |
10 | License as published by the Free Software Foundation; either | 10 | License as published by the Free Software Foundation; either |
11 | version 2 of the License, or (at your option) any later version. | 11 | version 2 of the License, or (at your option) any later version. |
12 | 12 | ||
13 | This library is distributed in the hope that it will be useful, | 13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Library General Public License for more details. | 16 | Library General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU Library General Public License | 18 | You should have received a copy of the GNU Library General Public License |
19 | along with this library; see the file COPYING.LIB. If not, write to | 19 | along with this library; see the file COPYING.LIB. If not, write to |
20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. | 21 | Boston, MA 02111-1307, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <kdebug.h> | 24 | #include <kdebug.h> |
25 | #include <kapplication.h> | 25 | #include <kapplication.h> |
26 | #include <kconfig.h> | 26 | #include <kconfig.h> |
27 | 27 | ||
28 | #include "resource.h" | 28 | #include "resource.h" |
29 | 29 | ||
30 | using namespace KRES; | 30 | using namespace KRES; |
31 | 31 | ||
32 | class Resource::ResourcePrivate | 32 | class Resource::ResourcePrivate |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | #ifdef QT_THREAD_SUPPORT | 35 | #ifdef QT_THREAD_SUPPORT |
36 | QMutex mMutex; | 36 | QMutex mMutex; |
37 | #endif | 37 | #endif |
38 | int mOpenCount; | 38 | int mOpenCount; |
39 | QString mType; | 39 | QString mType; |
40 | QString mIdentifier; | 40 | QString mIdentifier; |
41 | bool mReadOnly; | 41 | bool mReadOnly; |
42 | QString mName; | 42 | QString mName; |
43 | bool mActive; | 43 | bool mActive; |
44 | bool mIsOpen; | 44 | bool mIsOpen; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | Resource::Resource( const KConfig* config ) | 47 | Resource::Resource( const KConfig* config ) |
48 | : QObject( 0, "" ), d( new ResourcePrivate ) | 48 | : QObject( 0, "" ), d( new ResourcePrivate ) |
49 | { | 49 | { |
50 | d->mOpenCount = 0; | 50 | d->mOpenCount = 0; |
51 | d->mIsOpen = false; | 51 | d->mIsOpen = false; |
52 | 52 | ||
53 | //US compiler claimed that const discards qualifier | 53 | //US compiler claimed that const discards qualifier |
54 | KConfig* cfg = (KConfig*)config; | 54 | KConfig* cfg = (KConfig*)config; |
55 | if ( cfg ) { | 55 | if ( cfg ) { |
56 | #ifdef _WIN32_ | ||
57 | // we use plugins on win32. the group is stored in a static variable | ||
58 | // such that group info not available on win32 plugins | ||
59 | // to fix that, it would be a looooot of work | ||
60 | if ( !cfg->tempGroup().isEmpty() ) | ||
61 | cfg->setGroup( cfg->tempGroup() ); | ||
62 | #endif | ||
56 | d->mType = cfg->readEntry( "ResourceType" ); | 63 | d->mType = cfg->readEntry( "ResourceType" ); |
57 | d->mName = cfg->readEntry( "ResourceName" ); | 64 | d->mName = cfg->readEntry( "ResourceName" ); |
58 | d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false ); | 65 | d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false ); |
59 | d->mActive = cfg->readBoolEntry( "ResourceIsActive", true ); | 66 | d->mActive = cfg->readBoolEntry( "ResourceIsActive", true ); |
60 | d->mIdentifier = cfg->readEntry( "ResourceIdentifier" ); | 67 | d->mIdentifier = cfg->readEntry( "ResourceIdentifier" ); |
61 | } else { | 68 | } else { |
62 | d->mType = "type"; | 69 | d->mType = "type"; |
63 | d->mName = "resource-name"; | 70 | d->mName = "resource-name"; |
64 | d->mReadOnly = false; | 71 | d->mReadOnly = false; |
65 | d->mActive = true; | 72 | d->mActive = true; |
66 | d->mIdentifier = KApplication::randomString( 10 ); | 73 | d->mIdentifier = KApplication::randomString( 10 ); |
67 | } | 74 | } |
68 | } | 75 | } |
69 | 76 | ||
70 | Resource::~Resource() | 77 | Resource::~Resource() |
71 | { | 78 | { |
72 | delete d; | 79 | delete d; |
73 | d = 0; | 80 | d = 0; |
74 | } | 81 | } |
75 | 82 | ||
76 | void Resource::writeConfig( KConfig* config ) | 83 | void Resource::writeConfig( KConfig* config ) |
77 | { | 84 | { |
78 | 85 | ||
79 | 86 | ||
80 | config->writeEntry( "ResourceType", d->mType ); | 87 | config->writeEntry( "ResourceType", d->mType ); |
81 | config->writeEntry( "ResourceName", d->mName ); | 88 | config->writeEntry( "ResourceName", d->mName ); |
82 | config->writeEntry( "ResourceIsReadOnly", d->mReadOnly ); | 89 | config->writeEntry( "ResourceIsReadOnly", d->mReadOnly ); |
83 | config->writeEntry( "ResourceIsActive", d->mActive ); | 90 | config->writeEntry( "ResourceIsActive", d->mActive ); |
84 | config->writeEntry( "ResourceIdentifier", d->mIdentifier ); | 91 | config->writeEntry( "ResourceIdentifier", d->mIdentifier ); |
85 | } | 92 | } |
86 | 93 | ||
87 | bool Resource::open() | 94 | bool Resource::open() |
88 | { | 95 | { |
89 | d->mIsOpen = true; | 96 | d->mIsOpen = true; |
90 | #ifdef QT_THREAD_SUPPORT | 97 | #ifdef QT_THREAD_SUPPORT |
91 | QMutexLocker guard( &(d->mMutex) ); | 98 | QMutexLocker guard( &(d->mMutex) ); |
92 | #endif | 99 | #endif |
93 | if ( !d->mOpenCount ) { | 100 | if ( !d->mOpenCount ) { |
94 | kdDebug(5650) << "Opening resource " << resourceName() << endl; | 101 | kdDebug(5650) << "Opening resource " << resourceName() << endl; |
95 | d->mIsOpen = doOpen(); | 102 | d->mIsOpen = doOpen(); |
96 | } | 103 | } |
97 | d->mOpenCount++; | 104 | d->mOpenCount++; |
98 | return d->mIsOpen; | 105 | return d->mIsOpen; |
99 | } | 106 | } |
100 | 107 | ||
101 | void Resource::close() | 108 | void Resource::close() |
102 | { | 109 | { |
103 | #ifdef QT_THREAD_SUPPORT | 110 | #ifdef QT_THREAD_SUPPORT |