|
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: Handles Refresh command
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
#include <msatrefreshobserver.h>
|
|
|
20 |
#include "MSatSUiClientHandler.h"
|
|
|
21 |
#include "CRefreshHandler.h"
|
|
|
22 |
#include "MSatApi.h"
|
|
|
23 |
#include "MSatUtils.h"
|
|
|
24 |
#include "MSatSystemState.h"
|
|
|
25 |
#include "MSatUiSession.h"
|
|
|
26 |
#include "SatSOpcodes.h"
|
|
|
27 |
#include "MSatRefreshSubSession.h"
|
|
|
28 |
#include "SatLog.h"
|
|
|
29 |
|
|
|
30 |
// ======== MEMBER FUNCTIONS ========
|
|
|
31 |
|
|
|
32 |
// -----------------------------------------------------------------------------
|
|
|
33 |
// CRefreshHandler::CRefreshHandler
|
|
|
34 |
// C++ default constructor can NOT contain any code, that
|
|
|
35 |
// might leave.
|
|
|
36 |
// -----------------------------------------------------------------------------
|
|
|
37 |
//
|
|
|
38 |
CRefreshHandler::CRefreshHandler() :
|
|
|
39 |
CSatCommandHandler(),
|
|
|
40 |
iRefreshData(),
|
|
|
41 |
iRefreshPckg( iRefreshData ),
|
|
|
42 |
iRefreshRsp(),
|
|
|
43 |
iRefreshRspPckg( iRefreshRsp ),
|
|
|
44 |
iRefreshNotifyClientCount( 0 ),
|
|
|
45 |
iAdditionalEFRead( EFalse ),
|
|
|
46 |
iSimResetExecuting( EFalse )
|
|
|
47 |
{
|
|
|
48 |
LOG( SIMPLE,
|
|
|
49 |
"REFRESH: CRefreshHandler::CRefreshHandler calling - exiting" )
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
// -----------------------------------------------------------------------------
|
|
|
53 |
// CRefreshHandler::ConstructL
|
|
|
54 |
// Symbian 2nd phase constructor can leave.
|
|
|
55 |
// -----------------------------------------------------------------------------
|
|
|
56 |
//
|
|
|
57 |
void CRefreshHandler::ConstructL()
|
|
|
58 |
{
|
|
|
59 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::ConstructL calling" )
|
|
|
60 |
|
|
|
61 |
// Register events to be listen.
|
|
|
62 |
iUtils->RegisterL( this, MSatUtils::ERefreshEFRead );
|
|
|
63 |
iUtils->RegisterL( this, MSatUtils::ERefreshAdditionalEFRead );
|
|
|
64 |
iUtils->RegisterL( this, MSatUtils::ESimResetCalled );
|
|
|
65 |
|
|
|
66 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::ConstructL exiting" )
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
// -----------------------------------------------------------------------------
|
|
|
70 |
// CRefreshHandler::NewL
|
|
|
71 |
// Two-phased constructor.
|
|
|
72 |
// -----------------------------------------------------------------------------
|
|
|
73 |
//
|
|
|
74 |
CRefreshHandler* CRefreshHandler::NewL( MSatUtils* aUtils )
|
|
|
75 |
{
|
|
|
76 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::NewL calling" )
|
|
|
77 |
|
|
|
78 |
CRefreshHandler* self = new( ELeave ) CRefreshHandler;
|
|
|
79 |
|
|
|
80 |
CleanupStack::PushL( self );
|
|
|
81 |
self->BaseConstructL( aUtils );
|
|
|
82 |
self->ConstructL();
|
|
|
83 |
CleanupStack::Pop( self );
|
|
|
84 |
|
|
|
85 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::NewL exiting" )
|
|
|
86 |
return self;
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
// Destructor
|
|
|
91 |
CRefreshHandler::~CRefreshHandler()
|
|
|
92 |
{
|
|
|
93 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::~CRefreshHandler calling" )
|
|
|
94 |
|
|
|
95 |
Cancel();
|
|
|
96 |
|
|
|
97 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::~CRefreshHandler exiting" )
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
// -----------------------------------------------------------------------------
|
|
|
101 |
// CRefreshHandler::Event
|
|
|
102 |
// -----------------------------------------------------------------------------
|
|
|
103 |
//
|
|
|
104 |
void CRefreshHandler::Event( TInt aEvent )
|
|
|
105 |
{
|
|
|
106 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::Event calling" )
|
|
|
107 |
|
|
|
108 |
switch ( aEvent )
|
|
|
109 |
{
|
|
|
110 |
case MSatUtils::ERefreshAdditionalEFRead:
|
|
|
111 |
{
|
|
|
112 |
LOG( NORMAL, "REFRESH: Event: Additional EF read" )
|
|
|
113 |
|
|
|
114 |
// At least one client indicates additional EF read.
|
|
|
115 |
iAdditionalEFRead = ETrue;
|
|
|
116 |
}
|
|
|
117 |
//lint -fallthrough intended here
|
|
|
118 |
|
|
|
119 |
case MSatUtils::ERefreshEFRead:
|
|
|
120 |
{
|
|
|
121 |
LOG( NORMAL, "REFRESH: Event: Client Completed" )
|
|
|
122 |
|
|
|
123 |
if ( 0 < iRefreshNotifyClientCount )
|
|
|
124 |
{
|
|
|
125 |
iRefreshNotifyClientCount--;
|
|
|
126 |
// Check whether all clients have replied.
|
|
|
127 |
if ( 0 == iRefreshNotifyClientCount )
|
|
|
128 |
{
|
|
|
129 |
LOG( NORMAL, "REFRESH: All clients are complete" )
|
|
|
130 |
// Construct and send terminal response..
|
|
|
131 |
CompleteRefresh();
|
|
|
132 |
}
|
|
|
133 |
}
|
|
|
134 |
break;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
case MSatUtils::ESimResetCalled:
|
|
|
138 |
{
|
|
|
139 |
LOG( NORMAL, "REFRESH: Event: Sim Reset called" )
|
|
|
140 |
iSimResetExecuting = ETrue;
|
|
|
141 |
break;
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
default:
|
|
|
145 |
{
|
|
|
146 |
LOG2( NORMAL, "REFRESH: Event: %i", aEvent )
|
|
|
147 |
CSatCommandHandler::Event( aEvent );
|
|
|
148 |
}
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::Event exiting" )
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
// -----------------------------------------------------------------------------
|
|
|
155 |
// CRefreshHandler::DoCancel
|
|
|
156 |
// Cancels the sat request.
|
|
|
157 |
// -----------------------------------------------------------------------------
|
|
|
158 |
//
|
|
|
159 |
void CRefreshHandler::DoCancel()
|
|
|
160 |
{
|
|
|
161 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::DoCancel calling" )
|
|
|
162 |
|
|
|
163 |
iUtils->USatAPI().NotifyRefreshCancel();
|
|
|
164 |
|
|
|
165 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::DoCancel exiting" )
|
|
|
166 |
}
|
|
|
167 |
|
|
|
168 |
// -----------------------------------------------------------------------------
|
|
|
169 |
// CRefreshHandler::IssueUSATRequest
|
|
|
170 |
// -----------------------------------------------------------------------------
|
|
|
171 |
//
|
|
|
172 |
void CRefreshHandler::IssueUSATRequest( TRequestStatus& aStatus )
|
|
|
173 |
{
|
|
|
174 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::IssueUSATRequest calling" )
|
|
|
175 |
|
|
|
176 |
// Refresh has been cancelled, lets notify clients waiting for it.
|
|
|
177 |
if ( KErrGeneral == aStatus.Int() )
|
|
|
178 |
{
|
|
|
179 |
LOG( SIMPLE, "REFRESH: Refresh cancelled" )
|
|
|
180 |
NotifyRefreshClientsCancel();
|
|
|
181 |
|
|
|
182 |
if ( iSimResetExecuting )
|
|
|
183 |
{
|
|
|
184 |
LOG( SIMPLE, "CRefreshHandler::IssueUSATRequest \
|
|
|
185 |
iSimResetExecuting" )
|
|
|
186 |
iUtils->NotifyEvent( MSatUtils::EAddSatUiCalled );
|
|
|
187 |
iUtils->NotifyEvent( MSatUtils::ESimResetCancelled );
|
|
|
188 |
|
|
|
189 |
iSimResetExecuting = EFalse;
|
|
|
190 |
}
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
// Clear the IPC package.
|
|
|
194 |
new (&iRefreshData) RSat::TRefreshV2();
|
|
|
195 |
|
|
|
196 |
iUtils->USatAPI().NotifyRefresh( aStatus, iRefreshPckg );
|
|
|
197 |
|
|
|
198 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::IssueUSATRequest exiting" )
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
// -----------------------------------------------------------------------------
|
|
|
202 |
// CRefreshHandler::CommandAllowed
|
|
|
203 |
// -----------------------------------------------------------------------------
|
|
|
204 |
//
|
|
|
205 |
TBool CRefreshHandler::CommandAllowed()
|
|
|
206 |
{
|
|
|
207 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::CommandAllowed calling - exiting" )
|
|
|
208 |
|
|
|
209 |
// Now we must always allow Refresh. We had our last chnage to deny it in
|
|
|
210 |
// RefreshRequired command.
|
|
|
211 |
return ETrue;
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
// -----------------------------------------------------------------------------
|
|
|
215 |
// CRefreshHandler::NeedUiSession
|
|
|
216 |
// -----------------------------------------------------------------------------
|
|
|
217 |
//
|
|
|
218 |
TBool CRefreshHandler::NeedUiSession()
|
|
|
219 |
{
|
|
|
220 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::NeedUiSession calling - exiting" )
|
|
|
221 |
return EFalse;
|
|
|
222 |
}
|
|
|
223 |
|
|
|
224 |
// -----------------------------------------------------------------------------
|
|
|
225 |
// CRefreshHandler::HandleCommand
|
|
|
226 |
// -----------------------------------------------------------------------------
|
|
|
227 |
//
|
|
|
228 |
void CRefreshHandler::HandleCommand()
|
|
|
229 |
{
|
|
|
230 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::HandleCommand calling" )
|
|
|
231 |
|
|
|
232 |
// Refresh has been done.
|
|
|
233 |
iSimResetExecuting = EFalse;
|
|
|
234 |
|
|
|
235 |
#ifdef ENABLE_SAT_LOGGING
|
|
|
236 |
TInt fileCount( iRefreshData.iFileList.Length() );
|
|
|
237 |
LOG2( NORMAL, "REFRESH: Refresh file count: %d", fileCount )
|
|
|
238 |
for ( TInt fileIndex = 0; fileIndex < fileCount; fileIndex++ )
|
|
|
239 |
{
|
|
|
240 |
LOG2( NORMAL, "REFRESH: Refresh file : %x",
|
|
|
241 |
iRefreshData.iFileList[ fileIndex ] )
|
|
|
242 |
}
|
|
|
243 |
#endif
|
|
|
244 |
|
|
|
245 |
// Notify all registered clients about refresh.
|
|
|
246 |
// Whether any clients exists, we must wait them all to complete EF read,
|
|
|
247 |
// otherwise we can complete now.
|
|
|
248 |
// Count must be local variable, due some client may reply before
|
|
|
249 |
// all other has been notified.
|
|
|
250 |
TInt clientCount( iUtils->RefreshSubSessions().Count() );
|
|
|
251 |
iRefreshNotifyClientCount = clientCount; // Actually notified clients.
|
|
|
252 |
iAdditionalEFRead = EFalse;
|
|
|
253 |
if ( 0 != clientCount )
|
|
|
254 |
{
|
|
|
255 |
LOG2( NORMAL, "REFRESH: Refresh client count: %d",
|
|
|
256 |
iRefreshNotifyClientCount )
|
|
|
257 |
|
|
|
258 |
// Notify refresh clients about refresh completion.
|
|
|
259 |
for ( TInt i = 0; i < clientCount ; i++ )
|
|
|
260 |
{
|
|
|
261 |
iUtils->RefreshSubSessions()[i]->NotifyClient( iRefreshData );
|
|
|
262 |
}
|
|
|
263 |
}
|
|
|
264 |
else
|
|
|
265 |
{
|
|
|
266 |
// Construct and send terminal response..
|
|
|
267 |
CompleteRefresh();
|
|
|
268 |
}
|
|
|
269 |
|
|
|
270 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::HandleCommand exiting" )
|
|
|
271 |
}
|
|
|
272 |
|
|
|
273 |
// -----------------------------------------------------------------------------
|
|
|
274 |
// CRefreshHandler::UiLaunchFailed
|
|
|
275 |
// -----------------------------------------------------------------------------
|
|
|
276 |
//
|
|
|
277 |
void CRefreshHandler::UiLaunchFailed()
|
|
|
278 |
{
|
|
|
279 |
// This command will not launch ui.
|
|
|
280 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::UiLaunchFailed calling-exiting" )
|
|
|
281 |
}
|
|
|
282 |
|
|
|
283 |
// -----------------------------------------------------------------------------
|
|
|
284 |
// CRefreshHandler::CompleteRefresh
|
|
|
285 |
// Waits for all clients complete.
|
|
|
286 |
// -----------------------------------------------------------------------------
|
|
|
287 |
//
|
|
|
288 |
void CRefreshHandler::CompleteRefresh()
|
|
|
289 |
{
|
|
|
290 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::CompleteRefresh calling" )
|
|
|
291 |
|
|
|
292 |
// Remove the idle mode text and icon for initialization type refreshes.
|
|
|
293 |
// Note that idle mode text was removed for ESimReset already in
|
|
|
294 |
// RefreshRequired command.
|
|
|
295 |
if ( ( RSat::EFileChangeNotification != iRefreshData.iType ) &&
|
|
|
296 |
( RSat::ESimReset != iRefreshData.iType ) )
|
|
|
297 |
{
|
|
|
298 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::CompleteRefresh ESimInitDone" )
|
|
|
299 |
iUtils->NotifyEvent( MSatUtils::ESimInitDone );
|
|
|
300 |
}
|
|
|
301 |
|
|
|
302 |
// Construct a proper refresh response data package.
|
|
|
303 |
if ( iAdditionalEFRead )
|
|
|
304 |
{
|
|
|
305 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::CompleteRefresh \
|
|
|
306 |
iAdditionalEFRead" )
|
|
|
307 |
iRefreshRsp.iGeneralResult = RSat::KRefreshAdditionEFRead;
|
|
|
308 |
iAdditionalEFRead = EFalse;
|
|
|
309 |
}
|
|
|
310 |
else
|
|
|
311 |
{
|
|
|
312 |
iRefreshRsp.iGeneralResult = RSat::KSuccess;
|
|
|
313 |
}
|
|
|
314 |
|
|
|
315 |
iRefreshRsp.iInfoType = RSat::KNoAdditionalInfo;
|
|
|
316 |
iRefreshRsp.iAdditionalInfo.Zero();
|
|
|
317 |
iRefreshRsp.SetPCmdNumber( iRefreshData.PCmdNumber() );
|
|
|
318 |
|
|
|
319 |
// Send the response
|
|
|
320 |
TerminalRsp( RSat::ERefresh, iRefreshRspPckg );
|
|
|
321 |
|
|
|
322 |
LOG( SIMPLE, "REFRESH: CRefreshHandler::CompleteRefresh exiting" )
|
|
|
323 |
}
|
|
|
324 |
|
|
|
325 |
// -----------------------------------------------------------------------------
|
|
|
326 |
// CRefreshHandler::NotifyRefreshClientsCancel
|
|
|
327 |
// Notifies waiting clients about refrsh cancel.
|
|
|
328 |
// -----------------------------------------------------------------------------
|
|
|
329 |
//
|
|
|
330 |
void CRefreshHandler::NotifyRefreshClientsCancel()
|
|
|
331 |
{
|
|
|
332 |
LOG( SIMPLE,
|
|
|
333 |
"REFRESH: CRefreshHandler::NotifyRefreshClientsCancel calling" )
|
|
|
334 |
LOG2( SIMPLE,
|
|
|
335 |
"REFRESH: CRefreshHandler::NotifyRefreshClientsCancel \
|
|
|
336 |
iRefreshNotifyClientCount: %d", iRefreshNotifyClientCount )
|
|
|
337 |
for ( TInt i = 0; i < iRefreshNotifyClientCount ; i++ )
|
|
|
338 |
{
|
|
|
339 |
iUtils->RefreshSubSessions()[i]->NotifyClientCancel();
|
|
|
340 |
}
|
|
|
341 |
iRefreshNotifyClientCount = 0;
|
|
|
342 |
|
|
|
343 |
LOG( SIMPLE,
|
|
|
344 |
"REFRESH: CRefreshHandler::NotifyRefreshClientsCancel exit" )
|
|
|
345 |
}
|