|
33
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2002-2008 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: This is the handler for the SIM Application Toolkit
|
|
|
15 |
* Get Input proactive command.
|
|
|
16 |
*
|
|
|
17 |
*/
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
#include <e32svr.h>
|
|
|
21 |
#include "RSatUiSession.h"
|
|
|
22 |
#include "MSatUiObserver.h"
|
|
|
23 |
#include "CSatCGetInputHandler.h"
|
|
|
24 |
#include "SatSOpcodes.h"
|
|
|
25 |
#include "SatSTypes.h"
|
|
|
26 |
#include "SatLog.h"
|
|
|
27 |
|
|
|
28 |
// ======== MEMBER FUNCTIONS ========
|
|
|
29 |
|
|
|
30 |
// -----------------------------------------------------------------------------
|
|
|
31 |
// CSatCGetInputHandler::CSatCGetInputHandler
|
|
|
32 |
// C++ default constructor can NOT contain any code, that
|
|
|
33 |
// might leave.
|
|
|
34 |
// -----------------------------------------------------------------------------
|
|
|
35 |
//
|
|
|
36 |
CSatCGetInputHandler::CSatCGetInputHandler(
|
|
|
37 |
TInt aPriority,
|
|
|
38 |
RSatUiSession* aSession ) :
|
|
|
39 |
CActive( aPriority ),
|
|
|
40 |
iSession( aSession ),
|
|
|
41 |
iGetInputData(),
|
|
|
42 |
iGetInputPckg( iGetInputData ),
|
|
|
43 |
iGetInputRsp(),
|
|
|
44 |
iGetInputRspPckg( iGetInputRsp )
|
|
|
45 |
{
|
|
|
46 |
LOG( SIMPLE,
|
|
|
47 |
"SATINTERNALCLIENT: CSatCGetInputHandler::CSatCGetInputHandler calling" )
|
|
|
48 |
|
|
|
49 |
// Add to active scheduler.
|
|
|
50 |
CActiveScheduler::Add( this );
|
|
|
51 |
|
|
|
52 |
LOG( SIMPLE,
|
|
|
53 |
"SATINTERNALCLIENT: CSatCGetInputHandler::CSatCGetInputHandler exiting" )
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
// -----------------------------------------------------------------------------
|
|
|
57 |
// CSatCGetInputHandler::NewL
|
|
|
58 |
// Two-phased constructor.
|
|
|
59 |
// -----------------------------------------------------------------------------
|
|
|
60 |
//
|
|
|
61 |
CSatCGetInputHandler* CSatCGetInputHandler::NewL(
|
|
|
62 |
RSatUiSession* aSat )
|
|
|
63 |
{
|
|
|
64 |
LOG( SIMPLE, "SATINTERNALCLIENT: CSatCGetInputHandler::NewL calling" )
|
|
|
65 |
|
|
|
66 |
// Perform construction.
|
|
|
67 |
CSatCGetInputHandler* self =
|
|
|
68 |
new ( ELeave ) CSatCGetInputHandler( EPriorityLow, aSat );
|
|
|
69 |
|
|
|
70 |
LOG( SIMPLE, "SATINTERNALCLIENT: CSatCGetInputHandler::NewL exiting" )
|
|
|
71 |
return self;
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
// Class destructor.
|
|
|
75 |
CSatCGetInputHandler::~CSatCGetInputHandler()
|
|
|
76 |
{
|
|
|
77 |
LOG( SIMPLE,
|
|
|
78 |
"SATINTERNALCLIENT: CSatCGetInputHandler::~CSatCGetInputHandler calling" )
|
|
|
79 |
|
|
|
80 |
// Cancel any outstanding requests.
|
|
|
81 |
Cancel();
|
|
|
82 |
|
|
|
83 |
iSession = NULL;
|
|
|
84 |
|
|
|
85 |
LOG( SIMPLE,
|
|
|
86 |
"SATINTERNALCLIENT: CSatCGetInputHandler::~CSatCGetInputHandler exiting" )
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
// -----------------------------------------------------------------------------
|
|
|
90 |
// CSatCGetInputHandler::Start
|
|
|
91 |
// Starts the handler.
|
|
|
92 |
// -----------------------------------------------------------------------------
|
|
|
93 |
//
|
|
|
94 |
void CSatCGetInputHandler::Start()
|
|
|
95 |
{
|
|
|
96 |
LOG( SIMPLE, "SATINTERNALCLIENT: CSatCGetInputHandler::Start calling" )
|
|
|
97 |
|
|
|
98 |
// Empty the IPC data
|
|
|
99 |
RSat::TGetInputV1 temp;
|
|
|
100 |
iGetInputData = temp;
|
|
|
101 |
RSat::TGetInputRspV1 temp2;
|
|
|
102 |
iGetInputRsp = temp2;
|
|
|
103 |
|
|
|
104 |
// Request Get Input notification.
|
|
|
105 |
TIpcArgs arguments( &iGetInputPckg );
|
|
|
106 |
|
|
|
107 |
// Pass the Get Input IPC package.
|
|
|
108 |
iSession->CreateRequest( ESatSProactiveGetInput, arguments, iStatus );
|
|
|
109 |
|
|
|
110 |
// Set this handler to active so that it can receive requests.
|
|
|
111 |
SetActive();
|
|
|
112 |
|
|
|
113 |
LOG( SIMPLE, "SATINTERNALCLIENT: CSatCGetInputHandler::Start exiting" )
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
// -----------------------------------------------------------------------------
|
|
|
117 |
// CSatCGetInputHandler::ConvertCharacterSet
|
|
|
118 |
// Converts USAT character set to SAT character set type.
|
|
|
119 |
// -----------------------------------------------------------------------------
|
|
|
120 |
//
|
|
|
121 |
TSatCharacterSet CSatCGetInputHandler::ConvertCharacterSet(
|
|
|
122 |
const RSat::TGetInputRspFormat& aCharacterSet ) const
|
|
|
123 |
{
|
|
|
124 |
LOG( SIMPLE,
|
|
|
125 |
"SATINTERNALCLIENT: CSatCGetInputHandler::ConvertCharacterSet calling" )
|
|
|
126 |
|
|
|
127 |
TSatCharacterSet charSet( ESatCharSmsDefaultAlphabet );
|
|
|
128 |
|
|
|
129 |
LOG2( SIMPLE,
|
|
|
130 |
"SATINTERNALCLIENT: CSatCGetInputHandler::ConvertCharacterSet aCharacterSet: %d",
|
|
|
131 |
aCharacterSet )
|
|
|
132 |
|
|
|
133 |
if ( ( RSat::EDigitOnlyUnpacked == aCharacterSet ) ||
|
|
|
134 |
( RSat::EDigitOnlyPacked == aCharacterSet ) )
|
|
|
135 |
{
|
|
|
136 |
charSet = ESatDigitOnly;
|
|
|
137 |
}
|
|
|
138 |
else if ( aCharacterSet == RSat::EUcs2Alphabet )
|
|
|
139 |
{
|
|
|
140 |
charSet = ESatCharUcs2Alphabet;
|
|
|
141 |
}
|
|
|
142 |
else
|
|
|
143 |
{
|
|
|
144 |
charSet = ESatCharSmsDefaultAlphabet;
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
LOG( SIMPLE,
|
|
|
148 |
"SATINTERNALCLIENT: CSatCGetInputHandler::ConvertCharacterSet exiting" )
|
|
|
149 |
return charSet;
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
// -----------------------------------------------------------------------------
|
|
|
153 |
// CSatCGetInputHandler::RunL
|
|
|
154 |
// Handles the command.
|
|
|
155 |
// -----------------------------------------------------------------------------
|
|
|
156 |
//
|
|
|
157 |
void CSatCGetInputHandler::RunL()
|
|
|
158 |
{
|
|
|
159 |
LOG( SIMPLE, "SATINTERNALCLIENT: CSatCGetInputHandler::RunL calling" )
|
|
|
160 |
|
|
|
161 |
// Check the status of the asnychronous operation
|
|
|
162 |
if ( KErrNone != iStatus.Int() )
|
|
|
163 |
{
|
|
|
164 |
LOG2(
|
|
|
165 |
SIMPLE,
|
|
|
166 |
"SATINTERNALCLIENT: CSatCGetInputHandler::RunL exiting, error: %d",
|
|
|
167 |
iStatus.Int() )
|
|
|
168 |
|
|
|
169 |
// Renew the request
|
|
|
170 |
Start();
|
|
|
171 |
|
|
|
172 |
return;
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
// Determine the character set.
|
|
|
176 |
const TSatCharacterSet characterSet(
|
|
|
177 |
ConvertCharacterSet( iGetInputData.iRspFormat ) );
|
|
|
178 |
|
|
|
179 |
// Determine whether user input should be hidden or not.
|
|
|
180 |
TBool hideInput( EFalse );
|
|
|
181 |
if ( RSat::EHideUserInput == iGetInputData.iInputDisplayOption )
|
|
|
182 |
{
|
|
|
183 |
LOG( SIMPLE, "SATINTERNALCLIENT: CSatCGetInputHandler::RunL EHideUserInput" )
|
|
|
184 |
hideInput = ETrue;
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
// This will contain user input.
|
|
|
188 |
TBuf<KSatGetInputEntrySize> inputText( iGetInputData.iDefaultText );
|
|
|
189 |
|
|
|
190 |
// Indicates whether help is available
|
|
|
191 |
TBool helpIsAvailable( EFalse );
|
|
|
192 |
if ( RSat::EHelpAvailable == iGetInputData.iHelp )
|
|
|
193 |
{
|
|
|
194 |
LOG( SIMPLE, "SATINTERNALCLIENT: CSatCGetInputHandler::RunL EHelpAvailable" )
|
|
|
195 |
helpIsAvailable = ETrue;
|
|
|
196 |
}
|
|
|
197 |
|
|
|
198 |
// Has to be casted to TInt before casting to TSatIconQualifier, because
|
|
|
199 |
// GCC warns about the direct cast.
|
|
|
200 |
const struct TSatIconId iconId = { iGetInputData.iIconId.iIdentifier,
|
|
|
201 |
static_cast<TSatIconQualifier>(
|
|
|
202 |
static_cast<TInt>( iGetInputData.iIconId.iQualifier ) ) };
|
|
|
203 |
|
|
|
204 |
// This will contain EFalse if requested icon is not displayed.
|
|
|
205 |
// And if icon is displayed, it contains ETrue.
|
|
|
206 |
TBool requestedIconDisplayed( EFalse );
|
|
|
207 |
|
|
|
208 |
// Notify the registered client and save the response.
|
|
|
209 |
TSatUiResponse response = iSession->SatUiObserver()->GetInputL(
|
|
|
210 |
iGetInputData.iText,
|
|
|
211 |
characterSet, inputText, iGetInputData.iRspLength.iMinRspLength,
|
|
|
212 |
iGetInputData.iRspLength.iMaxRspLength, hideInput,
|
|
|
213 |
helpIsAvailable, iconId, requestedIconDisplayed );
|
|
|
214 |
|
|
|
215 |
// Use the same format in the response as it is in the input.
|
|
|
216 |
iGetInputRsp.iRspFormat = iGetInputData.iRspFormat;
|
|
|
217 |
|
|
|
218 |
// By default, this command does not have additional information.
|
|
|
219 |
iGetInputRsp.iInfoType = RSat::KNoAdditionalInfo;
|
|
|
220 |
iGetInputRsp.iAdditionalInfo.Zero();
|
|
|
221 |
|
|
|
222 |
iGetInputRsp.SetPCmdNumber( iGetInputData.PCmdNumber() );
|
|
|
223 |
|
|
|
224 |
// Examine the client response.
|
|
|
225 |
ExamineClientResponse(
|
|
|
226 |
response, inputText, requestedIconDisplayed );
|
|
|
227 |
|
|
|
228 |
// Pass the Get Input response package.
|
|
|
229 |
TIpcArgs arguments( &iGetInputRspPckg );
|
|
|
230 |
|
|
|
231 |
// Perform the IPC data transfer.
|
|
|
232 |
iSession->CreateRequest( ESatSProactiveGetInputResponse, arguments );
|
|
|
233 |
|
|
|
234 |
// Renew the service request.
|
|
|
235 |
Start();
|
|
|
236 |
|
|
|
237 |
LOG( SIMPLE, "SATINTERNALCLIENT: CSatCGetInputHandler::RunL exiting" )
|
|
|
238 |
}
|
|
|
239 |
|
|
|
240 |
// -----------------------------------------------------------------------------
|
|
|
241 |
// CSatCGetInputHandler::ExamineClientResponse
|
|
|
242 |
// Examine the client response.
|
|
|
243 |
// -----------------------------------------------------------------------------
|
|
|
244 |
//
|
|
|
245 |
void CSatCGetInputHandler::ExamineClientResponse(
|
|
|
246 |
TSatUiResponse aResponse,
|
|
|
247 |
const TDes& aInputText,
|
|
|
248 |
TBool aRequestedIconDisplayed )
|
|
|
249 |
{
|
|
|
250 |
LOG2( SIMPLE,
|
|
|
251 |
"SATINTERNALCLIENT: CSatCGetInputHandler::ExamineClientResponse calling,\
|
|
|
252 |
aResponse: %d", aResponse )
|
|
|
253 |
|
|
|
254 |
// Examine the client response.
|
|
|
255 |
switch ( aResponse )
|
|
|
256 |
{
|
|
|
257 |
case ESatSuccess:
|
|
|
258 |
{
|
|
|
259 |
|
|
|
260 |
// Convert terminal rsp if icon used
|
|
|
261 |
RSat::TPCmdResult result( RSat::KSuccess );
|
|
|
262 |
RSat::TIconQualifier iconQualifier(
|
|
|
263 |
iGetInputData.iIconId.iQualifier );
|
|
|
264 |
|
|
|
265 |
if ( !aRequestedIconDisplayed )
|
|
|
266 |
{
|
|
|
267 |
LOG( SIMPLE,
|
|
|
268 |
"SATINTERNALCLIENT: CSatCGetInputHandler::ExamineClientResponse \
|
|
|
269 |
aRequestedIconDisplayed false" )
|
|
|
270 |
if ( iconQualifier == RSat::ESelfExplanatory ||
|
|
|
271 |
iconQualifier == RSat::ENotSelfExplanatory )
|
|
|
272 |
{
|
|
|
273 |
LOG( SIMPLE,
|
|
|
274 |
"SATINTERNALCLIENT: CSatCGetInputHandler::ExamineClientResponse \
|
|
|
275 |
IconNotDisplayed" )
|
|
|
276 |
result = RSat::KSuccessRequestedIconNotDisplayed;
|
|
|
277 |
}
|
|
|
278 |
}
|
|
|
279 |
|
|
|
280 |
iGetInputRsp.iGeneralResult = result;
|
|
|
281 |
LOG2( SIMPLE,
|
|
|
282 |
"SATINTERNALCLIENT: CSatCGetInputHandler::ExamineClientResponse length \
|
|
|
283 |
of aInputText: %d", aInputText.Length() )
|
|
|
284 |
// Change the additional information type
|
|
|
285 |
if ( aInputText.Length() > 0 )
|
|
|
286 |
{
|
|
|
287 |
iGetInputRsp.iInfoType = RSat::KTextString;
|
|
|
288 |
|
|
|
289 |
// Save the character input by the user
|
|
|
290 |
iGetInputRsp.iAdditionalInfo.Append( aInputText );
|
|
|
291 |
}
|
|
|
292 |
break;
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
// Otherwise, just return the response.
|
|
|
296 |
case ESatFailure:
|
|
|
297 |
{
|
|
|
298 |
iGetInputRsp.iInfoType = RSat::KMeProblem;
|
|
|
299 |
iGetInputRsp.iGeneralResult = RSat::KMeUnableToProcessCmd;
|
|
|
300 |
iGetInputRsp.iAdditionalInfo.SetLength( 1 );
|
|
|
301 |
iGetInputRsp.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem;
|
|
|
302 |
break;
|
|
|
303 |
}
|
|
|
304 |
|
|
|
305 |
case ESatSessionTerminatedByUser:
|
|
|
306 |
{
|
|
|
307 |
iGetInputRsp.iGeneralResult = RSat::KPSessionTerminatedByUser;
|
|
|
308 |
break;
|
|
|
309 |
}
|
|
|
310 |
|
|
|
311 |
case ESatBackwardModeRequestedByUser:
|
|
|
312 |
{
|
|
|
313 |
iGetInputRsp.iGeneralResult =
|
|
|
314 |
RSat::KBackwardModeRequestedByUser;
|
|
|
315 |
break;
|
|
|
316 |
}
|
|
|
317 |
|
|
|
318 |
case ESatNoResponseFromUser:
|
|
|
319 |
{
|
|
|
320 |
iGetInputRsp.iGeneralResult = RSat::KNoResponseFromUser;
|
|
|
321 |
break;
|
|
|
322 |
}
|
|
|
323 |
|
|
|
324 |
case EHelpRequestedByUser:
|
|
|
325 |
{
|
|
|
326 |
iGetInputRsp.iGeneralResult = RSat::KHelpRequestedByUser;
|
|
|
327 |
break;
|
|
|
328 |
}
|
|
|
329 |
|
|
|
330 |
case EPCmdNotAcceptedByUser:
|
|
|
331 |
case ESatCmdDataNotUnderstood:
|
|
|
332 |
default:
|
|
|
333 |
{
|
|
|
334 |
iSession->Panic( ESatInvalidResponse );
|
|
|
335 |
break;
|
|
|
336 |
}
|
|
|
337 |
}
|
|
|
338 |
|
|
|
339 |
LOG( SIMPLE,
|
|
|
340 |
"SATINTERNALCLIENT: CSatCGetInputHandler::ExamineClientResponse exiting" )
|
|
|
341 |
}
|
|
|
342 |
|
|
|
343 |
// -----------------------------------------------------------------------------
|
|
|
344 |
// CSatCGetInputHandler::DoCancel
|
|
|
345 |
// Cancels the pending request.
|
|
|
346 |
// -----------------------------------------------------------------------------
|
|
|
347 |
//
|
|
|
348 |
void CSatCGetInputHandler::DoCancel()
|
|
|
349 |
{
|
|
|
350 |
LOG( SIMPLE, "SATINTERNALCLIENT: CSatCGetInputHandler::DoCancel calling" )
|
|
|
351 |
|
|
|
352 |
// Complete the request with cancel code.
|
|
|
353 |
TRequestStatus* requestStatus = &iStatus;
|
|
|
354 |
User::RequestComplete( requestStatus, KErrCancel );
|
|
|
355 |
|
|
|
356 |
LOG( SIMPLE, "SATINTERNALCLIENT: CSatCGetInputHandler::DoCancel exiting" )
|
|
|
357 |
}
|