Creating a new plugin for Soprano is pretty easy. Imagine, for example, we want to write a new Backend plugin. We simply create a class that inherits from QObject and the Soprano::Backend interface and use the Q_INTERFACES macro to tell Qt's meta-object system about the new plugin. We then export the plugin via the Q_EXPORT_PLUGIN2 macro in the source file.
An example would look as follows:
class MyBackend : public QObject, public Soprano::Backend { Q_OBJECT Q_INTERFACES(Soprano::Backend) public: StorageModel* createModel( const QStringList& options = QStringList() ) const; bool deleteModelData( const BackendSettings& settings ) const; BackendFeatures supportedFeatures() const; };
In the implementation file export the plugin so it can be picked up by the plugin loading framework:
Q_EXPORT_PLUGIN2(soprano_mybackend, MyBackend)
The plugin then needs to be linked as a library and installed into the lib/soprano target folder.
Finally we need to create a desktop file describing the plugin. The minimal desktop file looks as follows (for details see Soprano Plugin Desktop Files):
[Desktop Entry] Encoding=UTF-8 X-Soprano-Library=libsoprano_mybackend X-Soprano-Version=2.1 Type=Service ServiceTypes=Soprano/Backend Name=MyBackend Comment=My very cool and fast Soprano backend
The desktop file should be installed into share/soprano/plugins so the Soprano::PluginManager will find it.
All plugin interfaces inherit from Soprano::Error::ErrorCache for error handling and subclasses should use Soprano::Error::ErrorCache::clearError() and Soprano::Error::ErrorCache::setError() to report the status.