Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
RPC Interface
RPCInterface.png


The RPCInterface can be used by plugins to call functions from other OpenFlipper plugins. The calls are internally transformed into scripting calls and passed to the other plugins.

You can directly connect signals and slots via the Plugin Connection Interface .

The interface itself contains two basic functions which can be used to check if another plugin exists (RPCInterface::pluginExists()) or if a specific function exists in another plugin (RPCInterface::functionExists()). Both functions get the clean name of the plugin to check. To get that name, just open the script editor in OpenFlipper which lists all plugins and their available functions.

Example Code for plugins:

bool isPluginAvailable;
emit pluginExists ("scripting", isPluginAvailable);

Example Code for functions:

bool isFunctionAvailable;
emit functionExists ("scripting", "showScriptInEditor(QString)", isFunctionAvailable);

In addition to these basic functions there is a set of template functions in RPCWrappers.hh which can be used to directly call a function from another plugin via the scripting system. This requires the parameters to be registered to the QT MetaObject system which is already done for the most common types of variables.

For calling a function you can use RPC::callFunction() or RPC::callFunctionValue() if the called function returns a value. These functions get the pluginName and the function name and call the requested function via scripting. It is possible to supply additional parameters to these functions that will be passed to the called function.

Example code:

// call without getting return value
RPC::callFunction ("pluginName", "FunctionName");
// call without getting return value and suplying a parameter
int parameter1
RPC::callFunction ("pluginName", "FunctionName", parameter1);
// call with getting return value which is defined as the template parameter
QString parameter2
bool value = RPC::callFunctionValue<bool> ("pluginName", "FunctionName", parameter1, parameter2);

To use the RPCInterface:

  • include RPCInterface.hh in your plugins header file
  • derive your plugin from the class RPCInterface
  • add Q_INTERFACES(RPCInterface) to your plugin class
  • And add the signals or slots you want to use to your plugin class (You don't need to implement all of them)
Note
Multithreading: You can call any script function from any thread, but the script will be executed on the main thread.