mmlibs/mmfw/src/Client/Utility/mmfclientutility.cpp
branchRCL_3
changeset 11 d5f04de580b7
parent 0 40261b775718
child 19 8184f75a63d4
equal deleted inserted replaced
8:bc06d8566074 11:d5f04de580b7
  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)
  2280         }
  2285         }
  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         }
       
  2290     if(!isDataProtected)
       
  2291         {
       
  2292         CleanupStack::PopAndDestroy(content);
       
  2293         return;//returning cause if data is not protected, we need not evaluate the type of rights.
       
  2294         }
       
  2295     
       
  2296     RArray<TAgent> agents;
       
  2297     TAgent drmAgent;
       
  2298 
       
  2299     CManager* manager = CManager::NewLC();
       
  2300     CleanupClosePushL( agents );
       
  2301     manager->ListAgentsL( agents );
       
  2302     
       
  2303     for ( TInt i = 0; i < agents.Count(); i++ )
       
  2304         {
       
  2305         if ( agents[i].Name().Compare( content->Agent().Name() ) == 0 )  
       
  2306             {
       
  2307             drmAgent = agents[i];
       
  2308             break;
       
  2309             }
       
  2310         }
       
  2311     
       
  2312     CleanupStack::PopAndDestroy( &agents );        
       
  2313     RStreamablePtrArray<CRightsInfo> infoArray;
       
  2314     CRightsManager*  rightsManager = manager->CreateRightsManagerL(drmAgent);
       
  2315     CleanupStack::PushL(rightsManager);
       
  2316     
       
  2317     if(iFileName.Length())
       
  2318         {
       
  2319         if(iUniqueId)
       
  2320             {
       
  2321             TVirtualPathPtr pathPtr(iFileName, *iUniqueId);
       
  2322             TRAP(error,rightsManager->ListRightsL(infoArray, pathPtr) );
       
  2323             }
       
  2324         else
       
  2325             {
       
  2326             TRAP(error,rightsManager->ListRightsL(infoArray, iFileName ) ); 
       
  2327             }
       
  2328         }
       
  2329     else if (iUseFileHandle && iOwnFileHandle) 
       
  2330         {
       
  2331         if(iUniqueId)
       
  2332             {
       
  2333             TRAP(error,rightsManager->ListRightsL(infoArray, iFileHandle, *iUniqueId) );
       
  2334             }
       
  2335         else
       
  2336             {
       
  2337             TRAP(error,rightsManager->ListRightsL(infoArray, iFileHandle, KNullDesC) );
       
  2338           }
       
  2339         }
       
  2340     
       
  2341     if(error)
       
  2342         {
       
  2343         infoArray.Close();
       
  2344         User::Leave(error);
       
  2345         }
       
  2346     TInt consumableRights = 0;
       
  2347     if(infoArray.Count() > 0)
       
  2348         consumableRights = (ContentAccess::ERightsTypeConsumable) &  infoArray[0]->RightsType();
       
  2349     
       
  2350     
       
  2351     CleanupStack::PopAndDestroy( rightsManager );
       
  2352     infoArray.Close();
       
  2353     CleanupStack::PopAndDestroy( manager );
       
  2354 
  2285     CleanupStack::PopAndDestroy(content);
  2355     CleanupStack::PopAndDestroy(content);
  2286     if(isDataProtected && !iHasDrmCapability && mode == EPlayback )
  2356     if(isDataProtected && !iHasDrmCapability && mode == EPlayback && !consumableRights)
  2287         {//only when the Data is protected and client does not have the DRM capability, we need secure DRM process
  2357         {//only when the Data is protected and client does not have the DRM capability, we need secure DRM process
  2288         aIsSecureDrmProcess = ETrue;
  2358         aIsSecureDrmProcess = ETrue;
  2289         }
  2359         }
  2290     }
  2360     }
  2291 
  2361