contentmgmt/contentaccessfwfordrm/source/caf/content.cpp
branchRCL_3
changeset 96 a71299154b21
parent 95 641f389e9157
equal deleted inserted replaced
95:641f389e9157 96:a71299154b21
    73 	CContent* self=CContent::NewLC(aFile);
    73 	CContent* self=CContent::NewLC(aFile);
    74 	CleanupStack::Pop(self);
    74 	CleanupStack::Pop(self);
    75 	return self;
    75 	return self;
    76 	}
    76 	}
    77 
    77 
    78 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
    79 
       
    80 EXPORT_C CContent* CContent::NewLC(const TDesC8& aHeaderData) 
       
    81 	{
       
    82 	CContent* self = new(ELeave) CContent();
       
    83 	CleanupStack::PushL(self);
       
    84 	self->ConstructL(aHeaderData);
       
    85 	return self;
       
    86 	}
       
    87 
       
    88 EXPORT_C CContent* CContent::NewL(const TDesC8& aHeaderData) 
       
    89 	{
       
    90 	CContent* self=CContent::NewLC(aHeaderData);
       
    91 	CleanupStack::Pop(self);
       
    92 	return self;
       
    93 	}
       
    94 	
       
    95 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
    96 
    78 
    97 CContent::CContent() : iDefaultVirtualPath(KNullDesC(), KDefaultContentObject())
    79 CContent::CContent() : iDefaultVirtualPath(KNullDesC(), KDefaultContentObject())
    98 	{ 
    80 	{ 
    99 	}
    81 	}
   100 
    82 
   105 	
    87 	
   106 	if(iVirtualPath)
    88 	if(iVirtualPath)
   107 		{
    89 		{
   108 		delete iVirtualPath;
    90 		delete iVirtualPath;
   109 		}
    91 		}
   110 	
       
   111 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   112 	delete iHeaderData;
       
   113 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   114 	
    92 	
   115 	// Finished with agent, this closes ECOM handle
    93 	// Finished with agent, this closes ECOM handle
   116 	delete iAgentFactory;
    94 	delete iAgentFactory;
   117 	REComSession::FinalClose();
    95 	REComSession::FinalClose();
   118 	}
    96 	}
   187 	
   165 	
   188 	// Finished with resolver and the CAgentInfo object it owns
   166 	// Finished with resolver and the CAgentInfo object it owns
   189 	CleanupStack::PopAndDestroy(2, resolver); // actualUri
   167 	CleanupStack::PopAndDestroy(2, resolver); // actualUri
   190 	}
   168 	}
   191 
   169 
   192 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   193 
       
   194 void CContent::ConstructL(const TDesC8& aHeaderData) 
       
   195 	{
       
   196 	if(aHeaderData.Length() <= 0)
       
   197 		{
       
   198 		User::Leave(KErrMissingWmdrmHeaderData);
       
   199 		}
       
   200 	
       
   201 	iHeaderData = aHeaderData.AllocL();
       
   202 	
       
   203 	CAgentResolver* resolver = CAgentResolver::NewLC(EFalse);
       
   204 	
       
   205 	// Find the agent who handles the file
       
   206 	CAgentInfo& agentInfo = resolver->ResolveFileL(aHeaderData);
       
   207 
       
   208 	// copy the agent name and Uid
       
   209 	iAgent = agentInfo.Agent();
       
   210 
       
   211 	// Construct the agent factory (ECOM handle)
       
   212 	iAgentFactory = CAgentFactory::NewL(iAgent.ImplementationUid());
       
   213 	// Construct the CAgentContent object
       
   214 	iAgentContent = iAgentFactory->CreateContentBrowserL(aHeaderData);
       
   215 
       
   216 	// Finished with resolver (and the agentInfo object it owns)
       
   217 	CleanupStack::PopAndDestroy(resolver); 
       
   218 	}
       
   219 
       
   220 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   221 
   170 
   222 EXPORT_C TInt CContent::OpenContainer(const TDesC &aUniqueId) 
   171 EXPORT_C TInt CContent::OpenContainer(const TDesC &aUniqueId) 
   223 	{
   172 	{
   224 	return iAgentContent->OpenContainer(aUniqueId);
   173 	return iAgentContent->OpenContainer(aUniqueId);
   225 	}
   174 	}
   349 	return iAgentContent->SetProperty(aProperty, aValue);
   298 	return iAgentContent->SetProperty(aProperty, aValue);
   350 	}
   299 	}
   351 
   300 
   352 EXPORT_C CData* CContent::OpenContentL(TIntent aIntent)
   301 EXPORT_C CData* CContent::OpenContentL(TIntent aIntent)
   353 	{
   302 	{
   354 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   355 	if(iHeaderData != NULL)
       
   356 		return OpenContentL(aIntent, *iHeaderData);
       
   357     else
       
   358 		return OpenContentL(aIntent, iDefaultVirtualPath.UniqueId());
       
   359 #else
       
   360 	return OpenContentL(aIntent, iDefaultVirtualPath.UniqueId());
   303 	return OpenContentL(aIntent, iDefaultVirtualPath.UniqueId());
   361 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   362 	}
   304 	}
   363 
   305 
   364 EXPORT_C CData* CContent::OpenContentLC(TIntent aIntent)
   306 EXPORT_C CData* CContent::OpenContentLC(TIntent aIntent)
   365 	{
   307 	{
   366 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   367 	if(iHeaderData != NULL)
       
   368 		return OpenContentLC(aIntent, *iHeaderData);
       
   369 	else
       
   370 		return OpenContentLC(aIntent, iDefaultVirtualPath.UniqueId());
       
   371 #else
       
   372 	return OpenContentLC(aIntent, iDefaultVirtualPath.UniqueId());
   308 	return OpenContentLC(aIntent, iDefaultVirtualPath.UniqueId());
   373 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   374 	}
   309 	}
   375 
   310 
   376 EXPORT_C CData* CContent::OpenContentL(TIntent aIntent, const TDesC &aUniqueId)
   311 EXPORT_C CData* CContent::OpenContentL(TIntent aIntent, const TDesC &aUniqueId)
   377 	{
   312 	{
   378 	CData* data = OpenContentLC(aIntent, aUniqueId);
   313 	CData* data = OpenContentLC(aIntent, aUniqueId);
   393 		// create a CData based upon the file handle supplied when this CContent was created
   328 		// create a CData based upon the file handle supplied when this CContent was created
   394 		return CData::NewLC(iAgent.ImplementationUid(), iFile, aUniqueId, aIntent);
   329 		return CData::NewLC(iAgent.ImplementationUid(), iFile, aUniqueId, aIntent);
   395 		}
   330 		}
   396 	}
   331 	}
   397 	
   332 	
   398 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   399 
       
   400 CData* CContent::OpenContentL(TIntent aIntent, const TDesC8& aHeaderData)
       
   401 	{
       
   402 	CData* data = OpenContentLC(aIntent, aHeaderData);
       
   403 	CleanupStack::Pop(data);
       
   404 	return data;
       
   405 	}
       
   406 
       
   407 CData* CContent::OpenContentLC(TIntent aIntent, const TDesC8& aHeaderData)
       
   408 	{
       
   409 	return CData::NewLC(iAgent.ImplementationUid(), aHeaderData, aIntent);
       
   410 	}
       
   411 	
       
   412 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   413 
       
   414 EXPORT_C const TAgent& CContent::Agent() const
   333 EXPORT_C const TAgent& CContent::Agent() const
   415 	{
   334 	{
   416 	// The agent handling this content
   335 	// The agent handling this content
   417 	return iAgent;
   336 	return iAgent;
   418 	}
   337 	}
   441 EXPORT_C CAttribute* CContent::NewAttributeL(TBool aPreloaded)
   360 EXPORT_C CAttribute* CContent::NewAttributeL(TBool aPreloaded)
   442 	{
   361 	{
   443 	return NewAttributeL(aPreloaded, EContentShareReadOnly);
   362 	return NewAttributeL(aPreloaded, EContentShareReadOnly);
   444 	}
   363 	}
   445 
   364 
   446 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   447 EXPORT_C CAttribute* CContent::NewAttributeL(TBool aPreloaded, TContentShareMode aShareMode)
   365 EXPORT_C CAttribute* CContent::NewAttributeL(TBool aPreloaded, TContentShareMode aShareMode)
   448 	{
   366 	{
   449 	CAttribute* attr = NULL;
   367 	CAttribute* attr = NULL;
   450 	
   368 	
   451 	if(iVirtualPath)
   369 	if(iVirtualPath)
   452 		{
   370 		{
   453 		// if we were opened with a file name
   371 		// if we were opened with a file name
   454 		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iDefaultVirtualPath.URI(), aShareMode);
   372 		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iDefaultVirtualPath.URI(), aShareMode);
   455 		}
   373 		}
   456 	else if(iHeaderData)
       
   457 		{
       
   458 		attr = CAttribute::NewLC(iAgent.ImplementationUid(), *iHeaderData);
       
   459 		}
       
   460 	else
   374 	else
   461 		{
   375 		{
   462 		// if we were opened with a file handle 
   376 		// if we were opened with a file handle 
   463 		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iFile);
   377 		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iFile);
   464 		}
   378 		}
   472 
   386 
   473 	CleanupStack::Pop(attr);
   387 	CleanupStack::Pop(attr);
   474 	return attr;
   388 	return attr;
   475 	}
   389 	}
   476 
   390 
   477 #else
       
   478 
       
   479 EXPORT_C CAttribute* CContent::NewAttributeL(TBool aPreloaded, TContentShareMode aShareMode)
       
   480 	{
       
   481 	CAttribute* attr = NULL;
       
   482 	
       
   483 	if(iVirtualPath)
       
   484 		{
       
   485 		// if we were opened with a file name
       
   486 		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iDefaultVirtualPath.URI(), aShareMode);
       
   487 		}
       
   488 	else
       
   489 		{
       
   490 		// if we were opened with a file handle 
       
   491 		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iFile);
       
   492 		}
       
   493 
       
   494 	// If aPreloaded is set, query the agent immediately for all the attributes
       
   495 	if (aPreloaded)
       
   496 		{
       
   497 		attr->QuerySet().SetAll();
       
   498 		attr->GetL();
       
   499 		}
       
   500 
       
   501 	CleanupStack::Pop(attr);
       
   502 	return attr;
       
   503 	}
       
   504 
       
   505 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   506 
       
   507 #endif // REMOVE_CAF1
   391 #endif // REMOVE_CAF1
   508 
   392 
   509 // DLL entry point - only for EKA1
   393 // DLL entry point - only for EKA1
   510 
   394 
   511 
   395