120 delete iLastConsumedItemUri; |
120 delete iLastConsumedItemUri; |
121 } |
121 } |
122 |
122 |
123 //============================================================================ |
123 //============================================================================ |
124 // CheckOpenRightsL |
124 // CheckOpenRightsL |
125 //============================================================================ |
125 // Fix for ESLM-82WJ59:always call 'CheckOpenRightsL' only for checking DRM |
126 EXPORT_C TBool CGlxDRMUtility::CheckOpenRightsL( const TDesC& aUri, |
126 // rights validity for item. |
|
127 //============================================================================ |
|
128 EXPORT_C TBool CGlxDRMUtility::CheckOpenRightsL( const TDesC& aUri, |
127 TBool aCheckViewRights ) |
129 TBool aCheckViewRights ) |
128 { |
130 { |
129 TRACER("CGlxDRMUtility::CheckOpenRightsL()"); |
131 TRACER("CGlxDRMUtility::CheckOpenRightsL()"); |
130 // When checking current rights for a URI, clear stored URI |
132 // When checking current rights for a URI |
131 TPtr ptr = iLastConsumedItemUri->Des(); |
133 |
132 ptr.Zero(); |
134 // Fix for ESLM-82WJ59: Allow to Open if rights for a URI was just consumed (i.e. same as stored URI) |
133 iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( 0 ); |
135 if ( iLastConsumedItemUri->Length() > 0 ) |
134 |
136 { |
|
137 if ( aUri.CompareF( *iLastConsumedItemUri ) == 0 ) |
|
138 { |
|
139 return ETrue; |
|
140 } |
|
141 } |
|
142 |
|
143 // Fix for ESLM-82WJ59: Else for uri of non-focused uri, just check validity rights |
135 TBool rightsValid = EFalse; |
144 TBool rightsValid = EFalse; |
136 TVirtualPathPtr path( aUri, KDefaultContentObject() ); |
145 TVirtualPathPtr path( aUri, KDefaultContentObject() ); |
137 |
146 |
138 ContentAccess::TAttribute attr = |
147 ContentAccess::TAttribute attr = |
139 aCheckViewRights ? ContentAccess::ECanView : ContentAccess::ECanPlay; |
148 aCheckViewRights ? ContentAccess::ECanView : ContentAccess::ECanPlay; |
144 return rightsValid; |
153 return rightsValid; |
145 } |
154 } |
146 |
155 |
147 //============================================================================ |
156 //============================================================================ |
148 // CheckDisplayRightsL |
157 // CheckDisplayRightsL |
149 //============================================================================ |
158 // Fix for ESLM-82WJ59:always call 'CheckDisplayRightsL' only for focused item. |
150 EXPORT_C TBool CGlxDRMUtility::CheckDisplayRightsL( const TDesC& aUri, |
159 //============================================================================ |
|
160 EXPORT_C TBool CGlxDRMUtility::CheckDisplayRightsL( const TDesC& aUri, |
151 TBool aCheckViewRights ) |
161 TBool aCheckViewRights ) |
152 { |
162 { |
153 TRACER("CGlxDRMUtility::CheckDisplayRightsL()"); |
163 TRACER("CGlxDRMUtility::CheckDisplayRightsL()"); |
|
164 |
154 // 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) |
155 if ( iLastConsumedItemUri->Length() > 0 ) |
166 if ( iLastConsumedItemUri->Length() > 0 ) |
156 { |
167 { |
157 if ( aUri.CompareF( *iLastConsumedItemUri ) == 0 ) |
168 if ( aUri.CompareF( *iLastConsumedItemUri ) == 0 ) |
158 { |
169 { |
159 return ETrue; |
170 return ETrue; |
160 } |
171 } |
161 } |
172 } |
162 |
173 |
163 // Otherwise, check current rights for the URI |
174 //Fix for ESLM-82WJ59: Clear the stored uri since focus has changed |
|
175 ClearLastConsumedItemUri(); |
|
176 |
|
177 // Otherwise, check current rights for the URI of newly focused item |
164 return CheckOpenRightsL( aUri, aCheckViewRights ); |
178 return CheckOpenRightsL( aUri, aCheckViewRights ); |
165 } |
179 } |
166 |
180 |
167 //============================================================================ |
181 //============================================================================ |
168 // ConsumeRightsL |
182 // ConsumeRightsL |
174 |
188 |
175 // Create a CData object to read the content |
189 // Create a CData object to read the content |
176 // Tell the agent we are planning to display the content |
190 // Tell the agent we are planning to display the content |
177 CData* data = CData::NewLC(path, ContentAccess::EView, EContentShareReadOnly); |
191 CData* data = CData::NewLC(path, ContentAccess::EView, EContentShareReadOnly); |
178 |
192 |
179 // When consuming rights for a URI, clear stored URI |
193 //Fix for ESLM-82WJ59: When consuming rights for a URI, clear stored URI |
180 TPtr oldPtr = iLastConsumedItemUri->Des(); |
194 ClearLastConsumedItemUri(); |
181 oldPtr.Zero(); |
|
182 iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( aUri.Length() ); |
|
183 |
195 |
184 // 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 |
185 // 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 |
186 TInt err = data->ExecuteIntent(ContentAccess::EView); |
198 TInt err = data->ExecuteIntent(ContentAccess::EView); |
187 if ( err == KErrNone ) |
199 if ( err == KErrNone ) |
188 { |
200 { |
189 // Update stored URI |
201 //Fix for ESLM-82WJ59: Update stored URI |
|
202 iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( aUri.Length() ); |
190 TPtr newPtr = iLastConsumedItemUri->Des(); |
203 TPtr newPtr = iLastConsumedItemUri->Des(); |
191 newPtr.Copy( aUri ); |
204 newPtr.Copy( aUri ); |
192 } |
205 } |
193 |
206 |
194 CleanupStack::PopAndDestroy(data); |
207 CleanupStack::PopAndDestroy(data); |
195 |
208 |
196 return (err == KErrNone); |
209 return (err == KErrNone); |
197 } |
210 } |
|
211 |
|
212 //============================================================================ |
|
213 //Fix for ESLM-82WJ59: |
|
214 //Clears Last Consumed Uri |
|
215 //============================================================================ |
|
216 EXPORT_C void CGlxDRMUtility::ClearLastConsumedItemUri() |
|
217 { |
|
218 //clears the stored uri |
|
219 TPtr aPtr = iLastConsumedItemUri->Des(); |
|
220 aPtr.Zero(); |
|
221 iLastConsumedItemUri = iLastConsumedItemUri->ReAllocL( 0 ); |
|
222 } |
198 |
223 |
199 //============================================================================ |
224 //============================================================================ |
200 // Test whether a media item is OMA DRM 2.0 protected and has an associated |
225 // Test whether a media item is OMA DRM 2.0 protected and has an associated |
201 // info URL. |
226 // info URL. |
202 //============================================================================ |
227 //============================================================================ |