|
1 /* |
|
2 * Copyright (c) 2002-2009 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 module contains the implementation of CPENetworkViagEngine |
|
15 * class member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "CNWNetworkViagCbEngine.h" |
|
23 #include "CNWNetworkViagBaseEngine.h" |
|
24 #include "CNWNetworkViagTimer.h" |
|
25 #include "NWPanic.pan" |
|
26 #include "NetworkHandlingDomainPSKeys.h" |
|
27 #include "NWLogger.h" |
|
28 #include <CMcn.h> |
|
29 #include <CMcnTopicArray.h> |
|
30 |
|
31 // CONSTANTS |
|
32 const TUint KNWzero = 0; |
|
33 const TUint KNWCityZone = 3; |
|
34 const TInt KHZCBSMessageDataMaxLength = 2 * KNWViagHzCoordinateLength; // x-coordinate and y-coordinate i.e. '111111222222' |
|
35 |
|
36 |
|
37 // ============================ MEMBER FUNCTIONS ============================== |
|
38 |
|
39 // ---------------------------------------------------------------------------- |
|
40 // CNWNetworkViagCbEngine::CNWNetworkViagCbEngine |
|
41 // C++ default constructor can NOT contain any code, that |
|
42 // might leave. |
|
43 // ---------------------------------------------------------------------------- |
|
44 // |
|
45 |
|
46 |
|
47 CNWNetworkViagCbEngine::CNWNetworkViagCbEngine( |
|
48 CNWNetworkViagBaseEngine& aBase, |
|
49 TNWInfo& aNetworkInfo, |
|
50 RMmCustomAPI& aCustomAPI, |
|
51 TNWInterInfo& aInterNetworkInfo, |
|
52 CNWGsmNetworkCellReselectionHandler& aCellReselectionHandler ) |
|
53 : |
|
54 iBase ( aBase ), |
|
55 iNWNetworkInfo( aNetworkInfo ), |
|
56 iCustomAPI( aCustomAPI ), |
|
57 iInterNetworkInfo( aInterNetworkInfo ), |
|
58 iCellReselectionHandler( aCellReselectionHandler ) |
|
59 { |
|
60 iCBSState = EListeningNone; |
|
61 |
|
62 NWLOGSTRING(KNWOBJECT, |
|
63 "NW: CNWNetworkViagCbEngine::CNWNetworkViagCbEngine complete"); |
|
64 } |
|
65 |
|
66 // ---------------------------------------------------------------------------- |
|
67 // CNWNetworkViagCbEngine::ConstructL |
|
68 // Symbian 2nd phase constructor can leave. |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 void CNWNetworkViagCbEngine::ConstructL() |
|
72 { |
|
73 NWLOGSTRING(KNWOBJECT, |
|
74 "NW: CNWNetworkViagCbEngine::CNWNetworkViagCbEngine Begin"); |
|
75 |
|
76 iTimer = CNWNetworkViagTimer::NewL(); |
|
77 iElements = new ( ELeave ) RMmCustomAPI::TViagElements( 1 ); //create array |
|
78 iElements->ResizeL( RMmCustomAPI::KViagElementCount ); |
|
79 iActiveZoneArray = new ( ELeave ) CViagZoneArray( 1 ); //create array |
|
80 iActiveZoneArray->ResizeL( RMmCustomAPI::KViagElementCount ); |
|
81 iCacheHandler = CNWNetworkHZCbCacheHandler::NewL( iCustomAPI ); |
|
82 |
|
83 NWLOGSTRING(KNWOBJECT, |
|
84 "NW: CNWNetworkViagCbEngine::CNWNetworkViagCbEngine End"); |
|
85 } |
|
86 |
|
87 // ---------------------------------------------------------------------------- |
|
88 // CNWNetworkViagCbEngine::NewL |
|
89 // Two-phased constructor. |
|
90 // ---------------------------------------------------------------------------- |
|
91 // |
|
92 CNWNetworkViagCbEngine* CNWNetworkViagCbEngine::NewL( |
|
93 CNWNetworkViagBaseEngine& aBase, |
|
94 TNWInfo& aNetworkInfo, |
|
95 RMmCustomAPI& aCustomAPI, |
|
96 TNWInterInfo& aInterNetworkInfo, |
|
97 CNWGsmNetworkCellReselectionHandler& aCellReselectionHandler ) |
|
98 { |
|
99 NWLOGSTRING(KNWOBJECT, |
|
100 "NW: CNWNetworkViagCbEngine::CNWNetworkViagCbEngine Begin"); |
|
101 |
|
102 CNWNetworkViagCbEngine* self = new (ELeave) CNWNetworkViagCbEngine( |
|
103 aBase, |
|
104 aNetworkInfo, |
|
105 aCustomAPI, |
|
106 aInterNetworkInfo, |
|
107 aCellReselectionHandler ); |
|
108 |
|
109 CleanupStack::PushL( self ); |
|
110 self->ConstructL(); |
|
111 CleanupStack::Pop( self ); |
|
112 |
|
113 NWLOGSTRING(KNWOBJECT, |
|
114 "NW: CNWNetworkViagCbEngine::CNWNetworkViagCbEngine End"); |
|
115 |
|
116 return self; |
|
117 } |
|
118 |
|
119 |
|
120 // ---------------------------------------------------------------------------- |
|
121 // CNWNetworkViagEngine::~CNWNetworkViagCbEngine |
|
122 // Destructor |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 CNWNetworkViagCbEngine::~CNWNetworkViagCbEngine() |
|
126 { |
|
127 NWLOGSTRING(KNWOBJECT, |
|
128 "NW: CNWNetworkViagCbEngine::~CNWNetworkViagCbEngine Begin"); |
|
129 |
|
130 if ( iMcn ) |
|
131 { |
|
132 if( iCBSState == EListeningViag ) |
|
133 { |
|
134 NWLOGSTRING( KNWINT, "NW: CNWnetworkviagengine > imcn.unregister" ); |
|
135 iMcn->Unregister( this ); |
|
136 } |
|
137 iMcn = NULL; // CNWGsmNetworkCellReselectionHandler has ownership. |
|
138 } |
|
139 |
|
140 delete iActiveZoneArray; //delete array |
|
141 delete iElements; //delete array |
|
142 delete iTimer; //delete timer |
|
143 delete iCacheHandler; |
|
144 |
|
145 NWLOGSTRING(KNWOBJECT, |
|
146 "NW: CNWNetworkViagCbEngine::~CNWNetworkViagCbEngine() End"); |
|
147 } |
|
148 |
|
149 |
|
150 // ---------------------------------------------------------------------------- |
|
151 // CNWNetworkViagEngine::CellInfoChanged |
|
152 // Gets called when a message of a subscribed topic is received from the network. |
|
153 // ---------------------------------------------------------------------------- |
|
154 // |
|
155 TInt CNWNetworkViagCbEngine::CellInfoChanged( |
|
156 const TCbsMcnMessage& aMcnMessage ) //MCN message received from the network. |
|
157 { |
|
158 NWLOGSTRING2( KNWINT, |
|
159 "NW: CNWNetworkViagEngine::CellInfoChanged, topic = %d", |
|
160 aMcnMessage.iTopicNumber ); |
|
161 //HZI message, check that we really are listening it |
|
162 if( aMcnMessage.iTopicNumber == KNWHomeZoneMsgId && |
|
163 iCBSState==EListeningViag ) |
|
164 { |
|
165 TInt error = HandleCBSMessages( aMcnMessage ); |
|
166 if( error != KErrNone ) |
|
167 { |
|
168 NWLOGSTRING2( KNWERROR, |
|
169 "NW: CNWNetworkViagEngine::CellInfoChanged, HandleCBSMessages \ |
|
170 error, error code = %d", error ); |
|
171 } |
|
172 else |
|
173 { |
|
174 iBase.SendMessage( |
|
175 MNWMessageObserver::ENWMessageCurrentHomeZoneMessage ); |
|
176 } |
|
177 } |
|
178 |
|
179 NWLOGSTRING( KNWINT, |
|
180 "NW: CNWNetworkViagEngine::CellInfoChanged() End" ); |
|
181 |
|
182 //This is called by MCN client API, so we return always KErrNone |
|
183 return KErrNone; |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CNWNetworkViagEngine::StopCbAlgo |
|
188 // Stops CBS activities |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CNWNetworkViagCbEngine::StopCbAlgo() |
|
192 { |
|
193 NWLOGSTRING( KNWINT, "NW: CNWNetworkViagCbEngine::StopCbAlgo() Begin" ); |
|
194 iTimer->Cancel(); |
|
195 iState=EIdle; |
|
196 if( iCBSState == EListeningViag ) |
|
197 { |
|
198 if ( iMcn ) |
|
199 { |
|
200 NWLOGSTRING( KNWINT, "NW: CNWNetworkViagEngine::StopCbAlgo: iMcn.Unregister" ); |
|
201 iMcn->Unregister( this ); |
|
202 } |
|
203 iCBSState=EListeningNone; |
|
204 } |
|
205 |
|
206 NWLOGSTRING( KNWINT, "NW: CNWNetworkViagCbEngine::StopCbAlgo() End" ); |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CNWNetworkViagCbEngine::CellReselection |
|
211 // Is called by CNWNetworkCurrentNetworkMonitor in case of cell re-selection. |
|
212 // (other items were commented in a header). |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 void CNWNetworkViagCbEngine::CellReselection() |
|
216 { |
|
217 NWLOGSTRING( KNWINT, |
|
218 "NW: CNWNetworkViagCbEngine::CellReselection() Begin" ); |
|
219 |
|
220 TUint cellId = iInterNetworkInfo.iCellId; |
|
221 iCellInfo.iCellId = static_cast<TUint16>( cellId ); |
|
222 iCellInfo.iLac = static_cast<TUint16>( iInterNetworkInfo.iLac ); |
|
223 |
|
224 // StartIndicatorhandling must be called even if cache reading fails. |
|
225 if ( iCacheHandler->InitialisingStatus() == ECBSHZCacheReader_Ready ) |
|
226 { |
|
227 TRAPD( err, StartIndicatorHandlingL( EFalse ) ) |
|
228 if( err!= KErrNone ) |
|
229 { |
|
230 __ASSERT_DEBUG( EFalse, Panic( ENWPanicNotCompleted ) ); |
|
231 } |
|
232 } |
|
233 else |
|
234 { |
|
235 NWLOGSTRING( KNWINT, |
|
236 "NW: CNWNetworkViagCbEngine::CellReselection Cache Reading is Ongoing, Do nothing " ); |
|
237 } |
|
238 |
|
239 NWLOGSTRING( KNWINT, |
|
240 "NW: CNWNetworkViagCbEngine::CellReselection() End" ); |
|
241 } |
|
242 |
|
243 // ---------------------------------------------------------------------------- |
|
244 // CNWNetworkViagCbEngine::IsActiveZone |
|
245 // Checks if there are active Viag Zones |
|
246 // (other items were commented in a header). |
|
247 // ---------------------------------------------------------------------------- |
|
248 // |
|
249 void CNWNetworkViagCbEngine::IsActiveZone( ) |
|
250 { |
|
251 NWLOGSTRING( KNWINT, |
|
252 "NW: CNWNetworkViagCbEngine::CellReselection() Begin" ); |
|
253 |
|
254 //Check that mobile is camping on the Viag network. |
|
255 TInt mcc = KNWzero; |
|
256 if ( TLex( iNWNetworkInfo.iCountryCode ).Val( mcc ) != KErrNone ) |
|
257 { |
|
258 //No error handling convention to use with this error |
|
259 NWLOGSTRING( KNWERROR, "NW: ERROR: CNWNetworkViagCbEngine::ISACTIVEZONE ! TLEX OPERATION FAILED 1"); |
|
260 } |
|
261 |
|
262 TInt mnc = KNWzero; |
|
263 if ( TLex( iNWNetworkInfo.iNetworkId ).Val( mnc ) != KErrNone ) |
|
264 { |
|
265 //No error handling convention to use with this error |
|
266 NWLOGSTRING( KNWERROR, "NW: ERROR: CNWNetworkViagCbEngine::ISACTIVEZONE ! TLEX OPERATION FAILED 2"); |
|
267 } |
|
268 |
|
269 NWLOGSTRING3( KNWINT, "NW: CNWNetworkViagCbEngine::CellReselection(), \ |
|
270 mcc = %d, mnc = %d ", mcc, mnc ); |
|
271 |
|
272 if( mcc == KNWViagMcc && mnc == KNWViagMnc ) |
|
273 { |
|
274 TBool home( EFalse ); |
|
275 TBool city( EFalse ); |
|
276 |
|
277 TInt count = iActiveZoneArray->Count(); |
|
278 |
|
279 NWLOGSTRING2( KNWINT, "NW: CNWNetworkViagCbEngine::CellReselection(), \ |
|
280 number of active zones = %d", count ); |
|
281 |
|
282 for ( TInt i=count-1; i>=0; i-- ) |
|
283 { |
|
284 TViagZoneInfo info = iActiveZoneArray->At(i); |
|
285 if ( info.iActiveFlag == RMmCustomAPI::EHomeZone ) |
|
286 { |
|
287 home=ETrue; |
|
288 //error is ignored, since it will always succeed. |
|
289 } |
|
290 else if ( info.iActiveFlag == RMmCustomAPI::ECityZone ) |
|
291 { |
|
292 city=ETrue; |
|
293 //error code is ignored |
|
294 } |
|
295 } |
|
296 if(home && city) |
|
297 iIsActiveZones=EBothActive; |
|
298 else if(home) |
|
299 iIsActiveZones=EHomeActive; |
|
300 else if(city) |
|
301 iIsActiveZones=ECityActive; |
|
302 else |
|
303 iIsActiveZones=ENoneActive; |
|
304 } |
|
305 else |
|
306 iIsActiveZones=ENoneActive; |
|
307 |
|
308 NWLOGSTRING2( KNWINT, "NW: CNWNetworkViagCbEngine::IsActiveZone: Active zones(0 none, 1 hz, 2 cz, 3 both): %d", iIsActiveZones ); |
|
309 |
|
310 } |
|
311 |
|
312 // ---------------------------------------------------------------------------- |
|
313 // CNWNetworkViagCbEngine::UpdateViagHzParams |
|
314 // Updates Viag HomeZone parameters from SIM. |
|
315 // KErrNone if everything goes allright. |
|
316 // Some error value if CustomAPI call or Append fails |
|
317 // (other items were commented in a header). |
|
318 // ---------------------------------------------------------------------------- |
|
319 // |
|
320 TInt CNWNetworkViagCbEngine::UpdateViagHzParams() |
|
321 { |
|
322 NWLOGSTRING( KNWINT, |
|
323 "NW: CNWNetworkViagCbEngine::UpdateViagHzParams() Begin" ); |
|
324 |
|
325 //Empty elements without free memory |
|
326 TInt count = iElements->Count(); |
|
327 TInt i; |
|
328 |
|
329 NWLOGSTRING2( KNWINT, "NW: CNWNetworkViagCbEngine::UpdateViagHzParams(), \ |
|
330 iElements->Count() = %d", count ); |
|
331 |
|
332 for ( i = count-1; i>=0; i-- ) |
|
333 { |
|
334 iElements->Delete( i ); |
|
335 } |
|
336 |
|
337 //For TSY requires this to be the array's size |
|
338 TRAPD( err, iElements->ResizeL( RMmCustomAPI::KViagElementCount ) ) |
|
339 if( err != KErrNone ) |
|
340 { |
|
341 //error handling |
|
342 NWLOGSTRING2( KNWINT, "NW: CNWNetworkViagCbEngine::\ |
|
343 UpdateViagHzParams(), elements array resize error: %d", err ); |
|
344 return err; |
|
345 } |
|
346 |
|
347 NWLOGSTRING( KNWREQOUT, |
|
348 "NW: CNWNetworkViagCbEngine::UpdateViagHzParams: \ |
|
349 ReadViagHomeZoneParams()" ); |
|
350 TInt error = iCustomAPI.ReadViagHomeZoneParams( iParams, *iElements ); |
|
351 |
|
352 if( error == KErrNone ) |
|
353 { |
|
354 NWLOGSTRING( KNWINT, |
|
355 "NW: CNWNetworkViagCbEngine::UpdateViagHzParams: params updated" ); |
|
356 |
|
357 //Empty zoneArray without free memory |
|
358 count = iActiveZoneArray->Count(); |
|
359 NWLOGSTRING2( KNWINT, "NW: CNWNetworkViagCbEngine::\ |
|
360 UpdateViagHzParams(), number of active zones: %d", count ); |
|
361 |
|
362 for ( i = count-1; i>=0; i-- ) |
|
363 { |
|
364 iActiveZoneArray->Delete( i ); |
|
365 } |
|
366 |
|
367 count = iElements->Count(); |
|
368 for ( i = KNWzero; i < count; i++ ) |
|
369 { |
|
370 RMmCustomAPI::TViagElement& element = iElements->At( i ); |
|
371 TViagZoneInfo info; |
|
372 |
|
373 info.iX = element.iCoordinates.iX; |
|
374 info.iY = element.iCoordinates.iY; |
|
375 info.iR2 = element.iCoordinates.iR2; |
|
376 info.iZoneId = element.iCoordinates.iZoneId; |
|
377 info.iName.Copy( element.iName ); |
|
378 iBase.SetZoneTag( info.iZoneId-1, info.iName ); |
|
379 NWLOGSTRING3( KNWINT, |
|
380 "NW: CNWNetworkViagCbEngine::UpdateViagHzParams: \ |
|
381 Zone Id: %d, element name: %S ", |
|
382 info.iZoneId, &info.iName ); |
|
383 NWLOGSTRING4( KNWINT, "ViagEngine::UpdateViagHzParams: \ |
|
384 iX = %d, iY = %d, iR2 = %d", |
|
385 info.iX, info.iY, info.iR2); |
|
386 |
|
387 switch( element.iActiveFlag ) |
|
388 { |
|
389 case RMmCustomAPI::ENotActive: |
|
390 info.iActiveFlag = RMmCustomAPI::ENotActive; |
|
391 NWLOGSTRING( KNWINT, |
|
392 "NW: CNWNetworkViagCbEngine::UpdateViagHzParams \ |
|
393 ! ENotActive" ); |
|
394 break; |
|
395 case RMmCustomAPI::EHomeZone: |
|
396 info.iActiveFlag = RMmCustomAPI::EHomeZone; |
|
397 NWLOGSTRING( KNWINT, |
|
398 "NW: CNWNetworkViagCbEngine::UpdateViagHzParams !\ |
|
399 EHomeZone active" ); |
|
400 break; |
|
401 case RMmCustomAPI::ECityZone: |
|
402 info.iActiveFlag = RMmCustomAPI::ECityZone; |
|
403 NWLOGSTRING( KNWINT, |
|
404 "NW: CNWNetworkViagCbEngine::UpdateViagHzParams ! \ |
|
405 ECityZone active " ); |
|
406 break; |
|
407 default: |
|
408 break; |
|
409 } |
|
410 |
|
411 // If zone is active, add it into iActiveZoneArray |
|
412 if ( element.iActiveFlag != RMmCustomAPI::ENotActive ) |
|
413 { |
|
414 TRAPD( err, iActiveZoneArray->AppendL( info ) )//lint !e578 |
|
415 if( err != KErrNone ) |
|
416 { |
|
417 //error handling |
|
418 NWLOGSTRING2( KNWERROR, |
|
419 "NW: CNWNetworkViagCbEngine::UpdateViagHzParams(),\ |
|
420 error code = %d", err ); |
|
421 return err; |
|
422 } |
|
423 } |
|
424 } |
|
425 |
|
426 NWLOGSTRING2( KNWINT, "NW: CNWNetworkViagCbEngine::\ |
|
427 UpdateViagHzParams(), after loop running variable i = %d", i ); |
|
428 } |
|
429 |
|
430 NWLOGSTRING2( KNWINT, |
|
431 "NW: CNWNetworkViagCbEngine::UpdateViagHzParams: returns %d", error ); |
|
432 |
|
433 return error; |
|
434 } |
|
435 |
|
436 // ---------------------------------------------------------------------------- |
|
437 // CNWNetworkViagCbEngine::RegisterToCBS |
|
438 // Registers to listening CBS messages |
|
439 // (other items were commented in a header). |
|
440 // ---------------------------------------------------------------------------- |
|
441 // |
|
442 void CNWNetworkViagCbEngine::RegisterToCBSL( |
|
443 TUint16 aTopic ) |
|
444 { |
|
445 NWLOGSTRING2( KNWINT, "NW: CNWNetworkViagCbEngine::RegisterToCBSL() Begin,\ |
|
446 aTopic = %d ", aTopic ); |
|
447 |
|
448 if( !iMcn ) |
|
449 { |
|
450 iMcn = iCellReselectionHandler.GetMcnPtr(); |
|
451 } |
|
452 |
|
453 if( iMcn ) |
|
454 { |
|
455 // Specify topics with CMcnTopicArray. |
|
456 CMcnTopicArray* topics = CMcnTopicArray::NewL(); |
|
457 CleanupStack::PushL( topics ); |
|
458 topics->AddCbTopicL( aTopic ); // MCN Info (cell info) |
|
459 |
|
460 // Register. Parameter observer is an instance of CCbsMcnObserver. |
|
461 NWLOGSTRING( KNWINT, "NW: CNWNetworkViagEngine::RegisterToCBSL > imcn.registerL()" ); |
|
462 iMcn->RegisterL( this, *topics ); |
|
463 iCBSState = EListeningViag; |
|
464 NWLOGSTRING( KNWINT, |
|
465 "NW: CNWNetworkViagEngine::RegisterToCBSL ! Registered to Viag messages" ); |
|
466 |
|
467 // Start CBS message waiting timer |
|
468 iTimer->Cancel(); |
|
469 iTimer->After( KViagTimerSixtySeconds, this ); |
|
470 iState = ECbsSixtySecondsWaiting; |
|
471 NWLOGSTRING( KNWINT, "NW: CNWNetworkViagCbEngine::RegisterToCBSL 60s timer started" ); |
|
472 CleanupStack::PopAndDestroy( topics ); |
|
473 } |
|
474 |
|
475 NWLOGSTRING( KNWINT, |
|
476 "NW: CNWNetworkViagCbEngine::RegisterToCBSL ! Registered to Viag \ |
|
477 messages" ); |
|
478 } |
|
479 |
|
480 // ---------------------------------------------------------------------------- |
|
481 // CNWNetworkViagCbEngine::StartIndicatorHandlingL |
|
482 // Checks and indicates user if current zone is City/HomeZone. |
|
483 // This method reads params from SIM card and checks if current zone is active |
|
484 // zone and if it is in SIM cache. It also starts 60 second timer to listen for |
|
485 // CBS messages. |
|
486 // (other items were commented in a header). |
|
487 // ---------------------------------------------------------------------------- |
|
488 // |
|
489 void CNWNetworkViagCbEngine::StartIndicatorHandlingL( TBool aRefreshOccureed ) |
|
490 { |
|
491 NWLOGSTRING( KNWINT, |
|
492 "NW: CNWNetworkViagCbEngine::StartIndicatorHandlingL Begin" ); |
|
493 ResetIndicatorValues(); |
|
494 IsActiveZone(); |
|
495 |
|
496 NWLOGSTRING3( KNWINT, "NW: CNWNetworkViagCbEngine::StartIndicatorHandlingL(),\ |
|
497 iIsActiveZones = %d, iInterNetworkInfo.iCellId = %d", iIsActiveZones, |
|
498 iInterNetworkInfo.iCellId ); |
|
499 // Is there any active zones? |
|
500 if( iIsActiveZones && iInterNetworkInfo.iCellId != 0 ) |
|
501 { |
|
502 TInt cache = SearchHomeZoneCaches( iCellInfo, iActiveZoneArray ); |
|
503 if( cache >= EHZ_HomeZoneCache1 ) |
|
504 { |
|
505 // Found from cache. Update values to UI. |
|
506 if( cache == EHZ_HomeZoneCache1 || |
|
507 cache == EHZ_HomeZoneCache2 || |
|
508 cache == EHZ_HomeZoneCache3 ) |
|
509 { |
|
510 NWLOGSTRING( KNWINT, |
|
511 "NW: CNWNetworkViagCbEngine::StartIndicatorHandlingL ! \ |
|
512 Calling writeviagvalues" ); |
|
513 iBase.WriteViagValues( ENWViagIndicatorTypeHomeZone, |
|
514 cache - 1 ); |
|
515 } |
|
516 else if( cache == EHZ_CityZoneCache ) |
|
517 { |
|
518 NWLOGSTRING( KNWINT, |
|
519 "NW: CNWNetworkViagCbEngine::StartIndicatorHandlingL ! \ |
|
520 Calling writeviagvalues" ); |
|
521 iBase.WriteViagValues( ENWViagIndicatorTypeCityZone, |
|
522 KNWCityZone ); // 3 is cityzone |
|
523 } |
|
524 } |
|
525 //----------------------------------------------------------- |
|
526 // No cell found from cache |
|
527 //------------------------------------------------------------ |
|
528 else |
|
529 { |
|
530 if( aRefreshOccureed ) |
|
531 { |
|
532 if ( iMcn ) |
|
533 { |
|
534 // When refresh is occured and we are in same cell the |
|
535 // CBS message is not received so we fetch the old message |
|
536 // from CBS server and use it like received CBS message. |
|
537 NWLOGSTRING( KNWINT, |
|
538 "NW: CNWNetworkViagCbEngine::StartIndicatorHandlingL\ |
|
539 -> Fetch previous CBS Msg from Server" ); |
|
540 |
|
541 // Initilize before fetching data from server |
|
542 iCachedHZCBSMessage.iBuffer.Copy( KNullDesC ); |
|
543 iCachedHZCBSMessage.iBuffer8.Copy( KNullDesC8 ); |
|
544 |
|
545 TInt error = iMcn->GetInfoMessage( |
|
546 iCachedHZCBSMessage.iBuffer, KNWHomeZoneMsgId ); |
|
547 if ( !error ) |
|
548 { |
|
549 NWLOGSTRING2( KNWINT, |
|
550 "NW: CNWNetworkViagCbEngine::StartIndicator\ |
|
551 HandlingL 'iCachedHZCBSMessage.iBuffer' = [%S]", |
|
552 &iCachedHZCBSMessage.iBuffer ); |
|
553 HandleCBSMessages( iCachedHZCBSMessage ); |
|
554 } |
|
555 NWLOGSTRING( KNWINT, |
|
556 "NW: CNWNetworkViagCbEngine::StartIndicatorHandlingL \ |
|
557 -> Simulated CBS message done" ); |
|
558 } |
|
559 } |
|
560 } |
|
561 // Start listening CBS messages. |
|
562 RegisterToCBSL( KNWHomeZoneMsgId ); |
|
563 } |
|
564 NWLOGSTRING( KNWINT, |
|
565 "NW: CNWNetworkViagCbEngine::StartIndicatorHandlingL End" ); |
|
566 } |
|
567 |
|
568 // ---------------------------------------------------------------------------- |
|
569 // CNWNetworkViagCbEngine::HandleCBSMessages |
|
570 // Checks and indicates user if current zone is City/HomeZone. |
|
571 // This method compares the coordinates received by CBS message to zones that we |
|
572 // are registered to.It also Adds and removes ids from SIM cache, according the |
|
573 // result of the comparation. |
|
574 // Return Values: KErrNone :Operation was done successfully |
|
575 // KErrArgument :Incorrect message |
|
576 // KErrGeneral :AddHomeZoneCache failed |
|
577 // Possible error code from TLex. |
|
578 // (other items were commented in a header). |
|
579 // ---------------------------------------------------------------------------- |
|
580 // |
|
581 TInt CNWNetworkViagCbEngine::HandleCBSMessages( |
|
582 const TCbsMcnMessage& aMcnMessage ) //MCN message received from the network. |
|
583 { |
|
584 NWLOGSTRING( KNWINT, |
|
585 "NW: CNWNetworkViagCbEngine::HandleCBSMessages() Begin" ); |
|
586 TInt res( KErrNone ); |
|
587 |
|
588 StopCbAlgo(); |
|
589 |
|
590 NWLOGSTRING2( KNWINT, |
|
591 "NW: CNWNetworkViagCbEngine::HandleCBSMessages 'CBS MSG' = [%S]", |
|
592 &aMcnMessage.iBuffer ); |
|
593 |
|
594 //Decode Msg |
|
595 //7-bit alphabet packing decoding is made in CBs server. |
|
596 TPtr msgData = aMcnMessage.iBuffer.LeftTPtr( KHZCBSMessageDataMaxLength ); |
|
597 |
|
598 // Validate data and then process it. |
|
599 if ( ValidateHZCBSMessage( msgData ) ) |
|
600 { |
|
601 TUint32 mX(0); |
|
602 TUint32 mY(0); |
|
603 |
|
604 TInt length = msgData.Length(); |
|
605 |
|
606 TInt lexErr = TLex( msgData.Right( KNWViagHzCoordinateLength ) ).Val( |
|
607 mY, EDecimal ); |
|
608 |
|
609 NWLOGSTRING2( KNWINT, |
|
610 "NW: CNWNetworkViagCbEngine::HandleCBSMessages(),\ |
|
611 lexErr = %d ", lexErr ); |
|
612 |
|
613 if( lexErr == KErrNone ) |
|
614 { |
|
615 TInt xpos = length - Min( length, KNWViagHzMsgLength ); |
|
616 |
|
617 lexErr = TLex( msgData.Mid( xpos, |
|
618 (length-KNWViagHzCoordinateLength)-xpos ) ).Val( |
|
619 mX, EDecimal ); |
|
620 } |
|
621 |
|
622 if( lexErr == KErrNone ) |
|
623 { |
|
624 TInt zone = CheckCellInHomeZoneArray( mX, mY ); |
|
625 //If it wasn't in any zone, make sure it's removed from cache |
|
626 if( zone==KErrNotFound ) |
|
627 { |
|
628 NWLOGSTRING( KNWINT, |
|
629 "NW: CNWNetworkViagCbEngine::HandleCBSMessages ! \ |
|
630 Remove from cache" ); |
|
631 if( RemoveFromHomeZoneCaches( iCellInfo ) ) |
|
632 { |
|
633 ResetIndicatorValues(); |
|
634 } |
|
635 } |
|
636 else |
|
637 { |
|
638 res = DoHandleAddToCBSHZCache( ( |
|
639 THomeZoneCacheId ) zone, iCellInfo ); |
|
640 } |
|
641 } |
|
642 else |
|
643 { |
|
644 //No error handling convention to use with this error |
|
645 NWLOGSTRING( KNWERROR, |
|
646 "NW: HandleCBSMessages ! TLEX OPERATION FAILED"); |
|
647 } |
|
648 } |
|
649 else //length != 2*KPhoneViagHzCoordinateLength |
|
650 { |
|
651 //incorrect message. Nothing to do |
|
652 res=KErrArgument; |
|
653 } |
|
654 |
|
655 NWLOGSTRING2( KNWINT, |
|
656 "NW: CNWNetworkViagCbEngine::HandleCBSMessages() End, \ |
|
657 res = %d ", res ); |
|
658 return res; |
|
659 } |
|
660 |
|
661 // ---------------------------------------------------------------------------- |
|
662 // CNWNetworkViagCbEngine::DoHandleAddToCBSHZCache |
|
663 // |
|
664 // |
|
665 // (other items were commented in a header). |
|
666 // ---------------------------------------------------------------------------- |
|
667 // |
|
668 TInt CNWNetworkViagCbEngine::DoHandleAddToCBSHZCache( |
|
669 const THomeZoneCacheId aCache, |
|
670 const RMmCustomAPI::TViagCacheRecordContent aCellInfo ) |
|
671 { |
|
672 NWLOGSTRING4( KNWINT, |
|
673 "NW: CNWNetworkViagCbEngine::DoHandleAddToCBSHZCache() Begin, \ |
|
674 aCache = %d, aCellInfo.iLac = %d, aCellInfo.iCellId = %d ", |
|
675 aCache, aCellInfo.iLac, aCellInfo.iCellId ); |
|
676 |
|
677 ASSERT( aCache >= EHZ_HomeZoneCache1 && aCache <= EHZ_CityZoneCache ); |
|
678 TInt retVal = KErrNone; |
|
679 |
|
680 // Step 1: Remove the cell from other caches |
|
681 // .. from higher priority ones |
|
682 for( TInt cacheId = EHZ_HomeZoneCache1; cacheId < aCache; cacheId++ ) |
|
683 { |
|
684 TInt pos = iCacheHandler->Find( ( |
|
685 THomeZoneCacheId ) cacheId, aCellInfo ); |
|
686 if( pos != KErrNotFound ) |
|
687 { |
|
688 NWLOGSTRING2( KNWINT, |
|
689 "NW: DoHandleAddToCBSHZCache(), Old item found from cache [%d], remove it", |
|
690 cacheId ); |
|
691 if( iCacheHandler->Remove( ( THomeZoneCacheId ) cacheId, pos ) ) |
|
692 { |
|
693 return KErrGeneral; |
|
694 } |
|
695 } |
|
696 } |
|
697 // .. and lower priority ones |
|
698 for( TInt cacheId = EHZ_CityZoneCache; cacheId > aCache; cacheId-- ) |
|
699 { |
|
700 TInt pos = iCacheHandler->Find( ( |
|
701 THomeZoneCacheId ) cacheId, aCellInfo ); |
|
702 if( pos != KErrNotFound ) |
|
703 { |
|
704 NWLOGSTRING2( KNWINT, |
|
705 "NW: DoHandleAddToCBSHZCache(), Old item found from cache \ |
|
706 [%d], remove it", cacheId ); |
|
707 if( iCacheHandler->Remove( ( THomeZoneCacheId ) cacheId, pos ) ) |
|
708 { |
|
709 return KErrGeneral; |
|
710 } |
|
711 } |
|
712 } |
|
713 |
|
714 // Step 2: Update the cache if needed |
|
715 // Check if the cell exists already in cache |
|
716 TInt pos = iCacheHandler->Find( ( THomeZoneCacheId ) aCache, aCellInfo ); |
|
717 if( pos == KErrNotFound ) |
|
718 { |
|
719 pos = AddToHomeZoneCache( ( THomeZoneCacheId ) aCache, iCellInfo ); |
|
720 if( pos < KErrNone ) |
|
721 { |
|
722 retVal = KErrGeneral; |
|
723 } |
|
724 } |
|
725 |
|
726 NWLOGSTRING2( KNWINT, |
|
727 "NW: CNWNetworkViagCbEngine::DoHandleAddToCBSHZCache() End, \ |
|
728 retVal = %d ", retVal ); |
|
729 |
|
730 return retVal; |
|
731 } |
|
732 |
|
733 // ---------------------------------------------------------------------------- |
|
734 // CNWNetworkViagCbEngine::ValidateHZCBSMessage |
|
735 // Validates that aMsgData contains valid HomeZone CBS Message data |
|
736 // |
|
737 // (other items were commented in a header). |
|
738 // ---------------------------------------------------------------------------- |
|
739 // |
|
740 TBool CNWNetworkViagCbEngine::ValidateHZCBSMessage( const TDesC & aMsgData ) |
|
741 { |
|
742 NWLOGSTRING( KNWINT, |
|
743 "NW: CNWNetworkViagCbEngine::ValidateHZCBSMessage() Begin" ); |
|
744 |
|
745 // ASSERT HERE |
|
746 TBool retVal ( EFalse ); |
|
747 TInt msgLength = aMsgData.Length(); |
|
748 NWLOGSTRING2( KNWINT, |
|
749 "NW: CNWNetworkViagCbEngine::ValidateHZCBSMessage 'aMsgData' = [%S]", |
|
750 &aMsgData ); |
|
751 NWLOGSTRING2( KNWINT, |
|
752 "NW: CNWNetworkViagCbEngine::ValidateHZCBSMessage 'msgLength' = [%d]", |
|
753 msgLength ); |
|
754 |
|
755 // Validate the length |
|
756 if( msgLength == KHZCBSMessageDataMaxLength ) |
|
757 { |
|
758 TInt pos; |
|
759 |
|
760 for( pos = 0; pos < msgLength; pos++ ) |
|
761 { |
|
762 // Validate the content. Only digits allowed. |
|
763 TChar tmpChar = aMsgData[ pos ]; |
|
764 if( !tmpChar.IsDigit() ) |
|
765 { |
|
766 break; |
|
767 } |
|
768 } |
|
769 |
|
770 NWLOGSTRING2( |
|
771 KNWINT, "NW:CNWNetworkViagCbEngine::ValidateHZCBSMessage,\ |
|
772 after loop running variable pos = %d ", pos ); |
|
773 |
|
774 // Check if the loop was run at the end. |
|
775 if( pos == msgLength ) |
|
776 { |
|
777 retVal = ETrue; |
|
778 } |
|
779 } |
|
780 |
|
781 NWLOGSTRING2( KNWINT, "NW: CNWNetworkViagCbEngine::ValidateHZCBSMessage()\ |
|
782 End, retVal = %d ", retVal ); |
|
783 // Contains only numbers |
|
784 return retVal; |
|
785 } |
|
786 |
|
787 // ---------------------------------------------------------------------------- |
|
788 // CNWNetworkViagCbEngine::CheckCellInHomeZoneArray |
|
789 // Checks if current zones coordinates are within some active Home-/CityZone limits. |
|
790 // Return Values: HomeZones number that matched the limits |
|
791 // KErrNotFound :No registered Zones were in limits |
|
792 // (other items were commented in a header). |
|
793 // ---------------------------------------------------------------------------- |
|
794 // |
|
795 TInt CNWNetworkViagCbEngine::CheckCellInHomeZoneArray( TUint32 aX, TUint32 aY ) |
|
796 { |
|
797 NWLOGSTRING3( KNWINT, |
|
798 "NW: CNWNetworkViagCbEngine::CheckCellInHomeZoneArray()\ |
|
799 Begin, parameter aX = %d, parameter aY = %d", aX, aY ); |
|
800 |
|
801 //Check if current cell is within HomeZone or CityZone |
|
802 TInt currentZone = KErrNotFound; |
|
803 for ( TInt i = KNWzero; i < iActiveZoneArray->Count(); i++ ) |
|
804 { |
|
805 TViagZoneInfo zoneInfo = iActiveZoneArray->At( i ); |
|
806 |
|
807 TInt32 dx = Abs( static_cast<TInt32>( aX-zoneInfo.iX ) ); |
|
808 TInt32 dy = Abs( static_cast<TInt32>( aY-zoneInfo.iY ) ); |
|
809 |
|
810 if ( dx > KNWViagHomeZoneMaxRad || dy > KNWViagHomeZoneMaxRad ) |
|
811 { |
|
812 //Checking next homezone |
|
813 continue; |
|
814 } |
|
815 |
|
816 TUint32 d2 = dx*dx + dy*dy;//lint !e732 |
|
817 |
|
818 if ( d2 < zoneInfo.iR2 ) |
|
819 { |
|
820 //Current cell is inside the home-/cityzone |
|
821 currentZone = zoneInfo.iZoneId; |
|
822 |
|
823 NWLOGSTRING3( KNWINT, |
|
824 "NW: CNWNetworkViagCbEngine::CheckCellInHomeZoneArray ! R2 \ |
|
825 is %d, matches to zone nbr: %d", d2, currentZone ); |
|
826 if( zoneInfo.iActiveFlag == RMmCustomAPI::ECityZone ) //This is CityZone |
|
827 { |
|
828 NWLOGSTRING( KNWINT, |
|
829 "NW: CNWNetworkViagCbEngine::CheckCellInHomeZoneArray ! \ |
|
830 calling writeviagvalues" ); |
|
831 |
|
832 iBase.WriteViagValues( ENWViagIndicatorTypeCityZone, |
|
833 zoneInfo.iZoneId - 1 ); |
|
834 |
|
835 NWLOGSTRING( KNWINT, |
|
836 "NW: CNWNetworkViagCbEngine::CheckCellInHomeZoneArray ! \ |
|
837 cityzoneinfo updated" ); |
|
838 } |
|
839 else //This is HomeZone |
|
840 { |
|
841 NWLOGSTRING( KNWINT, |
|
842 "NW: CNWNetworkViagCbEngine::CheckCellInHomeZoneArray ! \ |
|
843 calling writeviagvalues" ); |
|
844 iBase.WriteViagValues( ENWViagIndicatorTypeHomeZone, |
|
845 zoneInfo.iZoneId - 1 ); |
|
846 NWLOGSTRING( KNWINT, |
|
847 "NW: CNWNetworkViagCbEngine::CheckCellInHomeZoneArray ! \ |
|
848 homezoneinfo updated" ); |
|
849 } |
|
850 |
|
851 break; |
|
852 } |
|
853 } |
|
854 |
|
855 NWLOGSTRING2( KNWINT, |
|
856 "NW: CNWNetworkViagCbEngine::CheckCellInHomeZoneArray()\ |
|
857 End, currentZone = %d ", currentZone ); |
|
858 return currentZone; |
|
859 } |
|
860 |
|
861 // ---------------------------------------------------------------------------- |
|
862 // CNWNetworkViagCbEngine::SearchHomeZoneCaches |
|
863 // |
|
864 // (other items were commented in a header). |
|
865 // ---------------------------------------------------------------------------- |
|
866 // |
|
867 TInt CNWNetworkViagCbEngine::SearchHomeZoneCaches( |
|
868 const RMmCustomAPI::TViagCacheRecordContent aCellInfo, |
|
869 const CViagZoneArray * aActiveZones ) |
|
870 { |
|
871 NWLOGSTRING( KNWINT, |
|
872 "NW: CNWNetworkViagCbEngine::SearchHomeZoneCaches() <- " ); |
|
873 NWLOGSTRING2( KNWINT, |
|
874 "NW: SearchHomeZoneCaches(), Item to be found: LAC [%d]", |
|
875 aCellInfo.iLac ); |
|
876 NWLOGSTRING2( KNWINT, |
|
877 "NW: SearchHomeZoneCaches(), Item to be found: CellId [%d]", |
|
878 aCellInfo.iCellId ); |
|
879 |
|
880 TInt retVal = KErrNotFound; |
|
881 |
|
882 for ( TInt i = 0; i < aActiveZones->Count(); i++ ) |
|
883 { |
|
884 const TViagZoneInfo & zoneInfo = aActiveZones->At( i ); |
|
885 TInt cacheIndex = zoneInfo.iZoneId; |
|
886 |
|
887 TInt index = iCacheHandler->Find( ( THomeZoneCacheId ) cacheIndex, |
|
888 aCellInfo ); |
|
889 |
|
890 if( index > KErrNotFound ) |
|
891 { |
|
892 // Found from cache |
|
893 // ...set return value |
|
894 NWLOGSTRING2( KNWINT, |
|
895 "NW: CNWNetworkViagCbEngine::SearchHomeZoneCaches(): \ |
|
896 Found from cache: [%d]", cacheIndex ); |
|
897 retVal = cacheIndex; |
|
898 break; |
|
899 } |
|
900 } |
|
901 |
|
902 NWLOGSTRING( KNWINT, |
|
903 "NW: CNWNetworkViagCbEngine::SearchHomeZoneCaches() -> " ); |
|
904 |
|
905 return retVal; |
|
906 } |
|
907 |
|
908 |
|
909 // ---------------------------------------------------------------------------- |
|
910 // CNWNetworkViagCbEngine::AddToHomeZoneCache |
|
911 // |
|
912 // (other items were commented in a header). |
|
913 // ---------------------------------------------------------------------------- |
|
914 // |
|
915 TInt CNWNetworkViagCbEngine::AddToHomeZoneCache( |
|
916 const THomeZoneCacheId aZone, |
|
917 const RMmCustomAPI::TViagCacheRecordContent aCellInfo ) |
|
918 { |
|
919 NWLOGSTRING4( KNWINT, "NW: CNWNetworkViagCbEngine::AddToHomeZoneCache() \ |
|
920 Begin, aZone = %d, aCellInfo.iLac = %d, aCellInfo.iCellId = %d", |
|
921 aZone, aCellInfo.iLac, aCellInfo.iCellId ); |
|
922 |
|
923 TInt retVal = KErrNotFound; |
|
924 |
|
925 // Find a zoneInfo which corresponds to aZone |
|
926 TInt zoneIndex = -1; |
|
927 TInt activeZones = iActiveZoneArray->Count(); |
|
928 |
|
929 for( zoneIndex = 0; zoneIndex < activeZones; zoneIndex++ ) |
|
930 { |
|
931 TViagZoneInfo& zoneInfo = iActiveZoneArray->At( zoneIndex ); |
|
932 if( zoneInfo.iZoneId == ( TUint ) aZone ) |
|
933 { |
|
934 // Write updated data in cache |
|
935 retVal = iCacheHandler->Insert( ( THomeZoneCacheId ) aZone, |
|
936 aCellInfo ); |
|
937 NWLOGSTRING2( KNWINT, |
|
938 "NW: CNWNetworkViagEngine::AddToHomeZoneCache, Added in \ |
|
939 CACHE [%d]", aZone ); |
|
940 NWLOGSTRING2( KNWINT, |
|
941 "NW: CNWNetworkViagEngine::AddToHomeZoneCache, Added by \ |
|
942 INDEX [%d]", retVal ); |
|
943 break; |
|
944 } |
|
945 } |
|
946 |
|
947 NWLOGSTRING2( KNWINT, |
|
948 "NW: CNWNetworkViagCbEngine::AddToHomeZoneCache(), after loop \ |
|
949 running variable zoneIndex = %d ", zoneIndex ); |
|
950 NWLOGSTRING2( KNWINT, |
|
951 "NW: CNWNetworkViagCbEngine::AddToHomeZoneCache() End, \ |
|
952 retVal = %d ", retVal ); |
|
953 |
|
954 return retVal; |
|
955 } |
|
956 |
|
957 |
|
958 // ---------------------------------------------------------------------------- |
|
959 // CNWNetworkViagCbEngine::HandleTimeOutL |
|
960 // Handles timeout. |
|
961 // (other items were commented in a header). |
|
962 // ---------------------------------------------------------------------------- |
|
963 // |
|
964 void CNWNetworkViagCbEngine::HandleTimeOut() |
|
965 { |
|
966 NWLOGSTRING( KNWINT, "NW: CNWNetworkViagCbEngine::HandleTimeOut() Begin "); |
|
967 |
|
968 switch ( iState ) |
|
969 { |
|
970 case ECbsSixtySecondsWaiting: |
|
971 { |
|
972 //Unregisters when 60/55sec timer expires |
|
973 NWLOGSTRING( KNWINT, |
|
974 "NW: CNWNetworkViagCbEngine::HandleTimeOut ! 60s timer \ |
|
975 expired" ); |
|
976 if ( iMcn ) |
|
977 { |
|
978 NWLOGSTRING( KNWINT, |
|
979 "NW: CNWNetworkViagEngine::HandleTimeOut > imcn.unre\ |
|
980 gister" ); |
|
981 iMcn->Unregister( this ); |
|
982 } |
|
983 iState=EIdle; |
|
984 iCBSState=EListeningNone; |
|
985 } |
|
986 break; |
|
987 case EIdle: |
|
988 default: |
|
989 __ASSERT_DEBUG( EFalse, Panic( ENWPanicNotCompleted ) ); |
|
990 break; |
|
991 } |
|
992 |
|
993 NWLOGSTRING( KNWINT, "NW: CNWNetworkViagCbEngine::HandleTimeOut() End "); |
|
994 } |
|
995 |
|
996 |
|
997 // ---------------------------------------------------------------------------- |
|
998 // CNWNetworkViagCbEngine::ResetIndicatorValues |
|
999 // Resets Viag's and MCN display's TPEInfo values. |
|
1000 // (other items were commented in a header). |
|
1001 // ---------------------------------------------------------------------------- |
|
1002 // |
|
1003 void CNWNetworkViagCbEngine::ResetIndicatorValues() |
|
1004 { |
|
1005 NWLOGSTRING( KNWINT, |
|
1006 "NW: CNWNetworkViagCbEngine::ResetIndicatorValues() Begin"); |
|
1007 |
|
1008 iBase.WriteViagValues( ENWViagIndicatorTypeNone, NULL ); |
|
1009 |
|
1010 NWLOGSTRING( KNWINT, |
|
1011 "NW: CNWNetworkViagCbEngine::ResetIndicatorValues() End "); |
|
1012 } |
|
1013 |
|
1014 |
|
1015 |
|
1016 // ---------------------------------------------------------------------------- |
|
1017 // CNWNetworkViagCbEngine::SatRefreshCompleteNotification |
|
1018 // If homezone files are refreshed this method is called. |
|
1019 // ---------------------------------------------------------------------------- |
|
1020 // |
|
1021 void CNWNetworkViagCbEngine::SatRefreshCompleteNotification() |
|
1022 { |
|
1023 NWLOGSTRING( KNWINT, |
|
1024 "NW: CNWNetworkViagCbEngine::SatRefreshCompleteNotification() Begin" ); |
|
1025 StopCbAlgo(); // Stop listening CBS Messages |
|
1026 TInt error = UpdateViagHzParams(); // Get updated data from SIM |
|
1027 //If params not found, do nothing |
|
1028 if( error ) |
|
1029 { |
|
1030 NWLOGSTRING2( KNWERROR, |
|
1031 "NW: ERROR: CNWNetworkViagCbEngine::STARTINDICATORHANDLINGL ! \ |
|
1032 UPDATEVIAGHZPARAMS RETURNED %d", error ); |
|
1033 ResetIndicatorValues(); |
|
1034 } |
|
1035 else |
|
1036 { |
|
1037 ClearHomeZoneCaches(); // Clear cache |
|
1038 TRAPD( err, StartIndicatorHandlingL( ETrue ) ) |
|
1039 if( err!= KErrNone ) |
|
1040 { |
|
1041 NWLOGSTRING2( KNWERROR, |
|
1042 "NW: ERROR: CNWNetworkViagCbEngine::STARTINDICATORHANDLINGL ! \ |
|
1043 StartIndicatorHandlingL returned %d", err ); |
|
1044 __ASSERT_DEBUG( EFalse, Panic( ENWPanicNotCompleted ) ); |
|
1045 } |
|
1046 NWLOGSTRING( KNWINT, |
|
1047 "NW: CNWNetworkViagCbEngine::SatRefreshCompleteNotification() ->" ); |
|
1048 } |
|
1049 NWLOGSTRING( KNWINT, |
|
1050 "NW: CNWNetworkViagCbEngine::SatRefreshCompleteNotification() End" ); |
|
1051 } |
|
1052 |
|
1053 |
|
1054 |
|
1055 // ---------------------------------------------------------------------------- |
|
1056 // CNWNetworkViagCbEngine::ClearHomeZoneCaches |
|
1057 // If homezone files are refreshed this method is called. |
|
1058 // ---------------------------------------------------------------------------- |
|
1059 // |
|
1060 void CNWNetworkViagCbEngine::ClearHomeZoneCaches() |
|
1061 { |
|
1062 NWLOGSTRING( KNWINT, |
|
1063 "NW: CNWNetworkViagCbEngine::ClearHomeZoneCaches() Begin " ); |
|
1064 iCacheHandler->Clear( EHZ_HomeZoneCache1 ); |
|
1065 iCacheHandler->Clear( EHZ_HomeZoneCache2 ); |
|
1066 iCacheHandler->Clear( EHZ_HomeZoneCache3 ); |
|
1067 iCacheHandler->Clear( EHZ_CityZoneCache ); |
|
1068 NWLOGSTRING( KNWINT, |
|
1069 "NW: CNWNetworkViagCbEngine::ClearHomeZoneCaches() End " ); |
|
1070 } |
|
1071 |
|
1072 // ---------------------------------------------------------------------------- |
|
1073 // CNWNetworkViagCbEngine::RemoveFromHomeZoneCaches |
|
1074 // |
|
1075 // ---------------------------------------------------------------------------- |
|
1076 // |
|
1077 TBool CNWNetworkViagCbEngine::RemoveFromHomeZoneCaches( |
|
1078 const RMmCustomAPI::TViagCacheRecordContent aCellInfo ) |
|
1079 { |
|
1080 NWLOGSTRING3( KNWINT, |
|
1081 "NW: CNWNetworkViagCbEngine::RemoveFromHomeZoneCaches() Begin, \ |
|
1082 aCellInfo.iLac = %d, aCellInfo.iCellId = %d ", |
|
1083 aCellInfo.iLac, aCellInfo.iCellId ); |
|
1084 |
|
1085 TInt index = iCacheHandler->Find( EHZ_HomeZoneCache1, aCellInfo ); |
|
1086 if( index != KErrNotFound ) |
|
1087 { |
|
1088 NWLOGSTRING2( KNWINT, |
|
1089 "NW: RemoveFromHomeZoneCaches(), The item found from cache [%d]\ |
|
1090 , remove it", EHZ_HomeZoneCache1 ); |
|
1091 if( iCacheHandler->Remove( EHZ_HomeZoneCache1, index ) ) |
|
1092 { |
|
1093 return EFalse; |
|
1094 } |
|
1095 } |
|
1096 index = iCacheHandler->Find( EHZ_HomeZoneCache2, aCellInfo ); |
|
1097 if( index != KErrNotFound ) |
|
1098 { |
|
1099 NWLOGSTRING2( KNWINT, |
|
1100 "NW: RemoveFromHomeZoneCaches(), The item found from cache [%d]\ |
|
1101 , remove it", |
|
1102 EHZ_HomeZoneCache2 ); |
|
1103 if( iCacheHandler->Remove( EHZ_HomeZoneCache2, index ) ) |
|
1104 { |
|
1105 return EFalse; |
|
1106 } |
|
1107 } |
|
1108 index = iCacheHandler->Find( EHZ_HomeZoneCache3, aCellInfo ); |
|
1109 if( index != KErrNotFound ) |
|
1110 { |
|
1111 NWLOGSTRING2( KNWINT, |
|
1112 "NW: RemoveFromHomeZoneCaches(), The item found from cache [%d]\ |
|
1113 , remove it", |
|
1114 EHZ_HomeZoneCache3 ); |
|
1115 if( iCacheHandler->Remove( EHZ_HomeZoneCache3, index ) ) |
|
1116 { |
|
1117 return EFalse; |
|
1118 } |
|
1119 } |
|
1120 |
|
1121 index = iCacheHandler->Find( EHZ_CityZoneCache, aCellInfo ); |
|
1122 if( index != KErrNotFound ) |
|
1123 { |
|
1124 NWLOGSTRING2( KNWINT, |
|
1125 "NW: RemoveFromHomeZoneCaches(), The item found from cache [%d]\ |
|
1126 , remove it", |
|
1127 EHZ_CityZoneCache ); |
|
1128 if( iCacheHandler->Remove( EHZ_CityZoneCache, index ) ) |
|
1129 { |
|
1130 return EFalse; |
|
1131 } |
|
1132 } |
|
1133 |
|
1134 NWLOGSTRING( KNWINT, |
|
1135 "NW: CNWNetworkViagCbEngine::RemoveFromHomeZoneCaches() End " ); |
|
1136 |
|
1137 return ETrue; |
|
1138 } |
|
1139 |
|
1140 // ---------------------------------------------------------------------------- |
|
1141 // CNWNetworkViagCbEngine::InitilizeCaches |
|
1142 // Starts cb cache initialization |
|
1143 // ---------------------------------------------------------------------------- |
|
1144 // |
|
1145 void CNWNetworkViagCbEngine::InitilizeCaches() |
|
1146 { |
|
1147 NWLOGSTRING( KNWINT, |
|
1148 "NW: CNWNetworkViagCbEngine::InitilizeCaches() Begin " ); |
|
1149 |
|
1150 iCacheHandler->InitialiseHomeZoneCachesAsync( this ); |
|
1151 |
|
1152 NWLOGSTRING( KNWINT, |
|
1153 "NW: CNWNetworkViagCbEngine::InitilizeCaches() End " ); |
|
1154 } |
|
1155 |
|
1156 // ---------------------------------------------------------------------------- |
|
1157 // CNWNetworkViagCbEngine::NotifyCachesInitialised |
|
1158 // Gets called when Cb cache reading is complete. |
|
1159 // ---------------------------------------------------------------------------- |
|
1160 // |
|
1161 void CNWNetworkViagCbEngine::NotifyCachesInitialised() |
|
1162 { |
|
1163 NWLOGSTRING( KNWINT, |
|
1164 "NW: CNWNetworkViagCbEngine::NotifyCachesInitialised() Begin " ); |
|
1165 |
|
1166 iBase.CellReselection(); |
|
1167 |
|
1168 NWLOGSTRING( KNWINT, |
|
1169 "NW: CNWNetworkViagCbEngine::NotifyCachesInitialised() End " ); |
|
1170 } |
|
1171 |
|
1172 // End of File |