os/security/contentmgmt/contentaccessfwfordrm/source/caf/content.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#include <caf/content.h>
sl@0
    20
#include "resolver.h"
sl@0
    21
#include <caf/data.h>
sl@0
    22
#include <caf/agentfactory.h>
sl@0
    23
#include "agentinfo.h"
sl@0
    24
#include <caf/agentinterface.h>
sl@0
    25
#include <caf/attributeset.h>
sl@0
    26
#include <caf/agent.h>
sl@0
    27
#include <caf/virtualpath.h>
sl@0
    28
#include <caf/agentfactory.h>
sl@0
    29
#include <caf/caferr.h>
sl@0
    30
sl@0
    31
#ifndef REMOVE_CAF1
sl@0
    32
#include <caf/attribute.h>
sl@0
    33
#include <caf/bitset.h>
sl@0
    34
#endif
sl@0
    35
sl@0
    36
using namespace ContentAccess;
sl@0
    37
sl@0
    38
EXPORT_C CContent* CContent::NewLC(const TDesC& aURI) 
sl@0
    39
	{
sl@0
    40
	return CContent::NewLC(aURI, EContentShareReadOnly);
sl@0
    41
	}
sl@0
    42
sl@0
    43
EXPORT_C CContent* CContent::NewL(const TDesC& aURI)  
sl@0
    44
	{
sl@0
    45
	return CContent::NewL(aURI, EContentShareReadOnly);
sl@0
    46
	}
sl@0
    47
sl@0
    48
EXPORT_C CContent* CContent::NewLC(const TDesC& aURI, TContentShareMode aShareMode) 
sl@0
    49
	{
sl@0
    50
	CContent* self = new(ELeave) CContent();
sl@0
    51
	CleanupStack::PushL(self);
sl@0
    52
	self->ConstructL(aURI, aShareMode);
sl@0
    53
	return self;
sl@0
    54
	}
sl@0
    55
sl@0
    56
EXPORT_C CContent* CContent::NewL(const TDesC& aURI, TContentShareMode aShareMode)  
sl@0
    57
	{
sl@0
    58
	CContent* self=CContent::NewLC(aURI, aShareMode);
sl@0
    59
	CleanupStack::Pop(self);
sl@0
    60
	return self;
sl@0
    61
	}
sl@0
    62
sl@0
    63
EXPORT_C CContent* CContent::NewLC(RFile& aFile) 
sl@0
    64
	{
sl@0
    65
	CContent* self = new(ELeave) CContent();
sl@0
    66
	CleanupStack::PushL(self);
sl@0
    67
	self->ConstructL(aFile);
sl@0
    68
	return self;
sl@0
    69
	}
sl@0
    70
sl@0
    71
EXPORT_C CContent* CContent::NewL(RFile& aFile) 
sl@0
    72
	{
sl@0
    73
	CContent* self=CContent::NewLC(aFile);
sl@0
    74
	CleanupStack::Pop(self);
sl@0
    75
	return self;
sl@0
    76
	}
sl@0
    77
sl@0
    78
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
    79
sl@0
    80
EXPORT_C CContent* CContent::NewLC(const TDesC8& aHeaderData) 
sl@0
    81
	{
sl@0
    82
	CContent* self = new(ELeave) CContent();
sl@0
    83
	CleanupStack::PushL(self);
sl@0
    84
	self->ConstructL(aHeaderData);
sl@0
    85
	return self;
sl@0
    86
	}
sl@0
    87
sl@0
    88
EXPORT_C CContent* CContent::NewL(const TDesC8& aHeaderData) 
sl@0
    89
	{
sl@0
    90
	CContent* self=CContent::NewLC(aHeaderData);
sl@0
    91
	CleanupStack::Pop(self);
sl@0
    92
	return self;
sl@0
    93
	}
sl@0
    94
	
sl@0
    95
#endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
    96
sl@0
    97
CContent::CContent() : iDefaultVirtualPath(KNullDesC(), KDefaultContentObject())
sl@0
    98
	{ 
sl@0
    99
	}
sl@0
   100
sl@0
   101
CContent::~CContent() 
sl@0
   102
	{ 
sl@0
   103
	delete iAgentContent;
sl@0
   104
	iFile.Close();
sl@0
   105
	
sl@0
   106
	if(iVirtualPath)
sl@0
   107
		{
sl@0
   108
		delete iVirtualPath;
sl@0
   109
		}
sl@0
   110
	
sl@0
   111
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
   112
	delete iHeaderData;
sl@0
   113
#endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
   114
	
sl@0
   115
	// Finished with agent, this closes ECOM handle
sl@0
   116
	delete iAgentFactory;
sl@0
   117
	REComSession::FinalClose();
sl@0
   118
	}
sl@0
   119
sl@0
   120
sl@0
   121
void CContent::ConstructL(RFile &aFile) 
sl@0
   122
	{
sl@0
   123
	// Make our own copy of the file handle
sl@0
   124
	User::LeaveIfError(iFile.Duplicate(aFile));
sl@0
   125
	
sl@0
   126
	// Rewind the file pointer
sl@0
   127
#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
sl@0
   128
	TInt64 pos = 0;
sl@0
   129
#else
sl@0
   130
	TInt pos = 0;
sl@0
   131
#endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
sl@0
   132
sl@0
   133
	iFile.Seek(ESeekStart, pos);
sl@0
   134
	
sl@0
   135
	// For case where CAF is built with an RFile
sl@0
   136
	CAgentResolver* resolver = CAgentResolver::NewLC(EFalse);
sl@0
   137
	
sl@0
   138
	// Find the agent who handles the file
sl@0
   139
	CAgentInfo& agentInfo = resolver->ResolveFileL(iFile);
sl@0
   140
sl@0
   141
	// copy the agent name and Uid
sl@0
   142
	iAgent = agentInfo.Agent();
sl@0
   143
sl@0
   144
	// Construct the agent factory (ECOM handle)
sl@0
   145
	iAgentFactory = CAgentFactory::NewL(iAgent.ImplementationUid());
sl@0
   146
sl@0
   147
	// Construct the CAgentContent object
sl@0
   148
	iAgentContent = iAgentFactory->CreateContentBrowserL(iFile);
sl@0
   149
sl@0
   150
	// Finished with resolver (and the agentInfo object it owns)
sl@0
   151
	CleanupStack::PopAndDestroy(resolver); 
sl@0
   152
	}
sl@0
   153
sl@0
   154
void CContent::ConstructL(const TDesC& aURI, TContentShareMode aShareMode) 
sl@0
   155
	{
sl@0
   156
	iShareMode = aShareMode;
sl@0
   157
sl@0
   158
	// Create the agent resolver which will contains a reference to
sl@0
   159
	// the agent responsible for this piece of content
sl@0
   160
	CAgentResolver* resolver = CAgentResolver::NewLC(EFalse);
sl@0
   161
	
sl@0
   162
	// Create a temporary buffer used to store the translated version of the URI
sl@0
   163
	HBufC* actualUri = HBufC::NewLC(aURI.Length() + KMaxSIDLength);
sl@0
   164
	TPtr uri = actualUri->Des();
sl@0
   165
	
sl@0
   166
	// Set the TVirtualPathPtr to point to the URI supplied, 
sl@0
   167
	// this will decode any combined URI into the actual URI and uniqueId
sl@0
   168
	// for use in subsequent functions
sl@0
   169
	TVirtualPathPtr contentVirtualPath = aURI;
sl@0
   170
sl@0
   171
	// Find the agent who handles the file and translate the URI if it is pointing to a private directory 
sl@0
   172
	CAgentInfo& agentInfo = resolver->ResolveFileL(contentVirtualPath.URI(), uri, iShareMode);
sl@0
   173
sl@0
   174
	// Set the iVirtualPath to point to the translated URI and the uniqueId
sl@0
   175
	iVirtualPath = CVirtualPath::NewL(*actualUri, contentVirtualPath.UniqueId());
sl@0
   176
	
sl@0
   177
	iDefaultVirtualPath = *iVirtualPath;
sl@0
   178
	
sl@0
   179
	// Copy the agent name and Uid
sl@0
   180
	iAgent = agentInfo.Agent();
sl@0
   181
sl@0
   182
	// Construct the agent factory (ECOM handle)
sl@0
   183
	iAgentFactory = CAgentFactory::NewL(iAgent.ImplementationUid());
sl@0
   184
sl@0
   185
	// Construct the agent content browser 
sl@0
   186
	iAgentContent = iAgentFactory->CreateContentBrowserL(uri, iShareMode);	
sl@0
   187
	
sl@0
   188
	// Finished with resolver and the CAgentInfo object it owns
sl@0
   189
	CleanupStack::PopAndDestroy(2, resolver); // actualUri
sl@0
   190
	}
sl@0
   191
sl@0
   192
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
   193
sl@0
   194
void CContent::ConstructL(const TDesC8& aHeaderData) 
sl@0
   195
	{
sl@0
   196
	if(aHeaderData.Length() <= 0)
sl@0
   197
		{
sl@0
   198
		User::Leave(KErrMissingWmdrmHeaderData);
sl@0
   199
		}
sl@0
   200
	
sl@0
   201
	iHeaderData = aHeaderData.AllocL();
sl@0
   202
	
sl@0
   203
	CAgentResolver* resolver = CAgentResolver::NewLC(EFalse);
sl@0
   204
	
sl@0
   205
	// Find the agent who handles the file
sl@0
   206
	CAgentInfo& agentInfo = resolver->ResolveFileL(aHeaderData);
sl@0
   207
sl@0
   208
	// copy the agent name and Uid
sl@0
   209
	iAgent = agentInfo.Agent();
sl@0
   210
sl@0
   211
	// Construct the agent factory (ECOM handle)
sl@0
   212
	iAgentFactory = CAgentFactory::NewL(iAgent.ImplementationUid());
sl@0
   213
	// Construct the CAgentContent object
sl@0
   214
	iAgentContent = iAgentFactory->CreateContentBrowserL(aHeaderData);
sl@0
   215
sl@0
   216
	// Finished with resolver (and the agentInfo object it owns)
sl@0
   217
	CleanupStack::PopAndDestroy(resolver); 
sl@0
   218
	}
sl@0
   219
sl@0
   220
#endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
   221
sl@0
   222
EXPORT_C TInt CContent::OpenContainer(const TDesC &aUniqueId) 
sl@0
   223
	{
sl@0
   224
	return iAgentContent->OpenContainer(aUniqueId);
sl@0
   225
	}
sl@0
   226
sl@0
   227
EXPORT_C TInt CContent::CloseContainer ()
sl@0
   228
	{
sl@0
   229
	return iAgentContent->CloseContainer();
sl@0
   230
	}
sl@0
   231
sl@0
   232
EXPORT_C void CContent::GetEmbeddedObjectsL (RStreamablePtrArray<CEmbeddedObject>& aArray) const
sl@0
   233
	{
sl@0
   234
	iAgentContent->GetEmbeddedObjectsL(aArray);
sl@0
   235
	}
sl@0
   236
sl@0
   237
EXPORT_C void CContent::GetEmbeddedObjectsL (RStreamablePtrArray<CEmbeddedObject>& aArray, TEmbeddedType aType) const
sl@0
   238
	{
sl@0
   239
	iAgentContent->GetEmbeddedObjectsL(aArray, aType);
sl@0
   240
	}
sl@0
   241
sl@0
   242
EXPORT_C TInt  CContent::Search (RStreamablePtrArray<CEmbeddedObject>& aArray, const TDesC8 &aMimeType, TBool aRecursive) 
sl@0
   243
	{
sl@0
   244
	return iAgentContent->Search(aArray, aMimeType, aRecursive);
sl@0
   245
	}
sl@0
   246
sl@0
   247
EXPORT_C TInt CContent::GetAttribute (TInt aAttribute, TInt &aValue) const
sl@0
   248
	{
sl@0
   249
	return GetAttribute(aAttribute, aValue, iDefaultVirtualPath.UniqueId());
sl@0
   250
	}
sl@0
   251
sl@0
   252
EXPORT_C TInt CContent::GetAttribute (TInt aAttribute, TInt& aValue, const TDesC &aUniqueId) const
sl@0
   253
	{
sl@0
   254
	return iAgentContent->GetAttribute(aAttribute, aValue, aUniqueId);
sl@0
   255
	}
sl@0
   256
sl@0
   257
EXPORT_C TInt CContent::GetAttributeSet(RAttributeSet& aAttributeSet) const
sl@0
   258
	{
sl@0
   259
	return GetAttributeSet(aAttributeSet, iDefaultVirtualPath.UniqueId());
sl@0
   260
	}
sl@0
   261
sl@0
   262
EXPORT_C TInt CContent::GetAttributeSet(RAttributeSet& aAttributeSet, const TDesC& aUniqueId) const
sl@0
   263
	{
sl@0
   264
	return iAgentContent->GetAttributeSet(aAttributeSet, aUniqueId);
sl@0
   265
	}
sl@0
   266
sl@0
   267
EXPORT_C TInt CContent::GetStringAttribute (TInt aAttribute, TDes &aValue) const
sl@0
   268
	{
sl@0
   269
	return GetStringAttribute(aAttribute, aValue, iDefaultVirtualPath.UniqueId());
sl@0
   270
	}
sl@0
   271
sl@0
   272
EXPORT_C TInt CContent::GetStringAttribute (TInt aAttribute, TDes &aValue, const TDesC &aUniqueId) const
sl@0
   273
	{
sl@0
   274
	return iAgentContent->GetStringAttribute(aAttribute, aValue, aUniqueId);
sl@0
   275
	}
sl@0
   276
sl@0
   277
EXPORT_C TInt CContent::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet) const
sl@0
   278
	{
sl@0
   279
	return GetStringAttributeSet(aStringAttributeSet, iDefaultVirtualPath.UniqueId());
sl@0
   280
	}
sl@0
   281
sl@0
   282
EXPORT_C TInt CContent::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet, const TDesC& aUniqueId) const
sl@0
   283
	{
sl@0
   284
	return iAgentContent->GetStringAttributeSet(aStringAttributeSet, aUniqueId);
sl@0
   285
	}
sl@0
   286
sl@0
   287
EXPORT_C TInt CContent::AgentSpecificCommand (TInt aCommand, const TDesC8 &aInputBuffer, TDes8 &aOutputBuffer) 
sl@0
   288
	{
sl@0
   289
	return iAgentContent->AgentSpecificCommand(aCommand, aInputBuffer, aOutputBuffer);
sl@0
   290
	}
sl@0
   291
sl@0
   292
EXPORT_C void CContent::AgentSpecificCommand (TInt aCommand, const TDesC8 &aInputBuffer, TDes8 &aOutputBuffer, TRequestStatus &aStatus) 
sl@0
   293
	{
sl@0
   294
	iAgentContent->AgentSpecificCommand(aCommand, aInputBuffer, aOutputBuffer, aStatus);
sl@0
   295
	}
sl@0
   296
sl@0
   297
EXPORT_C void CContent::NotifyStatusChange(TEventMask aMask, TRequestStatus &aStatus) 
sl@0
   298
	{
sl@0
   299
	NotifyStatusChange(aMask, aStatus, iDefaultVirtualPath.UniqueId());
sl@0
   300
	}
sl@0
   301
sl@0
   302
EXPORT_C void CContent::NotifyStatusChange(TEventMask aMask, TRequestStatus &aStatus, const TDesC &aUniqueId) 
sl@0
   303
	{
sl@0
   304
	iAgentContent->NotifyStatusChange(aMask, aStatus, aUniqueId);
sl@0
   305
	}
sl@0
   306
sl@0
   307
EXPORT_C TInt CContent::CancelNotifyStatusChange(TRequestStatus &aStatus) 
sl@0
   308
	{
sl@0
   309
	return CancelNotifyStatusChange(aStatus, iDefaultVirtualPath.UniqueId());
sl@0
   310
	}
sl@0
   311
sl@0
   312
EXPORT_C TInt CContent::CancelNotifyStatusChange(TRequestStatus &aStatus, const TDesC &aUniqueId) 
sl@0
   313
	{
sl@0
   314
	return iAgentContent->CancelNotifyStatusChange(aStatus, aUniqueId);
sl@0
   315
	}
sl@0
   316
sl@0
   317
EXPORT_C void  CContent::RequestRights(TRequestStatus &aStatus) 
sl@0
   318
	{
sl@0
   319
	RequestRights(aStatus, iDefaultVirtualPath.UniqueId());
sl@0
   320
	}
sl@0
   321
sl@0
   322
EXPORT_C void  CContent::RequestRights(TRequestStatus &aStatus, const TDesC &aUniqueId) 
sl@0
   323
	{
sl@0
   324
	iAgentContent->RequestRights(aStatus, aUniqueId);
sl@0
   325
	}
sl@0
   326
sl@0
   327
EXPORT_C TInt CContent::CancelRequestRights(TRequestStatus &aStatus)
sl@0
   328
	{
sl@0
   329
	return CancelRequestRights(aStatus, iDefaultVirtualPath.UniqueId());
sl@0
   330
	}
sl@0
   331
sl@0
   332
EXPORT_C TInt CContent::CancelRequestRights(TRequestStatus &aStatus, const TDesC& aUniqueId)
sl@0
   333
	{
sl@0
   334
	return iAgentContent->CancelRequestRights(aStatus, aUniqueId);
sl@0
   335
	}
sl@0
   336
sl@0
   337
EXPORT_C void CContent::DisplayInfoL(TDisplayInfo aInfo) const
sl@0
   338
	{
sl@0
   339
	DisplayInfoL(aInfo, iDefaultVirtualPath.UniqueId());
sl@0
   340
	}
sl@0
   341
sl@0
   342
EXPORT_C void CContent::DisplayInfoL(TDisplayInfo aInfo, const TDesC& aUniqueId) const
sl@0
   343
	{
sl@0
   344
	iAgentContent->DisplayInfoL(aInfo, aUniqueId);
sl@0
   345
	}
sl@0
   346
sl@0
   347
EXPORT_C TInt CContent::SetProperty(TAgentProperty aProperty, TInt aValue) 
sl@0
   348
	{
sl@0
   349
	return iAgentContent->SetProperty(aProperty, aValue);
sl@0
   350
	}
sl@0
   351
sl@0
   352
EXPORT_C CData* CContent::OpenContentL(TIntent aIntent)
sl@0
   353
	{
sl@0
   354
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
   355
	if(iHeaderData != NULL)
sl@0
   356
		return OpenContentL(aIntent, *iHeaderData);
sl@0
   357
    else
sl@0
   358
		return OpenContentL(aIntent, iDefaultVirtualPath.UniqueId());
sl@0
   359
#else
sl@0
   360
	return OpenContentL(aIntent, iDefaultVirtualPath.UniqueId());
sl@0
   361
#endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
   362
	}
sl@0
   363
sl@0
   364
EXPORT_C CData* CContent::OpenContentLC(TIntent aIntent)
sl@0
   365
	{
sl@0
   366
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
   367
	if(iHeaderData != NULL)
sl@0
   368
		return OpenContentLC(aIntent, *iHeaderData);
sl@0
   369
	else
sl@0
   370
		return OpenContentLC(aIntent, iDefaultVirtualPath.UniqueId());
sl@0
   371
#else
sl@0
   372
	return OpenContentLC(aIntent, iDefaultVirtualPath.UniqueId());
sl@0
   373
#endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
   374
	}
sl@0
   375
sl@0
   376
EXPORT_C CData* CContent::OpenContentL(TIntent aIntent, const TDesC &aUniqueId)
sl@0
   377
	{
sl@0
   378
	CData* data = OpenContentLC(aIntent, aUniqueId);
sl@0
   379
	CleanupStack::Pop(data);
sl@0
   380
	return data;
sl@0
   381
	}
sl@0
   382
sl@0
   383
EXPORT_C CData* CContent::OpenContentLC(TIntent aIntent, const TDesC &aUniqueId)
sl@0
   384
	{
sl@0
   385
	// Open the content object specified by the Unique Id
sl@0
   386
	if(iVirtualPath)
sl@0
   387
		{
sl@0
   388
		// create a CData based upon the URI supplied when this CContent was created
sl@0
   389
		return CData::NewLC(iAgent.ImplementationUid(), TVirtualPathPtr(iDefaultVirtualPath.URI(), aUniqueId), aIntent, iShareMode);
sl@0
   390
		}
sl@0
   391
	else
sl@0
   392
		{
sl@0
   393
		// create a CData based upon the file handle supplied when this CContent was created
sl@0
   394
		return CData::NewLC(iAgent.ImplementationUid(), iFile, aUniqueId, aIntent);
sl@0
   395
		}
sl@0
   396
	}
sl@0
   397
	
sl@0
   398
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
   399
sl@0
   400
CData* CContent::OpenContentL(TIntent aIntent, const TDesC8& aHeaderData)
sl@0
   401
	{
sl@0
   402
	CData* data = OpenContentLC(aIntent, aHeaderData);
sl@0
   403
	CleanupStack::Pop(data);
sl@0
   404
	return data;
sl@0
   405
	}
sl@0
   406
sl@0
   407
CData* CContent::OpenContentLC(TIntent aIntent, const TDesC8& aHeaderData)
sl@0
   408
	{
sl@0
   409
	return CData::NewLC(iAgent.ImplementationUid(), aHeaderData, aIntent);
sl@0
   410
	}
sl@0
   411
	
sl@0
   412
#endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
   413
sl@0
   414
EXPORT_C const TAgent& CContent::Agent() const
sl@0
   415
	{
sl@0
   416
	// The agent handling this content
sl@0
   417
	return iAgent;
sl@0
   418
	}
sl@0
   419
sl@0
   420
#ifndef REMOVE_CAF1 
sl@0
   421
// Deprecated functions
sl@0
   422
sl@0
   423
EXPORT_C CData* CContent::OpenContentL(TIntent aIntent, TContentShareMode aShareMode)
sl@0
   424
	{
sl@0
   425
	CData* data = NULL;
sl@0
   426
	// Open the content object specified by the Unique Id
sl@0
   427
	if(iVirtualPath)
sl@0
   428
		{
sl@0
   429
		// create a CData based upon the URI supplied when this CContent was created
sl@0
   430
		data = CData::NewLC(iAgent.ImplementationUid(), iDefaultVirtualPath, aIntent, aShareMode);
sl@0
   431
		}
sl@0
   432
	else
sl@0
   433
		{
sl@0
   434
		// create a CData based upon the file handle supplied when this CContent was created
sl@0
   435
		data = CData::NewLC(iAgent.ImplementationUid(), iFile, iDefaultVirtualPath.UniqueId(), aIntent);
sl@0
   436
		}
sl@0
   437
	CleanupStack::Pop(data);
sl@0
   438
	return data;
sl@0
   439
	}
sl@0
   440
sl@0
   441
EXPORT_C CAttribute* CContent::NewAttributeL(TBool aPreloaded)
sl@0
   442
	{
sl@0
   443
	return NewAttributeL(aPreloaded, EContentShareReadOnly);
sl@0
   444
	}
sl@0
   445
sl@0
   446
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
   447
EXPORT_C CAttribute* CContent::NewAttributeL(TBool aPreloaded, TContentShareMode aShareMode)
sl@0
   448
	{
sl@0
   449
	CAttribute* attr = NULL;
sl@0
   450
	
sl@0
   451
	if(iVirtualPath)
sl@0
   452
		{
sl@0
   453
		// if we were opened with a file name
sl@0
   454
		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iDefaultVirtualPath.URI(), aShareMode);
sl@0
   455
		}
sl@0
   456
	else if(iHeaderData)
sl@0
   457
		{
sl@0
   458
		attr = CAttribute::NewLC(iAgent.ImplementationUid(), *iHeaderData);
sl@0
   459
		}
sl@0
   460
	else
sl@0
   461
		{
sl@0
   462
		// if we were opened with a file handle 
sl@0
   463
		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iFile);
sl@0
   464
		}
sl@0
   465
sl@0
   466
	// If aPreloaded is set, query the agent immediately for all the attributes
sl@0
   467
	if (aPreloaded)
sl@0
   468
		{
sl@0
   469
		attr->QuerySet().SetAll();
sl@0
   470
		attr->GetL();
sl@0
   471
		}
sl@0
   472
sl@0
   473
	CleanupStack::Pop(attr);
sl@0
   474
	return attr;
sl@0
   475
	}
sl@0
   476
sl@0
   477
#else
sl@0
   478
sl@0
   479
EXPORT_C CAttribute* CContent::NewAttributeL(TBool aPreloaded, TContentShareMode aShareMode)
sl@0
   480
	{
sl@0
   481
	CAttribute* attr = NULL;
sl@0
   482
	
sl@0
   483
	if(iVirtualPath)
sl@0
   484
		{
sl@0
   485
		// if we were opened with a file name
sl@0
   486
		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iDefaultVirtualPath.URI(), aShareMode);
sl@0
   487
		}
sl@0
   488
	else
sl@0
   489
		{
sl@0
   490
		// if we were opened with a file handle 
sl@0
   491
		attr = CAttribute::NewLC(iAgent.ImplementationUid(), iFile);
sl@0
   492
		}
sl@0
   493
sl@0
   494
	// If aPreloaded is set, query the agent immediately for all the attributes
sl@0
   495
	if (aPreloaded)
sl@0
   496
		{
sl@0
   497
		attr->QuerySet().SetAll();
sl@0
   498
		attr->GetL();
sl@0
   499
		}
sl@0
   500
sl@0
   501
	CleanupStack::Pop(attr);
sl@0
   502
	return attr;
sl@0
   503
	}
sl@0
   504
sl@0
   505
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
   506
sl@0
   507
#endif // REMOVE_CAF1
sl@0
   508
sl@0
   509
// DLL entry point - only for EKA1
sl@0
   510
sl@0
   511
sl@0
   512
sl@0
   513