mmlibs/mmfw/src/Client/Utility/mmfclientutility.cpp
branchRCL_3
changeset 11 d5f04de580b7
parent 0 40261b775718
child 19 8184f75a63d4
--- a/mmlibs/mmfw/src/Client/Utility/mmfclientutility.cpp	Mon Mar 15 12:46:07 2010 +0200
+++ b/mmlibs/mmfw/src/Client/Utility/mmfclientutility.cpp	Wed Mar 31 23:56:23 2010 +0300
@@ -2235,7 +2235,12 @@
 	}
 
 void CMMFFindAndOpenController::UseSecureDRMProcessL(TBool& aIsSecureDrmProcess)
-    {       
+    {
+    if(iHasDrmCapability)//if client has DRM capability, we never use Secure DRM Process
+        {
+        aIsSecureDrmProcess = EFalse;
+        return;
+        }       
     TBool isDataProtected = EFalse;
     ContentAccess::CContent* content = NULL;
     TControllerMode mode = iCurrentConfig->iControllerMode;
@@ -2282,8 +2287,73 @@
         {//leaving as GetAttribute of CAF caused an error.
         User::Leave(error);
         }
+    if(!isDataProtected)
+        {
+        CleanupStack::PopAndDestroy(content);
+        return;//returning cause if data is not protected, we need not evaluate the type of rights.
+        }
+    
+    RArray<TAgent> agents;
+    TAgent drmAgent;
+
+    CManager* manager = CManager::NewLC();
+    CleanupClosePushL( agents );
+    manager->ListAgentsL( agents );
+    
+    for ( TInt i = 0; i < agents.Count(); i++ )
+        {
+        if ( agents[i].Name().Compare( content->Agent().Name() ) == 0 )  
+            {
+            drmAgent = agents[i];
+            break;
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( &agents );        
+    RStreamablePtrArray<CRightsInfo> infoArray;
+    CRightsManager*  rightsManager = manager->CreateRightsManagerL(drmAgent);
+    CleanupStack::PushL(rightsManager);
+    
+    if(iFileName.Length())
+        {
+        if(iUniqueId)
+            {
+            TVirtualPathPtr pathPtr(iFileName, *iUniqueId);
+            TRAP(error,rightsManager->ListRightsL(infoArray, pathPtr) );
+            }
+        else
+            {
+            TRAP(error,rightsManager->ListRightsL(infoArray, iFileName ) ); 
+            }
+        }
+    else if (iUseFileHandle && iOwnFileHandle) 
+        {
+        if(iUniqueId)
+            {
+            TRAP(error,rightsManager->ListRightsL(infoArray, iFileHandle, *iUniqueId) );
+            }
+        else
+            {
+            TRAP(error,rightsManager->ListRightsL(infoArray, iFileHandle, KNullDesC) );
+          }
+        }
+    
+    if(error)
+        {
+        infoArray.Close();
+        User::Leave(error);
+        }
+    TInt consumableRights = 0;
+    if(infoArray.Count() > 0)
+        consumableRights = (ContentAccess::ERightsTypeConsumable) &  infoArray[0]->RightsType();
+    
+    
+    CleanupStack::PopAndDestroy( rightsManager );
+    infoArray.Close();
+    CleanupStack::PopAndDestroy( manager );
+
     CleanupStack::PopAndDestroy(content);
-    if(isDataProtected && !iHasDrmCapability && mode == EPlayback )
+    if(isDataProtected && !iHasDrmCapability && mode == EPlayback && !consumableRights)
         {//only when the Data is protected and client does not have the DRM capability, we need secure DRM process
         aIsSecureDrmProcess = ETrue;
         }