|
1 /* |
|
2 * Copyright (c) 2000 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: Implementation of terminalsecurity components |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32debug.h> |
|
21 #include <f32file.h> |
|
22 #include <e32math.h> |
|
23 #include <SCPParamObject.h> |
|
24 #include <hash.h> |
|
25 |
|
26 #include "SCPServer.h" |
|
27 #include "SCPPluginEventHandler.h" |
|
28 #include "SCP_IDs.h" |
|
29 |
|
30 // ================= MEMBER FUNCTIONS ======================= |
|
31 |
|
32 // --------------------------------------------------------- |
|
33 // void CSCPPluginEventHandler::CSCPPluginEventHandler() |
|
34 // C++ default constructor |
|
35 // |
|
36 // Status : Approved |
|
37 // --------------------------------------------------------- |
|
38 // |
|
39 CSCPPluginEventHandler::CSCPPluginEventHandler( RFs* aRfs ): |
|
40 iPluginConfiguration( NULL ), |
|
41 iRfs( aRfs ) |
|
42 { |
|
43 Dprint( (_L("--> CSCPPluginEventHandler::CSCPPluginEventHandler()") )); |
|
44 |
|
45 // No implementation required |
|
46 |
|
47 Dprint( (_L("<-- CSCPPluginEventHandler::CSCPPluginEventHandler()") )); |
|
48 } |
|
49 |
|
50 |
|
51 // --------------------------------------------------------- |
|
52 // void CSCPPluginEventHandler::NewL() |
|
53 // Static constructor |
|
54 // |
|
55 // Status : Approved |
|
56 // --------------------------------------------------------- |
|
57 // |
|
58 CSCPPluginEventHandler* CSCPPluginEventHandler::NewL( RFs* aRfs ) |
|
59 { |
|
60 CSCPPluginEventHandler* self = CSCPPluginEventHandler::NewLC( aRfs ); |
|
61 CleanupStack::Pop( self ); |
|
62 |
|
63 return self; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // void CSCPPluginEventHandler::NewLC() |
|
68 // Static constructor, leaves object pointer to the cleanup stack. |
|
69 // |
|
70 // Status : Approved |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 CSCPPluginEventHandler* CSCPPluginEventHandler::NewLC( RFs* aRfs ) |
|
74 { |
|
75 CSCPPluginEventHandler* self = new (ELeave) CSCPPluginEventHandler( aRfs ); |
|
76 |
|
77 CleanupStack::PushL( self ); |
|
78 self->ConstructL(); |
|
79 |
|
80 return self; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------- |
|
84 // void CSCPPluginEventHandler::ConstructL() |
|
85 // Symbian 2nd phase constructor |
|
86 // |
|
87 // Status : Approved |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 void CSCPPluginEventHandler::ConstructL() |
|
91 { |
|
92 // Read the configuration path |
|
93 iConfigurationPath.Zero(); |
|
94 User::LeaveIfError( iRfs->PrivatePath( iConfigurationPath ) ); |
|
95 |
|
96 // Fetch the configuration for the plugins from disk |
|
97 |
|
98 iPluginConfiguration = CSCPParamObject::NewL(); |
|
99 |
|
100 // Build the configuration file name |
|
101 TFileName cfgFileName = iConfigurationPath; |
|
102 cfgFileName.Append( KSCPPluginConfigFilename ); |
|
103 |
|
104 TRAPD( err, iPluginConfiguration->ReadFromFileL( cfgFileName, iRfs ) ); |
|
105 |
|
106 if ( ( err != KErrNotFound ) && ( err != KErrNone ) ) |
|
107 { |
|
108 Dprint( (_L("CSCPPluginEventHandler::ConstructL(): WARNING:\ |
|
109 failed to read plugin configuration: %d"), err )); |
|
110 } |
|
111 } |
|
112 |
|
113 |
|
114 |
|
115 // --------------------------------------------------------- |
|
116 // void CSCPPluginEventHandler::GetParameters() |
|
117 // Return the stored object pointer. |
|
118 // |
|
119 // Status : Approved |
|
120 // --------------------------------------------------------- |
|
121 // |
|
122 CSCPParamObject& CSCPPluginEventHandler::GetParameters() |
|
123 { |
|
124 return *iPluginConfiguration; |
|
125 } |
|
126 |
|
127 |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // void CSCPPluginEventHandler::GetRfsSession() |
|
131 // Return the stored RFs reference |
|
132 // |
|
133 // Status : Approved |
|
134 // --------------------------------------------------------- |
|
135 // |
|
136 RFs& CSCPPluginEventHandler::GetFsSession() |
|
137 { |
|
138 return *iRfs; |
|
139 } |
|
140 |
|
141 |
|
142 |
|
143 // --------------------------------------------------------- |
|
144 // void CSCPPluginEventHandler::WritePluginConfigurationL() |
|
145 // Get the param buffer from the object and write it to disk |
|
146 // |
|
147 // Status : Approved |
|
148 // --------------------------------------------------------- |
|
149 // |
|
150 TInt CSCPPluginEventHandler::WritePluginConfigurationL() |
|
151 { |
|
152 // Build the configuration file name |
|
153 TFileName cfgFileName; |
|
154 TInt ret = GetStoragePathL( cfgFileName ); |
|
155 if ( ret != KErrNone ) |
|
156 { |
|
157 Dprint( (_L("CSCPPluginEventHandler::WritePluginConfigurationL():\ |
|
158 ERROR: Failed to get storage path: %d"), ret )); |
|
159 User::Leave( ret ); |
|
160 } |
|
161 |
|
162 cfgFileName.Append( KSCPPluginConfigFilename ); |
|
163 |
|
164 TRAP( ret, iPluginConfiguration->WriteToFileL( cfgFileName, iRfs ) ); |
|
165 |
|
166 return ret; |
|
167 } |
|
168 |
|
169 |
|
170 // --------------------------------------------------------- |
|
171 // void CSCPPluginEventHandler::GetStoragePath() |
|
172 // Retrieve the private path and fill it in aPath |
|
173 // |
|
174 // Status : Approved |
|
175 // --------------------------------------------------------- |
|
176 // |
|
177 TInt CSCPPluginEventHandler::GetStoragePathL( TDes& aPath ) |
|
178 { |
|
179 aPath.Copy( iConfigurationPath ); |
|
180 |
|
181 return KErrNone; |
|
182 } |
|
183 |
|
184 |
|
185 |
|
186 // --------------------------------------------------------- |
|
187 // CSCPPluginEventHandler::HashInput() |
|
188 // Use the symbian Crypto API to hash the input buffer. |
|
189 // |
|
190 // Status : Approved |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 TInt CSCPPluginEventHandler::HashInput( TDes& aInput, TDes& aOutput ) |
|
194 { |
|
195 TInt ret = KErrNone; |
|
196 |
|
197 CMD5* hashObject = NULL; |
|
198 TRAP( ret, hashObject = CMD5::NewL() ); |
|
199 |
|
200 #ifdef UNICODE |
|
201 TUint16* inputPtr = const_cast<TUint16*>( aInput.Ptr() ); |
|
202 TPtrC8 inputData( reinterpret_cast<TUint8*>(inputPtr), aInput.Length()*2 ); |
|
203 #else // !UNICODE |
|
204 TPtrC8 inputData = aInput; |
|
205 #endif |
|
206 |
|
207 if ( hashObject != NULL ) |
|
208 { |
|
209 TPtrC8 hash = hashObject->Final( inputData ); |
|
210 aOutput.Copy( hash ); |
|
211 delete hashObject; |
|
212 } |
|
213 |
|
214 return ret; |
|
215 } |
|
216 |
|
217 |
|
218 // --------------------------------------------------------- |
|
219 // CSCPPluginEventHandler::ResetConfigurationL() |
|
220 // Reset the common parameter storage by resetting the ParamObject. |
|
221 // |
|
222 // Status : Approved |
|
223 // --------------------------------------------------------- |
|
224 // |
|
225 void CSCPPluginEventHandler::ResetConfigurationL() |
|
226 { |
|
227 iPluginConfiguration->Reset(); |
|
228 |
|
229 WritePluginConfigurationL(); |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------- |
|
233 // void CSCPPluginEventHandler::~CSCPPluginEventHandler() |
|
234 // Destructor |
|
235 // |
|
236 // Status : Approved |
|
237 // --------------------------------------------------------- |
|
238 // |
|
239 CSCPPluginEventHandler::~CSCPPluginEventHandler() |
|
240 { |
|
241 Dprint( (_L("--> CSCPPluginEventHandler::~CSCPPluginEventHandler()") )); |
|
242 |
|
243 TRAPD( err, WritePluginConfigurationL() ); |
|
244 if ( err != KErrNone ) |
|
245 { |
|
246 Dprint( (_L("CSCPPluginEventHandler::~CSCPPluginEventHandler():\ |
|
247 WARNING: Failed to store plugin configuration: %d"), err )); |
|
248 } |
|
249 delete iPluginConfiguration; |
|
250 |
|
251 Dprint( (_L("<-- CSCPPluginEventHandler::~CSCPPluginEventHandler()") )); |
|
252 } |
|
253 |
|
254 |
|
255 // End of File |
|
256 |