This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[SOLVED] Can not create plugin instance

Tags: None
(comma "," separated)
Spomky
Registered Member
Posts
15
Karma
0
OS
Hi,
I want to load plugins but I have the following error:
The service "Dummy Passwords Manager" does not provide "libFusible::Plugin" interface with keyword ""
I do not understand where is the error/are the errors.

Can you help me please?

My .desktop file:
Code: Select all
[Desktop Entry]
Name=Dummy Passwords Manager
Comment=Just for test.
Icon=dummy
Type=Service
ServiceTypes=libFusible/Plugin
X-KDE-Library=libfusible_plugin_dummy_passwordsmanager
X-KDE-PluginInfo-Author=Spomky
X-KDE-PluginInfo-Email=spomky@gmail.com
X-KDE-PluginInfo-Name=libfusible-plugin-dummy-passwordsmanager
X-KDE-PluginInfo-Version=1.1
X-KDE-PluginInfo-Website=https://edge.launchpad.net/fusible
X-KDE-PluginInfo-Category=Plugins
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPLv3
X-KDE-PluginInfo-EnabledByDefault=true
X-libFusible-Version=2
X-libFusible-Type=Password


My plugin:
Code: Select all
#ifndef __LIBFUSIBLE_PLUGIN_DUMMY_PASSWORDSMANAGER_H__
   #define __LIBFUSIBLE_PLUGIN_DUMMY_PASSWORDSMANAGER_H__
   
   #include "libfusiblePlugin.h"
   
   class DummyPM : public libFusible::Plugin
   {
      Q_OBJECT
      public:
         DummyPM( QObject* parent = NULL , const QStringList& arguments = QStringList() );
         ~DummyPM( void ){};
         
         bool getPassword( const QString& , QString& );
         QString getPassword( const QString& ) const;
         bool setPassword( const QString& , const QString& ) {return false;};
         
         bool getMap( const QString& , QMap& ) const {return false;};
         QMap getMap( const QString& ) const {return QMap();};
         bool setMap( const QString& , const QMap ) {return false;};
         
         bool getEntry( const QString& , QByteArray& ) const {return false;};
         QByteArray getEntry( const QString& ) const {return QByteArray();};
         bool setEntry( const QString& , const QByteArray ) {return false;};
         
         bool canGetPassword( void ) const {return true;};
         bool canSetPassword( void ) const {return false;};
         bool canGetMap( void ) const {return false;};
         bool canSetMap( void ) const {return false;};
         bool canGetEntry( void ) const {return false;};
         bool canSetEntry( void ) const {return false;};
   };

#endif //__LIBFUSIBLE_PLUGIN_DUMMY_PASSWORDSMANAGER_H__


Code: Select all
#include "libfusible_plugin_dummy_passwordsmanager.h"
#include

K_EXPORT_COMPONENT_FACTORY( libfusible_plugin_dummy_passwordsmanager, KGenericFactory( "libfusible_plugin_dummy_passwordsmanager" ) )

DummyPM::DummyPM( QObject* parent , const QStringList& arguments ) : libFusible::Plugin(parent,arguments)
{
   
}


bool DummyPM::getPassword( const QString& , QString& password )
{
   password = "dummy";
   return true;
}


QString DummyPM::getPassword( const QString& ) const
{
   return "dummy";
}

#include "moc_libfusible_plugin_dummy_passwordsmanager.cpp"


The interface:
Code: Select all
#ifndef __LIBFUSIBLE_PLUGIN_H__
   #define __LIBFUSIBLE_PLUGIN_H__
   
   #include
   #include
   #include
   #include
   #include
   #include
   
   
   #ifndef X_LIBFUSIBLE_VERSION
      #define X_LIBFUSIBLE_VERSION "[X-libFusible-Version]==2"
   #endif
   
   #ifdef KDE_EXPORT
      #define LIBFUSIBLE_PLUGIN_EXPORT KDE_EXPORT
   #else
      #define LIBFUSIBLE_PLUGIN_EXPORT
   #endif
   
   namespace libFusible
   {
      
      class LIBFUSIBLE_PLUGIN_EXPORT Plugin : public QObject
      {
         Q_OBJECT
         public:
            Plugin( QObject* parent = NULL , const QStringList& = QStringList() ):QObject(parent){};
            virtual ~Plugin(){};
            
            virtual bool getPassword( const QString& , QString& ) {return false;};
            virtual QString getPassword( const QString& ) const {return QString::null;};
            virtual bool setPassword( const QString& , const QString& ) {return false;};
            
            virtual bool getMap( const QString& , QMap& ) const {return false;};
            virtual QMap getMap( const QString& ) const {return QMap();};
            virtual bool setMap( const QString& , const QMap ) {return false;};
            
            virtual bool getEntry( const QString& , QByteArray& ) const {return false;};
            virtual QByteArray getEntry( const QString& ) const {return QByteArray();};
            virtual bool setEntry( const QString& , const QByteArray ) {return false;};
            
            virtual bool canGetPassword( void ) const {return false;};
            virtual bool canSetPassword( void ) const {return false;};
            virtual bool canGetMap( void ) const {return false;};
            virtual bool canSetMap( void ) const {return false;};
            virtual bool canGetEntry( void ) const {return false;};
            virtual bool canSetEntry( void ) const {return false;};
      };
   }; //END namespace libFusible
#endif // __LIBFUSIBLE_PLUGIN_H__


The function that try to load plugins:
Code: Select all
void PluginManager::loadPlugins( void )
{
   KService::List pluginList = this->getPlugins( X_LIBFUSIBLE_VERSION );
   
   for(KService::List::ConstIterator iter = pluginList.constBegin(); iter != pluginList.constEnd(); ++iter)
   {
      QString error;
      KService::Ptr service = *iter;
      if( this->isPluginEnabled( KPluginInfo(service) ) )
      {
         libFusible::Plugin* plugin = service->createInstance(this,QList(),&error);
         if ( plugin != NULL )
         {
            loadedPlugins.insert(service->name(),plugin);
         }
         else
            KMessageBox::error(NULL,"Plugin* is not valid: "+error);
      }
   }
}
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Try installing a Service Type file also. I had to create a plugin interface not too long ago for the KControl port to KDE 4, and remember having to do this. Ensure that you run kbuildsycoca4 after installing it as well. You also need to have a shared library between the application and the plugins, that contains the Interface also, otherwise it won't work either.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Spomky
Registered Member
Posts
15
Karma
0
OS
I solved my problem. I have added #include in the header of the plugin interface.
I think that KDE_EXPORT was not defined so my interface was not correctly shared and that is why I was unable to create an instance.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell