[webkit-qt] Platform plugin interface

Simon Hausmann simon.hausmann at nokia.com
Fri Apr 30 06:36:57 PDT 2010


Hi,

on the phone we discussed the option of a platform plugin. I'd like to
recommend the following design for that:

1) Define the interface as a Qt interface:

WebCore/platform/qt/PlatformPluginInterface.h:

struct QWebKitPlatformPluginInterface
{
   virtual ~QWebKitPlatformPluginInterface() {}
   virtual void doSomething() = 0;
   ...
};

Q_DECLARE_INTERFACE(QWebKitPlatformPluginInterface, "com.nokia.Qt.WebKit.PlatformPluginInterface/1.0")

2) Copy (yes, copy) the header file into your plugin implementation source tree, implement it there and export it using Q_EXPORT_PLUGIN2.

3) Use QPluginLoader in WebCore to load the plugin, get a pointer to the plugin implementation using instance() and do

    QWebKitPlatformPluginInterface* iface = qobject_cast<QWebKitPlatformPluginInterface*>(loader->instance());


If you change the interface, make sure to also change the string passed to Q_DECLARE_INTERFACE. That will make
sure that the qobject_cast will return a null pointer if the plugin implementation was _compiled_ against a
different interface.

See also examples/tools/plugandpaint in Qt for an example of how to use the Qt plugin interfaces.


Good luck :)


Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.webkit.org/pipermail/webkit-qt/attachments/20100430/26472158/attachment-0001.bin>


More information about the webkit-qt mailing list