|
1 /* |
|
2 * Copyright (c) 2002-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: core ROAP engine |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <DrmRights.h> |
|
21 #include <DrmRightsClient.h> |
|
22 // #include <GenericParam.h> // from S60 |
|
23 #include "RoapEngBase.h" |
|
24 #include "RoapHttpHandler.h" |
|
25 #include "RoapTrigger.h" |
|
26 #include "RoapDef.h" |
|
27 #include "RoapMessage.h" |
|
28 #include "RoapLog.h" |
|
29 #include "RoapObserver.h" |
|
30 #include "DrmRiContext.h" |
|
31 #include "RoapStorageClient.h" |
|
32 |
|
33 using namespace Roap; |
|
34 |
|
35 // ================= MEMBER FUNCTIONS ======================= |
|
36 |
|
37 // --------------------------------------------------------- |
|
38 // CRoapEngBase::~CRoapEngBase() |
|
39 // --------------------------------------------------------- |
|
40 // |
|
41 EXPORT_C CRoapEngBase::~CRoapEngBase() |
|
42 { |
|
43 Cancel(); |
|
44 delete iTrigger; |
|
45 delete iRequest; |
|
46 delete iResponse; |
|
47 delete iRoapResp; |
|
48 delete iHttpHandler; |
|
49 delete iStoredRiContext; |
|
50 iReturnedROs.ResetAndDestroy(); |
|
51 delete iDomainRightsResp; |
|
52 delete iRiAlias; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // CRoapEngBase::CRoapEngBase() |
|
57 // --------------------------------------------------------- |
|
58 // |
|
59 CRoapEngBase::CRoapEngBase( ): CActive( CActive::EPriorityStandard ), |
|
60 iPreferredIap(0) |
|
61 { |
|
62 CActiveScheduler::Add( this ); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------- |
|
66 // CRoapEngBase::ConstructL() |
|
67 // --------------------------------------------------------- |
|
68 // |
|
69 void CRoapEngBase::ConstructL() |
|
70 { |
|
71 LOGLIT( "CRoapEngBase::ConstructL" ) |
|
72 |
|
73 iCompleted = EFalse; |
|
74 iState = EInit; |
|
75 iTransTrackConf = EFalse; |
|
76 iAllowedToContactRi = EFalse; |
|
77 iUseRiContextUrl = EFalse; |
|
78 iImplicitJoinDomain = EFalse; |
|
79 iReRegistered = EFalse; |
|
80 iRiAlias = NULL; |
|
81 } |
|
82 |
|
83 |
|
84 // --------------------------------------------------------- |
|
85 // CRoapEngBase::SetTriggerL() |
|
86 // --------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C void CRoapEngBase::SetTriggerL( const TDesC8& aXmlTrigger, |
|
89 const CAiwGenericParamList* /*aParamList*/, |
|
90 TTriggerType& aType, |
|
91 TRiContextStatus& aContextStatus, |
|
92 TDomainOperation& aDomainOperation, |
|
93 RPointerArray<HBufC8>& aContentIdList ) |
|
94 { |
|
95 LOGLIT( "CRoapEngBase::SetTriggerL" ) |
|
96 |
|
97 #ifndef __DRM_OMA2 |
|
98 User::Leave(KErrNotSupported); |
|
99 #endif |
|
100 |
|
101 __ASSERT_ALWAYS( iState == EInit || iState == EReady, \ |
|
102 User::Invariant() ); |
|
103 TBool registered = EFalse; |
|
104 TBool isValidDomainGeneration = ETrue; |
|
105 TInt error = KErrNone; |
|
106 HBufC8* temp = NULL; |
|
107 aDomainOperation = ENotDomainOperation; |
|
108 iProgressInBytes = KRoapProgressDelta; |
|
109 |
|
110 delete iTrigger; |
|
111 iTrigger = NULL; |
|
112 |
|
113 iTrigger = ParseTriggerL( aXmlTrigger ); |
|
114 |
|
115 if ( !iTrigger || !iTrigger->ValidTrigger() ) |
|
116 { |
|
117 LOGLIT( "Trigger parsing failed!" ) |
|
118 User::Leave( KErrRoapGeneral ); |
|
119 } |
|
120 |
|
121 aType = iTrigger->iTriggerType; |
|
122 |
|
123 if ( iTrigger->iTriggerType == ERegistrationTrigger ) |
|
124 { |
|
125 iReqMessage = EDeviceHello; |
|
126 if ( iAllowedToContactRi ) |
|
127 { |
|
128 aContextStatus = EInvalidContextNoConf; |
|
129 } |
|
130 else |
|
131 { |
|
132 aContextStatus = EInvalidContext; |
|
133 } |
|
134 iState = EReady; |
|
135 return; |
|
136 } |
|
137 else if ( iTrigger->iTriggerType == ERoAcquisitionTrigger ) |
|
138 { |
|
139 iReqMessage = EROAcquisition; |
|
140 } |
|
141 else if ( iTrigger->iTriggerType == EJoinDomainTrigger ) |
|
142 { |
|
143 iReqMessage = EJoinDomain; |
|
144 } |
|
145 else if ( iTrigger->iTriggerType == ELeaveDomainTrigger ) |
|
146 { |
|
147 iReqMessage = ELeaveDomain; |
|
148 } |
|
149 #ifdef RD_DRM_METERING |
|
150 else if ( iTrigger->iTriggerType == EMeteringReportTrigger ) |
|
151 { |
|
152 iReqMessage = EMeteringRequest; |
|
153 } |
|
154 #endif |
|
155 else |
|
156 { |
|
157 LOG2(_L ("Unsupported Trigger type: %d"), iTrigger->iTriggerType) |
|
158 User::Leave( KErrRoapUnsupported ); |
|
159 } |
|
160 |
|
161 GetRIContextL( registered, iTrigger->iRiId ); |
|
162 |
|
163 if ( !registered ) |
|
164 { |
|
165 LOGLIT( "No valid RI Context -> Device Hello" ) |
|
166 iReqMessage = EDeviceHello; |
|
167 aContextStatus = EInvalidContext; |
|
168 } |
|
169 else |
|
170 { |
|
171 aContextStatus = EValidContext; |
|
172 } |
|
173 |
|
174 if ( iTrigger->iTriggerType == EJoinDomainTrigger ) |
|
175 { |
|
176 GetDomainContextL( registered, isValidDomainGeneration, *iTrigger->iDomainId ); |
|
177 registered ? aDomainOperation = EKeyUpgradeOperation : aDomainOperation = EJoinDomainOperation; |
|
178 } |
|
179 |
|
180 for ( TInt i = 0; i < iTrigger->iContentIdList.Count(); i++ ) |
|
181 { |
|
182 temp = iTrigger->iContentIdList[i]->Alloc(); |
|
183 if ( temp ) |
|
184 { |
|
185 error = aContentIdList.Append( temp ); |
|
186 if ( error ) |
|
187 { |
|
188 aContentIdList.ResetAndDestroy(); |
|
189 delete temp; |
|
190 User::Leave( error ); |
|
191 } |
|
192 } |
|
193 else |
|
194 { |
|
195 aContentIdList.ResetAndDestroy(); |
|
196 User::Leave( KErrNoMemory ); |
|
197 } |
|
198 } |
|
199 |
|
200 if ( iTrigger->iDomainId && iTrigger->iTriggerType == ERoAcquisitionTrigger ) |
|
201 { |
|
202 GetDomainContextL( registered, isValidDomainGeneration, *iTrigger->iDomainId ); |
|
203 if ( !registered || !isValidDomainGeneration ) |
|
204 { |
|
205 // We don't have a valid Domain key for the RO -> JoinDomain |
|
206 LOGLIT( "Perform implicit Join Domain" ) |
|
207 iImplicitJoinDomain = ETrue; |
|
208 if ( aContextStatus == EValidContext ) |
|
209 { |
|
210 iReqMessage = EJoinDomain; |
|
211 } |
|
212 } |
|
213 } |
|
214 iState = EReady; |
|
215 |
|
216 if ( aContextStatus == EInvalidContext && iAllowedToContactRi ) |
|
217 { |
|
218 aContextStatus = EInvalidContextNoConf; |
|
219 } |
|
220 else if ( aContextStatus == EInvalidContext ) |
|
221 { |
|
222 RRoapStorageClient client; |
|
223 User::LeaveIfError( client.Connect() ); |
|
224 CleanupClosePushL( client ); |
|
225 // check that SilentRightsUrl is on the white list |
|
226 // URL is searched from pre-configured white list |
|
227 TBool fromPreConfiguredWhiteList( ETrue ); |
|
228 if ( client.WhiteListURLExistsL( *iTrigger->iRoapUrl, fromPreConfiguredWhiteList ) ) |
|
229 { |
|
230 aContextStatus = EInvalidContextNoConf; |
|
231 } |
|
232 CleanupStack::PopAndDestroy( &client ); |
|
233 } |
|
234 |
|
235 if ( iTrigger->iRiAlias ) |
|
236 { |
|
237 iRiAlias = iTrigger->iRiAlias->AllocL(); |
|
238 } |
|
239 |
|
240 } |
|
241 |
|
242 |
|
243 // --------------------------------------------------------- |
|
244 // CRoapEngBase::AcceptL() |
|
245 // --------------------------------------------------------- |
|
246 // |
|
247 EXPORT_C void CRoapEngBase::AcceptL( MRoapObserver* aObserver, TRequestStatus* aStatus ) |
|
248 { |
|
249 LOGLIT( "CRoapEngBase::Accept" ) |
|
250 PERFORMANCE_LOGLIT( "ROAP started" ) |
|
251 |
|
252 if ( iState != EReady ) |
|
253 { |
|
254 User::Leave( KErrNotReady ); |
|
255 } |
|
256 |
|
257 iObserver = aObserver; |
|
258 iParentStatus = aStatus; |
|
259 *iParentStatus = KRequestPending; |
|
260 iResult = KErrNone; |
|
261 |
|
262 if ( iObserver ) |
|
263 { |
|
264 iObserver->RoapProgressInfoL( iProgressInBytes ); |
|
265 } |
|
266 iProgressInBytes = Min( iProgressInBytes + KRoapProgressDelta, KRoapProgressMax ); |
|
267 |
|
268 Continue( ECreateConn ); |
|
269 } |
|
270 |
|
271 |
|
272 // --------------------------------------------------------- |
|
273 // CRoapEngBase::Reject() |
|
274 // --------------------------------------------------------- |
|
275 // |
|
276 EXPORT_C void CRoapEngBase::Reject() |
|
277 { |
|
278 LOGLIT( "CRoapEngBase::Reject" ) |
|
279 |
|
280 Cancel(); |
|
281 |
|
282 // Cleanup first, so that |
|
283 DoCleanup(); |
|
284 |
|
285 delete iTrigger; |
|
286 iTrigger = NULL; |
|
287 delete iRequest; |
|
288 iRequest = NULL; |
|
289 delete iResponse; |
|
290 iResponse = NULL; |
|
291 delete iRoapResp; |
|
292 iRoapResp = NULL; |
|
293 delete iHttpHandler; |
|
294 iHttpHandler = NULL; |
|
295 delete iStoredRiContext; |
|
296 iStoredRiContext = NULL; |
|
297 delete iDomainRightsResp; |
|
298 iDomainRightsResp = NULL; |
|
299 |
|
300 iImplicitJoinDomain = EFalse; |
|
301 |
|
302 iState = EInit; |
|
303 } |
|
304 |
|
305 |
|
306 // --------------------------------------------------------- |
|
307 // CRoapEngBase::DoCleanup() |
|
308 // --------------------------------------------------------- |
|
309 // |
|
310 EXPORT_C TInt CRoapEngBase::DoCleanup() |
|
311 { |
|
312 LOGLIT( "CRoapEngBase::DoCleanup" ) |
|
313 |
|
314 RDRMRightsClient rightsClient; |
|
315 HBufC8* contentUri = NULL; |
|
316 TInt error = KErrNone; |
|
317 |
|
318 if ( iTrigger && iTrigger->iTriggerType == ERoAcquisitionTrigger ) |
|
319 { |
|
320 if ( iCompleted ) |
|
321 { |
|
322 error = rightsClient.Connect(); |
|
323 if ( !error) |
|
324 { |
|
325 for ( TInt i = 0; i < iReturnedROs.Count(); i++ ) |
|
326 { |
|
327 error = iReturnedROs[i]->GetContentURI( contentUri ); |
|
328 if ( !error ) |
|
329 { |
|
330 // rightsClient.DeleteDbEntry( *contentUri, iReturnedROs[i]->GetLocalID() ) |
|
331 } |
|
332 } |
|
333 rightsClient.Close(); |
|
334 } |
|
335 iReturnedROs.ResetAndDestroy(); |
|
336 } |
|
337 } |
|
338 if ( iRoapResp ) |
|
339 { |
|
340 if ( iRoapResp->DcfFileName().Length() ) |
|
341 { |
|
342 RFs fs; |
|
343 error = fs.Connect(); |
|
344 if ( error != KErrNone ) |
|
345 { |
|
346 fs.Delete( iRoapResp->DcfFileName() ); |
|
347 } |
|
348 fs.Close(); |
|
349 } |
|
350 } |
|
351 return error; |
|
352 } |
|
353 |
|
354 |
|
355 // --------------------------------------------------------- |
|
356 // CRoapEngBase::HandleRoReponseL() |
|
357 // --------------------------------------------------------- |
|
358 // |
|
359 EXPORT_C void CRoapEngBase::HandleRoReponseL( const TDesC8& aResponse, RPointerArray<CDRMRights>& aParsedRights ) |
|
360 { |
|
361 LOGLIT( "CRoapEngBase::HandleRoReponseL" ) |
|
362 |
|
363 __ASSERT_ALWAYS( iState == EInit, User::Invariant() ); |
|
364 |
|
365 aParsedRights.ResetAndDestroy(); |
|
366 |
|
367 TRAPD( error, HandleRightsResponsePduL( aResponse, ETrue ) ); |
|
368 if ( error == KErrRoapNotRegistered ) |
|
369 { |
|
370 // Needs to register |
|
371 } |
|
372 else if ( iReturnedROs.Count() ) |
|
373 { |
|
374 for ( TInt i = 0; i < iReturnedROs.Count(); i++ ) |
|
375 { |
|
376 CDRMRights* temp = CDRMRights::NewL(); |
|
377 CleanupStack::PushL( temp ); |
|
378 *temp = *iReturnedROs[i]; |
|
379 aParsedRights.AppendL( temp ); |
|
380 CleanupStack::Pop( temp ); |
|
381 } |
|
382 } |
|
383 } |
|
384 |
|
385 // --------------------------------------------------------- |
|
386 // CRoapEngBase::GetTrigger() |
|
387 // --------------------------------------------------------- |
|
388 // |
|
389 EXPORT_C const CRoapTrigger& CRoapEngBase::Trigger() const |
|
390 { |
|
391 return *iTrigger; |
|
392 } |
|
393 |
|
394 // --------------------------------------------------------- |
|
395 // CRoapEngBase::DoCancel() |
|
396 // --------------------------------------------------------- |
|
397 // |
|
398 void CRoapEngBase::DoCancel() |
|
399 { |
|
400 LOGLIT( "CRoapEngBase::DoCancel" ) |
|
401 |
|
402 if (iHttpHandler) |
|
403 { |
|
404 iHttpHandler->Cancel(); |
|
405 } |
|
406 iResult = KErrCancel; |
|
407 CompleteRequest(); |
|
408 } |
|
409 |
|
410 |
|
411 // --------------------------------------------------------- |
|
412 // CRoapEngBase::RunL() |
|
413 // --------------------------------------------------------- |
|
414 // |
|
415 void CRoapEngBase::RunL() |
|
416 { |
|
417 LOGLIT( "CRoapEngBase::RunL" ) |
|
418 |
|
419 switch ( iState ) |
|
420 { |
|
421 case ECreateConn: |
|
422 { |
|
423 CreateConnectionL(); |
|
424 break; |
|
425 } |
|
426 case EStartTrans: |
|
427 { |
|
428 StartTransactionL(); |
|
429 break; |
|
430 } |
|
431 case ERespReceived: |
|
432 { |
|
433 HandleResponseL(); |
|
434 break; |
|
435 } |
|
436 case EComplete: |
|
437 { |
|
438 CompleteL(); |
|
439 break; |
|
440 } |
|
441 default: |
|
442 { |
|
443 break; |
|
444 } |
|
445 } |
|
446 } |
|
447 |
|
448 // --------------------------------------------------------- |
|
449 // CRoapEngBase::RunError() |
|
450 // --------------------------------------------------------- |
|
451 // |
|
452 TInt CRoapEngBase::RunError( TInt aError ) |
|
453 { |
|
454 LOG2( _L ( "CRoapEngBase::RunError: %d" ), aError ) |
|
455 PERFORMANCE_LOG2( _L ( "Error occured: %d" ), aError ) |
|
456 |
|
457 iResult = aError; |
|
458 |
|
459 if ( aError == KErrTimedOut || aError == KErrDisconnected ) |
|
460 { |
|
461 // Retry in time out and disconnected cases |
|
462 iResult = KErrRoapServer; |
|
463 } |
|
464 |
|
465 if ( iReqMessage == ERegistration ) |
|
466 { |
|
467 // in case of retry send DeviceHello (not RegRequest) |
|
468 iReqMessage = EDeviceHello; |
|
469 } |
|
470 |
|
471 if ( iRoapResp ) |
|
472 { |
|
473 if ( iRoapResp->DcfFileName().Length() ) |
|
474 { |
|
475 RFs fs; |
|
476 if ( fs.Connect() ) |
|
477 { |
|
478 fs.Delete( iRoapResp->DcfFileName() ); |
|
479 fs.Close(); |
|
480 } |
|
481 } |
|
482 } |
|
483 |
|
484 iCompleted = ETrue; |
|
485 Continue( EComplete ); |
|
486 |
|
487 return KErrNone; |
|
488 } |
|
489 |
|
490 // --------------------------------------------------------- |
|
491 // CRoapEngBase::CreateConnectionL() |
|
492 // --------------------------------------------------------- |
|
493 // |
|
494 void CRoapEngBase::CreateConnectionL() |
|
495 { |
|
496 LOGLIT( "CRoapEngBase::CreateConnectionL" ) |
|
497 |
|
498 __ASSERT_ALWAYS( iState == ECreateConn, User::Invariant() ); |
|
499 |
|
500 if ( iObserver ) |
|
501 { |
|
502 iObserver->RoapProgressInfoL( iProgressInBytes ); |
|
503 } |
|
504 iProgressInBytes = Min( iProgressInBytes + KRoapProgressDelta, KRoapProgressMax ); |
|
505 |
|
506 iHttpHandler = CRoapHttpHandler::NewL(); |
|
507 iHttpHandler->SetObserver( iObserver ); |
|
508 iHttpHandler->SetPreferredIap( iPreferredIap ); |
|
509 iHttpHandler->CreateConnectionL( &iStatus ); |
|
510 |
|
511 iState = EStartTrans; |
|
512 SetActive(); |
|
513 } |
|
514 |
|
515 // --------------------------------------------------------- |
|
516 // CRoapEngBase::StartTransactionL() |
|
517 // --------------------------------------------------------- |
|
518 // |
|
519 void CRoapEngBase::StartTransactionL() |
|
520 { |
|
521 LOGLIT( "CRoapEngBase::StartTransactionL" ) |
|
522 |
|
523 User::LeaveIfError( iStatus.Int() ); |
|
524 |
|
525 __ASSERT_ALWAYS( iState == EStartTrans, User::Invariant() ); |
|
526 __ASSERT_ALWAYS( iHttpHandler, User::Invariant() ); |
|
527 __ASSERT_ALWAYS( iTrigger, User::Invariant() ); |
|
528 __ASSERT_ALWAYS( !iRequest, User::Invariant() ); |
|
529 |
|
530 if ( iObserver ) |
|
531 { |
|
532 iObserver->RoapProgressInfoL( iProgressInBytes ); |
|
533 } |
|
534 iProgressInBytes = Min( iProgressInBytes + KRoapProgressDelta, KRoapProgressMax ); |
|
535 |
|
536 HBufC8* reqBody = NULL; |
|
537 HBufC8* signedReqBody = NULL; |
|
538 HBufC8* url = NULL; |
|
539 |
|
540 CreateReqMessageL(); // creates iRequest |
|
541 |
|
542 reqBody = iRequest->MessageAsXmlL(); |
|
543 |
|
544 CleanupStack::PushL( reqBody ); |
|
545 |
|
546 if ( iUseRiContextUrl ) |
|
547 { |
|
548 if ( iStoredRiContext ) |
|
549 { |
|
550 url = HBufC8::NewMaxLC( iStoredRiContext->RightsIssuerURL().Length() ); |
|
551 url->Des().Copy( iStoredRiContext->RightsIssuerURL() ); |
|
552 } |
|
553 else |
|
554 { |
|
555 User::Leave( KErrRoapNotRegistered ); |
|
556 } |
|
557 } |
|
558 else |
|
559 { |
|
560 url = HBufC8::NewMaxLC( iTrigger->iRoapUrl->Length() ); |
|
561 url->Des().Copy( *iTrigger->iRoapUrl ); |
|
562 } |
|
563 |
|
564 signedReqBody = SignMessageL( *reqBody ); |
|
565 |
|
566 CleanupStack::PushL( signedReqBody ); |
|
567 |
|
568 LOGHEX(signedReqBody->Ptr(), signedReqBody->Length()) |
|
569 |
|
570 iRoapResp = CRoapResponse::NewL(); |
|
571 |
|
572 iHttpHandler->SetUrlL( *url ); |
|
573 |
|
574 if ( iReqMessage == EROAcquisition ) |
|
575 { |
|
576 if ( iObserver ) |
|
577 { |
|
578 iObserver->RoapProgressInfoL( iProgressInBytes ); |
|
579 } |
|
580 iProgressInBytes = Min( iProgressInBytes + KRoapProgressDelta, KRoapProgressMax ); |
|
581 } |
|
582 |
|
583 iHttpHandler->DoTransactionL(*iRoapResp, *signedReqBody, &iStatus ); |
|
584 |
|
585 CleanupStack::PopAndDestroy( signedReqBody ); |
|
586 CleanupStack::PopAndDestroy( url ); |
|
587 CleanupStack::PopAndDestroy( reqBody ); |
|
588 |
|
589 iState = ERespReceived; |
|
590 SetActive(); |
|
591 } |
|
592 |
|
593 |
|
594 // --------------------------------------------------------- |
|
595 // CRoapEngBase::HandleResponseL() |
|
596 // --------------------------------------------------------- |
|
597 // |
|
598 void CRoapEngBase::HandleResponseL() |
|
599 { |
|
600 LOGLIT( "CRoapEngBase::HandleResponseL" ) |
|
601 |
|
602 __ASSERT_ALWAYS( iState == ERespReceived, User::Invariant() ); |
|
603 __ASSERT_ALWAYS( iRoapResp, User::Invariant() ); |
|
604 |
|
605 User::LeaveIfError( iStatus.Int() ); |
|
606 |
|
607 LOG(iRoapResp->DataType().Des()) |
|
608 LOGHEX(iRoapResp->ProtocolUnit().Ptr(), iRoapResp->ProtocolUnit().Length()) |
|
609 |
|
610 TInt status = KErrNone; |
|
611 |
|
612 if ( iRoapResp->DataType() == TDataType( KRoapPDUType ) ) |
|
613 { |
|
614 LOGLIT( "ROAP PDU datatype received." ) |
|
615 |
|
616 if ( iObserver ) |
|
617 { |
|
618 iObserver->RoapProgressInfoL( iProgressInBytes ); |
|
619 } |
|
620 iProgressInBytes = Min( iProgressInBytes + KRoapProgressDelta, KRoapProgressMax ); |
|
621 |
|
622 HandleRoapResponseL( iRoapResp->ProtocolUnit() ); |
|
623 } |
|
624 else if ( iRoapResp->DataType() == TDataType( KMultipartRelatedType ) ) |
|
625 { |
|
626 LOGLIT( "Multipart related datatype received." ) |
|
627 HandleMultipartL(); |
|
628 } |
|
629 else |
|
630 { |
|
631 LOGLIT( "Error: Unsupported response datatype." ) |
|
632 |
|
633 User::Leave( KErrRoapUnsupported ); |
|
634 } |
|
635 |
|
636 status = MapStatusL(); |
|
637 |
|
638 iUseRiContextUrl = EFalse; |
|
639 |
|
640 if ( status == KErrRoapNotRegistered ) |
|
641 { |
|
642 // Not registered or DRM Time is incorrect |
|
643 // -> Check user consent and initiate the registration protocol |
|
644 |
|
645 if ( iReRegistered ) |
|
646 { |
|
647 LOGLIT( "DRM Time update or re-registering is already performed once!" ) |
|
648 User::Leave( KErrRoapServer ); |
|
649 } |
|
650 |
|
651 if ( iObserver && !iAllowedToContactRi ) |
|
652 { |
|
653 if ( iObserver->ContactRiConfL() ) |
|
654 { |
|
655 iReqMessage = EDeviceHello; |
|
656 iCompleted = EFalse; |
|
657 iAllowedToContactRi = ETrue; |
|
658 iUseRiContextUrl = EFalse; |
|
659 } |
|
660 else |
|
661 { |
|
662 User::Leave( status ); |
|
663 } |
|
664 } |
|
665 else |
|
666 { |
|
667 iReqMessage = EDeviceHello; |
|
668 iCompleted = EFalse; |
|
669 } |
|
670 iReRegistered = ETrue; |
|
671 } |
|
672 else |
|
673 { |
|
674 SetProtocolL(); |
|
675 } |
|
676 |
|
677 // delete previous request and response |
|
678 delete iRequest; |
|
679 iRequest = NULL; |
|
680 delete iRoapResp; |
|
681 iRoapResp = NULL; |
|
682 |
|
683 if ( !iCompleted ) |
|
684 { |
|
685 // Send next request |
|
686 Continue( EStartTrans ); |
|
687 } |
|
688 else |
|
689 { |
|
690 // Complete request |
|
691 Continue( EComplete ); |
|
692 } |
|
693 } |
|
694 |
|
695 |
|
696 // --------------------------------------------------------- |
|
697 // CRoapEngBase::SetProtocol() |
|
698 // --------------------------------------------------------- |
|
699 // |
|
700 void CRoapEngBase::SetProtocolL() |
|
701 { |
|
702 LOG2( _L ( "CRoapEngBase::SetProtocol: %d" ), iReqMessage ) |
|
703 |
|
704 switch ( iReqMessage ) |
|
705 { |
|
706 case EDeviceHello: |
|
707 { |
|
708 iReqMessage = ERegistration; |
|
709 iCompleted = EFalse; |
|
710 break; |
|
711 } |
|
712 case ERegistration: |
|
713 { |
|
714 if ( iTrigger->iTriggerType != ERegistrationTrigger ) |
|
715 { |
|
716 if ( !iImplicitJoinDomain && iTrigger->iTriggerType == ERoAcquisitionTrigger ) |
|
717 { |
|
718 iReqMessage = EROAcquisition; |
|
719 } |
|
720 else if ( iTrigger->iTriggerType == EJoinDomainTrigger ) |
|
721 { |
|
722 iReqMessage = EJoinDomain; |
|
723 } |
|
724 else if ( iTrigger->iTriggerType == ELeaveDomainTrigger ) |
|
725 { |
|
726 iReqMessage = ELeaveDomain; |
|
727 } |
|
728 #ifdef RD_DRM_METERING |
|
729 else if ( iTrigger->iTriggerType == EMeteringReportTrigger ) |
|
730 { |
|
731 iReqMessage = EMeteringRequest; |
|
732 } |
|
733 #endif |
|
734 else if ( iImplicitJoinDomain && iTrigger->iTriggerType == ERoAcquisitionTrigger ) |
|
735 { |
|
736 iReqMessage = EJoinDomain; |
|
737 } |
|
738 else |
|
739 { |
|
740 User::Leave( KErrRoapUnsupported ); |
|
741 } |
|
742 iCompleted = EFalse; |
|
743 } |
|
744 else |
|
745 { |
|
746 iCompleted = ETrue; |
|
747 } |
|
748 break; |
|
749 } |
|
750 case EROAcquisition: |
|
751 { |
|
752 if ( iImplicitJoinDomain && iTrigger->iTriggerType == ERoAcquisitionTrigger ) |
|
753 { |
|
754 iReqMessage = EJoinDomain; |
|
755 iImplicitJoinDomain = EFalse; |
|
756 iCompleted = EFalse; |
|
757 } |
|
758 else |
|
759 { |
|
760 iCompleted = ETrue; |
|
761 } |
|
762 break; |
|
763 } |
|
764 case EJoinDomain: |
|
765 { |
|
766 if ( iImplicitJoinDomain && iTrigger->iTriggerType == ERoAcquisitionTrigger ) |
|
767 { |
|
768 iReqMessage = EROAcquisition; |
|
769 iImplicitJoinDomain = EFalse; |
|
770 iCompleted = EFalse; |
|
771 } |
|
772 else |
|
773 { |
|
774 iCompleted = ETrue; |
|
775 } |
|
776 break; |
|
777 } |
|
778 #ifdef RD_DRM_METERING |
|
779 case EMeteringRequest: |
|
780 { |
|
781 if ( iTrigger->iTriggerType != EMeteringReportTrigger ) |
|
782 { |
|
783 // PostUrl would be done here? |
|
784 iCompleted = EFalse; |
|
785 } |
|
786 else |
|
787 { |
|
788 iCompleted = ETrue; |
|
789 } |
|
790 break; |
|
791 } |
|
792 #endif |
|
793 default: |
|
794 { |
|
795 iCompleted = ETrue; |
|
796 break; |
|
797 } |
|
798 } |
|
799 if (iCompleted) |
|
800 { |
|
801 LOGLIT( "Completed" ) |
|
802 } |
|
803 else |
|
804 { |
|
805 LOG2(_L ("Next protocol: %d"), iReqMessage) |
|
806 } |
|
807 } |
|
808 |
|
809 // --------------------------------------------------------- |
|
810 // CRoapEngBase::CompleteL() |
|
811 // --------------------------------------------------------- |
|
812 // |
|
813 void CRoapEngBase::CompleteL() |
|
814 { |
|
815 LOGLIT( "CRoapEngBase::CompleteL" ) |
|
816 |
|
817 if ( iCompleted ) |
|
818 { |
|
819 CompleteRequest(); |
|
820 } |
|
821 } |
|
822 |
|
823 |
|
824 // --------------------------------------------------------- |
|
825 // CRoapEngBase::CompleteRequest() |
|
826 // --------------------------------------------------------- |
|
827 // |
|
828 void CRoapEngBase::CompleteRequest() |
|
829 { |
|
830 LOGLIT( "CRoapEngBase::CompleteRequest" ) |
|
831 PERFORMANCE_LOGLIT( "ROAP completed" ) |
|
832 |
|
833 // Complete request |
|
834 iState = EReady; |
|
835 |
|
836 // Delete allocated member variables also here since AcceptL |
|
837 // might be called in retry case without deleting the CRoapEngBase instance |
|
838 delete iRequest; |
|
839 iRequest = NULL; |
|
840 delete iRoapResp; |
|
841 iRoapResp = NULL; |
|
842 delete iResponse; |
|
843 iResponse = NULL; |
|
844 delete iHttpHandler; |
|
845 iHttpHandler = NULL; |
|
846 iReturnedROs.ResetAndDestroy(); |
|
847 delete iDomainRightsResp; |
|
848 iDomainRightsResp = NULL; |
|
849 iImplicitJoinDomain = EFalse; |
|
850 |
|
851 // Notify caller |
|
852 User::RequestComplete( iParentStatus, iResult ); |
|
853 iParentStatus = NULL; |
|
854 } |
|
855 |
|
856 |
|
857 // --------------------------------------------------------- |
|
858 // CRoapEngBase::Continue |
|
859 // --------------------------------------------------------- |
|
860 // |
|
861 void CRoapEngBase::Continue( TRoapState aNextState ) |
|
862 { |
|
863 iState = aNextState; |
|
864 TRequestStatus* ownStatus = &iStatus; |
|
865 *ownStatus = KRequestPending; |
|
866 SetActive(); |
|
867 User::RequestComplete( ownStatus, KErrNone ); |
|
868 } |