18 @internalComponent |
18 @internalComponent |
19 @released |
19 @released |
20 */ |
20 */ |
21 |
21 |
22 #include "cmdcoopsysselftest.h" |
22 #include "cmdcoopsysselftest.h" |
|
23 #include "ssmdebug.h" |
|
24 |
|
25 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
26 _LIT( KSecEnvLogicalDeviceDriverName, "secldd" ); |
|
27 #endif //SYMBIAN_INCLUDE_APP_CENTRIC |
23 |
28 |
24 CCustomCmdCoopSysSelfTest* CCustomCmdCoopSysSelfTest::NewL() |
29 CCustomCmdCoopSysSelfTest* CCustomCmdCoopSysSelfTest::NewL() |
25 { |
30 { |
26 CCustomCmdCoopSysSelfTest* self = new (ELeave) CCustomCmdCoopSysSelfTest(); |
31 CCustomCmdCoopSysSelfTest* self = new (ELeave) CCustomCmdCoopSysSelfTest(); |
27 return self; |
32 return self; |
28 } |
33 } |
29 |
34 |
30 CCustomCmdCoopSysSelfTest::CCustomCmdCoopSysSelfTest() |
35 CCustomCmdCoopSysSelfTest::CCustomCmdCoopSysSelfTest() |
31 { |
36 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
37 : iSsmLoadSecLdd(EFalse) |
|
38 #endif //SYMBIAN_INCLUDE_APP_CENTRIC |
|
39 { |
32 } |
40 } |
33 |
41 |
34 CCustomCmdCoopSysSelfTest::~CCustomCmdCoopSysSelfTest() |
42 CCustomCmdCoopSysSelfTest::~CCustomCmdCoopSysSelfTest() |
35 { |
43 { |
36 } |
44 } |
37 |
45 |
38 TInt CCustomCmdCoopSysSelfTest::Initialize(CSsmCustomCommandEnv* /*aCmdEnv*/) |
46 TInt CCustomCmdCoopSysSelfTest::Initialize(CSsmCustomCommandEnv* /*aCmdEnv*/) |
39 { |
47 { |
|
48 TInt err = KErrNone; |
|
49 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
50 //Load the logical device. |
|
51 err = User::LoadLogicalDevice(KSecEnvLogicalDeviceDriverName); |
|
52 DEBUGPRINT2A("CCustomCmdCoopSysSelfTest: LoadLogicalDevice returned error %d", err); |
|
53 iSsmLoadSecLdd = (KErrNone == err) ? ETrue : EFalse; |
|
54 if ( KErrNone == err || KErrAlreadyExists == err ) |
|
55 { |
|
56 err = iSecEnvLogicalChannel.Open(); |
|
57 DEBUGPRINT2A("CCustomCmdCoopSysSelfTest: Opening the Logical channel retured error %d", err); |
|
58 } |
|
59 #else |
40 //Connect RSsmStateAdaptation |
60 //Connect RSsmStateAdaptation |
41 return iSsmStateAdaptation.Connect(); |
61 err = iSsmStateAdaptation.Connect(); |
|
62 #endif //SYMBIAN_INCLUDE_APP_CENTRIC |
|
63 return err; |
42 } |
64 } |
43 |
65 |
44 void CCustomCmdCoopSysSelfTest::Close() |
66 void CCustomCmdCoopSysSelfTest::Close() |
45 { |
67 { |
|
68 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
69 //Cancel the request if there is any |
|
70 iSecEnvLogicalChannel.CancelRequest(KErrCancel); |
|
71 //Close the channel. |
|
72 iSecEnvLogicalChannel.Close(); |
|
73 //Free the ldd if it is loaded by SSM selftest custom command. |
|
74 if (iSsmLoadSecLdd) |
|
75 { |
|
76 //Ignore the error returned by unloading the logical device. |
|
77 TInt err = User::FreeLogicalDevice(KSecEnvDriverName); |
|
78 DEBUGPRINT2A("CCustomCmdCoopSysSelfTest: FreeLogicalDevice() returned error %d", err); |
|
79 } |
|
80 #else |
46 //Cancel the request if there is any |
81 //Cancel the request if there is any |
47 iSsmStateAdaptation.RequestCancel(); |
82 iSsmStateAdaptation.RequestCancel(); |
48 |
83 |
49 //Close RSsmStateAdaptation |
84 // Close RSsmStateAdaptation |
50 iSsmStateAdaptation.Close(); |
85 iSsmStateAdaptation.Close(); |
|
86 #endif //SYMBIAN_INCLUDE_APP_CENTRIC |
51 } |
87 } |
52 |
88 |
53 void CCustomCmdCoopSysSelfTest::Release() |
89 void CCustomCmdCoopSysSelfTest::Release() |
54 { |
90 { |
55 delete this; |
91 delete this; |
56 } |
92 } |
57 |
93 |
58 void CCustomCmdCoopSysSelfTest::Execute(const TDesC8& /*aParams*/, TRequestStatus& aStatus) |
94 void CCustomCmdCoopSysSelfTest::Execute(const TDesC8& /*aParams*/, TRequestStatus& aStatus) |
59 { |
95 { |
60 //Request coop system to perform self test |
96 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
97 iParam.iSelfTest = TSecSelfTest::ESelfTestSecurity; |
|
98 iSecEnvLogicalChannel.ServiceRequest(aStatus, iParam); |
|
99 #else |
|
100 //Request coop system to perform self test |
61 iSsmStateAdaptation.RequestCoopSysSelfTest(aStatus); |
101 iSsmStateAdaptation.RequestCoopSysSelfTest(aStatus); |
|
102 #endif //SYMBIAN_INCLUDE_APP_CENTRIC |
|
103 |
62 } |
104 } |
63 |
105 |
64 void CCustomCmdCoopSysSelfTest::ExecuteCancel() |
106 void CCustomCmdCoopSysSelfTest::ExecuteCancel() |
65 { |
107 { |
|
108 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
109 iSecEnvLogicalChannel.CancelRequest(KErrCancel); |
|
110 #else |
66 //Cancel the request if there is any |
111 //Cancel the request if there is any |
67 iSsmStateAdaptation.RequestCancel(); |
112 iSsmStateAdaptation.RequestCancel(); |
|
113 #endif //SYMBIAN_INCLUDE_APP_CENTRIC |
68 } |
114 } |