Update contrib.
2 * Copyright (c) 2003-2009 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>
34 #include <caf/agent.h>
35 #include <caf/streamableptrarray.h>
36 #include <caf/virtualpathptr.h>
38 namespace ContentAccess
44 class CEmbeddedObject;
46 class RStringAttributeSet;
56 CContent allows applications to browse the content objects contained within a
57 single file and construct a CData object for reading that content.
59 Applications will use an object of this type rather than the traditional
60 RFile mechanisms. They will, however, be required to indicate
61 <i>DRM Intent</i> - something that determines whether (and how) access to
62 the content should be permitted by a Content-Access agent.
64 CContent allows direct access to meta-data such as the attributes of
65 the content and indirect access to the plaintext data itself through
68 Applications can use CContent to browse the hierarchy of content objects
69 within a file containing several content objects.
71 During construction CContent loads the correct CAF Agent plugin to handle
72 the file specified by the URI.
74 class CContent : public CBase
79 Constructs a new CContent object with a given URI. The URI can be in the same format as a virtual path for more information see CVirtualPath and TVirtualPathPtr
81 @param aURI The filename, URI or virtual path of the DRM file.
82 @return a new CContent object.
83 @leave KErrNotFound If the file at the given URI does not exist or if an invalid URI or virtual path have been supplied.
84 @leave KErrPermissionDenied If the access to the protected content is not permitted by the CAF Agent.
85 @leave ... One of the CAF error codes defined in \c caferr.h or one of the
86 other system-wide error codes for any other errors.
87 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
89 IMPORT_C static CContent* NewLC(const TDesC& aURI);
92 Constructs a new CContent object with a given URI. The URI can be in the same format as a virtual path for more information see CVirtualPath and TVirtualPathPtr
94 @param aURI The filename, URI or virtual path of the DRM file.
95 @return a new CContent object.
96 @leave KErrNotFound If the file at the given URI does not exist or if an invalid URI or virtual path have been supplied.
97 @leave KErrPermissionDenied If the access to the protected content is not permitted by the CAF Agent.
98 @leave ... One of the CAF error codes defined in \c caferr.h or one of the
99 other system-wide error codes for any other errors.
100 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
102 IMPORT_C static CContent* NewL(const TDesC& aURI);
105 Constructs a new CContent object with a given URI. The URI can be in the same format as a virtual path for more information see CVirtualPath and TVirtualPathPtr
107 @param aURI The filename, URI or virtual path of the DRM file.
108 @param aShareMode The sharing mode used when accessing the content.
109 @return a new CContent object.
110 @leave KErrNotFound If the file at the given URI does not exist or if an invalid URI or virtual path have been supplied.
111 @leave KErrAccessDenied If the file is already open with a different share mode.
112 @leave KErrPermissionDenied If the access to the protected content is not permitted by the CAF Agent.
113 @leave ... One of the CAF error codes defined in \c caferr.h or one of the
114 other system-wide error codes for any other errors.
115 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
117 IMPORT_C static CContent* NewLC(const TDesC& aURI, TContentShareMode aShareMode);
120 Constructs a new CContent object with a given URI. The URI can be in the same format as a virtual path for more information see CVirtualPath and TVirtualPathPtr
122 @param aURI The filename, URI or virtual path of the DRM file.
123 @param aShareMode The sharing mode used when accessing the content.
124 @return a new CContent object.
125 @leave KErrNotFound If the file at the given URI does not exist or if an invalid URI or virtual path have been supplied.
126 @leave KErrAccessDenied If the file is already open with a different share mode.
127 @leave KErrPermissionDenied If the access to the protected content is not permitted by the CAF Agent.
128 @leave ... One of the CAF error codes defined in \c caferr.h or one of the
129 other system-wide error codes for any other errors.
130 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
132 IMPORT_C static CContent* NewL(const TDesC& aURI, TContentShareMode aShareMode);
135 Constructs a new CContent object with an open file handle.
137 CContent will use a duplicate of this file handle, the client is
138 free to close its file handle any time after creating the CContent
141 @param aFile The file handle. The file must already be open before calling NewLC.
142 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.
143 @return a new CContent object.
144 @leave KErrPermissionDenied If the access to the protected content is not permitted by the CAF Agent.
145 @leave ... One of the CAF error codes defined in \c caferr.h or one of the
146 other system-wide error codes for any other errors.
147 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
149 IMPORT_C static CContent* NewLC(RFile& aFile);
152 Constructs a new CContent object with an open file handle.
154 CContent will use a duplicate of this file handle, the client is
155 free to close its file handle any time after creating the CContent
158 @param aFile The file handle. The file must already be open before calling this method.
159 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.
160 @return a new CContent object.
161 @leave KErrPermissionDenied If the access to the protected content is not permitted by the CAF Agent.
162 @leave ... One of the CAF error codes defined in \c caferr.h or one of the
163 other system-wide error codes for any other errors.
164 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
166 IMPORT_C static CContent* NewL(RFile& aFile);
168 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
170 Constructs a new CContent object.
172 @param aHeaderData Header data of WMDRM file/stream content.
173 @return CContent object.
174 @leave KErrMissingHeaderData if the header data is NULL or one of the CAF error codes defined in caferr.h
175 or one of the system-wide error codes for any other errors.
176 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
178 IMPORT_C static CContent* NewL(const TDesC8& aHeaderData);
181 Constructs a new CContent object.
183 @param aHeaderData Header data of WMDRM file/stream content.
184 @return CContent object.
185 @leave KErrMissingHeaderData if the header data is NULL or one of the CAF error codes defined in caferr.h or one of the
186 system-wide error codes for any other errors.
187 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
189 IMPORT_C static CContent* NewLC(const TDesC8& aHeaderData);
191 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
196 /** Open a Container object within the file.
198 Allows an application to access the content objects and
199 any nested container objects within the specified container.
201 @param aUniqueId The container object's unique ID.
202 @return Whether the container was opened.
203 @return KErrNone if the container was opened successfully.
204 @return KErrNotFound if the container does not exist.
205 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
206 @return Otherwise one of the CAF error codes defined in \c caferr.h or one of the
207 other system-wide error codes for any other errors.
208 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
210 IMPORT_C TInt OpenContainer(const TDesC& aUniqueId);
212 /** Close the current container object and go back to previous enclosing
213 container within the file.
215 Allows an application to access the content objects and
216 any nested container objects within parent container.
218 @return Whether the container was closed.
219 @return KErrNone if the container was closed.
220 @return KErrNotFound if there is no enclosing container.
221 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
222 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
224 IMPORT_C TInt CloseContainer();
226 /** List all the embedded container objects and content objects within the
229 The UniqueId() member of CEmbeddedObject can be used to refer directly to
230 a particular object within the file.
233 // Create a ccontent object for the file of interest
234 CContent* content = CContent::NewLC(uri);
236 // Define an array to store the results
237 RStreamablePtrArray <CEmbeddedObject> array;
238 CleanupClosePushL(array);
240 // Find all the content and container objects within the current container
241 content->GetEmbeddedObjectsL(array);
243 // Do something with the array
247 CleanupStack::PopAndDestroy(2);
250 @param aArray The array to be populated with the embedded objects.
251 @leave KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
252 @leave ... One of the CAF error codes defined in \c caferr.h or one of the
253 other system-wide error codes for any other errors.
254 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
256 IMPORT_C void GetEmbeddedObjectsL(RStreamablePtrArray<CEmbeddedObject>& aArray) const;
258 /** List all the embedded objects within the current container that
259 are of the specified type
262 // Create a ccontent object for the file of interest
263 CContent* content = CContent::NewLC(uri);
265 // Define an array to store the results
266 RStreamablePtrArray <CEmbeddedObject> array;
267 CleanupClosePushL(array);
269 // Find all the content objects within the current container
270 content->GetEmbeddedObjectsL(array, EContentObject);
272 // Do something with the array
276 CleanupStack::PopAndDestroy(2);
279 @param aArray The array to be populated with the embedded objects.
280 @param aType The type of objects to list.
281 @leave KErrPermissionDenied If the access to the protected content is not permitted by the CAF Agent.
282 @leave ... One of the CAF error codes defined in \c caferr.h or one of the
283 other system-wide error codes for any other errors.
284 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
286 IMPORT_C void GetEmbeddedObjectsL(RStreamablePtrArray<CEmbeddedObject>& aArray, TEmbeddedType aType) const;
288 /** Search the current container for content objects with a particular mime type
291 _LIT8(KTextPlainMimeType, "text/plain");
293 // Create a ccontent object for the file of interest
294 CContent* content = CContent::NewLC(uri);
296 // Define an array to store the results
297 RStreamablePtrArray <CEmbeddedObject> array;
298 CleanupClosePushL(array);
300 // Recursively search for all the content objects with the
301 // specified mime type
302 User::LeaveIfError(content->Search(array, KTextPlainMimeType(), ETrue));
304 // Do something with the array
308 CleanupStack::PopAndDestroy(2);
311 @param aArray The array to store the results of the search. The agent will add CEmbeddedObject objects to the supplied array.
312 @param aMimeType The mime type to search for.
313 @param aRecursive ETrue to search inside containers embedded within the current container, EFalse to search only the current container.
314 @return The result of the search.
315 @return KErrNone if the search was successful, even if no content objects were found.
316 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
317 @return Otherwise one of the CAF error codes defined in \c caferr.h or one of the
318 other system-wide error codes for any other errors.
319 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
321 IMPORT_C TInt Search(RStreamablePtrArray<CEmbeddedObject>& aArray, const TDesC8& aMimeType, TBool aRecursive);
324 /** Get an attribute for the default content object within the file
326 @see ContentAccess::TAttribute
330 CContent* c = CContent::NewL(uri);
331 TInt err =c->GetAttribute(EIsProtected, value);
332 if(err == KErrNone && value)
338 @param aAttribute The attribute to query, from ContentAccess::TAttribute.
339 @param aValue Used to return the attribute value.
340 @return Whether the attribute value was updated.
341 @return KErrNone if the value of the attribute was updated.
342 @return KErrNotFound if the object with the given UniqueId was not found.
343 @return KErrCANotSupported if the requested attribute does not exist.
344 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
345 @return Otherwise one of the other CAF error codes defined in \c caferr.h or one of the
346 other system-wide error codes for any other errors.
347 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
349 IMPORT_C TInt GetAttribute(TInt aAttribute, TInt& aValue) const;
351 /** Get an attribute for an object within the file
353 @see ContentAccess::TAttribute
357 CContent* c = CContent::NewL(uri);
358 TInt err =c->GetAttribute(EIsProtected, value, uniqueId);
359 if(err == KErrNone && value)
365 @param aAttribute The attribute to query, from ContentAccess::TAttribute.
366 @param aValue Used to return the attribute value.
367 @param aUniqueId The UniqueId of the object within the file.
368 @return Whether the attribute value was updated.
369 @return KErrNone if the value of the attribute was updated.
370 @return KErrNotFound if the object with the given UniqueId was not found.
371 @return KErrCANotSupported if the requested attribute does not exist.
372 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
373 @return Otherwise one of the other CAF error codes defined in \c caferr.h or one of the
374 other system-wide error codes for any other errors.
375 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
377 IMPORT_C TInt GetAttribute(TInt aAttribute, TInt& aValue, const TDesC& aUniqueId) const;
380 /** Get a set of attributes for the default content object within the file
382 @see ContentAccess::TAttribute
384 The following example determines whether the default content object
385 is protected and has rights that will enable it to be viewed by the
389 CContent* content = CContent::NewLC(uri);
391 RAttributeSet attributeSet;
392 CleanupClosePushL(attributeSet);
393 attributeSet->AddL(EProtected);
394 attributeSet->AddL(ECanView);
396 User::LeaveIfError(content->GetAttributeSet(attributeSet);
398 TInt err = attributeSet.GetValue(EProtected, value);
399 if(err == KErrNone && value)
401 // file is DRM protected
404 err = attributeSet.GetValue(ECanView, value);
405 if(err == KErrNone && value)
407 // File has rights that allow it to be displayed on screen
411 CleanupStack::PopAndDestroy(2); // content, attributeSet.Close()
415 @param aAttributeSet The set of attributes to query and update.
416 @return Whether the attribute set was updated.
417 @return KErrNone if the attributes were retrieved successfully.
418 @return KErrNotFound if the default content object was not found.
419 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
420 @return Otherwise one of the CAF error codes defined in \c caferr.h or one of the
421 other system-wide error codes for any other errors.
422 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
424 IMPORT_C TInt GetAttributeSet(RAttributeSet& aAttributeSet) const;
426 /** Get a set of attributes from an object within the file
428 @see ContentAccess::TAttribute
430 The following example determines whether the default content object
431 is protected and has rights that will enable it to be viewed by the
435 CContent* content = CContent::NewLC(uri);
437 RAttributeSet attributeSet;
438 CleanupClosePushL(attributeSet);
439 attributeSet->AddL(EProtected);
440 attributeSet->AddL(ECanView);
442 User::LeaveIfError(content->GetAttributeSet(attributeSet, uniqueId);
444 TInt err = attributeSet.GetValue(EProtected, value);
445 if(err == KErrNone && value)
447 // file is DRM protected
450 err = attributeSet.GetValue(ECanView, value);
451 if(err == KErrNone && value)
453 // File has rights that allow it to be displayed on screen
457 CleanupStack::PopAndDestroy(2); // content, attributeSet.Close()
461 @param aAttributeSet The set of attributes to query and update.
462 @param aUniqueId The unique ID of the object within the file.
463 @return Whether that attribute set was updated.
464 @return KErrNone if the attributes were retrieved successfully.
465 @return KErrNotFound if the default content object was not found.
466 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
467 @return Otherwise one of the CAF error codes defined in \c caferr.h or one of the
468 other system-wide error codes for any other errors.
469 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
471 IMPORT_C TInt GetAttributeSet(RAttributeSet& aAttributeSet, const TDesC& aUniqueId) const;
473 /** Get text string attributes or meta-data for the default content object within the file
475 @see ContentAccess::TStringAttribute
480 CContent* c = CContent::NewL(uri);
481 TBuf <MAX_PATH> previewUri;
482 err = c->GetStringAttribute(EPreviewURI, previewUri);
485 DisplayPreview(previewUri);
489 @param aAttribute The attribute to query, from ContentAccess::TStringAttribute.
490 @param aValue Returns the value of the attribute.
491 @return Whether the attribute value was updated.
492 @return KErrNone if the attribute was retrieved.
493 @return KErrNotFound if the default content object was not found.
494 @return KErrOverflow if the buffer was not large enough to return the result.
495 @return KErrCANotSupported if the requested attribute does not exist.
496 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
497 @return Otherwise one of the other CAF error codes defined in \c caferr.h or one of the
498 other system-wide error codes for any other errors.
499 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
501 IMPORT_C TInt GetStringAttribute(TInt aAttribute, TDes& aValue) const;
503 /** Get text string attributes or meta-data for an object within the file
505 @see ContentAccess::TStringAttribute
510 CContent* c = CContent::NewL(uri);
511 TBuf <MAX_PATH> previewUri;
512 err = c->GetStringAttribute(EPreviewURI, previewUri, uniqueId);
515 DisplayPreview(previewUri);
519 @param aAttribute The attribute to query, from ContentAccess::TStringAttribute.
520 @param aValue Returns the value of the attribute.
521 @param aUniqueId The UniqueId of the object within the file.
522 @return Whether the attribute value was updated.
523 @return KErrNone if the attribute was retrieved.
524 @return KErrNotFound if the object with the given UniqueId was not found.
525 @return KErrOverflow if the buffer was not large enough to return the result.
526 @return KErrCANotSupported if the requested attribute does not exist.
527 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
528 @return Otherwise one of the other CAF error codes defined in \c caferr.h or one of the
529 other system-wide error codes for any other errors.
530 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
532 IMPORT_C TInt GetStringAttribute(TInt aAttribute, TDes& aValue, const TDesC& aUniqueId) const;
534 /** Obtain a set of string attributes for the default content object within the file
536 @see ContentAccess::TStringAttribute
539 CContent* content = CContent::NewLC(uri);
541 // create the attribute set, add the attributes we are interested in
542 RStringAttributeSet stringAttributeSet;
543 CleanupClosePushL(stringAttributeSet);
544 stringAttributeSet.AddL(EPreviewURI);
545 stringAttributeSet.AddL(ETitle);
547 User::LeaveIfError(content->GetStringAttributeSet(stringAttributeSet));
549 // Pass the value of the string attribute to DisplayPreview()
550 TFileName previewUri;
551 TInt err = stringAttributeSet.GetValue(EPreviewURI, previewUri);
554 DisplayPreview(previewUri);
557 CleanupStack::PopAndDestroy(2); // content, stringAttributeSet.Close()
561 @param aStringAttributeSet The set of attributes to query and update.
562 @return Whether the attribute set was updated.
563 @return KErrNone if the attributes were retrieved successfully.
564 @return KErrNotFound if the default content object was not found.
565 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
566 @return Otherwise one of the CAF error codes defined in \c caferr.h or one of the
567 other system-wide error codes for any other errors.
568 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
570 IMPORT_C TInt GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet) const;
572 /** Used to obtain a set of string attributes for an object within the file
574 @see ContentAccess::TStringAttribute
577 CContent* content = CContent::NewLC(uri);
579 // create the attribute set, add the attributes we are interested in
580 RStringAttributeSet stringAttributeSet;
581 CleanupClosePushL(stringAttributeSet);
582 stringAttributeSet.AddL(EPreviewURI);
583 stringAttributeSet.AddL(ETitle);
585 User::LeaveIfError(content->GetStringAttributeSet(stringAttributeSet, uniqueId));
587 // Pass the value of the string attribute to DisplayPreview()
588 TFileName previewUri;
589 TInt err = stringAttributeSet.GetValue(EPreviewURI, previewUri);
592 DisplayPreview(previewUri);
595 CleanupStack::PopAndDestroy(2); // content, stringAttributeSet.Close()
599 @param aStringAttributeSet The set of attributes to query and update.
600 @param aUniqueId The UniqueId of the container or content.
601 @return Whether the attribute set was updated.
602 @return KErrNone if the attributes were retrieved successfully.
603 @return KErrNotFound if the object with the given UniqueId was not found.
604 @return KErrPermissionDenied if the access to the protected content is not permitted by the CAF Agent.
605 @return Otherwise one of the CAF error codes defined in \c caferr.h or one of the
606 other system-wide error codes for any other errors.
607 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
609 IMPORT_C TInt GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet, const TDesC& aUniqueId) const;
611 /** Allows extended synchronous calls to the CAF agent handling this file
613 Applications familiar with the agent can pass objects in and out using serialization.
615 @param aCommand The agent defined command.
616 @param aInputBuffer Non modifyable input data buffer.
617 @param aOutputBuffer Modifyable output buffer to hold the result of the command.
618 @return The outcome of the agent specific command.
619 @return KErrCANotSupported if the agent does not recognize the command.
620 @return KErrOverflow if the output buffer supplied is too small.
621 @return KErrPermissionDenied if the agent does not allow the client to execute the command.
622 @return Otherwise one of the other CAF error codes defined in \c caferr.h or one of the
623 other system-wide error codes for any other errors.
624 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
626 IMPORT_C TInt AgentSpecificCommand(TInt aCommand, const TDesC8& aInputBuffer, TDes8& aOutputBuffer);
628 /** Allows extended synchronous calls to the CAF agent handling this file
629 Applications familiar with the agent can pass objects in and out using serialization.
630 NB: It is important that the descriptor passed to
631 aOutputBuffer remains in scope until the request has completed.
633 @param aCommand The agent defined command.
634 @param aInputBuffer Non modifyable input data buffer.
635 @param aOutputBuffer Modifyable output buffer to hold the result of the command.
636 @param aStatus Asynchronous request status. On completion this will contain
637 one of the following error codes:
638 KErrNone if the command was successfully executed.
639 KErrCANotSupported if the agent does not recognize the command.
640 KErrOverflow if the output buffer supplied is too small.
641 KErrPermissionDenied if the agent does not allow the client
642 to execute the command. Otherwise one of the other CAF error codes defined
643 in \c caferr.h or one of the other system-wide error codes
644 for any other errors.
645 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
647 IMPORT_C void AgentSpecificCommand(TInt aCommand, const TDesC8& aInputBuffer, TDes8& aOutputBuffer, TRequestStatus& aStatus);
650 /** Request notification for an event for the default content object within the file
652 @see ContentAccess::TEventMask
654 @param aMask Bitmask of events the caller is interested in.
655 @param aStatus The TRequestStatus object to complete if the event occurs.
656 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
658 IMPORT_C void NotifyStatusChange(TEventMask aMask, TRequestStatus& aStatus);
660 /** Request notification for an event for an object within the file
662 @see ContentAccess::TEventMask
664 @param aMask Bitmask of events the caller is interested in.
665 @param aStatus The TRequestStatus object to complete if the event occurs.
666 @param aUniqueId The UniqueId of the container or content.
667 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
669 IMPORT_C void NotifyStatusChange(TEventMask aMask, TRequestStatus& aStatus, const TDesC& aUniqueId);
671 /** Cancel a previous notification request for the default content object
673 @param aStatus The TRequestStatus supplied in the call to NotifyStatusChange().
674 @return The outcome of the cancel request.
675 @return KErrNone if the request was cancelled.
676 @return KErrNotFound if there was no matching request outstanding.
677 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
679 IMPORT_C TInt CancelNotifyStatusChange(TRequestStatus& aStatus);
681 /** Cancel a previous notification request
683 @param aStatus The TRequestStatus supplied in the call to NotifyStatusChange().
684 @param aUniqueId The UniqueId of the content object within the file.
685 @return The outcome of the cancel request.
686 @return KErrNone if the request was cancelled.
687 @return KErrNotFound if there was no matching request outstanding.
688 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
690 IMPORT_C TInt CancelNotifyStatusChange(TRequestStatus& aStatus, const TDesC& aUniqueId);
692 /** Request the agent to obtain rights for the default content object
694 This request may be handled differently by different agents.
695 Some agents may open a browser and direct the user to a URL. Others may
696 download and install the rights in the background.
698 The call should not block execution, applications can wait for a notification
699 if they are interested in the outcome.
701 @param aStatus Asynchronous request status. On completion this will contain
702 one of the following error codes:
703 KErrNone if the rights request was successful.
704 KErrCANotSupported if the agent does not allow rights requests.
705 Otherwise one of the other CAF error codes defined in \c caferr.h
706 or one of the other system-wide error codes
707 for any other errors.
708 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
710 IMPORT_C void RequestRights(TRequestStatus& aStatus);
712 /** Request the agent to obtain rights for a protected content object
714 This request may be handled differently by different agents.
715 Some agents may open a browser and direct the user to a URL. Others may
716 download and install the rights in the background.
718 The call should not block execution, applications can wait for a notification
719 if they are interested in the outcome.
721 @param aStatus Asynchronous request status. On completion this will contain
722 one of the following error codes:
723 KErrNone if the rights request was successful.
724 KErrCANotSupported if the agent does not allow rights requests.
725 Otherwise one of the other CAF error codes defined in \c caferr.h
726 or one of the other system-wide error codes
727 for any other errors.
729 @param aUniqueId The unique id of the object within the file.
730 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
732 IMPORT_C void RequestRights(TRequestStatus& aStatus, const TDesC& aUniqueId);
735 /** Cancel a previous RequestRights() request for the default content object
737 @param aStatus The TRequestStatus that was supplied to the RequestRights() function.
738 @return The result of the cancel rights request.
739 @return KErrNone if the rights request was cancelled.
740 @return KErrNotFound if there was no matching rights request outstanding.
741 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
743 IMPORT_C TInt CancelRequestRights(TRequestStatus& aStatus);
745 /** Cancel a previous RequestRights() request
747 @param aStatus The TRequestStatus that was supplied to the RequestRights() function.
748 @param aUniqueId The objects Unique Id that was supplied to the RequestRights() function.
749 @return The result of the cancel rights request.
750 @return KErrNone if the rights request was cancelled.
751 @return KErrNotFound if there was no matching rights request outstanding.
752 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
754 IMPORT_C TInt CancelRequestRights(TRequestStatus& aStatus, const TDesC& aUniqueId);
756 /** View information associated with the default content object
758 This call blocks execution and only returns once the display is dismissed
761 @see ContentAccess::TDisplayInfo
763 @param aInfo The information to display.
764 @leave KErrCANotSupported if information cannot be displayed or does not exist.
765 @leave ... One of the other CAF error codes defined in \c caferr.h
766 or one of the system-wide error codes for
768 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
770 IMPORT_C void DisplayInfoL(TDisplayInfo aInfo) const;
772 /** View information associated with a single content object
774 This call blocks execution and only returns once the display is dismissed
777 @see ContentAccess::TDisplayInfo
779 @param aInfo The information to display.
780 @param aUniqueId The unique id of the object within the file.
781 @leave KErrCANotSupported if information cannot be displayed or does not exist.
782 @leave ... One of the other CAF error codes defined in \c caferr.h
783 or one of the system-wide error codes for
785 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
787 IMPORT_C void DisplayInfoL(TDisplayInfo aInfo, const TDesC& aUniqueId) const;
790 /** Request the agent handling this content to set a property value. If
791 the property is set it is only set for this CContent session and does not
792 impact other CAF users and is not set for CData products created by the
795 @see ContentAccess::TAgentProperty
797 @param aProperty The property to set.
798 @param aValue The value of the property.
799 @return Whether the property was set.
800 @return KErrNone if the property was set.
801 @return KErrCANotSupported if the agent does not support the property or value.
802 @return KErrAccessDenied if the agent does not permit the property to be changed.
803 @return KErrPermissionDenied if the application does not have the necessary capability to change the property.
804 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
806 IMPORT_C TInt SetProperty(TAgentProperty aProperty, TInt aValue);
809 Grants read access to the default content object based on
810 evaluation of the supplied intent information.
812 Note that the intent is simply evaluated and not executed.
813 To force the intent to be executed, clients must use the call
814 ContentAccess::CData::ExecuteIntent().
816 A CData object can be obtained as follows:
818 CData* MyData = myContent->OpenContentL(ChosenIntent);
820 delete MyData; // when finished accessing plaintext content
823 @see ContentAccess::TIntent
825 @param aIntent The intent indicator.
826 @return A CData instance. The caller gets ownership of this object.
828 @leave KErrNotFound The content object with the given UniqueId does not exist.
829 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
830 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
831 @leave KErrCANoRights No rights exist for the content object.
832 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
833 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
834 @leave KErrAccessDenied The content is already in use.
835 @leave ... One of the other CAF error codes defined in \c caferr.h
836 or one of the other system-wide error codes for any other
838 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
840 IMPORT_C CData* OpenContentL(TIntent aIntent);
843 Grants read access to the default content object based on
844 evaluation of the supplied intent information.
846 Note that the intent is simply evaluated and not executed.
847 To force the intent to be executed, clients must use the call
848 ContentAccess::CData::ExecuteIntent().
850 A CData object can be obtained as follows:
852 CData* myData = myContent->OpenContentLC(ChosenIntent);
854 // when finished accessing plaintext content
855 CleanupStack::PopAndDestroy(myData);
858 @see ContentAccess::TIntent
860 @param aIntent The intent indicator.
861 @return A CData instance. The caller gets ownership of this object.
863 @leave KErrNotFound The content object with the given UniqueId does not exist.
864 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
865 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
866 @leave KErrCANoRights No rights exist for the content object.
867 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
868 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
869 @leave KErrAccessDenied The content is already in use.
870 @leave ... One of the other CAF error codes defined in \c caferr.h
871 or one of the other system-wide error codes for any other
873 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted.
875 IMPORT_C CData* OpenContentLC(TIntent aIntent);
878 Grants read access to the content object based on evaluation of the
879 supplied intent information.
881 Note that the intent is simply evaluated and not executed.
882 To force the intent to be executed, clients must use the call
883 ContentAccess::CData::ExecuteIntent().
885 A CData object can be obtained as follows:
887 CData* MyData = myContent->OpenContentL(ChosenIntent, uniqueId);
889 delete MyData; // when finished accessing plaintext content
892 @see ContentAccess::TIntent
894 @param aIntent The intent indicator.
895 @param aUniqueId The object to open for reading. If the UniqueId is set to KNullDesC16() the entire file will be opened for reading with no transformation.
896 @return A CData instance. The caller gets ownership of this object.
898 @leave KErrNotFound The content object with the given UniqueId does not exist.
899 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
900 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
901 @leave KErrCANoRights No rights exist for the content object.
902 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
903 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
904 @leave KErrAccessDenied The content is already in use.
905 @leave ... One of the other CAF error codes defined in \c caferr.h
906 or one of the other system-wide error codes for any other
908 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
910 IMPORT_C CData* OpenContentL(TIntent aIntent, const TDesC& aUniqueId);
914 Grants read access to the content object based on evaluation of the
915 supplied intent information.
917 Note that the intent is simply evaluated and not executed.
918 To force the intent to be executed, clients must use the call
919 ContentAccess::CData::ExecuteIntent().
921 A CData object can be obtained as follows:
923 CData* MyData = myContent->OpenContentLC(ChosenIntent, uniqueId);
925 PopAndDestroy(MyData); // when finished accessing plaintext content
928 @see ContentAccess::TIntent
930 @param aIntent The intent indicator.
931 @param aUniqueId The object to open for reading. If the UniqueId is set to KNullDesC16() the entire file will be opened for reading with no transformation.
932 @return A CData instance. The caller gets ownership of this object.
934 @leave KErrNotFound The content object with the given UniqueId does not exist.
935 @leave KErrCAPendingRights The rights have not yet arrived but are expected soon.
936 @leave KErrCANoPermission Rights exist but the specified intent is not permitted.
937 @leave KErrCANoRights No rights exist for the content object.
938 @leave KErrCANotSupported Unable to open the object with the specified UniqueId, it may be a container object.
939 @leave KErrPermissionDenied The agent does not allow the client to access the content object.
940 @leave KErrAccessDenied The content is already in use.
941 @leave ... One of the other CAF error codes defined in \c caferr.h
942 or one of the other system-wide error codes for any other
944 @capability DRM Access to DRM protected content is not permitted for processes without DRM capability. Access to unprotected content is unrestricted
946 IMPORT_C CData* OpenContentLC(TIntent aIntent, const TDesC& aUniqueId);
949 /** Find out which agent is handling this file
950 @return The agent handling the File
952 IMPORT_C const TAgent& Agent() const;
954 /** Indicates the mode in which the content is shared.
955 @return The content sharing mode
957 inline TContentShareMode ShareMode() const;
960 /** Create a CData object for reading the content
962 @see ContentAccess::TIntent
963 @param aIntent The intended use of the content
964 @param aShareMode The mode used to open the file. If EContentShareExclusive is required, use CData::NewL() instead
965 @return A new CData object
966 @leave One of the CAF error codes defined in \c caferr.h or one of the system-wide error codes for any errors.
967 @capability DRM Access to DRM agents is not permitted for processes without DRM capability
970 IMPORT_C CData* OpenContentL(TIntent aIntent, TContentShareMode aShareMode);
972 /** Create a CAttribute object to determine the attributes of the default content object
974 @return The agent handling the File
975 @capability DRM Access to DRM agents is not permitted for processes without DRM capability
978 IMPORT_C CAttribute* NewAttributeL(TBool aPreloaded);
980 /** Create a CAttribute object to determine the attributes of the default content object
982 @return The agent handling the File
983 @capability DRM Access to DRM agents is not permitted for processes without DRM capability
986 IMPORT_C CAttribute* NewAttributeL(TBool aPreloaded, TContentShareMode aShareMode);
988 #endif // REMOVE_CAF1
992 void ConstructL(RFile& aFile);
993 void ConstructL(const TDesC& aURI, TContentShareMode aShareMode);
995 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
996 void ConstructL(const TDesC8& aHeaderData);
999 Create a CData object for reading WMDRM content.
1001 @param aIntent The intended use of the content.
1002 @param aHeaderData Header data of WMDRM file/stream content.
1003 @return CData object.
1004 @leave One of the CAF error codes defined in caferr.h or one of the system-wide error codes for any errors.
1005 @capability DRM Access to DRM agents is not permitted for processes without DRM capability.
1008 CData* OpenContentL(TIntent aIntent, const TDesC8& aHeaderData);
1011 Create a CData object for reading WMDRM content.
1013 @param aIntent The intended use of the content.
1014 @param aHeaderData Header data of WMDRM file/stream content.
1015 @return CData object.
1016 @leave One of the CAF error codes defined in caferr.h or one of the system-wide error codes for any errors.
1017 @capability DRM Access to DRM agents is not permitted for processes without DRM capability.
1019 CData* OpenContentLC(TIntent aIntent, const TDesC8& aHeaderData);
1021 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1025 /** CAgentFactory object is effectively the ECOM session handle */
1026 CAgentFactory* iAgentFactory;
1029 Agent object used for browsing the contents of a file
1031 CAgentContent* iAgentContent;
1033 /** Points to the default content object if the file is opened by name */
1034 CVirtualPath* iVirtualPath;
1036 /** The content object referred to by CContent, either points to iVirtualPath
1037 or points to (KNullDesC(), KDefaultContentObject())
1039 TVirtualPathPtr iDefaultVirtualPath;
1041 /* Stores the name and UID of the agent
1045 /** The share mode used to open the content file*/
1046 TContentShareMode iShareMode;
1048 /** Reference to the file handle if the content was opened with a file handle */
1049 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
1053 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
1055 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1056 HBufC8* iHeaderData;
1057 #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1061 #include <caf/content.inl>
1062 } // namespace ContentAccess
1064 #endif // __CONTENT_H__