Rights Manager API Tutorial

Applications can use the ContentAccess::CRightsManager class to manage Digital Rights Management (DRM) rights within a particular DRM agent.

Required background

Before you start, you must understand:

Introduction

Rights Manager API gives simple access to the rights within a CAF agent implementing a DRM scheme. The rights are represented in a generic form using the ContentAccess::CRightsInfo class. This class holds a text description of the rights and some simple properties associated with these rights.

Rights Manager API also allows applications to determine which content files are associated with each rights object and vice versa.

Procedure

  1. Create a DRM rights management object.

  2. Perform one or more of the following tasks as per your requirement:

Create a DRM rights management object

The ContentAccess::CRightsManagerobject is created by the ContentAccess::CManager object to look at the rights stored by a particular content access agent.

// create the CManager object
CManager manager = CManager::NewL(); 

// Create RPointerArray to store pointers to the agents 
RPointerArray <CAgent> agentArray; 
		
// Get the list of agents 
manager->ListAgentsL(agentArray); 
				
// Create a CRightsManager for the first agent	
CRightsManager *rightsManager = manager->CreateRightsManagerL(agentArray[0]);

List all rights objects

The CRightsManager::ListAllRightsL() function produces a list of all the rights stored in the given DRM agent.

// Create the array to store rights objects 
RStreamablePtrArray<CRightsInfo> myArray; 
CleanupClosePushL(myArray); 

// Get the rights objects from the agent 
rightsManager->ListAllRightsL(myArray); 
			
// count the number of rights objects 
TInt numRights = myArray.Count(); 
				
// clear the contents of the array
myArray.ResetAndDestroy();

List the rights associated with a content file

The CRightsManager::ListRightsL() function produces a list of all the rights stored in the given DRM agent that are associated with the file at a given URI.

// Get the rights objects associated with the content 
rightsManager->ListRightsL(myArray, uri); 
		  
// Count the number of rights objects associated with the content 
TInt numRights = myArray.Count(); 
			 
// clear the contents of the array 
myArray.ResetAndDestroy();

List the rights associated with a content object

The CRightsManager::ListRightsL() function produces a list of all the rights stored in the given DRM agent that are associated with the content object at a given virtual path.

// Get the rights objects assocated with the content 
rightsManager->ListRightsL(myArray, virtualPath); 

// Count the number of rights objects associated with the content 
TInt numRights = myArray.Count(); 

// clear the contents of the array 
myArray->ResetAndDestroy();

List the content associated with a rights object

The CRightsManager::ListContentL() function produces a list of all the content that is associated with the given rights object.
rightsManager->ListAllRightsL(myArray);

// get the first CRightsInfo object 
CRightsInfo* aRightsObject = myArray[0]; 

RStreamablePtrArray<CVirtualPath> array;
CleanupClosePushL(array);

// Get the array of content objects associated with the rights 
rightsManager->ListContentL(array, aRightsObject); 
				  
// count the number of content objects
TInt numContentObjects = array.Count();

Retrieve a rights object

The CRightsManager::GetRightsDataL() function allows an application to retrieve a pointer to a rights object. The rights object is derived from MAgentRightsBase.

// Retrieve the full rights object
// The application needs to cast it to the agent's derived Rights class before using it. 

MAgentRightsBase *rightsObject = rightsManager->GetRightsDataL(aRightsObject);

Delete a rights object

The CRightsManager::DeleteRightsObject() function allows an application to delete rights stored by the agent.
// Delete the rights object 
TInt result = rightsManager->DeleteRightsObject(aRightsObject);

It is also possible to delete all the rights associated with a particular content object.

// Delete all the rights objects associated with the given content object 
TInt result = rightsManager->DeleteAllRights(virtualPath);