wmdrm/wmdrmengine/wmdrmserver/server/src/wmdrmserver.cpp
changeset 23 493788a4a8a4
parent 0 95b198f216e5
equal deleted inserted replaced
5:79d62d1d7957 23:493788a4a8a4
    14 * Description:  WMDRM Server implementation
    14 * Description:  WMDRM Server implementation
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <bacntf.h>
    18 #include <bacntf.h>
    19 #include <DriveInfo.h>
    19 #include <driveinfo.h>
    20 #include "wmdrmsession.h"
    20 #include "wmdrmsession.h"
    21 #include "wmdrmserver.h"
    21 #include "wmdrmserver.h"
    22 #include "clock.h"
    22 #include "clock.h"
    23 #include "slotdatacache.h"
    23 #include "slotdatacache.h"
    24 #include "slotenumeratorcache.h"
    24 #include "slotenumeratorcache.h"
    30 
    30 
    31 #include "flogger.h"
    31 #include "flogger.h"
    32 #include "logfn.h"
    32 #include "logfn.h"
    33 
    33 
    34 CWmDrmServer::CWmDrmServer():
    34 CWmDrmServer::CWmDrmServer():
    35 	CServer2( CActive::EPriorityStandard,  ESharableSessions ),
    35     CServer2( CActive::EPriorityStandard,  ESharableSessions ),
    36 	iCache( NULL ), iDriveNumber( -1 ), iWmDrmRightsConfigFound( EFalse )
    36     iCache( NULL ), iDriveNumber( -1 ), iWmDrmRightsConfigFound( EFalse )
    37 	{
    37     {
    38 	}
    38     }
    39 
    39 
    40 CServer2* CWmDrmServer::NewLC()
    40 CServer2* CWmDrmServer::NewLC()
    41 	{
    41     {
    42 	LOGFN( "CWmDrmServer::NewLC" );
    42     LOGFN( "CWmDrmServer::NewLC" );
    43 	CWmDrmServer* self = new( ELeave ) CWmDrmServer;
    43     CWmDrmServer* self = new( ELeave ) CWmDrmServer;
    44 	CleanupStack::PushL( self );
    44     CleanupStack::PushL( self );
    45 	self->ConstructL();
    45     self->ConstructL();
    46 	return self;
    46     return self;
    47 	}
    47     }
    48 
    48 
    49 CWmDrmServer::~CWmDrmServer()
    49 CWmDrmServer::~CWmDrmServer()
    50     {
    50     {
    51 	LOGFN( "CWmDrmServer::~CWmDrmServer" );
    51     LOGFN( "CWmDrmServer::~CWmDrmServer" );
    52     delete iCache;
    52     delete iCache;
    53     delete iEnumeratorCache;
    53     delete iEnumeratorCache;
    54     delete iClock;
    54     delete iClock;
    55     delete iDb;
    55     delete iDb;
    56     delete iDataStore;
    56     delete iDataStore;
    57     iFs.Close();
    57     iFs.Close();
    58     }
    58     }
    59 
    59 
    60 void CWmDrmServer::ConstructL()
    60 void CWmDrmServer::ConstructL()
    61 	{
    61     {
    62 	LOGFN( "CWmDrmServer::ConstructL" );
    62     LOGFN( "CWmDrmServer::ConstructL" );
    63 	TDrmScheme drmScheme( EDrmSchemeWmDrm );
    63     TDrmScheme drmScheme( EDrmSchemeWmDrm );
    64 	TChar driveLetter;
    64     TChar driveLetter;
    65 	
    65 
    66 	StartL( KWmDrmServerName );
    66     StartL( KWmDrmServerName );
    67 	User::LeaveIfError( iFs.Connect() );
    67     User::LeaveIfError( iFs.Connect() );
    68     iCache = NULL;
    68     iCache = NULL;
    69 	iEnumeratorCache = NULL;
    69     iEnumeratorCache = NULL;
    70 	ResetCacheL();
    70     ResetCacheL();
    71 	iClock = CClock::NewL( this );
    71     iClock = CClock::NewL( this );
    72 	iClock->Start();
    72     iClock->Start();
    73 	
    73 
    74     // Check which drive is configured in the Central Repository Key
    74     // Check which drive is configured in the Central Repository Key
    75     // for the desired storing location of license and sync stores. 
    75     // for the desired storing location of license and sync stores.
    76 	// Convert the drive letter to drive number and store it.
    76     // Convert the drive letter to drive number and store it.
    77 	iWmDrmRightsConfigFound = 
    77     iWmDrmRightsConfigFound =
    78 	    DrmRightsStoringLocation::CheckDrmRightsStorageDriveL( iFs,
    78         DrmRightsStoringLocation::CheckDrmRightsStorageDriveL( iFs,
    79 	        drmScheme, driveLetter );
    79             drmScheme, driveLetter );
    80 	
    80 
    81 	// Check also the system drive
    81     // Check also the system drive
    82 	DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, iSystemDriveNumber );
    82     DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, iSystemDriveNumber );
    83 	    
    83 
    84     iFs.CharToDrive( driveLetter, iDriveNumber );
    84     iFs.CharToDrive( driveLetter, iDriveNumber );
    85 	
    85 
    86 	iDb = CWmDrmDb::NewL( this );
    86     iDb = CWmDrmDb::NewL( this );
    87 	iDataStore = CWmDrmDataStore::NewL( this );
    87     iDataStore = CWmDrmDataStore::NewL( this );
    88 	}
    88     }
    89 
    89 
    90 void CWmDrmServer::ResetCacheL()
    90 void CWmDrmServer::ResetCacheL()
    91     {
    91     {
    92     LOGFN( "CWmDrmServer::ResetCacheL" );
    92     LOGFN( "CWmDrmServer::ResetCacheL" );
    93     if ( iCache )
    93     if ( iCache )
    94         {
    94         {
    95         delete iCache;
    95         delete iCache;
    96         iCache = NULL;
    96         iCache = NULL;
    97 	    }
    97         }
    98     iCache = CSlotDataCache::NewL( this );
    98     iCache = CSlotDataCache::NewL( this );
    99 	if ( iEnumeratorCache )
    99     if ( iEnumeratorCache )
   100 	    {
   100         {
   101 	    delete iEnumeratorCache;
   101         delete iEnumeratorCache;
   102 	    iEnumeratorCache = NULL;
   102         iEnumeratorCache = NULL;
   103 	    }
   103         }
   104 	iEnumeratorCache = CSlotEnumeratorCache::NewL( this );
   104     iEnumeratorCache = CSlotEnumeratorCache::NewL( this );
   105     }
   105     }
   106 
   106 
   107 CSession2* CWmDrmServer::NewSessionL(
   107 CSession2* CWmDrmServer::NewSessionL(
   108     const TVersion& /*aVersion*/,
   108     const TVersion& /*aVersion*/,
   109     const RMessage2& /*aMessage*/ ) const
   109     const RMessage2& /*aMessage*/ ) const
   110 	{
   110     {
   111 	LOGFN( "CWmDrmServer::NewSessionL" );
   111     LOGFN( "CWmDrmServer::NewSessionL" );
   112 	return new( ELeave ) CWmDrmSession();
   112     return new( ELeave ) CWmDrmSession();
   113 	}
   113     }
   114 
   114 
   115 CSlotDataCache* CWmDrmServer::Cache()
   115 CSlotDataCache* CWmDrmServer::Cache()
   116 	{
   116     {
   117 	return iCache;
   117     return iCache;
   118 	}
   118     }
   119 
   119 
   120 CSlotEnumeratorCache* CWmDrmServer::EnumeratorCache()
   120 CSlotEnumeratorCache* CWmDrmServer::EnumeratorCache()
   121 	{
   121     {
   122     return iEnumeratorCache;
   122     return iEnumeratorCache;
   123 	}
   123     }
   124 
   124 
   125 CClock* CWmDrmServer::Clock()
   125 CClock* CWmDrmServer::Clock()
   126 	{
   126     {
   127 	return iClock;
   127     return iClock;
   128 	}
   128     }
   129 
   129 
   130 RFs& CWmDrmServer::Fs()
   130 RFs& CWmDrmServer::Fs()
   131 	{
   131     {
   132 	return iFs;
   132     return iFs;
   133 	}
   133     }
   134 
   134 
   135 CWmDrmDataStore* CWmDrmServer::DataStore()
   135 CWmDrmDataStore* CWmDrmServer::DataStore()
   136     {
   136     {
   137     return iDataStore;
   137     return iDataStore;
   138     }
   138     }
   148     if ( aConfiguredDrive )
   148     if ( aConfiguredDrive )
   149         {
   149         {
   150         // Check the disk space from the configured drive
   150         // Check the disk space from the configured drive
   151         User::LeaveIfError( iFs.Volume( info, iDriveNumber ) );
   151         User::LeaveIfError( iFs.Volume( info, iDriveNumber ) );
   152         }
   152         }
   153     else 
   153     else
   154         {
   154         {
   155         // Check the disk space from the system drive
   155         // Check the disk space from the system drive
   156         User::LeaveIfError( iFs.Volume( info, iSystemDriveNumber ) );   
   156         User::LeaveIfError( iFs.Volume( info, iSystemDriveNumber ) );
   157         }
   157         }
   158     return info.iFree;    
   158     return info.iFree;
   159     } 
   159     }
   160 
   160 
   161 static void RunServerL()
   161 static void RunServerL()
   162 	{
   162     {
   163 	LOGFN( "RunServerL" );
   163     LOGFN( "RunServerL" );
   164 
   164 
   165 	User::LeaveIfError( RThread::RenameMe( KWmDrmServerName ) );
   165     User::LeaveIfError( RThread::RenameMe( KWmDrmServerName ) );
   166 	CActiveScheduler* s = new( ELeave ) CActiveScheduler;
   166     CActiveScheduler* s = new( ELeave ) CActiveScheduler;
   167 	CleanupStack::PushL( s );
   167     CleanupStack::PushL( s );
   168 	CActiveScheduler::Install( s );
   168     CActiveScheduler::Install( s );
   169     CWmDrmServer::NewLC();
   169     CWmDrmServer::NewLC();
   170 	RProcess::Rendezvous( KErrNone );
   170     RProcess::Rendezvous( KErrNone );
   171 	CActiveScheduler::Start();
   171     CActiveScheduler::Start();
   172 	CleanupStack::PopAndDestroy( 2 ); // server, s
   172     CleanupStack::PopAndDestroy( 2 ); // server, s
   173 	}
   173     }
   174 
   174 
   175 TInt E32Main()
   175 TInt E32Main()
   176 	{
   176     {
   177 	__UHEAP_MARK;
   177     __UHEAP_MARK;
   178 	CTrapCleanup* cleanup = CTrapCleanup::New();
   178     CTrapCleanup* cleanup = CTrapCleanup::New();
   179 	TInt r = KErrNoMemory;
   179     TInt r = KErrNoMemory;
   180 	if ( cleanup )
   180     if ( cleanup )
   181 		{
   181         {
   182 		TRAP( r, RunServerL() );
   182         TRAP( r, RunServerL() );
   183 		delete cleanup;
   183         delete cleanup;
   184 		}
   184         }
   185 	__UHEAP_MARKEND;
   185     __UHEAP_MARKEND;
   186 	return r;
   186     return r;
   187 	}
   187     }