1 /* |
|
2 * Copyright (c) 2002-2007 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: Handles GetInkey command |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "MSatApi.h" |
|
20 #include "MSatUtils.h" |
|
21 #include "MSatUiSession.h" |
|
22 #include "SatSOpcodes.h" |
|
23 #include "MSatSUiClientHandler.h" |
|
24 #include "CGetInkeyHandler.h" |
|
25 #include "SatLog.h" |
|
26 |
|
27 // ======== MEMBER FUNCTIONS ======== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // Two-phased constructor. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CGetInkeyHandler* CGetInkeyHandler::NewL( MSatUtils* aUtils ) |
|
34 { |
|
35 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::NewL calling" ) |
|
36 |
|
37 CGetInkeyHandler* self = new( ELeave ) CGetInkeyHandler; |
|
38 |
|
39 CleanupStack::PushL( self ); |
|
40 self->BaseConstructL( aUtils ); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop( self ); |
|
43 |
|
44 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::NewL exiting" ) |
|
45 return self; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // Destructor |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CGetInkeyHandler::~CGetInkeyHandler() |
|
53 { |
|
54 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::~CGetInkeyHandler calling" ) |
|
55 |
|
56 Cancel(); |
|
57 |
|
58 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::~CGetInkeyHandler exiting" ) |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // From class MSatCommand. |
|
63 // Response from the client. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void CGetInkeyHandler::ClientResponse() |
|
67 { |
|
68 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::ClientResponse calling" ) |
|
69 |
|
70 if ( RSat::KPSessionTerminatedByUser == iGetInkeyRsp.iGeneralResult ) |
|
71 { |
|
72 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::ClientResponse close ui \ |
|
73 session" ) |
|
74 // Next SimSession end will close the ui session |
|
75 iUtils->NotifyEvent( MSatUtils::ESessionTerminatedByUser ); |
|
76 } |
|
77 |
|
78 // If command had icon data and was done succesfully, report that icon |
|
79 // was not shown |
|
80 // To be removed when icons are allowed in this command |
|
81 if ( ( RSat::KSuccess == iGetInkeyRsp.iGeneralResult ) && |
|
82 iIconCommand ) |
|
83 { |
|
84 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::ClientResponse requested \ |
|
85 icon not displayed" ) |
|
86 iGetInkeyRsp.iGeneralResult = |
|
87 RSat::KSuccessRequestedIconNotDisplayed; |
|
88 } |
|
89 |
|
90 iGetInkeyRsp.SetPCmdNumber( iGetInkeyData.PCmdNumber() ); |
|
91 CSatCommandHandler::TerminalRsp( RSat::EGetInkey, iGetInkeyRspPckg ); |
|
92 |
|
93 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::ClientResponse exiting" ) |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // From class CActive. |
|
98 // Cancels the sat request. |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CGetInkeyHandler::DoCancel() |
|
102 { |
|
103 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::DoCancel calling" ) |
|
104 |
|
105 iUtils->USatAPI().NotifyGetInkeyCancel(); |
|
106 |
|
107 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::DoCancel exiting" ) |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // From class CSatCommandHandler. |
|
112 // Requests the command notification. |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CGetInkeyHandler::IssueUSATRequest( TRequestStatus& aStatus ) |
|
116 { |
|
117 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::IssueUSATRequest calling" ) |
|
118 |
|
119 // Clear the IPC package. |
|
120 new (&iGetInkeyData) RSat::TGetInkeyV2(); |
|
121 iGetInkeyRsp.iGeneralResult = RSat::KPSessionTerminatedByUser; // default |
|
122 |
|
123 iUtils->USatAPI().NotifyGetInkey( aStatus, iGetInkeyPckg ); |
|
124 |
|
125 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::IssueUSATRequest exiting" ) |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // From class CSatCommandHandler. |
|
130 // Precheck before executing the command. |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 TBool CGetInkeyHandler::CommandAllowed() |
|
134 { |
|
135 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::CommandAllowed calling" ) |
|
136 TBool allowed( ETrue ); |
|
137 |
|
138 // If provided duration is missing time units |
|
139 if ( ( RSat::ENoDurationAvailable != iGetInkeyData.iDuration.iTimeUnit && |
|
140 RSat::ETimeUnitNotSet != iGetInkeyData.iDuration.iTimeUnit ) && |
|
141 0 == iGetInkeyData.iDuration.iNumOfUnits ) |
|
142 { |
|
143 LOG( SIMPLE, |
|
144 "GETINKEY: CGetInkeyHandler::CommandAllowed invalid duration" ) |
|
145 allowed = EFalse; |
|
146 } |
|
147 |
|
148 // If icon is provided without any text |
|
149 if ( ( 0 == iGetInkeyData.iText.Length() ) && |
|
150 ( RSat::ENotSelfExplanatory == iGetInkeyData.iIconId.iQualifier || |
|
151 RSat::ESelfExplanatory == iGetInkeyData.iIconId.iQualifier ) ) |
|
152 { |
|
153 LOG( SIMPLE, |
|
154 "GETINKEY: CGetInkeyHandler::CommandAllowed icon w/o alpha id" ) |
|
155 allowed = EFalse; |
|
156 } |
|
157 // Set icon command flag whether icon data was received and set qualifier |
|
158 // to no icon id |
|
159 // To be removed when icons are allowed in this command |
|
160 else if ( ( RSat::ESelfExplanatory == |
|
161 iGetInkeyData.iIconId.iQualifier ) || |
|
162 ( RSat::ENotSelfExplanatory == |
|
163 iGetInkeyData.iIconId.iQualifier ) ) |
|
164 { |
|
165 LOG( SIMPLE, |
|
166 "GETINKEY: CGetInkeyHandler::CommandAllowed set no icon id" ) |
|
167 iIconCommand = ETrue; |
|
168 iGetInkeyData.iIconId.iQualifier = RSat::ENoIconId; |
|
169 } |
|
170 else |
|
171 { |
|
172 iIconCommand = EFalse; |
|
173 } |
|
174 |
|
175 if ( !allowed ) |
|
176 { |
|
177 LOG( SIMPLE, |
|
178 "GETINKEY: CGetInkeyHandler::CommandAllowed allowed false" ) |
|
179 iGetInkeyRsp.iGeneralResult = RSat::KCmdDataNotUnderstood; |
|
180 iGetInkeyRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
181 iGetInkeyRsp.iAdditionalInfo.Zero(); |
|
182 iGetInkeyRsp.SetPCmdNumber( iGetInkeyData.PCmdNumber() ); |
|
183 // send terminal response |
|
184 TerminalRsp( RSat::EGetInkey, iGetInkeyRspPckg ); |
|
185 } |
|
186 |
|
187 LOG2( SIMPLE, "GETINKEY: CGetInkeyHandler::CommandAllowed exiting,\ |
|
188 allowed: %d", allowed ) |
|
189 return allowed; |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // From class CSatCommandHandler. |
|
194 // Need for ui session. |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 TBool CGetInkeyHandler::NeedUiSession() |
|
198 { |
|
199 LOG( NORMAL, "GETINKEY: CGetInkeyHandler::NeedUiSession calling" ) |
|
200 |
|
201 // Notify Cover UI if it's supported |
|
202 if ( iUtils->CoverUiSupported() ) |
|
203 { |
|
204 LOG( NORMAL, "CGetInkeyHandler::NeedUiSession coverui supported" ) |
|
205 TSatCommandData medEventData; |
|
206 medEventData.iPCmdNumber = RSat::EGetInkey; |
|
207 if ( iGetInkeyData.iText.Length() ) |
|
208 { |
|
209 LOG( NORMAL, "CGetInkeyHandler::NeedUiSession EAlphaIdProvided" ) |
|
210 medEventData.iAlphaId.iStatus = RSat::EAlphaIdProvided; |
|
211 medEventData.iAlphaId.iAlphaId.Copy( iGetInkeyData.iText ); |
|
212 } |
|
213 else |
|
214 { |
|
215 medEventData.iAlphaId.iStatus = RSat::EAlphaIdNotPresent; |
|
216 } |
|
217 // Duration not set, use KSatLongDuration |
|
218 if ( RSat::ETimeUnitNotSet == iGetInkeyData.iDuration.iTimeUnit ) |
|
219 { |
|
220 LOG( NORMAL, "CGetInkeyHandler::NeedUiSession Duration not set" ) |
|
221 medEventData.iDuration.iTimeUnit = RSat::ESeconds; |
|
222 medEventData.iDuration.iNumOfUnits = KSatLongDuration; |
|
223 } |
|
224 else |
|
225 { |
|
226 medEventData.iDuration = iGetInkeyData.iDuration; |
|
227 } |
|
228 |
|
229 medEventData.iIconID = iGetInkeyData.iIconId; |
|
230 TSatCommandPckg tPckg( medEventData ); |
|
231 iUtils->RaiseSatEvent( tPckg ); |
|
232 } |
|
233 |
|
234 LOG( NORMAL, "GETINKEY: CGetInkeyHandler::NeedUiSession exiting" ) |
|
235 return ETrue; |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // From class CSatCommandHandler. |
|
240 // Called when USAT API notifies that command. |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 void CGetInkeyHandler::HandleCommand() |
|
244 { |
|
245 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::HandleCommand calling" ) |
|
246 |
|
247 iUtils->NotifyEvent( MSatUtils::EGetInkeyExecuting ); |
|
248 |
|
249 MSatUiSession* uiSession = iUtils->SatUiHandler().UiSession(); |
|
250 uiSession->SendCommand( |
|
251 &iGetInkeyPckg, |
|
252 &iGetInkeyRspPckg, |
|
253 ESatSProactiveGetInkey ); |
|
254 |
|
255 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::HandleCommand exiting" ) |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // From class CSatCommandHandler. |
|
260 // Indicates the failure of launching ui client. |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 void CGetInkeyHandler::UiLaunchFailed() |
|
264 { |
|
265 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::UiLaunchFailed calling" ) |
|
266 |
|
267 iGetInkeyRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
268 iGetInkeyRsp.iInfoType = RSat::KMeProblem; |
|
269 iGetInkeyRsp.iAdditionalInfo.SetLength( 1 ); |
|
270 iGetInkeyRsp.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem; |
|
271 iGetInkeyRsp.SetPCmdNumber( iGetInkeyData.PCmdNumber() ); |
|
272 TerminalRsp( RSat::EGetInkey, iGetInkeyRspPckg ); |
|
273 |
|
274 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::UiLaunchFailed exiting" ) |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // C++ default constructor can NOT contain any code, that |
|
279 // might leave. |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 CGetInkeyHandler::CGetInkeyHandler() : |
|
283 CSatCommandHandler(), |
|
284 iGetInkeyData(), |
|
285 iGetInkeyPckg( iGetInkeyData ), |
|
286 iGetInkeyRsp(), |
|
287 iGetInkeyRspPckg( iGetInkeyRsp ), |
|
288 // To be removed when icons are allowed in this command |
|
289 iIconCommand( EFalse ) |
|
290 { |
|
291 LOG( SIMPLE, |
|
292 "GETINKEY: CGetInkeyHandler::CGetInkeyHandler calling - exiting" ) |
|
293 } |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // Symbian 2nd phase constructor can leave. |
|
297 // ----------------------------------------------------------------------------- |
|
298 // |
|
299 void CGetInkeyHandler::ConstructL() |
|
300 { |
|
301 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::ConstructL calling" ) |
|
302 |
|
303 // Register service request handler for GetInkey command |
|
304 iUtils->RegisterServiceRequestL( |
|
305 ESatSProactiveGetInkey, |
|
306 ESatSProactiveGetInkeyResponse, |
|
307 this ); |
|
308 |
|
309 LOG( SIMPLE, "GETINKEY: CGetInkeyHandler::ConstructL exiting" ) |
|
310 } |
|
311 |
|