MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

The Meego Resource Policy Qt API: Libresourceqt



This library is used to request resources from the Meego Policy Resource Manager, by means of two classes: ResourcePolicy::Resource and ResourcePolicy::ResourceSet.

The Libresourceqt API provides:

Classes in Libresourceqt API
Name Content
ResourcePolicy::ResourceSet The ResourceSet is the main class whose instances should be filled with resources needed by the application. Then use the ResourceSet's methods to acquire those resources.
ResourcePolicy::Resource The ResourceSet is filled with instances of subclasses of the class Resource, for example AudioResource.

Getting started

Say that your application is a player (if not a player than use another suitable application class, please see "Further Information" section), then in order to use the Resource Policy Library, you first need to create the ResourcePolicy::ResourceSet like this:

Then to add resources to the set, use the ResourceSet::addResource() method like this:


If you want to pre-populate the AudioResource with the audio group (it is a good idea) and other audio parameters, you can create an audio object yourself and then give that to the ResourcePolicy::ResourceSet. Note that you should NOT free this object. The ResourcePolicy::ResourceSet takes ownership of this pointer.

 ResourcePolicy::AudioResource*audioResource = new ResourcePolicy::AudioResource("player");

Calling the ResourcePolicy::ResourceSet::deleteResource() method will remove and delete the object. Then when you want to acquire the modified ResourcePolicy::ResourceSet you simply use the ResourcePolicy::ResourceSet::acquire() method, like this:

 QObject::connect(mySet, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)), this, SLOT(acquireOkHandler(QList<ResourcePolicy::Resource>)));
 QObject::connect(mySet, SIGNAL(resourcesDenied()), this, SLOT(acquireDeniedHandler()));

You should also connect to the ResourcePolicy::ResourceSet::lostResources() signal like this:

 QObject::connect(mySet, SIGNAL(lostResources()), this, SLOT(lostResourcesHandler()));

This signal tells you when you should stop using the resources you have asked for. So it is important that you connect to it.

To modify the properties of the resources you can use the ResourcePolicy::ResourceSet::resource() method.

Further information

For a more detailed guide see the MeeGo Policy Framework Developer Guide (PDF).

Copyright (C) 2011 Nokia Corporation.
LGPL This file is part of libresourceqt
MeeGo 1.2 Harmattan API