|
||
The 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 simple
class just holds a text description of the rights and some simple properties
associated with those rights.
The Rights Manager also allows applications to determine which content files are associated with each rights object and vice versa.
The ContentAccess::CRightsManager
object 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]);
The
ContentAccess::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();
The ContentAccess::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 assocated 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();
The ContentAccess::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();
The ContentAccess::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();
The
ContentAccess::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 will need to cast it to the agent's derived Rights class before using it.
MAgentRightsBase *rightsObject = rightsManager->GetRightsDataL(aRightsObject);
The
ContentAccess::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);