summaryrefslogtreecommitdiffabout
path: root/microkde/kresources/resource.h
Unidiff
Diffstat (limited to 'microkde/kresources/resource.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/resource.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/microkde/kresources/resource.h b/microkde/kresources/resource.h
index ed5af96..1f9527c 100644
--- a/microkde/kresources/resource.h
+++ b/microkde/kresources/resource.h
@@ -1,79 +1,79 @@
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 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#ifndef KRESOURCES_RESOURCE_H 23#ifndef KRESOURCES_RESOURCE_H
24#define KRESOURCES_RESOURCE_H 24#define KRESOURCES_RESOURCE_H
25 25
26//US 26//US
27#ifdef QT_THREAD_SUPPORT 27#ifdef QT_THREAD_SUPPORT
28#include <qmutex.h> 28#include <qmutex.h>
29#endif //QT_THREAD_SUPPORT 29#endif //QT_THREAD_SUPPORT
30 30
31#include <qvaluelist.h> 31#include <q3valuelist.h>
32#include <qwidget.h> 32#include <qwidget.h>
33 33
34#include <qobject.h> 34#include <qobject.h>
35 35
36#include <klibloader.h> 36#include <klibloader.h>
37 37
38class KConfig; 38class KConfig;
39 39
40namespace KRES { 40namespace KRES {
41 41
42class ConfigWidget; 42class ConfigWidget;
43 43
44/** 44/**
45 * @internal 45 * @internal
46 * @libdoc The KDE Resource library 46 * @libdoc The KDE Resource library
47 * 47 *
48 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this 48 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this
49 * interface, it is in constant flux. 49 * interface, it is in constant flux.
50 * 50 *
51 * The KDE Resource framework can be used to manage resources of 51 * The KDE Resource framework can be used to manage resources of
52 * different types, organized in families. The Resource framework 52 * different types, organized in families. The Resource framework
53 * is currently used for addressbook resources in libkabc and for 53 * is currently used for addressbook resources in libkabc and for
54 * calendar resources in libkcal. 54 * calendar resources in libkcal.
55 * 55 *
56 * When you want to use the framework for a new family, you need to 56 * When you want to use the framework for a new family, you need to
57 * <ul><li>Define a name for your resource family</li> 57 * <ul><li>Define a name for your resource family</li>
58 * <li>subclass Resource and add the fields and method that are needed 58 * <li>subclass Resource and add the fields and method that are needed
59 * in your application</li> 59 * in your application</li>
60 * <li>If needed, override the doOpen() and doClose() methods. 60 * <li>If needed, override the doOpen() and doClose() methods.
61 * <li> Provide a configuration possibility for resources in your 61 * <li> Provide a configuration possibility for resources in your
62 * new family. You can use @ref ResourcesConfigPage to easily create a 62 * new family. You can use @ref ResourcesConfigPage to easily create a
63 * KControl applet</li> 63 * KControl applet</li>
64 * <li>In your application, you can use @ref ResourceManager to keep track 64 * <li>In your application, you can use @ref ResourceManager to keep track
65 * of the resources in your family, and you can use @ref ResourceSelectDialog 65 * of the resources in your family, and you can use @ref ResourceSelectDialog
66 * to let the user select a single resource.</li> 66 * to let the user select a single resource.</li>
67 * </ul> 67 * </ul>
68 * 68 *
69 * When you want to add a new resource type to an existing resource family, 69 * When you want to add a new resource type to an existing resource family,
70 * you need to 70 * you need to
71 * <ul><li>Further subclass the family-specific Resource to implement 71 * <ul><li>Further subclass the family-specific Resource to implement
72 * resource type-specific operation</li> 72 * resource type-specific operation</li>
73 * <li>Subclass ResourceConfigWidget to provide a configuration widget 73 * <li>Subclass ResourceConfigWidget to provide a configuration widget
74 * for your new resource type</li> 74 * for your new resource type</li>
75 * <li>Provide a .desktop file so that the new resource type can be found 75 * <li>Provide a .desktop file so that the new resource type can be found
76 * automatically by the ResourceManager</li> 76 * automatically by the ResourceManager</li>
77 * </ul> 77 * </ul>
78 * 78 *
79 * Example: 79 * Example:
@@ -194,97 +194,97 @@ void ResourceExampleConfig::saveSettings( KRES::Resource *resource )
194 ResourceExample* res = dynamic_cast<ResourceExample *>( resource ); 194 ResourceExample* res = dynamic_cast<ResourceExample *>( resource );
195 if (res) { 195 if (res) {
196 res->setHost(mHostEdit->text()); 196 res->setHost(mHostEdit->text());
197 res->setPassword(mPasswordEdit->text()); 197 res->setPassword(mPasswordEdit->text());
198 } else 198 } else
199 kdDebug(5700) << "ERROR: ResourceExampleConfig::saveSettings(): no ResourceExample, cast failed" << endl; 199 kdDebug(5700) << "ERROR: ResourceExampleConfig::saveSettings(): no ResourceExample, cast failed" << endl;
200} 200}
201</pre> 201</pre>
202* <B>resourceexample.desktop</B>: 202* <B>resourceexample.desktop</B>:
203<pre> 203<pre>
204[Desktop Entry] 204[Desktop Entry]
205Type=Service 205Type=Service
206 206
207[Misc] 207[Misc]
208Encoding=UTF-8 208Encoding=UTF-8
209Name=Example Resource 209Name=Example Resource
210 210
211[Plugin] 211[Plugin]
212Type=exchange 212Type=exchange
213X-KDE-Library=resourceexample 213X-KDE-Library=resourceexample
214</pre> 214</pre>
215* <B>Makefile.am</B> 215* <B>Makefile.am</B>
216<pre> 216<pre>
217kde_module_LTLIBRARIES = resourceexample.la 217kde_module_LTLIBRARIES = resourceexample.la
218 218
219resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp 219resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp
220resourceexample_la_LDFLAGS= $(all_libraries) -module $(KDE_PLUGIN) 220resourceexample_la_LDFLAGS= $(all_libraries) -module $(KDE_PLUGIN)
221resourceexample_la_LIBADD= -lkderesources 221resourceexample_la_LIBADD= -lkderesources
222 222
223linkdir= $(kde_datadir)/resources/family 223linkdir= $(kde_datadir)/resources/family
224link_DATA= resourceexample.desktop 224link_DATA= resourceexample.desktop
225</pre> 225</pre>
226 * 226 *
227 * 227 *
228 */ 228 */
229 229
230/** 230/**
231 * A @ref Resource is a ... 231 * A @ref Resource is a ...
232 * 232 *
233 * A subclass should reimplement at least the constructor and the 233 * A subclass should reimplement at least the constructor and the
234k * @ref writeConfig method. 234k * @ref writeConfig method.
235 * 235 *
236 */ 236 */
237class Resource : public QObject 237class Resource : public QObject
238{ 238{
239 Q_OBJECT 239 Q_OBJECT
240 240
241 public: 241 public:
242 typedef QValueList<Resource *> List; 242 typedef Q3ValueList<Resource *> List;
243 243
244 /** 244 /**
245 * Constructor. Construct resource from config. 245 * Constructor. Construct resource from config.
246 * @param config Configuration to read persistence information from. 246 * @param config Configuration to read persistence information from.
247 * If config==0, create object using default settings. 247 * If config==0, create object using default settings.
248 */ 248 */
249 Resource( const KConfig* config ); 249 Resource( const KConfig* config );
250 250
251 /** 251 /**
252 * Destructor. 252 * Destructor.
253 */ 253 */
254 virtual ~Resource(); 254 virtual ~Resource();
255 255
256 /** 256 /**
257 * Write configuration information for this resource to a configuration 257 * Write configuration information for this resource to a configuration
258 * file. If you override this method, remember to call Resource::writeConfig 258 * file. If you override this method, remember to call Resource::writeConfig
259 * or Terrible Things(TM) will happen. 259 * or Terrible Things(TM) will happen.
260 * @param config Configuration to write persistence information to. 260 * @param config Configuration to write persistence information to.
261 */ 261 */
262 virtual void writeConfig( KConfig* config ); 262 virtual void writeConfig( KConfig* config );
263 263
264 /** 264 /**
265 * Open this resource, if it not already open. Increase the open 265 * Open this resource, if it not already open. Increase the open
266 * count of this object, and open the resource by calling @ref doOpen(). 266 * count of this object, and open the resource by calling @ref doOpen().
267 * This method may block while another thread is concurrently opening 267 * This method may block while another thread is concurrently opening
268 * or closing the resource. 268 * or closing the resource.
269 * 269 *
270 * Returns true if the resource was already opened or if it was opened 270 * Returns true if the resource was already opened or if it was opened
271 * successfully; returns false if the resource was not opened successfully. 271 * successfully; returns false if the resource was not opened successfully.
272 */ 272 */
273 bool open(); 273 bool open();
274 274
275 /** 275 /**
276 * Decrease the open count of this object, and if the count reaches 276 * Decrease the open count of this object, and if the count reaches
277 * zero, close this resource by calling @ref doClose(). 277 * zero, close this resource by calling @ref doClose().
278 * This method may block while another thread is concurrently closing 278 * This method may block while another thread is concurrently closing
279 * or opening the resource. 279 * or opening the resource.
280 */ 280 */
281 void close(); 281 void close();
282 282
283 /** 283 /**
284 * Returns whether the resource is open or not. 284 * Returns whether the resource is open or not.
285 */ 285 */
286 bool isOpen() const; 286 bool isOpen() const;
287 287
288 /** 288 /**
289 * Returns a unique identifier. The identifier is unique for this resource. 289 * Returns a unique identifier. The identifier is unique for this resource.
290 * It is created when the resource is first created, and it is retained 290 * It is created when the resource is first created, and it is retained