| Home · All Classes · Annotated · Functions |
#include <QDrmContent>
Inherits QObject and QContent.
QDrmContent provides the interface through which applications can request access to DRM protected content and notify the DRM agent of usage information when access has been granted. Applications wishing to access DRM content need to create an instance of QDrmContent and connect to the rightsExpired signal which will notify the application if access rights to open content expires during use. QDrmContent objects can be reused for sequential access to different content but an individual QDrmContent object will only allow access to a single item of content at a time, concurrent access to multiple content items requires a QDrmContent object for each item of content.
Once a QDrmContent object has been initialised with an item of content access to content can be requested using the the requestLicence method. If requestLicence returns true access to the content has been granted and it is possible to access the content using the standard Qt file API. Calling releaseLicence will relinquish access rights to the content, this is not neccessary as QDrmContent calls this implicitly when destroyed or new content is assigned, but it's recommended in cases when neiher action occurs immediately after usage ends to free resources.
If no permission type is specified when requesting a licence the default permission type specificed during construction is used. When the a licence is successfully requested with a permission type specified the default is changed to that permission type.
To enforce time and use based rights the DRM agent needs to notified of the number of uses and the duration of each use. The renderStarted, renderPaused and renderStopped slots track this information and should be called as appropriate when usage state changes.
An implementation for a simple media player would be:
class MediaPlayer : public QWidget
{
public:
MediaPlayer( QWidget *parent = 0 );
public slots:
void open( const QContent &content );
void play();
void pause();
void stop();
void nextTrack();
void previousTrack();
void removeFromPlaylist( const QContent &content );
signals:
void playing();
void paused();
void stopped();
private slots:
void rightsExpired( const QDrmContent &content );
private:
QDrmContent openContent;
};
MediaPlayer::MediaPlayer( QWidget *parent = 0 )
: QWidget( parent )
{
// Perform initialisation.
connect( this, SIGNAL(playing()), &openContent, SLOT(renderStarted()));
connect( this, SIGNAL(paused()), &openContent, SLOT(renderPaused()));
connect( this, SIGNAL(stopped()), &openContent, SLOT(renderStopped()));
connect( &openContent, SIGNAL(rightsExpired(const QDrmContent&)), this, SLOT(rightsExpired(const QDrmContent&)) );
}
void MediaPlayer::open( const QContent &content )
{
if( openContent.requestLicence( content, QDrmContent::Play ) )
{
// Open file as normal.
}
else
rightsExpired( openContent );
}
void MediaPlayer::rightsExpired( const QDrmContent &content )
{
removeFromPlaylist( openContent );
nextTrack();
}
It is not neccessary to notify the user within an application that the rights to content have expired as when content expires a qcop message is sent to a service application which will perform the notification.
Represents methods for activating DRM protected content.
| Constant | Value | Description |
|---|---|---|
| QDrmContent::NoActivation | 0x000 | There is no way in which the content can be activated. |
| QDrmContent::RightsIssuerUrl | 0x001 | The rights issuer has a web page from which rights may be obtained. |
Flags indicating all available options for activating DRM protected content.
Synonym for QFlags< QDrmContent::ActivationMethod >
Synonym for QFlags< QDrmContent::PermissionType >
Represents the type of consumption permission is being sought for.
| Constant | Value | Description |
|---|---|---|
| QDrmContent::Unrestricted | 0x00 | Permission to open content for any use. This will never be granted for DRM protected content. |
| QDrmContent::Play | 0x01 | Playback permission for media files. |
| QDrmContent::Display | 0x02 | Display permission for images and documents. |
| QDrmContent::Execute | 0x04 | Execute permission for applications. |
| QDrmContent::Print | 0x08 | Print permission for images and documents. |
| QDrmContent::Export | 0x10 | Export data to external device for render (eg Playback on a television). OMA DRM v2 only. |
Represents the current state of a render or usage of content.
| Constant | Value | Description |
|---|---|---|
| QDrmContent::Started | 0 | Content is currently being rendered. The time in which the content is in this state counts towards any timed usage allowance. |
| QDrmContent::Paused | 2 | Rendering of the content has started but been interrupted. Continuing the render will not count as an additional use and time does not count towards timed usage allowance. |
| QDrmContent::Stopped | 1 | The content is not currently being rendered. Starting a render from this state is considered a use. |
Creates a new uninitialised QDrmContent object and sets the default permission type to permission.
Creates a new QDrmContent object, initialises it with content and sets the default permission type to permission.
Creates a new QDrmContent object, initialises it with the content with contentId and sets the default permission type to permission.
Creates a new QDrmContent object, initialises it with the content with fileName and sets the default permission type to permission.
Destroys a QDrmContent object.
Initiates an attempt to activate content using an ActivationMethod.
Returns true if method is a valid method for activating content.
Returns the available options for activating content.
Returns the default permission type or the permission type of the last requested licence.
See also setPermissionType().
Releases the currently held content licence. No further file access will be possible after this unless a new licence is requested.
Notifies the DRM agent that rendering of the content has been paused.
Notifies the DRM agent that rendering of the content has started.
Returns the current render state.
Signals that the render state of content has changed.
Notifies the DRM agent that rendering of the content has ended.
Requests a licence for DRM content with the currently assigned permission type. This must be called and return successfully before protected content can be accessed.
If handover is true the render state will initially be set to Paused. This allows usage to begin in one context, be stopped and started again in another context without counting an additional usage.
This is an overloaded member function, provided for convenience.
Requests a licence for DRM content with permission permissionType. This must be called and return successfully before protected content can be accessed.
If handover is true the render state will initially be set to Paused. This allows usage to begin in one context, be stopped and started again in another context without counting an additional usage.
This is an overloaded member function, provided for convenience.
Requests a licence for DRM content with pthe currently assigned permission type. This is equivalent to assigning content to an instance of QDrmContent and then calling requestLicence().
If handover is true the render state will initially be set to Paused. This allows usage to begin in one context, be stopped and started again in another context without counting an additional usage.
This is an overloaded member function, provided for convenience.
Requests a licence for DRM content with permission permissionType. This is equivalent to assigning content to an instance of QDrmContent and then calling requestLicence( PermissionType ). If no licence for the content can be obtained the state of the QDrmContent instance will remain unchanged.
If handover is true the render state will initially be set to Paused. This allows usage to begin in one context, be stopped and started again in another context without counting an additional usage.
Signals that the rights to content have expired and that any rendering of that content should stop immediately.
Checks if there are current valid permission rights to render content.
Returns true if the rights are valid.
Sets the default permission type to type.
This will only succeed if no licence is currently held.
See also permissionType().
Assign a new QContent content to this QDrmContent object. If there is a licence held for the previous content it will be released.
PermissionFlags for specifying all permissions.
| Copyright © 2006 Trolltech | Trademarks | Qtopia 4.1.7 |