diff -r 000000000000 -r bde4ae8d615e os/security/contentmgmt/contentaccessfwfordrm/engineering/dox/Attributes.dox --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/security/contentmgmt/contentaccessfwfordrm/engineering/dox/Attributes.dox Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,161 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Each of these objects may have properties or attributes associated with it. This section +// outlines how applications can retrieve these using the CAF API. +//
ContentAccess::TAttribute
. It is possible
+// for agents to extend this set of attributes, starting from EAgentSpecificAttributeBase
.
+// The attribute functions are implemented in ContentAccess::CContent
, ContentAccess::CData
and
+// ContentAccess::CManager
.
+// Retrieving a Single Attribute
+// The attributes of one content object in a file may not necessarily be the same as the
+// attributes of other content objects within the same file. Attributes relate to a single
+// content object within a file.
+// It is possible that the attribute may not make sense for a particular content object. In that
+// case the agent will return an error KErrCANotSupported
. If an attempt is made to
+// retrieve the attributes of a content object that does not exist the agent will return KErrNotFound
.
+// The following code fragment illustrates how to retrieve an attribute for a particular
+// object within a content file.
+// CContent* content = CContent::NewL(uri);
+// // check if DRM rights are pending for the object specified by uniqueId
+// TInt attributeValue;
+// TInt err = content->GetAttribute(ERightsPending, attributeValue, uniqueId);
+// if(err == KErrNone)
+// // Check the value of the attribute
+// if(attributeValue == ETrue)
+// // Rights are pending, display waiting for rights countdown
+// else if(attributeValue == EFalse)
+// // Rights are not pending
+// else if(err == KErrCANotSupported)
+// // This attribute does not apply to this content object
+// else if(err == KErrNotFound)
+// // Cannot find the object specified by the given uniqueId
+// else if (err != KErrPermissionDenied)
+// // Unknown error
+// User::Leave(err);
+// Retrieving Several Attributes
+// For some agent implementations it may be more efficient to retrieve all the attributes for a content
+// object in one function call. The ContentAccess::RAttributeSet
object is used here to provide a way to
+// request and store several attributes.
+// Querying two attributes using the CManager API would look like the following:
+// // Agent manager
+// CManager *manager = CManager::NewLC();
+// // Prepare the attributes to query using the CAttributeSet object
+// RAttributeSet attributeSet;
+// CleanupClosePushL(attributeSet);
+// attributeSet.AddL(EProtected);
+// attributeSet.AddL(ECanView);
+// // Retrieve the attribute values from the agent
+// User::LeaveIfError(manager->GetAttributeSet(attributeSet, virtualPath));
+// // Check if the content object is protected
+// TInt attributeValue;
+// TInt err = attributeSet.GetValue(EProtected, attributeValue);
+// if(err == KErrNone && attributeValue)
+// // content object is DRM protected
+// // Check if the content object can be display on screen
+// TInt err = attributeSet.GetValue(ECanView, attributeValue);
+// if(err == KErrNone && attributeValue)
+// // content object has rights that allow it to be displayed on screen
+// // Finished
+// CleanupStack::PopAndDestroy(2); // manager, attributeSet
+// ContentAccess::TStringAttribute
enumeration. This
+// allows applications to request information such as the MIME type in a generic way for all agents.
+// Agents can extend this mechanism to provide agent specific attributes starting at
+// EAgentSpecificStringAttributeBase
.
+// The following example finds the author of a content object.
+// CContent* content = CContent::NewL(uri);
+// // define a buffer to store the attribute value string
+// TBuf <100> buf;
+// // retrieve the attribute
+// err = content->GetAttribute(EAuthor, authorBuffer, uniqueId);
+// // Display the authors name on screen
+// if (err == KErrNone)
+// DisplayAuthor(buf);
+// If the Agent does not support this attribute, it will return KErrCANotSupported
.
+// Retrieving Several String Attributes
+// For some agent implementations it may be more efficient to retrieve several string attributes for a content
+// object in one function call. The ContentAccess::RStringAttributeSet
object is used here to provide a way to
+// request and store several attributes.
+// Querying three attributes using the CManager API would look like the following:
+// CManager *manager = CManager::NewLC();
+// // Prepare the attributes to query using the CAttributeSet object
+// RStringAttributeSet stringAttributeSet;
+// CleanupClosePushL(stringAttributeSet);
+// stringAttributeSet.AddL(ETitle);
+// stringAttributeSet.AddL(EAuthor);
+// stringAttributeSet.AddL(EDescription);
+// // Retrieve the attribute values from the agent
+// User::LeaveIfError(manager->GetStringAttributeSet(stringAttributeSet, virtualPath));
+// // Display the values
+// TBuf <256> value;
+// TInt err = stringAttributeSet.GetValue(ETitle, value);
+// if(err == KErrNone)
+// Printf("Title : %s", value);
+// err = stringAttributeSet.GetValue(EAuthor, value);
+// if(err == KErrNone)
+// Printf("Author : %s", value);
+// err = stringAttributeSet.GetValue(EDescription, value);
+// if(err == KErrNone)
+// Printf("Description : %s", value);
+// // Finished
+// CleanupStack::PopAndDestroy(2); // manager, stringAttributeSet
+// ContentAccess::CContent::OpenContentL()
function.
+// CContent* content = CContent::NewLC(uri);
+// // Create an array to store the embedded objects
+// RStreamablePtrArray