commondrm/drmutility/src/drmutilitywmdrmwrapper.cpp
branchRCL_3
changeset 71 1221b68b8a5f
parent 32 457cd4423b8c
child 72 1481bf457703
equal deleted inserted replaced
67:50c53e893c3f 71:1221b68b8a5f
    29 #include <utf.h>
    29 #include <utf.h>
    30 #include <f32file.h>
    30 #include <f32file.h>
    31 #include <avkon.hrh>
    31 #include <avkon.hrh>
    32 
    32 
    33 // access point utils
    33 // access point utils
    34 #include <centralrepository.h>
    34 
    35 #include <cdblen.h>
    35 #include <cdblen.h>
    36 #include <cmconnectionmethod.h>
    36 #include <cmconnectionmethod.h>
    37 #include <cmdestination.h>
    37 #include <cmdestination.h>
    38 #include <cmconnectionmethoddef.h>
    38 #include <cmconnectionmethoddef.h>
    39 #include <cmmanager.h>
    39 #include <cmmanager.h>
    40 #ifdef __SERIES60_NATIVE_BROWSER
       
    41 #include <browseruisdkcrkeys.h>
       
    42 #endif
       
    43 
       
    44 #include <featdiscovery.h>
       
    45 #include <aknmessagequerydialog.h>
       
    46 
    40 
    47 #include    <wmdrmagent.h> // for WMDRM file details view
    41 #include    <wmdrmagent.h> // for WMDRM file details view
    48 #include    <drmutilitytypes.h>
    42 #include    <drmutilitytypes.h>
    49 #include    <drmuicheckrightsobserver.h>
    43 #include    <drmuicheckrightsobserver.h>
    50 
    44 
    59 
    53 
    60 #include    "drmutilityinternaltypes.h"
    54 #include    "drmutilityinternaltypes.h"
    61 #include    "drmutilitywmdrmutilities.h"
    55 #include    "drmutilitywmdrmutilities.h"
    62 
    56 
    63 #include    "wmdrmdlawrapper.h"
    57 #include    "wmdrmdlawrapper.h"
    64 
    58 #include    "drmuidialogids.h"
    65 using namespace DRM;
       
    66 
    59 
    67 // CONSTANTS
    60 // CONSTANTS
    68 const TInt KMaxUrlLength( 1024 );
    61 const TInt KMaxUrlLength( 1024 );
    69 const TInt KMaxUrlSanityLength( 102400 );
    62 const TInt KMaxUrlSanityLength( 102400 );
    70 
       
    71 #ifndef __SERIES60_NATIVE_BROWSER
       
    72 const TUid KCRUidBrowser = {0x10008D39};
       
    73 const TUint32 KBrowserDefaultAccessPoint = 0x0000000E;
       
    74 const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E;
       
    75 #endif
       
    76 
    63 
    77 #ifdef _DEBUG
    64 #ifdef _DEBUG
    78 // debug panic
    65 // debug panic
    79 _LIT( KWmDrmWrapperDebugPanicMessage, "WmDrmWrapperDebugPanic" );
    66 _LIT( KWmDrmWrapperDebugPanicMessage, "WmDrmWrapperDebugPanic" );
    80 const TInt KWmDrmWrapperDebugPanicCode( 1 );
    67 const TInt KWmDrmWrapperDebugPanicCode( 1 );
    88 // might leave.
    75 // might leave.
    89 // -----------------------------------------------------------------------------
    76 // -----------------------------------------------------------------------------
    90 //
    77 //
    91 DRM::CDrmUtilityWMDrmWrapper::CDrmUtilityWMDrmWrapper() :
    78 DRM::CDrmUtilityWMDrmWrapper::CDrmUtilityWMDrmWrapper() :
    92     iCoeEnv( NULL ),
    79     iCoeEnv( NULL ),
    93     iDrmUtilityUi( NULL ),
    80     iDrmUtilityUi( NULL )
    94     iWmDrmDlaSupportOn ( ETrue )
       
    95     {
    81     {
    96     }
    82     }
    97 
    83 
    98 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
    99 // CDrmUtilityWMDrmWrapper::ConstructL
    85 // CDrmUtilityWMDrmWrapper::ConstructL
   101 // -----------------------------------------------------------------------------
    87 // -----------------------------------------------------------------------------
   102 //
    88 //
   103 void DRM::CDrmUtilityWMDrmWrapper::ConstructL()
    89 void DRM::CDrmUtilityWMDrmWrapper::ConstructL()
   104     {
    90     {
   105     User::LeaveIfError( iFs.Connect() );
    91     User::LeaveIfError( iFs.Connect() );
   106     TUid u = TUid::Uid( KFeatureIdFfWmdrmDlaSupport );
       
   107     TRAPD(err, iWmDrmDlaSupportOn = CFeatureDiscovery::IsFeatureSupportedL( u ));
       
   108     }
    92     }
   109 
    93 
   110 // -----------------------------------------------------------------------------
    94 // -----------------------------------------------------------------------------
   111 // CDrmUtilityWMDrmWrapper::NewL
    95 // CDrmUtilityWMDrmWrapper::NewL
   112 // Two-phased constructor.
    96 // Two-phased constructor.
   274     // Ask the rights from CAF, same call for both ECanPlay and ECanView
   258     // Ask the rights from CAF, same call for both ECanPlay and ECanView
   275     User::LeaveIfError( aContent.GetAttribute( ContentAccess::ECanPlay, value ) );
   259     User::LeaveIfError( aContent.GetAttribute( ContentAccess::ECanPlay, value ) );
   276 
   260 
   277     if ( !value )
   261     if ( !value )
   278         {
   262         {
   279         ShowNoRightsNoteL( aContent, reason );
   263         ShowNoRightsNoteL( aContent, reason, aOperationId, aObserver );
   280         User::LeaveIfError( aContent.GetAttribute( ContentAccess::ECanPlay, value ) );
   264         User::LeaveIfError( aContent.GetAttribute( ContentAccess::ECanPlay, value ) );
   281         if ( value )
   265         if ( value )
   282             {
   266             {
   283             CallRightsAvailable( aObserver, aOperationId, KErrNone );
   267             CallRightsAvailable( aObserver, aOperationId, KErrNone );
   284             }
   268             }
   498 
   482 
   499     switch ( rightsAction )
   483     switch ( rightsAction )
   500         {
   484         {
   501         case DRM::EUHCheckRightsActionDefault:
   485         case DRM::EUHCheckRightsActionDefault:
   502             {
   486             {
   503             ShowNoRightsNoteL( aContent, aReason );
   487             ShowNoRightsNoteL( aContent, aReason, aOperationId, aObserver );
   504             }
   488             }
   505             break;
   489             break;
   506 
   490 
   507         case DRM::EUHCheckRightsActionOpenDetailsView:
   491         case DRM::EUHCheckRightsActionOpenDetailsView:
   508             {
   492             {
   556 // CDrmUtilityWMDrmWrapper::ShowNoRightsNoteL
   540 // CDrmUtilityWMDrmWrapper::ShowNoRightsNoteL
   557 // -----------------------------------------------------------------------------
   541 // -----------------------------------------------------------------------------
   558 //
   542 //
   559 void DRM::CDrmUtilityWMDrmWrapper::ShowNoRightsNoteL(
   543 void DRM::CDrmUtilityWMDrmWrapper::ShowNoRightsNoteL(
   560     ContentAccess::CData& aContent,
   544     ContentAccess::CData& aContent,
   561     TUint32 /*aReason*/ )
   545     TUint32 /*aReason*/,
   562     {
   546     TInt aOperationId,
       
   547     DRM::MDrmHandleErrorObserver* aObserver )
       
   548     {
       
   549     TInt value;
   563     TRAPD( err, LoadDlaWrapperL() );
   550     TRAPD( err, LoadDlaWrapperL() );
   564     if ( !err )
   551     if ( !err )
   565         {
   552         {
   566         TInt ret( EAknSoftkeyYes );
   553         TInt ret( EOk );
   567         RFile file;
   554         RFile file;
   568         GetRFileFromCDataL( aContent, file );
   555         GetRFileFromCDataL( aContent, file );
   569         CleanupClosePushL( file );
   556         CleanupClosePushL( file );
   570         TBool isSilent( EFalse );
   557         TBool isSilent( EFalse );
   571         TRAP( err, isSilent = IsDlaLicenseAcquisitionSilentL( file ) );
   558         TRAP( err, isSilent = IsDlaLicenseAcquisitionSilentL( file ) );
   575                 {
   562                 {
   576                 iDrmUtilityUi = DRM::CDrmUtilityUI::NewL( iCoeEnv );
   563                 iDrmUtilityUi = DRM::CDrmUtilityUI::NewL( iCoeEnv );
   577                 }
   564                 }
   578             TFileName fileName;
   565             TFileName fileName;
   579             User::LeaveIfError( aContent.GetStringAttribute( DRM::EDrmFileName, fileName ) );
   566             User::LeaveIfError( aContent.GetStringAttribute( DRM::EDrmFileName, fileName ) );
   580             if(iWmDrmDlaSupportOn)
   567             // Qt dialog not implemented yet
       
   568             ret = iDrmUtilityUi->DisplayQueryL( EQueryFileWithNoRightsObj, fileName );
       
   569             }
       
   570 
       
   571         if ( !err && ret == EOk )
       
   572             {
       
   573             TRAP_IGNORE( DlaLicenseAcquisitionL( file ) );
       
   574             
       
   575             // Ask the rights from CAF, same call for both ECanPlay and ECanView
       
   576             aContent.GetAttribute( ContentAccess::ECanPlay, value );
       
   577             // call given HandleErrorObserver
       
   578             if( value > 0 )
   581                 {
   579                 {
   582                 ret = iDrmUtilityUi->DisplayQueryL( R_DRM_QUERY_EXPIRED_OR_NO_RO, fileName );
   580                 aObserver->RightsAvailable( aOperationId, KErrNone );              
   583                 }
   581                 }
   584             else
       
   585                 {
       
   586                 ret = iDrmUtilityUi->DisplayMessageQueryL( R_DRMUTILITY_SYNC_WITH_PC, R_DRMUTILITY_HEAD_NO_LICENSE, fileName);
       
   587                 }
       
   588             }
       
   589         if ( !err && ( ret == EAknSoftkeyYes || ret == EAknSoftkeyOk ) && iWmDrmDlaSupportOn)
       
   590             {
       
   591             TRAP_IGNORE( DlaLicenseAcquisitionL( file ) );
       
   592             }
   582             }
   593         CleanupStack::PopAndDestroy( &file );
   583         CleanupStack::PopAndDestroy( &file );
   594         }
   584         }
   595     else
   585     else
   596         {
   586         {
   597         if ( !iDrmUtilityUi )
   587         if ( !iDrmUtilityUi )
   598             {
   588             {
   599             iDrmUtilityUi = DRM::CDrmUtilityUI::NewL( iCoeEnv );
   589             iDrmUtilityUi = DRM::CDrmUtilityUI::NewL( iCoeEnv );
   600             }
   590             }
   601         iDrmUtilityUi->DisplayNoteL( R_DRM_INFO_EXPIRED_OR_NO_RO );
   591         iDrmUtilityUi->DisplayNoteL( EConfLicenceExpired );
   602         }
   592         }
   603     }
   593     }
   604 
   594 
   605 // -----------------------------------------------------------------------------
   595 // -----------------------------------------------------------------------------
   606 // CDrmUtilityWMDrmWrapper::RejectReason
   596 // CDrmUtilityWMDrmWrapper::RejectReason
   775 // -----------------------------------------------------------------------------
   765 // -----------------------------------------------------------------------------
   776 //
   766 //
   777 void DRM::CDrmUtilityWMDrmWrapper::DlaLicenseAcquisitionL(
   767 void DRM::CDrmUtilityWMDrmWrapper::DlaLicenseAcquisitionL(
   778     RFile& aFile )
   768     RFile& aFile )
   779     {
   769     {
   780     if( iWmDrmDlaSupportOn )
   770     TInt iapId( 0 );
   781         {
   771     HBufC* contentUrl( NULL );
   782         TInt iapId( 0 );
   772     HBufC* htmlData( NULL );
   783         HBufC* contentUrl( NULL );
   773     LoadDlaWrapperL();
   784         HBufC* htmlData( NULL );
   774     TRAPD( err, iapId = DefaultAccessPointL() );
   785         LoadDlaWrapperL();
   775     if ( !err )
   786         TRAPD( err, iapId = DefaultAccessPointL() );
   776         {
   787         if ( !err )
   777         iDlaWrapper->SetIapId( iapId );
   788             {
   778         }
   789             iDlaWrapper->SetIapId( iapId );
   779     iDlaWrapper->AcquireLicenseL( aFile, contentUrl, htmlData  );
   790             }
   780     delete contentUrl;
   791         iDlaWrapper->AcquireLicenseL( aFile, contentUrl, htmlData  );
   781     delete htmlData;
   792         delete contentUrl;
       
   793         delete htmlData;
       
   794         }
       
   795     else
       
   796         {
       
   797         if ( !iDrmUtilityUi )
       
   798             {
       
   799             iDrmUtilityUi = DRM::CDrmUtilityUI::NewL( iCoeEnv );
       
   800             }
       
   801         TFileName aFileName;
       
   802         TInt err = aFile.Name(aFileName);
       
   803         iDrmUtilityUi->DisplayNoteL( R_DRMUTILITY_SYNC_WITH_PC , aFileName);
       
   804         }
       
   805     }
   782     }
   806 
   783 
   807 // -----------------------------------------------------------------------------
   784 // -----------------------------------------------------------------------------
   808 // CDrmUtilityWMDrmWrapper::SilentDlaLicenseAcquisitionL
   785 // CDrmUtilityWMDrmWrapper::SilentDlaLicenseAcquisitionL
   809 // -----------------------------------------------------------------------------
   786 // -----------------------------------------------------------------------------
   822 // CDrmUtilityWMDrmWrapper::DefaultAccessPointL
   799 // CDrmUtilityWMDrmWrapper::DefaultAccessPointL
   823 // -----------------------------------------------------------------------------
   800 // -----------------------------------------------------------------------------
   824 //
   801 //
   825 TInt DRM::CDrmUtilityWMDrmWrapper::DefaultAccessPointL()
   802 TInt DRM::CDrmUtilityWMDrmWrapper::DefaultAccessPointL()
   826     {
   803     {
   827     const TInt KDestinationSelectionMode( 2 );
   804     //Fetch default connection
   828     CRepository* repository( NULL );
       
   829     TInt ap( 0 );
       
   830     TInt alwaysAsk( 0 );
       
   831     TUint32 iapd32( 0 );
   805     TUint32 iapd32( 0 );
   832     TInt defaultSnap( 0 );
   806     TCmDefConnValue defConn;
   833 
   807     RCmManager cmManager;
   834     repository = CRepository::NewL( KCRUidBrowser );
   808     cmManager.OpenLC();
   835     CleanupStack::PushL( repository );
   809     cmManager.ReadDefConnL(defConn);
   836     repository->Get( KBrowserDefaultAccessPoint, ap );
   810     if (defConn.iType == ECmDefConnConnectionMethod)
   837     repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk );
   811         {
   838     repository->Get( KBrowserNGDefaultSnapId, defaultSnap );
   812         iapd32=defConn.iId;
   839     CleanupStack::PopAndDestroy( repository );
   813         }
   840 
   814     else if (defConn.iType == ECmDefConnDestination)
   841     if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound )
   815         {
   842         {
   816         RCmDestination dest( cmManager.DestinationL( defConn.iId ) );
   843         alwaysAsk = ETrue;
   817         CleanupClosePushL( dest );
       
   818 
       
   819         if ( dest.ConnectionMethodCount() <= 0 )
       
   820             {
       
   821             User::Leave( KErrNotFound );
       
   822             }
       
   823 
       
   824         RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
       
   825         CleanupClosePushL( cMeth );
       
   826 
       
   827         iapd32 = cMeth.GetIntAttributeL( CMManager::ECmIapId );
       
   828         CleanupStack::PopAndDestroy( 2, &dest ); //cMeth, dest
   844         }
   829         }
   845     else
   830     else
   846         {
   831         {
   847         RCmManager cmManager;
       
   848         cmManager.OpenLC();
       
   849         if ( !alwaysAsk )
       
   850             {
       
   851             iapd32 =
       
   852                 cmManager.GetConnectionMethodInfoIntL( ap,
       
   853                                                        CMManager::ECmIapId );
       
   854             }
       
   855         else if ( alwaysAsk == KDestinationSelectionMode )
       
   856             {
       
   857             RCmDestination dest( cmManager.DestinationL( defaultSnap ) );
       
   858             CleanupClosePushL( dest );
       
   859 
       
   860             if ( dest.ConnectionMethodCount() <= 0 )
       
   861                 {
       
   862                 User::Leave( KErrNotFound );
       
   863                 }
       
   864 
       
   865             RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
       
   866             CleanupClosePushL( cMeth );
       
   867 
       
   868             iapd32 = cMeth.GetIntAttributeL( CMManager::ECmIapId );
       
   869             CleanupStack::PopAndDestroy( 2, &dest ); //cMeth, dest
       
   870             }
       
   871         CleanupStack::PopAndDestroy( &cmManager );
       
   872         }
       
   873     if ( alwaysAsk && alwaysAsk != KDestinationSelectionMode )
       
   874         {
       
   875         User::Leave( KErrAccessDenied );
   832         User::Leave( KErrAccessDenied );
   876         }
   833         }
       
   834     CleanupStack::PopAndDestroy(&cmManager);
       
   835     // End of fetch default connection
   877     return iapd32;
   836     return iapd32;
   878     }
   837     }
   879 
   838 
   880 //  End of File
   839 //  End of File