contentmgmt/contentaccessfwfordrm/source/caf/content.cpp
changeset 15 da2ae96f639b
parent 8 35751d3474b7
child 45 030c4fbc13d7
equal deleted inserted replaced
10:afc583cfa176 15:da2ae96f639b
    24 #include <caf/agentinterface.h>
    24 #include <caf/agentinterface.h>
    25 #include <caf/attributeset.h>
    25 #include <caf/attributeset.h>
    26 #include <caf/agent.h>
    26 #include <caf/agent.h>
    27 #include <caf/virtualpath.h>
    27 #include <caf/virtualpath.h>
    28 #include <caf/agentfactory.h>
    28 #include <caf/agentfactory.h>
       
    29 #include <caf/caferr.h>
    29 
    30 
    30 #ifndef REMOVE_CAF1
    31 #ifndef REMOVE_CAF1
    31 #include <caf/attribute.h>
    32 #include <caf/attribute.h>
    32 #include <caf/bitset.h>
    33 #include <caf/bitset.h>
    33 #endif
    34 #endif
    72 	CContent* self=CContent::NewLC(aFile);
    73 	CContent* self=CContent::NewLC(aFile);
    73 	CleanupStack::Pop(self);
    74 	CleanupStack::Pop(self);
    74 	return self;
    75 	return self;
    75 	}
    76 	}
    76 
    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 
    77 CContent::CContent() : iDefaultVirtualPath(KNullDesC(), KDefaultContentObject())
    97 CContent::CContent() : iDefaultVirtualPath(KNullDesC(), KDefaultContentObject())
    78 	{ 
    98 	{ 
    79 	}
    99 	}
    80 
   100 
    81 CContent::~CContent() 
   101 CContent::~CContent() 
    82 	{ 
   102 	{ 
    83 	delete iAgentContent;
   103 	delete iAgentContent;
    84 
   104 	iFile.Close();
       
   105 	
    85 	if(iVirtualPath)
   106 	if(iVirtualPath)
    86 		{
   107 		{
    87 		delete iVirtualPath;
   108 		delete iVirtualPath;
    88 		}
   109 		}
    89 	else
   110 	
    90 		{
   111 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
    91 		iFile.Close();	
   112 	delete iHeaderData;
    92 		}
   113 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
    93 	
   114 	
    94 	// Finished with agent, this closes ECOM handle
   115 	// Finished with agent, this closes ECOM handle
    95 	delete iAgentFactory;
   116 	delete iAgentFactory;
    96 	REComSession::FinalClose();
   117 	REComSession::FinalClose();
    97 	}
   118 	}
   166 	
   187 	
   167 	// Finished with resolver and the CAgentInfo object it owns
   188 	// Finished with resolver and the CAgentInfo object it owns
   168 	CleanupStack::PopAndDestroy(2, resolver); // actualUri
   189 	CleanupStack::PopAndDestroy(2, resolver); // actualUri
   169 	}
   190 	}
   170 
   191 
       
   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 
   171 EXPORT_C TInt CContent::OpenContainer(const TDesC &aUniqueId) 
   222 EXPORT_C TInt CContent::OpenContainer(const TDesC &aUniqueId) 
   172 	{
   223 	{
   173 	return iAgentContent->OpenContainer(aUniqueId);
   224 	return iAgentContent->OpenContainer(aUniqueId);
   174 	}
   225 	}
   175 
   226 
   298 	return iAgentContent->SetProperty(aProperty, aValue);
   349 	return iAgentContent->SetProperty(aProperty, aValue);
   299 	}
   350 	}
   300 
   351 
   301 EXPORT_C CData* CContent::OpenContentL(TIntent aIntent)
   352 EXPORT_C CData* CContent::OpenContentL(TIntent aIntent)
   302 	{
   353 	{
       
   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
   303 	return OpenContentL(aIntent, iDefaultVirtualPath.UniqueId());
   360 	return OpenContentL(aIntent, iDefaultVirtualPath.UniqueId());
       
   361 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   304 	}
   362 	}
   305 
   363 
   306 EXPORT_C CData* CContent::OpenContentLC(TIntent aIntent)
   364 EXPORT_C CData* CContent::OpenContentLC(TIntent aIntent)
   307 	{
   365 	{
       
   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
   308 	return OpenContentLC(aIntent, iDefaultVirtualPath.UniqueId());
   372 	return OpenContentLC(aIntent, iDefaultVirtualPath.UniqueId());
       
   373 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   309 	}
   374 	}
   310 
   375 
   311 EXPORT_C CData* CContent::OpenContentL(TIntent aIntent, const TDesC &aUniqueId)
   376 EXPORT_C CData* CContent::OpenContentL(TIntent aIntent, const TDesC &aUniqueId)
   312 	{
   377 	{
   313 	CData* data = OpenContentLC(aIntent, aUniqueId);
   378 	CData* data = OpenContentLC(aIntent, aUniqueId);
   327 		{
   392 		{
   328 		// create a CData based upon the file handle supplied when this CContent was created
   393 		// create a CData based upon the file handle supplied when this CContent was created
   329 		return CData::NewLC(iAgent.ImplementationUid(), iFile, aUniqueId, aIntent);
   394 		return CData::NewLC(iAgent.ImplementationUid(), iFile, aUniqueId, aIntent);
   330 		}
   395 		}
   331 	}
   396 	}
       
   397 	
       
   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
   332 
   413 
   333 EXPORT_C const TAgent& CContent::Agent() const
   414 EXPORT_C const TAgent& CContent::Agent() const
   334 	{
   415 	{
   335 	// The agent handling this content
   416 	// The agent handling this content
   336 	return iAgent;
   417 	return iAgent;
   360 EXPORT_C CAttribute* CContent::NewAttributeL(TBool aPreloaded)
   441 EXPORT_C CAttribute* CContent::NewAttributeL(TBool aPreloaded)
   361 	{
   442 	{
   362 	return NewAttributeL(aPreloaded, EContentShareReadOnly);
   443 	return NewAttributeL(aPreloaded, EContentShareReadOnly);
   363 	}
   444 	}
   364 
   445 
       
   446 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   365 EXPORT_C CAttribute* CContent::NewAttributeL(TBool aPreloaded, TContentShareMode aShareMode)
   447 EXPORT_C CAttribute* CContent::NewAttributeL(TBool aPreloaded, TContentShareMode aShareMode)
   366 	{
   448 	{
   367 	CAttribute* attr = NULL;
   449 	CAttribute* attr = NULL;
   368 	
   450 	
   369 	if(iVirtualPath)
   451 	if(iVirtualPath)
   370 		{
   452 		{
   371 		// if we were opened with a file name
   453 		// if we were opened with a file name
   372 		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iDefaultVirtualPath.URI(), aShareMode);
   454 		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iDefaultVirtualPath.URI(), aShareMode);
   373 		}
   455 		}
       
   456 	else if(iHeaderData)
       
   457 		{
       
   458 		attr = CAttribute::NewLC(iAgent.ImplementationUid(), *iHeaderData);
       
   459 		}
   374 	else
   460 	else
   375 		{
   461 		{
   376 		// if we were opened with a file handle 
   462 		// if we were opened with a file handle 
   377 		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iFile);
   463 		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iFile);
   378 		}
   464 		}
   386 
   472 
   387 	CleanupStack::Pop(attr);
   473 	CleanupStack::Pop(attr);
   388 	return attr;
   474 	return attr;
   389 	}
   475 	}
   390 
   476 
       
   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 
   391 #endif // REMOVE_CAF1
   507 #endif // REMOVE_CAF1
   392 
   508 
   393 
       
   394 // DLL entry point - only for EKA1
   509 // DLL entry point - only for EKA1
   395 
   510 
   396 
   511 
   397 
   512 
   398 
   513