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