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.h24
1 files changed, 5 insertions, 19 deletions
diff --git a/microkde/kresources/resource.h b/microkde/kresources/resource.h
index 70b5613..ed5af96 100644
--- a/microkde/kresources/resource.h
+++ b/microkde/kresources/resource.h
@@ -19,49 +19,48 @@
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 <qvaluelist.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;
43class SyncWidgetContainer;
44 43
45/** 44/**
46 * @internal 45 * @internal
47 * @libdoc The KDE Resource library 46 * @libdoc The KDE Resource library
48 * 47 *
49 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this 48 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this
50 * interface, it is in constant flux. 49 * interface, it is in constant flux.
51 * 50 *
52 * The KDE Resource framework can be used to manage resources of 51 * The KDE Resource framework can be used to manage resources of
53 * different types, organized in families. The Resource framework 52 * different types, organized in families. The Resource framework
54 * is currently used for addressbook resources in libkabc and for 53 * is currently used for addressbook resources in libkabc and for
55 * calendar resources in libkcal. 54 * calendar resources in libkcal.
56 * 55 *
57 * 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
58 * <ul><li>Define a name for your resource family</li> 57 * <ul><li>Define a name for your resource family</li>
59 * <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
60 * in your application</li> 59 * in your application</li>
61 * <li>If needed, override the doOpen() and doClose() methods. 60 * <li>If needed, override the doOpen() and doClose() methods.
62 * <li> Provide a configuration possibility for resources in your 61 * <li> Provide a configuration possibility for resources in your
63 * new family. You can use @ref ResourcesConfigPage to easily create a 62 * new family. You can use @ref ResourcesConfigPage to easily create a
64 * KControl applet</li> 63 * KControl applet</li>
65 * <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
66 * 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
67 * to let the user select a single resource.</li> 66 * to let the user select a single resource.</li>
@@ -211,49 +210,49 @@ Name=Example Resource
211 210
212[Plugin] 211[Plugin]
213Type=exchange 212Type=exchange
214X-KDE-Library=resourceexample 213X-KDE-Library=resourceexample
215</pre> 214</pre>
216* <B>Makefile.am</B> 215* <B>Makefile.am</B>
217<pre> 216<pre>
218kde_module_LTLIBRARIES = resourceexample.la 217kde_module_LTLIBRARIES = resourceexample.la
219 218
220resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp 219resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp
221resourceexample_la_LDFLAGS= $(all_libraries) -module $(KDE_PLUGIN) 220resourceexample_la_LDFLAGS= $(all_libraries) -module $(KDE_PLUGIN)
222resourceexample_la_LIBADD= -lkderesources 221resourceexample_la_LIBADD= -lkderesources
223 222
224linkdir= $(kde_datadir)/resources/family 223linkdir= $(kde_datadir)/resources/family
225link_DATA= resourceexample.desktop 224link_DATA= resourceexample.desktop
226</pre> 225</pre>
227 * 226 *
228 * 227 *
229 */ 228 */
230 229
231/** 230/**
232 * A @ref Resource is a ... 231 * A @ref Resource is a ...
233 * 232 *
234 * A subclass should reimplement at least the constructor and the 233 * A subclass should reimplement at least the constructor and the
235 * @ref writeConfig method. 234k * @ref writeConfig method.
236 * 235 *
237 */ 236 */
238class Resource : public QObject 237class Resource : public QObject
239{ 238{
240 Q_OBJECT 239 Q_OBJECT
241 240
242 public: 241 public:
243 typedef QValueList<Resource *> List; 242 typedef QValueList<Resource *> List;
244 243
245 /** 244 /**
246 * Constructor. Construct resource from config. 245 * Constructor. Construct resource from config.
247 * @param config Configuration to read persistence information from. 246 * @param config Configuration to read persistence information from.
248 * If config==0, create object using default settings. 247 * If config==0, create object using default settings.
249 */ 248 */
250 Resource( const KConfig* config ); 249 Resource( const KConfig* config );
251 250
252 /** 251 /**
253 * Destructor. 252 * Destructor.
254 */ 253 */
255 virtual ~Resource(); 254 virtual ~Resource();
256 255
257 /** 256 /**
258 * Write configuration information for this resource to a configuration 257 * Write configuration information for this resource to a configuration
259 * file. If you override this method, remember to call Resource::writeConfig 258 * file. If you override this method, remember to call Resource::writeConfig
@@ -302,117 +301,104 @@ class Resource : public QObject
302 /** 301 /**
303 * Mark the resource as read-only. You can override this method, 302 * Mark the resource as read-only. You can override this method,
304 * but also remember to call Resource::setReadOnly(). 303 * but also remember to call Resource::setReadOnly().
305 */ 304 */
306 virtual void setReadOnly( bool value ); 305 virtual void setReadOnly( bool value );
307 306
308 /** 307 /**
309 * Returns, if the resource is read-only. 308 * Returns, if the resource is read-only.
310 */ 309 */
311 virtual bool readOnly() const; 310 virtual bool readOnly() const;
312 311
313 void setIncludeInSync( bool value ); 312 void setIncludeInSync( bool value );
314 bool includeInSync() const; 313 bool includeInSync() const;
315 /** 314 /**
316 * Set the name of resource.You can override this method, 315 * Set the name of resource.You can override this method,
317 * but also remember to call Resource::setResourceName(). 316 * but also remember to call Resource::setResourceName().
318 */ 317 */
319 virtual void setResourceName( const QString &name ); 318 virtual void setResourceName( const QString &name );
320 319
321 /** 320 /**
322 * Returns the name of resource. 321 * Returns the name of resource.
323 */ 322 */
324 virtual QString resourceName() const; 323 virtual QString resourceName() const;
325 324
326
327
328 virtual bool isSyncable() const = 0;
329
330
331 /** 325 /**
332 Sets, if the resource is active. 326 Sets, if the resource is active.
333 */ 327 */
334 void setActive( bool active ); 328 void setActive( bool active );
335 329
336 /** 330 /**
337 Return true, if the resource is active. 331 Return true, if the resource is active.
338 */ 332 */
339 bool isActive() const; 333 bool isActive() const;
340 334
341 friend class Factory; 335 friend class Factory;
342 friend class ManagerImpl; 336 friend class ManagerImpl;
343 337
344 /** 338 /**
345 Print resource information as debug output. 339 Print resource information as debug output.
346 */ 340 */
347 virtual void dump() const; 341 virtual void dump() const;
348 342
349 343
350 protected: 344 protected:
351 /** 345 /**
352 * Open this resource. When called, the resource must be in 346 * Open this resource. When called, the resource must be in
353 * a closed state. 347 * a closed state.
354 * 348 *
355 * Returns true if the resource was opened successfully; 349 * Returns true if the resource was opened successfully;
356 * returns false if the resource was not opened successfully. 350 * returns false if the resource was not opened successfully.
357 * 351 *
358 * The result of this call can be accessed later by @ref isOpen() 352 * The result of this call can be accessed later by @ref isOpen()
359 */ 353 */
360 virtual bool doOpen() { return true; } 354 virtual bool doOpen() { return true; }
361 355
362 /** 356 /**
363 * Close this resource. Pre-condition: resource is open. 357 * Close this resource. Pre-condition: resource is open.
364 * Post-condition: resource is closed. 358 * Post-condition: resource is closed.
365 */ 359 */
366 virtual void doClose() {} 360 virtual void doClose() {}
367 361
368 void setIdentifier( const QString& identifier ); 362 void setIdentifier( const QString& identifier );
369 void setType( const QString& type ); 363 void setType( const QString& type );
370 364
371 private: 365 private:
372 class ResourcePrivate; 366 class ResourcePrivate;
373 ResourcePrivate *d; 367 ResourcePrivate *d;
374}; 368};
375 369
376class PluginFactoryBase : public KLibFactory 370class PluginFactoryBase : public KLibFactory
377{ 371{
378 public: 372 public:
379 virtual Resource *resource( const KConfig *config, bool syncable ) = 0; 373 virtual Resource *resource( const KConfig *config) = 0;
380 374
381 virtual ConfigWidget *configWidget( QWidget *parent ) = 0; 375 virtual ConfigWidget *configWidget( QWidget *parent ) = 0;
382 376
383 virtual SyncWidgetContainer *syncWidgetContainer() = 0;
384
385 protected: 377 protected:
386 virtual QObject* createObject( QObject*, const char*, const char*, 378 virtual QObject* createObject( QObject*, const char*, const char*,
387 const QStringList & ) 379 const QStringList & )
388 { 380 {
389 return 0; 381 return 0;
390 } 382 }
391}; 383};
392 384
393template<class TR,class TC, class TS> 385template<class TR,class TC>
394class PluginFactory : public PluginFactoryBase 386class PluginFactory : public PluginFactoryBase
395{ 387{
396 public: 388 public:
397 Resource *resource( const KConfig *config, bool syncable ) 389 Resource *resource( const KConfig *config)
398 { 390 {
399 return new TR( config, syncable ); 391 return new TR( config );
400 } 392 }
401 393
402 ConfigWidget *configWidget( QWidget *parent ) 394 ConfigWidget *configWidget( QWidget *parent )
403 { 395 {
404 return new TC( parent ); 396 return new TC( parent );
405 } 397 }
406
407 SyncWidgetContainer *syncWidgetContainer()
408 {
409 return new TS();
410 }
411
412}; 398};
413 399
414 400
415 401
416} 402}
417 403
418#endif 404#endif