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