summaryrefslogtreecommitdiffabout
path: root/microkde/kresources/resource.h
Side-by-side diff
Diffstat (limited to 'microkde/kresources/resource.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/resource.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/microkde/kresources/resource.h b/microkde/kresources/resource.h
index 580b5d1..70b5613 100644
--- a/microkde/kresources/resource.h
+++ b/microkde/kresources/resource.h
@@ -185,232 +185,234 @@ void ResourceExampleConfig::loadSettings( KRES::Resource *resource )
ResourceExample* res = dynamic_cast<ResourceExample *>( resource );
if (res) {
mHostEdit->setText( res->host() );
mPasswordEdit->setText( res->password() );
} else
kdDebug(5700) << "ERROR: ResourceExampleConfig::loadSettings(): no ResourceExample, cast failed" << endl;
}
void ResourceExampleConfig::saveSettings( KRES::Resource *resource )
{
ResourceExample* res = dynamic_cast<ResourceExample *>( resource );
if (res) {
res->setHost(mHostEdit->text());
res->setPassword(mPasswordEdit->text());
} else
kdDebug(5700) << "ERROR: ResourceExampleConfig::saveSettings(): no ResourceExample, cast failed" << endl;
}
</pre>
* <B>resourceexample.desktop</B>:
<pre>
[Desktop Entry]
Type=Service
[Misc]
Encoding=UTF-8
Name=Example Resource
[Plugin]
Type=exchange
X-KDE-Library=resourceexample
</pre>
* <B>Makefile.am</B>
<pre>
kde_module_LTLIBRARIES = resourceexample.la
resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp
resourceexample_la_LDFLAGS= $(all_libraries) -module $(KDE_PLUGIN)
resourceexample_la_LIBADD= -lkderesources
linkdir= $(kde_datadir)/resources/family
link_DATA= resourceexample.desktop
</pre>
*
*
*/
/**
* A @ref Resource is a ...
*
* A subclass should reimplement at least the constructor and the
* @ref writeConfig method.
*
*/
class Resource : public QObject
{
Q_OBJECT
public:
typedef QValueList<Resource *> List;
/**
* Constructor. Construct resource from config.
* @param config Configuration to read persistence information from.
* If config==0, create object using default settings.
*/
Resource( const KConfig* config );
/**
* Destructor.
*/
virtual ~Resource();
/**
* Write configuration information for this resource to a configuration
* file. If you override this method, remember to call Resource::writeConfig
* or Terrible Things(TM) will happen.
* @param config Configuration to write persistence information to.
*/
virtual void writeConfig( KConfig* config );
/**
* Open this resource, if it not already open. Increase the open
* count of this object, and open the resource by calling @ref doOpen().
* This method may block while another thread is concurrently opening
* or closing the resource.
*
* Returns true if the resource was already opened or if it was opened
* successfully; returns false if the resource was not opened successfully.
*/
bool open();
/**
* Decrease the open count of this object, and if the count reaches
* zero, close this resource by calling @ref doClose().
* This method may block while another thread is concurrently closing
* or opening the resource.
*/
void close();
/**
* Returns whether the resource is open or not.
*/
bool isOpen() const;
/**
* Returns a unique identifier. The identifier is unique for this resource.
* It is created when the resource is first created, and it is retained
* in the resource family configuration file for this resource.
* @return This resource's identifier
*/
QString identifier() const;
/**
* Returns the type of this resource.
*/
QString type() const;
/**
* Mark the resource as read-only. You can override this method,
* but also remember to call Resource::setReadOnly().
*/
virtual void setReadOnly( bool value );
/**
* Returns, if the resource is read-only.
*/
virtual bool readOnly() const;
+ void setIncludeInSync( bool value );
+ bool includeInSync() const;
/**
* Set the name of resource.You can override this method,
* but also remember to call Resource::setResourceName().
*/
virtual void setResourceName( const QString &name );
/**
* Returns the name of resource.
*/
virtual QString resourceName() const;
virtual bool isSyncable() const = 0;
/**
Sets, if the resource is active.
*/
void setActive( bool active );
/**
Return true, if the resource is active.
*/
bool isActive() const;
friend class Factory;
friend class ManagerImpl;
/**
Print resource information as debug output.
*/
virtual void dump() const;
protected:
/**
* Open this resource. When called, the resource must be in
* a closed state.
*
* Returns true if the resource was opened successfully;
* returns false if the resource was not opened successfully.
*
* The result of this call can be accessed later by @ref isOpen()
*/
virtual bool doOpen() { return true; }
/**
* Close this resource. Pre-condition: resource is open.
* Post-condition: resource is closed.
*/
virtual void doClose() {}
void setIdentifier( const QString& identifier );
void setType( const QString& type );
private:
class ResourcePrivate;
ResourcePrivate *d;
};
class PluginFactoryBase : public KLibFactory
{
public:
virtual Resource *resource( const KConfig *config, bool syncable ) = 0;
virtual ConfigWidget *configWidget( QWidget *parent ) = 0;
virtual SyncWidgetContainer *syncWidgetContainer() = 0;
protected:
virtual QObject* createObject( QObject*, const char*, const char*,
const QStringList & )
{
return 0;
}
};
template<class TR,class TC, class TS>
class PluginFactory : public PluginFactoryBase
{
public:
Resource *resource( const KConfig *config, bool syncable )
{
return new TR( config, syncable );
}
ConfigWidget *configWidget( QWidget *parent )
{
return new TC( parent );
}
SyncWidgetContainer *syncWidgetContainer()
{
return new TS();
}
};
}
#endif