commondrm/drmutility/src/DrmUiHandlingImpl.cpp
branchRCL_3
changeset 72 1481bf457703
parent 71 1221b68b8a5f
child 88 c1bd57533c56
equal deleted inserted replaced
71:1221b68b8a5f 72:1481bf457703
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 // INCLUDE FILES
    18 // INCLUDE FILES
    19 
    19 
       
    20 // connection
       
    21 #include <cmconnectionmethod.h>
       
    22 #include <cmdestination.h>
       
    23 #include <cmconnectionmethoddef.h>
       
    24 #include <cmmanager.h>
       
    25 #include <sacls.h>
       
    26 #include <utf.h>
    20 
    27 
    21 // publish & subscribe
    28 // publish & subscribe
    22 #include <e32property.h>
    29 #include <e32property.h>
    23 #include <PSVariables.h>
    30 #include <PSVariables.h>
    24 #include <centralrepository.h>
    31 #include <centralrepository.h>
    27 #include <coemain.h>
    34 #include <coemain.h>
    28 #include <apgtask.h>
    35 #include <apgtask.h>
    29 #include <avkon.hrh>
    36 #include <avkon.hrh>
    30 #include <aknenv.h>
    37 #include <aknenv.h>
    31 
    38 
       
    39 // browser
       
    40 #ifdef __SERIES60_NATIVE_BROWSER
       
    41 #include <browseruisdkcrkeys.h>
       
    42 #endif
       
    43 
    32 // caf
    44 // caf
    33 #include <caf/data.h>
    45 #include <caf/data.h>
    34 #include <caf/caftypes.h>
    46 #include <caf/caftypes.h>
    35 
    47 
    36 // launching embedded details view
    48 // launching embedded details view
    42 #include <DcfRep.h>
    54 #include <DcfRep.h>
    43 #include <DcfEntry.h>
    55 #include <DcfEntry.h>
    44 
    56 
    45 // character conversions
    57 // character conversions
    46 #include <utf.h>
    58 #include <utf.h>
       
    59 
       
    60 // handling urls
       
    61 #include <schemehandler.h>
    47 
    62 
    48 // resources
    63 // resources
    49 #include <data_caging_path_literals.hrh>
    64 #include <data_caging_path_literals.hrh>
    50 #include <drmutility.rsg>
    65 #include <drmutility.rsg>
    51 
    66 
    57 #include <DRMRightsClient.h>
    72 #include <DRMRightsClient.h>
    58 #include <drmutility.h>
    73 #include <drmutility.h>
    59 #include <drmutilitytypes.h>
    74 #include <drmutilitytypes.h>
    60 #include <drmasyncobserver.h>
    75 #include <drmasyncobserver.h>
    61 #include <drmhandleerrorobserver.h>
    76 #include <drmhandleerrorobserver.h>
    62 #include <drmbrowserlauncher.h>
       
    63 
       
    64 //connectivity logic
       
    65 #include <cmconnectionmethod.h> // RCmConnectionMethod
       
    66 #include <cmdestination.h> // RCmDestination
       
    67 #include <cmmanager.h> // RCmManager
       
    68 
       
    69 
       
    70 
    77 
    71 #ifdef _DEBUG
    78 #ifdef _DEBUG
    72 #include <e32debug.h>
    79 #include <e32debug.h>
    73 #endif
    80 #endif
    74 
    81 
    87 #include "drmsettingsplugininternalcrkeys.h"
    94 #include "drmsettingsplugininternalcrkeys.h"
    88 #include "DRMRIContext.h"
    95 #include "DRMRIContext.h"
    89 #include "DRMDomainContext.h"
    96 #include "DRMDomainContext.h"
    90 
    97 
    91 #include "DrmUtilityInternalcrkeys.h"      // Cenrep extension for OmaBased
    98 #include "DrmUtilityInternalcrkeys.h"      // Cenrep extension for OmaBased
    92 #include "drmuidialogids.h"
       
    93 
    99 
    94 // CONSTANTS
   100 // CONSTANTS
    95 const TInt KCommandHandleErrorFile( 1 );
   101 const TInt KCommandHandleErrorFile( 1 );
    96 const TInt KCommandHandleErrorData( 2 );
   102 const TInt KCommandHandleErrorData( 2 );
    97 const TInt KCommandCheckRightsAmountFile( 3 );
   103 const TInt KCommandCheckRightsAmountFile( 3 );
   100 const TInt KCommandShowDetailsViewData( 6 );
   106 const TInt KCommandShowDetailsViewData( 6 );
   101 const TInt KCommandHandleUrlFile( 7 );
   107 const TInt KCommandHandleUrlFile( 7 );
   102 const TInt KCommandHandleUrlData( 8 );
   108 const TInt KCommandHandleUrlData( 8 );
   103 const TInt KCommandAvailableUrlsFile( 9 );
   109 const TInt KCommandAvailableUrlsFile( 9 );
   104 const TInt KCommandAvailableUrlsData( 10 );
   110 const TInt KCommandAvailableUrlsData( 10 );
       
   111 // browser
       
   112 #ifndef __SERIES60_NATIVE_BROWSER
       
   113 const TUid KCRUidBrowser =
       
   114     {0x10008D39};
       
   115 const TUint32 KBrowserDefaultAccessPoint = 0x0000000E;
       
   116 const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E;
       
   117 const TUint32 KBrowserNGDefaultSnapId = 0x00000053;
       
   118 #endif
   105 
   119 
   106 _LIT( KEncryptedRightsIssuerMatchString, "flk*" );
   120 _LIT( KEncryptedRightsIssuerMatchString, "flk*" );
   107 
   121 
   108 // buffer sizes
   122 // buffer sizes
   109 const TInt KDRMMaxETABufSize( 11 );
   123 const TInt KDRMMaxETABufSize( 11 );
   120 
   134 
   121 const TInt KCenRepDataLength( 50 );
   135 const TInt KCenRepDataLength( 50 );
   122 
   136 
   123 const TInt KresOmaBasedBuf( 512 );
   137 const TInt KresOmaBasedBuf( 512 );
   124 const TInt KNameBuf( 256 );
   138 const TInt KNameBuf( 256 );
   125 const TInt KNoValue = -1;
       
   126 
       
   127 #ifdef _DEBUG
   139 #ifdef _DEBUG
   128 // debug panic
   140 // debug panic
   129 _LIT( KDRMUtilityDebugPanicMessage, "DrmUiHandlingDebugPanic" );
   141 _LIT( KDRMUtilityDebugPanicMessage, "DrmUiHandlingDebugPanic" );
   130 const TInt KDRMUtilityDebugPanicCode( 1 );
   142 const TInt KDRMUtilityDebugPanicCode( 1 );
   131 #endif
   143 #endif
   132 
   144 
   133 // ============================= LOCAL FUNCTIONS ===============================
   145 // ============================= LOCAL FUNCTIONS ===============================
   134 // -----------------------------------------------------------------------------
   146 // -----------------------------------------------------------------------------
   135 // HasDefaultConnectionL
       
   136 // Finds default IAP id
       
   137 // @return Etrue: valid AP found
       
   138 //         EFalse: valid AP not found
       
   139 // @leave system wide error codes
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 LOCAL_C TBool HasDefaultConnectionL()
       
   143     {
       
   144     TBool hasDefault(EFalse);
       
   145     TCmDefConnValue defConn;
       
   146     RCmManager cmManager;
       
   147     cmManager.OpenLC();
       
   148     cmManager.ReadDefConnL(defConn);
       
   149     if (defConn.iType == ECmDefConnConnectionMethod)
       
   150         {
       
   151         cmManager.GetConnectionMethodInfoIntL(defConn.iId,
       
   152                 CMManager::ECmIapId);
       
   153         hasDefault = ETrue;
       
   154         }
       
   155     else if (defConn.iType == ECmDefConnDestination)
       
   156         {
       
   157         RCmDestination dest(cmManager.DestinationL(defConn.iId));
       
   158         CleanupClosePushL(dest);
       
   159 
       
   160         if (dest.ConnectionMethodCount() <= 0)
       
   161             {
       
   162             User::Leave(KErrNotFound);
       
   163             }
       
   164 
       
   165         RCmConnectionMethod cMeth(dest.ConnectionMethodL(0));
       
   166         CleanupClosePushL(cMeth);
       
   167 
       
   168         cMeth.GetIntAttributeL(CMManager::ECmIapId);
       
   169         CleanupStack::PopAndDestroy(&cMeth);
       
   170         CleanupStack::PopAndDestroy(&dest);
       
   171         hasDefault = ETrue;
       
   172         }
       
   173     CleanupStack::PopAndDestroy(&cmManager);
       
   174     return hasDefault;
       
   175     }
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 // HasAccessPointsL
       
   179 // -----------------------------------------------------------------------------
       
   180 //
       
   181 LOCAL_C TBool HasAccessPointsL()
       
   182     {
       
   183     TInt apCount(0);
       
   184     RCmManager cmManager;
       
   185     CleanupClosePushL(cmManager);
       
   186     cmManager.OpenL();
       
   187     RArray<TUint32> aps;
       
   188     CleanupClosePushL(aps);
       
   189     cmManager.ConnectionMethodL(aps, EFalse, EFalse, ETrue);
       
   190     apCount = aps.Count();
       
   191     CleanupStack::PopAndDestroy(2, &cmManager); //aps, cmManager
       
   192     return apCount > 0;
       
   193     }
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 // MapToCallError
   147 // MapToCallError
   197 // -----------------------------------------------------------------------------
   148 // -----------------------------------------------------------------------------
   198 //
   149 //
   199 LOCAL_C inline TInt CheckAndMapToCallError(
   150 LOCAL_C inline TInt CheckAndMapToCallError(
   200     RDRMRightsClient& aOmaClient,
   151     RDRMRightsClient& aOmaClient,
   205     TInt err( aOmaClient.CheckRights( aIntent, aContentUri, rr ) );
   156     TInt err( aOmaClient.CheckRights( aIntent, aContentUri, rr ) );
   206     return err ? KErrCANoRights : KErrNone;
   157     return err ? KErrCANoRights : KErrNone;
   207     }
   158     }
   208 
   159 
   209 // -----------------------------------------------------------------------------
   160 // -----------------------------------------------------------------------------
   210 // HasDefConn
   161 // IapIdOfDefaultSnapL
   211 // -----------------------------------------------------------------------------
   162 // for trapping purposes only
   212 //
   163 // -----------------------------------------------------------------------------
   213 inline TBool HasDefConn()
   164 //
   214     {
   165 LOCAL_C TUint32 IapIdOfDefaultSnapL(
   215     TBool found( EFalse );
   166     RCmManager& aCmManager,
   216 
   167     const TUint32 aDefaultSnap )
   217     TRAP_IGNORE( found = HasDefaultConnectionL() );
   168     {
   218 
   169     RCmDestination dest( aCmManager.DestinationL( aDefaultSnap ) );
   219     return found;
   170     CleanupClosePushL( dest );
       
   171     TUint32 iapIdOfDest( 0 );
       
   172 
       
   173     if ( dest.ConnectionMethodCount() <= 0 )
       
   174         {
       
   175         User::Leave( KErrNotFound );
       
   176         }
       
   177 
       
   178     RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
       
   179     CleanupClosePushL( cMeth );
       
   180 
       
   181     iapIdOfDest = cMeth.GetIntAttributeL( CMManager::ECmIapId );
       
   182     CleanupStack::PopAndDestroy( &cMeth );
       
   183     CleanupStack::PopAndDestroy( &dest );
       
   184     return iapIdOfDest;
   220     }
   185     }
   221 
   186 
   222 // ---------------------------------------------------------
   187 // ---------------------------------------------------------
   223 // UpdateDCFRepositoryL()
   188 // UpdateDCFRepositoryL()
   224 // Update saved file to DCFRepository
   189 // Update saved file to DCFRepository
   434         }
   399         }
   435 
   400 
   436     delete iDrmUtilityCommon;
   401     delete iDrmUtilityCommon;
   437 
   402 
   438     delete iDrmUtilityUi;
   403     delete iDrmUtilityUi;
       
   404 
       
   405     delete iSchemeHandler;
   439 
   406 
   440     delete iWrapperLoader;
   407     delete iWrapperLoader;
   441 
   408 
   442     delete iOmaBasedAgentName;
   409     delete iOmaBasedAgentName;
   443 
   410 
  1834 
  1801 
  1835     // Show that only reason for error was rejected metering.
  1802     // Show that only reason for error was rejected metering.
  1836     TBool onlyMeteringRejection( reason == DRM::EURejectionMetering );
  1803     TBool onlyMeteringRejection( reason == DRM::EURejectionMetering );
  1837     if ( onlyMeteringRejection )
  1804     if ( onlyMeteringRejection )
  1838         {
  1805         {
  1839         // Qt dialog not implemented yet
  1806         iDrmUtilityUi->DisplayQueryWithIdL( R_DRM_QUERY_METERING_DISABLED,
  1840         iDrmUtilityUi->DisplayNoteL( EConfUnableToOpen );
  1807             R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY );
  1841 
  1808 
  1842         CleanupStack::PopAndDestroy( contentId );
  1809         CleanupStack::PopAndDestroy( contentId );
  1843         return;
  1810         return;
  1844         }
  1811         }
  1845 
  1812 
  2966         case DRM::EUHCheckRightsActionDefault:
  2933         case DRM::EUHCheckRightsActionDefault:
  2967             {
  2934             {
  2968             if ( RejectReason( aReason ) == DRM::EURejectionMetering )
  2935             if ( RejectReason( aReason ) == DRM::EURejectionMetering )
  2969                 {
  2936                 {
  2970                 // Show that only reason for error was rejected metering.
  2937                 // Show that only reason for error was rejected metering.
  2971                 // Qt dialog not implemented yet
  2938                 iDrmUtilityUi->DisplayQueryWithIdL(
  2972                 iDrmUtilityUi->DisplayNoteL( EConfUnableToOpen );
  2939                     R_DRM_QUERY_METERING_DISABLED,
       
  2940                     R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY );
  2973                 }
  2941                 }
  2974             else
  2942             else
  2975                 {
  2943                 {
  2976                 if ( !GetSilentAndCallL( aObserver, aOperationId, aIntent,
  2944                 if ( !GetSilentAndCallL( aObserver, aOperationId, aIntent,
  2977                     aContentUri, aSilentUrl, ETrue ) )
  2945                     aContentUri, aSilentUrl, ETrue ) )
  3488     TInt aError )
  3456     TInt aError )
  3489     {
  3457     {
  3490     HBufC* etaBuf( NULL );
  3458     HBufC* etaBuf( NULL );
  3491     TBool isRegistered( EFalse );
  3459     TBool isRegistered( EFalse );
  3492     TBool isJoined( EFalse );
  3460     TBool isJoined( EFalse );
  3493     TInt ret( ECancelled );
  3461     TInt ret( 0 );
  3494     TInt err( KErrNone );
  3462     TInt err( KErrNone );
  3495     TInt eta( 0 );
  3463     TInt eta( 0 );
  3496     TFileName fileName;
  3464     TFileName fileName;
  3497     TBool rightsRenewalWanted( EFalse );
  3465     TBool rightsRenewalWanted( EFalse );
  3498 
  3466 
  3514         if ( !err && aError == EPendingRights && eta == -1 )
  3482         if ( !err && aError == EPendingRights && eta == -1 )
  3515             {
  3483             {
  3516             // rights should have come already
  3484             // rights should have come already
  3517             if ( aRightsUrl )
  3485             if ( aRightsUrl )
  3518                 {
  3486                 {
  3519                 ret = iDrmUtilityUi->DisplayQueryL( EQueryGetNewLicence, KNoValue );
  3487                 ret = iDrmUtilityUi->DisplayQueryWithIdL(
       
  3488                     R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME,
       
  3489                     R_DRMUTILITY_CONFIRMATION_QUERY );
  3520                 }
  3490                 }
  3521             else
  3491             else
  3522                 {
  3492                 {
  3523                 // no rights issuer
  3493                 // no rights issuer
  3524                 // Qt dialog not implemented yet
  3494                 iDrmUtilityUi->DisplayQueryWithIdL(
  3525                 iDrmUtilityUi->DisplayNoteL( EConfLicenceNotReceived );
  3495                     R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME_NO_RI,
       
  3496                     R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY );
  3526                 }
  3497                 }
  3527             }
  3498             }
  3528         else if ( !eta || err || eta == -1 )
  3499         else if ( !eta || err || eta == -1 )
  3529             {
  3500             {
  3530             // rights not expected to arrive
  3501             // rights not expected to arrive
  3534                     isJoined );
  3505                     isJoined );
  3535                 }
  3506                 }
  3536 
  3507 
  3537             if ( aRightsUrl && isRegistered && !isJoined ) // Domain ro case
  3508             if ( aRightsUrl && isRegistered && !isJoined ) // Domain ro case
  3538                 {
  3509                 {
  3539                 ret = iDrmUtilityUi->DisplayQueryL( EQueryAccountUpdate, KNoValue );
  3510                 ret = iDrmUtilityUi->DisplayQueryWithIdL(
       
  3511                     R_DRMUTILITY_ACTIVATE_ACCOUNT,
       
  3512                     R_DRMUTILITY_CONFIRMATION_QUERY );
  3540                 }
  3513                 }
  3541             else if ( aRightsUrl ) // Device ro case
  3514             else if ( aRightsUrl ) // Device ro case
  3542                 {
  3515                 {
  3543                 if ( aReason & EConstraintIndividual )
  3516                 if ( aReason & EConstraintIndividual )
  3544                     {
  3517                     {
  3545                     ret = iDrmUtilityUi->DisplayQueryL( EQueryFileLockedForSim, KNoValue );
  3518                     ret = iDrmUtilityUi->DisplayQueryWithIdL(
       
  3519                         R_DRMUTILITY_INVALID_SIM,
       
  3520                         R_DRMUTILITY_CONFIRMATION_QUERY );
  3546                     }
  3521                     }
  3547                 else
  3522                 else
  3548                     {
  3523                     {
  3549                     // get filename
  3524                     // get filename
  3550                     User::LeaveIfError( aContent.GetStringAttribute(
  3525                     User::LeaveIfError( aContent.GetStringAttribute(
  3551                         EFileName, fileName ) );
  3526                         EFileName, fileName ) );
  3552 
  3527 
  3553                     // Qt dialog not implemented yet
  3528                     ret = iDrmUtilityUi->DisplayQueryL(
  3554                     ret = iDrmUtilityUi->DisplayQueryL( EQueryFileWithNoRightsObj, fileName );
  3529                         R_DRM_QUERY_EXPIRED_OR_NO_RO, fileName );
  3555                     }
  3530                     }
  3556                 }
  3531                 }
  3557             else // no rights issuer
  3532             else // no rights issuer
  3558                 {
  3533                 {
  3559                 if ( aReason & EConstraintIndividual )
  3534                 if ( aReason & EConstraintIndividual )
  3560                     {
  3535                     {
  3561                     // Qt dialog not implemented yet
  3536                     iDrmUtilityUi->DisplayNoteL( R_DRM_INFO_SIM_NOT_ALLOWED );
  3562                     iDrmUtilityUi->DisplayNoteL( EConfFileLockedForSim );
       
  3563                     }
  3537                     }
  3564                 else
  3538                 else
  3565                     {
  3539                     {
  3566                     iDrmUtilityUi->DisplayNoteL( EConfLicenceExpired );
  3540                     iDrmUtilityUi->DisplayNoteL( R_DRM_INFO_EXPIRED_OR_NO_RO );
  3567                     }
  3541                     }
  3568                 }
  3542                 }
  3569             }
  3543             }
  3570         else
  3544         else
  3571             {
  3545             {
  3572             // rights expected to arrive
  3546             // rights expected to arrive
  3573             if ( eta != KErrCAPendingRights )
  3547             if ( eta != KErrCAPendingRights )
  3574                 {
  3548                 {
  3575                 // rights expected to arrive in eta seconds
  3549                 // rights expected to arrive in eta seconds
  3576                 iDrmUtilityUi->DisplayNoteL( EConfWaitingForLicence );
  3550                 iDrmUtilityUi->DisplayQueryWithIdL(
       
  3551                     R_DRMUTILITY_WAITING_FOR_RIGHTS,
       
  3552                     R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY );
  3577                 }
  3553                 }
  3578             else
  3554             else
  3579                 {
  3555                 {
  3580                 // rights should have come
  3556                 // rights should have come
  3581                 if ( aRightsUrl )
  3557                 if ( aRightsUrl )
  3582                     {
  3558                     {
  3583                     ret = iDrmUtilityUi->DisplayQueryL( EQueryGetNewLicence, KNoValue );
  3559                     ret = iDrmUtilityUi->DisplayQueryWithIdL(
       
  3560                         R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME,
       
  3561                         R_DRMUTILITY_CONFIRMATION_QUERY );
  3584                     }
  3562                     }
  3585                 else
  3563                 else
  3586                     {
  3564                     {
  3587                     // no rights issuer
  3565                     // no rights issuer
  3588                     // Qt dialog not implemented yet
  3566                     iDrmUtilityUi->DisplayQueryWithIdL(
  3589                     iDrmUtilityUi->DisplayNoteL( EConfLicenceNotReceived );
  3567                         R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME_NO_RI,
       
  3568                         R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY );
  3590                     }
  3569                     }
  3591                 }
  3570                 }
  3592             }
  3571             }
  3593         }
  3572         }
  3594     if ( ret == EOk )
  3573 
       
  3574     if ( ret == EAknSoftkeyYes || ret == EAknSoftkeyOk )
  3595         {
  3575         {
  3596         rightsRenewalWanted = ETrue;
  3576         rightsRenewalWanted = ETrue;
  3597         }
  3577         }
  3598     return rightsRenewalWanted;
  3578     return rightsRenewalWanted;
  3599     }
  3579     }
  4068         ptr.Append( KHttp );
  4048         ptr.Append( KHttp );
  4069         ptr.Append( *aUrl );
  4049         ptr.Append( *aUrl );
  4070         ptrc.Set( *newUrl );
  4050         ptrc.Set( *newUrl );
  4071         }
  4051         }
  4072 
  4052 
  4073     CDrmBrowserLauncher* browserLauncher = CDrmBrowserLauncher::NewLC();
  4053     CSchemeHandler* schemeHandler( CSchemeHandler::NewL( ptrc ) );
  4074     	
  4054     CleanupStack::PushL( schemeHandler );
  4075     browserLauncher->LaunchUrlL(ptrc);
  4055     if ( iCoeEnv )
  4076     
  4056         {
  4077     CleanupStack::PopAndDestroy(); // browserLauncher
  4057         embeddedLaunch = ETrue;
       
  4058         // launch embedded
       
  4059         schemeHandler->Observer( this );
       
  4060         schemeHandler->HandleUrlEmbeddedL();
       
  4061         CleanupStack::Pop( schemeHandler );
       
  4062         iSchemeHandler = schemeHandler;
       
  4063         iWait.Start();
       
  4064         }
       
  4065     else
       
  4066         {
       
  4067         // no CoeEnv, launch standalone with scheme app
       
  4068         schemeHandler->HandleUrlStandaloneL();
       
  4069         CleanupStack::PopAndDestroy( schemeHandler );
       
  4070         }
       
  4071     schemeHandler = NULL;
  4078 
  4072 
  4079     // delete newUrl if needed
  4073     // delete newUrl if needed
  4080     if ( newUrl )
  4074     if ( newUrl )
  4081         {
  4075         {
  4082         CleanupStack::PopAndDestroy( newUrl );
  4076         CleanupStack::PopAndDestroy( newUrl );
  4091 TInt DRM::CDrmUiHandlingImpl::GetSilentRightsL(
  4085 TInt DRM::CDrmUiHandlingImpl::GetSilentRightsL(
  4092     const TDesC8& aUrl,
  4086     const TDesC8& aUrl,
  4093     const TBool aShowNotes )
  4087     const TBool aShowNotes )
  4094     {
  4088     {
  4095     TInt r( KErrCancel );
  4089     TInt r( KErrCancel );
  4096     TInt buttonCode( EOk );
  4090     TInt buttonCode( EAknSoftkeyYes );
  4097     HBufC8* url( NULL );
  4091     HBufC8* url( NULL );
  4098 
  4092 
  4099     if ( !SilentRightsAllowedL() )
  4093     if ( !SilentRightsAllowedL() )
  4100         {
  4094         {
  4101         buttonCode = ECancelled;
  4095         buttonCode = EAknSoftkeyNo;
  4102         if ( aShowNotes )
  4096         if ( aShowNotes )
  4103             {
  4097             {
  4104             // Qt dialog not implemented yet
  4098             buttonCode = iDrmUtilityUi->DisplayQueryWithIdL(
  4105             buttonCode = iDrmUtilityUi->DisplayQueryL( EQueryConnectToActivate, KNoValue );
  4099                 R_DRM_QRY_CONNECT_TO_ACTIVATE,
  4106             }
  4100                 R_DRMUTILITY_CONFIRMATION_QUERY );
  4107         }
  4101             }
  4108     else if ( !(HasDefConn()) )
  4102         }
  4109         {
  4103     else if ( !BrowserAPDefinedL() )
  4110         buttonCode = ECancelled;
  4104         {
       
  4105         buttonCode = EAknSoftkeyNo;
  4111         if ( aShowNotes )
  4106         if ( aShowNotes )
  4112             {
  4107             {
  4113             // Qt dialog not implemented yet
  4108             buttonCode = iDrmUtilityUi->DisplayQueryWithIdL(
  4114             buttonCode = iDrmUtilityUi->DisplayQueryL( EQueryConnectToActivate, KNoValue );
  4109                 R_DRM_QRY_CONNECT_TO_ACTIVATE,
  4115             }
  4110                 R_DRMUTILITY_CONFIRMATION_QUERY );
  4116         }
  4111             }
  4117 
  4112         }
  4118     if ( buttonCode == EOk )
  4113 
  4119         {
  4114     if ( buttonCode == EAknSoftkeyYes || buttonCode == EAknSoftkeyOk )
  4120         TBool APs( HasAccessPointsL() );
  4115         {
       
  4116         TInt APs( APCountL() );
  4121         if ( !APs )
  4117         if ( !APs )
  4122             {
  4118             {
  4123             // No AP defined
  4119             // No AP defined
  4124             if ( aShowNotes )
  4120             if ( aShowNotes )
  4125                 {
  4121                 {
  4126                 // Qt dialog not implemented yet
  4122                 iDrmUtilityUi->DisplayNoteL( R_DRM_WARN_NO_CONN_DEFINED );
  4127                 iDrmUtilityUi->DisplayNoteL( EConfNoAccessPoint );
       
  4128                 }
  4123                 }
  4129             r = KErrCANoRights;
  4124             r = KErrCANoRights;
  4130             }
  4125             }
  4131         else
  4126         else
  4132             {
  4127             {
  4156                     if ( r == KErrCouldNotConnect )
  4151                     if ( r == KErrCouldNotConnect )
  4157                         {
  4152                         {
  4158                         // Connection failed with selected AP
  4153                         // Connection failed with selected AP
  4159                         if ( aShowNotes )
  4154                         if ( aShowNotes )
  4160                             {
  4155                             {
  4161                             // Qt dialog not implemented yet
  4156                             iDrmUtilityUi->DisplayNoteL(
  4162                             iDrmUtilityUi->DisplayNoteL( EConfConnectionFailed );
  4157                                 R_DRM_WARN_INVALID_OR_NO_AP );
  4163                             }
  4158                             }
  4164                         r = KErrCANoRights;
  4159                         r = KErrCANoRights;
  4165                         }
  4160                         }
  4166                     else
  4161                     else
  4167                         {
  4162                         {
  4174                             // error url is got only if temporary roap error
  4169                             // error url is got only if temporary roap error
  4175 
  4170 
  4176                             if ( errorUrl )
  4171                             if ( errorUrl )
  4177                                 {
  4172                                 {
  4178                                 // ask user whether error url should be opened
  4173                                 // ask user whether error url should be opened
  4179                                 // Qt dialog not implemented yet
  4174                                 buttonCode
  4180                                 buttonCode = iDrmUtilityUi->DisplayQueryL( EQueryOpenErrorUrl, KNoValue );
  4175                                     = iDrmUtilityUi->DisplayQueryWithIdL(
  4181 
  4176                                         R_DRM_QUERY_OPEN_ERROR_URL,
  4182                                 if ( buttonCode == EOk )
  4177                                         R_DRMUTILITY_CONFIRMATION_QUERY );
       
  4178 
       
  4179                                 if ( buttonCode == EAknSoftkeyYes
       
  4180                                     || buttonCode == EAknSoftkeyOk )
  4183                                     {
  4181                                     {
  4184                                     // Launch browser
  4182                                     // Launch browser
  4185                                     LaunchBrowserL( errorUrl );
  4183                                     LaunchBrowserL( errorUrl );
  4186                                     }
  4184                                     }
  4187                                 }
  4185                                 }
  4188                             else
  4186                             else
  4189                                 {
  4187                                 {
  4190                                 // Qt dialog not implemented yet
  4188                                 iDrmUtilityUi->DisplayNoteL(
  4191                                 iDrmUtilityUi->DisplayNoteL( EConfUnableToUnlock );
  4189                                     R_DRM_ERR_OPENING_FAIL_PERM );
  4192                                 }
  4190                                 }
  4193                             CleanupStack::PopAndDestroy( errorUrl );
  4191                             CleanupStack::PopAndDestroy( errorUrl );
  4194                             }
  4192                             }
  4195                         }
  4193                         }
  4196                     }
  4194                     }
  4213     delete repository;
  4211     delete repository;
  4214     return !value ? EFalse : ETrue;
  4212     return !value ? EFalse : ETrue;
  4215     }
  4213     }
  4216 
  4214 
  4217 // -----------------------------------------------------------------------------
  4215 // -----------------------------------------------------------------------------
       
  4216 // CDrmUiHandlingImpl::BrowserAPDefinedL
       
  4217 // -----------------------------------------------------------------------------
       
  4218 //
       
  4219 TBool DRM::CDrmUiHandlingImpl::BrowserAPDefinedL()
       
  4220     {
       
  4221     const TInt KDestinationSelectionMode( 2 );
       
  4222     TInt err( KErrNone );
       
  4223     TInt ap( 0 );
       
  4224     TInt alwaysAsk( 0 );
       
  4225     TInt defaultSnap( 0 );
       
  4226 
       
  4227     CRepository* repository( CRepository::NewL( KCRUidBrowser ) );
       
  4228     repository->Get( KBrowserDefaultAccessPoint, ap );
       
  4229     repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk );
       
  4230     repository->Get( KBrowserNGDefaultSnapId, defaultSnap );
       
  4231     delete repository;
       
  4232     if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound )
       
  4233         {
       
  4234         alwaysAsk = ETrue;
       
  4235         }
       
  4236     else
       
  4237         {
       
  4238         RCmManager cmManager;
       
  4239         CleanupClosePushL( cmManager );
       
  4240         cmManager.OpenL();
       
  4241         if ( !alwaysAsk )
       
  4242             {
       
  4243                 TRAP( err, cmManager.GetConnectionMethodInfoIntL(
       
  4244                         ap, CMManager::ECmIapId ) );
       
  4245             }
       
  4246         else if ( alwaysAsk == KDestinationSelectionMode )
       
  4247             {
       
  4248                 TRAP( err, IapIdOfDefaultSnapL( cmManager, defaultSnap ) );
       
  4249             }
       
  4250         CleanupStack::PopAndDestroy( &cmManager );
       
  4251         if ( !err && ( !alwaysAsk || alwaysAsk == KDestinationSelectionMode ) )
       
  4252             {
       
  4253             return ETrue;
       
  4254             }
       
  4255         }
       
  4256     return EFalse;
       
  4257     }
       
  4258 
       
  4259 // -----------------------------------------------------------------------------
       
  4260 // CDrmUiHandlingImpl::APCountL
       
  4261 // -----------------------------------------------------------------------------
       
  4262 //
       
  4263 TInt DRM::CDrmUiHandlingImpl::APCountL()
       
  4264     {
       
  4265     TInt apCount( 0 );
       
  4266     RCmManager cmManager;
       
  4267     CleanupClosePushL( cmManager );
       
  4268     cmManager.OpenL();
       
  4269     RArray<TUint32> aps;
       
  4270     CleanupClosePushL( aps );
       
  4271     cmManager.ConnectionMethodL( aps, EFalse, EFalse, ETrue );
       
  4272     apCount = aps.Count();
       
  4273     CleanupStack::PopAndDestroy( 2, &cmManager ); //aps, cmManager
       
  4274     return apCount;
       
  4275     }
       
  4276 
       
  4277 // -----------------------------------------------------------------------------
  4218 // CDrmUiHandlingImpl::HandleServerAppExit
  4278 // CDrmUiHandlingImpl::HandleServerAppExit
  4219 // -----------------------------------------------------------------------------
  4279 // -----------------------------------------------------------------------------
  4220 //
  4280 //
  4221 void DRM::CDrmUiHandlingImpl::HandleServerAppExit( TInt aReason )
  4281 void DRM::CDrmUiHandlingImpl::HandleServerAppExit( TInt aReason )
  4222     {
  4282     {
  4223     if ( aReason == EAknCmdExit)
  4283     if ( aReason == EAknCmdExit && !iSchemeHandler )
  4224         {
  4284         {
  4225         CAknEnv::RunAppShutter();
  4285         CAknEnv::RunAppShutter();
       
  4286         }
       
  4287 
       
  4288     if ( iSchemeHandler )
       
  4289         {
       
  4290         delete iSchemeHandler;
       
  4291         iSchemeHandler = NULL;
  4226         }
  4292         }
  4227 
  4293 
  4228     if ( iWait.IsStarted() )
  4294     if ( iWait.IsStarted() )
  4229         {
  4295         {
  4230         iWait.AsyncStop();
  4296         iWait.AsyncStop();