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