|
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: Terminal Control DM Adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __SMLTCADAPTER_H__ |
|
21 #define __SMLTCADAPTER_H__ |
|
22 |
|
23 // --------------------------------------------------------------------- |
|
24 // Includes |
|
25 // --------------------------------------------------------------------- |
|
26 // symbian |
|
27 #include <e32base.h> |
|
28 #include <smldmadapter.h> |
|
29 // s60 |
|
30 #include "TARMDmAdapter.h" |
|
31 #include "TerminalControlClient.h" |
|
32 #include <PolicyEngineClient.h> |
|
33 |
|
34 #define TCADAPTER_FILESCAN_EXECUTE_LEAF |
|
35 |
|
36 const TUint KSmlDMTCAdapterImplUid = 0x10207824; |
|
37 |
|
38 #ifndef MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64 |
|
39 #define MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64 21 |
|
40 #endif |
|
41 |
|
42 // The string value for true/false |
|
43 _LIT8( KTCValueTrue, "true" ); |
|
44 _LIT8( KTCValueFalse, "false" ); |
|
45 |
|
46 // Passcode min/max length |
|
47 const TInt KTCPassCodeMinLen = 4; |
|
48 const TInt KTCPassCodeMaxLen = 255; |
|
49 |
|
50 // the DDF version must be changed if any changes in |
|
51 // DDF structure ( built in DDFStructureL() function ) |
|
52 _LIT8( KSmlTCDDFVersion, "1.0" ); |
|
53 |
|
54 _LIT8( KSmlTCTextPlain, "text/plain" ); |
|
55 _LIT8( KSmlTCTextXml, "text/xml" ); |
|
56 |
|
57 _LIT8( KTCNodeName, "TerminalSecurity" ); |
|
58 _LIT8( KTCNodeDescription, |
|
59 "This node is the root node for all terminal control functionality" ); |
|
60 |
|
61 _LIT8( KTCFileScanNodeName, "FileScan" ); |
|
62 _LIT8( KTCFileScanNodeDescription, |
|
63 "The file scan feature delivers to admin a list of files or \ |
|
64 folders found in device" ); |
|
65 |
|
66 #ifdef TCADAPTER_FILESCAN_EXECUTE_LEAF |
|
67 _LIT8( KTCFileScanExecuteNodeName, "Execute" ); |
|
68 _LIT8( KTCFileScanExecuteNodeDescription, |
|
69 "This node can be used to execute file scan operation." ); |
|
70 #endif |
|
71 |
|
72 _LIT8( KTCFileScanResultsNodeName, "Results" ); |
|
73 _LIT8( KTCFileScanResultsNodeDescription, |
|
74 "This node will hold the scan results" ); |
|
75 |
|
76 _LIT8( KTCFileDeleteNodeName, "FileDelete" ); |
|
77 _LIT8( KTCFileDeleteNodeDescription, "Deletes a file or empty folder" ); |
|
78 |
|
79 _LIT8( KTCDeviceLockNodeName, "DeviceLock" ); |
|
80 _LIT8( KTCDeviceLockNodeDescription, |
|
81 "The parent node for all DeviceLock related nodes" ); |
|
82 |
|
83 _LIT8( KTCAutoLockPeriodNodeName, "AutoLockPeriod" ); |
|
84 _LIT8( KTCAutoLockPeriodNodeDescription, |
|
85 "AutoLockPeriod is an integer that tells after how many minutes the device \ |
|
86 will be automatically locked if not used" ); |
|
87 |
|
88 _LIT8( KTCMaxAutoLockPeriodNodeName, "MaxAutoLockPeriod" ); |
|
89 _LIT8( KTCMaxAutoLockPeriodNodeDescription, |
|
90 "MaxAutoLockPeriod is an integer that tells maximum value of AutoLockPeriod" ); |
|
91 |
|
92 _LIT8( KTCLockLevelNodeName, "LockLevel" ); |
|
93 _LIT8( KTCLockLevelNodeDescription, |
|
94 "Lock level tells whether lock is enabled, and what type of lock it is" ); |
|
95 |
|
96 _LIT8( KTCLockCodeNodeName, "LockCode" ); |
|
97 _LIT8( KTCLockCodeNodeDescription, |
|
98 "LockCode is the character sequence that is needed to open locked device" ); |
|
99 |
|
100 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
101 // -------- Enhanced features BEGIN |
|
102 |
|
103 _LIT8( KTCLockCodeMinLengthNodeName, "LockCodeMinLength" ); |
|
104 _LIT8( KTCLockCodeMinLengthNodeDescription, |
|
105 "LockCode minimum length, 4-256 characters" ); |
|
106 |
|
107 _LIT8( KTCLockCodeMaxLengthNodeName, "LockCodeMaxLength" ); |
|
108 _LIT8( KTCLockCodeMaxLengthNodeDescription, |
|
109 "LockCode maximum length, 4-256 characters" ); |
|
110 |
|
111 _LIT8( KTCLockCodeRequireUpperAndLowerNodeName, |
|
112 "LockCodeRequireUpperAndLower" ); |
|
113 _LIT8( KTCLockCodeRequireUpperAndLowerNodeDescription, |
|
114 "If enabled the LockCode must contain both upper and lower case letters" ); |
|
115 |
|
116 _LIT8( KTCLockCodeRequireCharsAndNumbersNodeName, |
|
117 "LockCodeRequireCharsAndNumbers" ); |
|
118 _LIT8( KTCLockCodeRequireCharsAndNumbersNodeDescription, |
|
119 "If enabled the LockCode must contain both chars and numbers" ); |
|
120 |
|
121 _LIT8( KTCLockCodeMaxRepeatedCharactersNodeName, |
|
122 "LockCodeMaxRepeatedCharacters" ); |
|
123 _LIT8( KTCLockCodeMaxRepeatedCharactersNodeDescription, |
|
124 "Tells how many times a single character can be used in a password. \ |
|
125 Values between 0 and 4, 0 = no restriction" ); |
|
126 |
|
127 _LIT8( KTCLockCodeHistoryBufferNodeName, "LockCodeHistoryBuffer" ); |
|
128 _LIT8( KTCLockCodeHistoryBufferNodeDescription, |
|
129 "History buffer for previously used lock codes. 0 = no restriction, \ |
|
130 1-X = the lock code can not match the previous X lock codes" ); |
|
131 |
|
132 _LIT8( KTCLockCodeExpirationNodeName, "LockCodeExpiration" ); |
|
133 _LIT8( KTCLockCodeExpirationNodeDescription, |
|
134 "The password expires after X days, 0 = no restriction, 1-365" ); |
|
135 |
|
136 _LIT8( KTCLockCodeMinChangeToleranceNodeName, "LockCodeMinChangeTolerance" ); |
|
137 _LIT8( KTCLockCodeMinChangeToleranceNodeDescription, |
|
138 "The user can change the password only X times before 'minimum change \ |
|
139 interval' hours has passed" ); |
|
140 |
|
141 _LIT8( KTCLockCodeMinChangeIntervalNodeName, "LockCodeMinChangeInterval" ); |
|
142 _LIT8( KTCLockCodeMinChangeIntervalNodeDescription, |
|
143 "The user cannot change the password more than 'minimum change tolerance' \ |
|
144 times before X hours have passed since the previous change" ); |
|
145 |
|
146 _LIT8( KTCLockCodeCheckSpecificStringsNodeName,"LockCodeCheckSpecificStrings" ); |
|
147 _LIT8( KTCLockCodeCheckSpecificStringsNodeDescription, |
|
148 "0 = No restriction, 1 = The password cannot match a string in the set of \ |
|
149 strings given by the next three calls" ); |
|
150 |
|
151 _LIT8( KTCLockCodeDisallowSpecificNodeName, "LockCodeDisallowSpecific" ); |
|
152 _LIT8( KTCLockCodeDisallowSpecificNodeDescription, |
|
153 "Disallow the specific string/strings given. Individual strings can be \ |
|
154 separated with ';'" ); |
|
155 |
|
156 _LIT8( KTCLockCodeAllowSpecificNodeName, "LockCodeAllowSpecific" ); |
|
157 _LIT8( KTCLockCodeAllowSpecificNodeDescription, |
|
158 "Re-allow the specific string/strings given. \ |
|
159 Individual strings can be separated with ';'" ); |
|
160 |
|
161 _LIT8( KTCLockCodeClearSpecificStringsNodeName, "LockCodeClearSpecificStrings" ); |
|
162 _LIT8( KTCLockCodeClearSpecificStringsNodeDescription, |
|
163 "Clear the specific string -buffer" ); |
|
164 |
|
165 _LIT8( KTCLockCodeMaxAttemptsNodeName, "LockCodeMaxAttempts" ); |
|
166 _LIT8( KTCLockCodeMaxAttemptsNodeDescription, |
|
167 "0 = No restriction, 3-100 = The device is 'hard' reset after the user has \ |
|
168 consecutively failed X times to answer the password query" ); |
|
169 |
|
170 _LIT8( KTCLockCodeConsecutiveNumbersNodeName, "LockCodeConsecutiveNumbers" ); |
|
171 _LIT8( KTCLockCodeConsecutiveNumbersNodeDescription, |
|
172 "0 = No restriction, 1 = The password cannot contain two consecutive numbers" ); |
|
173 |
|
174 _LIT8( KTCLockCodeMinSpecialCharactersNodeName, |
|
175 "LockCodeMinSpecialCharacters" ); |
|
176 _LIT8( KTCLockCodeMinSpecialCharactersNodeDescription, |
|
177 "Tells the least number of special characters that must be present in the lock code. \ |
|
178 Values between 0 and 255, 0 = no restriction" ); |
|
179 |
|
180 _LIT8( KTCLockCodeDisallowSimpleNodeName, "LockCodeDisallowSimple" ); |
|
181 _LIT8( KTCLockCodeDisallowSimpleNodeDescription, |
|
182 "0 = No restriction, 1 = The password cannot be a simple string" ); |
|
183 |
|
184 |
|
185 |
|
186 // -------- Enhanced features END |
|
187 //#endif |
|
188 |
|
189 _LIT8( KTCDeviceWipeNodeName, "DeviceWipe" ); |
|
190 _LIT8( KTCDeviceWipeNodeDescription, |
|
191 "This node is the root node for all terminal control functionality" ); |
|
192 |
|
193 _LIT8( KTCLocalOperationsNodeName, "LocalOperations" ); |
|
194 _LIT8( KTCLocalOperationsNodeDescription, |
|
195 "This node is common parent for all local operations" ); |
|
196 |
|
197 _LIT8( KTCStartNodeName, "Start" ); |
|
198 _LIT8( KTCStartNodeDescription, |
|
199 "Exec command causes device to start an application" ); |
|
200 |
|
201 _LIT8( KTCStopNodeName, "Stop" ); |
|
202 _LIT8( KTCStopNodeDescription, |
|
203 "Exec command causes device to stop an application or process" ); |
|
204 |
|
205 _LIT8( KTCProcessesNodeName, "Processes" ); |
|
206 _LIT8( KTCProcessesNodeDescription, |
|
207 "TThis is root for all process related information that is \ |
|
208 available for the admin" ); |
|
209 |
|
210 _LIT8( KTCProcessesDynaNodeDescription, |
|
211 "This node is placeholder for an identity of a process" ); |
|
212 |
|
213 _LIT8( KTCIDNodeName, "ID" ); |
|
214 _LIT8( KTCIDNodeDescription, |
|
215 "This leaf node holds the unique id of the process" ); |
|
216 |
|
217 _LIT8( KTCFromRAMNodeName, "FromRAM" ); |
|
218 _LIT8( KTCFromRAMNodeDescription, |
|
219 "This leaf holds knowledge whether the process has been loaded from \ |
|
220 RAM or ROM. " ); |
|
221 |
|
222 _LIT8( KTCMemoryInfoNodeName, "MemoryInfo" ); |
|
223 _LIT8( KTCMemoryInfoNodeDescription, |
|
224 "This node holds some extra information about memory usage of the process." ); |
|
225 |
|
226 _LIT8( KTCProcessFilenameNodeName, "Filename" ); |
|
227 _LIT8( KTCProcessFilenameNodeDescription, |
|
228 "This node holds the filename of the process" ); |
|
229 |
|
230 _LIT8( KTCRebootNodeName, "Reboot" ); |
|
231 _LIT8( KTCRebootNodeDescription, |
|
232 "This node is the root node for all terminal control functionality" ); |
|
233 |
|
234 _LIT8( KTCDynamicNodeName, "" ); |
|
235 _LIT( KTCSeparator16, "/" ); |
|
236 |
|
237 _LIT8( KTCSeparator8, "/" ); |
|
238 |
|
239 // ------------------------------------------------------------------- |
|
240 // CSmlDmEmailAdapter |
|
241 // ------------------------------------------------------------------- |
|
242 class CTcAdapter : public CTARMDmAdapter//, public MMsvSessionObserver |
|
243 { |
|
244 private: |
|
245 enum TTcNodeIdentifier |
|
246 { |
|
247 ETcNodeTerminalControl = 0, |
|
248 ETcNodeFileScan, |
|
249 #ifdef TCADAPTER_FILESCAN_EXECUTE_LEAF |
|
250 ETcNodeFileScanExecute, |
|
251 #endif |
|
252 ETcNodeFileScanResults, |
|
253 ETcNodeFileDelete, |
|
254 ETcNodeDeviceLock, |
|
255 ETcNodeAutoLockPeriod, |
|
256 ETcNodeMaxAutoLockPeriod, |
|
257 ETcNodeLockLevel, |
|
258 ETcNodeLockCode, |
|
259 // --------- Enhanced features BEGIN ------------------ |
|
260 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
261 ETcNodeLockCodeMinLength, |
|
262 ETcNodeLockCodeMaxLength, |
|
263 ETcNodeLockCodeRequireUpperAndLower, |
|
264 ETcNodeLockCodeRequireCharsAndNumbers, |
|
265 ETcNodeLockCodeMaxRepeatedCharacters, |
|
266 ETcNodeLockCodeHistoryBuffer, |
|
267 ETcNodeLockCodeExpiration, |
|
268 ETcNodeLockCodeMinChangeTolerance, |
|
269 ETcNodeLockCodeMinChangeInterval, |
|
270 ETcNodeLockCodeCheckSpecificStrings, |
|
271 ETcNodeLockCodeDisallowSpecific, |
|
272 ETcNodeLockCodeAllowSpecific, |
|
273 ETcNodeLockCodeClearSpecificStrings, |
|
274 ETcNodeLockCodeMaxAttempts, |
|
275 ETcNodeLockConsecutiveNumbers, |
|
276 ETcNodeLockCodeMinSpecialCharacters, |
|
277 ETcNodeLockDisallowSimple, |
|
278 //#endif |
|
279 // --------- Enhanced features END -------------------- |
|
280 ETcNodeDeviceWipe, |
|
281 ETcNodeProcesses, |
|
282 ETcNodeProcessesX, |
|
283 ETcNodeID, |
|
284 ETcNodeFromRAM, |
|
285 ETcNodeMemoryInfo, |
|
286 ETcNodeFilename, |
|
287 ETcNodeReboot, |
|
288 ETcNodeLocalOperations, |
|
289 ETcNodeStart, |
|
290 ETcNodeStop, |
|
291 ETcNodeNotUsedAndAlwaysLast |
|
292 }; |
|
293 |
|
294 enum TTcNodeAccessType |
|
295 { |
|
296 ENoAccess = 0, |
|
297 EExecute = 1, |
|
298 EGet = 2, |
|
299 EReplace = 4, |
|
300 }; |
|
301 |
|
302 static const TInt iAccessTypeList[ETcNodeNotUsedAndAlwaysLast+1]; |
|
303 |
|
304 TInt iAccessHistory[ETcNodeNotUsedAndAlwaysLast+1]; |
|
305 |
|
306 public: |
|
307 CTcAdapter(TAny* aEcomArguments); |
|
308 |
|
309 static CTcAdapter* NewL(MSmlDmCallback* aDmCallback ); |
|
310 static CTcAdapter* NewLC(MSmlDmCallback* aDmCallback ); |
|
311 |
|
312 virtual ~CTcAdapter(); |
|
313 |
|
314 // Pure virtual methods |
|
315 void DDFVersionL( CBufBase& aVersion ); |
|
316 |
|
317 void DDFStructureL( MSmlDmDDFObject& aDDF ); |
|
318 |
|
319 CSmlDmAdapter::TError FetchLeafObjectL( const TDesC8& aURI, |
|
320 const TDesC8& aLUID, const TDesC8& aType, |
|
321 CBufFlat* aObject, CBufFlat* aRetMime ); |
|
322 |
|
323 // From CTARMDmAdapter |
|
324 void _UpdateLeafObjectL( const TDesC8& aURI, |
|
325 const TDesC8& aLUID, const TDesC8& aObject, |
|
326 const TDesC8& aType, TInt aStatusRef ); |
|
327 void _UpdateLeafObjectL( const TDesC8& aURI, |
|
328 const TDesC8& aLUID, RWriteStream*& aStream, |
|
329 const TDesC8& aType, TInt aStatusRef ); |
|
330 void _DeleteObjectL( const TDesC8& aURI, |
|
331 const TDesC8& aLUID, TInt aStatusRef ); |
|
332 void _FetchLeafObjectL( const TDesC8& aURI, |
|
333 const TDesC8& aLUID, const TDesC8& aType, |
|
334 TInt aResultsRef, TInt aStatusRef ); |
|
335 void _FetchLeafObjectSizeL( const TDesC8& aURI, |
|
336 const TDesC8& aLUID, const TDesC8& aType, |
|
337 TInt aResultsRef, TInt aStatusRef ); |
|
338 void _ChildURIListL( const TDesC8& aURI, |
|
339 const TDesC8& aLUID, |
|
340 const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, |
|
341 TInt aResultsRef, TInt aStatusRef ); |
|
342 void _AddNodeObjectL( const TDesC8& aURI, |
|
343 const TDesC8& aParentLUID, TInt aStatusRef ); |
|
344 void _ExecuteCommandL( const TDesC8& aURI, |
|
345 const TDesC8& aLUID, const TDesC8& aArgument, |
|
346 const TDesC8& aType, TInt aStatusRef ); |
|
347 void _ExecuteCommandL( const TDesC8& aURI, |
|
348 const TDesC8& aLUID, RWriteStream*& aStream, |
|
349 const TDesC8& aType, TInt aStatusRef ); |
|
350 void _CopyCommandL( const TDesC8& aTargetURI, |
|
351 const TDesC8& aTargetLUID, const TDesC8& aSourceURI, |
|
352 const TDesC8& aSourceLUID, const TDesC8& aType, |
|
353 TInt aStatusRef ); |
|
354 |
|
355 void StartAtomicL(); |
|
356 void CommitAtomicL(); |
|
357 void RollbackAtomicL(); |
|
358 TBool StreamingSupport( TInt& aItemSize ); |
|
359 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
360 virtual void StreamCommittedL( RWriteStream& aStream ); |
|
361 #else |
|
362 virtual void StreamCommittedL(); |
|
363 #endif |
|
364 void CompleteOutstandingCmdsL(); |
|
365 |
|
366 TInt StartProcessL(const TDesC8& aURI); |
|
367 TInt StopProcessL(const TDesC8& aURI); |
|
368 |
|
369 private: |
|
370 void ConstructL(MSmlDmCallback* aDmCallback); |
|
371 |
|
372 void FillNodeInfoL(MSmlDmDDFObject& aNode,TSmlDmAccessTypes aAccTypes, |
|
373 MSmlDmDDFObject::TOccurence aOccurrence, |
|
374 MSmlDmDDFObject::TScope aScope, |
|
375 MSmlDmDDFObject::TDFFormat aFormat, |
|
376 const TDesC8& aDescription, |
|
377 const TDesC8& aMimeType); |
|
378 |
|
379 void CopyAndTrimMimeType(TDes8& aNewMime, const TDesC8& aType); |
|
380 void CopyAndTrimURI(TDes8& aNewURI, const TDesC8& aURI); |
|
381 void ParseStartPathL(const TDesC8 &aArguments, |
|
382 TDes8 &aStartPath, TBool &aRecursive); |
|
383 |
|
384 TTcNodeIdentifier GetNodeIdentifier(const TDesC8& aURI); |
|
385 TInt NewTerminalControlSession(); |
|
386 TInt CheckTerminalControlSession(); |
|
387 TPtrC8 PolicyRequestResourceL( const TDesC8& aURI ); |
|
388 |
|
389 void _UpdateLeafObjectToBeTrappedL( const TDesC8& aURI, |
|
390 const TDesC8& aLUID, |
|
391 const TDesC8& aObject, const TDesC8& aType, |
|
392 const TInt aStatusRef); |
|
393 |
|
394 void FetchLeafObjectToBeTrappedL( const TDesC8& aURI, |
|
395 const TDesC8& aLUID, |
|
396 const TDesC8& aType, |
|
397 CBufFlat* aObject, |
|
398 CBufFlat* aRetMime ); |
|
399 |
|
400 void _ExecuteCommandToBeTrappedL( const TDesC8& aURI, |
|
401 const TDesC8& aLUID, |
|
402 const TDesC8& aArgument, |
|
403 const TDesC8& aType, |
|
404 TInt aStatusRef ); |
|
405 |
|
406 private: |
|
407 |
|
408 RTerminalControl iTC; |
|
409 RTerminalControlSession iTCSession; |
|
410 TBool iConnected; |
|
411 |
|
412 // Rollback information |
|
413 TInt32 iAutoLockPeriod; |
|
414 TInt32 iLockLevel; |
|
415 TInt32 iMaxAutoLockPeriod; |
|
416 // --------- Enhanced features BEGIN ------------------ |
|
417 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
418 TInt32 iLockCodeMinLength; |
|
419 TInt32 iLockCodeMaxLength; |
|
420 TBool iLockCodeRequireUpperAndLower; |
|
421 TInt32 iLockCodeRequireUpperAndLowerInt; |
|
422 TBool iLockCodeRequireCharsAndNumbers; |
|
423 TInt32 iLockCodeRequireCharsAndNumbersInt; |
|
424 TInt32 iLockCodeMaxRepeatedCharacters; |
|
425 TInt32 iLockCodeHistoryBuffer; |
|
426 TInt32 iLockCodeExpiration; |
|
427 TInt32 iLockCodeMinChangeTolerance; |
|
428 TInt32 iLockCodeMinChangeInterval; |
|
429 TBool iLockCodeCheckSpecificStrings; |
|
430 TInt32 iLockCodeCheckSpecificStringsInt; |
|
431 TInt32 iLockCodeMaxAttempts; |
|
432 TBool iLockCodeConsecutiveNumbers; |
|
433 TInt32 iLockCodeConsecutiveNumbersInt; |
|
434 TInt32 iLockCodeMinSpecialCharacters; |
|
435 TBool iLockCodeDisallowSimple; |
|
436 TInt32 iLockCodeDisallowSimpleInt; |
|
437 |
|
438 //#endif |
|
439 // --------- Enhanced features END -------------------- |
|
440 |
|
441 }; |
|
442 |
|
443 #endif // __SMLTCADAPTER_H__ |