|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "DRMEncryptorAppUi.h" |
|
21 #include "DRMEncryptorContainer.h" |
|
22 #include "DRMEncryptor.hrh" |
|
23 #include "Performance.h" |
|
24 #include "DRMPlayServerTest.h" |
|
25 |
|
26 #include <avkon.hrh> |
|
27 #include <aknnotewrappers.h> |
|
28 |
|
29 extern TUint EncryptL(TUint& aEncryptedCount, TUint& aRightsCount, TUint& aMessagesProcessed); |
|
30 extern TUint KeyStorage(); |
|
31 extern void DeleteRdbL(); |
|
32 extern void GetDrmClockL(); |
|
33 extern void SetDrmClockL(); |
|
34 extern TUint Bb5KeyStorage(); |
|
35 extern void DeleteWmDrmRdbL(); |
|
36 extern void BackupWmDrmDbL(); |
|
37 extern void RestoreWmDrmDbL(); |
|
38 |
|
39 |
|
40 // ================= MEMBER FUNCTIONS ======================= |
|
41 // |
|
42 // ---------------------------------------------------------- |
|
43 // CDRMEncryptorAppUi::ConstructL() |
|
44 // ?implementation_description |
|
45 // ---------------------------------------------------------- |
|
46 // |
|
47 void CDRMEncryptorAppUi::ConstructL() |
|
48 { |
|
49 BaseConstructL(); |
|
50 iAppContainer = new( ELeave ) CDRMEncryptorContainer; |
|
51 iAppContainer->SetMopParent( this ); |
|
52 iAppContainer->ConstructL( ClientRect() ); |
|
53 AddToStackL( iAppContainer ); |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------- |
|
57 // CDRMEncryptorAppUi::~CDRMEncryptorAppUi() |
|
58 // Destructor |
|
59 // Frees reserved resources |
|
60 // ---------------------------------------------------- |
|
61 // |
|
62 CDRMEncryptorAppUi::~CDRMEncryptorAppUi() |
|
63 { |
|
64 if ( iAppContainer ) |
|
65 { |
|
66 RemoveFromStack( iAppContainer ); |
|
67 delete iAppContainer; |
|
68 } |
|
69 } |
|
70 |
|
71 // ---------------------------------------------------- |
|
72 // CDRMEncryptorAppUi::HandleCommandL( TInt aCommand ) |
|
73 // ?implementation_description |
|
74 // ---------------------------------------------------- |
|
75 // |
|
76 void CDRMEncryptorAppUi::HandleCommandL( TInt aCommand ) |
|
77 { |
|
78 TUint result = 0; |
|
79 TUint aEncryptedCount = 0; |
|
80 TUint aRightsCount = 0; |
|
81 TUint aMessagesProcessed = 0; |
|
82 TBuf<128> buffer; |
|
83 |
|
84 switch ( aCommand ) |
|
85 { |
|
86 case EAknSoftkeyExit: |
|
87 case EAknSoftkeyBack: |
|
88 case EEikCmdExit: |
|
89 { |
|
90 Exit(); |
|
91 break; |
|
92 } |
|
93 case EDrmEncryptorUICommand1: |
|
94 { |
|
95 |
|
96 result = EncryptL(aEncryptedCount, aRightsCount, aMessagesProcessed); |
|
97 |
|
98 buffer.Append(_L("Encryption done\n")); |
|
99 if(result < 1) |
|
100 { |
|
101 buffer.Append(_L("No files found")); |
|
102 } |
|
103 if(aMessagesProcessed != 0) |
|
104 { |
|
105 buffer.AppendNum(aMessagesProcessed); |
|
106 buffer.Append(_L(" messages processed\n")); |
|
107 } |
|
108 if(aRightsCount != 0) |
|
109 { |
|
110 buffer.AppendNum(aRightsCount); |
|
111 buffer.Append(_L(" rights objects processed\n")); |
|
112 } |
|
113 if(aMessagesProcessed != 0) |
|
114 { |
|
115 buffer.AppendNum(aEncryptedCount); |
|
116 buffer.Append(_L(" files encrypted\n")); |
|
117 } |
|
118 |
|
119 CAknInformationNote* informationNote = new (ELeave) CAknInformationNote; |
|
120 informationNote->ExecuteLD(buffer); |
|
121 |
|
122 break; |
|
123 } |
|
124 case EDrmEncryptorKeyCommand: |
|
125 { |
|
126 result = KeyStorage(); |
|
127 |
|
128 if(result < 1) |
|
129 { |
|
130 buffer.Append(_L("No key files found")); |
|
131 } |
|
132 else |
|
133 { |
|
134 buffer.Append(_L("Keys imported\n")); |
|
135 buffer.AppendNum(result); |
|
136 buffer.Append(_L(" keys imported")); |
|
137 } |
|
138 CAknInformationNote* informationNote = new (ELeave) CAknInformationNote; |
|
139 informationNote->ExecuteLD(buffer); |
|
140 break; |
|
141 } |
|
142 case EDrmEncryptorDeleteCommand: |
|
143 { |
|
144 DeleteRdbL(); |
|
145 CAknInformationNote* informationNote = new (ELeave) CAknInformationNote; |
|
146 informationNote->ExecuteLD(_L("Database deleted")); |
|
147 break; |
|
148 } |
|
149 case EDrmTimeCommand: |
|
150 { |
|
151 GetDrmClockL(); |
|
152 break; |
|
153 } |
|
154 case ESetDrmTimeCommand: |
|
155 { |
|
156 SetDrmClockL(); |
|
157 break; |
|
158 } |
|
159 case EDrmBb5KeyTestCommand: |
|
160 { |
|
161 result = Bb5KeyStorage(); |
|
162 |
|
163 if(result != KErrNone) |
|
164 { |
|
165 buffer.Append(_L("No CMLA keys available")); |
|
166 buffer.AppendNum(result); |
|
167 |
|
168 } |
|
169 else |
|
170 { |
|
171 buffer.Append(_L(" CMLA data OK! \n")); |
|
172 buffer.AppendNum(result); |
|
173 buffer.Append(_L(" \n Check log for Root.")); |
|
174 } |
|
175 CAknInformationNote* informationNote = new (ELeave) CAknInformationNote; |
|
176 informationNote->ExecuteLD(buffer); |
|
177 break; |
|
178 } |
|
179 case EDRMPlayServerCommand: |
|
180 { |
|
181 CDRMPlayServerTest* test = CDRMPlayServerTest::NewLC(); |
|
182 TInt error = test->ExecutePlayServerTest(); |
|
183 CleanupStack::PopAndDestroy( test ); |
|
184 if ( error == KErrCANoRights ) |
|
185 { |
|
186 buffer.Append(_L("Test succeeded\n")); |
|
187 buffer.Append(_L("DRMPlayServer can't be used with WMDRM")); |
|
188 } |
|
189 else |
|
190 { |
|
191 buffer.Append(_L("Test failed with error code: ")); |
|
192 buffer.AppendNum(error); |
|
193 } |
|
194 CAknInformationNote* informationNote = new (ELeave) CAknInformationNote; |
|
195 informationNote->ExecuteLD(buffer); |
|
196 break; |
|
197 } |
|
198 case EDrmEncryptorDeleteWmDrmCommand: |
|
199 { |
|
200 DeleteWmDrmRdbL(); |
|
201 CAknInformationNote* informationNote = new (ELeave) CAknInformationNote; |
|
202 informationNote->ExecuteLD(_L("WmDrm Rights Deleted")); |
|
203 break; |
|
204 } |
|
205 case EDrmEncryptorBackupWmDrmCommand: |
|
206 { |
|
207 TRAPD( error, BackupWmDrmDbL() ); |
|
208 if ( !error ) |
|
209 { |
|
210 buffer.Append(_L("WmDrm License DB backup succeeded")); |
|
211 } |
|
212 else |
|
213 { |
|
214 buffer.Append(_L("WmDrm License DB backup failed")); |
|
215 } |
|
216 CAknInformationNote* informationNote = new (ELeave) CAknInformationNote; |
|
217 informationNote->ExecuteLD(buffer); |
|
218 break; |
|
219 } |
|
220 case EDrmEncryptorRestoreWmDrmCommand: |
|
221 { |
|
222 TRAPD( error, RestoreWmDrmDbL() ); |
|
223 if ( !error ) |
|
224 { |
|
225 buffer.Append(_L("WmDrm License DB restore succeeded")); |
|
226 } |
|
227 else |
|
228 { |
|
229 buffer.Append(_L("WmDrm License DB restore failed")); |
|
230 } |
|
231 CAknInformationNote* informationNote = new (ELeave) CAknInformationNote; |
|
232 informationNote->ExecuteLD(buffer); |
|
233 break; |
|
234 } |
|
235 default: |
|
236 TestPerformanceL(aCommand); |
|
237 |
|
238 buffer.Append(_L("Performance test done\n")); |
|
239 buffer.Append(_L("See results from \nc:\\logs\\performance.log")); |
|
240 |
|
241 CAknInformationNote* informationNote = new (ELeave) CAknInformationNote; |
|
242 informationNote->ExecuteLD(buffer); |
|
243 |
|
244 break; |
|
245 } |
|
246 } |
|
247 |
|
248 |
|
249 TBool CDRMEncryptorAppUi::ProcessCommandParametersL( |
|
250 TApaCommand /*aCommand*/, |
|
251 TFileName& /*aDocumentName*/, |
|
252 const TDesC8& /*aTail*/) |
|
253 { |
|
254 return EFalse; |
|
255 } |
|
256 |
|
257 // End of File |