sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Each of these objects may have properties or attributes associated with it. This section
|
sl@0
|
15 |
// outlines how applications can retrieve these using the CAF API.
|
sl@0
|
16 |
// <hr>
|
sl@0
|
17 |
// Different agents may use different terms to describe the same concept. Generic attributes provide a
|
sl@0
|
18 |
// way for applications to query standardised information about a content object.
|
sl@0
|
19 |
// These standardised attributes are given by the enumeration <code>ContentAccess::TAttribute</code>. It is possible
|
sl@0
|
20 |
// for agents to extend this set of attributes, starting from <code>EAgentSpecificAttributeBase</code>.
|
sl@0
|
21 |
// The attribute functions are implemented in <code>ContentAccess::CContent</code>, <code>ContentAccess::CData</code> and
|
sl@0
|
22 |
// <code>ContentAccess::CManager</code>.
|
sl@0
|
23 |
// <b> Retrieving a Single Attribute </b>
|
sl@0
|
24 |
// The attributes of one content object in a file may not necessarily be the same as the
|
sl@0
|
25 |
// attributes of other content objects within the same file. Attributes relate to a single
|
sl@0
|
26 |
// content object within a file.
|
sl@0
|
27 |
// It is possible that the attribute may not make sense for a particular content object. In that
|
sl@0
|
28 |
// case the agent will return an error <code>KErrCANotSupported</code>. If an attempt is made to
|
sl@0
|
29 |
// retrieve the attributes of a content object that does not exist the agent will return <code>KErrNotFound</code>.
|
sl@0
|
30 |
// The following code fragment illustrates how to retrieve an attribute for a particular
|
sl@0
|
31 |
// object within a content file.
|
sl@0
|
32 |
// CContent* content = CContent::NewL(uri);
|
sl@0
|
33 |
// // check if DRM rights are pending for the object specified by uniqueId
|
sl@0
|
34 |
// TInt attributeValue;
|
sl@0
|
35 |
// TInt err = content->GetAttribute(ERightsPending, attributeValue, uniqueId);
|
sl@0
|
36 |
// if(err == KErrNone)
|
sl@0
|
37 |
// // Check the value of the attribute
|
sl@0
|
38 |
// if(attributeValue == ETrue)
|
sl@0
|
39 |
// // Rights are pending, display waiting for rights countdown
|
sl@0
|
40 |
// else if(attributeValue == EFalse)
|
sl@0
|
41 |
// // Rights are not pending
|
sl@0
|
42 |
// else if(err == KErrCANotSupported)
|
sl@0
|
43 |
// // This attribute does not apply to this content object
|
sl@0
|
44 |
// else if(err == KErrNotFound)
|
sl@0
|
45 |
// // Cannot find the object specified by the given uniqueId
|
sl@0
|
46 |
// else if (err != KErrPermissionDenied)
|
sl@0
|
47 |
// // Unknown error
|
sl@0
|
48 |
// User::Leave(err);
|
sl@0
|
49 |
// <b> Retrieving Several Attributes </b>
|
sl@0
|
50 |
// For some agent implementations it may be more efficient to retrieve all the attributes for a content
|
sl@0
|
51 |
// object in one function call. The <code>ContentAccess::RAttributeSet</code> object is used here to provide a way to
|
sl@0
|
52 |
// request and store several attributes.
|
sl@0
|
53 |
// Querying two attributes using the CManager API would look like the following:
|
sl@0
|
54 |
// // Agent manager
|
sl@0
|
55 |
// CManager *manager = CManager::NewLC();
|
sl@0
|
56 |
// // Prepare the attributes to query using the CAttributeSet object
|
sl@0
|
57 |
// RAttributeSet attributeSet;
|
sl@0
|
58 |
// CleanupClosePushL(attributeSet);
|
sl@0
|
59 |
// attributeSet.AddL(EProtected);
|
sl@0
|
60 |
// attributeSet.AddL(ECanView);
|
sl@0
|
61 |
// // Retrieve the attribute values from the agent
|
sl@0
|
62 |
// User::LeaveIfError(manager->GetAttributeSet(attributeSet, virtualPath));
|
sl@0
|
63 |
// // Check if the content object is protected
|
sl@0
|
64 |
// TInt attributeValue;
|
sl@0
|
65 |
// TInt err = attributeSet.GetValue(EProtected, attributeValue);
|
sl@0
|
66 |
// if(err == KErrNone && attributeValue)
|
sl@0
|
67 |
// // content object is DRM protected
|
sl@0
|
68 |
// // Check if the content object can be display on screen
|
sl@0
|
69 |
// TInt err = attributeSet.GetValue(ECanView, attributeValue);
|
sl@0
|
70 |
// if(err == KErrNone && attributeValue)
|
sl@0
|
71 |
// // content object has rights that allow it to be displayed on screen
|
sl@0
|
72 |
// // Finished
|
sl@0
|
73 |
// CleanupStack::PopAndDestroy(2); // manager, attributeSet
|
sl@0
|
74 |
// <hr>
|
sl@0
|
75 |
// String attributes are similar to the attributes described above except the value associated
|
sl@0
|
76 |
// with the attribute is a string. A good example of where a string attribute is required is the
|
sl@0
|
77 |
// MIME type of a content object within a file.
|
sl@0
|
78 |
// The string attributes are standardised by the <code>ContentAccess::TStringAttribute</code> enumeration. This
|
sl@0
|
79 |
// allows applications to request information such as the MIME type in a generic way for all agents.
|
sl@0
|
80 |
// Agents can extend this mechanism to provide agent specific attributes starting at
|
sl@0
|
81 |
// <code>EAgentSpecificStringAttributeBase</code>.
|
sl@0
|
82 |
// The following example finds the author of a content object.
|
sl@0
|
83 |
// CContent* content = CContent::NewL(uri);
|
sl@0
|
84 |
// // define a buffer to store the attribute value string
|
sl@0
|
85 |
// TBuf <100> buf;
|
sl@0
|
86 |
// // retrieve the attribute
|
sl@0
|
87 |
// err = content->GetAttribute(EAuthor, authorBuffer, uniqueId);
|
sl@0
|
88 |
// // Display the authors name on screen
|
sl@0
|
89 |
// if (err == KErrNone)
|
sl@0
|
90 |
// DisplayAuthor(buf);
|
sl@0
|
91 |
// If the Agent does not support this attribute, it will return <code>KErrCANotSupported</code>.
|
sl@0
|
92 |
// <b> Retrieving Several String Attributes </b>
|
sl@0
|
93 |
// For some agent implementations it may be more efficient to retrieve several string attributes for a content
|
sl@0
|
94 |
// object in one function call. The <code>ContentAccess::RStringAttributeSet</code> object is used here to provide a way to
|
sl@0
|
95 |
// request and store several attributes.
|
sl@0
|
96 |
// Querying three attributes using the CManager API would look like the following:
|
sl@0
|
97 |
// CManager *manager = CManager::NewLC();
|
sl@0
|
98 |
// // Prepare the attributes to query using the CAttributeSet object
|
sl@0
|
99 |
// RStringAttributeSet stringAttributeSet;
|
sl@0
|
100 |
// CleanupClosePushL(stringAttributeSet);
|
sl@0
|
101 |
// stringAttributeSet.AddL(ETitle);
|
sl@0
|
102 |
// stringAttributeSet.AddL(EAuthor);
|
sl@0
|
103 |
// stringAttributeSet.AddL(EDescription);
|
sl@0
|
104 |
// // Retrieve the attribute values from the agent
|
sl@0
|
105 |
// User::LeaveIfError(manager->GetStringAttributeSet(stringAttributeSet, virtualPath));
|
sl@0
|
106 |
// // Display the values
|
sl@0
|
107 |
// TBuf <256> value;
|
sl@0
|
108 |
// TInt err = stringAttributeSet.GetValue(ETitle, value);
|
sl@0
|
109 |
// if(err == KErrNone)
|
sl@0
|
110 |
// Printf("Title : %s", value);
|
sl@0
|
111 |
// err = stringAttributeSet.GetValue(EAuthor, value);
|
sl@0
|
112 |
// if(err == KErrNone)
|
sl@0
|
113 |
// Printf("Author : %s", value);
|
sl@0
|
114 |
// err = stringAttributeSet.GetValue(EDescription, value);
|
sl@0
|
115 |
// if(err == KErrNone)
|
sl@0
|
116 |
// Printf("Description : %s", value);
|
sl@0
|
117 |
// // Finished
|
sl@0
|
118 |
// CleanupStack::PopAndDestroy(2); // manager, stringAttributeSet
|
sl@0
|
119 |
// <hr>
|
sl@0
|
120 |
// Some agents may expose meta data so they can be read using a \c CData object. The format
|
sl@0
|
121 |
// of these meta-data objects is not specified by the Content Access Framework but could
|
sl@0
|
122 |
// be useful for applications familiar with the agent to read meta data this way.
|
sl@0
|
123 |
// \c CData objects for agent specific meta-data can be opened in the same way content objects
|
sl@0
|
124 |
// are opened using the <code>ContentAccess::CContent::OpenContentL()</code> function.
|
sl@0
|
125 |
// CContent* content = CContent::NewLC(uri);
|
sl@0
|
126 |
// // Create an array to store the embedded objects
|
sl@0
|
127 |
// RStreamablePtrArray<CEmbeddedObject> myArray;
|
sl@0
|
128 |
// CleanupClosePushL(myArray);
|
sl@0
|
129 |
// // Get the embedded "Agent Specific" objects in the current container
|
sl@0
|
130 |
// content->GetEmbeddedObjectsL(myArray, EAgentSpecificObject);
|
sl@0
|
131 |
// // Get the unique Id of the first meta-data object
|
sl@0
|
132 |
// TPtrC aUniqueId = myArray[0]->UniqueId();
|
sl@0
|
133 |
// // create a CData object to read the meta data
|
sl@0
|
134 |
// CData *myMetaData = content->OpenContentLC(EPeek, aUniqueId);
|
sl@0
|
135 |
// // Do something with the data
|
sl@0
|
136 |
// // Finished
|
sl@0
|
137 |
// CleanupStack::PopAndDestroy(3); // content, myArray, myMetaData
|
sl@0
|
138 |
// <hr>
|
sl@0
|
139 |
//
|
sl@0
|
140 |
//
|
sl@0
|
141 |
|
sl@0
|
142 |
/**
|
sl@0
|
143 |
@page ContentAttributes Content Object Attributes
|
sl@0
|
144 |
As shown in the @ref CContentAPI "Consumer API", a file may consist of many content and container objects.
|
sl@0
|
145 |
- @ref CAFAttributes
|
sl@0
|
146 |
- @ref CAFStringAttributes
|
sl@0
|
147 |
- @ref CAFAgentSpecificMetaData
|
sl@0
|
148 |
@section CAFAttributes Generic Attributes
|
sl@0
|
149 |
@code
|
sl@0
|
150 |
@endcode
|
sl@0
|
151 |
@code
|
sl@0
|
152 |
@endcode
|
sl@0
|
153 |
@section CAFStringAttributes Generic String attributes
|
sl@0
|
154 |
@code
|
sl@0
|
155 |
@endcode
|
sl@0
|
156 |
@code
|
sl@0
|
157 |
@endcode
|
sl@0
|
158 |
@section CAFAgentSpecificMetaData Agent specific meta-data
|
sl@0
|
159 |
@code
|
sl@0
|
160 |
@endcode
|
sl@0
|
161 |
*/
|