Home · All Classes · Annotated · Functions

QDrmContent Class Reference

#include <QDrmContent>

Inherits QObject and QContent.

Public Types

Public Functions

Public Slots

Signals

Static Public Members

Additional Inherited Members


Detailed Description

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.


Member Type Documentation

enum QDrmContent::ActivationMethod

Represents methods for activating DRM protected content.

ConstantValueDescription
QDrmContent::NoActivation0x000There is no way in which the content can be activated.
QDrmContent::RightsIssuerUrl0x001The rights issuer has a web page from which rights may be obtained.

typedef QDrmContent::ActivationOptions

Flags indicating all available options for activating DRM protected content.

Synonym for QFlags< QDrmContent::ActivationMethod >

typedef QDrmContent::PermissionFlags

Synonym for QFlags< QDrmContent::PermissionType >

enum QDrmContent::PermissionType

Represents the type of consumption permission is being sought for.

ConstantValueDescription
QDrmContent::Unrestricted0x00Permission to open content for any use. This will never be granted for DRM protected content.
QDrmContent::Play0x01Playback permission for media files.
QDrmContent::Display0x02Display permission for images and documents.
QDrmContent::Execute0x04Execute permission for applications.
QDrmContent::Print0x08Print permission for images and documents.
QDrmContent::Export0x10Export data to external device for render (eg Playback on a television). OMA DRM v2 only.

enum QDrmContent::RenderState

Represents the current state of a render or usage of content.

ConstantValueDescription
QDrmContent::Started0Content is currently being rendered. The time in which the content is in this state counts towards any timed usage allowance.
QDrmContent::Paused2Rendering 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::Stopped1The content is not currently being rendered. Starting a render from this state is considered a use.


Member Function Documentation

QDrmContent::QDrmContent ( PermissionType permission = Unrestricted )

Creates a new uninitialised QDrmContent object and sets the default permission type to permission.

QDrmContent::QDrmContent ( const QContent & content, PermissionType permission = Unrestricted )

Creates a new QDrmContent object, initialises it with content and sets the default permission type to permission.

QDrmContent::QDrmContent ( QContentId contentId, PermissionType permission = Unrestricted )

Creates a new QDrmContent object, initialises it with the content with contentId and sets the default permission type to permission.

QDrmContent::QDrmContent ( const QString & fileName, PermissionType permission = Unrestricted )

Creates a new QDrmContent object, initialises it with the content with fileName and sets the default permission type to permission.

QDrmContent::~QDrmContent ()   [virtual]

Destroys a QDrmContent object.

bool QDrmContent::activate ( const QContent & content, ActivationMethod method )   [static]

Initiates an attempt to activate content using an ActivationMethod.

Returns true if method is a valid method for activating content.

ActivationOptions QDrmContent::activationOptions ( const QContent & content )   [static]

Returns the available options for activating content.

void QDrmContent::licenceDenied ( const QContent & content )   [signal]

void QDrmContent::licenceGranted ( const QContent & content )   [signal]

PermissionType QDrmContent::permissionType () const

Returns the default permission type or the permission type of the last requested licence.

See also setPermissionType().

void QDrmContent::releaseLicence ()   [slot]

Releases the currently held content licence. No further file access will be possible after this unless a new licence is requested.

void QDrmContent::renderPaused ()   [slot]

Notifies the DRM agent that rendering of the content has been paused.

void QDrmContent::renderStarted ()   [slot]

Notifies the DRM agent that rendering of the content has started.

RenderState QDrmContent::renderState () const

Returns the current render state.

void QDrmContent::renderStateChanged ( const QDrmContent & content )   [signal]

Signals that the render state of content has changed.

void QDrmContent::renderStopped ()   [slot]

Notifies the DRM agent that rendering of the content has ended.

bool QDrmContent::requestLicence ( bool handover = false )   [slot]

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.

bool QDrmContent::requestLicence ( PermissionType permissionType, bool handover = false )   [slot]

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.

bool QDrmContent::requestLicence ( const QContent & content, bool handover = false )   [slot]

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.

bool QDrmContent::requestLicence ( const QContent & content, PermissionType permissionType, bool handover = false )   [slot]

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.

void QDrmContent::rightsExpired ( const QDrmContent & content )   [signal]

Signals that the rights to content have expired and that any rendering of that content should stop immediately.

bool QDrmContent::rightsValid ( const QContent & content, PermissionType permission )   [static]

Checks if there are current valid permission rights to render content.

Returns true if the rights are valid.

void QDrmContent::setPermissionType ( PermissionType type )

Sets the default permission type to type.

This will only succeed if no licence is currently held.

See also permissionType().

QDrmContent & QDrmContent::operator= ( const QContent & content )

Assign a new QContent content to this QDrmContent object. If there is a licence held for the previous content it will be released.


Member Variable Documentation

const PermissionFlags QDrmContent::AllPermissions

PermissionFlags for specifying all permissions.


Copyright © 2006 Trolltech Trademarks
Qtopia 4.1.7