omadrm/drmhelper/src/drmhelper.cpp
branchRCL_3
changeset 26 1221b68b8a5f
parent 16 457cd4423b8c
child 27 1481bf457703
equal deleted inserted replaced
25:50c53e893c3f 26:1221b68b8a5f
    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
       
    64 #include "DRMHelperServer.h"
    62 #include "DRMHelperServer.h"
    65 #include "ConsumeData.h"
    63 #include "ConsumeData.h"
    66 #include "DRMTypes.h"
    64 #include "DRMTypes.h"
    67 #include "DRMClockClient.h"
    65 #include "DRMClockClient.h"
    68 #include "DRMPointerArray.h"
    66 #include "DRMPointerArray.h"
       
    67 #include <drmbrowserlauncher.h>
    69 
    68 
    70 #include <SecondaryDisplay/DRMHelperSecondaryDisplay.h> // for secondary display support
    69 #include <SecondaryDisplay/DRMHelperSecondaryDisplay.h> // for secondary display support
    71 #include <AknMediatorFacade.h>
    70 #include <AknMediatorFacade.h>
    72 #include <MediatorEventProvider.h>
    71 #include <MediatorEventProvider.h>
    73 #include <MediatorDomainUIDs.h>
    72 #include <MediatorDomainUIDs.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.
   838         iFs.Close();
   860         iFs.Close();
   839         }
   861         }
   840 
   862 
   841     FeatureManager::UnInitializeLib();
   863     FeatureManager::UnInitializeLib();
   842 
   864 
   843     delete iSchemeHandler;
       
   844     delete iEventProvider;
   865     delete iEventProvider;
   845     }
   866     }
   846 
   867 
   847 #pragma mark -
   868 #pragma mark -
   848 
   869 
  2337         }
  2358         }
  2338 
  2359 
  2339     if ( buttonCode == EAknSoftkeyYes )
  2360     if ( buttonCode == EAknSoftkeyYes )
  2340         {
  2361         {
  2341         // check if there are any APs defined
  2362         // check if there are any APs defined
  2342         RCmManager cmManager;
  2363         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 )
  2364         if ( !APs )
  2350             {
  2365             {
  2351             // No AP defined
  2366             // No AP defined
  2352             DisplayInfoNoteL( R_DRM_WARN_NO_CONN_DEFINED );
  2367             DisplayInfoNoteL( R_DRM_WARN_NO_CONN_DEFINED );
  2353             r = KErrCANoRights;
  2368             r = KErrCANoRights;
  2428     return EFalse;
  2443     return EFalse;
  2429 #endif
  2444 #endif
  2430     }
  2445     }
  2431 
  2446 
  2432 
  2447 
       
  2448 // -----------------------------------------------------------------------------
       
  2449 // CDRMHelper::CheckRightsPercentL
       
  2450 // Note: obsolete function name kept only
       
  2451 // to avoid SC break on Helper selection logic
       
  2452 // -----------------------------------------------------------------------------
       
  2453 //
  2433 TBool CDRMHelper::BrowserAPDefinedL()
  2454 TBool CDRMHelper::BrowserAPDefinedL()
  2434     {
  2455     {
  2435     const TInt KDestinationSelectionMode( 2 );
  2456     TBool apFound( EFalse );
  2436     TInt err( KErrNone );
  2457     TRAP_IGNORE( apFound = HasDefaultConnectionL() );
  2437     TInt ap( 0 );
  2458     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     }
  2459     }
  2471 
  2460 
  2472 
  2461 
  2473 #pragma mark -
  2462 #pragma mark -
  2474 
  2463 
  3625     ptr.SetLength( length );
  3614     ptr.SetLength( length );
  3626     for ( TInt i = 0 ; i < aUrl->Length(); i++ )
  3615     for ( TInt i = 0 ; i < aUrl->Length(); i++ )
  3627         {
  3616         {
  3628         ptr[index++] = ( unsigned char ) (*aUrl)[i];
  3617         ptr[index++] = ( unsigned char ) (*aUrl)[i];
  3629         }
  3618         }
  3630     
  3619 
  3631     ptr[index] = ( unsigned char ) KMarker()[0];
  3620     ptr[index] = ( unsigned char ) KMarker()[0];
  3632     
  3621 
  3633     CleanupStack::PopAndDestroy( localIDBuf );
  3622     CleanupStack::PopAndDestroy( localIDBuf );
  3634     }
  3623     }
  3635 
  3624 
  3636 
  3625 
  3637 // -----------------------------------------------------------------------------
  3626 // -----------------------------------------------------------------------------
  5557             newUrl->Des().Append( ptr.Mid( i ) );
  5546             newUrl->Des().Append( ptr.Mid( i ) );
  5558             ptr.Set( *newUrl );
  5547             ptr.Set( *newUrl );
  5559             i = 0;
  5548             i = 0;
  5560             }
  5549             }
  5561 
  5550 
  5562         CSchemeHandler* schemeHandler( CSchemeHandler::NewL( ptr.Mid( i ) ) );
  5551 				// convert given URL to QUrl format
  5563         CleanupStack::PushL( schemeHandler );
  5552 				DRM::CDrmBrowserLauncher* browserLauncher = DRM::CDrmBrowserLauncher::NewLC();
  5564         if ( iUseCoeEnv )
  5553     	
  5565             {
  5554 		    browserLauncher->LaunchUrlL(ptr);
  5566             // launch embedded
  5555     
  5567             schemeHandler->Observer( this );
  5556     		CleanupStack::PopAndDestroy(); // browserLauncher
  5568             schemeHandler->HandleUrlEmbeddedL();
  5557 
  5569             CleanupStack::Pop( schemeHandler );
  5558         
  5570             iSchemeHandler = schemeHandler;
       
  5571             iWait.Start();
       
  5572             }
       
  5573         else
       
  5574             {
       
  5575             // no CoeEnv, launch standalone with scheme app
       
  5576             schemeHandler->HandleUrlStandaloneL();
       
  5577             CleanupStack::PopAndDestroy( schemeHandler );
       
  5578             }
       
  5579         schemeHandler = NULL;
       
  5580 
       
  5581         // delete newUrl if needed
  5559         // delete newUrl if needed
  5582         if ( newUrl )
  5560         if ( newUrl )
  5583             {
  5561             {
  5584             CleanupStack::PopAndDestroy( newUrl );
  5562             CleanupStack::PopAndDestroy( newUrl );
  5585             }
  5563             }
  5605         TAiwGenericParam param( EGenericParamFile, variantObject );
  5583         TAiwGenericParam param( EGenericParamFile, variantObject );
  5606         paramList->AppendL( param );
  5584         paramList->AppendL( param );
  5607 
  5585 
  5608         CAknLaunchAppService* launchAppService =
  5586         CAknLaunchAppService* launchAppService =
  5609             CAknLaunchAppService::NewL( KUidDRMUI, this, paramList );
  5587             CAknLaunchAppService::NewL( KUidDRMUI, this, paramList );
  5610         
  5588 
  5611         CleanupStack::PushL( launchAppService );
  5589         CleanupStack::PushL( launchAppService );
  5612         iWait.Start();
  5590         iWait.Start();
  5613 
  5591 
  5614         CleanupStack::PopAndDestroy( 2, paramList ); // paramList, launchAppService
  5592         CleanupStack::PopAndDestroy( 2, paramList ); // paramList, launchAppService
  5615         }
  5593         }
  7031     }
  7009     }
  7032 
  7010 
  7033 EXPORT_C TInt CDRMHelper::SupportedDRMMethods2(
  7011 EXPORT_C TInt CDRMHelper::SupportedDRMMethods2(
  7034     TInt& aDRMMethod, TDRMHelperOMALevel& aOMALevel)
  7012     TInt& aDRMMethod, TDRMHelperOMALevel& aOMALevel)
  7035     {
  7013     {
  7036     if ( !( FeatureManager::FeatureSupported( KFeatureIdFfOmadrm1FullSupport ) ) )
  7014 #ifndef __DRM_FULL
  7037         {
  7015     aDRMMethod = CDRMHelper::EForwardLock;
  7038         aDRMMethod = CDRMHelper::EForwardLock;
  7016 #else
  7039         }
  7017     aDRMMethod =
  7040     else
  7018         CDRMHelper::EForwardLock |
  7041         {
  7019         CDRMHelper::ECombinedDelivery |
  7042         aDRMMethod =
  7020         CDRMHelper::ESeparateDelivery |
  7043                 CDRMHelper::EForwardLock |
  7021         CDRMHelper::ESuperDistribution;
  7044                 CDRMHelper::ECombinedDelivery |
       
  7045                 CDRMHelper::ESeparateDelivery |
       
  7046                 CDRMHelper::ESuperDistribution;
       
  7047         aOMALevel = EOMA_1_0;
       
  7048         }
       
  7049     
       
  7050 #ifdef __DRM_OMA2
  7022 #ifdef __DRM_OMA2
  7051     if ( FeatureManager::FeatureSupported( KFeatureIdFfOmadrm2Support ) )
  7023     aOMALevel = EOMA_2_0;
  7052         {
  7024 #else
  7053         aOMALevel = EOMA_2_0;
  7025     aOmaLevel = EOMA_1_0;
  7054         }
       
  7055 #endif // __DRM_OMA2
  7026 #endif // __DRM_OMA2
  7056 
  7027 
       
  7028 #endif // __DRM_FULL
  7057     return KErrNone;
  7029     return KErrNone;
  7058     }
  7030     }
  7059 
  7031 
  7060 
  7032 
  7061 // -----------------------------------------------------------------------------
  7033 // -----------------------------------------------------------------------------
  7062 // CDRMHelper::HandleServerAppExit
  7034 // CDRMHelper::HandleServerAppExit
  7063 // -----------------------------------------------------------------------------
  7035 // -----------------------------------------------------------------------------
  7064 //
  7036 //
  7065 void CDRMHelper::HandleServerAppExit( TInt aReason )
  7037 void CDRMHelper::HandleServerAppExit( TInt aReason )
  7066     {
  7038     {
  7067     if ( aReason == EAknCmdExit && !iSchemeHandler )
  7039     if ( aReason == EAknCmdExit )
  7068         {
  7040         {
  7069         CAknEnv::RunAppShutter();
  7041         CAknEnv::RunAppShutter();
  7070         }
       
  7071 
       
  7072     if ( iSchemeHandler )
       
  7073         {
       
  7074         delete iSchemeHandler;
       
  7075         iSchemeHandler = NULL;
       
  7076         }
  7042         }
  7077 
  7043 
  7078     if ( iWait.IsStarted() )
  7044     if ( iWait.IsStarted() )
  7079         {
  7045         {
  7080         iWait.AsyncStop();
  7046         iWait.AsyncStop();