mmlibs/mmfw/src/Client/Utility/mmfclientutility.cpp
changeset 54 b68f3e90dca1
parent 13 efebd1779a59
equal deleted inserted replaced
51:613e4e943120 54:b68f3e90dca1
  2233 	{
  2233 	{
  2234 	Close();
  2234 	Close();
  2235 	}
  2235 	}
  2236 
  2236 
  2237 void CMMFFindAndOpenController::UseSecureDRMProcessL(TBool& aIsSecureDrmProcess)
  2237 void CMMFFindAndOpenController::UseSecureDRMProcessL(TBool& aIsSecureDrmProcess)
  2238     {       
  2238     {
       
  2239     if(iHasDrmCapability)//if client has DRM capability, we never use Secure DRM Process
       
  2240         {
       
  2241         aIsSecureDrmProcess = EFalse;
       
  2242         return;
       
  2243         }       
  2239     TBool isDataProtected = EFalse;
  2244     TBool isDataProtected = EFalse;
  2240     ContentAccess::CContent* content = NULL;
  2245     ContentAccess::CContent* content = NULL;
  2241     TControllerMode mode = iCurrentConfig->iControllerMode;
  2246     TControllerMode mode = iCurrentConfig->iControllerMode;
  2242 
  2247 
  2243     //setting aUseSecureDrmProcess to false(default value)
  2248     //setting aUseSecureDrmProcess to false(default value)
  2281     else if( error != KErrNone && error != KErrPermissionDenied)
  2286     else if( error != KErrNone && error != KErrPermissionDenied)
  2282         {//leaving as GetAttribute of CAF caused an error.
  2287         {//leaving as GetAttribute of CAF caused an error.
  2283         User::Leave(error);
  2288         User::Leave(error);
  2284         }
  2289         }
  2285 
  2290 
  2286     if(!isDataProtected)
       
  2287         {
       
  2288         CleanupStack::PopAndDestroy(content);
       
  2289         return;//returning cause if data is not protected, we need not evaluate the type of rights.
       
  2290         }
       
  2291     
       
  2292     RArray<TAgent> agents;
       
  2293     TAgent drmAgent;
       
  2294 
       
  2295     CManager* manager = CManager::NewLC();
       
  2296     CleanupClosePushL( agents );
       
  2297     manager->ListAgentsL( agents );
       
  2298     
       
  2299     for ( TInt i = 0; i < agents.Count(); i++ )
       
  2300         {
       
  2301         if ( agents[i].Name().Compare( content->Agent().Name() ) == 0 )  
       
  2302             {
       
  2303             drmAgent = agents[i];
       
  2304             break;
       
  2305             }
       
  2306         }
       
  2307     
       
  2308     CleanupStack::PopAndDestroy( &agents );        
       
  2309     RStreamablePtrArray<CRightsInfo> infoArray;
       
  2310     CRightsManager*  rightsManager = manager->CreateRightsManagerL(drmAgent);
       
  2311     CleanupStack::PushL(rightsManager);
       
  2312     
       
  2313     if(iFileName.Length())
       
  2314         {
       
  2315         if(iUniqueId)
       
  2316             {
       
  2317             TVirtualPathPtr pathPtr(iFileName, *iUniqueId);
       
  2318             TRAP(error,rightsManager->ListRightsL(infoArray, pathPtr) );
       
  2319             }
       
  2320         else
       
  2321             {
       
  2322             TRAP(error,rightsManager->ListRightsL(infoArray, iFileName ) ); 
       
  2323             }
       
  2324         }
       
  2325     else if (iUseFileHandle && iOwnFileHandle) 
       
  2326         {
       
  2327         if(iUniqueId)
       
  2328             {
       
  2329             TRAP(error,rightsManager->ListRightsL(infoArray, iFileHandle, *iUniqueId) );
       
  2330             }
       
  2331         else
       
  2332             {
       
  2333             TRAP(error,rightsManager->ListRightsL(infoArray, iFileHandle, KNullDesC) );
       
  2334           }
       
  2335         }
       
  2336     
       
  2337     if(error)
       
  2338         {
       
  2339         infoArray.Close();
       
  2340         User::Leave(error);
       
  2341         }
       
  2342     TInt consumableRights = 0;
       
  2343     if(infoArray.Count() > 0)
       
  2344         consumableRights = (ContentAccess::ERightsTypeConsumable) &  infoArray[0]->RightsType();
       
  2345     
       
  2346     
       
  2347     CleanupStack::PopAndDestroy( rightsManager );
       
  2348     infoArray.Close();
       
  2349     CleanupStack::PopAndDestroy( manager );
       
  2350     CleanupStack::PopAndDestroy(content);
  2291     CleanupStack::PopAndDestroy(content);
  2351     if(isDataProtected && !iHasDrmCapability && mode == EPlayback && !consumableRights)
  2292     if(isDataProtected && !iHasDrmCapability && mode == EPlayback)
  2352         {//only when the Data is protected and client does not have the DRM capability, we need secure DRM process
  2293         {//only when the Data is protected and client does not have the DRM capability, we need secure DRM process
  2353         aIsSecureDrmProcess = ETrue;
  2294         aIsSecureDrmProcess = ETrue;
  2354         }
  2295         }
  2355     }
  2296     }
  2356 
  2297