commondrm/drmutility/src/drmutilitywmdrmwrapper.cpp
branchRCL_3
changeset 26 1221b68b8a5f
parent 16 457cd4423b8c
child 27 1481bf457703
--- a/commondrm/drmutility/src/drmutilitywmdrmwrapper.cpp	Thu Aug 19 10:12:10 2010 +0300
+++ b/commondrm/drmutility/src/drmutilitywmdrmwrapper.cpp	Tue Aug 31 15:29:38 2010 +0300
@@ -31,18 +31,12 @@
 #include <avkon.hrh>
 
 // access point utils
-#include <centralrepository.h>
+
 #include <cdblen.h>
 #include <cmconnectionmethod.h>
 #include <cmdestination.h>
 #include <cmconnectionmethoddef.h>
 #include <cmmanager.h>
-#ifdef __SERIES60_NATIVE_BROWSER
-#include <browseruisdkcrkeys.h>
-#endif
-
-#include <featdiscovery.h>
-#include <aknmessagequerydialog.h>
 
 #include    <wmdrmagent.h> // for WMDRM file details view
 #include    <drmutilitytypes.h>
@@ -61,19 +55,12 @@
 #include    "drmutilitywmdrmutilities.h"
 
 #include    "wmdrmdlawrapper.h"
-
-using namespace DRM;
+#include    "drmuidialogids.h"
 
 // CONSTANTS
 const TInt KMaxUrlLength( 1024 );
 const TInt KMaxUrlSanityLength( 102400 );
 
-#ifndef __SERIES60_NATIVE_BROWSER
-const TUid KCRUidBrowser = {0x10008D39};
-const TUint32 KBrowserDefaultAccessPoint = 0x0000000E;
-const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E;
-#endif
-
 #ifdef _DEBUG
 // debug panic
 _LIT( KWmDrmWrapperDebugPanicMessage, "WmDrmWrapperDebugPanic" );
@@ -90,8 +77,7 @@
 //
 DRM::CDrmUtilityWMDrmWrapper::CDrmUtilityWMDrmWrapper() :
     iCoeEnv( NULL ),
-    iDrmUtilityUi( NULL ),
-    iWmDrmDlaSupportOn ( ETrue )
+    iDrmUtilityUi( NULL )
     {
     }
 
@@ -103,8 +89,6 @@
 void DRM::CDrmUtilityWMDrmWrapper::ConstructL()
     {
     User::LeaveIfError( iFs.Connect() );
-    TUid u = TUid::Uid( KFeatureIdFfWmdrmDlaSupport );
-    TRAPD(err, iWmDrmDlaSupportOn = CFeatureDiscovery::IsFeatureSupportedL( u ));
     }
 
 // -----------------------------------------------------------------------------
@@ -276,7 +260,7 @@
 
     if ( !value )
         {
-        ShowNoRightsNoteL( aContent, reason );
+        ShowNoRightsNoteL( aContent, reason, aOperationId, aObserver );
         User::LeaveIfError( aContent.GetAttribute( ContentAccess::ECanPlay, value ) );
         if ( value )
             {
@@ -500,7 +484,7 @@
         {
         case DRM::EUHCheckRightsActionDefault:
             {
-            ShowNoRightsNoteL( aContent, aReason );
+            ShowNoRightsNoteL( aContent, aReason, aOperationId, aObserver );
             }
             break;
 
@@ -558,12 +542,15 @@
 //
 void DRM::CDrmUtilityWMDrmWrapper::ShowNoRightsNoteL(
     ContentAccess::CData& aContent,
-    TUint32 /*aReason*/ )
+    TUint32 /*aReason*/,
+    TInt aOperationId,
+    DRM::MDrmHandleErrorObserver* aObserver )
     {
+    TInt value;
     TRAPD( err, LoadDlaWrapperL() );
     if ( !err )
         {
-        TInt ret( EAknSoftkeyYes );
+        TInt ret( EOk );
         RFile file;
         GetRFileFromCDataL( aContent, file );
         CleanupClosePushL( file );
@@ -577,18 +564,21 @@
                 }
             TFileName fileName;
             User::LeaveIfError( aContent.GetStringAttribute( DRM::EDrmFileName, fileName ) );
-            if(iWmDrmDlaSupportOn)
-                {
-                ret = iDrmUtilityUi->DisplayQueryL( R_DRM_QUERY_EXPIRED_OR_NO_RO, fileName );
-                }
-            else
-                {
-                ret = iDrmUtilityUi->DisplayMessageQueryL( R_DRMUTILITY_SYNC_WITH_PC, R_DRMUTILITY_HEAD_NO_LICENSE, fileName);
-                }
+            // Qt dialog not implemented yet
+            ret = iDrmUtilityUi->DisplayQueryL( EQueryFileWithNoRightsObj, fileName );
             }
-        if ( !err && ( ret == EAknSoftkeyYes || ret == EAknSoftkeyOk ) && iWmDrmDlaSupportOn)
+
+        if ( !err && ret == EOk )
             {
             TRAP_IGNORE( DlaLicenseAcquisitionL( file ) );
+            
+            // Ask the rights from CAF, same call for both ECanPlay and ECanView
+            aContent.GetAttribute( ContentAccess::ECanPlay, value );
+            // call given HandleErrorObserver
+            if( value > 0 )
+                {
+                aObserver->RightsAvailable( aOperationId, KErrNone );              
+                }
             }
         CleanupStack::PopAndDestroy( &file );
         }
@@ -598,7 +588,7 @@
             {
             iDrmUtilityUi = DRM::CDrmUtilityUI::NewL( iCoeEnv );
             }
-        iDrmUtilityUi->DisplayNoteL( R_DRM_INFO_EXPIRED_OR_NO_RO );
+        iDrmUtilityUi->DisplayNoteL( EConfLicenceExpired );
         }
     }
 
@@ -777,31 +767,18 @@
 void DRM::CDrmUtilityWMDrmWrapper::DlaLicenseAcquisitionL(
     RFile& aFile )
     {
-    if( iWmDrmDlaSupportOn )
+    TInt iapId( 0 );
+    HBufC* contentUrl( NULL );
+    HBufC* htmlData( NULL );
+    LoadDlaWrapperL();
+    TRAPD( err, iapId = DefaultAccessPointL() );
+    if ( !err )
         {
-        TInt iapId( 0 );
-        HBufC* contentUrl( NULL );
-        HBufC* htmlData( NULL );
-        LoadDlaWrapperL();
-        TRAPD( err, iapId = DefaultAccessPointL() );
-        if ( !err )
-            {
-            iDlaWrapper->SetIapId( iapId );
-            }
-        iDlaWrapper->AcquireLicenseL( aFile, contentUrl, htmlData  );
-        delete contentUrl;
-        delete htmlData;
+        iDlaWrapper->SetIapId( iapId );
         }
-    else
-        {
-        if ( !iDrmUtilityUi )
-            {
-            iDrmUtilityUi = DRM::CDrmUtilityUI::NewL( iCoeEnv );
-            }
-        TFileName aFileName;
-        TInt err = aFile.Name(aFileName);
-        iDrmUtilityUi->DisplayNoteL( R_DRMUTILITY_SYNC_WITH_PC , aFileName);
-        }
+    iDlaWrapper->AcquireLicenseL( aFile, contentUrl, htmlData  );
+    delete contentUrl;
+    delete htmlData;
     }
 
 // -----------------------------------------------------------------------------
@@ -824,56 +801,38 @@
 //
 TInt DRM::CDrmUtilityWMDrmWrapper::DefaultAccessPointL()
     {
-    const TInt KDestinationSelectionMode( 2 );
-    CRepository* repository( NULL );
-    TInt ap( 0 );
-    TInt alwaysAsk( 0 );
+    //Fetch default connection
     TUint32 iapd32( 0 );
-    TInt defaultSnap( 0 );
+    TCmDefConnValue defConn;
+    RCmManager cmManager;
+    cmManager.OpenLC();
+    cmManager.ReadDefConnL(defConn);
+    if (defConn.iType == ECmDefConnConnectionMethod)
+        {
+        iapd32=defConn.iId;
+        }
+    else if (defConn.iType == ECmDefConnDestination)
+        {
+        RCmDestination dest( cmManager.DestinationL( defConn.iId ) );
+        CleanupClosePushL( dest );
 
-    repository = CRepository::NewL( KCRUidBrowser );
-    CleanupStack::PushL( repository );
-    repository->Get( KBrowserDefaultAccessPoint, ap );
-    repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk );
-    repository->Get( KBrowserNGDefaultSnapId, defaultSnap );
-    CleanupStack::PopAndDestroy( repository );
+        if ( dest.ConnectionMethodCount() <= 0 )
+            {
+            User::Leave( KErrNotFound );
+            }
 
-    if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound )
-        {
-        alwaysAsk = ETrue;
+        RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
+        CleanupClosePushL( cMeth );
+
+        iapd32 = cMeth.GetIntAttributeL( CMManager::ECmIapId );
+        CleanupStack::PopAndDestroy( 2, &dest ); //cMeth, dest
         }
     else
         {
-        RCmManager cmManager;
-        cmManager.OpenLC();
-        if ( !alwaysAsk )
-            {
-            iapd32 =
-                cmManager.GetConnectionMethodInfoIntL( ap,
-                                                       CMManager::ECmIapId );
-            }
-        else if ( alwaysAsk == KDestinationSelectionMode )
-            {
-            RCmDestination dest( cmManager.DestinationL( defaultSnap ) );
-            CleanupClosePushL( dest );
-
-            if ( dest.ConnectionMethodCount() <= 0 )
-                {
-                User::Leave( KErrNotFound );
-                }
-
-            RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
-            CleanupClosePushL( cMeth );
-
-            iapd32 = cMeth.GetIntAttributeL( CMManager::ECmIapId );
-            CleanupStack::PopAndDestroy( 2, &dest ); //cMeth, dest
-            }
-        CleanupStack::PopAndDestroy( &cmManager );
-        }
-    if ( alwaysAsk && alwaysAsk != KDestinationSelectionMode )
-        {
         User::Leave( KErrAccessDenied );
         }
+    CleanupStack::PopAndDestroy(&cmManager);
+    // End of fetch default connection
     return iapd32;
     }