108 //============================================================================ |
111 //============================================================================ |
109 // Destructor |
112 // Destructor |
110 //============================================================================ |
113 //============================================================================ |
111 CGlxDRMUtility::~CGlxDRMUtility() |
114 CGlxDRMUtility::~CGlxDRMUtility() |
112 { |
115 { |
|
116 TRACER("CGlxDRMUtility::~CGlxDRMUtility()"); |
113 delete iCManager; |
117 delete iCManager; |
114 delete iDrmHelper; |
118 delete iDrmHelper; |
115 delete iLastConsumedItemUri; |
119 delete iLastConsumedItemUri; |
116 } |
120 } |
117 |
121 |
118 //============================================================================ |
122 //============================================================================ |
119 // CheckOpenRightsL |
123 // ItemRightsValidityCheckL |
120 //============================================================================ |
124 // for checking DRM rights validity for item. |
121 EXPORT_C TBool CGlxDRMUtility::CheckOpenRightsL( const TDesC& aUri, |
125 // is called before right is consumed and for all items (focused or unfocused). |
|
126 //============================================================================ |
|
127 EXPORT_C TBool CGlxDRMUtility::ItemRightsValidityCheckL( const TDesC& aUri, |
122 TBool aCheckViewRights ) |
128 TBool aCheckViewRights ) |
123 { |
129 { |
124 // When checking current rights for a URI, clear stored URI |
130 TRACER("CGlxDRMUtility::ItemRightsValidityCheckL()"); |
125 TPtr ptr = iLastConsumedItemUri->Des(); |
131 // When checking current rights for a URI |
126 ptr.Zero(); |
132 |
127 iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( 0 ); |
133 //Allow to Open if rights for a URI was just consumed (i.e. same as stored URI) |
128 |
134 if ( iLastConsumedItemUri->Length() > 0 ) |
129 TBool rightsValid = EFalse; |
135 { |
|
136 if ( aUri.CompareF( *iLastConsumedItemUri ) == 0 ) |
|
137 { |
|
138 return ETrue; |
|
139 } |
|
140 } |
|
141 |
|
142 //Else for uri of non-focused uri, just check validity rights |
|
143 TInt rightsValid = 0; |
130 TVirtualPathPtr path( aUri, KDefaultContentObject() ); |
144 TVirtualPathPtr path( aUri, KDefaultContentObject() ); |
131 |
145 |
132 ContentAccess::TAttribute attr = |
146 ContentAccess::TAttribute attr = |
133 aCheckViewRights ? ContentAccess::ECanView : ContentAccess::ECanPlay; |
147 aCheckViewRights ? ContentAccess::ECanView : ContentAccess::ECanPlay; |
134 |
148 |
137 |
151 |
138 return rightsValid; |
152 return rightsValid; |
139 } |
153 } |
140 |
154 |
141 //============================================================================ |
155 //============================================================================ |
142 // CheckDisplayRightsL |
156 // ItemRightsValidityCheckL |
143 //============================================================================ |
157 // for checking DRM rights validity for item. |
144 EXPORT_C TBool CGlxDRMUtility::CheckDisplayRightsL( const TDesC& aUri, |
158 // is called before right is consumed and for all items (focused or unfocused). |
|
159 //============================================================================ |
|
160 EXPORT_C TBool CGlxDRMUtility::ItemRightsValidityCheckL( RFile& aFileHandle, |
|
161 TBool /*aCheckViewRights*/ ) |
|
162 { |
|
163 TRACER("CGlxDRMUtility::ItemRightsValidityCheckL()"); |
|
164 TBool rightsValid = EFalse; |
|
165 |
|
166 ContentAccess::CContent* content = ContentAccess::CContent::NewLC( aFileHandle ); |
|
167 content->GetAttribute( ContentAccess::ECanView, rightsValid ); |
|
168 CleanupStack::PopAndDestroy( content ); |
|
169 return rightsValid; |
|
170 } |
|
171 |
|
172 //============================================================================ |
|
173 // DisplayItemRightsCheckL |
|
174 // is called after right is consumed and for only focused/displayed item. |
|
175 //============================================================================ |
|
176 EXPORT_C TBool CGlxDRMUtility::DisplayItemRightsCheckL( const TDesC& aUri, |
145 TBool aCheckViewRights ) |
177 TBool aCheckViewRights ) |
146 { |
178 { |
|
179 TRACER("CGlxDRMUtility::DisplayItemRightsCheckL()"); |
|
180 |
147 // Allow to display if rights for a URI was just consumed (i.e. same as stored URI) |
181 // Allow to display if rights for a URI was just consumed (i.e. same as stored URI) |
148 if ( iLastConsumedItemUri->Length() > 0 ) |
182 if ( iLastConsumedItemUri->Length() > 0 ) |
149 { |
183 { |
150 if ( aUri.CompareF( *iLastConsumedItemUri ) == 0 ) |
184 if ( aUri.CompareF( *iLastConsumedItemUri ) == 0 ) |
151 { |
185 { |
152 return ETrue; |
186 return ETrue; |
153 } |
187 } |
154 } |
188 } |
155 |
189 |
156 // Otherwise, check current rights for the URI |
190 //Clear the stored uri since focus has changed |
157 return CheckOpenRightsL( aUri, aCheckViewRights ); |
191 ClearLastConsumedItemUriL(); |
158 } |
192 |
|
193 // Otherwise, check current rights for the URI of newly focused item |
|
194 return ItemRightsValidityCheckL( aUri, aCheckViewRights ); |
|
195 } |
|
196 |
|
197 //============================================================================ |
|
198 // DisplayItemRightsCheckL |
|
199 // is called after right is consumed and for only focused/displayed item. |
|
200 //============================================================================ |
|
201 EXPORT_C TBool CGlxDRMUtility::DisplayItemRightsCheckL( RFile& aFileHandle, |
|
202 TBool aCheckViewRights ) |
|
203 { |
|
204 TRACER("CGlxDRMUtility::DisplayItemRightsCheckL()"); |
|
205 // Otherwise, check current rights for the URI of newly focused item |
|
206 return ItemRightsValidityCheckL( aFileHandle, aCheckViewRights ); |
|
207 } |
|
208 |
159 |
209 |
160 //============================================================================ |
210 //============================================================================ |
161 // ConsumeRightsL |
211 // ConsumeRightsL |
162 //============================================================================ |
212 //============================================================================ |
163 EXPORT_C TBool CGlxDRMUtility::ConsumeRightsL(const TDesC& aUri) |
213 EXPORT_C TBool CGlxDRMUtility::ConsumeRightsL(const TDesC& aUri) |
164 { |
214 { |
|
215 TRACER("CGlxDRMUtility::ConsumeRightsL()"); |
165 TVirtualPathPtr path( aUri, KDefaultContentObject() ); |
216 TVirtualPathPtr path( aUri, KDefaultContentObject() ); |
166 |
217 |
167 // Create a CData object to read the content |
218 // Create a CData object to read the content |
168 // Tell the agent we are planning to display the content |
219 // Tell the agent we are planning to display the content |
169 CData* data = CData::NewLC(path, ContentAccess::EView, EContentShareReadOnly); |
220 CData* data = CData::NewLC(path, ContentAccess::EView, EContentShareReadOnly); |
170 |
221 |
171 // When consuming rights for a URI, clear stored URI |
222 //When consuming rights for a URI, clear stored URI |
172 TPtr oldPtr = iLastConsumedItemUri->Des(); |
223 ClearLastConsumedItemUriL(); |
173 oldPtr.Zero(); |
|
174 iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( aUri.Length() ); |
|
175 |
224 |
176 // Execute the intent, tell the agent that we plan to display the content |
225 // Execute the intent, tell the agent that we plan to display the content |
177 // It is at this point that any stateful rights will be decremented |
226 // It is at this point that any stateful rights will be decremented |
178 TInt err = data->ExecuteIntent(ContentAccess::EView); |
227 TInt err = data->ExecuteIntent(ContentAccess::EView); |
179 if ( err == KErrNone ) |
228 if ( err == KErrNone ) |
180 { |
229 { |
181 // Update stored URI |
230 //Update stored URI |
|
231 iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( aUri.Length() ); |
182 TPtr newPtr = iLastConsumedItemUri->Des(); |
232 TPtr newPtr = iLastConsumedItemUri->Des(); |
183 newPtr.Copy( aUri ); |
233 newPtr.Copy( aUri ); |
184 } |
234 } |
185 |
235 |
186 CleanupStack::PopAndDestroy(data); |
236 CleanupStack::PopAndDestroy(data); |
187 |
237 |
188 return (err == KErrNone); |
238 return (err == KErrNone); |
189 } |
239 } |
190 |
240 |
|
241 |
|
242 //============================================================================ |
|
243 // ConsumeRightsL |
|
244 //============================================================================ |
|
245 EXPORT_C TBool CGlxDRMUtility::ConsumeRightsL(RFile& aFileHandle) |
|
246 { |
|
247 TRACER("CGlxDRMUtility::ConsumeRightsL(RFile& aFileHandle)"); |
|
248 CData* data = CData::NewLC( aFileHandle, KDefaultContentObject(), EPeek ); |
|
249 TInt err = data->ExecuteIntent(ContentAccess::EView); |
|
250 CleanupStack::PopAndDestroy( data ); |
|
251 return (err == KErrNone); |
|
252 } |
|
253 |
|
254 //============================================================================ |
|
255 //Clears Last Consumed Uri |
|
256 //============================================================================ |
|
257 EXPORT_C void CGlxDRMUtility::ClearLastConsumedItemUriL() |
|
258 { |
|
259 //clears the stored uri |
|
260 TPtr ptr = iLastConsumedItemUri->Des(); |
|
261 ptr.Zero(); |
|
262 iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( 0 ); |
|
263 } |
|
264 |
191 //============================================================================ |
265 //============================================================================ |
192 // Test whether a media item is OMA DRM 2.0 protected and has an associated |
266 // Test whether a media item is OMA DRM 2.0 protected and has an associated |
193 // info URL. |
267 // info URL. |
194 //============================================================================ |
268 //============================================================================ |
195 EXPORT_C TBool CGlxDRMUtility::CanShowInfoOnlineL(TDesC& aUri) |
269 EXPORT_C TBool CGlxDRMUtility::CanShowInfoOnlineL(const TDesC& aUri) |
196 { |
270 { |
|
271 TRACER("CGlxDRMUtility::CanShowInfoOnlineL()"); |
197 TBool canShowInfoOnline = EFalse; |
272 TBool canShowInfoOnline = EFalse; |
198 |
273 |
199 HBufC8* urlBuf = NULL; |
274 HBufC8* urlBuf = NULL; |
200 canShowInfoOnline = iDrmHelper->HasInfoUrlL(aUri, urlBuf); |
275 canShowInfoOnline = iDrmHelper->HasInfoUrlL( const_cast<TDesC&>(aUri) , urlBuf); |
201 |
276 |
202 // discard buf we don't need it |
277 // discard buf we don't need it |
203 delete urlBuf; |
278 delete urlBuf; |
204 |
279 |
205 return canShowInfoOnline; |
280 return canShowInfoOnline; |
206 } |
281 } |
207 |
282 |
208 //============================================================================ |
283 //============================================================================ |
209 // Open the associated info URL for a media item in the browser. |
284 // Open the associated info URL for a media item in the browser. |
210 //============================================================================ |
285 //============================================================================ |
211 EXPORT_C void CGlxDRMUtility::ShowInfoOnlineL(TDesC& aUri) |
286 EXPORT_C void CGlxDRMUtility::ShowInfoOnlineL(const TDesC& aUri) |
212 { |
287 { |
213 iDrmHelper->OpenInfoUrlL(aUri); |
288 TRACER("CGlxDRMUtility::ShowInfoOnlineL()"); |
|
289 iDrmHelper->OpenInfoUrlL( const_cast<TDesC&>(aUri) ); |
214 } |
290 } |
215 |
291 |
216 //============================================================================ |
292 //============================================================================ |
217 // Test whether a media item can be set as automated content. |
293 // Test whether a media item can be set as automated content. |
218 //============================================================================ |
294 //============================================================================ |
219 EXPORT_C TBool CGlxDRMUtility::CanSetAsAutomatedL(const TDesC& aUri, |
295 EXPORT_C TBool CGlxDRMUtility::CanSetAsAutomatedL(const TDesC& aUri, |
220 TGlxDrmAutomatedType aType) |
296 TGlxDrmAutomatedType aType) |
221 { |
297 { |
|
298 TRACER("CGlxDRMUtility::CanSetAsAutomatedL()"); |
222 TBool canSetAutomated = EFalse; |
299 TBool canSetAutomated = EFalse; |
223 switch(aType) |
300 switch(aType) |
224 { |
301 { |
225 case EGlxDrmAutomatedTypeWallpaper: |
302 case EGlxDrmAutomatedTypeWallpaper: |
226 { |
303 { |
264 //============================================================================ |
342 //============================================================================ |
265 // ShowDRMDetailsPane |
343 // ShowDRMDetailsPane |
266 //============================================================================ |
344 //============================================================================ |
267 EXPORT_C void CGlxDRMUtility::ShowDRMDetailsPaneL( const TDesC& aUri ) |
345 EXPORT_C void CGlxDRMUtility::ShowDRMDetailsPaneL( const TDesC& aUri ) |
268 { |
346 { |
|
347 TRACER("CGlxDRMUtility::ShowDRMDetailsPaneL()"); |
269 TRAPD( err, iDrmHelper->LaunchDetailsViewEmbeddedL( aUri ) ); |
348 TRAPD( err, iDrmHelper->LaunchDetailsViewEmbeddedL( aUri ) ); |
270 // if no rights ask user to re-activate? |
349 // if no rights ask user to re-activate |
271 if( err == KErrCANoRights ) |
350 if( err == KErrCANoRights ) |
272 { |
351 { |
273 HBufC* buf = aUri.AllocLC(); |
352 HBufC* buf = aUri.AllocLC(); |
274 iDrmHelper->ActivateContentL( *buf ); |
353 iDrmHelper->ActivateContentL( *buf ); |
275 CleanupStack::PopAndDestroy( buf ); |
354 CleanupStack::PopAndDestroy( buf ); |
276 } |
355 } |
277 |
356 |
278 } |
357 } |
279 |
358 |
280 //============================================================================ |
359 //============================================================================ |
|
360 // ShowDRMDetailsPane |
|
361 //============================================================================ |
|
362 EXPORT_C void CGlxDRMUtility::ShowDRMDetailsPaneL(RFile& aFileHandle) |
|
363 { |
|
364 TRACER("CGlxDRMUtility::ShowDRMDetailsPaneL()"); |
|
365 TRAPD( err, iDrmHelper->LaunchDetailsViewEmbeddedL( aFileHandle ) ); |
|
366 // if no rights ask user to re-activate |
|
367 if( err == KErrCANoRights ) |
|
368 { |
|
369 //need to check if we need to handle. |
|
370 } |
|
371 |
|
372 } |
|
373 |
|
374 //============================================================================ |
281 // IsForwardLockedL |
375 // IsForwardLockedL |
282 //============================================================================ |
376 //============================================================================ |
283 EXPORT_C TBool CGlxDRMUtility::IsForwardLockedL(const TDesC& aUri) |
377 EXPORT_C TBool CGlxDRMUtility::IsForwardLockedL(const TDesC& aUri) |
284 { |
378 { |
|
379 TRACER("CGlxDRMUtility::IsForwardLockedL()"); |
285 TBool forwardLocked = EFalse; |
380 TBool forwardLocked = EFalse; |
286 TVirtualPathPtr path( aUri, KDefaultContentObject() ); |
381 TVirtualPathPtr path( aUri, KDefaultContentObject() ); |
287 |
382 |
288 // forwardLocked is not updated if an error occurs |
383 // forwardLocked is not updated if an error occurs |
289 iCManager->GetAttribute( ContentAccess::EIsForwardable, forwardLocked, path ); |
384 iCManager->GetAttribute( ContentAccess::EIsForwardable, forwardLocked, path ); |
294 //============================================================================ |
389 //============================================================================ |
295 // ShowRightsInfoL |
390 // ShowRightsInfoL |
296 //============================================================================ |
391 //============================================================================ |
297 EXPORT_C void CGlxDRMUtility::ShowRightsInfoL(const TDesC& aUri) |
392 EXPORT_C void CGlxDRMUtility::ShowRightsInfoL(const TDesC& aUri) |
298 { |
393 { |
|
394 TRACER("CGlxDRMUtility::ShowRightsInfoL()"); |
299 iDrmHelper->CheckRightsAmountL( aUri ); |
395 iDrmHelper->CheckRightsAmountL( aUri ); |
300 } |
396 } |
301 |
397 |
302 //============================================================================ |
398 //============================================================================ |
|
399 // ShowRightsInfoL |
|
400 //============================================================================ |
|
401 EXPORT_C void CGlxDRMUtility::ShowRightsInfoL(RFile& aFileHandle) |
|
402 { |
|
403 TRACER("CGlxDRMUtility::ShowRightsInfoL(aFileHandle)"); |
|
404 iDrmHelper->CheckRightsAmountL( aFileHandle ); |
|
405 } |
|
406 |
|
407 //============================================================================ |
303 // Return size for DRM thumbnail request. |
408 // Return size for DRM thumbnail request. |
304 //============================================================================ |
409 //============================================================================ |
305 EXPORT_C TSize CGlxDRMUtility::DRMThumbnailSize(TSize& aSize) |
410 EXPORT_C TSize CGlxDRMUtility::DRMThumbnailSize(TSize& aSize) |
306 { |
411 { |
|
412 TRACER("CGlxDRMUtility::DRMThumbnailSize()"); |
307 TSize thumbnailSize(KGlxDRMThumbnailWidth, KGlxDRMThumbnailHeight); |
413 TSize thumbnailSize(KGlxDRMThumbnailWidth, KGlxDRMThumbnailHeight); |
308 |
414 |
309 if((aSize.iWidth*aSize.iHeight)/4 < |
415 if((aSize.iWidth*aSize.iHeight)/4 < |
310 KGlxDRMThumbnailWidth * KGlxDRMThumbnailHeight) |
416 KGlxDRMThumbnailWidth * KGlxDRMThumbnailHeight) |
311 { |
417 { |