|
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 * Display Text proactive command. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <e32svr.h> |
|
21 #include "RSatUiSession.h" |
|
22 #include "MSatUiObserver.h" |
|
23 #include "CSatCDisplayTextHandler.h" |
|
24 #include "SatSOpcodes.h" |
|
25 #include "SatLog.h" |
|
26 |
|
27 // ======== MEMBER FUNCTIONS ======== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CSatCDisplayTextHandler::CSatCDisplayTextHandler |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CSatCDisplayTextHandler::CSatCDisplayTextHandler( |
|
36 TInt aPriority, |
|
37 RSatUiSession* aSession ) : |
|
38 CActive( aPriority ), iSession( aSession ), |
|
39 iDisplayTextData(), |
|
40 iDisplayTextPckg( iDisplayTextData ), |
|
41 iDisplayTextRsp(), |
|
42 iDisplayTextRspPckg( iDisplayTextRsp ) |
|
43 { |
|
44 LOG( SIMPLE, |
|
45 "SATINTERNALCLIENT: CSatCDisplayTextHandler::CSatCDisplayTextHandler calling" ) |
|
46 |
|
47 CActiveScheduler::Add( this ); // add to active scheduler |
|
48 |
|
49 LOG( SIMPLE, |
|
50 "SATINTERNALCLIENT: CSatCDisplayTextHandler::CSatCDisplayTextHandler exiting" ) |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CSatCDisplayTextHandler::NewL |
|
55 // Two-phased constructor. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CSatCDisplayTextHandler* CSatCDisplayTextHandler::NewL( |
|
59 RSatUiSession* aSat ) |
|
60 { |
|
61 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCDisplayTextHandler::NewL calling" ) |
|
62 |
|
63 // Perform construction. |
|
64 CSatCDisplayTextHandler* self = |
|
65 new ( ELeave ) CSatCDisplayTextHandler( EPriorityLow, aSat ); |
|
66 |
|
67 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCDisplayTextHandler::NewL exiting" ) |
|
68 return self; |
|
69 } |
|
70 |
|
71 // Destructor |
|
72 CSatCDisplayTextHandler::~CSatCDisplayTextHandler() |
|
73 { |
|
74 LOG( SIMPLE, |
|
75 "SATINTERNALCLIENT: CSatCDisplayTextHandler::~CSatCDisplayTextHandler calling" ) |
|
76 |
|
77 // Cancel any outstanding requests. |
|
78 Cancel(); |
|
79 iSession = NULL; |
|
80 |
|
81 LOG( SIMPLE, |
|
82 "SATINTERNALCLIENT: CSatCDisplayTextHandler::~CSatCDisplayTextHandler exiting" ) |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CSatCDisplayTextHandler::Start |
|
87 // Starts the handler. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CSatCDisplayTextHandler::Start() |
|
91 { |
|
92 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCDisplayTextHandler::Start calling" ) |
|
93 |
|
94 // Empty the IPC data |
|
95 TSatDisplayTextV1 temp; |
|
96 iDisplayTextData = temp; |
|
97 RSat::TDisplayTextRspV1 temp2; |
|
98 iDisplayTextRsp = temp2; |
|
99 |
|
100 // Request Display Text notifications. |
|
101 TIpcArgs arguments( &iDisplayTextPckg ); |
|
102 |
|
103 // Pass the Display Text IPC package |
|
104 iSession->CreateRequest( ESatSProactiveDisplayText, arguments, iStatus ); |
|
105 |
|
106 // Set this handler to active so that it can receive requests. |
|
107 SetActive(); |
|
108 |
|
109 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCDisplayTextHandler::Start exiting" ) |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CSatCDisplayTextHandler::RunL |
|
114 // Handles the command. |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CSatCDisplayTextHandler::RunL() |
|
118 { |
|
119 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCDisplayTextHandler::RunL calling" ) |
|
120 |
|
121 // Check the status of the asnychronous operation |
|
122 if ( KErrNone != iStatus.Int() ) |
|
123 { |
|
124 LOG2( |
|
125 SIMPLE, |
|
126 "SATINTERNALCLIENT: CSatCDisplayTextHandler::RunL exiting, error: %d", |
|
127 iStatus.Int() ) |
|
128 |
|
129 // Renew the request |
|
130 Start(); |
|
131 } |
|
132 else |
|
133 { |
|
134 // Has to be casted to TInt before casting to TSatIconQualifier, because |
|
135 // gcc warns about the direct cast. |
|
136 const struct TSatIconId iconId = { iDisplayTextData.iIconId.iIdentifier, |
|
137 static_cast<TSatIconQualifier>( |
|
138 static_cast<TInt>( iDisplayTextData.iIconId.iQualifier ) ) }; |
|
139 |
|
140 // This will contain EFalse if requested icon is not displayed. |
|
141 TBool requestedIconDisplayed( ETrue ); |
|
142 |
|
143 // Indicator if user is expected to clear the message |
|
144 TBool waitUserToClear( ETrue ); |
|
145 |
|
146 if ( RSat::EClearAfterDelay == iDisplayTextData.iClearScreen ) |
|
147 { |
|
148 LOG( SIMPLE, |
|
149 "SATINTERNALCLIENT: CSatCDisplayTextHandler::RunL EClearAfterDelay" ) |
|
150 waitUserToClear = EFalse; |
|
151 } |
|
152 |
|
153 // Notify the registered client and save the response. |
|
154 TSatUiResponse response; |
|
155 response = iSession->SatUiObserver()->DisplayTextL( |
|
156 iDisplayTextData.iText, |
|
157 iDisplayTextData.iSimApplicationName, |
|
158 iconId, |
|
159 requestedIconDisplayed, |
|
160 iDisplayTextData.iSustainedText, |
|
161 iDisplayTextData.iDuration, |
|
162 waitUserToClear ); |
|
163 |
|
164 // This command never has any additional information. |
|
165 iDisplayTextRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
166 iDisplayTextRsp.iAdditionalInfo.Zero(); |
|
167 |
|
168 iDisplayTextRsp.SetPCmdNumber( iDisplayTextData.iPCmdNumber ); |
|
169 |
|
170 // Examine the client response. |
|
171 ExamineClientResponse( |
|
172 response, requestedIconDisplayed ); |
|
173 |
|
174 // Pass the Display Text response IPC package. |
|
175 TIpcArgs arguments( &iDisplayTextRspPckg ); |
|
176 |
|
177 // Perform the IPC data transfer. |
|
178 iSession->CreateRequest( ESatSProactiveDisplayTextResponse, arguments ); |
|
179 |
|
180 // Renew the service request. |
|
181 Start(); |
|
182 } |
|
183 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCDisplayTextHandler::RunL exiting" ) |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CSatCDisplayTextHandler::ExamineClientResponse |
|
188 // Examine the client response. |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CSatCDisplayTextHandler::ExamineClientResponse( |
|
192 TSatUiResponse aResponse, |
|
193 TBool aRequestedIconDisplayed ) |
|
194 { |
|
195 LOG2( SIMPLE, |
|
196 "SATINTERNALCLIENT: CSatCDisplayTextHandler::ExamineClientResponse calling,\ |
|
197 aResponse: %x", aResponse ) |
|
198 |
|
199 switch ( aResponse ) |
|
200 { |
|
201 case ESatSuccess: |
|
202 { |
|
203 // Convert terminal rsp if icon used |
|
204 RSat::TPCmdResult result( RSat::KSuccess ); |
|
205 RSat::TIconQualifier iconQualifier( |
|
206 iDisplayTextData.iIconId.iQualifier ); |
|
207 |
|
208 if ( !aRequestedIconDisplayed ) |
|
209 { |
|
210 LOG( SIMPLE, |
|
211 "SATINTERNALCLIENT: CSatCDisplayTextHandler::ExamineClientResponse \ |
|
212 aRequestedIconDisplayed false" ) |
|
213 if ( iconQualifier == RSat::ESelfExplanatory || |
|
214 iconQualifier == RSat::ENotSelfExplanatory ) |
|
215 { |
|
216 LOG( SIMPLE, |
|
217 "SATINTERNALCLIENT: CSatCDisplayTextHandler::ExamineClientResponse \ |
|
218 IconNotDisplayed" ) |
|
219 result = RSat::KSuccessRequestedIconNotDisplayed; |
|
220 } |
|
221 } |
|
222 |
|
223 iDisplayTextRsp.iGeneralResult = result; |
|
224 break; |
|
225 } |
|
226 |
|
227 case ESatFailure: |
|
228 { |
|
229 iDisplayTextRsp.iInfoType = RSat::KMeProblem; |
|
230 iDisplayTextRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
231 iDisplayTextRsp.iAdditionalInfo.SetLength( 1 ); |
|
232 iDisplayTextRsp.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem; |
|
233 break; |
|
234 } |
|
235 |
|
236 case ESatSessionTerminatedByUser: |
|
237 { |
|
238 iDisplayTextRsp.iGeneralResult = RSat::KPSessionTerminatedByUser; |
|
239 break; |
|
240 } |
|
241 |
|
242 case ESatBackwardModeRequestedByUser: |
|
243 { |
|
244 iDisplayTextRsp.iGeneralResult = |
|
245 RSat::KBackwardModeRequestedByUser; |
|
246 break; |
|
247 } |
|
248 |
|
249 case ESatNoResponseFromUser: |
|
250 { |
|
251 iDisplayTextRsp.iGeneralResult = RSat::KNoResponseFromUser; |
|
252 break; |
|
253 } |
|
254 |
|
255 // No help is ever supplied with this command |
|
256 case EHelpRequestedByUser: |
|
257 case EPCmdNotAcceptedByUser: |
|
258 case ESatCmdDataNotUnderstood: |
|
259 default: |
|
260 { |
|
261 iSession->Panic( ESatInvalidResponse ); |
|
262 break; |
|
263 } |
|
264 } |
|
265 |
|
266 LOG( SIMPLE, |
|
267 "SATINTERNALCLIENT: CSatCDisplayTextHandler::ExamineClientResponse exiting" ) |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // CSatCDisplayTextHandler::DoCancel |
|
272 // Cancels the pending request. |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 void CSatCDisplayTextHandler::DoCancel() |
|
276 { |
|
277 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCDisplayTextHandler::DoCancel calling" ) |
|
278 |
|
279 // Complete the request with cancel code. |
|
280 TRequestStatus* requestStatus = &iStatus; |
|
281 User::RequestComplete( requestStatus, KErrCancel ); |
|
282 |
|
283 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCDisplayTextHandler::DoCancel exiting" ) |
|
284 } |