Update contrib.
2 * Copyright (c) 2003-2008 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
33 #include <caf/caftypes.h>
35 namespace ContentAccess
39 class TVirtualPathPtr;
42 class RStringAttributeSet;
46 Allows clients to read data from a content object.
48 This class is initialised with an agent implementation that is
49 responsible for this content object.
52 class CData : public CBase
56 Creates a new CData object.
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.
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
74 IMPORT_C static CData* NewL(const TVirtualPathPtr& aVirtualPath,
75 TIntent aIntent, TContentShareMode aShareMode);
78 Creates a new CData object.
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.
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
95 IMPORT_C static CData* NewL(const TVirtualPathPtr& aVirtualPath,
96 TContentShareMode aShareMode);
100 Creates a new CData object
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.
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
118 IMPORT_C static CData* NewLC(const TVirtualPathPtr& aVirtualPath,
119 TIntent aIntent, TContentShareMode aShareMode);
122 Creates a new CData object
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.
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
139 IMPORT_C static CData* NewLC(const TVirtualPathPtr& aVirtualPath,
140 TContentShareMode aShareMode);
144 Creates a new CData object.
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.
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
163 IMPORT_C static CData* NewL(RFile& aFile, const TDesC& aUniqueId, TIntent aIntent);
166 Creates a new CData object.
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.
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
184 IMPORT_C static CData* NewL(RFile& aFile, const TDesC& aUniqueId);
187 Creates a new CData object.
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.
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.
206 IMPORT_C static CData* NewLC(RFile& aFile, const TDesC& aUniqueId, TIntent aIntent);
209 Creates a new CData object.
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.
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.
227 IMPORT_C static CData* NewLC(RFile& aFile, const TDesC& aUniqueId);
230 Creates a new CData object.
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.
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.
249 static CData* NewLC(TUid aAgentUid, const TVirtualPathPtr& aVirtualPath,
250 TIntent aIntent, TContentShareMode aShareMode);
253 Creates a new CData object.
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.
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
274 static CData* NewLC(TUid aAgentUid, RFile& aFile, const TDesC& aUniqueId, TIntent aIntent);
276 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
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.
288 IMPORT_C static CData* NewL(const TDesC8& aHeaderData);
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.
301 IMPORT_C static CData* NewL(const TDesC8& aHeaderData, TIntent aIntent);
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.
313 IMPORT_C static CData* NewLC(const TDesC8& aHeaderData);
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.
326 IMPORT_C static CData* NewLC(const TDesC8& aHeaderData, TIntent aIntent);
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.
341 static CData* NewLC(TUid aAgentUid, const TDesC8& aHeaderData, TIntent aIntent);
343 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
349 Reads from a content object up to the maximum length of the
350 descriptor or the end of the content object.
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.
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
366 IMPORT_C TInt Read(TDes8& aDes) const;
369 Reads from a content object up to the specified length of the
370 descriptor or the end of the content object.
372 @see Read(TDes8& aDes)
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
385 IMPORT_C TInt Read(TDes8& aDes,TInt aLength) const;
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.
393 @see Read(TDes8& aDes)
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
405 IMPORT_C void Read(TDes8& aDes, TRequestStatus& aStatus) const;
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.
413 @see Read(TDes8& aDes)
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
428 IMPORT_C void Read(TDes8& aDes, TInt aLength, TRequestStatus& aStatus) const;
431 Cancels asynchronous read.
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
438 IMPORT_C void ReadCancel(TRequestStatus &aStatus) const;
440 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
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
449 @see Read(TDes8& aDes)
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
469 IMPORT_C TInt Read(TInt64 aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus) const;
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.
476 @see Read(TDes8& aDes)
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
496 IMPORT_C TInt Read(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus) const;
497 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
500 Gets the data size in bytes.
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
508 IMPORT_C void DataSizeL(TInt& aSize);
510 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
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
516 @see DataSizeL(TInt& aSize)
518 IMPORT_C void DataSize64L(TInt64& aSize);
519 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
522 Changes or retrieves the location of the file pointer within
525 NOTE: Some operations may fail if the content data is sourced over a network connection.
527 There are four seek modes used:
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
544 @param aMode Seek mode - controls the destination of the
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.
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
556 IMPORT_C TInt Seek(TSeek aMode,TInt& aPos) const;
558 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
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
564 @see Seek(TSeek aMode,TInt& aPos)
566 IMPORT_C TInt Seek64(TSeek aMode,TInt64& aPos) const;
567 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
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.
572 For example setting the buffer-size to 256 bytes can be achieved as follows:
575 MyData->SetProperty(EAgentPropertyBufferSize, 256);
578 @see ContentAccess::TAgentProperty
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.
589 IMPORT_C TInt SetProperty(TAgentProperty aProperty, TInt aValue);
592 Allows a client to verify that the intent is supported by the
593 current rights for the data object.
595 @note Since the intent is only evaluated the agent will not decrement
596 any rights-state such as play counts.
598 @see ContentAccess::TIntent
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
612 IMPORT_C TInt EvaluateIntent(TIntent aIntent);
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.
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.
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.
628 @note Since rights are executed here the agent will decrement any rights-state such as
629 play counts that apply.
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
643 IMPORT_C TInt ExecuteIntent(TIntent aIntent);
645 /** Get an attribute for the content object
647 @see ContentAccess::TAttribute
650 CContent* content = CContent::NewL(uri);
651 CData* data = content->OpenContentL(EPlay, uniqueId);
655 TInt err = data->GetAttribute(EIsProtected, value);
656 if(err == KErrNone && value)
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
674 IMPORT_C TInt GetAttribute(TInt aAttribute, TInt& aValue) const;
676 /** Get a set of attributes for the content object
678 @see ContentAccess::TAttribute
680 The following example determines whether the content object
681 is protected and has rights that will enable it to be viewed by the
685 // CData* data = a data object
687 RAttributeSet attributeSet;
688 CleanupClosePushL(attributeSet);
689 attributeSet->AddL(EProtected);
690 attributeSet->AddL(ECanView);
692 User::LeaveIfError(data->GetAttributeSet(attributeSet);
694 TInt err = attributeSet.GetValue(EProtected, value);
695 if(err == KErrNone && value)
697 // file is DRM protected
700 err = attributeSet.GetValue(ECanView, value);
701 if(err == KErrNone && value)
703 // File has rights that allow it to be displayed on screen
707 CleanupStack::PopAndDestroy(); // attributeSet.Close()
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
719 IMPORT_C TInt GetAttributeSet(RAttributeSet& aAttributeSet) const;
722 /** Get text string attributes or meta-data for the content object
724 @see ContentAccess::TStringAttribute
727 CContent* content = CContent::NewLC(uri);
728 CData* data = content->OpenContentLC(EPlay, uniqueId);
729 CleanupStack::PopAndDestroy(content);
731 TBuf <MAX_PATH> previewUri;
732 TInt err = data->GetStringAttribute(EPreviewURI, previewUri);
735 DisplayPreview(previewUri);
738 CleanupStack::PopAndDestroy(data);
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
752 IMPORT_C TInt GetStringAttribute(TInt aAttribute, TDes& aValue) const;
756 /** Obtain a set of string attributes for the content object
758 @see ContentAccess::TStringAttribute
761 CContent* content = CContent::NewLC(uri);
762 CData* data = content->OpenContentLC(EPlay, uniqueId);
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);
770 User::LeaveIfError(data->GetStringAttributeSet(stringAttributeSet));
772 // Pass the value of the string attribute to DisplayPreview()
773 TFileName previewUri;
774 TInt err = stringAttributeSet.GetValue(EPreviewURI, previewUri);
777 DisplayPreview(previewUri);
780 CleanupStack::PopAndDestroy(3); // content, data, stringAttributeSet
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
793 IMPORT_C TInt GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet) const;
797 /** Set Qos attribute
798 @param aQosAttr The Qos attribute to set.
799 @param aValue The value of the attribute.
802 IMPORT_C void SetQosL(TQosAttribute aQosAttr, TInt aValue);
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.
809 IMPORT_C TBool GetMimeTypeL(TDes8& aMimeType) const;
810 #endif // REMOVE_CAF1
812 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
814 Decrypts the encrypted input data packet.
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.
826 IMPORT_C TInt Read(const TDesC8& aEncryptedInputDataPacket, TDes8& aDecryptedOutputDataPacket) const;
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.
840 IMPORT_C void Read(const TDesC8& aEncryptedInputDataPacket, TDes8& aDecryptedOutputDataPacket, TRequestStatus& aStatus) const;
842 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
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);
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);
856 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
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);
863 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
865 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
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
872 IMPORT_C TInt Read_Unused(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus) const;
873 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
876 // The agent handling this content
877 CAgentData* iAgentData;
879 // Defacto ECOM session handle
880 CAgentFactory* iAgentFactory;
886 } // namespace ContentAccess
887 #endif /* __DATA_H__ */