2 * Copyright (c) 2003-2007 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.
54 class CData : public CBase
58 Creates a new CData object.
60 @param aVirtualPath The content object to read
61 @param aIntent The intended use of the content.
62 @param aShareMode The file share mode used to open this content.
63 @return The new CData object.
65 @leave KErrNotFound The content object with the given UniqueId does not exist.
66 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
67 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
68 @leave KErrCANoRights No rights exist for the content object.
69 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
70 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
71 @leave KErrAccessDenied The content is already in use.
72 @leave ... One of the other CAF error codes defined in \c caferr.h
73 or one of the other system-wide error codes
76 IMPORT_C static CData* NewL(const TVirtualPathPtr& aVirtualPath,
77 TIntent aIntent, TContentShareMode aShareMode);
80 Creates a new CData object.
82 @param aVirtualPath The content object to read.
83 @param aShareMode The file share mode used to open this content.
84 @return The new CData object.
86 @leave KErrNotFound The content object with the given UniqueId does not exist.
87 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
88 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
89 @leave KErrCANoRights No rights exist for the content object.
90 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
91 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
92 @leave KErrAccessDenied The content is already in use.
93 @leave ... One of the other CAF error codes defined in \c caferr.h
94 or one of the other system-wide error codes for
97 IMPORT_C static CData* NewL(const TVirtualPathPtr& aVirtualPath,
98 TContentShareMode aShareMode);
102 Creates a new CData object
104 @param aVirtualPath The content object to read.
105 @param aIntent The intended use of the content.
106 @param aShareMode The file share mode used to open this content.
107 @return The new CData object.
109 @leave KErrNotFound The content object with the given UniqueId does not exist.
110 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
111 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
112 @leave KErrCANoRights No rights exist for the content object.
113 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
114 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
115 @leave KErrAccessDenied The content is already in use.
116 @leave ... One of the other CAF error codes defined in \c caferr.h
117 or one of the other system-wide error codes for
120 IMPORT_C static CData* NewLC(const TVirtualPathPtr& aVirtualPath,
121 TIntent aIntent, TContentShareMode aShareMode);
124 Creates a new CData object
126 @param aVirtualPath The content object to read.
127 @param aShareMode The file share mode used to open this content.
128 @return The new CData object.
130 @leave KErrNotFound The content object with the given UniqueId does not exist.
131 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
132 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
133 @leave KErrCANoRights No rights exist for the content object.
134 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
135 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
136 @leave KErrAccessDenied The content is already in use.
137 @leave ... One of the other CAF error codes defined in \c caferr.h
138 or one of the other system-wide error codes for
141 IMPORT_C static CData* NewLC(const TVirtualPathPtr& aVirtualPath,
142 TContentShareMode aShareMode);
146 Creates a new CData object.
148 @param aFile An open RFile handle, the agent will make a duplicate of this handle.
149 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.
150 @param aUniqueId The content object to read.
151 @param aIntent The intended use of the content.
152 @return The new CData object.
154 @leave KErrNotFound The content object with the given UniqueId does not exist.
155 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
156 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
157 @leave KErrCANoRights No rights exist for the content object.
158 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
159 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
160 @leave KErrAccessDenied The content is already in use.
161 @leave ... One of the other CAF error codes defined in \c caferr.h
162 or one of the other system-wide error codes for
165 IMPORT_C static CData* NewL(RFile& aFile, const TDesC& aUniqueId, TIntent aIntent);
168 Creates a new CData object.
170 @param aFile An open RFile handle, the agent will make a duplicate of this handle.
171 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.
172 @param aUniqueId The content object to read.
173 @return The new CData object.
175 @leave KErrNotFound The content object with the given UniqueId does not exist.
176 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
177 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
178 @leave KErrCANoRights No rights exist for the content object.
179 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
180 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
181 @leave KErrAccessDenied The content is already in use.
182 @leave ... One of the other CAF error codes defined in \c caferr.h
183 or one of the other system-wide error codes for
186 IMPORT_C static CData* NewL(RFile& aFile, const TDesC& aUniqueId);
189 Creates a new CData object.
191 @param aFile An open RFile handle, the agent will make a duplicate of this handle.
192 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.
193 @param aUniqueId The content object to read.
194 @param aIntent The intended use of the content.
195 @return The new CData object.
197 @leave KErrNotFound The content object with the given UniqueId does not exist.
198 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
199 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
200 @leave KErrCANoRights No rights exist for the content object.
201 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
202 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
203 @leave KErrAccessDenied The content is already in use.
204 @leave ... One of the other CAF error codes defined in \c caferr.h
205 or one of the other system-wide error codes
206 for any other errors.
208 IMPORT_C static CData* NewLC(RFile& aFile, const TDesC& aUniqueId, TIntent aIntent);
211 Creates a new CData object.
213 @param aFile An open RFile handle, the agent will make a duplicate of this handle.
214 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.
215 @param aUniqueId The content object to read.
216 @return The new CData object.
218 @leave KErrNotFound The content object with the given UniqueId does not exist.
219 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
220 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
221 @leave KErrCANoRights No rights exist for the content object.
222 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
223 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
224 @leave KErrAccessDenied The content is already in use.
225 @leave ... One of the other CAF error codes defined in \c caferr.h
226 or one of the other system-wide error codes
227 for any other errors.
229 IMPORT_C static CData* NewLC(RFile& aFile, const TDesC& aUniqueId);
232 Creates a new CData object.
234 @param aAgentUid The agent determined to support this content.
235 @param aVirtualPath The content object to read.
236 @param aIntent The intended use of the content.
237 @param aShareMode The file share mode used to open this content.
238 @return The new CData object.
240 @leave KErrNotFound The content object with the given UniqueId does not exist.
241 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
242 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
243 @leave KErrCANoRights No rights exist for the content object.
244 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
245 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
246 @leave KErrAccessDenied The content is already in use.
247 @leave ... One of the other CAF error codes defined in \c caferr.h
248 or one of the other system-wide error codes
249 for any other errors.
254 static CData* NewLC(TUid aAgentUid, const TVirtualPathPtr& aVirtualPath,
255 TIntent aIntent, TContentShareMode aShareMode);
258 Creates a new CData object.
260 @param aAgentUid The Uid of the agent who supports this content.
261 @param aFile An open RFile handle, the agent will make a duplicate of this handle.
262 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.
263 @param aUniqueId The content object to read.
264 @param aIntent The intended use of the content.
265 @return The new CData object.
267 @leave KErrNotFound The content object with the given UniqueId does not exist.
268 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
269 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
270 @leave KErrCANoRights No rights exist for the content object.
271 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
272 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
273 @leave KErrAccessDenied The content is already in use.
274 @leave ... One of the other CAF error codes defined in \c caferr.h
275 or one of the other system-wide error codes for
281 static CData* NewLC(TUid aAgentUid, RFile& aFile, const TDesC& aUniqueId, TIntent aIntent);
287 Reads from a content object up to the maximum length of the
288 descriptor or the end of the content object.
290 When an attempt is made to read beyond the end of the content,
291 no error is returned. The descriptor’s length is set to the
292 number of bytes that were read into it. Therefore, when reading
293 through content, the end has been reached when the
294 descriptor length (given by TDesC::Length()) is zero.
296 @param aDes Descriptor into which binary data is read. Any existing
297 contents are overwritten. On return, its length is set
298 to the number of bytes read.
299 @return KErrNone if successful.
300 @return One of the CAF error codes defined in \c caferr.h or
301 one of the other system-wide error codes.
302 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
304 IMPORT_C TInt Read(TDes8& aDes) const;
307 Reads from a content object up to the specified length of the
308 descriptor or the end of the content object.
310 @see Read(TDes8& aDes)
312 @param aDes Descriptor into which binary data is read. Any existing
313 contents are overwritten. On return, its length is set
314 to the number of bytes read.
315 @param aLength The number of bytes to read from the file,
316 or to the end of the file, whichever is encountered first.
317 The length of the buffer is set to the number of bytes actually read.
318 @return KErrNone if successful.
319 @return Otherwise one of the CAF error codes defined in \c caferr.h or
320 one of the other system-wide error codes.
321 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
323 IMPORT_C TInt Read(TDes8& aDes,TInt aLength) const;
326 Read content asynchronously up to the maximum length of the descriptor
327 or until the end of the content object is reached.
328 NB: It is important that the descriptor passed to
329 aDes remains in scope until the request has completed.
331 @see Read(TDes8& aDes)
333 @param aDes Descriptor into which binary data is read. Any
334 existing contents are overwritten. On return,
335 its length is set to the number of bytes read.
336 @param aStatus Asynchronous request status. On completion this will contain one
337 of the following error codes: KErrNone if the data was
338 successfully read. Otherwise one of the CAF error codes defined in
339 \c caferr.h or one of the other standard system-wide
340 error codes for any other errors.
341 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
343 IMPORT_C void Read(TDes8& aDes, TRequestStatus& aStatus) const;
346 Read content asynchronously up to the specified length
347 or until the end of the content object is reached.
348 NB: It is important that the descriptor passed to
349 aDes remains in scope until the request has completed.
351 @see Read(TDes8& aDes)
353 @param aDes Descriptor into which binary data is read. Any
354 existing contents are overwritten. On return,
355 its length is set to the number of bytes read.
356 @param aLength The number of bytes to read from the file,
357 or to the end of the file, whichever is encountered first.
358 The length of the buffer is set to the number of bytes actually read.
359 @param aStatus Asynchronous request status. On completion this will contain one
360 of the following error codes: KErrNone if the data was
361 successfully read. Otherwise one of the CAF error codes defined in
362 \c caferr.h or one of the other standard system-wide
363 error codes for any other errors.
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 void Read(TDes8& aDes, TInt aLength, TRequestStatus& aStatus) const;
369 Cancels asynchronous read.
371 @param aStatus Asynchronous request status. This parameter should have been supplied earlier to
372 an asynchronous Read call. If it has not been previously supplied to a Read call,
373 this function will not have any effect.
374 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
376 IMPORT_C void ReadCancel(TRequestStatus &aStatus) const;
379 Reads content asynchronously. The data is read from a specified offset
380 up to a specified number of bytes or until the end of the content object
381 is reached. The data is read into the descriptor buffer supplied.
382 NB: It is important that the descriptor passed to
383 aDes remains in scope until the request has completed.
385 @see Read(TDes8& aDes)
387 @param aPos Position of first byte to be read.
388 This is an offset from the start of the file.
389 @param aDes Descriptor into which binary data is read. Any
390 existing contents are overwritten. On return,
391 its length is set to the number of bytes read.
392 @param aLength The number of bytes to read from the file,
393 or to the end of the file, whichever is encountered first.
394 The length of the buffer is set to the number of bytes actually read.
395 @param aStatus Asynchronous request status. On completion this will contain one
396 of the following error codes: KErrNone if the data was
397 successfully read. Otherwise one of the CAF error codes defined in
398 \c caferr.h or one of the other standard system-wide
399 error codes for any other errors.
400 @return KErrNone if the async read request was successfully submitted.
401 @return KErrArgument if a negative offset is supplied.
402 @return KErrCANotSupported if the agent does not support this operation.
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 TInt Read(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus) const;
408 Gets the data size in bytes.
410 @param aSize On return this will contain the size of the plaintext data in bytes.
411 @leave KErrCASizeNotDetermined Size could not be determined by the managing agent.
412 @leave ... One of the other CAF error codes defined in \c caferr.h or one of the
413 system-wide error codes for any other errors.
414 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
416 IMPORT_C void DataSizeL(TInt& aSize);
419 Changes or retrieves the location of the file pointer within
422 NOTE: Some operations may fail if the content data is sourced over a network connection.
424 There are four seek modes used:
426 @li ESeekStart - Sets the file pointer aPos bytes from the start of the
427 content object. aPos is not modified by the call to Seek()
428 @li ESeekEnd - Sets the file pointer aPos bytes from the end of the
429 content object. The aPos parameter supplied should be zero or negative
430 when using ESeekEnd. Upon completion aPos is updated with the current
431 position relative to the start of the content object.
432 @li ESeekCurrent - Moves the file pointer aPos bytes from the current
433 position. Upon completion aPos is updated with the new position relative
434 to the start of the content object. Suppling a zero value for the aPos Parameter can be
435 used to retrieve the current file pointer location
436 @li ESeekAddress Sets the aPos parameter to the address of the byte
437 aPos bytes from the start of the content object
441 @param aMode Seek mode - controls the destination of the
444 @param aPos Offset from either the start, end or current position depending upon
445 the seek mode. Negative offsets are used to seek before the current position or
446 relative to the end of the file.
448 @return KErrNone if successful.
449 @return Otherwise one of the CAF error codes defined in \c caferr.h or one
450 of the other system-wide error codes.
451 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
453 IMPORT_C TInt Seek(TSeek aMode,TInt& aPos) const;
456 /** Request the agent handling this content to set a property value. If the property is set
457 it is only set for this CData session and does not impact other CAF users.
459 For example setting the buffer-size to 256 bytes can be achieved as follows:
462 MyData->SetProperty(EAgentPropertyBufferSize, 256);
465 @see ContentAccess::TAgentProperty
467 @param aProperty The property to set.
468 @param aValue The value of the property.
469 @return Whether or not the property was set.
470 @return KErrNone if the property was set.
471 @return KErrCANotSupported if the agent does not support the property or value.
472 @return KErrAccessDenied if the agent does not permit the property to be changed.
473 @return KErrPermissionDenied if the application does not have the necessary capability to change the property.
474 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
476 IMPORT_C TInt SetProperty(TAgentProperty aProperty, TInt aValue);
479 Allows a client to verify that the intent is supported by the
480 current rights for the data object.
482 @note Since the intent is only evaluated the agent will not decrement
483 any rights-state such as play counts.
485 @see ContentAccess::TIntent
487 @param aIntent The intended way the content will be used.
488 @return Whether rights exist allowing the content to be used for this intent.
489 @return KErrNone if the intent is permitted.
490 @return KErrNoRights if no rights exist for the specified content object.
491 @return KErrCANoPermission if rights exist but the specified intent is not permitted.
492 @return KErrCAPendingRights if the rights have not yet arrived but are expected soon.
493 @return KErrNoPermission if rights exist but none permit the specified intent.
494 @return KErrPermissionDenied if the client is not allowed to use this content object.
495 @return Otherwise one of the other CAF error codes defined in \c caferr.h or one of the
496 other system-wide error codes for any other errors.
497 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
499 IMPORT_C TInt EvaluateIntent(TIntent aIntent);
502 Execute intent allows the application to signal it is about to carry out
503 the specified intent on protected content.The agent will decrement applicable
504 stateful rights such as play counts where necessary.
506 Applications should be very careful to use this function correctly.
507 @li If ExecuteIntent() is never called stateful rights will never be decremented. Users will be able to use the content forever
508 @li If ExecuteIntent() is called too often stateful rights may be consumed prematurely.
510 Usually it would be best to call ExecuteIntent immediately before the content
511 is displayed or the instant playback begins. ExecuteIntent should not be considered a
512 prerequisite for calling the Read functions. It is valid for an application to read from
513 the file before calling ExecuteIntent.
515 @note Since rights are executed here the agent will decrement any rights-state such as
516 play counts that apply.
518 @param aIntent The intent indicator.
519 @return The result of attempting executing the intent.
520 @return KErrNone if the intent is permitted and stateful rights may have been decremented.
521 @return KErrNoRights if no rights exist for the specified content object.
522 @return KErrCANoPermission if rights exist but the specified intent is not permitted.
523 @return KErrCAPendingRights if the rights have not yet arrived but are expected soon.
524 @return KErrNoPermission if rights exist but none permit the specified intent.
525 @return KErrPermissionDenied if the client is not allowed to use this content object.
526 @return Otherwise one of the other CAF error codes defined in \c caferr.h or one of the.
527 other system-wide error codes for any other errors.
528 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
530 IMPORT_C TInt ExecuteIntent(TIntent aIntent);
532 /** Get an attribute for the content object
534 @see ContentAccess::TAttribute
537 CContent* content = CContent::NewL(uri);
538 CData* data = content->OpenContentL(EPlay, uniqueId);
542 TInt err = data->GetAttribute(EIsProtected, value);
543 if(err == KErrNone && value)
551 @param aAttribute The attribute to query, from ContentAccess::TAttribute.
552 @param aValue Used to return the attribute value.
553 @return Whether the attribute was updated.
554 @return KErrNone if the value of the attribute was updated.
555 @return KErrCANotSupported if the requested attribute does not exist.
556 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
557 @return Otherwise one of the other CAF error codes defined in \c caferr.h or one of the
558 other system-wide error codes for any other errors.
559 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
561 IMPORT_C TInt GetAttribute(TInt aAttribute, TInt& aValue) const;
563 /** Get a set of attributes for the content object
565 @see ContentAccess::TAttribute
567 The following example determines whether the content object
568 is protected and has rights that will enable it to be viewed by the
572 // CData* data = a data object
574 RAttributeSet attributeSet;
575 CleanupClosePushL(attributeSet);
576 attributeSet->AddL(EProtected);
577 attributeSet->AddL(ECanView);
579 User::LeaveIfError(data->GetAttributeSet(attributeSet);
581 TInt err = attributeSet.GetValue(EProtected, value);
582 if(err == KErrNone && value)
584 // file is DRM protected
587 err = attributeSet.GetValue(ECanView, value);
588 if(err == KErrNone && value)
590 // File has rights that allow it to be displayed on screen
594 CleanupStack::PopAndDestroy(); // attributeSet.Close()
598 @param aAttributeSet The set of attributes to query and update.
599 @return Whether the attribute set was updated.
600 @return KErrNone if the attributes were retrieved successfully.
601 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
602 @return Otherwise one of the CAF error codes defined in \c caferr.h or one of the
603 other system-wide error codes for any other errors.
604 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
606 IMPORT_C TInt GetAttributeSet(RAttributeSet& aAttributeSet) const;
609 /** Get text string attributes or meta-data for the content object
611 @see ContentAccess::TStringAttribute
614 CContent* content = CContent::NewLC(uri);
615 CData* data = content->OpenContentLC(EPlay, uniqueId);
616 CleanupStack::PopAndDestroy(content);
618 TBuf <MAX_PATH> previewUri;
619 TInt err = data->GetStringAttribute(EPreviewURI, previewUri);
622 DisplayPreview(previewUri);
625 CleanupStack::PopAndDestroy(data);
628 @param aAttribute The attribute to query, from ContentAccess::TStringAttribute.
629 @param aValue Returns the value of the attribute.
630 @return Whether the value was updated.
631 @return KErrNone if the attribute was retrieved.
632 @return KErrOverflow if the buffer was not large enough to return the result.
633 @return KErrCANotSupported if the requested attribute does not exist.
634 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
635 @return Otherwise one of the other CAF error codes defined in \c caferr.h or one of the
636 other system-wide error codes for any other errors.
637 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
639 IMPORT_C TInt GetStringAttribute(TInt aAttribute, TDes& aValue) const;
643 /** Obtain a set of string attributes for the content object
645 @see ContentAccess::TStringAttribute
648 CContent* content = CContent::NewLC(uri);
649 CData* data = content->OpenContentLC(EPlay, uniqueId);
651 // create the attribute set, add the attributes we are interested in
652 RStringAttributeSet stringAttributeSet;
653 CleanupClosePushL(stringAttributeSet);
654 stringAttributeSet.AddL(EPreviewURI);
655 stringAttributeSet.AddL(ETitle);
657 User::LeaveIfError(data->GetStringAttributeSet(stringAttributeSet));
659 // Pass the value of the string attribute to DisplayPreview()
660 TFileName previewUri;
661 TInt err = stringAttributeSet.GetValue(EPreviewURI, previewUri);
664 DisplayPreview(previewUri);
667 CleanupStack::PopAndDestroy(3); // content, data, stringAttributeSet
671 @param aStringAttributeSet The set of attributes to query and update.
672 @return Whether the string attribute set was updated.
673 @return KErrNone if the attributes were retrieved successfully.
674 @return KErrNotFound if the default content object was not found.
675 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
676 @return Otherwise one of the CAF error codes defined in \c caferr.h or one of the
677 other system-wide error codes for any other errors.
678 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
680 IMPORT_C TInt GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet) const;
683 /** Set Qos attribute
684 @param aQosAttr The Qos attribute to set.
685 @param aValue The value of the attribute.
688 IMPORT_C void SetQosL(TQosAttribute aQosAttr, TInt aValue);
690 /** Get the mime type of the content
691 @param aMimeType Buffer to store the mime type provided by the agent.
692 @return ETrue if the mime type was retrieved successfully.
695 IMPORT_C TBool GetMimeTypeL(TDes8& aMimeType) const;
696 #endif // REMOVE_CAF1
701 void ConstructL(RFile& aFile, const TDesC& aUniqueId, TIntent aIntent);
702 void ConstructL(const TVirtualPathPtr& aVirtualPath, TIntent aIntent, TContentShareMode aShareMode);
703 void ConstructL(TUid aAgentUid, RFile& aFile, const TDesC& aUniqueId, TIntent aIntent);
704 void ConstructL(TUid aAgentUid, const TVirtualPathPtr& aVirtualPath, TIntent aIntent, TContentShareMode aShareMode);
706 void ConstructL(RFile& aFile, const TDesC& aUniqueId);
707 void ConstructL(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode);
708 void ConstructL(TUid aAgentUid, RFile& aFile, const TDesC& aUniqueId);
709 void ConstructL(TUid aAgentUid, const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode);
713 // The agent handling this content
714 CAgentData* iAgentData;
716 // Defacto ECOM session handle
717 CAgentFactory* iAgentFactory;
723 } // namespace ContentAccess
724 #endif /* __DATA_H__ */