commondrm/drmutility/src/drmutilitywmdrmwrapper.cpp
changeset 29 3bdc3b853094
parent 23 493788a4a8a4
child 49 69d8e75812b7
equal deleted inserted replaced
23:493788a4a8a4 29:3bdc3b853094
    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 
    40 
    44 #include    <wmdrmagent.h> // for WMDRM file details view
    41 #include    <wmdrmagent.h> // for WMDRM file details view
    45 #include    <drmutilitytypes.h>
    42 #include    <drmutilitytypes.h>
    46 #include    <drmuicheckrightsobserver.h>
    43 #include    <drmuicheckrightsobserver.h>
    47 
    44 
    60 #include    "wmdrmdlawrapper.h"
    57 #include    "wmdrmdlawrapper.h"
    61 
    58 
    62 // CONSTANTS
    59 // CONSTANTS
    63 const TInt KMaxUrlLength( 1024 );
    60 const TInt KMaxUrlLength( 1024 );
    64 const TInt KMaxUrlSanityLength( 102400 );
    61 const TInt KMaxUrlSanityLength( 102400 );
    65 
       
    66 #ifndef __SERIES60_NATIVE_BROWSER
       
    67 const TUid KCRUidBrowser = {0x10008D39};
       
    68 const TUint32 KBrowserDefaultAccessPoint = 0x0000000E;
       
    69 const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E;
       
    70 #endif
       
    71 
    62 
    72 #ifdef _DEBUG
    63 #ifdef _DEBUG
    73 // debug panic
    64 // debug panic
    74 _LIT( KWmDrmWrapperDebugPanicMessage, "WmDrmWrapperDebugPanic" );
    65 _LIT( KWmDrmWrapperDebugPanicMessage, "WmDrmWrapperDebugPanic" );
    75 const TInt KWmDrmWrapperDebugPanicCode( 1 );
    66 const TInt KWmDrmWrapperDebugPanicCode( 1 );
   795 // CDrmUtilityWMDrmWrapper::DefaultAccessPointL
   786 // CDrmUtilityWMDrmWrapper::DefaultAccessPointL
   796 // -----------------------------------------------------------------------------
   787 // -----------------------------------------------------------------------------
   797 //
   788 //
   798 TInt DRM::CDrmUtilityWMDrmWrapper::DefaultAccessPointL()
   789 TInt DRM::CDrmUtilityWMDrmWrapper::DefaultAccessPointL()
   799     {
   790     {
   800     const TInt KDestinationSelectionMode( 2 );
   791     //Fetch default connection
   801     CRepository* repository( NULL );
       
   802     TInt ap( 0 );
       
   803     TInt alwaysAsk( 0 );
       
   804     TUint32 iapd32( 0 );
   792     TUint32 iapd32( 0 );
   805     TInt defaultSnap( 0 );
   793     TCmDefConnValue defConn;
   806 
   794     RCmManager cmManager;
   807     repository = CRepository::NewL( KCRUidBrowser );
   795     cmManager.OpenLC();
   808     CleanupStack::PushL( repository );
   796     cmManager.ReadDefConnL(defConn);
   809     repository->Get( KBrowserDefaultAccessPoint, ap );
   797     if (defConn.iType == ECmDefConnConnectionMethod)
   810     repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk );
   798         {
   811     repository->Get( KBrowserNGDefaultSnapId, defaultSnap );
   799         iapd32=defConn.iId;
   812     CleanupStack::PopAndDestroy( repository );
   800         }
   813 
   801     else if (defConn.iType == ECmDefConnDestination)
   814     if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound )
   802         {
   815         {
   803         RCmDestination dest( cmManager.DestinationL( defConn.iId ) );
   816         alwaysAsk = ETrue;
   804         CleanupClosePushL( dest );
       
   805 
       
   806         if ( dest.ConnectionMethodCount() <= 0 )
       
   807             {
       
   808             User::Leave( KErrNotFound );
       
   809             }
       
   810 
       
   811         RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
       
   812         CleanupClosePushL( cMeth );
       
   813 
       
   814         iapd32 = cMeth.GetIntAttributeL( CMManager::ECmIapId );
       
   815         CleanupStack::PopAndDestroy( 2, &dest ); //cMeth, dest
   817         }
   816         }
   818     else
   817     else
   819         {
   818         {
   820         RCmManager cmManager;
       
   821         cmManager.OpenLC();
       
   822         if ( !alwaysAsk )
       
   823             {
       
   824             iapd32 =
       
   825                 cmManager.GetConnectionMethodInfoIntL( ap,
       
   826                                                        CMManager::ECmIapId );
       
   827             }
       
   828         else if ( alwaysAsk == KDestinationSelectionMode )
       
   829             {
       
   830             RCmDestination dest( cmManager.DestinationL( defaultSnap ) );
       
   831             CleanupClosePushL( dest );
       
   832 
       
   833             if ( dest.ConnectionMethodCount() <= 0 )
       
   834                 {
       
   835                 User::Leave( KErrNotFound );
       
   836                 }
       
   837 
       
   838             RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
       
   839             CleanupClosePushL( cMeth );
       
   840 
       
   841             iapd32 = cMeth.GetIntAttributeL( CMManager::ECmIapId );
       
   842             CleanupStack::PopAndDestroy( 2, &dest ); //cMeth, dest
       
   843             }
       
   844         CleanupStack::PopAndDestroy( &cmManager );
       
   845         }
       
   846     if ( alwaysAsk && alwaysAsk != KDestinationSelectionMode )
       
   847         {
       
   848         User::Leave( KErrAccessDenied );
   819         User::Leave( KErrAccessDenied );
   849         }
   820         }
       
   821     CleanupStack::PopAndDestroy(&cmManager);
       
   822     // End of fetch default connection
   850     return iapd32;
   823     return iapd32;
   851     }
   824     }
   852 
   825 
   853 //  End of File
   826 //  End of File