19 #include <es_enum_partner.h> |
19 #include <es_enum_partner.h> |
20 #endif |
20 #endif |
21 #include <centralrepository.h> |
21 #include <centralrepository.h> |
22 #include <cdblen.h> |
22 #include <cdblen.h> |
23 |
23 |
24 #ifdef __SERIES60_NATIVE_BROWSER |
|
25 #include <browseruisdkcrkeys.h> |
|
26 #endif |
|
27 |
|
28 #include <cmconnectionmethod.h> |
24 #include <cmconnectionmethod.h> |
29 #include <cmdestination.h> |
25 #include <cmdestination.h> |
30 #include <cmconnectionmethoddef.h> |
26 #include <cmconnectionmethoddef.h> |
31 #include <cmmanager.h> |
27 #include <cmmanager.h> |
32 |
28 |
33 #ifdef RD_MULTIPLE_DRIVE |
29 #ifdef RD_MULTIPLE_DRIVE |
34 #include <driveinfo.h> |
30 #include <driveinfo.h> |
35 #endif |
31 #endif |
36 |
32 |
37 #include <data_caging_path_literals.hrh> |
33 #include <data_caging_path_literals.hrh> |
38 |
|
39 #include <downloadmgrclient.h> |
|
40 |
34 |
41 #include <es_enum.h> // tconnectioninfo |
35 #include <es_enum.h> // tconnectioninfo |
42 #include <es_sock.h> // rconnection rsocket |
36 #include <es_sock.h> // rconnection rsocket |
43 #include <RoapEng.h> |
37 #include <RoapEng.h> |
44 #include <RoapDef.h> |
38 #include <RoapDef.h> |
45 #include <RoapObserver.h> |
39 #include <RoapObserver.h> |
46 #include "RoapSyncWrapper.h" |
40 #include "RoapSyncWrapper.h" |
47 |
41 |
|
42 // Download manager apis |
|
43 #include <qobject.h> |
|
44 #include <downloadmanager.h> |
|
45 #include <download.h> |
|
46 |
48 #include "rohandlerdmgrwrapper.h" |
47 #include "rohandlerdmgrwrapper.h" |
|
48 #include "cleanupresetanddestroy.h" |
|
49 #include "buffercontainers.h" |
|
50 #include "qrohandlerdmgreventhandler.h" |
49 |
51 |
50 #ifdef _DEBUG |
52 #ifdef _DEBUG |
51 #define DRMDEBUG( a ) RDebug::Print( a ) |
53 #define DRMDEBUG( a ) RDebug::Print( a ) |
52 #define DRMDEBUG2( a, b ) RDebug::Print( a, b ) |
54 #define DRMDEBUG2( a, b ) RDebug::Print( a, b ) |
53 #define DRMDEBUG3( a, b, c ) RDebug::Print( a, b, c ) |
55 #define DRMDEBUG3( a, b, c ) RDebug::Print( a, b, c ) |
91 _LIT( KMethDestructor, "~CRoHandlerDMgrWrapper" ); |
93 _LIT( KMethDestructor, "~CRoHandlerDMgrWrapper" ); |
92 //Methods |
94 //Methods |
93 _LIT( KMethConstructL, "ConstructL" ); |
95 _LIT( KMethConstructL, "ConstructL" ); |
94 _LIT( KMethNewL, "NewL" ); |
96 _LIT( KMethNewL, "NewL" ); |
95 _LIT( KMethNewLC, "NewLC" ); |
97 _LIT( KMethNewLC, "NewLC" ); |
96 _LIT( KMethDownloadAndHandleRoapTriggerL, "DownloadAndHandleRoapTriggerL" ); |
|
97 _LIT( KMethDownloadAndHandleRoapTriggerFromPrUrlL, |
|
98 "DownloadAndHandleRoapTriggerFromPrUrlL" ); |
|
99 _LIT( KMethDoDownloadAndHandleRoapTriggerL, |
98 _LIT( KMethDoDownloadAndHandleRoapTriggerL, |
100 "DoDownloadAndHandleRoapTriggerL" ); |
99 "DoDownloadAndHandleRoapTriggerL" ); |
101 _LIT( KFormatDoDlHdlRoapTrigL, "DoDownloadAndHandleRoapTriggerL: %S" ); |
100 _LIT( KFormatDoDlHdlRoapTrigL, "DoDownloadAndHandleRoapTriggerL: %S" ); |
102 _LIT( KStrDlCreated, "download created" ); |
101 _LIT( KStrDlCreated, "download created" ); |
103 _LIT( KStrDlFinished, "download finished" ); |
102 _LIT( KStrDlFinished, "download finished" ); |
104 |
103 |
105 _LIT( KMethSetDefaultAccessPointL, "SetDefaultAccessPointL" ); |
104 _LIT( KMethSetDefaultAccessPointL, "SetDefaultAccessPointL" ); |
106 _LIT( KMiIapId, "iIapId" ); |
|
107 |
105 |
108 _LIT( KMethHandleDMgrEventL, "HandleDMgrEventL" ); |
106 _LIT( KMethHandleDMgrEventL, "HandleDMgrEventL" ); |
109 _LIT( KFormatMethHandleDMgrEventL, "HandleDMgrEventL %S" ); |
107 _LIT( KFormatMethHandleDMgrEventL, "HandleDMgrEventL %S" ); |
110 _LIT( KStrEHttpDlCreated, "EHttpDlCreated" ); |
108 _LIT( KStrEHttpDlCreated, "EHttpDlCreated" ); |
111 _LIT( KStrEHttpContentTypeReceived, "EHttpContentTypeReceived" ); |
109 _LIT( KStrEHttpContentTypeReceived, "EHttpContentTypeReceived" ); |
133 //#define LOG( a ) |
130 //#define LOG( a ) |
134 //#define LOGHEX( ptr, len ) |
131 //#define LOGHEX( ptr, len ) |
135 //#define LOG2( a, b ) |
132 //#define LOG2( a, b ) |
136 #endif |
133 #endif |
137 |
134 |
138 #ifndef __SERIES60_NATIVE_BROWSER |
|
139 const TUid KCRUidBrowser = |
|
140 {0x10008D39}; |
|
141 const TUint32 KBrowserDefaultAccessPoint = 0x0000000E; |
|
142 const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E; |
|
143 const TUint32 KBrowserNGDefaultSnapId = 0x00000053; |
|
144 #endif |
|
145 |
|
146 // CONSTANTS |
135 // CONSTANTS |
147 #ifndef RD_MULTIPLE_DRIVE |
136 #ifndef RD_MULTIPLE_DRIVE |
148 _LIT( KHelperTriggerFilePath, "d:\\" ); |
137 _LIT( KHelperTriggerFilePath, "d:\\" ); |
149 #endif |
138 #endif |
150 |
139 |
151 // ============================== LOCAL FUNCTIONS ============================== |
140 using namespace WRT; |
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // DoResetAndDestroy |
|
155 // Does RPointerArray< typename >->ResetAndDestroy() for the given array aPtr. |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 template< typename elemType > |
|
159 LOCAL_C void DoResetAndDestroy( TAny* aPtr ) |
|
160 { |
|
161 ( reinterpret_cast< RPointerArray< elemType >* >( aPtr ) )-> |
|
162 ResetAndDestroy(); |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // DeleteHttpDowload |
|
167 // --------------------------------------------------------------------------- |
|
168 // |
|
169 LOCAL_C void DeleteHttpDowload( TAny* aDownload ) |
|
170 { |
|
171 reinterpret_cast< RHttpDownload* >( aDownload )->Delete(); |
|
172 } |
|
173 |
141 |
174 // --------------------------------------------------------------------------- |
142 // --------------------------------------------------------------------------- |
175 // UpdateBufferL |
143 // UpdateBufferL |
176 // --------------------------------------------------------------------------- |
144 // --------------------------------------------------------------------------- |
177 // |
145 // |
315 Continue( EMeteringReportSubmit, KErrNone ); |
254 Continue( EMeteringReportSubmit, KErrNone ); |
316 iWait.Start(); |
255 iWait.Start(); |
317 } |
256 } |
318 |
257 |
319 // --------------------------------------------------------------------------- |
258 // --------------------------------------------------------------------------- |
320 // CRoHandlerDMgrWrapper::DownloadAndHandleRoapTriggerL |
|
321 // --------------------------------------------------------------------------- |
|
322 // |
|
323 void CRoHandlerDMgrWrapper::DownloadAndHandleRoapTriggerL( const HBufC8* aUrl ) |
|
324 { |
|
325 DRMDEBUGMETHOD( |
|
326 RoHdlrDMgrWrDebugLiterals::KMethDownloadAndHandleRoapTriggerL() ); |
|
327 if ( iState != EInit || iWait.IsStarted() ) |
|
328 { |
|
329 User::Leave( KErrNotReady ); |
|
330 } |
|
331 |
|
332 UpdateBufferL< HBufC8, TDesC8 >( iTriggerUrl, *aUrl ); |
|
333 Continue( EGetMeteringTrigger, KErrNone ); |
|
334 iWait.Start(); |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // CRoHandlerDMgrWrapper::DownloadAndHandleRoapTriggerFromPrUrlL |
|
339 // --------------------------------------------------------------------------- |
|
340 // |
|
341 void CRoHandlerDMgrWrapper::DownloadAndHandleRoapTriggerFromPrUrlL( |
|
342 const HBufC8* aUrl ) |
|
343 { |
|
344 DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethDownloadAndHandleRoapTriggerFromPrUrlL() ); |
|
345 if ( iState != EInit || iWait.IsStarted() ) |
|
346 { |
|
347 User::Leave( KErrNotReady ); |
|
348 } |
|
349 |
|
350 UpdateBufferL< HBufC8, TDesC8 >( iTriggerUrl, *aUrl ); |
|
351 Continue( EGetPrUrlTrigger, KErrNone ); |
|
352 iWait.Start(); |
|
353 } |
|
354 |
|
355 // --------------------------------------------------------------------------- |
|
356 // CRoHandlerDMgrWrapper::DoDownloadRoapTriggerL |
259 // CRoHandlerDMgrWrapper::DoDownloadRoapTriggerL |
357 // --------------------------------------------------------------------------- |
260 // --------------------------------------------------------------------------- |
358 // |
261 // |
359 void CRoHandlerDMgrWrapper::DoDownloadRoapTriggerL( TMeterState aNextState ) |
262 void CRoHandlerDMgrWrapper::DoDownloadRoapTriggerL( TMeterState aNextState ) |
360 { |
263 { |
361 RFile roapTrigger; |
264 RFile roapTrigger; |
362 TBool result( EFalse ); |
265 DRM::CFileNameContainer* triggerFileName(NULL); |
363 TFileName triggerFileName; |
|
364 |
266 |
365 DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethDoDownloadAndHandleRoapTriggerL() ); |
267 DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethDoDownloadAndHandleRoapTriggerL() ); |
366 // If no Trigger URL then nothing to download. So finish transaction |
268 // If no Trigger URL then nothing to download. So finish transaction |
367 if ( !iTriggerUrl || iTriggerUrl->Length() <= 0 ) |
269 if ( !iTriggerUrl || iTriggerUrl->Length() <= 0 ) |
368 { |
270 { |
369 Continue( EComplete, KErrNone ); |
271 Continue( EComplete, KErrNone ); |
370 return; |
272 return; |
371 } |
273 } |
372 |
274 |
|
275 triggerFileName=DRM::CFileNameContainer::NewLC(); |
373 #ifndef RD_MULTIPLE_DRIVE |
276 #ifndef RD_MULTIPLE_DRIVE |
374 |
277 |
375 User::LeaveIfError( roapTrigger.Temp( |
278 User::LeaveIfError( roapTrigger.Temp( |
376 iFs, KHelperTriggerFilePath, triggerFileName, EFileWrite ) ); |
279 iFs, KHelperTriggerFilePath, triggerFileName->iBuffer, EFileWrite ) ); |
377 |
280 |
378 #else //RD_MULTIPLE_DRIVE |
281 #else //RD_MULTIPLE_DRIVE |
379 _LIT( KDrive, "%c:\\" ); |
282 _LIT( KDrive, "%c:\\" ); |
380 TInt driveNumber( -1 ); |
283 TInt driveNumber( -1 ); |
381 TChar driveLetter; |
284 TChar driveLetter; |
382 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRam, driveNumber ); |
285 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRam, driveNumber ); |
383 iFs.DriveToChar( driveNumber, driveLetter ); |
286 iFs.DriveToChar( driveNumber, driveLetter ); |
384 |
287 |
385 TFileName helperTriggerFilePath; |
288 DRM::CFileNameContainer* |
386 |
289 helperTriggerFilePath( DRM::CFileNameContainer::NewLC() ); |
387 helperTriggerFilePath.Format( KDrive, ( TUint )driveLetter ); |
290 |
388 |
291 helperTriggerFilePath->iBuffer.Format( KDrive, ( TUint )driveLetter ); |
389 User::LeaveIfError( roapTrigger.Temp( iFs, helperTriggerFilePath, |
292 |
390 triggerFileName, EFileWrite ) ); |
293 User::LeaveIfError( roapTrigger.Temp( iFs, helperTriggerFilePath->iBuffer, |
|
294 triggerFileName->iBuffer, EFileWrite ) ); |
|
295 CleanupStack::PopAndDestroy( helperTriggerFilePath ); |
|
296 helperTriggerFilePath=NULL; |
391 |
297 |
392 #endif |
298 #endif |
393 UpdateBufferL< HBufC, TFileName >( iFileName, triggerFileName ); |
299 UpdateBufferL< HBufC, TFileName >( iFileName, triggerFileName->iBuffer ); |
394 |
300 CleanupStack::PopAndDestroy( triggerFileName ); |
395 // create and start download |
301 triggerFileName=NULL; |
396 RHttpDownload& download = iDlMgr.CreateDownloadL( *iTriggerUrl, result ); |
302 |
397 // Put download for proper cleanup. |
303 try |
398 TCleanupItem item( DeleteHttpDowload, &download ); |
304 { |
399 CleanupStack::PushL( item ); |
305 // create and start download |
400 |
306 QString downloadUrl((QChar*)iTriggerUrl->Des().Ptr(),iTriggerUrl->Length()); |
|
307 iDownload = iDlMgr->createDownload( downloadUrl ); |
|
308 iRoHandlerDMgrEventHandler = q_check_ptr(new QRoHandlerDMgrEventHandler(*this, *iDownload)); |
|
309 } |
|
310 catch(const std::exception& exception) |
|
311 { |
|
312 qt_symbian_exception2LeaveL(exception); |
|
313 } |
|
314 |
401 CleanupClosePushL( roapTrigger ); |
315 CleanupClosePushL( roapTrigger ); |
402 |
316 |
403 if ( result ) |
317 |
404 { |
318 DRMDEBUG2( |
405 DRMDEBUG2( |
319 RoHdlrDMgrWrDebugLiterals::KFormatDoDlHdlRoapTrigL(), |
406 RoHdlrDMgrWrDebugLiterals::KFormatDoDlHdlRoapTrigL(), |
320 &RoHdlrDMgrWrDebugLiterals::KStrDlCreated() ); |
407 &RoHdlrDMgrWrDebugLiterals::KStrDlCreated() ); |
321 iDownloadSuccess = EFalse; |
408 iDownloadSuccess = EFalse; |
322 iConnectionError = EFalse; |
409 iConnectionError = EFalse; |
323 |
410 |
324 SetDefaultAccessPointL(); |
411 SetDefaultAccessPointL(); |
325 |
412 User::LeaveIfError( download.SetFileHandleAttribute( roapTrigger ) ); |
326 try |
413 User::LeaveIfError( download.SetBoolAttribute( |
327 { |
414 EDlAttrNoContentTypeCheck, ETrue ) ); |
328 RBuf fileName; |
415 User::LeaveIfError( download.Start() ); |
329 User::LeaveIfError(fileName.Create(KMaxFileName)); |
416 |
330 CleanupClosePushL(fileName); |
417 // wait until download is finished |
331 roapTrigger.Name(fileName); |
418 iState = aNextState; |
332 const QVariant& roapTriggerValue( QString((QChar*) fileName.Ptr(), fileName.Length()) ); |
419 TRequestStatus* status( &iStatus ); |
333 CleanupStack::PopAndDestroy(&fileName); |
420 *status = KRequestPending; |
334 iDownload->setAttribute(FileName,roapTriggerValue); |
421 SetActive(); |
335 const QVariant& val(ETrue); |
422 } |
336 iDownload->setAttribute(ContentType, val); |
|
337 iDownload->start(); |
|
338 } |
|
339 catch(const std::exception& exception) |
|
340 { |
|
341 qt_symbian_exception2LeaveL(exception); |
|
342 } |
|
343 |
|
344 // wait until download is finished |
|
345 iState = aNextState; |
|
346 TRequestStatus* status( &iStatus ); |
|
347 *status = KRequestPending; |
|
348 SetActive(); |
|
349 |
423 CleanupStack::PopAndDestroy( &roapTrigger ); |
350 CleanupStack::PopAndDestroy( &roapTrigger ); |
424 CleanupStack::Pop( &download ); // Left open for DoSaveRoapTrigger |
|
425 } |
351 } |
426 // --------------------------------------------------------------------------- |
352 // --------------------------------------------------------------------------- |
427 // CRoHandlerDMgrWrapper::DoSaveRoapTriggerL |
353 // CRoHandlerDMgrWrapper::DoSaveRoapTriggerL |
428 // --------------------------------------------------------------------------- |
354 // --------------------------------------------------------------------------- |
429 // |
355 // |
533 // CRoHandlerDMgrWrapper::SetDefaultAccessPointL |
464 // CRoHandlerDMgrWrapper::SetDefaultAccessPointL |
534 // --------------------------------------------------------------------------- |
465 // --------------------------------------------------------------------------- |
535 // |
466 // |
536 void CRoHandlerDMgrWrapper::SetDefaultAccessPointL() |
467 void CRoHandlerDMgrWrapper::SetDefaultAccessPointL() |
537 { |
468 { |
538 const TInt KDestinationSelectionMode( 2 ); |
|
539 CRepository* repository( NULL ); |
|
540 TInt ap( 0 ); |
|
541 TInt alwaysAsk( 0 ); |
|
542 TUint32 iapd32( 0 ); |
|
543 TInt defaultSnap( 0 ); |
|
544 TInt err( KErrNone ); |
|
545 |
|
546 DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethSetDefaultAccessPointL() ); |
469 DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethSetDefaultAccessPointL() ); |
547 |
470 |
548 if ( !iIapId ) |
471 if ( iIapId ) |
549 { |
472 { |
550 repository = CRepository::NewL( KCRUidBrowser ); |
473 QVariant iapId((unsigned long long)iIapId); |
551 CleanupStack::PushL( repository ); |
474 iDlMgr->setAttribute(DefaultDestinationPath, iapId); |
552 repository->Get( KBrowserDefaultAccessPoint, ap ); |
|
553 repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk ); |
|
554 repository->Get( KBrowserNGDefaultSnapId, defaultSnap ); |
|
555 if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound ) |
|
556 { |
|
557 alwaysAsk = ETrue; |
|
558 } |
|
559 else |
|
560 { |
|
561 RCmManager cmManager; |
|
562 cmManager.OpenLC(); |
|
563 if ( !alwaysAsk ) |
|
564 { |
|
565 TRAP( err, iapd32 = cmManager.GetConnectionMethodInfoIntL( |
|
566 ap, CMManager::ECmIapId ) ); |
|
567 } |
|
568 else if ( alwaysAsk == KDestinationSelectionMode ) |
|
569 { |
|
570 TRAP( err, iapd32 = IapIdOfDefaultSnapL( |
|
571 cmManager, defaultSnap ) ); |
|
572 } |
|
573 CleanupStack::PopAndDestroy( &cmManager ); |
|
574 } |
|
575 if ( !err && ( !alwaysAsk || alwaysAsk == KDestinationSelectionMode ) ) |
|
576 { |
|
577 iIapId = iapd32; |
|
578 DRMDEBUG3( RoHdlrDMgrWrDebugLiterals::KFormatMembValInt(), |
|
579 &RoHdlrDMgrWrDebugLiterals::KMiIapId(), iIapId ); |
|
580 err = iDlMgr.SetIntAttribute( EDlMgrIap, iapd32 ); |
|
581 } |
|
582 CleanupStack::PopAndDestroy( repository ); |
|
583 } |
|
584 else |
|
585 { |
|
586 err = iDlMgr.SetIntAttribute( EDlMgrIap, iIapId ); |
|
587 } |
475 } |
588 } |
476 } |
589 |
477 |
590 // --------------------------------------------------------------------------- |
478 // --------------------------------------------------------------------------- |
591 // CRoHandlerDMgrWrapper::Continue |
479 // CRoHandlerDMgrWrapper::Continue |
606 |
494 |
607 // --------------------------------------------------------------------------- |
495 // --------------------------------------------------------------------------- |
608 // CRoHandlerDMgrWrapper::HandleDMgrEventL |
496 // CRoHandlerDMgrWrapper::HandleDMgrEventL |
609 // --------------------------------------------------------------------------- |
497 // --------------------------------------------------------------------------- |
610 // |
498 // |
611 void CRoHandlerDMgrWrapper::HandleDMgrEventL( RHttpDownload& aDownload, |
499 void CRoHandlerDMgrWrapper::HandleDownloadEventL( WRT::DownloadEvent* aEvent ) |
612 THttpDownloadEvent aEvent ) |
500 { |
613 { |
501 QString KDRMHelperMimeTypeROAPTrigger("application/vnd.oma.drm.roap-trigger+xml" ); |
614 _LIT8( KDRMHelperMimeTypeROAPTrigger, "application/vnd.oma.drm.roap-trigger+xml" ); |
|
615 |
502 |
616 DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethHandleDMgrEventL() ); |
503 DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethHandleDMgrEventL() ); |
617 DRMDEBUG3( RoHdlrDMgrWrDebugLiterals::KFormatMembValInt(), |
504 DRMDEBUG3( RoHdlrDMgrWrDebugLiterals::KFormatMembValInt(), |
618 &RoHdlrDMgrWrDebugLiterals::KMiDownLoadState(), aEvent.iDownloadState ); |
505 &RoHdlrDMgrWrDebugLiterals::KMiState(), aEvent->type() ); |
619 DRMDEBUG3( RoHdlrDMgrWrDebugLiterals::KFormatMembValInt(), |
506 |
620 &RoHdlrDMgrWrDebugLiterals::KMiProgressState(), aEvent.iProgressState ); |
507 if ( aEvent->type() == DownloadEvent::HeadersReceived ) |
621 |
|
622 if ( aEvent.iProgressState == EHttpContentTypeReceived ) |
|
623 { |
508 { |
624 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
509 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
625 &RoHdlrDMgrWrDebugLiterals::KStrEHttpContentTypeReceived() ); |
510 &RoHdlrDMgrWrDebugLiterals::KStrEHttpContentTypeReceived() ); |
626 // check received mimetype |
511 // check received mimetype |
627 RBuf8 contentType; |
512 QString contentType = iDownload->attribute( ContentType).toString(); |
628 contentType.CleanupClosePushL(); |
513 if ( contentType.contains( KDRMHelperMimeTypeROAPTrigger ) == EFalse ) |
629 contentType.CreateL( KMaxContentTypeLength ); |
|
630 User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrContentType, |
|
631 contentType ) ); |
|
632 if ( !contentType.FindF( KDRMHelperMimeTypeROAPTrigger ) ) |
|
633 { |
514 { |
634 // ROAP trigger found, continue download |
515 // ROAP trigger found, continue download |
635 User::LeaveIfError( aDownload.Start() ); |
516 iDownload->start(); |
636 } |
517 } |
637 else |
518 else |
638 { |
519 { |
639 // wrong MIME type?, stop download |
520 // wrong MIME type?, stop download |
640 iDownloadSuccess = EFalse; |
521 iDownloadSuccess = EFalse; |
641 User::LeaveIfError( aDownload.Delete() ); |
522 iDownload->cancel(); |
642 } |
523 } |
643 CleanupStack::PopAndDestroy( &contentType ); |
524 CleanupStack::PopAndDestroy( &contentType ); |
644 } |
525 } |
645 |
526 |
646 if ( aEvent.iDownloadState == EHttpDlCreated ) |
527 if ( aEvent->type() == DownloadEvent::Created ) |
647 { |
528 { |
648 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
529 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
649 &RoHdlrDMgrWrDebugLiterals::KStrEHttpDlCreated() ); |
530 &RoHdlrDMgrWrDebugLiterals::KStrEHttpDlCreated() ); |
650 } |
531 } |
651 else |
532 else |
652 if ( aEvent.iProgressState == EHttpProgDisconnected ) |
533 if ( aEvent->type() == DownloadEvent::NetworkLoss ) |
653 { |
534 { |
654 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
535 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
655 &RoHdlrDMgrWrDebugLiterals::KStrEHttpProgDisconnected() ); |
536 &RoHdlrDMgrWrDebugLiterals::KStrEHttpProgDisconnected() ); |
656 // store failure |
537 // store failure |
657 iDownloadSuccess = EFalse; |
538 iDownloadSuccess = EFalse; |
658 iConnectionError = ETrue; |
539 iConnectionError = ETrue; |
659 // finished |
540 // finished |
660 TRequestStatus* status( &iStatus ); |
541 TRequestStatus* status( &iStatus ); |
661 User::RequestComplete( status, KErrCancel ); |
542 User::RequestComplete( status, KErrCancel ); |
662 } |
543 } |
663 else |
544 else |
664 if ( aEvent.iDownloadState == EHttpDlInprogress ) |
545 if ( aEvent->type() == DownloadEvent::InProgress ) |
665 { |
546 { |
666 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
547 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
667 &RoHdlrDMgrWrDebugLiterals::KStrEHttpDlInprogress() ); |
548 &RoHdlrDMgrWrDebugLiterals::KStrEHttpDlInprogress() ); |
668 } |
549 } |
669 else |
550 else |
670 if ( aEvent.iDownloadState == EHttpDlCompleted ) |
551 if ( aEvent->type() == DownloadEvent::Completed ) |
671 { |
552 { |
672 // store success |
553 // store success |
673 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
554 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
674 &RoHdlrDMgrWrDebugLiterals::KStrEHttpDlCompleted() ); |
555 &RoHdlrDMgrWrDebugLiterals::KStrEHttpDlCompleted() ); |
675 iDownloadSuccess = ETrue; |
556 iDownloadSuccess = ETrue; |
676 |
557 |
677 // finished |
558 // finished |
678 TRequestStatus* status( &iStatus ); |
559 TRequestStatus* status( &iStatus ); |
679 User::RequestComplete( status, KErrNone ); |
560 User::RequestComplete( status, KErrNone ); |
680 } |
561 } |
681 else |
562 else |
682 if ( aEvent.iDownloadState == EHttpDlFailed ) |
563 if ( aEvent->type() == DownloadEvent::Failed ) |
683 { |
564 { |
684 TInt32 err; |
565 TInt32 err; |
685 |
566 |
686 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
567 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
687 &RoHdlrDMgrWrDebugLiterals::KStrEHttpDlFailed() ); |
568 &RoHdlrDMgrWrDebugLiterals::KStrEHttpDlFailed() ); |
688 // store failure |
569 // store failure |
689 iDownloadSuccess = EFalse; |
570 iDownloadSuccess = EFalse; |
690 User::LeaveIfError( aDownload.GetIntAttribute( |
571 err = iDownload->attribute(LastError ).toInt(); |
691 EDlAttrErrorId, err ) ); |
572 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatEDlAttrErrorId(), err ); |
692 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatEDlAttrErrorId(), err ); |
573 |
693 |
574 if ( err == ConnectionFailed || err == TransactionFailed ) |
694 if ( err == EConnectionFailed || err |
575 { |
695 == ETransactionFailed ) |
576 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
696 { |
577 &RoHdlrDMgrWrDebugLiterals::KStrEConnectionFailed() ); |
697 DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(), |
578 iConnectionError = ETrue; |
698 &RoHdlrDMgrWrDebugLiterals::KStrEConnectionFailed() ); |
579 } |
699 iConnectionError = ETrue; |
580 |
700 } |
581 // finished |
701 |
582 TRequestStatus* status( &iStatus ); |
702 // finished |
583 User::RequestComplete( status, KErrCancel ); |
703 TRequestStatus* status( &iStatus ); |
584 } |
704 User::RequestComplete( status, KErrCancel ); |
|
705 } |
|
706 } |
585 } |
707 |
586 |
708 |
587 |
709 // RoapObserver methods |
588 // RoapObserver methods |
710 |
589 |