|
1 /* |
|
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: WMDRM Server implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <bacntf.h> |
|
19 #include <DriveInfo.h> |
|
20 #include "wmdrmsession.h" |
|
21 #include "wmdrmserver.h" |
|
22 #include "clock.h" |
|
23 #include "slotdatacache.h" |
|
24 #include "slotenumeratorcache.h" |
|
25 #include "wmdrmdatastore.h" |
|
26 #include "wmdrmdb.h" |
|
27 #include "drmrightsstoringlocation.h" |
|
28 |
|
29 #define _LOGGING_FILE L"wmdrmserver.txt" |
|
30 |
|
31 #include "flogger.h" |
|
32 #include "logfn.h" |
|
33 |
|
34 CWmDrmServer::CWmDrmServer(): |
|
35 CServer2( CActive::EPriorityStandard, ESharableSessions ), |
|
36 iCache( NULL ), iDriveNumber( -1 ), iWmDrmRightsConfigFound( EFalse ) |
|
37 { |
|
38 } |
|
39 |
|
40 CServer2* CWmDrmServer::NewLC() |
|
41 { |
|
42 LOGFN( "CWmDrmServer::NewLC" ); |
|
43 CWmDrmServer* self = new( ELeave ) CWmDrmServer; |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 CWmDrmServer::~CWmDrmServer() |
|
50 { |
|
51 LOGFN( "CWmDrmServer::~CWmDrmServer" ); |
|
52 delete iCache; |
|
53 delete iEnumeratorCache; |
|
54 delete iClock; |
|
55 delete iDb; |
|
56 delete iDataStore; |
|
57 iFs.Close(); |
|
58 } |
|
59 |
|
60 void CWmDrmServer::ConstructL() |
|
61 { |
|
62 LOGFN( "CWmDrmServer::ConstructL" ); |
|
63 TDrmScheme drmScheme( EDrmSchemeWmDrm ); |
|
64 TChar driveLetter; |
|
65 |
|
66 StartL( KWmDrmServerName ); |
|
67 User::LeaveIfError( iFs.Connect() ); |
|
68 iCache = NULL; |
|
69 iEnumeratorCache = NULL; |
|
70 ResetCacheL(); |
|
71 iClock = CClock::NewL( this ); |
|
72 iClock->Start(); |
|
73 |
|
74 // Check which drive is configured in the Central Repository Key |
|
75 // for the desired storing location of license and sync stores. |
|
76 // Convert the drive letter to drive number and store it. |
|
77 iWmDrmRightsConfigFound = |
|
78 DrmRightsStoringLocation::CheckDrmRightsStorageDriveL( iFs, |
|
79 drmScheme, driveLetter ); |
|
80 |
|
81 // Check also the system drive |
|
82 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, iSystemDriveNumber ); |
|
83 |
|
84 iFs.CharToDrive( driveLetter, iDriveNumber ); |
|
85 |
|
86 iDb = CWmDrmDb::NewL( this ); |
|
87 iDataStore = CWmDrmDataStore::NewL( this ); |
|
88 } |
|
89 |
|
90 void CWmDrmServer::ResetCacheL() |
|
91 { |
|
92 LOGFN( "CWmDrmServer::ResetCacheL" ); |
|
93 if ( iCache ) |
|
94 { |
|
95 delete iCache; |
|
96 iCache = NULL; |
|
97 } |
|
98 iCache = CSlotDataCache::NewL( this ); |
|
99 if ( iEnumeratorCache ) |
|
100 { |
|
101 delete iEnumeratorCache; |
|
102 iEnumeratorCache = NULL; |
|
103 } |
|
104 iEnumeratorCache = CSlotEnumeratorCache::NewL( this ); |
|
105 } |
|
106 |
|
107 CSession2* CWmDrmServer::NewSessionL( |
|
108 const TVersion& /*aVersion*/, |
|
109 const RMessage2& /*aMessage*/ ) const |
|
110 { |
|
111 LOGFN( "CWmDrmServer::NewSessionL" ); |
|
112 return new( ELeave ) CWmDrmSession(); |
|
113 } |
|
114 |
|
115 CSlotDataCache* CWmDrmServer::Cache() |
|
116 { |
|
117 return iCache; |
|
118 } |
|
119 |
|
120 CSlotEnumeratorCache* CWmDrmServer::EnumeratorCache() |
|
121 { |
|
122 return iEnumeratorCache; |
|
123 } |
|
124 |
|
125 CClock* CWmDrmServer::Clock() |
|
126 { |
|
127 return iClock; |
|
128 } |
|
129 |
|
130 RFs& CWmDrmServer::Fs() |
|
131 { |
|
132 return iFs; |
|
133 } |
|
134 |
|
135 CWmDrmDataStore* CWmDrmServer::DataStore() |
|
136 { |
|
137 return iDataStore; |
|
138 } |
|
139 |
|
140 CWmDrmDb* CWmDrmServer::Db() |
|
141 { |
|
142 return iDb; |
|
143 } |
|
144 |
|
145 TInt64 CWmDrmServer::FreeSpaceL( TBool aConfiguredDrive ) |
|
146 { |
|
147 TVolumeInfo info; |
|
148 if ( aConfiguredDrive ) |
|
149 { |
|
150 // Check the disk space from the configured drive |
|
151 User::LeaveIfError( iFs.Volume( info, iDriveNumber ) ); |
|
152 } |
|
153 else |
|
154 { |
|
155 // Check the disk space from the system drive |
|
156 User::LeaveIfError( iFs.Volume( info, iSystemDriveNumber ) ); |
|
157 } |
|
158 return info.iFree; |
|
159 } |
|
160 |
|
161 static void RunServerL() |
|
162 { |
|
163 LOGFN( "RunServerL" ); |
|
164 |
|
165 User::LeaveIfError( RThread::RenameMe( KWmDrmServerName ) ); |
|
166 CActiveScheduler* s = new( ELeave ) CActiveScheduler; |
|
167 CleanupStack::PushL( s ); |
|
168 CActiveScheduler::Install( s ); |
|
169 CWmDrmServer::NewLC(); |
|
170 RProcess::Rendezvous( KErrNone ); |
|
171 CActiveScheduler::Start(); |
|
172 CleanupStack::PopAndDestroy( 2 ); // server, s |
|
173 } |
|
174 |
|
175 TInt E32Main() |
|
176 { |
|
177 __UHEAP_MARK; |
|
178 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
179 TInt r = KErrNoMemory; |
|
180 if ( cleanup ) |
|
181 { |
|
182 TRAP( r, RunServerL() ); |
|
183 delete cleanup; |
|
184 } |
|
185 __UHEAP_MARKEND; |
|
186 return r; |
|
187 } |