MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

File Manager Plugin Example

Files:

This example shows how to write a service plugin for the Service Framework.

Registering the Service

The service can be registered by using the function addService() which takes a path to the XML file that describes the service, filemanagerservice.xml.

Writing the Plug-In

A Service plug-in is made by deriving a new plugin class from the QServicePluginInterface class then implementing the function QServicePluginInterface::createInstance().

The FileManager plugin example has a simple createInstance(). It only needs to create the appropriate object based on the interface name and return a pointer to it.

     if (descriptor.interfaceName() == "com.nokia.qt.examples.FileStorage")
         return new FileManagerStorage(this);
     else if (descriptor.interfaceName() == "com.nokia.qt.examples.FileTransfer")
         return new FileManagerTransfer(this);
     else
         return 0;

The functionality of the FileManager and the FileTransfer classes are in the separate classes FileManagerStorage and FileManagerTransfer respectively. The existing functions are merely test stubs to demonstrate the concept.