MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

Qt Service Framework on Symbian

How to register and unregister service plugins in S60?

All services must be registered for clients to be able to locate and use them. Symbian provides 3 different methods to register services.

Automatic registration

Registration phase is a little different compared to other platforms because of the authenticity of the provider is done during (un)registering phase based on the verification of VID/SID (vendor ID or secure ID). Durring automatic registration the VID/SID is set to 0. This method is suitable for services that aren't security critical.

To use automatic registration the XML file is copied to the imports directory of the service framework database server. In the pro file for example:

 xmlautoimport.path = /private/2002AC7F/import/
 xmlautoimport.sources = <service xml file>.xml
 DEPLOYMENT += xmlautoimport

Or in a symbian .pkg file by:

 "/epoc32/data/z/private/2002AC7F/import/<service xml file>.xml" - "c:\private\2002AC7F\import\<service xml file>.xml"

Secure registration

For security registration a tiny installer application can be implemented by the service provider. The installer application can then provide a VID/PID and is responsible for the registering (and the unregistering) of the service. The example code for the installer is shown below. The whole installer project can be found under examples/serviceinstaller_sfw_symbian.

 const QString filemanagerxml = "c:\\resource\\apps\\xmldata\\filemanagerservice.xml";
 const QString bluetoothxml = "c:\\resource\\apps\\xmldata\\bluetoothtransferservice.xml";
 const QString notemanagerxml = "c:\\resource\\apps\\xmldata\\notesmanagerservice.xml";

 int main(int argc, char *argv[])
 {
     QCoreApplication app(argc, argv);

     QServiceManager s;

         if (QFile::exists(filemanagerxml)) {
                 s.addService(filemanagerxml);
         } else {
                 s.removeService("FileManagerService");
         }

         if (QFile::exists(bluetoothxml)) {
                 s.addService(bluetoothxml);
         } else {
                 s.removeService("BluetoothTransferService");
         }

     if (QFile::exists(notemanagerxml)) {
                 s.addService(notemanagerxml);
         } else {
                 s.removeService("NotesManagerService");
         }
 }

If you want to create your own installer take a copy from the installer project (examples/serviceinstaller_sfw_symbian) and modify only the necessary parts e.g a target for your installer and define plugins which are deployed etc.

If the installer defines the VID (non-zero value) then the VID is stored to the database, otherwise SID is used. When unregistering the plugin the VID/SID verification is done to ensure that only the application which actually registered the service is only allowed to remove it. VID/SID is left to the database even the service has been unregistered. This prevents the exactly same way named services to be installed afterwards because the VID/SID information is locked to the service name.

More info about VID and SID can be found from

ROM build registration

For application built into the ROM the host tool servicedbgen must be used prior to building the ROM image to add the service to the database.

What's special from the security perspective?

There is only one database in S60 because both databases (user and system) are combined to the same database. The database is located behind the server's private folder, (c:\private\E3b48c24). This ensures the database can't be altered without Allfiles capability which isn't user-grantable (More about the capabilities: http://wiki.forum.nokia.com/index.php/Capabilities). That makes it impossible for example to replace the whole database with the new one which might contain malicious services.

Note! It doesn't matter which scope is used on Symbian as QService::UserScope and QService::SystemScope are mapped to the same database.

Directory structure

There are different implementations for the both emulator and device because emulator doesn't support multiple applications running at the same time, (Known issue: QTBUG-2950) prior to Symbian. The dll approach must be used in the emulator environment and the exe approach instead of dll in the real device.

Note! The greatest part of the S60 specific code is located under the symbian folder in a directory hierarchy of Service FW. ServiceDatabase class contains also S60 specific code and the DatabaseManager class has been replaced totally with the corresponding class.