author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:19:17 +0300 | |
branch | RCL_3 |
changeset 27 | 34937ec34dac |
parent 26 | 5b3385a43d68 |
permissions | -rw-r--r-- |
26 | 1 |
/* |
2 |
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "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". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: DRM utility implementation |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDES |
|
20 |
||
21 |
#include "glxdrmutility.h" |
|
22 |
||
23 |
#include <glxpanic.h> |
|
24 |
||
25 |
#include <DRMHelper.h> |
|
26 |
#include <DRMCommon.h> |
|
27 |
||
28 |
#include <caf/caf.h> |
|
29 |
#include <caf/content.h> |
|
30 |
#include <caf/data.h> |
|
31 |
#include <caf/manager.h> |
|
32 |
#include "glxtracer.h" |
|
33 |
#include "glxlog.h" |
|
34 |
||
35 |
#include <drmuihandling.h> |
|
36 |
using namespace DRM; |
|
37 |
||
38 |
const TInt KGlxDRMThumbnailHeight = 120; |
|
39 |
const TInt KGlxDRMThumbnailWidth = 90; |
|
40 |
||
41 |
// ======== MEMBER FUNCTIONS ======== |
|
42 |
||
43 |
/** |
|
44 |
* CGlxDrmTls |
|
45 |
* |
|
46 |
* Global object stored in TLS. |
|
47 |
* Owns the only instance of a CGlxDRMUtility |
|
48 |
*/ |
|
49 |
struct CGlxDrmTls |
|
50 |
{ |
|
51 |
CGlxDrmTls(CGlxDRMUtility* aUtility) |
|
52 |
{ |
|
53 |
iDrmUtility = aUtility; |
|
54 |
iRefCount = 0; |
|
55 |
} |
|
56 |
||
57 |
CGlxDRMUtility* iDrmUtility; |
|
58 |
TInt iRefCount; |
|
59 |
}; |
|
60 |
||
61 |
//============================================================================ |
|
62 |
// InstanceL |
|
63 |
//============================================================================ |
|
64 |
EXPORT_C CGlxDRMUtility* CGlxDRMUtility::InstanceL() |
|
65 |
{ |
|
66 |
TRACER("CGlxDRMUtility::InstanceL()"); |
|
67 |
CGlxDrmTls* tls = reinterpret_cast<CGlxDrmTls*> (Dll::Tls()); |
|
68 |
||
69 |
if (!tls) |
|
70 |
{ |
|
71 |
CGlxDRMUtility* drmutil = new (ELeave) CGlxDRMUtility(); |
|
72 |
CleanupStack::PushL(drmutil); |
|
73 |
drmutil->ConstructL(); |
|
74 |
||
75 |
tls = new (ELeave) CGlxDrmTls(drmutil); |
|
76 |
||
77 |
CleanupStack::Pop(drmutil); |
|
78 |
||
79 |
Dll::SetTls(reinterpret_cast<TAny*> (tls)); |
|
80 |
} |
|
81 |
||
82 |
tls->iRefCount++; |
|
83 |
||
84 |
return tls->iDrmUtility; |
|
85 |
} |
|
86 |
||
87 |
//============================================================================ |
|
88 |
// Close |
|
89 |
//============================================================================ |
|
90 |
EXPORT_C void CGlxDRMUtility::Close() |
|
91 |
{ |
|
92 |
TRACER("CGlxDRMUtility::Close()"); |
|
93 |
CGlxDrmTls* tls = reinterpret_cast<CGlxDrmTls*> (Dll::Tls()); |
|
94 |
||
95 |
if (tls) |
|
96 |
{ |
|
97 |
tls->iRefCount--; |
|
98 |
||
99 |
// Delete the tls pointer and list manager instance if this was the |
|
100 |
// last reference |
|
101 |
if (tls->iRefCount == 0) |
|
102 |
{ |
|
103 |
delete tls->iDrmUtility; |
|
104 |
delete tls; |
|
105 |
Dll::SetTls(NULL); |
|
106 |
} |
|
107 |
} |
|
108 |
} |
|
109 |
||
110 |
//============================================================================ |
|
111 |
// Destructor |
|
112 |
//============================================================================ |
|
113 |
CGlxDRMUtility::~CGlxDRMUtility() |
|
114 |
{ |
|
115 |
TRACER("CGlxDRMUtility::~CGlxDRMUtility()"); |
|
116 |
delete iCManager; |
|
117 |
delete iDrmHelper; |
|
118 |
delete iLastConsumedItemUri; |
|
119 |
} |
|
120 |
||
121 |
//============================================================================ |
|
122 |
// ItemRightsValidityCheckL |
|
123 |
// for checking DRM rights validity for item. |
|
124 |
// is called before right is consumed and for all items (focused or unfocused). |
|
125 |
//============================================================================ |
|
126 |
EXPORT_C TBool CGlxDRMUtility::ItemRightsValidityCheckL(const TDesC& aUri, |
|
127 |
TBool aCheckViewRights) |
|
128 |
{ |
|
129 |
TRACER("CGlxDRMUtility::ItemRightsValidityCheckL(URI)"); |
|
130 |
#ifdef _DEBUG |
|
131 |
TTime startTime; |
|
132 |
startTime.HomeTime(); |
|
133 |
#endif |
|
134 |
// When checking current rights for a URI |
|
135 |
//Allow to Open if rights for a URI was just consumed (i.e. same as stored URI) |
|
136 |
if (iLastConsumedItemUri->Length() > 0) |
|
137 |
{ |
|
138 |
if (aUri.CompareF(*iLastConsumedItemUri) == 0) |
|
139 |
{ |
|
140 |
return ETrue; |
|
141 |
} |
|
142 |
} |
|
143 |
||
144 |
//Else for uri of non-focused uri, just check validity rights |
|
145 |
TBool rightsValid = EFalse; |
|
146 |
TVirtualPathPtr path(aUri, KDefaultContentObject()); |
|
147 |
||
148 |
ContentAccess::TAttribute attr = |
|
149 |
aCheckViewRights ? ContentAccess::ECanView : ContentAccess::ECanPlay; |
|
150 |
||
151 |
// rightsValid is not updated if an error occurs |
|
152 |
iCManager->GetAttribute(attr, rightsValid, path); |
|
153 |
#ifdef _DEBUG |
|
154 |
TTime stopTime; |
|
155 |
stopTime.HomeTime(); |
|
156 |
GLX_DEBUG2("CGlxDRMUtility::ItemRightsValidityCheckL(URI) took <%d> us", |
|
157 |
(TInt) stopTime.MicroSecondsFrom(startTime).Int64()); |
|
158 |
#endif |
|
159 |
return rightsValid; |
|
160 |
} |
|
161 |
||
162 |
//============================================================================ |
|
163 |
// ItemRightsValidityCheckL |
|
164 |
// for checking DRM rights validity for item. |
|
165 |
// is called before right is consumed and for all items (focused or unfocused). |
|
166 |
//============================================================================ |
|
167 |
EXPORT_C TBool CGlxDRMUtility::ItemRightsValidityCheckL(RFile& aFileHandle, |
|
168 |
TBool aCheckViewRights) |
|
169 |
{ |
|
170 |
TRACER("CGlxDRMUtility::ItemRightsValidityCheckL(RFile)"); |
|
171 |
#ifdef _DEBUG |
|
172 |
TTime startTime; |
|
173 |
startTime.HomeTime(); |
|
27
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
174 |
#endif |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
175 |
TFileName fileName(KNullDesC); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
176 |
fileName.Append(aFileHandle.FullName(fileName)); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
177 |
if (iLastConsumedItemUri->Length() > 0) |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
178 |
{ |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
179 |
if (fileName.CompareF(*iLastConsumedItemUri) == 0) |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
180 |
{ |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
181 |
return ETrue; |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
182 |
} |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
183 |
} |
26 | 184 |
TBool rightsValid = EFalse; |
185 |
ContentAccess::TAttribute attrib = |
|
186 |
aCheckViewRights ? ContentAccess::ECanView : ContentAccess::ECanPlay; |
|
187 |
||
188 |
ContentAccess::CContent* content = ContentAccess::CContent::NewLC( |
|
189 |
aFileHandle); |
|
190 |
TInt err(content->GetAttribute(attrib, rightsValid)); |
|
191 |
CleanupStack::PopAndDestroy(content); |
|
192 |
#ifdef _DEBUG |
|
193 |
TTime stopTime; |
|
194 |
stopTime.HomeTime(); |
|
195 |
GLX_DEBUG2("CGlxDRMUtility::ItemRightsValidityCheckL(RFile) took <%d> us", |
|
196 |
(TInt) stopTime.MicroSecondsFrom(startTime).Int64()); |
|
197 |
#endif |
|
198 |
return rightsValid; |
|
199 |
} |
|
200 |
||
201 |
//============================================================================ |
|
202 |
// DisplayItemRightsCheckL |
|
203 |
// is called after right is consumed and for only focused/displayed item. |
|
204 |
//============================================================================ |
|
205 |
EXPORT_C TBool CGlxDRMUtility::DisplayItemRightsCheckL(const TDesC& aUri, |
|
206 |
TBool aCheckViewRights) |
|
207 |
{ |
|
208 |
TRACER("CGlxDRMUtility::DisplayItemRightsCheckL(URI)"); |
|
209 |
||
210 |
// Allow to display if rights for a URI was just consumed (i.e. same as stored URI) |
|
211 |
if (iLastConsumedItemUri->Length() > 0) |
|
212 |
{ |
|
213 |
if (aUri.CompareF(*iLastConsumedItemUri) == 0) |
|
214 |
{ |
|
215 |
return ETrue; |
|
216 |
} |
|
217 |
} |
|
218 |
||
219 |
//Clear the stored uri since focus has changed |
|
220 |
ClearLastConsumedItemUriL(); |
|
221 |
||
222 |
// Otherwise, check current rights for the URI of newly focused item |
|
223 |
return ItemRightsValidityCheckL(aUri, aCheckViewRights); |
|
224 |
} |
|
225 |
||
226 |
//============================================================================ |
|
227 |
// DisplayItemRightsCheckL |
|
228 |
// is called after right is consumed and for only focused/displayed item. |
|
229 |
//============================================================================ |
|
230 |
EXPORT_C TBool CGlxDRMUtility::DisplayItemRightsCheckL(RFile& aFileHandle, |
|
231 |
TBool aCheckViewRights) |
|
232 |
{ |
|
233 |
TRACER("CGlxDRMUtility::DisplayItemRightsCheckL(RFile)"); |
|
27
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
234 |
TFileName fileName(KNullDesC); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
235 |
fileName.Append(aFileHandle.FullName(fileName)); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
236 |
// Allow to display if rights for a URI was just consumed (i.e. same as stored URI) |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
237 |
if (iLastConsumedItemUri->Length() > 0) |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
238 |
{ |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
239 |
if (fileName.CompareF(*iLastConsumedItemUri) == 0) |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
240 |
{ |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
241 |
return ETrue; |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
242 |
} |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
243 |
} |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
244 |
|
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
245 |
//Clear the stored uri |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
246 |
ClearLastConsumedItemUriL(); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
247 |
|
26 | 248 |
// Otherwise, check current rights for the URI of newly focused item |
249 |
return ItemRightsValidityCheckL(aFileHandle, aCheckViewRights); |
|
250 |
} |
|
251 |
||
252 |
//============================================================================ |
|
253 |
// ConsumeRightsL |
|
254 |
//============================================================================ |
|
255 |
EXPORT_C TBool CGlxDRMUtility::ConsumeRightsL(const TDesC& aUri) |
|
256 |
{ |
|
257 |
TRACER("CGlxDRMUtility::ConsumeRightsL(URI)"); |
|
258 |
TVirtualPathPtr path(aUri, KDefaultContentObject()); |
|
259 |
||
260 |
// Create a CData object to read the content |
|
261 |
// Tell the agent we are planning to display the content |
|
262 |
CData* data = CData::NewLC(path, ContentAccess::EView, |
|
263 |
EContentShareReadOnly); |
|
264 |
||
265 |
//When consuming rights for a URI, clear stored URI |
|
266 |
ClearLastConsumedItemUriL(); |
|
267 |
||
268 |
// Execute the intent, tell the agent that we plan to display the content |
|
269 |
// It is at this point that any stateful rights will be decremented |
|
270 |
TInt err = data->ExecuteIntent(ContentAccess::EView); |
|
271 |
if (err == KErrNone) |
|
272 |
{ |
|
273 |
//Update stored URI |
|
274 |
iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL(aUri.Length()); |
|
275 |
TPtr newPtr = iLastConsumedItemUri->Des(); |
|
276 |
newPtr.Copy(aUri); |
|
277 |
} |
|
278 |
||
279 |
CleanupStack::PopAndDestroy(data); |
|
280 |
||
281 |
return (err == KErrNone); |
|
282 |
} |
|
283 |
||
284 |
//============================================================================ |
|
285 |
// ConsumeRightsL |
|
286 |
//============================================================================ |
|
287 |
EXPORT_C TBool CGlxDRMUtility::ConsumeRightsL(RFile& aFileHandle) |
|
288 |
{ |
|
289 |
TRACER("CGlxDRMUtility::ConsumeRightsL(RFile)"); |
|
290 |
CData* data = CData::NewLC(aFileHandle, KDefaultContentObject(), EPeek); |
|
27
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
291 |
|
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
292 |
//When consuming rights for a URI, clear stored URI |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
293 |
ClearLastConsumedItemUriL(); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
294 |
|
26 | 295 |
TInt err = data->ExecuteIntent(ContentAccess::EView); |
27
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
296 |
TFileName fileName(KNullDesC); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
297 |
fileName.Append(aFileHandle.FullName(fileName)); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
298 |
|
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
299 |
if (err == KErrNone) |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
300 |
{ |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
301 |
//Update stored URI |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
302 |
iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL(fileName.Length()); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
303 |
TPtr newPtr = iLastConsumedItemUri->Des(); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
304 |
newPtr.Copy(fileName); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
305 |
} |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
306 |
|
26 | 307 |
CleanupStack::PopAndDestroy(data); |
308 |
return (err == KErrNone); |
|
309 |
} |
|
310 |
||
311 |
//============================================================================ |
|
312 |
//Clears Last Consumed Uri |
|
313 |
//============================================================================ |
|
314 |
EXPORT_C void CGlxDRMUtility::ClearLastConsumedItemUriL() |
|
315 |
{ |
|
316 |
TRACER("CGlxDRMUtility::ClearLastConsumedItemUriL()"); |
|
317 |
//clears the stored uri |
|
318 |
TPtr ptr = iLastConsumedItemUri->Des(); |
|
319 |
ptr.Zero(); |
|
320 |
iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL(0); |
|
321 |
} |
|
322 |
||
323 |
//============================================================================ |
|
324 |
// Test whether a media item is OMA DRM 2.0 protected and has an associated |
|
325 |
// info URL. |
|
326 |
//============================================================================ |
|
327 |
EXPORT_C TBool CGlxDRMUtility::CanShowInfoOnlineL(const TDesC& aUri) |
|
328 |
{ |
|
329 |
TRACER("CGlxDRMUtility::CanShowInfoOnlineL()"); |
|
330 |
TBool canShowInfoOnline = EFalse; |
|
331 |
||
332 |
HBufC8* urlBuf = NULL; |
|
333 |
canShowInfoOnline = iDrmHelper->HasInfoUrlL(const_cast<TDesC&> (aUri), |
|
334 |
urlBuf); |
|
335 |
||
336 |
// discard buf we don't need it |
|
337 |
delete urlBuf; |
|
338 |
||
339 |
return canShowInfoOnline; |
|
340 |
} |
|
341 |
||
342 |
//============================================================================ |
|
343 |
// Open the associated info URL for a media item in the browser. |
|
344 |
//============================================================================ |
|
345 |
EXPORT_C void CGlxDRMUtility::ShowInfoOnlineL(const TDesC& aUri) |
|
346 |
{ |
|
347 |
TRACER("CGlxDRMUtility::ShowInfoOnlineL()"); |
|
348 |
iDrmHelper->OpenInfoUrlL(const_cast<TDesC&> (aUri)); |
|
349 |
} |
|
350 |
||
351 |
//============================================================================ |
|
352 |
// Test whether a media item can be set as automated content. |
|
353 |
//============================================================================ |
|
354 |
EXPORT_C TBool CGlxDRMUtility::CanSetAsAutomatedL(const TDesC& aUri, |
|
355 |
TGlxDrmAutomatedType aType) |
|
356 |
{ |
|
357 |
TRACER("CGlxDRMUtility::CanSetAsAutomatedL()"); |
|
358 |
TBool canSetAutomated = EFalse; |
|
359 |
switch (aType) |
|
360 |
{ |
|
361 |
case EGlxDrmAutomatedTypeWallpaper: |
|
362 |
{ |
|
363 |
User::LeaveIfError(iDrmHelper->SetAutomatedType( |
|
364 |
CDRMHelper::EAutomatedTypeWallpaper)); |
|
365 |
User::LeaveIfError(iDrmHelper->CanSetAutomated(aUri, |
|
366 |
canSetAutomated)); |
|
367 |
break; |
|
368 |
} |
|
369 |
default: |
|
370 |
break; |
|
371 |
}; |
|
372 |
return canSetAutomated; |
|
373 |
} |
|
374 |
||
375 |
//============================================================================ |
|
376 |
// SetAsAutomatedL |
|
377 |
//============================================================================ |
|
378 |
EXPORT_C void CGlxDRMUtility::SetAsAutomatedL(const TDesC& aUri, |
|
379 |
TGlxDrmAutomatedType aType) |
|
380 |
{ |
|
381 |
TRACER("CGlxDRMUtility::SetAsAutomatedL()"); |
|
382 |
switch (aType) |
|
383 |
{ |
|
384 |
case EGlxDrmAutomatedTypeWallpaper: |
|
385 |
{ |
|
386 |
TInt error = iDrmHelper->SetAutomatedType( |
|
387 |
CDRMHelper::EAutomatedTypeWallpaper); |
|
388 |
if (KErrNone == error) |
|
389 |
{ |
|
390 |
error = iDrmHelper->SetAutomatedPassive(aUri); |
|
391 |
if (KErrNone != error) |
|
392 |
{ |
|
393 |
iDrmHelper->HandleErrorL(error, aUri); |
|
394 |
} |
|
395 |
} |
|
396 |
||
397 |
break; |
|
398 |
} |
|
399 |
default: |
|
400 |
break; |
|
401 |
}; |
|
402 |
} |
|
403 |
||
404 |
//============================================================================ |
|
405 |
// ShowDRMDetailsPane |
|
406 |
//============================================================================ |
|
407 |
EXPORT_C void CGlxDRMUtility::ShowDRMDetailsPaneL(const TDesC& aUri) |
|
408 |
{ |
|
409 |
TRACER("CGlxDRMUtility::ShowDRMDetailsPaneL(URI)"); |
|
410 |
GLX_LOG_URI("CGlxDRMUtility::ShowDRMDetailsPaneL(%S)", &aUri); |
|
411 |
RFs fs; |
|
412 |
User::LeaveIfError(fs.Connect()); |
|
413 |
CleanupClosePushL(fs); |
|
414 |
||
415 |
RFile64 drmFile; |
|
416 |
User::LeaveIfError(drmFile.Open(fs, aUri, EFileRead |
|
417 |
| EFileShareReadersOrWriters)); |
|
418 |
CleanupClosePushL(drmFile); |
|
419 |
||
420 |
CDrmUiHandling* drmUiHandler = CDrmUiHandling::NewLC(); |
|
421 |
TRAP_IGNORE(drmUiHandler->ShowDetailsViewL(drmFile)); |
|
422 |
CleanupStack::PopAndDestroy(drmUiHandler); |
|
423 |
||
424 |
CleanupStack::PopAndDestroy(&drmFile); |
|
425 |
CleanupStack::PopAndDestroy(&fs); |
|
426 |
} |
|
427 |
||
428 |
//============================================================================ |
|
429 |
// ShowDRMDetailsPane |
|
430 |
//============================================================================ |
|
431 |
EXPORT_C void CGlxDRMUtility::ShowDRMDetailsPaneL(RFile& aFileHandle) |
|
432 |
{ |
|
433 |
TRACER("CGlxDRMUtility::ShowDRMDetailsPaneL(RFile)"); |
|
434 |
CDrmUiHandling* drmUiHandler = CDrmUiHandling::NewLC(); |
|
435 |
TRAP_IGNORE(drmUiHandler->ShowDetailsViewL(aFileHandle)); |
|
436 |
CleanupStack::PopAndDestroy(drmUiHandler); |
|
437 |
} |
|
438 |
||
439 |
//============================================================================ |
|
440 |
// IsForwardLockedL |
|
441 |
//============================================================================ |
|
442 |
EXPORT_C TBool CGlxDRMUtility::IsForwardLockedL(const TDesC& aUri) |
|
443 |
{ |
|
444 |
TRACER("CGlxDRMUtility::IsForwardLockedL()"); |
|
445 |
TBool forwardLocked = EFalse; |
|
446 |
TVirtualPathPtr path(aUri, KDefaultContentObject()); |
|
447 |
||
448 |
// forwardLocked is not updated if an error occurs |
|
449 |
iCManager->GetAttribute(ContentAccess::EIsForwardable, forwardLocked, |
|
450 |
path); |
|
451 |
||
452 |
return forwardLocked; |
|
453 |
} |
|
454 |
||
455 |
//============================================================================ |
|
456 |
// ShowRightsInfoL |
|
457 |
//============================================================================ |
|
458 |
EXPORT_C void CGlxDRMUtility::ShowRightsInfoL(const TDesC& aUri) |
|
459 |
{ |
|
460 |
TRACER("CGlxDRMUtility::ShowRightsInfoL(URI)"); |
|
461 |
iDrmHelper->CheckRightsAmountL(aUri); |
|
462 |
} |
|
463 |
||
464 |
//============================================================================ |
|
465 |
// ShowRightsInfoL |
|
466 |
//============================================================================ |
|
467 |
EXPORT_C void CGlxDRMUtility::ShowRightsInfoL(RFile& aFileHandle) |
|
468 |
{ |
|
469 |
TRACER("CGlxDRMUtility::ShowRightsInfoL(RFile)"); |
|
470 |
iDrmHelper->CheckRightsAmountL(aFileHandle); |
|
471 |
} |
|
472 |
||
473 |
//============================================================================ |
|
474 |
// Return size for DRM thumbnail request. |
|
475 |
//============================================================================ |
|
476 |
EXPORT_C TSize CGlxDRMUtility::DRMThumbnailSize(TSize& aSize) |
|
477 |
{ |
|
478 |
TRACER("CGlxDRMUtility::DRMThumbnailSize()"); |
|
479 |
TSize thumbnailSize(KGlxDRMThumbnailWidth, KGlxDRMThumbnailHeight); |
|
480 |
||
481 |
if ((aSize.iWidth * aSize.iHeight) / 4 < KGlxDRMThumbnailWidth |
|
482 |
* KGlxDRMThumbnailHeight) |
|
483 |
{ |
|
484 |
thumbnailSize.iWidth = aSize.iWidth / 2; |
|
485 |
thumbnailSize.iHeight = aSize.iHeight / 2; |
|
486 |
} |
|
487 |
||
488 |
return thumbnailSize; |
|
489 |
} |
|
490 |
||
491 |
/** |
|
492 |
* C++ default constructor. |
|
493 |
*/ |
|
494 |
CGlxDRMUtility::CGlxDRMUtility() |
|
495 |
{ |
|
496 |
TRACER("CGlxDRMUtility::CGlxDRMUtility()"); |
|
497 |
} |
|
498 |
||
499 |
/** |
|
500 |
* By default Symbian 2nd phase constructor is private. |
|
501 |
*/ |
|
502 |
void CGlxDRMUtility::ConstructL() |
|
503 |
{ |
|
504 |
TRACER("CGlxDRMUtility::ConstructL()"); |
|
505 |
iCManager = ContentAccess::CManager::NewL(); |
|
506 |
iDrmHelper = CDRMHelper::NewL(); |
|
507 |
iLastConsumedItemUri = HBufC::NewL(0); |
|
508 |
} |
|
509 |
||
510 |
// End of File |