|
1 /* |
|
2 * Copyright (c) 2010 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: Secui dialog notifier server session |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "secuidialognotifiersession.h" // CSecuiDialogNotifierSession |
|
19 #include "secuidialognotifierserver.h" // CSecuiDialogNotifierServer |
|
20 #include "secuidialognotifierservername.h" // KSecuiDialogsCancelOperation |
|
21 // #include "secuidialogoperserverauthfail.h" // CServerAuthFailOperation |
|
22 #include "secuidialogoperbasicpinquery.h" // CBasicPinQueryOperation |
|
23 #include "secuidialogstrace.h" // TRACE macro |
|
24 #include <secdlgimpldefs.h> // TSecurityDialogOperation |
|
25 #include <keyguardaccessapi.h> |
|
26 |
|
27 const TInt KInputParam = 0; |
|
28 const TInt KOutputParam = 1; |
|
29 |
|
30 |
|
31 // ======== MEMBER FUNCTIONS ======== |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CSecuiDialogNotifierSession::NewL() |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CSecuiDialogNotifierSession* CSecuiDialogNotifierSession::NewL() |
|
38 { |
|
39 TRACE( "CBasicPinQueryOperation::RunL, 1 =%d", 1 ); |
|
40 CSecuiDialogNotifierSession* self = new( ELeave ) CSecuiDialogNotifierSession; |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop( self ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession() |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession() |
|
52 { |
|
53 TRACE( "CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession, begin" ); |
|
54 Server().RemoveSession(); |
|
55 delete iOperationHandler; |
|
56 iOperationHandler = NULL; |
|
57 delete iInputBuffer; |
|
58 iInputBuffer = NULL; |
|
59 TRACE( "CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession, end" ); |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CSecuiDialogNotifierSession::CreateL() |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 void CSecuiDialogNotifierSession::CreateL() |
|
67 { |
|
68 TRACE( "CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession" ); |
|
69 Server().AddSession(); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CSecuiDialogNotifierSession::ServiceL() |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void CSecuiDialogNotifierSession::ServiceL( const RMessage2& aMessage ) |
|
77 { |
|
78 TRACE( "CSecuiDialogNotifierSession::ServiceL, message 0x%08x", aMessage.Handle() ); |
|
79 TRAPD( error, DispatchMessageL( aMessage ) ); |
|
80 TRACE( "CSecuiDialogNotifierSession::ServiceL, dispatched, error %d", error ); |
|
81 if( error && !aMessage.IsNull() ) |
|
82 { |
|
83 TRACE( "CSecuiDialogNotifierSession::ServiceL, completing msg 0x%08x", |
|
84 aMessage.Handle() ); |
|
85 aMessage.Complete( error ); |
|
86 } |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CSecuiDialogNotifierSession::OperationComplete() |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 void CSecuiDialogNotifierSession::OperationComplete() |
|
94 { |
|
95 TRACE( "CSecuiDialogNotifierSession::OperationComplete, begin" ); |
|
96 delete iOperationHandler; |
|
97 iOperationHandler = NULL; |
|
98 TRACE( "CSecuiDialogNotifierSession::OperationComplete, end" ); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CSecuiDialogNotifierSession::CSecuiDialogNotifierSession() |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 CSecuiDialogNotifierSession::CSecuiDialogNotifierSession() |
|
106 { |
|
107 TRACE( "CSecuiDialogNotifierSession::CSecuiDialogNotifierSession" ); |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CSecuiDialogNotifierSession::ConstructL() |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void CSecuiDialogNotifierSession::ConstructL() |
|
115 { |
|
116 TRACE( "CSecuiDialogNotifierSession::ConstructL" ); |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // CSecuiDialogNotifierSession::Server() |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 CSecuiDialogNotifierServer& CSecuiDialogNotifierSession::Server() |
|
124 { |
|
125 return *static_cast< CSecuiDialogNotifierServer* >( |
|
126 const_cast< CServer2* >( CSession2::Server() ) ); |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // CSecuiDialogNotifierSession::DispatchMessageL() |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 void CSecuiDialogNotifierSession::DispatchMessageL( const RMessage2& aMessage ) |
|
134 { |
|
135 TRACE( "CSecuiDialogNotifierSession::DispatchMessageL, begin" ); |
|
136 if( !IsOperationCancelled( aMessage ) ) |
|
137 { |
|
138 TInt lOperation = aMessage.Function(); |
|
139 TSecurityDialogOperation operation = |
|
140 static_cast< TSecurityDialogOperation >( lOperation ); |
|
141 TRACE( "CSecuiDialogNotifierSession::DispatchMessageL, operation=%d", operation ); |
|
142 |
|
143 // from AskSecCodeInAutoLockL |
|
144 if(lOperation==0x100+6 /*RMobilePhone::EPhonePasswordRequired*/) |
|
145 { |
|
146 TRACE( "CSecuiDialogNotifierSession::DispatchMessageL, query from AskSecCodeInAutoLockL . No need to start Autolock.exe =%d", 0 ); |
|
147 } |
|
148 else |
|
149 { |
|
150 CKeyguardAccessApi* iKeyguardAccess = CKeyguardAccessApi::NewL( ); |
|
151 TRACE( "CBasicPinQueryOperation::RunL, 1 =%d", 1 ); |
|
152 TInt err = iKeyguardAccess->ShowKeysLockedNote( ); |
|
153 TRACE( "CBasicPinQueryOperation::RunL, err =%d", err ); |
|
154 delete iKeyguardAccess; |
|
155 } |
|
156 TRACE( "CBasicPinQueryOperation::RunL, lOperation =%d", lOperation ); |
|
157 if( lOperation >= 0x1000 ) // flag for iStartup |
|
158 lOperation -= 0x1000; |
|
159 TRACE( "CBasicPinQueryOperation::RunL, new lOperation =%d", lOperation ); |
|
160 if( lOperation < 0x200 ) |
|
161 { |
|
162 BasicPinOperationL( aMessage ); |
|
163 } |
|
164 else |
|
165 { |
|
166 TRACE( "CBasicPinQueryOperation::RunL, lOperation =%d", lOperation ); |
|
167 User::Leave( KErrNotSupported ); |
|
168 } |
|
169 } |
|
170 TRACE( "CSecuiDialogNotifierSession::DispatchMessageL, end" ); |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // CSecuiDialogNotifierSession::IsOperationCancelled() |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 TBool CSecuiDialogNotifierSession::IsOperationCancelled( const RMessage2& aMessage ) |
|
178 { |
|
179 TBool isCancelled = EFalse; |
|
180 if( aMessage.Function() == KSecuiDialogCancelOperation ) |
|
181 { |
|
182 if( iOperationHandler ) |
|
183 { |
|
184 TRACE( "CSecuiDialogNotifierSession::CheckIfOperationCancelledL, cancelling" ); |
|
185 iOperationHandler->CancelOperation(); |
|
186 } |
|
187 TRACE( "CSecuiDialogNotifierSession::CheckIfOperationCancelledL, completing msg 0x%08x", |
|
188 aMessage.Handle() ); |
|
189 aMessage.Complete( KErrNone ); |
|
190 isCancelled = ETrue; |
|
191 } |
|
192 return isCancelled; |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // CSecuiDialogNotifierSession::GetInputBufferL() |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 void CSecuiDialogNotifierSession::GetInputBufferL( const RMessage2& aMessage ) |
|
200 { |
|
201 TInt inputLength = aMessage.GetDesLength( KInputParam ); |
|
202 TRACE( "CSecuiDialogNotifierSession::GetInputBufferL, inputLength=%d", inputLength ); |
|
203 __ASSERT_ALWAYS( inputLength > 0, User::Leave( KErrCorrupt ) ); |
|
204 if( iInputBuffer ) |
|
205 { |
|
206 delete iInputBuffer; |
|
207 iInputBuffer = NULL; |
|
208 } |
|
209 iInputBuffer = HBufC8::NewL( inputLength ); |
|
210 TPtr8 inputBufferPtr( iInputBuffer->Des() ); |
|
211 aMessage.ReadL( KInputParam, inputBufferPtr ); |
|
212 TRACE( "CSecuiDialogNotifierSession::GetInputBufferL, read complete" ); |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // CSecuiDialogNotifierSession::ServerAuthenticationFailureL() |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 void CSecuiDialogNotifierSession::ServerAuthenticationFailureL( const RMessage2& aMessage ) |
|
220 { |
|
221 TRACE( "CSecuiDialogNotifierSession::ServerAuthenticationFailureL, begin" ); |
|
222 GetInputBufferL( aMessage ); |
|
223 |
|
224 ASSERT( iOperationHandler == NULL ); |
|
225 // iOperationHandler = CServerAuthFailOperation::NewL( *this, aMessage, KOutputParam ); |
|
226 // iOperationHandler->StartL( *iInputBuffer ); |
|
227 |
|
228 TRACE( "CSecuiDialogNotifierSession::ServerAuthenticationFailureL, end" ); |
|
229 } |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // CSecuiDialogNotifierSession::BasicPinOperationL() |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 void CSecuiDialogNotifierSession::BasicPinOperationL( const RMessage2& aMessage ) |
|
236 { |
|
237 TRACE( "CSecuiDialogNotifierSession::BasicPinOperationL, begin" ); |
|
238 GetInputBufferL( aMessage ); |
|
239 |
|
240 ASSERT( iOperationHandler == NULL ); |
|
241 iOperationHandler = CBasicPinQueryOperation::NewL( *this, aMessage, KOutputParam ); |
|
242 iOperationHandler->StartL( *iInputBuffer ); |
|
243 |
|
244 TRACE( "CSecuiDialogNotifierSession::BasicPinOperationL, end" ); |
|
245 } |
|
246 |