|
1 /* |
|
2 * Copyright (c) 2008 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: HTTP plugin framework implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <utf.h> |
|
20 #include <wmdrmdlatypes.h> |
|
21 #include <wmdrmdlahttpplugin.h> |
|
22 #include <wmdrmdlauinotifier.h> |
|
23 #include <wmdrmdlautils.rsg> |
|
24 #include "wmdrmdlahttplicacqpluginfw.h" |
|
25 #include "wmdrmdlahttpfwpluginresolver.h" |
|
26 #include "wmdrmdlaparser.h" |
|
27 #include "wmdrmdlaui.h" |
|
28 |
|
29 #define _LOGGING_FILE L"wmdrmdla.txt" |
|
30 #include "logfn.h" |
|
31 |
|
32 // ======== MEMBER FUNCTIONS ======== |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // CWmDrmDlaHttpLicAcqPluginFw::ConstructL |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 void CWmDrmDlaHttpLicAcqPluginFw::ConstructL() |
|
39 { |
|
40 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::ConstructL" ); |
|
41 iDlaParser = CWmDrmDlaParser::NewL(); |
|
42 iWait = new (ELeave) CActiveSchedulerWait; |
|
43 iIdle = CIdle::NewL( CActive::EPriorityIdle ); |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CWmDrmDlaHttpLicAcqPluginFw::CWmDrmDlaHttpLicAcqPluginFw |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CWmDrmDlaHttpLicAcqPluginFw::CWmDrmDlaHttpLicAcqPluginFw() |
|
51 : CActive( EPriorityStandard ), |
|
52 iState( CWmDrmDlaHttpLicAcqPluginFw::EIdle ) |
|
53 { |
|
54 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::CWmDrmDlaHttpLicAcqPluginFw" ); |
|
55 CActiveScheduler::Add( this ); |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CWmDrmDlaHttpLicAcqPluginFw::NewL |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CWmDrmDlaHttpLicAcqPluginFw* CWmDrmDlaHttpLicAcqPluginFw::NewL() |
|
63 { |
|
64 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::NewL" ); |
|
65 CWmDrmDlaHttpLicAcqPluginFw* self |
|
66 = CWmDrmDlaHttpLicAcqPluginFw::NewLC(); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CWmDrmDlaHttpLicAcqPluginFw::NewLC |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CWmDrmDlaHttpLicAcqPluginFw* CWmDrmDlaHttpLicAcqPluginFw::NewLC() |
|
77 { |
|
78 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::NewLC" ); |
|
79 CWmDrmDlaHttpLicAcqPluginFw* self |
|
80 = new( ELeave ) CWmDrmDlaHttpLicAcqPluginFw; |
|
81 CleanupStack::PushL( self ); |
|
82 self->ConstructL(); |
|
83 return self; |
|
84 } |
|
85 |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CWmDrmDlaHttpLicAcqPluginFw::~CWmDrmDlaHttpLicAcqPluginFw |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 CWmDrmDlaHttpLicAcqPluginFw::~CWmDrmDlaHttpLicAcqPluginFw() |
|
92 { |
|
93 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::~CWmDrmDlaHttpLicAcqPluginFw" ); |
|
94 CancelLicenseAcquisition(); |
|
95 delete iDlaParser; |
|
96 delete iHttpPlugin; |
|
97 delete iUiNotifier; |
|
98 delete iWait; |
|
99 delete iIdle; |
|
100 delete iDrmHeader; |
|
101 delete iLicenseServerUrl; |
|
102 delete iLicenseChallenge; |
|
103 delete iLicenseResponse; |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CWmDrmDlaHttpLicAcqPluginFw::SilentL |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 TBool CWmDrmDlaHttpLicAcqPluginFw::SilentL( |
|
111 const RFile& aFile ) |
|
112 { |
|
113 TInt err( KErrNone ); |
|
114 TBool silent( EFalse ); |
|
115 |
|
116 LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::SilentL", err ); |
|
117 if ( iState != CWmDrmDlaHttpLicAcqPluginFw::EIdle ) |
|
118 { |
|
119 User::Leave( KErrInUse ); |
|
120 } |
|
121 //Finds out, if current content should be handled silently, also |
|
122 //resolves and initializes plugin that handles this content |
|
123 TRAP( err, silent = SilentHandlerL( aFile ) ); |
|
124 if ( err ) |
|
125 { |
|
126 HandleErrorL( err ); |
|
127 } |
|
128 iSilentInitialised = ETrue; |
|
129 return silent; |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CWmDrmDlaHttpLicAcqPluginFw::AcquireLicense |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void CWmDrmDlaHttpLicAcqPluginFw::AcquireLicense( |
|
137 const RFile& aFile, |
|
138 HBufC*& aContentUrl, |
|
139 HBufC*& aHtmlData, |
|
140 TRequestStatus& aStatus ) |
|
141 { |
|
142 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::AcquireLicense" ); |
|
143 |
|
144 TRequestStatus *status = &aStatus; |
|
145 aStatus = KRequestPending; |
|
146 if ( iState != CWmDrmDlaHttpLicAcqPluginFw::EIdle ) |
|
147 { |
|
148 User::RequestComplete( status, KErrInUse ); |
|
149 return; |
|
150 } |
|
151 |
|
152 iClientStatus = &aStatus; |
|
153 iFile = &aFile; |
|
154 iContentUrl = &aContentUrl; |
|
155 iHtmlData = &aHtmlData; |
|
156 //If FW is already initialized, then go straight to license acquisition. |
|
157 //Otherwise try to resolve plugin that handles this content. |
|
158 if ( iSilentInitialised ) |
|
159 { |
|
160 iState = |
|
161 CWmDrmDlaHttpLicAcqPluginFw::ERetrievingDRMHeaderFromFileHandle; |
|
162 } |
|
163 else |
|
164 { |
|
165 iState = |
|
166 CWmDrmDlaHttpLicAcqPluginFw::EResolvingHttpPluginFromFileHandle; |
|
167 } |
|
168 CompleteSelf(); |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------------------------- |
|
172 // CWmDrmDlaHttpLicAcqPluginFw::AcquireLicenseFromDrmHeader |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 void CWmDrmDlaHttpLicAcqPluginFw::AcquireLicenseFromDrmHeader( |
|
176 const TDesC8& aDrmHeader, |
|
177 HBufC* aErrorUrl, |
|
178 HBufC*& aContentUrl, |
|
179 HBufC*& aHtmlData, |
|
180 TRequestStatus& aStatus ) |
|
181 { |
|
182 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::AcquireLicenseFromDrmHeader" ); |
|
183 |
|
184 TRequestStatus *status = &aStatus; |
|
185 aStatus = KRequestPending; |
|
186 if ( iState != CWmDrmDlaHttpLicAcqPluginFw::EIdle ) |
|
187 { |
|
188 User::RequestComplete( status, KErrInUse ); |
|
189 return; |
|
190 } |
|
191 |
|
192 iClientStatus = &aStatus; |
|
193 delete iDrmHeader; |
|
194 iDrmHeader = NULL; |
|
195 iDrmHeader = aDrmHeader.Alloc(); |
|
196 if ( !iDrmHeader ) |
|
197 { |
|
198 CompleteClientRequest( KErrNoMemory ); |
|
199 } |
|
200 else |
|
201 { |
|
202 iErrorUrl = aErrorUrl; |
|
203 iContentUrl = &aContentUrl; |
|
204 iHtmlData = &aHtmlData; |
|
205 iState = |
|
206 CWmDrmDlaHttpLicAcqPluginFw::EResolvingHttpPluginFromDRMHeader; |
|
207 CompleteSelf(); |
|
208 } |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // CWmDrmDlaHttpLicAcqPluginFw::SetIapId |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 void CWmDrmDlaHttpLicAcqPluginFw::SetIapId( TInt aIapId ) |
|
216 { |
|
217 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::SetIapId" ); |
|
218 LOG2( "aIapId: %d", aIapId ); |
|
219 iIapId = aIapId; |
|
220 if ( iHttpPlugin ) |
|
221 { |
|
222 iHttpPlugin->SetIapId( iIapId ); |
|
223 } |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // CWmDrmDlaHttpLicAcqPluginFw::CancelLicenseAcquisition |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 void CWmDrmDlaHttpLicAcqPluginFw::CancelLicenseAcquisition() |
|
231 { |
|
232 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::CancelLicenseAcquisition" ); |
|
233 LOG2( "iState: %d", iState ); |
|
234 //If we are currently sending header error or license storage status |
|
235 //to server, then let it finish before cancelling |
|
236 if ( iState == CWmDrmDlaHttpLicAcqPluginFw::ESentDRMHeaderError || |
|
237 iState == CWmDrmDlaHttpLicAcqPluginFw::ESentLicenseStorageStatus ) |
|
238 { |
|
239 iWait->Start(); |
|
240 } |
|
241 if ( iHttpPlugin ) |
|
242 { |
|
243 iHttpPlugin->CancelLicenseAcquisition(); |
|
244 } |
|
245 Cancel(); |
|
246 if ( iUiNotifier ) |
|
247 { |
|
248 TRAP_IGNORE( iUiNotifier->HandleErrorL( KErrCancel ) ); |
|
249 } |
|
250 CompleteClientRequest( KErrCancel ); |
|
251 Reset(); |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // CWmDrmDlaHttpLicAcqPluginFw::DoCancel |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 void CWmDrmDlaHttpLicAcqPluginFw::DoCancel() |
|
259 { |
|
260 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::DoCancel" ); |
|
261 } |
|
262 |
|
263 // --------------------------------------------------------------------------- |
|
264 // CWmDrmDlaHttpLicAcqPluginFw::RunL |
|
265 // --------------------------------------------------------------------------- |
|
266 // |
|
267 void CWmDrmDlaHttpLicAcqPluginFw::RunL() |
|
268 { |
|
269 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::RunL" ); |
|
270 LOG2( "iState: %d", iState ); |
|
271 LOG2( "iStatus.Int(): %d", iStatus.Int() ); |
|
272 if ( iStatus.Int() != KErrNone ) |
|
273 { |
|
274 HandleErrorL( iStatus.Int() ); |
|
275 } |
|
276 |
|
277 switch ( iState ) |
|
278 { |
|
279 case CWmDrmDlaHttpLicAcqPluginFw::EResolvingHttpPluginFromDRMHeader: |
|
280 ResolvingHttpPluginFromDRMHeaderHandlerL(); |
|
281 break; |
|
282 |
|
283 case CWmDrmDlaHttpLicAcqPluginFw::EResolvingHttpPluginFromFileHandle: |
|
284 ResolvingHttpPluginFromFileHandleHandlerL(); |
|
285 break; |
|
286 |
|
287 case CWmDrmDlaHttpLicAcqPluginFw::ERetrievingDRMHeaderFromFileHandle: |
|
288 RetrievingDRMHeaderFromFileHandleHandler(); |
|
289 break; |
|
290 |
|
291 case CWmDrmDlaHttpLicAcqPluginFw::EProcessingDRMHeader: |
|
292 ProcessingDRMHeaderHandler(); |
|
293 break; |
|
294 |
|
295 case CWmDrmDlaHttpLicAcqPluginFw::ESentDRMHeaderError: |
|
296 SentDRMHeaderErrorHandlerL(); |
|
297 break; |
|
298 |
|
299 case CWmDrmDlaHttpLicAcqPluginFw::ERetrievingChallenge: |
|
300 RetrievingChallengeHandler(); |
|
301 break; |
|
302 |
|
303 case CWmDrmDlaHttpLicAcqPluginFw::ERetrievingLicense: |
|
304 RetrievingLicenseHandler(); |
|
305 break; |
|
306 |
|
307 case CWmDrmDlaHttpLicAcqPluginFw::EAddingLicense: |
|
308 AddingLicenseHandlerL(); |
|
309 break; |
|
310 |
|
311 case CWmDrmDlaHttpLicAcqPluginFw::ESendingLicenseStorageStatus: |
|
312 SendingLicenseStorageStatusHandler(); |
|
313 break; |
|
314 |
|
315 case CWmDrmDlaHttpLicAcqPluginFw::ESentLicenseStorageStatus: |
|
316 SentLicenseStorageStatusHandler(); |
|
317 break; |
|
318 |
|
319 case CWmDrmDlaHttpLicAcqPluginFw::ELicensingComplete: |
|
320 LicensingCompleteL(); |
|
321 break; |
|
322 |
|
323 default: |
|
324 ASSERT( EFalse ); |
|
325 break; |
|
326 } |
|
327 } |
|
328 |
|
329 // --------------------------------------------------------------------------- |
|
330 // CWmDrmDlaHttpLicAcqPluginFw::RunError |
|
331 // --------------------------------------------------------------------------- |
|
332 // |
|
333 TInt CWmDrmDlaHttpLicAcqPluginFw::RunError( TInt aError ) |
|
334 { |
|
335 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::RunError" ); |
|
336 LOG2( "aError: %d", aError ); |
|
337 CompleteClientRequest( aError ); |
|
338 Reset(); |
|
339 return KErrNone; |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // CWmDrmDlaHttpLicAcqPluginFw::UserCancellation |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 void CWmDrmDlaHttpLicAcqPluginFw::UserCancellation() |
|
347 { |
|
348 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::UserCancellation" ); |
|
349 //User has cancelled the license acquisition from the UI. |
|
350 //Cancel the license acquisition asynchronously. |
|
351 TCallBack callBack( CWmDrmDlaHttpLicAcqPluginFw::AsyncCancel, |
|
352 this ); |
|
353 iIdle->Start( callBack ); |
|
354 } |
|
355 |
|
356 // ---------------------------------------------------------------------------- |
|
357 // CWmDrmDlaHttpLicAcqPluginFw::CompleteSelf |
|
358 // ---------------------------------------------------------------------------- |
|
359 // |
|
360 void CWmDrmDlaHttpLicAcqPluginFw::CompleteSelf() |
|
361 { |
|
362 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::CompleteSelf" ); |
|
363 if ( !IsActive() ) |
|
364 { |
|
365 TRequestStatus* status = &iStatus; |
|
366 User::RequestComplete( status, KErrNone ); |
|
367 SetActive(); |
|
368 } |
|
369 } |
|
370 |
|
371 // ---------------------------------------------------------------------------- |
|
372 // CWmDrmDlaHandlerImpl::CompleteClientRequest |
|
373 // ---------------------------------------------------------------------------- |
|
374 // |
|
375 void CWmDrmDlaHttpLicAcqPluginFw::CompleteClientRequest( TInt aError ) |
|
376 { |
|
377 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::CompleteClientRequest" ); |
|
378 LOG2( "aError: %d", aError ); |
|
379 if ( iClientStatus ) |
|
380 { |
|
381 User::RequestComplete( iClientStatus, aError ); |
|
382 iClientStatus = NULL; |
|
383 } |
|
384 } |
|
385 |
|
386 // ---------------------------------------------------------------------------- |
|
387 // CWmDrmDlaHttpLicAcqPluginFw::::Reset |
|
388 // ---------------------------------------------------------------------------- |
|
389 // |
|
390 void CWmDrmDlaHttpLicAcqPluginFw::Reset() |
|
391 { |
|
392 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::Reset" ); |
|
393 iSilentInitialised = EFalse; |
|
394 delete iHttpPlugin; |
|
395 iHttpPlugin = NULL; |
|
396 delete iUiNotifier; |
|
397 iUiNotifier = NULL; |
|
398 delete iDrmHeader; |
|
399 iDrmHeader = NULL; |
|
400 delete iLicenseServerUrl; |
|
401 iLicenseServerUrl = NULL; |
|
402 delete iLicenseChallenge; |
|
403 iLicenseChallenge = NULL; |
|
404 delete iLicenseResponse; |
|
405 iLicenseResponse = NULL; |
|
406 iFile = NULL; |
|
407 iContentUrl = NULL; |
|
408 iHtmlData = NULL; |
|
409 iClientStatus = NULL; |
|
410 iState = CWmDrmDlaHttpLicAcqPluginFw::EIdle; |
|
411 } |
|
412 |
|
413 // ---------------------------------------------------------------------------- |
|
414 // CWmDrmDlaHttpLicAcqPluginFw::SilentHandlerL |
|
415 // ---------------------------------------------------------------------------- |
|
416 // |
|
417 TBool CWmDrmDlaHttpLicAcqPluginFw::SilentHandlerL( |
|
418 const RFile& aFile ) |
|
419 { |
|
420 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::SilentHandlerL" ); |
|
421 iSilentInitialised = EFalse; |
|
422 ResolveHttpPluginL( aFile ); |
|
423 return iHttpPlugin->SilentL( aFile ); |
|
424 } |
|
425 |
|
426 // ---------------------------------------------------------------------------- |
|
427 // CWmDrmDlaHttpLicAcqPluginFw::ResolvingHttpPluginFromDRMHeaderHandlerL |
|
428 // ---------------------------------------------------------------------------- |
|
429 // |
|
430 void CWmDrmDlaHttpLicAcqPluginFw::ResolvingHttpPluginFromDRMHeaderHandlerL() |
|
431 { |
|
432 TInt err( KErrNone ); |
|
433 |
|
434 LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::ResolvingHttpPluginFromDRMHeaderHandlerL", err ); |
|
435 |
|
436 iSilentInitialised = EFalse; |
|
437 TRAP( err, ResolveHttpPluginL( *iDrmHeader ) ); |
|
438 if ( err ) |
|
439 { |
|
440 HandleErrorL( err ); |
|
441 } |
|
442 iState = CWmDrmDlaHttpLicAcqPluginFw::EProcessingDRMHeader; |
|
443 CompleteSelf(); |
|
444 } |
|
445 |
|
446 // ---------------------------------------------------------------------------- |
|
447 // CWmDrmDlaHttpLicAcqPluginFw::ResolvingHttpPluginFromFileHandleHandlerL |
|
448 // ---------------------------------------------------------------------------- |
|
449 // |
|
450 void CWmDrmDlaHttpLicAcqPluginFw::ResolvingHttpPluginFromFileHandleHandlerL() |
|
451 { |
|
452 TInt err( KErrNone ); |
|
453 |
|
454 LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::ResolvingHttpPluginFromFileHandleHandlerL", err ); |
|
455 |
|
456 TRAP( err, SilentHandlerL( *iFile ) ); |
|
457 if ( err ) |
|
458 { |
|
459 HandleErrorL( err ); |
|
460 } |
|
461 iState = CWmDrmDlaHttpLicAcqPluginFw::ERetrievingDRMHeaderFromFileHandle; |
|
462 CompleteSelf(); |
|
463 } |
|
464 |
|
465 // ---------------------------------------------------------------------------- |
|
466 // CWmDrmDlaHttpLicAcqPluginFw::RetrievingDRMHeaderFromFileHandleHandler |
|
467 // ---------------------------------------------------------------------------- |
|
468 // |
|
469 void CWmDrmDlaHttpLicAcqPluginFw::RetrievingDRMHeaderFromFileHandleHandler() |
|
470 { |
|
471 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::RetrievingDRMHeaderFromFileHandleHandler" ); |
|
472 delete iDrmHeader; |
|
473 iDrmHeader = NULL; |
|
474 SetActive(); |
|
475 iState = CWmDrmDlaHttpLicAcqPluginFw::EProcessingDRMHeader; |
|
476 TRequestStatus* status = &iStatus; |
|
477 User::RequestComplete( status, KErrNotSupported ); |
|
478 } |
|
479 |
|
480 // ---------------------------------------------------------------------------- |
|
481 // CWmDrmDlaHttpLicAcqPluginFw::ProcessingDRMHeaderHandler |
|
482 // ---------------------------------------------------------------------------- |
|
483 // |
|
484 void CWmDrmDlaHttpLicAcqPluginFw::ProcessingDRMHeaderHandler() |
|
485 { |
|
486 TInt err( KErrNone ); |
|
487 |
|
488 LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::ProcessingDRMHeaderHandler", err ); |
|
489 |
|
490 TRAP( err, iHttpPlugin->ProcessDrmHeaderL( *iDrmHeader ) ); |
|
491 if ( err ) |
|
492 { |
|
493 SendingDRMHeaderErrorHandler( err ); |
|
494 } |
|
495 delete iLicenseServerUrl; |
|
496 iLicenseServerUrl = NULL; |
|
497 TRAP( err, ParseDrmHeaderL( *iDrmHeader, iLicenseServerUrl ) ); |
|
498 if ( err ) |
|
499 { |
|
500 SendingDRMHeaderErrorHandler( err ); |
|
501 } |
|
502 iState = CWmDrmDlaHttpLicAcqPluginFw::ERetrievingChallenge; |
|
503 CompleteSelf(); |
|
504 } |
|
505 |
|
506 // ---------------------------------------------------------------------------- |
|
507 // CWmDrmDlaHttpLicAcqPluginFw::SendingDRMHeaderErrorHandler |
|
508 // ---------------------------------------------------------------------------- |
|
509 // |
|
510 void CWmDrmDlaHttpLicAcqPluginFw::SendingDRMHeaderErrorHandler( |
|
511 TInt aError ) |
|
512 { |
|
513 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::SendingDRMHeaderErrorHandler" ); |
|
514 LOG2( "aError: %d", aError ); |
|
515 iHttpPlugin->SendDrmHeaderError( *iErrorUrl, aError, iStatus ); |
|
516 SetActive(); |
|
517 iState = CWmDrmDlaHttpLicAcqPluginFw::ESentDRMHeaderError; |
|
518 } |
|
519 |
|
520 // ---------------------------------------------------------------------------- |
|
521 // CWmDrmDlaHttpLicAcqPluginFw::SentDRMHeaderErrorHandlerL |
|
522 // ---------------------------------------------------------------------------- |
|
523 // |
|
524 void CWmDrmDlaHttpLicAcqPluginFw::SentDRMHeaderErrorHandlerL() |
|
525 { |
|
526 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::SentDRMHeaderErrorHandlerL" ); |
|
527 //If license acquisition is cancelled during the send operation, |
|
528 //then don't continue license acquisition process |
|
529 if ( iWait->IsStarted() ) |
|
530 { |
|
531 iWait->AsyncStop(); |
|
532 } |
|
533 else |
|
534 { |
|
535 HandleErrorL( KErrCorrupt ); |
|
536 } |
|
537 } |
|
538 |
|
539 // ---------------------------------------------------------------------------- |
|
540 // CWmDrmDlaHttpLicAcqPluginFw::RetrievingChallengeHandler |
|
541 // ---------------------------------------------------------------------------- |
|
542 // |
|
543 void CWmDrmDlaHttpLicAcqPluginFw::RetrievingChallengeHandler() |
|
544 { |
|
545 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::RetrievingChallengeHandler" ); |
|
546 delete iLicenseChallenge; |
|
547 iLicenseChallenge = NULL; |
|
548 SetActive(); |
|
549 iState = CWmDrmDlaHttpLicAcqPluginFw::ERetrievingLicense; |
|
550 TRequestStatus* status = &iStatus; |
|
551 User::RequestComplete( status, KErrNotSupported ); |
|
552 } |
|
553 |
|
554 // ---------------------------------------------------------------------------- |
|
555 // CWmDrmDlaHttpLicAcqPluginFw::RetrievingLicenseHandler |
|
556 // ---------------------------------------------------------------------------- |
|
557 // |
|
558 void CWmDrmDlaHttpLicAcqPluginFw::RetrievingLicenseHandler() |
|
559 { |
|
560 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::RetrievingLicenseHandler" ); |
|
561 iHttpPlugin->AcquireLicense( *iLicenseChallenge, |
|
562 iLicenseServerUrl, |
|
563 iStatus ); |
|
564 SetActive(); |
|
565 iState = CWmDrmDlaHttpLicAcqPluginFw::EAddingLicense; |
|
566 } |
|
567 |
|
568 // ---------------------------------------------------------------------------- |
|
569 // CWmDrmDlaHttpLicAcqPluginFw::AddingLicenseHandlerL |
|
570 // ---------------------------------------------------------------------------- |
|
571 // |
|
572 void CWmDrmDlaHttpLicAcqPluginFw::AddingLicenseHandlerL() |
|
573 { |
|
574 TInt err( KErrNone ); |
|
575 |
|
576 LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::AddingLicenseHandler", err ); |
|
577 |
|
578 delete iLicenseResponse; |
|
579 iLicenseResponse = NULL; |
|
580 TRAP( err, iLicenseResponse = iHttpPlugin->GetLicenseResponseL() ); |
|
581 if ( err ) |
|
582 { |
|
583 HandleErrorL( err ); |
|
584 } |
|
585 SetActive(); |
|
586 iState = CWmDrmDlaHttpLicAcqPluginFw::ESendingLicenseStorageStatus; |
|
587 TRequestStatus* status = &iStatus; |
|
588 User::RequestComplete( status, KErrNotSupported ); |
|
589 } |
|
590 |
|
591 // ---------------------------------------------------------------------------- |
|
592 // CWmDrmDlaHttpLicAcqPluginFw::SendingLicenseStorageStatusHandler |
|
593 // ---------------------------------------------------------------------------- |
|
594 // |
|
595 void CWmDrmDlaHttpLicAcqPluginFw::SendingLicenseStorageStatusHandler() |
|
596 { |
|
597 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::SendingLicenseStorageStatusHandler" ); |
|
598 LOG2( "iStatus.Int(): %d", iStatus.Int() ); |
|
599 HBufC8* tid( NULL ); |
|
600 TRAP_IGNORE( ParseLicenseResponseL( *iLicenseResponse, |
|
601 tid, |
|
602 *iContentUrl ) ); |
|
603 //If license couldn't be added succesfully to license store, |
|
604 //then make sure content won't be downloaded |
|
605 if ( iStatus.Int() ) |
|
606 { |
|
607 delete *iContentUrl; |
|
608 *iContentUrl = NULL; |
|
609 } |
|
610 iHttpPlugin->SendLicenseStorageStatus( tid, |
|
611 *iLicenseServerUrl, |
|
612 iStatus.Int(), |
|
613 iStatus ); |
|
614 delete tid; |
|
615 SetActive(); |
|
616 iState = CWmDrmDlaHttpLicAcqPluginFw::ESentLicenseStorageStatus; |
|
617 } |
|
618 |
|
619 // ---------------------------------------------------------------------------- |
|
620 // CWmDrmDlaHttpLicAcqPluginFw::SentLicenseStorageStatusHandler |
|
621 // ---------------------------------------------------------------------------- |
|
622 // |
|
623 void CWmDrmDlaHttpLicAcqPluginFw::SentLicenseStorageStatusHandler() |
|
624 { |
|
625 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::SentLicenseStorageStatusHandler" ); |
|
626 //If license acquisition is cancelled during the send operation, |
|
627 //then don't continue license acquisition process |
|
628 if ( iWait->IsStarted() ) |
|
629 { |
|
630 iWait->AsyncStop(); |
|
631 } |
|
632 else |
|
633 { |
|
634 iState = CWmDrmDlaHttpLicAcqPluginFw::ELicensingComplete; |
|
635 CompleteSelf(); |
|
636 } |
|
637 } |
|
638 |
|
639 |
|
640 // ---------------------------------------------------------------------------- |
|
641 // CWmDrmDlaHttpLicAcqPluginFw::LicensingCompleteL |
|
642 // ---------------------------------------------------------------------------- |
|
643 // |
|
644 void CWmDrmDlaHttpLicAcqPluginFw::LicensingCompleteL() |
|
645 { |
|
646 TInt err( KErrNone ); |
|
647 |
|
648 LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::LicensingComplete", err ); |
|
649 |
|
650 //If content URL couldn't be parsed from the license response, |
|
651 //then try to get it from the http plugin |
|
652 if ( !*iContentUrl ) |
|
653 { |
|
654 TRAP( err, *iContentUrl = iHttpPlugin->GetContentUrlL() ); |
|
655 if ( err ) |
|
656 { |
|
657 HandleErrorL( err ); |
|
658 } |
|
659 } |
|
660 TRAP( err, *iHtmlData = iHttpPlugin->GetHtmlDataL() ); |
|
661 if ( err ) |
|
662 { |
|
663 HandleErrorL( err ); |
|
664 } |
|
665 CompleteClientRequest( KErrNone ); |
|
666 Reset(); |
|
667 } |
|
668 |
|
669 // --------------------------------------------------------------------------- |
|
670 // CWmDrmDlaHttpLicAcqPluginFw::ResolveHttpPluginL |
|
671 // --------------------------------------------------------------------------- |
|
672 // |
|
673 void CWmDrmDlaHttpLicAcqPluginFw::ResolveHttpPluginL( |
|
674 const RFile& aFile ) |
|
675 { |
|
676 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::ResolveHttpPluginL" ); |
|
677 |
|
678 delete iHttpPlugin; |
|
679 iHttpPlugin = NULL; |
|
680 delete iUiNotifier; |
|
681 iUiNotifier = NULL; |
|
682 |
|
683 WmDrmDlaHttpFwPluginResolver::ResolveHttpPluginL( aFile, |
|
684 iHttpPlugin, |
|
685 iUiNotifier ); |
|
686 |
|
687 //Set cancel observer for ui plugin |
|
688 if ( iUiNotifier ) |
|
689 { |
|
690 iUiNotifier->SetCancelObserver( this ); |
|
691 } |
|
692 //Set iap for http plugin |
|
693 if ( iIapId ) |
|
694 { |
|
695 iHttpPlugin->SetIapId( iIapId ); |
|
696 } |
|
697 } |
|
698 |
|
699 // --------------------------------------------------------------------------- |
|
700 // CWmDrmDlaHttpLicAcqPluginFw::ResolveHttpPluginL |
|
701 // --------------------------------------------------------------------------- |
|
702 // |
|
703 void CWmDrmDlaHttpLicAcqPluginFw::ResolveHttpPluginL( |
|
704 const TDesC8& aDrmHeader ) |
|
705 { |
|
706 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::ResolveHttpPluginL" ); |
|
707 |
|
708 delete iHttpPlugin; |
|
709 iHttpPlugin = NULL; |
|
710 delete iUiNotifier; |
|
711 iUiNotifier = NULL; |
|
712 |
|
713 WmDrmDlaHttpFwPluginResolver::ResolveHttpPluginL( aDrmHeader, |
|
714 iHttpPlugin, |
|
715 iUiNotifier ); |
|
716 |
|
717 //Set cancel observer for ui plugin |
|
718 if ( iUiNotifier ) |
|
719 { |
|
720 iUiNotifier->SetCancelObserver( this ); |
|
721 } |
|
722 //Set iap for http plugin |
|
723 if ( iIapId ) |
|
724 { |
|
725 iHttpPlugin->SetIapId( iIapId ); |
|
726 } |
|
727 } |
|
728 |
|
729 // ---------------------------------------------------------------------------- |
|
730 // CWmDrmDlaHttpLicAcqPluginFw::ParseDrmHeaderL |
|
731 // ---------------------------------------------------------------------------- |
|
732 // |
|
733 void CWmDrmDlaHttpLicAcqPluginFw::ParseDrmHeaderL( |
|
734 const TDesC8& aDrmHeader, |
|
735 HBufC*& aLicenseServerUrl ) |
|
736 { |
|
737 TInt err( KErrNone ); |
|
738 |
|
739 LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::ParseDrmHeader", err ); |
|
740 |
|
741 HBufC8* licenseServerUrl( NULL ); |
|
742 err = iDlaParser->GetLicenseServerURLFromDRMHeader( aDrmHeader, |
|
743 licenseServerUrl ); |
|
744 if ( licenseServerUrl ) |
|
745 { |
|
746 CleanupStack::PushL( licenseServerUrl ); |
|
747 aLicenseServerUrl |
|
748 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *licenseServerUrl ); |
|
749 CleanupStack::PopAndDestroy( licenseServerUrl ); |
|
750 } |
|
751 User::LeaveIfError( err ); |
|
752 } |
|
753 |
|
754 // ---------------------------------------------------------------------------- |
|
755 // CWmDrmDlaHttpLicAcqPluginFw::ParseLicenseResponseL |
|
756 // ---------------------------------------------------------------------------- |
|
757 // |
|
758 void CWmDrmDlaHttpLicAcqPluginFw::ParseLicenseResponseL( |
|
759 const TDesC8& aLicenseResponse, |
|
760 HBufC8*& aTid, |
|
761 HBufC*& aContentUrl ) |
|
762 { |
|
763 TInt err( KErrNone ); |
|
764 |
|
765 LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::ParseLicenseResponse", err ); |
|
766 |
|
767 HBufC8* contentUrl( NULL ); |
|
768 err = iDlaParser->ProcessLicenseResponse( aLicenseResponse, |
|
769 aTid, |
|
770 contentUrl ); |
|
771 if ( contentUrl ) |
|
772 { |
|
773 CleanupStack::PushL( contentUrl ); |
|
774 aContentUrl |
|
775 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *contentUrl ); |
|
776 CleanupStack::PopAndDestroy( contentUrl ); |
|
777 } |
|
778 User::LeaveIfError( err ); |
|
779 } |
|
780 |
|
781 // ---------------------------------------------------------------------------- |
|
782 // CWmDrmDlaHttpLicAcqPluginFw::HandleErrorL |
|
783 // ---------------------------------------------------------------------------- |
|
784 // |
|
785 void CWmDrmDlaHttpLicAcqPluginFw::HandleErrorL( TInt aError ) |
|
786 { |
|
787 TInt err( KErrNotFound ); |
|
788 |
|
789 LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::HandleErrorL", err ); |
|
790 LOG2( "iState: %d", iState ); |
|
791 LOG2( "aError: %d", aError ); |
|
792 |
|
793 //First try to let ui plugin to handle the error |
|
794 if ( iUiNotifier ) |
|
795 { |
|
796 TRAP( err, iUiNotifier->HandleErrorL( aError ) ); |
|
797 } |
|
798 //If ui plugin didn't handle the error and we aren't currently sending |
|
799 //license storage status to server, then try to show the generic |
|
800 //error note. |
|
801 if ( err && |
|
802 iState != CWmDrmDlaHttpLicAcqPluginFw::ESendingLicenseStorageStatus ) |
|
803 { |
|
804 CWmDrmDlaUi* ui( NULL ); |
|
805 TRAP_IGNORE( ui = CWmDrmDlaUi::NewL() ); |
|
806 if ( ui ) |
|
807 { |
|
808 CleanupStack::PushL( ui ); |
|
809 ui->ShowErrorNoteL( R_WMDRMDLA_NOTE_AQUISITION_FAILED ); |
|
810 CleanupStack::PopAndDestroy( ui ); |
|
811 } |
|
812 } |
|
813 //If we aren't currently sending license storage status to server, |
|
814 //the leave with the error code. |
|
815 if ( iState != CWmDrmDlaHttpLicAcqPluginFw::ESendingLicenseStorageStatus ) |
|
816 { |
|
817 User::Leave( aError ); |
|
818 } |
|
819 } |
|
820 |
|
821 // --------------------------------------------------------------------------- |
|
822 // CWmDrmDlaHttpLicAcqPluginFw::AsyncCancel |
|
823 // --------------------------------------------------------------------------- |
|
824 // |
|
825 TInt CWmDrmDlaHttpLicAcqPluginFw::AsyncCancel( TAny* aPtr ) |
|
826 { |
|
827 LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::AsyncCancel" ); |
|
828 CWmDrmDlaHttpLicAcqPluginFw* licAcqFw = |
|
829 static_cast<CWmDrmDlaHttpLicAcqPluginFw*>( aPtr ); |
|
830 licAcqFw->CancelLicenseAcquisition(); |
|
831 return EFalse; |
|
832 } |