omadrm/drmhelper/src/drmhelper.cpp
changeset 29 3bdc3b853094
parent 23 493788a4a8a4
child 31 908beac81e0a
equal deleted inserted replaced
23:493788a4a8a4 29:3bdc3b853094
    23 #include "DRMHelperInfoNoteWrapper.h"
    23 #include "DRMHelperInfoNoteWrapper.h"
    24 #include "DRMRightsClient.h"
    24 #include "DRMRightsClient.h"
    25 #include "DcfCommon.h"
    25 #include "DcfCommon.h"
    26 #include "DRMHelperDownloadManager.h"
    26 #include "DRMHelperDownloadManager.h"
    27 
    27 
    28 #include <sacls.h>
       
    29 #include <Drmhelper.rsg>
    28 #include <Drmhelper.rsg>
    30 #include <AknQueryDialog.h>
    29 #include <AknQueryDialog.h>
    31 #include <DRMCommon.h>
    30 #include <DRMCommon.h>
    32 
    31 
    33 #include <starterclient.h>
    32 #include <starterclient.h>
    58 
    57 
    59 #include <AknLaunchAppService.h> // for launching RMUI embedded
    58 #include <AknLaunchAppService.h> // for launching RMUI embedded
    60 
    59 
    61 #include <utf.h>
    60 #include <utf.h>
    62 
    61 
    63 #include <SchemeHandler.h> // for handling URLs
    62 #include <schemehandler.h> // for handling URLs
    64 #include "DRMHelperServer.h"
    63 #include "DRMHelperServer.h"
    65 #include "ConsumeData.h"
    64 #include "ConsumeData.h"
    66 #include "DRMTypes.h"
    65 #include "DRMTypes.h"
    67 #include "DRMClockClient.h"
    66 #include "DRMClockClient.h"
    68 #include "DRMPointerArray.h"
    67 #include "DRMPointerArray.h"
    81 #include "drmsettingsplugininternalcrkeys.h"
    80 #include "drmsettingsplugininternalcrkeys.h"
    82 #endif
    81 #endif
    83 #include "DRMRIContext.h"
    82 #include "DRMRIContext.h"
    84 #include "DRMDomainContext.h"
    83 #include "DRMDomainContext.h"
    85 
    84 
    86 #include <cmconnectionmethod.h>
       
    87 #include <cmdestination.h>
       
    88 #include <cmconnectionmethoddef.h>
       
    89 #include <cmmanager.h>
       
    90 
       
    91 // publish & subrscibe
    85 // publish & subrscibe
    92 #include <e32property.h>
    86 #include <e32property.h>
    93 #include <PSVariables.h>
    87 #include <PSVariables.h>
    94 
    88 
    95 #ifdef __SERIES60_NATIVE_BROWSER
    89 
    96 #include <BrowserUiSDKCRKeys.h>
    90 //connectivity logic
    97 #endif
    91 #include <cmconnectionmethod.h> // RCmConnectionMethod
    98 
    92 #include <cmdestination.h> // RCmDestination
    99 #ifndef __SERIES60_NATIVE_BROWSER
    93 #include <cmmanager.h> // RCmManager
   100 const TUid KCRUidBrowser   = {0x10008D39};
       
   101 const TUint32 KBrowserDefaultAccessPoint =  0x0000000E;
       
   102 const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E;
       
   103 #endif
       
   104 
       
   105 
    94 
   106 // EXTERNAL DATA STRUCTURES
    95 // EXTERNAL DATA STRUCTURES
   107 
    96 
   108 // EXTERNAL FUNCTION PROTOTYPES
    97 // EXTERNAL FUNCTION PROTOTYPES
   109 
    98 
   167 private:
   156 private:
   168     T iHandle;
   157     T iHandle;
   169     };
   158     };
   170 
   159 
   171 // ============================= LOCAL FUNCTIONS ===============================
   160 // ============================= LOCAL FUNCTIONS ===============================
   172 
   161 // -----------------------------------------------------------------------------
   173 // -----------------------------------------------------------------------------
   162 // HasDefaultConnectionL
   174 // IapIdOfDefaultSnapL
   163 // Finds default IAP id
   175 // for trapping purposes only
   164 // @return Etrue: valid AP found
   176 // -----------------------------------------------------------------------------
   165 //         EFalse: valid AP not found
   177 //
   166 // @leave system wide error codes
   178 LOCAL_C TUint32 IapIdOfDefaultSnapL(
   167 // -----------------------------------------------------------------------------
   179     RCmManager& aCmManager,
   168 //
   180     const TUint32 aDefaultSnap )
   169 LOCAL_C TBool HasDefaultConnectionL()
   181     {
   170     {
   182     RCmDestination dest( aCmManager.DestinationL( aDefaultSnap ) );
   171     TBool hasDefault(EFalse);
   183     CleanupClosePushL( dest );
   172     TCmDefConnValue defConn;
   184     TUint32 iapIdOfDest( 0 );
   173     RCmManager cmManager;
   185 
   174     cmManager.OpenLC();
   186     if ( dest.ConnectionMethodCount() <= 0 )
   175     cmManager.ReadDefConnL(defConn);
   187         {
   176     if (defConn.iType == ECmDefConnConnectionMethod)
   188         User::Leave( KErrNotFound );
   177         {
   189         }
   178         cmManager.GetConnectionMethodInfoIntL(defConn.iId,
   190 
   179                 CMManager::ECmIapId);
   191     RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
   180         hasDefault = ETrue;
   192     CleanupClosePushL( cMeth );
   181         }
   193 
   182     else if (defConn.iType == ECmDefConnDestination)
   194     iapIdOfDest = cMeth.GetIntAttributeL( CMManager::ECmIapId );
   183         {
   195     CleanupStack::PopAndDestroy( &cMeth );
   184         RCmDestination dest(cmManager.DestinationL(defConn.iId));
   196     CleanupStack::PopAndDestroy( &dest );
   185         CleanupClosePushL(dest);
   197     return iapIdOfDest;
   186 
       
   187         if (dest.ConnectionMethodCount() <= 0)
       
   188             {
       
   189             User::Leave(KErrNotFound);
       
   190             }
       
   191 
       
   192         RCmConnectionMethod cMeth(dest.ConnectionMethodL(0));
       
   193         CleanupClosePushL(cMeth);
       
   194 
       
   195         cMeth.GetIntAttributeL(CMManager::ECmIapId);
       
   196         CleanupStack::PopAndDestroy(&cMeth);
       
   197         CleanupStack::PopAndDestroy(&dest);
       
   198         hasDefault = ETrue;
       
   199         }
       
   200     CleanupStack::PopAndDestroy(&cmManager);
       
   201     return hasDefault;
       
   202     }
       
   203 
       
   204 // -----------------------------------------------------------------------------
       
   205 // HasAccessPointsL
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 LOCAL_C TBool HasAccessPointsL()
       
   209     {
       
   210     TInt apCount(0);
       
   211     RCmManager cmManager;
       
   212     CleanupClosePushL(cmManager);
       
   213     cmManager.OpenL();
       
   214     RArray<TUint32> aps;
       
   215     CleanupClosePushL(aps);
       
   216     cmManager.ConnectionMethodL(aps, EFalse, EFalse, ETrue);
       
   217     apCount = aps.Count();
       
   218     CleanupStack::PopAndDestroy(2, &cmManager); //aps, cmManager
       
   219     return apCount > 0;
   198     }
   220     }
   199 
   221 
   200 // -----------------------------------------------------------------------------
   222 // -----------------------------------------------------------------------------
   201 // Creates note for resource text to be viewed,
   223 // Creates note for resource text to be viewed,
   202 // Defaults to information note.
   224 // Defaults to information note.
  2337         }
  2359         }
  2338 
  2360 
  2339     if ( buttonCode == EAknSoftkeyYes )
  2361     if ( buttonCode == EAknSoftkeyYes )
  2340         {
  2362         {
  2341         // check if there are any APs defined
  2363         // check if there are any APs defined
  2342         RCmManager cmManager;
  2364         TBool APs( HasAccessPointsL() );
  2343         cmManager.OpenLC();
       
  2344         RArray<TUint32> aps;
       
  2345         CleanupClosePushL( aps );
       
  2346         cmManager.ConnectionMethodL( aps, EFalse, EFalse, ETrue );
       
  2347         TUint32 APs( aps.Count() );
       
  2348         CleanupStack::PopAndDestroy( 2, &cmManager ); //aps, cmManager
       
  2349         if ( !APs )
  2365         if ( !APs )
  2350             {
  2366             {
  2351             // No AP defined
  2367             // No AP defined
  2352             DisplayInfoNoteL( R_DRM_WARN_NO_CONN_DEFINED );
  2368             DisplayInfoNoteL( R_DRM_WARN_NO_CONN_DEFINED );
  2353             r = KErrCANoRights;
  2369             r = KErrCANoRights;
  2428     return EFalse;
  2444     return EFalse;
  2429 #endif
  2445 #endif
  2430     }
  2446     }
  2431 
  2447 
  2432 
  2448 
       
  2449 // -----------------------------------------------------------------------------
       
  2450 // CDRMHelper::CheckRightsPercentL
       
  2451 // Note: obsolete function name kept only
       
  2452 // to avoid SC break on Helper selection logic
       
  2453 // -----------------------------------------------------------------------------
       
  2454 //
  2433 TBool CDRMHelper::BrowserAPDefinedL()
  2455 TBool CDRMHelper::BrowserAPDefinedL()
  2434     {
  2456     {
  2435     const TInt KDestinationSelectionMode( 2 );
  2457     TBool apFound( EFalse );
  2436     TInt err( KErrNone );
  2458     TRAP_IGNORE( apFound = HasDefaultConnectionL() );
  2437     TInt ap( 0 );
  2459     return apFound;
  2438     TInt alwaysAsk( 0 );
       
  2439     TInt defaultSnap( 0 );
       
  2440 
       
  2441     CRepository* repository( CRepository::NewL( KCRUidBrowser ) );
       
  2442     repository->Get( KBrowserDefaultAccessPoint, ap );
       
  2443     repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk );
       
  2444     repository->Get( KBrowserNGDefaultSnapId, defaultSnap );
       
  2445     delete repository;
       
  2446     if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound )
       
  2447         {
       
  2448         alwaysAsk = ETrue;
       
  2449         }
       
  2450     else
       
  2451         {
       
  2452         RCmManager cmManager;
       
  2453         cmManager.OpenLC();
       
  2454         if ( !alwaysAsk )
       
  2455             {
       
  2456             TRAP( err, cmManager.GetConnectionMethodInfoIntL(
       
  2457                     ap, CMManager::ECmIapId ) );
       
  2458             }
       
  2459         else if ( alwaysAsk == KDestinationSelectionMode )
       
  2460             {
       
  2461             TRAP( err, IapIdOfDefaultSnapL( cmManager, defaultSnap ) );
       
  2462             }
       
  2463         CleanupStack::PopAndDestroy( &cmManager );
       
  2464         if ( !err && ( !alwaysAsk || alwaysAsk == KDestinationSelectionMode ) )
       
  2465             {
       
  2466             return ETrue;
       
  2467             }
       
  2468         }
       
  2469     return EFalse;
       
  2470     }
  2460     }
  2471 
  2461 
  2472 
  2462 
  2473 #pragma mark -
  2463 #pragma mark -
  2474 
  2464