Inter plugin communication

Roberto Raggi roberto at
Fri May 20 13:06:05 UTC 2005

Hi Andreas,

the trick is to introduce a small library that contains the common 
interfaces+a singleton. For instance,

in libshared

struct MyInterface {
   virtual ~MyInterface() {}

   virtual void my_signal() = 0; // the is a signal

   virtual QObject *objectCast() = 0;

// static reference here.
   static MyInterface *instance();
   static void setInstance(MyInterface *iface);

in plugin1.cpp
class MyImpl: public QObject, public MyInterface

   virtual QObject *objectCast() { return this; }

  virtual void my_signal();


in plugin2.cpp

after the kdevcore is initialized it's safe to call MyInterface::instance().. 
because all the global-plugins are loaded. Or if it's a project-scope plugin 
you have to wait for the signal projectInitialized() 

connect(MyInterface::instance()->my_signal(), SIGNAL(initialized()), 
		this, SLOT(useMe()));

ciao robe

On Friday 20 May 2005 12:25, Andras Mantia wrote:
> Hi,
>  I'm having some problems with KDevelop interfaces. ;-) The main problem
> is that I don't know how can I communicate between two plugins. Here
> are two examples:
> 1) Let's have a global plugin called A which wants to print out some
> text to a message view. We have plugin B, which is a message-view
> plugin who is able to process some text and print it out in a nice
> form. Plugins A and B are completely independent, plugin A should
> compile without plugin B being present and vice versa.
> Taking the above into the account, how can:
> - plugin A send some data to plugin B?
> - plugin A request the showing of the main widget of plugin B?
> I'm afraid this won't work without creating another KDevelop interface
> for "message-view" style plugins, am I right?
> If it is so, I think we will need this and possibly more such
> interfaces. Am I allowed to add those to the platform?
> 2) The same plugin A wants to send some data to a languagesupport
> plugin.  How can this be done? I mean the data might be processed
> differently depending on what part is active (editor, VPL widget, HTML
> widget) and it might depend also on the type of the language/project
> (C++, Quanta, whatever).
> This is about executing a user action. A user action can output some
> text which can be:
> - inserted as-is in the currently edited document
> - as HTML in our VPL widget
> - inserted in the currently edited document, but further steps made
> (like bringing up a dialog to edit the inserted tag).
> It is clear that it is not wise to do all the above stuff in plugin A
> (the user toolbars) as this way the plugin will not be a generic one.
> Any idea how to solve it?
> Andras

More information about the KDevelop-devel mailing list