summaryrefslogtreecommitdiffabout
path: root/microkde/kresources
authorzautrix <zautrix>2004-07-07 03:28:52 (UTC)
committer zautrix <zautrix>2004-07-07 03:28:52 (UTC)
commit816db8f76a1fd8b5cc586dfd5ebf8d6298221801 (patch) (unidiff)
treee418207a02e60c0807e75731a19c44a58d0fb896 /microkde/kresources
parent3db5c4e190d1031f2471516f8a52114f06d1a3eb (diff)
downloadkdepimpi-816db8f76a1fd8b5cc586dfd5ebf8d6298221801.zip
kdepimpi-816db8f76a1fd8b5cc586dfd5ebf8d6298221801.tar.gz
kdepimpi-816db8f76a1fd8b5cc586dfd5ebf8d6298221801.tar.bz2
Changed some strings. Removed some kdebug
Diffstat (limited to 'microkde/kresources') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/factory.cpp10
-rw-r--r--microkde/kresources/resource.cpp3
2 files changed, 7 insertions, 6 deletions
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp
index 56b0ef3..827ec38 100644
--- a/microkde/kresources/factory.cpp
+++ b/microkde/kresources/factory.cpp
@@ -1,242 +1,242 @@
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>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
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 <klocale.h> 25#include <klocale.h>
26#include <ksimpleconfig.h> 26#include <ksimpleconfig.h>
27#include <kstandarddirs.h> 27#include <kstandarddirs.h>
28#include <kstaticdeleter.h> 28#include <kstaticdeleter.h>
29#include <klibloader.h> 29#include <klibloader.h>
30 30
31#include <qfile.h> 31#include <qfile.h>
32 32
33#include "resource.h" 33#include "resource.h"
34#include "factory.h" 34#include "factory.h"
35 35
36using namespace KRES; 36using namespace KRES;
37 37
38QDict<Factory> *Factory::mSelves = 0; 38QDict<Factory> *Factory::mSelves = 0;
39static KStaticDeleter< QDict<Factory> > staticDeleter; 39static KStaticDeleter< QDict<Factory> > staticDeleter;
40 40
41Factory *Factory::self( const QString& resourceFamily ) 41Factory *Factory::self( const QString& resourceFamily )
42{ 42{
43 kdDebug(5650) << "Factory::self()" << endl; 43
44 44
45 Factory *factory = 0; 45 Factory *factory = 0;
46 if ( !mSelves ) 46 if ( !mSelves )
47 { 47 {
48 mSelves = staticDeleter.setObject( new QDict<Factory> ); 48 mSelves = staticDeleter.setObject( new QDict<Factory> );
49 } 49 }
50 50
51 factory = mSelves->find( resourceFamily ); 51 factory = mSelves->find( resourceFamily );
52 52
53 if ( !factory ) { 53 if ( !factory ) {
54 factory = new Factory( resourceFamily ); 54 factory = new Factory( resourceFamily );
55 mSelves->insert( resourceFamily, factory ); 55 mSelves->insert( resourceFamily, factory );
56 } 56 }
57 57
58 return factory; 58 return factory;
59} 59}
60 60
61Factory::Factory( const QString& resourceFamily ) : 61Factory::Factory( const QString& resourceFamily ) :
62 mResourceFamily( resourceFamily ) 62 mResourceFamily( resourceFamily )
63{ 63{
64//US so far we have three types available for resourceFamily "contact" 64//US so far we have three types available for resourceFamily "contact"
65// and that are "file", "dir", "ldap" 65// and that are "file", "dir", "ldap"
66/*US 66/*US
67 67
68 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" ) 68 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" )
69 .arg( resourceFamily ) ); 69 .arg( resourceFamily ) );
70 KTrader::OfferList::ConstIterator it; 70 KTrader::OfferList::ConstIterator it;
71 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 71 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
72 QVariant type = (*it)->property( "X-KDE-ResourceType" ); 72 QVariant type = (*it)->property( "X-KDE-ResourceType" );
73 if ( !type.toString().isEmpty() ) 73 if ( !type.toString().isEmpty() )
74 mTypeMap.insert( type.toString(), *it ); 74 mTypeMap.insert( type.toString(), *it );
75 } 75 }
76*/ 76*/
77 77
78//US new 78//US new
79 PluginInfo* info = new PluginInfo; 79 PluginInfo* info = new PluginInfo;
80 info->library = "microkabc_file"; 80 info->library = "microkabc_file";
81 info->nameLabel = i18n( "file" ); 81 info->nameLabel = i18n( "file" );
82 info->descriptionLabel = i18n( "No description available." ); 82 info->descriptionLabel = i18n( "Choose one file" );
83 mTypeMap.insert( "file", info ); 83 mTypeMap.insert( "file", info );
84 84
85 info = new PluginInfo; 85 info = new PluginInfo;
86 info->library = "microkabc_dir"; 86 info->library = "microkabc_dir";
87 info->nameLabel = i18n( "dir" ); 87 info->nameLabel = i18n( "dir" );
88 info->descriptionLabel = i18n( "No description available." ); 88 info->descriptionLabel = i18n( "Choose a directory with may files" );
89 mTypeMap.insert( "dir", info ); 89 mTypeMap.insert( "dir", info );
90 90
91 info = new PluginInfo; 91 info = new PluginInfo;
92 info->library = "microkabc_ldap"; 92 info->library = "microkabc_ldap";
93 info->nameLabel = i18n( "ldap" ); 93 info->nameLabel = i18n( "ldap" );
94 info->descriptionLabel = i18n( "No description available." ); 94 info->descriptionLabel = i18n( "No description available" );
95 mTypeMap.insert( "ldap", info ); 95 mTypeMap.insert( "ldap", info );
96 96
97 //US add opie plugin only, if the library exists 97 //US add opie plugin only, if the library exists
98 QString libname = "microkabc_opie"; 98 QString libname = "microkabc_opie";
99 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 99 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
100 if ( !path.isEmpty() ) 100 if ( !path.isEmpty() )
101 { 101 {
102 info = new PluginInfo; 102 info = new PluginInfo;
103 info->library = libname; 103 info->library = libname;
104 info->nameLabel = i18n( "opie" ); 104 info->nameLabel = i18n( "opie" );
105 info->descriptionLabel = i18n( "Opie PIM Addressbook." ); 105 info->descriptionLabel = i18n( "Opie PIM Addressbook." );
106 mTypeMap.insert( "opie", info ); 106 mTypeMap.insert( "opie", info );
107 } 107 }
108 108
109 //US add qtopia plugin only, if the library exists 109 //US add qtopia plugin only, if the library exists
110 libname = "microkabc_qtopia"; 110 libname = "microkabc_qtopia";
111 path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 111 path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
112 if ( !path.isEmpty() ) 112 if ( !path.isEmpty() )
113 { 113 {
114 info = new PluginInfo; 114 info = new PluginInfo;
115 info->library = libname; 115 info->library = libname;
116 info->nameLabel = i18n( "qtopia" ); 116 info->nameLabel = i18n( "qtopia" );
117 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." ); 117 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." );
118 mTypeMap.insert( "qtopia", info ); 118 mTypeMap.insert( "qtopia", info );
119 } 119 }
120 120
121 121
122} 122}
123 123
124Factory::~Factory() 124Factory::~Factory()
125{ 125{
126} 126}
127 127
128QStringList Factory::typeNames() const 128QStringList Factory::typeNames() const
129{ 129{
130//US method QMap::keys() not available yet. SO collect the data manually 130//US method QMap::keys() not available yet. SO collect the data manually
131//US return mTypeMap.keys(); 131//US return mTypeMap.keys();
132 132
133 QStringList result; 133 QStringList result;
134 134
135 QMap<QString, PluginInfo*>::ConstIterator it; 135 QMap<QString, PluginInfo*>::ConstIterator it;
136 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) { 136 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) {
137 result << it.key().latin1(); 137 result << it.key().latin1();
138// qDebug("Factory::typeNames() : %s ", it.key().latin1()); 138// qDebug("Factory::typeNames() : %s ", it.key().latin1());
139 139
140 } 140 }
141 return result; 141 return result;
142} 142}
143 143
144ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) 144ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
145{ 145{
146 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 146 if ( type.isEmpty() || !mTypeMap.contains( type ) )
147 return 0; 147 return 0;
148 148
149//US KService::Ptr ptr = mTypeMap[ type ]; 149//US KService::Ptr ptr = mTypeMap[ type ];
150//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 150//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
151 PluginInfo* pi = mTypeMap[ type ]; 151 PluginInfo* pi = mTypeMap[ type ];
152 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 152 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
153 if ( !factory ) { 153 if ( !factory ) {
154 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1()); 154 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1());
155 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl; 155 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl;
156 return 0; 156 return 0;
157 } 157 }
158 158
159 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 159 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
160 160
161 if ( !pluginFactory ) { 161 if ( !pluginFactory ) {
162 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1()); 162 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1());
163 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl; 163 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl;
164 return 0; 164 return 0;
165 } 165 }
166 166
167 ConfigWidget *wdg = pluginFactory->configWidget( parent ); 167 ConfigWidget *wdg = pluginFactory->configWidget( parent );
168 if ( !wdg ) { 168 if ( !wdg ) {
169//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 169//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
170 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 170 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
171 return 0; 171 return 0;
172 } 172 }
173 return wdg; 173 return wdg;
174 174
175} 175}
176 176
177QString Factory::typeName( const QString &type ) const 177QString Factory::typeName( const QString &type ) const
178{ 178{
179 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 179 if ( type.isEmpty() || !mTypeMap.contains( type ) )
180 return QString(); 180 return QString();
181 181
182 182
183//US KService::Ptr ptr = mTypeMap[ type ]; 183//US KService::Ptr ptr = mTypeMap[ type ];
184//US return ptr->name(); 184//US return ptr->name();
185 PluginInfo* pi = mTypeMap[ type ]; 185 PluginInfo* pi = mTypeMap[ type ];
186 return pi->nameLabel; 186 return pi->nameLabel;
187 187
188} 188}
189 189
190QString Factory::typeDescription( const QString &type ) const 190QString Factory::typeDescription( const QString &type ) const
191{ 191{
192 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 192 if ( type.isEmpty() || !mTypeMap.contains( type ) )
193 return QString(); 193 return QString();
194 194
195//US KService::Ptr ptr = mTypeMap[ type ]; 195//US KService::Ptr ptr = mTypeMap[ type ];
196//US return ptr->comment(); 196//US return ptr->comment();
197 PluginInfo* pi = mTypeMap[ type ]; 197 PluginInfo* pi = mTypeMap[ type ];
198 return pi->descriptionLabel; 198 return pi->descriptionLabel;
199} 199}
200 200
201Resource *Factory::resource( const QString& type, const KConfig *config ) 201Resource *Factory::resource( const QString& type, const KConfig *config )
202{ 202{
203 kdDebug() << "Factory::resource( " << type << ", config)" << endl; 203
204 204
205 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 205 if ( type.isEmpty() || !mTypeMap.contains( type ) )
206 return 0; 206 return 0;
207 207
208/*US load the lib not dynamicly. !! 208/*US load the lib not dynamicly. !!
209 KService::Ptr ptr = mTypeMap[ type ]; 209 KService::Ptr ptr = mTypeMap[ type ];
210 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 210 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
211 if ( !factory ) { 211 if ( !factory ) {
212 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 212 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
213 return 0; 213 return 0;
214 } 214 }
215*/ 215*/
216 PluginInfo* pi = mTypeMap[ type ]; 216 PluginInfo* pi = mTypeMap[ type ];
217 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 217 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
218 if ( !factory ) { 218 if ( !factory ) {
219 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1()); 219 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1());
220 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 220 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
221 return 0; 221 return 0;
222 } 222 }
223 223
224 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 224 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
225 225
226 if ( !pluginFactory ) { 226 if ( !pluginFactory ) {
227 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); 227 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1());
228 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; 228 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl;
229 return 0; 229 return 0;
230 } 230 }
231 231
232 Resource *resource = pluginFactory->resource( config ); 232 Resource *resource = pluginFactory->resource( config );
233 if ( !resource ) { 233 if ( !resource ) {
234//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 234//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
235 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 235 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
236 return 0; 236 return 0;
237 } 237 }
238 238
239 resource->setType( type ); 239 resource->setType( type );
240 240
241 return resource; 241 return resource;
242} 242}
diff --git a/microkde/kresources/resource.cpp b/microkde/kresources/resource.cpp
index 169eaa4..7827a67 100644
--- a/microkde/kresources/resource.cpp
+++ b/microkde/kresources/resource.cpp
@@ -1,185 +1,186 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
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 d->mType = cfg->readEntry( "ResourceType" ); 56 d->mType = cfg->readEntry( "ResourceType" );
57 d->mName = cfg->readEntry( "ResourceName" ); 57 d->mName = cfg->readEntry( "ResourceName" );
58 d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false ); 58 d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false );
59 d->mActive = cfg->readBoolEntry( "ResourceIsActive", true ); 59 d->mActive = cfg->readBoolEntry( "ResourceIsActive", true );
60 d->mIdentifier = cfg->readEntry( "ResourceIdentifier" ); 60 d->mIdentifier = cfg->readEntry( "ResourceIdentifier" );
61 } else { 61 } else {
62 d->mType = "type"; 62 d->mType = "type";
63 d->mName = "resource-name"; 63 d->mName = "resource-name";
64 d->mReadOnly = false; 64 d->mReadOnly = false;
65 d->mActive = true; 65 d->mActive = true;
66 d->mIdentifier = KApplication::randomString( 10 ); 66 d->mIdentifier = KApplication::randomString( 10 );
67 } 67 }
68} 68}
69 69
70Resource::~Resource() 70Resource::~Resource()
71{ 71{
72 delete d; 72 delete d;
73 d = 0; 73 d = 0;
74} 74}
75 75
76void Resource::writeConfig( KConfig* config ) 76void Resource::writeConfig( KConfig* config )
77{ 77{
78 kdDebug(5650) << "Resource::writeConfig()" << endl; 78
79 79
80 config->writeEntry( "ResourceType", d->mType ); 80 config->writeEntry( "ResourceType", d->mType );
81 config->writeEntry( "ResourceName", d->mName ); 81 config->writeEntry( "ResourceName", d->mName );
82 config->writeEntry( "ResourceIsReadOnly", d->mReadOnly ); 82 config->writeEntry( "ResourceIsReadOnly", d->mReadOnly );
83 config->writeEntry( "ResourceIsActive", d->mActive ); 83 config->writeEntry( "ResourceIsActive", d->mActive );
84 config->writeEntry( "ResourceIdentifier", d->mIdentifier ); 84 config->writeEntry( "ResourceIdentifier", d->mIdentifier );
85} 85}
86 86
87bool Resource::open() 87bool Resource::open()
88{ 88{
89 d->mIsOpen = true; 89 d->mIsOpen = true;
90#ifdef QT_THREAD_SUPPORT 90#ifdef QT_THREAD_SUPPORT
91 QMutexLocker guard( &(d->mMutex) ); 91 QMutexLocker guard( &(d->mMutex) );
92#endif 92#endif
93 if ( !d->mOpenCount ) { 93 if ( !d->mOpenCount ) {
94 kdDebug(5650) << "Opening resource " << resourceName() << endl; 94 kdDebug(5650) << "Opening resource " << resourceName() << endl;
95 d->mIsOpen = doOpen(); 95 d->mIsOpen = doOpen();
96 } 96 }
97 d->mOpenCount++; 97 d->mOpenCount++;
98 return d->mIsOpen; 98 return d->mIsOpen;
99} 99}
100 100
101void Resource::close() 101void Resource::close()
102{ 102{
103#ifdef QT_THREAD_SUPPORT 103#ifdef QT_THREAD_SUPPORT
104 QMutexLocker guard( &(d->mMutex) ); 104 QMutexLocker guard( &(d->mMutex) );
105#endif 105#endif
106 if ( !d->mOpenCount ) { 106 if ( !d->mOpenCount ) {
107 kdDebug(5650) << "ERROR: Resource " << resourceName() << " closed more times than previously opened" << endl; 107 kdDebug(5650) << "ERROR: Resource " << resourceName() << " closed more times than previously opened" << endl;
108 return; 108 return;
109 } 109 }
110 d->mOpenCount--; 110 d->mOpenCount--;
111 if ( !d->mOpenCount ) { 111 if ( !d->mOpenCount ) {
112 kdDebug(5650) << "Closing resource " << resourceName() << endl; 112 kdDebug(5650) << "Closing resource " << resourceName() << endl;
113 doClose(); 113 doClose();
114 d->mIsOpen = false; 114 d->mIsOpen = false;
115 } else { 115 } else {
116 kdDebug(5650) << "Not yet closing resource " << resourceName() << ", open count = " << d->mOpenCount << endl; 116 kdDebug(5650) << "Not yet closing resource " << resourceName() << ", open count = " << d->mOpenCount << endl;
117 } 117 }
118} 118}
119 119
120bool Resource::isOpen() const 120bool Resource::isOpen() const
121{ 121{
122 return d->mIsOpen; 122 return d->mIsOpen;
123} 123}
124 124
125void Resource::setIdentifier( const QString& identifier ) 125void Resource::setIdentifier( const QString& identifier )
126{ 126{
127 d->mIdentifier = identifier; 127 d->mIdentifier = identifier;
128} 128}
129 129
130QString Resource::identifier() const 130QString Resource::identifier() const
131{ 131{
132 return d->mIdentifier; 132 return d->mIdentifier;
133} 133}
134 134
135void Resource::setType( const QString& type ) 135void Resource::setType( const QString& type )
136{ 136{
137 d->mType = type; 137 d->mType = type;
138} 138}
139 139
140QString Resource::type() const 140QString Resource::type() const
141{ 141{
142 return d->mType; 142 return d->mType;
143} 143}
144 144
145void Resource::setReadOnly( bool value ) 145void Resource::setReadOnly( bool value )
146{ 146{
147 d->mReadOnly = value; 147 d->mReadOnly = value;
148} 148}
149 149
150bool Resource::readOnly() const 150bool Resource::readOnly() const
151{ 151{
152 return d->mReadOnly; 152 return d->mReadOnly;
153} 153}
154 154
155void Resource::setResourceName( const QString &name ) 155void Resource::setResourceName( const QString &name )
156{ 156{
157 d->mName = name; 157 d->mName = name;
158} 158}
159 159
160QString Resource::resourceName() const 160QString Resource::resourceName() const
161{ 161{
162 return d->mName; 162 return d->mName;
163} 163}
164 164
165void Resource::setActive( bool value ) 165void Resource::setActive( bool value )
166{ 166{
167 d->mActive = value; 167 d->mActive = value;
168} 168}
169 169
170bool Resource::isActive() const 170bool Resource::isActive() const
171{ 171{
172 return d->mActive; 172 return d->mActive;
173} 173}
174 174
175void Resource::dump() const 175void Resource::dump() const
176{ 176{
177 qDebug("Resource::dump() ");
177 kdDebug(5650) << "Resource:" << endl; 178 kdDebug(5650) << "Resource:" << endl;
178 kdDebug(5650) << " Name: " << d->mName << endl; 179 kdDebug(5650) << " Name: " << d->mName << endl;
179 kdDebug(5650) << " Identifier: " << d->mIdentifier << endl; 180 kdDebug(5650) << " Identifier: " << d->mIdentifier << endl;
180 kdDebug(5650) << " Type: " << d->mType << endl; 181 kdDebug(5650) << " Type: " << d->mType << endl;
181 kdDebug(5650) << " OpenCount: " << d->mOpenCount << endl; 182 kdDebug(5650) << " OpenCount: " << d->mOpenCount << endl;
182 kdDebug(5650) << " ReadOnly: " << ( d->mReadOnly ? "yes" : "no" ) << endl; 183 kdDebug(5650) << " ReadOnly: " << ( d->mReadOnly ? "yes" : "no" ) << endl;
183 kdDebug(5650) << " Active: " << ( d->mActive ? "yes" : "no" ) << endl; 184 kdDebug(5650) << " Active: " << ( d->mActive ? "yes" : "no" ) << endl;
184 kdDebug(5650) << " IsOpen: " << ( d->mIsOpen ? "yes" : "no" ) << endl; 185 kdDebug(5650) << " IsOpen: " << ( d->mIsOpen ? "yes" : "no" ) << endl;
185} 186}