119 delete iDrmHelper; |
119 delete iDrmHelper; |
120 delete iLastConsumedItemUri; |
120 delete iLastConsumedItemUri; |
121 } |
121 } |
122 |
122 |
123 //============================================================================ |
123 //============================================================================ |
124 // CheckOpenRightsL |
124 // ItemRightsValidityCheckL |
125 // Fix for ESLM-82WJ59:always call 'CheckOpenRightsL' only for checking DRM |
125 // for checking DRM rights validity for item. |
126 // rights validity for item. |
126 // is called before right is consumed and for all items (focused or unfocused). |
127 //============================================================================ |
127 //============================================================================ |
128 EXPORT_C TBool CGlxDRMUtility::CheckOpenRightsL( const TDesC& aUri, |
128 EXPORT_C TBool CGlxDRMUtility::ItemRightsValidityCheckL( const TDesC& aUri, |
129 TBool aCheckViewRights ) |
129 TBool aCheckViewRights ) |
130 { |
130 { |
131 TRACER("CGlxDRMUtility::CheckOpenRightsL()"); |
131 TRACER("CGlxDRMUtility::ItemRightsValidityCheckL()"); |
132 // When checking current rights for a URI |
132 // When checking current rights for a URI |
133 |
133 |
134 // Fix for ESLM-82WJ59: Allow to Open if rights for a URI was just consumed (i.e. same as stored URI) |
134 //Allow to Open if rights for a URI was just consumed (i.e. same as stored URI) |
135 if ( iLastConsumedItemUri->Length() > 0 ) |
135 if ( iLastConsumedItemUri->Length() > 0 ) |
136 { |
136 { |
137 if ( aUri.CompareF( *iLastConsumedItemUri ) == 0 ) |
137 if ( aUri.CompareF( *iLastConsumedItemUri ) == 0 ) |
138 { |
138 { |
139 return ETrue; |
139 return ETrue; |
140 } |
140 } |
141 } |
141 } |
142 |
142 |
143 // Fix for ESLM-82WJ59: Else for uri of non-focused uri, just check validity rights |
143 //Else for uri of non-focused uri, just check validity rights |
144 TBool rightsValid = EFalse; |
144 TBool rightsValid = EFalse; |
145 TVirtualPathPtr path( aUri, KDefaultContentObject() ); |
145 TVirtualPathPtr path( aUri, KDefaultContentObject() ); |
146 |
146 |
147 ContentAccess::TAttribute attr = |
147 ContentAccess::TAttribute attr = |
148 aCheckViewRights ? ContentAccess::ECanView : ContentAccess::ECanPlay; |
148 aCheckViewRights ? ContentAccess::ECanView : ContentAccess::ECanPlay; |
152 |
152 |
153 return rightsValid; |
153 return rightsValid; |
154 } |
154 } |
155 |
155 |
156 //============================================================================ |
156 //============================================================================ |
157 // CheckDisplayRightsL |
157 // DisplayItemRightsCheckL |
158 // Fix for ESLM-82WJ59:always call 'CheckDisplayRightsL' only for focused item. |
158 // is called after right is consumed and for only focused/displayed item. |
159 //============================================================================ |
159 //============================================================================ |
160 EXPORT_C TBool CGlxDRMUtility::CheckDisplayRightsL( const TDesC& aUri, |
160 EXPORT_C TBool CGlxDRMUtility::DisplayItemRightsCheckL( const TDesC& aUri, |
161 TBool aCheckViewRights ) |
161 TBool aCheckViewRights ) |
162 { |
162 { |
163 TRACER("CGlxDRMUtility::CheckDisplayRightsL()"); |
163 TRACER("CGlxDRMUtility::DisplayItemRightsCheckL()"); |
164 |
164 |
165 // Allow to display if rights for a URI was just consumed (i.e. same as stored URI) |
165 // Allow to display if rights for a URI was just consumed (i.e. same as stored URI) |
166 if ( iLastConsumedItemUri->Length() > 0 ) |
166 if ( iLastConsumedItemUri->Length() > 0 ) |
167 { |
167 { |
168 if ( aUri.CompareF( *iLastConsumedItemUri ) == 0 ) |
168 if ( aUri.CompareF( *iLastConsumedItemUri ) == 0 ) |
169 { |
169 { |
170 return ETrue; |
170 return ETrue; |
171 } |
171 } |
172 } |
172 } |
173 |
173 |
174 //Fix for ESLM-82WJ59: Clear the stored uri since focus has changed |
174 //Clear the stored uri since focus has changed |
175 ClearLastConsumedItemUri(); |
175 ClearLastConsumedItemUriL(); |
176 |
176 |
177 // Otherwise, check current rights for the URI of newly focused item |
177 // Otherwise, check current rights for the URI of newly focused item |
178 return CheckOpenRightsL( aUri, aCheckViewRights ); |
178 return ItemRightsValidityCheckL( aUri, aCheckViewRights ); |
179 } |
179 } |
180 |
180 |
181 //============================================================================ |
181 //============================================================================ |
182 // ConsumeRightsL |
182 // ConsumeRightsL |
183 //============================================================================ |
183 //============================================================================ |
188 |
188 |
189 // Create a CData object to read the content |
189 // Create a CData object to read the content |
190 // Tell the agent we are planning to display the content |
190 // Tell the agent we are planning to display the content |
191 CData* data = CData::NewLC(path, ContentAccess::EView, EContentShareReadOnly); |
191 CData* data = CData::NewLC(path, ContentAccess::EView, EContentShareReadOnly); |
192 |
192 |
193 //Fix for ESLM-82WJ59: When consuming rights for a URI, clear stored URI |
193 //When consuming rights for a URI, clear stored URI |
194 ClearLastConsumedItemUri(); |
194 ClearLastConsumedItemUriL(); |
195 |
195 |
196 // Execute the intent, tell the agent that we plan to display the content |
196 // Execute the intent, tell the agent that we plan to display the content |
197 // It is at this point that any stateful rights will be decremented |
197 // It is at this point that any stateful rights will be decremented |
198 TInt err = data->ExecuteIntent(ContentAccess::EView); |
198 TInt err = data->ExecuteIntent(ContentAccess::EView); |
199 if ( err == KErrNone ) |
199 if ( err == KErrNone ) |
200 { |
200 { |
201 //Fix for ESLM-82WJ59: Update stored URI |
201 //Update stored URI |
202 iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( aUri.Length() ); |
202 iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( aUri.Length() ); |
203 TPtr newPtr = iLastConsumedItemUri->Des(); |
203 TPtr newPtr = iLastConsumedItemUri->Des(); |
204 newPtr.Copy( aUri ); |
204 newPtr.Copy( aUri ); |
205 } |
205 } |
206 |
206 |
208 |
208 |
209 return (err == KErrNone); |
209 return (err == KErrNone); |
210 } |
210 } |
211 |
211 |
212 //============================================================================ |
212 //============================================================================ |
213 //Fix for ESLM-82WJ59: |
|
214 //Clears Last Consumed Uri |
213 //Clears Last Consumed Uri |
215 //============================================================================ |
214 //============================================================================ |
216 EXPORT_C void CGlxDRMUtility::ClearLastConsumedItemUri() |
215 EXPORT_C void CGlxDRMUtility::ClearLastConsumedItemUriL() |
217 { |
216 { |
218 //clears the stored uri |
217 //clears the stored uri |
219 TPtr aPtr = iLastConsumedItemUri->Des(); |
218 TPtr ptr = iLastConsumedItemUri->Des(); |
220 aPtr.Zero(); |
219 ptr.Zero(); |
221 iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( 0 ); |
220 iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( 0 ); |
222 } |
221 } |
223 |
222 |
224 //============================================================================ |
223 //============================================================================ |
225 // Test whether a media item is OMA DRM 2.0 protected and has an associated |
224 // Test whether a media item is OMA DRM 2.0 protected and has an associated |
226 // info URL. |
225 // info URL. |
227 //============================================================================ |
226 //============================================================================ |
228 EXPORT_C TBool CGlxDRMUtility::CanShowInfoOnlineL(TDesC& aUri) |
227 EXPORT_C TBool CGlxDRMUtility::CanShowInfoOnlineL(const TDesC& aUri) |
229 { |
228 { |
230 TRACER("CGlxDRMUtility::CanShowInfoOnlineL()"); |
229 TRACER("CGlxDRMUtility::CanShowInfoOnlineL()"); |
231 TBool canShowInfoOnline = EFalse; |
230 TBool canShowInfoOnline = EFalse; |
232 |
231 |
233 HBufC8* urlBuf = NULL; |
232 HBufC8* urlBuf = NULL; |
234 canShowInfoOnline = iDrmHelper->HasInfoUrlL(aUri, urlBuf); |
233 canShowInfoOnline = iDrmHelper->HasInfoUrlL( const_cast<TDesC&>(aUri) , urlBuf); |
235 |
234 |
236 // discard buf we don't need it |
235 // discard buf we don't need it |
237 delete urlBuf; |
236 delete urlBuf; |
238 |
237 |
239 return canShowInfoOnline; |
238 return canShowInfoOnline; |
240 } |
239 } |
241 |
240 |
242 //============================================================================ |
241 //============================================================================ |
243 // Open the associated info URL for a media item in the browser. |
242 // Open the associated info URL for a media item in the browser. |
244 //============================================================================ |
243 //============================================================================ |
245 EXPORT_C void CGlxDRMUtility::ShowInfoOnlineL(TDesC& aUri) |
244 EXPORT_C void CGlxDRMUtility::ShowInfoOnlineL(const TDesC& aUri) |
246 { |
245 { |
247 TRACER("CGlxDRMUtility::ShowInfoOnlineL()"); |
246 TRACER("CGlxDRMUtility::ShowInfoOnlineL()"); |
248 iDrmHelper->OpenInfoUrlL(aUri); |
247 iDrmHelper->OpenInfoUrlL( const_cast<TDesC&>(aUri) ); |
249 } |
248 } |
250 |
249 |
251 //============================================================================ |
250 //============================================================================ |
252 // Test whether a media item can be set as automated content. |
251 // Test whether a media item can be set as automated content. |
253 //============================================================================ |
252 //============================================================================ |
303 //============================================================================ |
302 //============================================================================ |
304 EXPORT_C void CGlxDRMUtility::ShowDRMDetailsPaneL( const TDesC& aUri ) |
303 EXPORT_C void CGlxDRMUtility::ShowDRMDetailsPaneL( const TDesC& aUri ) |
305 { |
304 { |
306 TRACER("CGlxDRMUtility::ShowDRMDetailsPaneL()"); |
305 TRACER("CGlxDRMUtility::ShowDRMDetailsPaneL()"); |
307 TRAPD( err, iDrmHelper->LaunchDetailsViewEmbeddedL( aUri ) ); |
306 TRAPD( err, iDrmHelper->LaunchDetailsViewEmbeddedL( aUri ) ); |
308 // if no rights ask user to re-activate? |
307 // if no rights ask user to re-activate |
309 if( err == KErrCANoRights ) |
308 if( err == KErrCANoRights ) |
310 { |
309 { |
311 HBufC* buf = aUri.AllocLC(); |
310 HBufC* buf = aUri.AllocLC(); |
312 iDrmHelper->ActivateContentL( *buf ); |
311 iDrmHelper->ActivateContentL( *buf ); |
313 CleanupStack::PopAndDestroy( buf ); |
312 CleanupStack::PopAndDestroy( buf ); |