os/security/contentmgmt/contentaccessfwfordrm/inc/data.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2003-2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 
    20 /** 
    21 @file
    22 
    23 @publishedAll
    24 @released
    25 */
    26 
    27 
    28 #ifndef __DATA_H__
    29 #define __DATA_H__
    30 
    31 #include <e32base.h>
    32 #include <f32file.h>
    33 #include <caf/caftypes.h>
    34 
    35 namespace ContentAccess
    36 {
    37 	class CAgentFactory;
    38 	class CAgentInfo;
    39 	class TVirtualPathPtr;
    40 	class CAgentData;
    41 	class RAttributeSet;
    42 	class RStringAttributeSet;
    43 	
    44 
    45 	/**
    46  	Allows clients to read data from a content object. 
    47 	 
    48  	This class is initialised with an agent implementation that is
    49  	responsible for this content object.
    50  
    51  	*/
    52 	class CData : public CBase
    53 		{
    54 	public:
    55 		/** 
    56 		 Creates a new CData object. 
    57 		 
    58 		 @param aVirtualPath The content object to read
    59 		 @param aIntent	The intended use of the content.
    60 		 @param aShareMode The file share mode used to open this content.
    61 		 @return The new CData object.
    62 		  
    63 		 @leave KErrNotFound		The content object with the given UniqueId does not exist.
    64 		 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
    65 		 @leave KErrCANoPermission	Rights exist but the specified intent is not permitted.
    66 		 @leave KErrCANoRights		No rights exist for the content object.
    67 		 @leave KErrCANotSupported	Unable to open the object with the specified UniqueId, it may be a container object.
    68 		 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
    69 		 @leave KErrAccessDenied	The content is already in use.
    70 		 @leave ...		One of the other CAF error codes defined in \c caferr.h  
    71 		 				or one of the other system-wide error codes 
    72 						for any other errors.
    73 		 */
    74 		IMPORT_C static CData* NewL(const TVirtualPathPtr& aVirtualPath,
    75 							TIntent aIntent, TContentShareMode aShareMode); 
    76 
    77 		/** 
    78 		 Creates a new CData object. 
    79 		 
    80 		 @param aVirtualPath The content object to read.
    81 		 @param aShareMode The file share mode used to open this content.
    82 		 @return The new CData object.
    83 		  
    84 		 @leave KErrNotFound		The content object with the given UniqueId does not exist.
    85 		 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
    86 		 @leave KErrCANoPermission	Rights exist but the specified intent is not permitted.
    87 		 @leave KErrCANoRights		No rights exist for the content object.
    88 		 @leave KErrCANotSupported	Unable to open the object with the specified UniqueId, it may be a container object.
    89 		 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
    90 		 @leave KErrAccessDenied	The content is already in use.
    91 		 @leave ... 	One of the other CAF error codes defined in \c caferr.h  
    92 		 				or one of the other system-wide error codes for 
    93 						any other errors.		 
    94 		 */
    95 		IMPORT_C static CData* NewL(const TVirtualPathPtr& aVirtualPath,
    96 							TContentShareMode aShareMode); 
    97 		
    98 
    99 		/** 
   100 		 Creates a new CData object 
   101 		 
   102 		 @param aVirtualPath The content object to read.
   103 		 @param aIntent	The intended use of the content.
   104 		 @param aShareMode The file share mode used to open this content.
   105 		 @return The new CData object.
   106 		  
   107 		 @leave KErrNotFound		The content object with the given UniqueId does not exist.
   108 		 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
   109 		 @leave KErrCANoPermission	Rights exist but the specified intent is not permitted.
   110 		 @leave KErrCANoRights		No rights exist for the content object.
   111 		 @leave KErrCANotSupported	Unable to open the object with the specified UniqueId, it may be a container object.
   112 		 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
   113 		 @leave KErrAccessDenied	The content is already in use.
   114 		 @leave ...		One of the other CAF error codes defined in \c caferr.h  
   115 		 				or one of the other system-wide error codes for 
   116 						any other errors.
   117 		 */
   118 		IMPORT_C static CData* NewLC(const TVirtualPathPtr& aVirtualPath,
   119 							TIntent aIntent, TContentShareMode aShareMode); 
   120 
   121 		/** 
   122 		 Creates a new CData object 
   123 		 
   124 		 @param aVirtualPath The content object to read.
   125 		 @param aShareMode The file share mode used to open this content.
   126 		 @return The new CData object.
   127 		  
   128 		 @leave KErrNotFound		The content object with the given UniqueId does not exist.
   129 		 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
   130 		 @leave KErrCANoPermission	Rights exist but the specified intent is not permitted.
   131 		 @leave KErrCANoRights		No rights exist for the content object.
   132 		 @leave KErrCANotSupported	Unable to open the object with the specified UniqueId, it may be a container object.
   133 		 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
   134 		 @leave KErrAccessDenied	The content is already in use.
   135 		 @leave ...			One of the other CAF error codes defined in \c caferr.h  
   136 		 					or one of the other system-wide error codes for 
   137 							any other errors.
   138 		 */					
   139 		IMPORT_C static CData* NewLC(const TVirtualPathPtr& aVirtualPath,
   140 							TContentShareMode aShareMode); 
   141 
   142 							
   143 		/** 
   144 		 Creates a new CData object. 
   145 		 
   146 		 @param aFile An open RFile handle, the agent will make a duplicate of this handle. 
   147 		 The underlying RFs session should be shared for transfer to other processes using RFs::ShareProtected(), since the agent may use transfer this handle to its own or one of the system servers.
   148 		 @param aUniqueId The content object to read.
   149 		 @param aIntent	The intended use of the content.
   150 		 @return The new CData object.
   151 		  
   152 		 @leave KErrNotFound		The content object with the given UniqueId does not exist.
   153 		 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
   154 		 @leave KErrCANoPermission	Rights exist but the specified intent is not permitted.
   155 		 @leave KErrCANoRights		No rights exist for the content object.
   156 		 @leave KErrCANotSupported	Unable to open the object with the specified UniqueId, it may be a container object.
   157 		 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
   158 		 @leave KErrAccessDenied	The content is already in use.
   159 		 @leave ...			One of the other CAF error codes defined in \c caferr.h  
   160 		 					or one of the other system-wide error codes for 
   161 							any other errors.
   162 		 */
   163 		IMPORT_C static CData* NewL(RFile& aFile, const TDesC& aUniqueId, TIntent aIntent);
   164 
   165 		/** 
   166 		 Creates a new CData object. 
   167 		 
   168 		 @param aFile An open RFile handle, the agent will make a duplicate of this handle. 
   169 		 The underlying RFs session should be shared for transfer to other processes using RFs::ShareProtected(), since the agent may use transfer this handle to its own or one of the system servers.
   170 		 @param aUniqueId The content object to read.
   171 		 @return The new CData object.
   172 		  
   173 		 @leave KErrNotFound		The content object with the given UniqueId does not exist.
   174 		 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
   175 		 @leave KErrCANoPermission	Rights exist but the specified intent is not permitted.
   176 		 @leave KErrCANoRights		No rights exist for the content object.
   177 		 @leave KErrCANotSupported	Unable to open the object with the specified UniqueId, it may be a container object.
   178 		 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
   179 		 @leave KErrAccessDenied	The content is already in use.
   180 		 @leave ...			One of the other CAF error codes defined in \c caferr.h  
   181 		 					or one of the other system-wide error codes for 
   182 							any other errors.
   183 		 */
   184 		IMPORT_C static CData* NewL(RFile& aFile, const TDesC& aUniqueId);
   185 		
   186 		/** 
   187 		 Creates a new CData object. 
   188 		 
   189 		 @param aFile An open RFile handle, the agent will make a duplicate of this handle. 
   190 		 The underlying RFs session should be shared for transfer to other processes using RFs::ShareProtected(), since the agent may use transfer this handle to its own or one of the system servers.
   191 		 @param aUniqueId The content object to read.
   192 		 @param aIntent	The intended use of the content.
   193 		 @return The new CData object.
   194 		  
   195 		 @leave KErrNotFound		The content object with the given UniqueId does not exist.
   196 		 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
   197 		 @leave KErrCANoPermission	Rights exist but the specified intent is not permitted.
   198 		 @leave KErrCANoRights		No rights exist for the content object.
   199 		 @leave KErrCANotSupported	Unable to open the object with the specified UniqueId, it may be a container object.
   200 		 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
   201 		 @leave KErrAccessDenied	The content is already in use.
   202 		 @leave ...				One of the other CAF error codes defined in \c caferr.h  
   203 		 						or one of the other system-wide error codes 
   204 								for any other errors.
   205 		 */
   206 		IMPORT_C static CData* NewLC(RFile& aFile, const TDesC& aUniqueId, TIntent aIntent);
   207 		
   208 		/** 
   209 		 Creates a new CData object. 
   210 		 
   211 		 @param aFile An open RFile handle, the agent will make a duplicate of this handle. 
   212 		 The underlying RFs session should be shared for transfer to other processes using RFs::ShareProtected(), since the agent may use transfer this handle to its own or one of the system servers.
   213 		 @param aUniqueId The content object to read.
   214 		 @return The new CData object.
   215 		  
   216 		 @leave KErrNotFound		The content object with the given UniqueId does not exist.
   217 		 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
   218 		 @leave KErrCANoPermission	Rights exist but the specified intent is not permitted.
   219 		 @leave KErrCANoRights		No rights exist for the content object.
   220 		 @leave KErrCANotSupported	Unable to open the object with the specified UniqueId, it may be a container object.
   221 		 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
   222 		 @leave KErrAccessDenied	The content is already in use.
   223 		 @leave ...				One of the other CAF error codes defined in \c caferr.h  
   224 		 						or one of the other system-wide error codes 
   225 								for any other errors.
   226 		 */
   227 		IMPORT_C static CData* NewLC(RFile& aFile, const TDesC& aUniqueId);
   228 		
   229 		/** 
   230 		 Creates a new CData object. 
   231 		 
   232 		 @param aAgentUid The agent determined to support this content.
   233 		 @param aVirtualPath The content object to read.
   234 		 @param aIntent	The intended use of the content.
   235 		 @param aShareMode The file share mode used to open this content.
   236 		 @return The new CData object.
   237 		  
   238 		 @leave KErrNotFound		The content object with the given UniqueId does not exist.
   239 		 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
   240 		 @leave KErrCANoPermission	Rights exist but the specified intent is not permitted.
   241 		 @leave KErrCANoRights		No rights exist for the content object.
   242 		 @leave KErrCANotSupported	Unable to open the object with the specified UniqueId, it may be a container object.
   243 		 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
   244 		 @leave KErrAccessDenied	The content is already in use.
   245 		 @leave ...				One of the other CAF error codes defined in \c caferr.h  
   246 		 						or one of the other system-wide error codes 
   247 								for any other errors.
   248 		 */
   249 		static CData* NewLC(TUid aAgentUid, const TVirtualPathPtr& aVirtualPath,
   250 							TIntent aIntent, TContentShareMode aShareMode); 
   251 		
   252 		/** 
   253 		 Creates a new CData object. 
   254 		 
   255 		 @param aAgentUid The Uid of the agent who supports this content.
   256 		 @param aFile An open RFile handle, the agent will make a duplicate of this handle. 
   257 		 The underlying RFs session should be shared for transfer to other processes using RFs::ShareProtected(), since the agent may use transfer this handle to its own or one of the system servers.
   258 		 @param aUniqueId The content object to read.
   259 		 @param aIntent	The intended use of the content.
   260 		 @return The new CData object.
   261 		  
   262 		 @leave KErrNotFound		The content object with the given UniqueId does not exist.
   263 		 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
   264 		 @leave KErrCANoPermission	Rights exist but the specified intent is not permitted.
   265 		 @leave KErrCANoRights		No rights exist for the content object.
   266 		 @leave KErrCANotSupported	Unable to open the object with the specified UniqueId, it may be a container object.
   267 		 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
   268 		 @leave KErrAccessDenied	The content is already in use.
   269 		 @leave ...				One of the other CAF error codes defined in \c caferr.h  
   270 		 						or one of the other system-wide error codes for 
   271 								any other errors.
   272 
   273 		 */
   274 		static CData* NewLC(TUid aAgentUid, RFile& aFile, const TDesC& aUniqueId, TIntent aIntent);
   275 
   276 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   277 		
   278 		/** 
   279 		 Creates a new CData object. 
   280 		 @param aHeaderData				Header data of WMDRM file/stream content. 
   281 		 @return 						CData object.
   282 		 @leave							One of the CAF error codes defined in caferr.h or one of the 
   283 										system-wide error for any other errors.
   284 		 @capability 					DRM Access to DRM protected content is not permitted for processes without DRM capability.
   285 										Access to unprotected content is unrestricted.
   286 		*/
   287 			
   288 		IMPORT_C static CData* NewL(const TDesC8& aHeaderData);
   289 		
   290 		/** 
   291 		 Creates a new CData object. 
   292 		 @param aHeaderData				Header data of WMDRM file/stream content.
   293 		 @param aIntent					The intended use of the content.
   294 		 @return 						CData object.
   295 		 @leave							One of the CAF error codes defined in caferr.h or one of the 
   296 										system-wide error for any other errors.
   297 		 @capability 					DRM Access to DRM protected content is not permitted for processes without DRM capability.
   298 										Access to unprotected content is unrestricted.
   299 		*/		
   300 		
   301 		IMPORT_C static CData* NewL(const TDesC8& aHeaderData, TIntent aIntent);
   302 		
   303 		/** 
   304 		 Creates a new CData object. 
   305 		 @param aHeaderData				Header data of WMDRM file/stream content. 
   306 		 @return 						CData object.
   307 		 @leave							One of the CAF error codes defined in caferr.h or one of the 
   308 										system-wide error for any other errors.
   309 		 @capability 					DRM Access to DRM protected content is not permitted for processes without DRM capability.
   310 										Access to unprotected content is unrestricted.
   311 		*/
   312 		
   313 		IMPORT_C static CData* NewLC(const TDesC8& aHeaderData);
   314 		
   315 		/** 
   316 		 Creates a new CData object. 
   317 		 @param aHeaderData				Header data of WMDRM file/stream content.
   318 		 @param aIntent					The intended use of the content. 
   319 		 @return 						CData object.
   320 		 @leave							One of the CAF error codes defined in caferr.h or one of the 
   321 										system-wide error for any other errors.
   322 		 @capability 					DRM Access to DRM protected content is not permitted for processes without DRM capability.
   323 										Access to unprotected content is unrestricted.
   324 		*/
   325 		
   326 		IMPORT_C static CData* NewLC(const TDesC8& aHeaderData, TIntent aIntent);
   327 		
   328 		/** 
   329 		 Creates a new CData object.
   330 		 @param	aAgentUid				UID of an agent which supports this content. 
   331 		 @param aHeaderData				Header data of WMDRM file/stream content.
   332 		 @param aIntent					The intended use of the content.
   333 		 @return 						CData object.
   334 		 @leave							One of the CAF error codes defined in caferr.h or one of the 
   335 										system-wide error for any other errors.
   336 		 @capability 					DRM Access to DRM protected content is not permitted for processes without DRM capability.
   337 										Access to unprotected content is unrestricted.
   338 		 
   339 		*/
   340 		
   341 		static CData* NewLC(TUid aAgentUid, const TDesC8& aHeaderData, TIntent aIntent);
   342 		
   343 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   344 
   345 		/** destructor */
   346 		virtual ~CData();
   347 		
   348 		/** 
   349 		 Reads from a content object up to the maximum length of the
   350 		 descriptor or the end of the content object.
   351 		 	
   352 		 When an attempt is made to read beyond the end of the content,
   353 		 no error is returned. The descriptor’s length is set to the
   354 		 number of bytes that were read into it. Therefore, when reading
   355 		 through content, the end has been reached when the
   356 		 descriptor length (given by TDesC::Length()) is zero.
   357 		 
   358 		 @param aDes	Descriptor into which binary data is read. Any existing
   359 		  				contents are overwritten. On return, its length is set
   360 		 				to the number of bytes read.
   361 		 @return		KErrNone if successful.
   362 		 @return		One of the CAF error codes defined in \c caferr.h  or 
   363 		 				one of the other system-wide error codes.
   364  		@capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted 
   365 		*/
   366 		IMPORT_C TInt Read(TDes8& aDes) const;
   367 
   368 		/** 
   369 		 Reads from a content object up to the specified length of the
   370 		 descriptor or the end of the content object.
   371 		 	
   372 		 @see Read(TDes8& aDes)
   373 		 		 
   374 		 @param aDes	Descriptor into which binary data is read. Any existing
   375 		  				contents are overwritten. On return, its length is set
   376 		 				to the number of bytes read.
   377 		 @param aLength		The number of bytes to read from the file,
   378 		 					or to the end of the file, whichever is encountered first. 
   379 		 					The length of the buffer is set to the number of bytes actually read.
   380 		 @return		KErrNone if successful.
   381 		 @return		Otherwise one of the CAF error codes defined in \c caferr.h  or 
   382 		 				one of the other system-wide error codes.
   383 		@capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted 
   384 		*/
   385 		IMPORT_C TInt Read(TDes8& aDes,TInt aLength) const;
   386 		
   387 		/**
   388 		 Read content asynchronously up to the maximum length of the descriptor
   389 		 or until the end of the content object is reached.
   390 		 NB: It is important that the descriptor passed to 
   391 		 aDes remains in scope until the request has completed.		
   392 		 
   393 		 @see Read(TDes8& aDes)
   394 		 
   395 		 @param aDes 		Descriptor into which binary data is read. Any
   396 		  					existing contents are overwritten. On return,
   397 		 					its length is set to the number of bytes read.
   398 		 @param aStatus		Asynchronous request status. On completion this will contain one 
   399 		 					of the following error codes: KErrNone if the data was 
   400 							successfully read. Otherwise one of the CAF error codes defined in 
   401 							\c caferr.h  or one of the other standard system-wide
   402 							error codes for any other errors.
   403 		@capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted 
   404 		*/	
   405 		IMPORT_C void Read(TDes8& aDes, TRequestStatus& aStatus) const;
   406 
   407 		/**
   408 		 Read content asynchronously up to the specified length 
   409 		 or until the end of the content object is reached.
   410 		 NB: It is important that the descriptor passed to 
   411 		 aDes remains in scope until the request has completed.		 	
   412 
   413 		 @see Read(TDes8& aDes)
   414 		 
   415 		 @param aDes 		Descriptor into which binary data is read. Any
   416 		  					existing contents are overwritten. On return,
   417 		 					its length is set to the number of bytes read.
   418 		 @param aLength		The number of bytes to read from the file,
   419 		 					or to the end of the file, whichever is encountered first. 
   420 		 					The length of the buffer is set to the number of bytes actually read.
   421 		 @param aStatus		Asynchronous request status. On completion this will contain one 
   422 		 					of the following error codes: KErrNone if the data was 
   423 							successfully read. Otherwise one of the CAF error codes defined in 
   424 							\c caferr.h  or one of the other standard system-wide
   425 							error codes for any other errors.
   426 		@capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted 
   427 		*/
   428 		IMPORT_C void Read(TDes8& aDes, TInt aLength, TRequestStatus& aStatus) const;
   429 		
   430 		/**
   431 		 Cancels asynchronous read.
   432 		 
   433 		 @param aStatus		Asynchronous request status. This parameter should have been supplied earlier to
   434 		 					an asynchronous Read call. If it has not been previously supplied to a Read call,
   435 		 					this function will not have any effect.
   436 		 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted 
   437 		*/
   438 		IMPORT_C void ReadCancel(TRequestStatus &aStatus) const;		
   439 
   440 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   441 		/**
   442 		 Reads content asynchronously. The data is read from a specified offset 
   443 		 up to a specified number of bytes or until the end of the content object 
   444 		 is reached. The data is read into the descriptor buffer supplied.
   445 		 NB: It is important that the descriptor passed to 
   446 		 aDes remains in scope until the request has completed.
   447 		 If agent does not support 64bit, fallback to 32bit Read is provided automatically by CAF			
   448 				 
   449 		 @see Read(TDes8& aDes)
   450 				 
   451 		 @param aPos		Position of first byte to be read. 
   452 							This is an offset from the start of the file. 
   453 		 @param aDes 		Descriptor into which binary data is read. Any
   454 		  					existing contents are overwritten. On return,
   455 		 					its length is set to the number of bytes read. 
   456 		 @param aLength		The number of bytes to read from the file,
   457 		 					or to the end of the file, whichever is encountered first. 
   458 		 					The length of the buffer is set to the number of bytes actually read.
   459 		 @param aStatus		Asynchronous request status. On completion this will contain one 
   460 		 					of the following error codes: KErrNone if the data was 
   461 							successfully read. Otherwise one of the CAF error codes defined in 
   462 							\c caferr.h  or one of the other standard system-wide
   463 							error codes for any other errors.
   464 		 @return KErrNone if the async read request was successfully submitted.
   465 		 @return KErrArgument if a negative offset is supplied.
   466 		 @return KErrCANotSupported if the agent does not support this operation.
   467 		 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted 
   468 		*/
   469 		IMPORT_C TInt Read(TInt64 aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus) const;
   470 #else
   471 			/**
   472 		 Reads content asynchronously. The data is read from a specified offset 
   473 		 up to a specified number of bytes or until the end of the content object 
   474 		 is reached. The data is read into the descriptor buffer supplied.
   475 				 
   476 		 @see Read(TDes8& aDes)
   477 				 
   478 		 @param aPos		Position of first byte to be read. 
   479 							This is an offset from the start of the file. 
   480 		 @param aDes 		Descriptor into which binary data is read. Any
   481 		  					existing contents are overwritten. On return,
   482 		 					its length is set to the number of bytes read. 
   483 		 @param aLength		The number of bytes to read from the file,
   484 		 					or to the end of the file, whichever is encountered first. 
   485 		 					The length of the buffer is set to the number of bytes actually read.
   486 		 @param aStatus		Asynchronous request status. On completion this will contain one 
   487 		 					of the following error codes: KErrNone if the data was 
   488 							successfully read. Otherwise one of the CAF error codes defined in 
   489 							\c caferr.h  or one of the other standard system-wide
   490 							error codes for any other errors.
   491 		 @return KErrNone if the async read request was successfully submitted.
   492 		 @return KErrArgument if a negative offset is supplied.
   493 		 @return KErrCANotSupported if the agent does not support this operation.
   494 		 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted 
   495 		*/
   496 		IMPORT_C TInt Read(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus) const;
   497 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   498 
   499 		/**
   500 		 Gets the data size in bytes.
   501 		 
   502 		 @param aSize	On return this will contain the size of the plaintext data in bytes.
   503 		 @leave KErrCASizeNotDetermined	Size could not be determined by the managing agent.
   504 		 @leave ...		One of the other CAF error codes defined in \c caferr.h  or one of the 
   505 						system-wide error codes for any other errors.		 
   506 		 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
   507 		 */
   508 		IMPORT_C void DataSizeL(TInt& aSize);
   509 
   510 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   511 		/**
   512 		 This is the 64bit version of CData::DataSizeL
   513 		 Client can call this function instead of CData::DataSizeL. If it's not implemented by the agent,
   514 		 fallback to 32bit counterpart will be provided automatically
   515 		 
   516 		 @see DataSizeL(TInt& aSize)
   517 		*/
   518 		IMPORT_C void DataSize64L(TInt64& aSize);
   519 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   520 				
   521 		/**
   522 		 Changes or retrieves the location of the file pointer within 
   523 		 the content object.
   524 		 
   525  		 NOTE: Some operations may fail if the content data is sourced over a network connection.		 
   526 		 
   527 		 There are four seek modes used: 
   528 		 
   529 		 @li ESeekStart - Sets the file pointer aPos bytes from the start of the 
   530 		 content object.  aPos is not modified by the call to Seek()
   531 		 @li ESeekEnd - Sets the file pointer aPos bytes from the end of the 
   532 		 content object. The aPos parameter supplied should be zero or negative 
   533 		 when using ESeekEnd. Upon completion aPos is updated with the current 
   534 		 position relative to the start of the content object.
   535 		 @li ESeekCurrent - Moves the file pointer aPos bytes from the current 
   536 		 position. Upon completion aPos is updated with the new position relative 
   537 		 to the start of the content object. Suppling a zero value for the aPos Parameter can be
   538 		 used to retrieve the current file pointer location 
   539 		 @li ESeekAddress Sets the aPos parameter to the address of the byte 
   540 		 aPos bytes from the start of the content object
   541 
   542 		 @see TSeek
   543 		 
   544 		 @param aMode	Seek mode - controls the destination of the
   545 		  				seek operation.
   546 		  
   547 		 @param aPos	Offset from either the start, end or current position depending upon 
   548 		 the seek mode. Negative offsets are used to seek before the current position or
   549 		 relative to the end of the file.
   550 		 
   551 		 @return		KErrNone if successful. 
   552 		 @return		Otherwise one of the CAF error codes defined in \c caferr.h  or one 
   553 		 				of the other system-wide error codes.
   554 		@capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted 
   555 		*/
   556 		IMPORT_C TInt Seek(TSeek aMode,TInt& aPos) const;
   557 		
   558 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   559 		/**
   560 		 This is the 64bit version of CData::Seek
   561 		 Client can call this function instead of CData::Seek. If it's not implemented by the agent,
   562 		 fallback to 32bit counterpart will be provided automatically
   563 		 
   564 		 @see Seek(TSeek aMode,TInt& aPos)
   565 		*/
   566 		IMPORT_C TInt Seek64(TSeek aMode,TInt64& aPos) const;
   567 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   568 
   569 		/** Request the agent handling this content to set a property value. If the property is set
   570 		it is only set for this CData session and does not impact other CAF	users.
   571 
   572 		 For example setting the buffer-size to 256 bytes can be achieved as follows:
   573 
   574 					@code
   575 		  			MyData->SetProperty(EAgentPropertyBufferSize, 256);
   576 		  			@endcode
   577 
   578   		@see ContentAccess::TAgentProperty
   579 	
   580 		@param aProperty The property to set.
   581 		@param aValue The value of the property.
   582 		@return Whether or not the property was set.
   583 		@return KErrNone if the property was set.
   584 		@return KErrCANotSupported if the agent does not support the property or value.
   585 		@return KErrAccessDenied if the agent does not permit the property to be changed.
   586 		@return KErrPermissionDenied if the application does not have the necessary capability to change the property.
   587 		@capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
   588 		*/
   589 		IMPORT_C TInt SetProperty(TAgentProperty aProperty, TInt aValue);
   590 		
   591 		/**
   592 		 Allows a client to verify that the intent is supported by the
   593 		 current rights for the data object. 
   594 		 
   595 		 @note Since the intent is only evaluated the agent will not decrement 
   596 		 any rights-state such as play counts.
   597 		  
   598 		 @see ContentAccess::TIntent
   599 
   600 		 @param aIntent	The intended way the content will be used.
   601 		 @return Whether rights exist allowing the content to be used for this intent.
   602 		 @return KErrNone if the intent is permitted.
   603 		 @return KErrNoRights if no rights exist for the specified content object.
   604 		 @return KErrCANoPermission	if rights exist but the specified intent is not permitted.
   605 		 @return KErrCAPendingRights if the rights have not yet arrived but are expected soon.
   606 		 @return KErrNoPermission if rights exist but none permit the specified intent.
   607 		 @return KErrPermissionDenied if the client is not allowed to use this content object.
   608 		 @return Otherwise one of the other CAF error codes defined in \c caferr.h  or one of the
   609 				other system-wide error codes for any other errors.
   610 		 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
   611 		 */		
   612 		IMPORT_C TInt EvaluateIntent(TIntent aIntent);
   613 		
   614 		/**
   615 		 Execute intent allows the application to signal it is about to carry out
   616 		 the specified intent on protected content.The agent will decrement applicable 
   617 		 stateful rights such as play counts where necessary.
   618 
   619   		 Applications should be very careful to use this function correctly.
   620 		 @li If ExecuteIntent() is never called stateful rights will never be decremented. Users will be able to use the content forever
   621 		 @li If ExecuteIntent() is called too often stateful rights may be consumed prematurely. 
   622 
   623 		 Usually it would be best to call ExecuteIntent immediately before the content 
   624 		 is displayed or the instant playback begins. ExecuteIntent should not be considered a 
   625 		 prerequisite for calling the Read functions. It is valid for an application to read from 
   626 		 the file before calling ExecuteIntent. 
   627 
   628 		 @note Since rights are executed here the agent will decrement any rights-state such as 
   629 		 play counts that apply. 
   630 		 
   631 		@param aIntent	The intent indicator.
   632 		@return The result of attempting executing the intent.
   633 		@return KErrNone if the intent is permitted and stateful rights may have been decremented.
   634 		@return KErrNoRights if no rights exist for the specified content object.
   635 		@return KErrCANoPermission	if rights exist but the specified intent is not permitted.
   636 		@return KErrCAPendingRights if the rights have not yet arrived but are expected soon.
   637 		@return KErrNoPermission if rights exist but none permit the specified intent.
   638 		@return KErrPermissionDenied if the client is not allowed to use this content object.
   639 		@return Otherwise one of the other CAF error codes defined in \c caferr.h  or one of the.
   640 				other system-wide error codes for any other errors.
   641 		@capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted 
   642 		*/		
   643 		IMPORT_C TInt ExecuteIntent(TIntent aIntent);
   644 		
   645 		/**  Get an attribute for the content object
   646 
   647 		@see ContentAccess::TAttribute
   648 
   649 		@code
   650 		CContent* content = CContent::NewL(uri);
   651 		CData* data = content->OpenContentL(EPlay, uniqueId);
   652 		delete content;
   653 
   654 		TInt value = 0;
   655 		TInt err = data->GetAttribute(EIsProtected, value);
   656 		if(err == KErrNone && value)
   657 			{
   658 			DisplayPadLock();
   659 			}
   660 
   661 		delete data;
   662 		@endcode
   663 
   664 		@param aAttribute The attribute to query, from ContentAccess::TAttribute.
   665 		@param aValue Used to return the attribute value.
   666 		@return Whether the attribute was updated.
   667 		@return KErrNone if the value of the attribute was updated.
   668 		@return KErrCANotSupported if the requested attribute does not exist.
   669 		@return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
   670 		@return Otherwise one of the other CAF error codes defined in \c caferr.h  or one of the 
   671 				other system-wide error codes for any other errors.
   672 		@capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted 
   673 		*/
   674 		IMPORT_C TInt GetAttribute(TInt aAttribute, TInt& aValue) const;
   675 
   676 		/** Get a set of attributes for the content object 
   677 
   678 		@see ContentAccess::TAttribute
   679 
   680 		The following example determines whether the content object 
   681 		is protected and has rights that will enable it to be viewed by the 
   682 		user
   683 
   684 		@code
   685 		// CData* data = a data object
   686 		
   687 		RAttributeSet attributeSet;
   688 		CleanupClosePushL(attributeSet);
   689 		attributeSet->AddL(EProtected);
   690 		attributeSet->AddL(ECanView);
   691 
   692 		User::LeaveIfError(data->GetAttributeSet(attributeSet);
   693 
   694 		TInt err = attributeSet.GetValue(EProtected, value);
   695 		if(err == KErrNone && value)
   696 				{
   697 				// file is DRM protected
   698 				}
   699 
   700 		err = attributeSet.GetValue(ECanView, value);
   701 		if(err == KErrNone && value)
   702 				{
   703 				// File has rights that allow it to be displayed on screen
   704 				}
   705 		
   706 		// Finished
   707 		CleanupStack::PopAndDestroy(); 	// attributeSet.Close()
   708 		@endcode
   709 
   710 
   711 		@param aAttributeSet The set of attributes to query and update.
   712 		@return Whether the attribute set was updated.
   713 		@return KErrNone if the attributes were retrieved successfully.
   714 		@return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
   715 		@return Otherwise one of the CAF error codes defined in \c caferr.h  or one of the 
   716 				other system-wide error codes for any other errors.				 
   717 		@capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted 
   718 		*/
   719 		IMPORT_C TInt GetAttributeSet(RAttributeSet& aAttributeSet) const;
   720 
   721 
   722 		/**  Get text string attributes or meta-data for the content object
   723 	
   724 		@see ContentAccess::TStringAttribute
   725 
   726 		@code
   727 		CContent* content = CContent::NewLC(uri);
   728 		CData* data = content->OpenContentLC(EPlay, uniqueId);
   729 		CleanupStack::PopAndDestroy(content);
   730 
   731 		TBuf <MAX_PATH> previewUri;
   732 		TInt err = data->GetStringAttribute(EPreviewURI, previewUri);
   733 		if(err == KErrNone)
   734 			{
   735 			DisplayPreview(previewUri);
   736 			}
   737 
   738 		CleanupStack::PopAndDestroy(data);
   739 		@endcode
   740 
   741 		@param aAttribute The attribute to query, from ContentAccess::TStringAttribute.
   742 		@param aValue Returns the value of the attribute.
   743 		@return Whether the value was updated.
   744 		@return KErrNone if the attribute was retrieved.
   745 		@return KErrOverflow if the buffer was not large enough to return the result.
   746 		@return KErrCANotSupported if the requested attribute does not exist.
   747 		@return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
   748 		@return Otherwise one of the other CAF error codes defined in \c caferr.h  or one of the 
   749 				other system-wide error codes for any other errors.				 
   750 		@capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted 
   751 		*/
   752 		IMPORT_C TInt GetStringAttribute(TInt aAttribute, TDes& aValue) const;
   753 
   754 		
   755 		
   756 		/** Obtain a set of string attributes for the content object 
   757 		
   758 		@see ContentAccess::TStringAttribute
   759 
   760 		@code
   761 		CContent* content = CContent::NewLC(uri);
   762 		CData* data = content->OpenContentLC(EPlay, uniqueId);
   763 
   764 		// create the attribute set, add the attributes we are interested in
   765 		RStringAttributeSet stringAttributeSet;
   766 		CleanupClosePushL(stringAttributeSet);
   767 		stringAttributeSet.AddL(EPreviewURI);
   768 		stringAttributeSet.AddL(ETitle);
   769 		
   770 		User::LeaveIfError(data->GetStringAttributeSet(stringAttributeSet));
   771 	
   772 		// Pass the value of the string attribute to DisplayPreview()
   773 		TFileName previewUri;
   774 		TInt err = stringAttributeSet.GetValue(EPreviewURI, previewUri);
   775 		if(err == KErrNone)
   776 			{
   777 			DisplayPreview(previewUri);
   778 			}
   779 		
   780 		CleanupStack::PopAndDestroy(3);	// content, data, stringAttributeSet
   781 		@endcode
   782 	
   783 
   784 		@param aStringAttributeSet The set of attributes to query and update.
   785 		@return Whether the string attribute set was updated.
   786 		@return KErrNone if the attributes were retrieved successfully.
   787 		@return KErrNotFound if the default content object was not found.
   788 		@return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
   789 		@return Otherwise one of the CAF error codes defined in \c caferr.h  or one of the 
   790 				other system-wide error codes for any other errors.				 
   791 		@capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted 
   792 		*/
   793 		IMPORT_C TInt GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet) const;
   794 				
   795 				
   796 #ifndef REMOVE_CAF1
   797 		/** Set Qos attribute
   798 		@param aQosAttr The Qos attribute to set.
   799 		@param aValue The value of the attribute.
   800 		@deprecated 
   801 		*/
   802 		IMPORT_C void SetQosL(TQosAttribute aQosAttr, TInt aValue);
   803 
   804 		/** Get the mime type of the content
   805 		@param aMimeType Buffer to store the mime type provided by the agent.
   806 		@return ETrue if the mime type was retrieved successfully.
   807 		@deprecated 
   808 		*/
   809 		IMPORT_C TBool GetMimeTypeL(TDes8& aMimeType) const;
   810 #endif	// REMOVE_CAF1
   811 
   812 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   813 		/**
   814 		Decrypts the encrypted input data packet.
   815 		
   816 		@param aEncryptedInputDataPacket	Buffer descriptor containing the encrypted data packet supplied by client application. 
   817 		@param aDecryptedOutputDataPacket	Buffer descriptor supplied by the client application into which the decrypted data is written.
   818 											The length of this descriptor must be equal to or greater than the input packet.
   819 		@return								KErrNone if successful.KErrInsufficientDataPacketLength if a part of input packet is provided,
   820 											otherwise one of the CAF error codes defined in \c caferr.h  or 
   821 		 									one of the other system-wide error codes.
   822 		@capability 						DRM Access to DRM protected content is not permitted for processes without DRM capability.
   823 											Access to unprotected content is unrestricted.
   824 		*/
   825 
   826 		IMPORT_C TInt Read(const TDesC8& aEncryptedInputDataPacket, TDes8& aDecryptedOutputDataPacket) const;
   827 		
   828 		/**
   829 		Decrypts the encrypted input data packet asynchronously.
   830 		@param aEncryptedInputDataPacket	Buffer descriptor containing the encrypted data packet supplied by client application. 
   831 		@param aDecryptedOutputDataPacket	Buffer descriptor supplied by the client application into which the decrypted data is written.
   832 											The length of this descriptor must be equal to or greater than the input packet.
   833 		@param aStatus						Asynchronous request status. On completion this will contain one of the following error codes:
   834 											KErrNone if the data packet was successfully decrypted.KErrInsufficientDataPacketLength if a 
   835 											part of input packet is provided, otherwise one of the CAF error codes defined in \c caferr.h or 
   836 		 									one of the other system-wide error codes.
   837 		@capability 						DRM Access to DRM protected content is not permitted for processes without DRM capability.
   838 										    Access to unprotected content is unrestricted. 
   839 		*/
   840 		IMPORT_C void Read(const TDesC8& aEncryptedInputDataPacket, TDes8& aDecryptedOutputDataPacket, TRequestStatus& aStatus) const;
   841 
   842 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   843 	
   844 	private:
   845 		CData();
   846 		void ConstructL(RFile& aFile, const TDesC& aUniqueId, TIntent aIntent);
   847 		void ConstructL(const TVirtualPathPtr& aVirtualPath, TIntent aIntent, TContentShareMode aShareMode);
   848 		void ConstructL(TUid aAgentUid, RFile& aFile, const TDesC& aUniqueId, TIntent aIntent);
   849 		void ConstructL(TUid aAgentUid, const TVirtualPathPtr& aVirtualPath, TIntent aIntent, TContentShareMode aShareMode); 
   850 
   851 		void ConstructL(RFile& aFile, const TDesC& aUniqueId);
   852 		void ConstructL(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode);
   853 		void ConstructL(TUid aAgentUid, RFile& aFile, const TDesC& aUniqueId);
   854 		void ConstructL(TUid aAgentUid, const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode); 
   855 
   856 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   857 		
   858 		void ConstructL(TUid aAgentUid, const TDesC8& aHeaderData, TIntent aIntent);
   859 		void ConstructL(const TDesC8& aHeaderData);
   860 		void ConstructL(const TDesC8& aHeaderData, TIntent aIntent);
   861 		void ConstructL(TUid aAgentUid, const TDesC8& aHeaderData);
   862 		
   863 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   864 
   865 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   866 		/*
   867 		 * This is the obselete 32bit Read and replaced by its 64bit counterpart
   868 		 * TInt Read(TInt64 aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus) const
   869 		 * However, this function still exits at its original ordinal to avoid BC break. 
   870 		 * Upgrade to 64bit Read is done automatically upon recompling the client code which uses CAF interfaces 
   871 		*/
   872 		IMPORT_C TInt Read_Unused(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus) const;
   873 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   874 
   875 	private:
   876 		// The agent handling this content
   877 		CAgentData* iAgentData; 
   878 
   879 		// Defacto ECOM session handle
   880 		CAgentFactory* iAgentFactory;
   881 
   882 		// Uid of the agent
   883 		TUid iAgentUid;
   884 		};
   885 
   886 } // namespace ContentAccess
   887 #endif /* __DATA_H__ */
   888