Qtopia Home - Classes - Hierachy - Annotated - Functions - Licenses - Reference

Qtopia Desktop Plug-ins

Architecture and Plug-ins

Qtopia Desktop has modular and flexible design allowing end-users to easily install plug-ins to integrate Qtopia into their local environment.

Developers access this architecture by creating a plugin for Qtopia Desktop which is written by implementing interfaces the defined by Qtopia Desktop.

The following table describes available interfaces:

Interface Description
PlugInterface Visual plug-ins for entering information or transfering documents
SyncAppInterface, MergeInterface Synchronize data and files
ImportInterface Import external data to Qtopia
ExportInterface Export data from Qtopia (not yet supported)

Qtopia Desktop provides each plug-in with access to the CenterInterface class which allows a plug-in to use the functionality provided by Qtopia Desktop.

On startup Qtopia Desktop:

Implementing a Plug-in

Each plug-in implementation needs to define some pure virtual methods defined in the plug-in hierarchy. Each plug-in must define the following methods:

    QRESULT queryInterface( const QUuid&, QUnknownInterface** );
    Q_REFCOUNT

    QString name() const;
    QString description() const;
    QString version() const;
    QString author() const;

The name() method and queryInterface() are the most important while description(), version() and author() methods are all purely informational and not currently displayed by Qtopia Desktop.

The PluginInterface::name() method defines the display name shown in the plug-in selection area on the left hand side of the screen. The name() method is purely descriptive for all other interfaces.

The implementation of queryInterface() allows Qtopia Desktop determine what type of interface a plug-in implements when it registers the plug-in at startup.

In the .cpp file for the interface, the following code must be present

Q_EXPORT_INTERFACE()
{
    Q_CREATE_INSTANCE( AddressBook )
}

  QRESULT AddressBook::queryInterface( const QUuid &uuid,
    QUnknownInterface** iface )
{
    *iface = 0;
    if ( uuid == IID_QUnknown )
        *iface = (QUnknownInterface*) (PluginInterface*) this;
    else if ( uuid == IID_QComponentInformation )
        *iface = (QComponentInformationInterface*)(PluginInterface *) this;
    else if ( uuid == IID_PalmtopCenterPlugin )
        *iface = (PluginInterface*)this;
    else if ( uuid == IID_SyncAppInterface )
        *iface = (SyncAppInterface*)this;
    else if ( uuid == IID_MergeInterface )
        *iface = (MergeInterface*)this;
    else
        return QE_NOINTERFACE;

    (*iface)->addRef();
    return QS_OK;
}

The implementation of the queryInterface() method depends on the interfaces a plug-in is implementing. Each plug-in should have only one implementation of queryInterface(). However, each plug-in may implement more than one interface as shown above and multiple interfaces may be implemented by the same class. All interfaces other than SyncAppInterface implement both QUnknownInterface and QComponentInformationInterface and should return as such.


Copyright © 2005 Trolltech Trademarks
Qtopia version 2.2.0