diff -r 1221b68b8a5f -r 1481bf457703 commondrm/drmutility/src/DrmUiHandlingImpl.cpp --- a/commondrm/drmutility/src/DrmUiHandlingImpl.cpp Tue Aug 31 15:29:38 2010 +0300 +++ b/commondrm/drmutility/src/DrmUiHandlingImpl.cpp Wed Sep 01 12:21:16 2010 +0100 @@ -17,6 +17,13 @@ // INCLUDE FILES +// connection +#include +#include +#include +#include +#include +#include // publish & subscribe #include @@ -29,6 +36,11 @@ #include #include +// browser +#ifdef __SERIES60_NATIVE_BROWSER +#include +#endif + // caf #include #include @@ -45,6 +57,9 @@ // character conversions #include +// handling urls +#include + // resources #include #include @@ -59,14 +74,6 @@ #include #include #include -#include - -//connectivity logic -#include // RCmConnectionMethod -#include // RCmDestination -#include // RCmManager - - #ifdef _DEBUG #include @@ -89,7 +96,6 @@ #include "DRMDomainContext.h" #include "DrmUtilityInternalcrkeys.h" // Cenrep extension for OmaBased -#include "drmuidialogids.h" // CONSTANTS const TInt KCommandHandleErrorFile( 1 ); @@ -102,6 +108,14 @@ const TInt KCommandHandleUrlData( 8 ); const TInt KCommandAvailableUrlsFile( 9 ); const TInt KCommandAvailableUrlsData( 10 ); +// browser +#ifndef __SERIES60_NATIVE_BROWSER +const TUid KCRUidBrowser = + {0x10008D39}; +const TUint32 KBrowserDefaultAccessPoint = 0x0000000E; +const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E; +const TUint32 KBrowserNGDefaultSnapId = 0x00000053; +#endif _LIT( KEncryptedRightsIssuerMatchString, "flk*" ); @@ -122,8 +136,6 @@ const TInt KresOmaBasedBuf( 512 ); const TInt KNameBuf( 256 ); -const TInt KNoValue = -1; - #ifdef _DEBUG // debug panic _LIT( KDRMUtilityDebugPanicMessage, "DrmUiHandlingDebugPanic" ); @@ -132,67 +144,6 @@ // ============================= LOCAL FUNCTIONS =============================== // ----------------------------------------------------------------------------- -// HasDefaultConnectionL -// Finds default IAP id -// @return Etrue: valid AP found -// EFalse: valid AP not found -// @leave system wide error codes -// ----------------------------------------------------------------------------- -// -LOCAL_C TBool HasDefaultConnectionL() - { - TBool hasDefault(EFalse); - TCmDefConnValue defConn; - RCmManager cmManager; - cmManager.OpenLC(); - cmManager.ReadDefConnL(defConn); - if (defConn.iType == ECmDefConnConnectionMethod) - { - cmManager.GetConnectionMethodInfoIntL(defConn.iId, - CMManager::ECmIapId); - hasDefault = ETrue; - } - else if (defConn.iType == ECmDefConnDestination) - { - RCmDestination dest(cmManager.DestinationL(defConn.iId)); - CleanupClosePushL(dest); - - if (dest.ConnectionMethodCount() <= 0) - { - User::Leave(KErrNotFound); - } - - RCmConnectionMethod cMeth(dest.ConnectionMethodL(0)); - CleanupClosePushL(cMeth); - - cMeth.GetIntAttributeL(CMManager::ECmIapId); - CleanupStack::PopAndDestroy(&cMeth); - CleanupStack::PopAndDestroy(&dest); - hasDefault = ETrue; - } - CleanupStack::PopAndDestroy(&cmManager); - return hasDefault; - } - -// ----------------------------------------------------------------------------- -// HasAccessPointsL -// ----------------------------------------------------------------------------- -// -LOCAL_C TBool HasAccessPointsL() - { - TInt apCount(0); - RCmManager cmManager; - CleanupClosePushL(cmManager); - cmManager.OpenL(); - RArray aps; - CleanupClosePushL(aps); - cmManager.ConnectionMethodL(aps, EFalse, EFalse, ETrue); - apCount = aps.Count(); - CleanupStack::PopAndDestroy(2, &cmManager); //aps, cmManager - return apCount > 0; - } - -// ----------------------------------------------------------------------------- // MapToCallError // ----------------------------------------------------------------------------- // @@ -207,16 +158,30 @@ } // ----------------------------------------------------------------------------- -// HasDefConn +// IapIdOfDefaultSnapL +// for trapping purposes only // ----------------------------------------------------------------------------- // -inline TBool HasDefConn() +LOCAL_C TUint32 IapIdOfDefaultSnapL( + RCmManager& aCmManager, + const TUint32 aDefaultSnap ) { - TBool found( EFalse ); - - TRAP_IGNORE( found = HasDefaultConnectionL() ); - - return found; + RCmDestination dest( aCmManager.DestinationL( aDefaultSnap ) ); + CleanupClosePushL( dest ); + TUint32 iapIdOfDest( 0 ); + + if ( dest.ConnectionMethodCount() <= 0 ) + { + User::Leave( KErrNotFound ); + } + + RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) ); + CleanupClosePushL( cMeth ); + + iapIdOfDest = cMeth.GetIntAttributeL( CMManager::ECmIapId ); + CleanupStack::PopAndDestroy( &cMeth ); + CleanupStack::PopAndDestroy( &dest ); + return iapIdOfDest; } // --------------------------------------------------------- @@ -437,6 +402,8 @@ delete iDrmUtilityUi; + delete iSchemeHandler; + delete iWrapperLoader; delete iOmaBasedAgentName; @@ -1836,8 +1803,8 @@ TBool onlyMeteringRejection( reason == DRM::EURejectionMetering ); if ( onlyMeteringRejection ) { - // Qt dialog not implemented yet - iDrmUtilityUi->DisplayNoteL( EConfUnableToOpen ); + iDrmUtilityUi->DisplayQueryWithIdL( R_DRM_QUERY_METERING_DISABLED, + R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY ); CleanupStack::PopAndDestroy( contentId ); return; @@ -2968,8 +2935,9 @@ if ( RejectReason( aReason ) == DRM::EURejectionMetering ) { // Show that only reason for error was rejected metering. - // Qt dialog not implemented yet - iDrmUtilityUi->DisplayNoteL( EConfUnableToOpen ); + iDrmUtilityUi->DisplayQueryWithIdL( + R_DRM_QUERY_METERING_DISABLED, + R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY ); } else { @@ -3490,7 +3458,7 @@ HBufC* etaBuf( NULL ); TBool isRegistered( EFalse ); TBool isJoined( EFalse ); - TInt ret( ECancelled ); + TInt ret( 0 ); TInt err( KErrNone ); TInt eta( 0 ); TFileName fileName; @@ -3516,13 +3484,16 @@ // rights should have come already if ( aRightsUrl ) { - ret = iDrmUtilityUi->DisplayQueryL( EQueryGetNewLicence, KNoValue ); + ret = iDrmUtilityUi->DisplayQueryWithIdL( + R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME, + R_DRMUTILITY_CONFIRMATION_QUERY ); } else { // no rights issuer - // Qt dialog not implemented yet - iDrmUtilityUi->DisplayNoteL( EConfLicenceNotReceived ); + iDrmUtilityUi->DisplayQueryWithIdL( + R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME_NO_RI, + R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY ); } } else if ( !eta || err || eta == -1 ) @@ -3536,13 +3507,17 @@ if ( aRightsUrl && isRegistered && !isJoined ) // Domain ro case { - ret = iDrmUtilityUi->DisplayQueryL( EQueryAccountUpdate, KNoValue ); + ret = iDrmUtilityUi->DisplayQueryWithIdL( + R_DRMUTILITY_ACTIVATE_ACCOUNT, + R_DRMUTILITY_CONFIRMATION_QUERY ); } else if ( aRightsUrl ) // Device ro case { if ( aReason & EConstraintIndividual ) { - ret = iDrmUtilityUi->DisplayQueryL( EQueryFileLockedForSim, KNoValue ); + ret = iDrmUtilityUi->DisplayQueryWithIdL( + R_DRMUTILITY_INVALID_SIM, + R_DRMUTILITY_CONFIRMATION_QUERY ); } else { @@ -3550,20 +3525,19 @@ User::LeaveIfError( aContent.GetStringAttribute( EFileName, fileName ) ); - // Qt dialog not implemented yet - ret = iDrmUtilityUi->DisplayQueryL( EQueryFileWithNoRightsObj, fileName ); + ret = iDrmUtilityUi->DisplayQueryL( + R_DRM_QUERY_EXPIRED_OR_NO_RO, fileName ); } } else // no rights issuer { if ( aReason & EConstraintIndividual ) { - // Qt dialog not implemented yet - iDrmUtilityUi->DisplayNoteL( EConfFileLockedForSim ); + iDrmUtilityUi->DisplayNoteL( R_DRM_INFO_SIM_NOT_ALLOWED ); } else { - iDrmUtilityUi->DisplayNoteL( EConfLicenceExpired ); + iDrmUtilityUi->DisplayNoteL( R_DRM_INFO_EXPIRED_OR_NO_RO ); } } } @@ -3573,25 +3547,31 @@ if ( eta != KErrCAPendingRights ) { // rights expected to arrive in eta seconds - iDrmUtilityUi->DisplayNoteL( EConfWaitingForLicence ); + iDrmUtilityUi->DisplayQueryWithIdL( + R_DRMUTILITY_WAITING_FOR_RIGHTS, + R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY ); } else { // rights should have come if ( aRightsUrl ) { - ret = iDrmUtilityUi->DisplayQueryL( EQueryGetNewLicence, KNoValue ); + ret = iDrmUtilityUi->DisplayQueryWithIdL( + R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME, + R_DRMUTILITY_CONFIRMATION_QUERY ); } else { // no rights issuer - // Qt dialog not implemented yet - iDrmUtilityUi->DisplayNoteL( EConfLicenceNotReceived ); + iDrmUtilityUi->DisplayQueryWithIdL( + R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME_NO_RI, + R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY ); } } } } - if ( ret == EOk ) + + if ( ret == EAknSoftkeyYes || ret == EAknSoftkeyOk ) { rightsRenewalWanted = ETrue; } @@ -4070,11 +4050,25 @@ ptrc.Set( *newUrl ); } - CDrmBrowserLauncher* browserLauncher = CDrmBrowserLauncher::NewLC(); - - browserLauncher->LaunchUrlL(ptrc); - - CleanupStack::PopAndDestroy(); // browserLauncher + CSchemeHandler* schemeHandler( CSchemeHandler::NewL( ptrc ) ); + CleanupStack::PushL( schemeHandler ); + if ( iCoeEnv ) + { + embeddedLaunch = ETrue; + // launch embedded + schemeHandler->Observer( this ); + schemeHandler->HandleUrlEmbeddedL(); + CleanupStack::Pop( schemeHandler ); + iSchemeHandler = schemeHandler; + iWait.Start(); + } + else + { + // no CoeEnv, launch standalone with scheme app + schemeHandler->HandleUrlStandaloneL(); + CleanupStack::PopAndDestroy( schemeHandler ); + } + schemeHandler = NULL; // delete newUrl if needed if ( newUrl ) @@ -4093,38 +4087,39 @@ const TBool aShowNotes ) { TInt r( KErrCancel ); - TInt buttonCode( EOk ); + TInt buttonCode( EAknSoftkeyYes ); HBufC8* url( NULL ); if ( !SilentRightsAllowedL() ) { - buttonCode = ECancelled; + buttonCode = EAknSoftkeyNo; if ( aShowNotes ) { - // Qt dialog not implemented yet - buttonCode = iDrmUtilityUi->DisplayQueryL( EQueryConnectToActivate, KNoValue ); + buttonCode = iDrmUtilityUi->DisplayQueryWithIdL( + R_DRM_QRY_CONNECT_TO_ACTIVATE, + R_DRMUTILITY_CONFIRMATION_QUERY ); } } - else if ( !(HasDefConn()) ) + else if ( !BrowserAPDefinedL() ) { - buttonCode = ECancelled; + buttonCode = EAknSoftkeyNo; if ( aShowNotes ) { - // Qt dialog not implemented yet - buttonCode = iDrmUtilityUi->DisplayQueryL( EQueryConnectToActivate, KNoValue ); + buttonCode = iDrmUtilityUi->DisplayQueryWithIdL( + R_DRM_QRY_CONNECT_TO_ACTIVATE, + R_DRMUTILITY_CONFIRMATION_QUERY ); } } - if ( buttonCode == EOk ) + if ( buttonCode == EAknSoftkeyYes || buttonCode == EAknSoftkeyOk ) { - TBool APs( HasAccessPointsL() ); + TInt APs( APCountL() ); if ( !APs ) { // No AP defined if ( aShowNotes ) { - // Qt dialog not implemented yet - iDrmUtilityUi->DisplayNoteL( EConfNoAccessPoint ); + iDrmUtilityUi->DisplayNoteL( R_DRM_WARN_NO_CONN_DEFINED ); } r = KErrCANoRights; } @@ -4158,8 +4153,8 @@ // Connection failed with selected AP if ( aShowNotes ) { - // Qt dialog not implemented yet - iDrmUtilityUi->DisplayNoteL( EConfConnectionFailed ); + iDrmUtilityUi->DisplayNoteL( + R_DRM_WARN_INVALID_OR_NO_AP ); } r = KErrCANoRights; } @@ -4176,10 +4171,13 @@ if ( errorUrl ) { // ask user whether error url should be opened - // Qt dialog not implemented yet - buttonCode = iDrmUtilityUi->DisplayQueryL( EQueryOpenErrorUrl, KNoValue ); - - if ( buttonCode == EOk ) + buttonCode + = iDrmUtilityUi->DisplayQueryWithIdL( + R_DRM_QUERY_OPEN_ERROR_URL, + R_DRMUTILITY_CONFIRMATION_QUERY ); + + if ( buttonCode == EAknSoftkeyYes + || buttonCode == EAknSoftkeyOk ) { // Launch browser LaunchBrowserL( errorUrl ); @@ -4187,8 +4185,8 @@ } else { - // Qt dialog not implemented yet - iDrmUtilityUi->DisplayNoteL( EConfUnableToUnlock ); + iDrmUtilityUi->DisplayNoteL( + R_DRM_ERR_OPENING_FAIL_PERM ); } CleanupStack::PopAndDestroy( errorUrl ); } @@ -4215,16 +4213,84 @@ } // ----------------------------------------------------------------------------- +// CDrmUiHandlingImpl::BrowserAPDefinedL +// ----------------------------------------------------------------------------- +// +TBool DRM::CDrmUiHandlingImpl::BrowserAPDefinedL() + { + const TInt KDestinationSelectionMode( 2 ); + TInt err( KErrNone ); + TInt ap( 0 ); + TInt alwaysAsk( 0 ); + TInt defaultSnap( 0 ); + + CRepository* repository( CRepository::NewL( KCRUidBrowser ) ); + repository->Get( KBrowserDefaultAccessPoint, ap ); + repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk ); + repository->Get( KBrowserNGDefaultSnapId, defaultSnap ); + delete repository; + if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound ) + { + alwaysAsk = ETrue; + } + else + { + RCmManager cmManager; + CleanupClosePushL( cmManager ); + cmManager.OpenL(); + if ( !alwaysAsk ) + { + TRAP( err, cmManager.GetConnectionMethodInfoIntL( + ap, CMManager::ECmIapId ) ); + } + else if ( alwaysAsk == KDestinationSelectionMode ) + { + TRAP( err, IapIdOfDefaultSnapL( cmManager, defaultSnap ) ); + } + CleanupStack::PopAndDestroy( &cmManager ); + if ( !err && ( !alwaysAsk || alwaysAsk == KDestinationSelectionMode ) ) + { + return ETrue; + } + } + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CDrmUiHandlingImpl::APCountL +// ----------------------------------------------------------------------------- +// +TInt DRM::CDrmUiHandlingImpl::APCountL() + { + TInt apCount( 0 ); + RCmManager cmManager; + CleanupClosePushL( cmManager ); + cmManager.OpenL(); + RArray aps; + CleanupClosePushL( aps ); + cmManager.ConnectionMethodL( aps, EFalse, EFalse, ETrue ); + apCount = aps.Count(); + CleanupStack::PopAndDestroy( 2, &cmManager ); //aps, cmManager + return apCount; + } + +// ----------------------------------------------------------------------------- // CDrmUiHandlingImpl::HandleServerAppExit // ----------------------------------------------------------------------------- // void DRM::CDrmUiHandlingImpl::HandleServerAppExit( TInt aReason ) { - if ( aReason == EAknCmdExit) + if ( aReason == EAknCmdExit && !iSchemeHandler ) { CAknEnv::RunAppShutter(); } + if ( iSchemeHandler ) + { + delete iSchemeHandler; + iSchemeHandler = NULL; + } + if ( iWait.IsStarted() ) { iWait.AsyncStop();