summaryrefslogtreecommitdiffabout
path: root/microkde/kresources/resource.cpp
Unidiff
Diffstat (limited to 'microkde/kresources/resource.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/resource.cpp7
1 files changed, 7 insertions, 0 deletions
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
30using namespace KRES; 30using namespace KRES;
31 31
32class Resource::ResourcePrivate 32class 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
47Resource::Resource( const KConfig* config ) 47Resource::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
70Resource::~Resource() 77Resource::~Resource()
71{ 78{
72 delete d; 79 delete d;
73 d = 0; 80 d = 0;
74} 81}
75 82
76void Resource::writeConfig( KConfig* config ) 83void 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
87bool Resource::open() 94bool 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
101void Resource::close() 108void Resource::close()
102{ 109{
103#ifdef QT_THREAD_SUPPORT 110#ifdef QT_THREAD_SUPPORT