|
1 /* |
|
2 * Copyright (c) 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 source file for the CAdtUpdaterContainer class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <AknsBasicBackgroundControlContext.h> |
|
20 #include <AknsSkinInstance.h> |
|
21 #include <AknsUtils.h> |
|
22 #include <AknsDrawUtils.h> |
|
23 #include <AknGlobalNote.h> |
|
24 #include <StringLoader.h> |
|
25 #include <adtupdater.rsg> |
|
26 #include <avkon.rsg> |
|
27 #include <tzlocalizer.h> |
|
28 #include <aknmessagequerydialog.h> |
|
29 #include <tz.h> |
|
30 #include <AknGlobalMsgQuery.h> |
|
31 #include <badesca.h> |
|
32 #include <aknlists.h> |
|
33 #include <centralrepository.h> |
|
34 #include <starterdomaincrkeys.h> |
|
35 #include <startupdomainpskeys.h> |
|
36 #include <startupdomaincrkeys.h> |
|
37 #include <starterclient.h> |
|
38 |
|
39 // User includes |
|
40 #include "adtupdatercontainer.h" |
|
41 #include "adtupdaterappui.h" |
|
42 #include "adtupdaterlistener.h" |
|
43 #include "adtupdaterpopuplist.h" |
|
44 #include "adtupdaterquerydialog.h" |
|
45 #include "clocktimezoneresolver.h" |
|
46 #include "clock_debug.h" |
|
47 #include <uikon/eiksrvui.h> |
|
48 |
|
49 // Constants |
|
50 const TInt KNitzPlugin( 0x200159A5 ); |
|
51 const TInt KTimeout( 40000000 ); // 40 seconds |
|
52 const TInt KInterval( 5000000 ); // 5 seconds |
|
53 const TInt KMaximumTwoDigitValue( 99 ); |
|
54 const TInt KNitzYearOffset( 2000 ); |
|
55 const TInt KMaxCityLength( 120 ); |
|
56 const TInt KMaxCountryLength( 120 ); |
|
57 const TInt KSingleCity( 1 ); |
|
58 const TInt KZero( 0 ); |
|
59 const TInt KFirstBootDone( 1 ); |
|
60 const TInt KTimeFormatLength( 16 ); // "20070000:090000." |
|
61 const TInt KMaxMobileCountryCode( 4 ); |
|
62 |
|
63 |
|
64 // Literals |
|
65 _LIT( KOneSpace, " " ); |
|
66 _LIT( KMobileCountryCode, "%d" ); |
|
67 _LIT( KDefaultDateTimeValue, "20070000:090000." ); // YYYYMMDD:HHMMSS. |
|
68 _LIT( KDefault, "default" ); |
|
69 |
|
70 // --------------------------------------------------------- |
|
71 // CAdtUpdaterContainer::NewL |
|
72 // rest of the details are commented in the header |
|
73 // --------------------------------------------------------- |
|
74 // |
|
75 CAdtUpdaterContainer* CAdtUpdaterContainer::NewL( const TRect& aRect ) |
|
76 { |
|
77 __PRINTS( "CAdtUpdaterContainer::NewL - Entry" ); |
|
78 |
|
79 CAdtUpdaterContainer* self = new ( ELeave ) CAdtUpdaterContainer; |
|
80 CleanupStack::PushL( self ); |
|
81 |
|
82 self->ConstructL( aRect ); |
|
83 |
|
84 CleanupStack::Pop( self ); |
|
85 |
|
86 __PRINTS( "CAdtUpdaterContainer::NewL - Exit" ); |
|
87 |
|
88 return self; |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------- |
|
92 // CAdtUpdaterContainer::~CAdtUpdaterContainer |
|
93 // rest of the details are commented in the header |
|
94 // --------------------------------------------------------- |
|
95 // |
|
96 CAdtUpdaterContainer::~CAdtUpdaterContainer() |
|
97 { |
|
98 __PRINTS( "CAdtUpdaterContainer::~CAdtUpdaterContainer - Entry" ); |
|
99 |
|
100 if( iBgContext ) |
|
101 { |
|
102 delete iBgContext; |
|
103 iBgContext = NULL; |
|
104 } |
|
105 if( iPeriodic ) |
|
106 { |
|
107 delete iPeriodic; |
|
108 iPeriodic = NULL; |
|
109 } |
|
110 if( iListener ) |
|
111 { |
|
112 delete iListener; |
|
113 iListener = NULL; |
|
114 } |
|
115 if( iGMTString ) |
|
116 { |
|
117 delete iGMTString; |
|
118 iGMTString = NULL; |
|
119 } |
|
120 if( iGMTText ) |
|
121 { |
|
122 delete iGMTText; |
|
123 iGMTText = NULL; |
|
124 } |
|
125 |
|
126 __PRINTS( "CAdtUpdaterContainer::~CAdtUpdaterContainer - Exit" ); |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // CAdtUpdaterContainer::CAdtUpdaterContainer |
|
131 // rest of the details are commented in the header |
|
132 // --------------------------------------------------------- |
|
133 // |
|
134 CAdtUpdaterContainer::CAdtUpdaterContainer() : iDataAvailability( EDataNone ), iQueryDialogsInDisplay( EFalse ) |
|
135 { |
|
136 __PRINTS( "CAdtUpdaterContainer::CAdtUpdaterContainer - Entry" ); |
|
137 |
|
138 //No Implementation yet |
|
139 |
|
140 __PRINTS( "CAdtUpdaterContainer::CAdtUpdaterContainer - Exit" ); |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------- |
|
144 // CAdtUpdaterContainer::ConstructL |
|
145 // rest of the details are commented in the header |
|
146 // --------------------------------------------------------- |
|
147 // |
|
148 void CAdtUpdaterContainer::ConstructL( const TRect& aRect ) |
|
149 { |
|
150 __PRINTS( "CAdtUpdaterContainer::ConstructL - Entry" ); |
|
151 |
|
152 CreateWindowL(); |
|
153 |
|
154 iAdtUpdaterAppUi = static_cast < CAdtUpdaterAppUi* > ( CCoeEnv::Static()->AppUi() ); |
|
155 |
|
156 SetRect( aRect ); |
|
157 |
|
158 // Construct the background control context. |
|
159 iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgScreen, |
|
160 aRect.Size(), |
|
161 EFalse ); |
|
162 |
|
163 // set the flag for showing startup queries |
|
164 iDisplayStartupQueries = DisplayStartupQueriesL(); |
|
165 |
|
166 |
|
167 ActivateL(); |
|
168 |
|
169 __PRINTS( "CAdtUpdaterContainer::ConstructL - Exit" ); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // CAdtUpdaterContainer::OfferKeyEventL |
|
174 // rest of the details are commented in the header |
|
175 // --------------------------------------------------------- |
|
176 // |
|
177 TKeyResponse CAdtUpdaterContainer::OfferKeyEventL( const TKeyEvent& /*aKeyEvent*/, |
|
178 TEventCode /*aType*/ ) |
|
179 { |
|
180 __PRINTS( "CAdtUpdaterContainer::OfferKeyEventL - Entry" ); |
|
181 |
|
182 TKeyResponse ret( EKeyWasConsumed ); |
|
183 |
|
184 __PRINTS( "CAdtUpdaterContainer::OfferKeyEventL - Exit" ); |
|
185 |
|
186 return ret; |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------- |
|
190 // CAdtUpdaterContainer::CountComponentControls |
|
191 // rest of the details are commented in the header |
|
192 // --------------------------------------------------------- |
|
193 // |
|
194 TInt CAdtUpdaterContainer::CountComponentControls() const |
|
195 { |
|
196 __PRINTS( "CAdtUpdaterContainer::CountComponentControls - Entry" ); |
|
197 |
|
198 __PRINTS( "CAdtUpdaterContainer::CountComponentControls - Exit" ); |
|
199 |
|
200 return 0; |
|
201 } |
|
202 |
|
203 // --------------------------------------------------------- |
|
204 // CAdtUpdaterContainer::ComponentControl |
|
205 // rest of the details are commented in the header |
|
206 // --------------------------------------------------------- |
|
207 // |
|
208 CCoeControl* CAdtUpdaterContainer::ComponentControl( TInt /*aIndex*/ ) const |
|
209 { |
|
210 __PRINTS( "CAdtUpdaterContainer::ComponentControl - Entry" ); |
|
211 |
|
212 __PRINTS( "CAdtUpdaterContainer::ComponentControl - Exit" ); |
|
213 |
|
214 return NULL; |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------- |
|
218 // CAdtUpdaterContainer::Draw |
|
219 // rest of the details are commented in the header |
|
220 // --------------------------------------------------------- |
|
221 // |
|
222 void CAdtUpdaterContainer::Draw( const TRect& aRect ) const |
|
223 { |
|
224 __PRINTS( "CAdtUpdaterContainer::Draw - Entry" ); |
|
225 |
|
226 CWindowGc& gc = SystemGc(); |
|
227 gc.Clear( aRect ); |
|
228 |
|
229 if( iBgContext ) |
|
230 { |
|
231 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
232 AknsDrawUtils::Background( skinInstance, iBgContext, this, gc, aRect ); |
|
233 } |
|
234 |
|
235 __PRINTS( "CAdtUpdaterContainer::Draw - Exit" ); |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------- |
|
239 // CAdtUpdaterContainer::SizeChanged |
|
240 // rest of the details are commented in the header |
|
241 // --------------------------------------------------------- |
|
242 // |
|
243 void CAdtUpdaterContainer::SizeChanged() |
|
244 { |
|
245 __PRINTS( "CAdtUpdaterContainer::SizeChanged - Entry" ); |
|
246 |
|
247 if( iBgContext ) |
|
248 { |
|
249 iBgContext->SetRect( Rect() ); |
|
250 } |
|
251 __PRINTS( "CAdtUpdaterContainer::SizeChanged - Exit" ); |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------- |
|
255 // CAdtUpdaterContainer::MopSupplyObject |
|
256 // rest of the details are commented in the header |
|
257 // --------------------------------------------------------- |
|
258 // |
|
259 TTypeUid::Ptr CAdtUpdaterContainer::MopSupplyObject( TTypeUid aId ) |
|
260 { |
|
261 __PRINTS( "CAdtUpdaterContainer::MopSupplyObject - Entry" ); |
|
262 |
|
263 if( MAknsControlContext::ETypeId == aId.iUid ) |
|
264 { |
|
265 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
266 } |
|
267 |
|
268 __PRINTS( "CAdtUpdaterContainer::MopSupplyObject - Exit" ); |
|
269 |
|
270 return CCoeControl::MopSupplyObject( aId ); |
|
271 } |
|
272 |
|
273 // --------------------------------------------------------- |
|
274 // CAdtUpdaterContainer::HandleResourceChange |
|
275 // rest of the details are commented in the header |
|
276 // --------------------------------------------------------- |
|
277 // |
|
278 void CAdtUpdaterContainer::HandleResourceChange( TInt aType ) |
|
279 { |
|
280 __PRINTS( "CAdtUpdaterContainer::HandleResourceChange - Entry" ); |
|
281 |
|
282 // Forward the control to CCoeControl. |
|
283 CCoeControl::HandleResourceChange( aType ); |
|
284 |
|
285 __PRINTS( "CAdtUpdaterContainer::HandleResourceChange - Exit" ); |
|
286 } |
|
287 |
|
288 // --------------------------------------------------------- |
|
289 // CAdtUpdaterContainer::InformAboutNwUpdateL |
|
290 // rest of the details are commented in the header |
|
291 // --------------------------------------------------------- |
|
292 // |
|
293 void CAdtUpdaterContainer::InformAboutNwUpdateL() |
|
294 { |
|
295 __PRINTS( "CAdtUpdaterContainer::InformAboutNwUpdate - Entry" ); |
|
296 |
|
297 if( IsFirstBoot() && IsSimPresent() && IsNitzPluginActive() ) |
|
298 { |
|
299 __PRINTS( "First boot, sim is present and auto time update is ON" ); |
|
300 |
|
301 // First bring the application to the foreground. |
|
302 iAdtUpdaterAppUi->ToggleAppViewL( EFalse ); |
|
303 // Hide in FSW. |
|
304 iAdtUpdaterAppUi->HideApplicationFromFSW( ETrue ); |
|
305 // Hide the status pane. |
|
306 iAdtUpdaterAppUi->HideStatusPane( ETrue ); |
|
307 |
|
308 // Listener object which listens for a Nitz packet |
|
309 iListener = CAdtUpdaterListener::NewL( this ); |
|
310 iListener->WaitForNitzInfoL(); |
|
311 |
|
312 // A 40 seconds call back timer. |
|
313 TCallBack timerCallBack( CallBackL, this ); |
|
314 iPeriodic = CPeriodic::NewL( EPriorityAbsoluteHigh ); |
|
315 // Start the timer |
|
316 iPeriodic->Start( KTimeout, KInterval, timerCallBack ); |
|
317 } |
|
318 else if( IsFirstBoot() ) |
|
319 { |
|
320 __PRINTS( "First boot, normal boot sequence" ); |
|
321 |
|
322 // The normal bootup sequence. |
|
323 ContinueWithNormalBootL(); |
|
324 |
|
325 __PRINTS( "CAdtUpdaterContainer::InformAboutNwUpdate : 2nd condition - Exit" ); |
|
326 |
|
327 // Exit the application. |
|
328 iAdtUpdaterAppUi->Exit(); |
|
329 } |
|
330 else if( !RTCStatus() && !HiddenReset() ) |
|
331 { |
|
332 __PRINTS( "RTC invalid or Hidden Reset" ); |
|
333 |
|
334 // Show in FSW. |
|
335 iAdtUpdaterAppUi->HideApplicationFromFSW( EFalse ); |
|
336 // Hide the status pane. |
|
337 iAdtUpdaterAppUi->HideStatusPane( ETrue ); |
|
338 |
|
339 // No first boot but RTCStatus is corrupted. Ask time and date" |
|
340 |
|
341 // Showing Date query to user. |
|
342 ShowDateQueryL(); |
|
343 |
|
344 // Showing Time query to user. |
|
345 ShowTimeQueryL(); |
|
346 |
|
347 //Deactivate the plug-in as we are setting the date/time manually |
|
348 DeActivateNitzPlugin(); |
|
349 |
|
350 __PRINTS( "CAdtUpdaterContainer::InformAboutNwUpdate : 3rd condition - Exit" ); |
|
351 |
|
352 // Exit the application. |
|
353 iAdtUpdaterAppUi->Exit(); |
|
354 } |
|
355 else |
|
356 { |
|
357 __PRINTS( "Not the first boot, simply exit" ); |
|
358 |
|
359 // No need ot execute further as it's not the first boot. Exit the application. |
|
360 User::Exit( KErrNone ); |
|
361 } |
|
362 |
|
363 __PRINTS( "CAdtUpdaterContainer::InformAboutNwUpdate - Exit" ); |
|
364 } |
|
365 |
|
366 // --------------------------------------------------------- |
|
367 // CAdtUpdaterContainer::InformAboutNwUpdate |
|
368 // rest of the details are commented in the header |
|
369 // --------------------------------------------------------- |
|
370 // |
|
371 TInt CAdtUpdaterContainer::CallBackL( TAny* aPtr ) |
|
372 { |
|
373 __PRINTS( "CAdtUpdaterContainer::CallBackL - Entry" ); |
|
374 |
|
375 CAdtUpdaterContainer* selfObject = static_cast< CAdtUpdaterContainer* >( aPtr ); |
|
376 CAdtUpdaterListener* listenerObject = selfObject->Listener(); |
|
377 |
|
378 // Callback after 40 seconds. If control reaches here, it means Nitz packet has |
|
379 // not yet arrived and we can continue with normal bootup sequence. |
|
380 |
|
381 // Buf before we do that, we can do a final check with the server, just to ensure |
|
382 // there weren't any missed notifications. |
|
383 TBool dataAvailable = listenerObject->ConfirmDataAvailabilityL(); |
|
384 |
|
385 if( dataAvailable ) |
|
386 { |
|
387 __PRINTS( "NITZ info is available" ); |
|
388 |
|
389 // Update the status to EDataAvailable |
|
390 selfObject->iDataAvailability = EDataAvailable; |
|
391 |
|
392 // We have data from server. |
|
393 listenerObject->NitzInfoAvailableL(); |
|
394 } |
|
395 else |
|
396 { |
|
397 __PRINTS( "NITZ info unavailable" ); |
|
398 |
|
399 // Update the status to EDataNotAvailable |
|
400 selfObject->iDataAvailability = EDataNotAvailable; |
|
401 |
|
402 // We don't have any data for sure. |
|
403 selfObject->NitzInfoNotAvailableL(); |
|
404 } |
|
405 |
|
406 __PRINTS( "CAdtUpdaterContainer::CallBackL - Exit" ); |
|
407 |
|
408 return KZero; |
|
409 } |
|
410 |
|
411 // --------------------------------------------------------- |
|
412 // CAdtUpdaterContainer::NitzInfoNotAvailableL |
|
413 // rest of the details are commented in the header |
|
414 // --------------------------------------------------------- |
|
415 // |
|
416 void CAdtUpdaterContainer::NitzInfoNotAvailableL() |
|
417 { |
|
418 __PRINTS( "CAdtUpdaterContainer::NitzInfoNotAvailableL - Entry" ); |
|
419 |
|
420 iTimeOut = ETrue; |
|
421 // First cancel all requests. |
|
422 CancelAllRequests(); |
|
423 |
|
424 // The normal bootup sequence. |
|
425 ContinueWithNormalBootL(); |
|
426 |
|
427 __PRINTS( "CAdtUpdaterContainer::NitzInfoNotAvailableL - Exit" ); |
|
428 |
|
429 // We're done. Exit the application. |
|
430 iAdtUpdaterAppUi->Exit(); |
|
431 } |
|
432 |
|
433 // --------------------------------------------------------- |
|
434 // CAdtUpdaterContainer::NitzInfoAvailableL |
|
435 // rest of the details are commented in the header |
|
436 // --------------------------------------------------------- |
|
437 // |
|
438 void CAdtUpdaterContainer::NitzInfoAvailableL( STimeAttributes aTimeAttributes, TInt aTimeZoneId ) |
|
439 { |
|
440 __PRINTS( "CAdtUpdaterContainer::NitzInfoAvailableL - Entry" ); |
|
441 |
|
442 __PRINTS( "!iTimeOut" ); |
|
443 |
|
444 // Check if the Nitz packet has arrived before timeout. |
|
445 // This is just a sanity check. Since this will function will be called by a different thread. |
|
446 if( !iTimeOut ) |
|
447 { |
|
448 __PRINT( "Received timezoneid: %d", aTimeZoneId ); |
|
449 |
|
450 // First store the values. |
|
451 iTimeAttributes = aTimeAttributes; |
|
452 iTimeZoneId = aTimeZoneId; |
|
453 |
|
454 // Cancel all requests and timers. |
|
455 CancelAllRequests(); |
|
456 |
|
457 // Display the Nitz info. |
|
458 DisplayNitzInfoL(); |
|
459 |
|
460 // We're done. Exit the application. |
|
461 iAdtUpdaterAppUi->Exit(); |
|
462 } |
|
463 |
|
464 __PRINTS( "CAdtUpdaterContainer::NitzInfoAvailableL - Exit" ); |
|
465 } |
|
466 |
|
467 // --------------------------------------------------------- |
|
468 // CAdtUpdaterContainer::CancelAllRequests |
|
469 // rest of the details are commented in the header |
|
470 // --------------------------------------------------------- |
|
471 // |
|
472 void CAdtUpdaterContainer::CancelAllRequests() |
|
473 { |
|
474 __PRINTS( "CAdtUpdaterContainer::CancelAllRequests - Entry" ); |
|
475 |
|
476 // Cancel the timer. |
|
477 if( iPeriodic ) |
|
478 { |
|
479 iPeriodic->Cancel(); |
|
480 } |
|
481 |
|
482 // Cancel the listener |
|
483 if( iListener ) |
|
484 { |
|
485 iListener->Cancel(); |
|
486 } |
|
487 |
|
488 __PRINTS( "CAdtUpdaterContainer::CancelAllRequests - Exit" ); |
|
489 } |
|
490 |
|
491 // --------------------------------------------------------- |
|
492 // CAdtUpdaterContainer::DisplayNitzInfoL |
|
493 // rest of the details are commented in the header |
|
494 // --------------------------------------------------------- |
|
495 // |
|
496 void CAdtUpdaterContainer::DisplayNitzInfoL() |
|
497 { |
|
498 __PRINTS( "CAdtUpdaterContainer::DisplayNitzInfoL - Entry" ); |
|
499 |
|
500 // Construct CTzLocalizer object to get the name of the zone. |
|
501 CTzLocalizer* tzLocalizer = CTzLocalizer::NewL(); |
|
502 CTzLocalizedCity* localizedCity( NULL ); |
|
503 CTzLocalizedTimeZone* localizedTimeZone( NULL ); |
|
504 |
|
505 TRAPD( errorVal, localizedTimeZone = tzLocalizer->GetLocalizedTimeZoneL( iTimeZoneId ) ); |
|
506 |
|
507 __PRINT( "Received timezoneid: %d errorVal: %d ", iTimeZoneId, errorVal ); |
|
508 |
|
509 if( KErrNone == errorVal ) |
|
510 { |
|
511 if( localizedTimeZone ) |
|
512 { |
|
513 __PRINTS( "CAdtUpdaterContainer::DisplayNitzInfoL - Localized TimeZone" ); |
|
514 |
|
515 // Match found!! Get the city corresponding to this timezone. |
|
516 localizedCity = tzLocalizer->GetDefaultCityL( localizedTimeZone->TimeZoneId() ); |
|
517 } |
|
518 } |
|
519 |
|
520 // If no matching city has been found, continue with normal bootup |
|
521 if( !localizedCity ) |
|
522 { |
|
523 __PRINTS( "CAdtUpdaterContainer::DisplayNitzInfoL - No Localized default city" ); |
|
524 |
|
525 NitzInfoNotAvailableL(); |
|
526 |
|
527 // Cleanup |
|
528 delete localizedTimeZone; |
|
529 delete tzLocalizer; |
|
530 |
|
531 __PRINTS( "CAdtUpdaterContainer::DisplayNitzInfoL - Exit: No Matching city found" ); |
|
532 |
|
533 return; |
|
534 } |
|
535 |
|
536 // We have the timezone. Get the date and time information. |
|
537 // Check if we have 2 digits instead of 4 digits for the year value. |
|
538 TInt fourDigitYear( iTimeAttributes.iUtcDateTime.Year() ); |
|
539 |
|
540 if( fourDigitYear <= KMaximumTwoDigitValue ) |
|
541 { |
|
542 // The year received from TSY is 2 digits we make it 4 digits |
|
543 fourDigitYear = fourDigitYear + KNitzYearOffset; // 2000 |
|
544 } |
|
545 |
|
546 TDateTime dateTime( fourDigitYear, |
|
547 TMonth( iTimeAttributes.iUtcDateTime.Month() ), |
|
548 iTimeAttributes.iUtcDateTime.Day(), |
|
549 iTimeAttributes.iUtcDateTime.Hour(), |
|
550 iTimeAttributes.iUtcDateTime.Minute(), |
|
551 iTimeAttributes.iUtcDateTime.Second(), |
|
552 iTimeAttributes.iUtcDateTime.MicroSecond() ); |
|
553 |
|
554 // Time sent by networks is the UTC time. |
|
555 TTime nwUtcTime( dateTime ); |
|
556 |
|
557 // Set the timezone and UTC time before displaying the info to the user. |
|
558 // First set the timezone. |
|
559 tzLocalizer->SetTimeZoneL( iTimeZoneId ); |
|
560 tzLocalizer->SetFrequentlyUsedZoneL( *localizedCity, CTzLocalizedTimeZone::ECurrentZone ); |
|
561 |
|
562 // Now set the UTC time. |
|
563 RTz tzHandle; |
|
564 User::LeaveIfError( tzHandle.Connect() ); |
|
565 User::LeaveIfError( User::SetUTCTime( nwUtcTime ) ); |
|
566 // Cleanup |
|
567 tzHandle.Close(); |
|
568 |
|
569 // Marking this boot as first boot. |
|
570 MarkFirstBoot(); |
|
571 |
|
572 delete localizedTimeZone; |
|
573 localizedTimeZone = NULL; |
|
574 |
|
575 delete localizedCity; |
|
576 localizedCity = NULL; |
|
577 |
|
578 delete tzLocalizer; |
|
579 tzLocalizer = NULL; |
|
580 |
|
581 __PRINTS( "CAdtUpdaterContainer::DisplayNitzInfoL - Exit" ); |
|
582 } |
|
583 |
|
584 // --------------------------------------------------------- |
|
585 // CAdtUpdaterContainer::ContinueWithNormalBootL |
|
586 // rest of the details are commented in the header |
|
587 // --------------------------------------------------------- |
|
588 // |
|
589 void CAdtUpdaterContainer::ContinueWithNormalBootL() |
|
590 { |
|
591 __PRINTS( "CAdtUpdaterContainer::ContinueWithNormalBootL - Entry" ); |
|
592 |
|
593 // First bring the application to the foreground. |
|
594 iAdtUpdaterAppUi->ToggleAppViewL( ETrue ); |
|
595 // Show in FSW. |
|
596 iAdtUpdaterAppUi->HideApplicationFromFSW( EFalse ); |
|
597 // Hide the status pane. |
|
598 iAdtUpdaterAppUi->HideStatusPane( ETrue ); |
|
599 |
|
600 //Deactivating Nitz |
|
601 DeActivateNitzPlugin(); |
|
602 |
|
603 TBool timeSaved; |
|
604 TBool dateSaved; |
|
605 |
|
606 iQueryDialogsInDisplay = ETrue; |
|
607 |
|
608 // First the country/city list. |
|
609 ShowCountryAndCityListsL(); |
|
610 // Then query date. |
|
611 timeSaved = ShowDateQueryL(); |
|
612 // Then query time. |
|
613 dateSaved = ShowTimeQueryL(); |
|
614 |
|
615 iQueryDialogsInDisplay = EFalse; |
|
616 |
|
617 // Modify the FirstBoot flag. |
|
618 if( timeSaved && dateSaved ) |
|
619 { |
|
620 MarkFirstBoot(); |
|
621 } |
|
622 |
|
623 __PRINTS( "CAdtUpdaterContainer::ContinueWithNormalBootL - Exit" ); |
|
624 } |
|
625 |
|
626 // --------------------------------------------------------- |
|
627 // CAdtUpdaterContainer::ShowCountryAndCityListsL |
|
628 // rest of the details are commented in the header |
|
629 // --------------------------------------------------------- |
|
630 // |
|
631 void CAdtUpdaterContainer::ShowCountryAndCityListsL() |
|
632 { |
|
633 __PRINTS( "CAdtUpdaterContainer::ShowCountryAndCityListsL - Entry" ); |
|
634 |
|
635 // Supress the application key |
|
636 STATIC_CAST( CEikServAppUi*, CCoeEnv::Static()->AppUi() )->SuppressAppSwitching( ETrue ); |
|
637 |
|
638 TInt citySelected( EFalse ); |
|
639 |
|
640 if( !iListener ) |
|
641 { |
|
642 iListener = CAdtUpdaterListener::NewL( this ); |
|
643 } |
|
644 |
|
645 // Get the current Mcc from listener. In case of a valid mcc show the city list directly. |
|
646 TInt currentMcc( iListener->GetCurrentMcc() ); |
|
647 |
|
648 if( currentMcc ) |
|
649 { |
|
650 CTzLocalizedCity* localizedCity( GetLocalizedCityL( currentMcc ) ); |
|
651 TInt cityGroupId = localizedCity->GroupId(); |
|
652 citySelected = ShowCityListL( cityGroupId ); |
|
653 delete localizedCity; |
|
654 } |
|
655 |
|
656 while( !citySelected ) |
|
657 { |
|
658 // First the country list. |
|
659 TInt cityGroupId = ShowCountryListL(); |
|
660 if( cityGroupId != KErrCancel ) |
|
661 { |
|
662 // Then if needed, i.e., if the country has many cities, then the city list. |
|
663 citySelected = ShowCityListL( cityGroupId ); |
|
664 } |
|
665 else |
|
666 { |
|
667 citySelected = ETrue; |
|
668 } |
|
669 } |
|
670 |
|
671 // Enable the application key |
|
672 STATIC_CAST( CEikServAppUi*, CCoeEnv::Static()->AppUi() )->SuppressAppSwitching( EFalse ); |
|
673 |
|
674 __PRINTS( "CAdtUpdaterContainer::ShowCountryAndCityListsL - Exit" ); |
|
675 } |
|
676 |
|
677 // --------------------------------------------------------- |
|
678 // CAdtUpdaterContainer::ShowCountryListL |
|
679 // rest of the details are commented in the header |
|
680 // --------------------------------------------------------- |
|
681 // |
|
682 TInt CAdtUpdaterContainer::ShowCountryListL() |
|
683 { |
|
684 __PRINTS( "CAdtUpdaterContainer::ShowCountryListL - Entry" ); |
|
685 |
|
686 // Listbox to display the country list. |
|
687 CAknSinglePopupMenuStyleListBox* countryListBox = new( ELeave ) CAknSinglePopupMenuStyleListBox; |
|
688 CleanupStack::PushL( countryListBox ); |
|
689 |
|
690 |
|
691 CAdtUpdaterPopupList* popupListBox = CAdtUpdaterPopupList::NewL( countryListBox, |
|
692 R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, |
|
693 AknPopupLayouts::EMenuGraphicHeadingWindow ); |
|
694 CleanupStack::PushL( popupListBox ); |
|
695 |
|
696 // Setup the properties of the popupListBox. |
|
697 countryListBox->ConstructL( popupListBox, EAknListBoxSelectionList | EAknListBoxScrollBarSizeExcluded ); |
|
698 countryListBox->CreateScrollBarFrameL( ETrue ); |
|
699 countryListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
700 CEikScrollBarFrame::EAuto ); |
|
701 |
|
702 // Array to hold the countries. |
|
703 CDesCArrayFlat *countryListItems = new( ELeave ) CDesCArrayFlat( 1 ); |
|
704 CleanupStack::PushL( countryListItems ); |
|
705 |
|
706 // We get the countries list from the CTzLocalizer. |
|
707 CTzLocalizer* tzLocalizer = CTzLocalizer::NewL(); |
|
708 CleanupStack::PushL( tzLocalizer ); |
|
709 |
|
710 CTzLocalizedCityGroupArray* countryList( NULL ); |
|
711 // Get the country list. |
|
712 countryList = tzLocalizer->GetAllCityGroupsL( CTzLocalizer::ETzAlphaNameAscending ); |
|
713 CleanupStack::PushL( countryList ); |
|
714 |
|
715 for( TInt itemIndex( KZero ); itemIndex < countryList->Count(); itemIndex++ ) |
|
716 { |
|
717 CTzLocalizedCityGroup& cityGroup = countryList->At( itemIndex ); |
|
718 |
|
719 // Check if the counrty name is blank. |
|
720 // If it is blank, ignore it. Empty name shouldn't be shown in the list. |
|
721 if( KZero != cityGroup.Name().Compare( KOneSpace ) ) |
|
722 { |
|
723 TBuf< KMaxCountryLength > countryItem; |
|
724 countryItem.Insert( KZero, cityGroup.Name() ); |
|
725 countryListItems->AppendL( countryItem ); |
|
726 } |
|
727 } |
|
728 // Set the item array to the listbox through listbox model. |
|
729 CTextListBoxModel* listBoxModel = countryListBox->Model(); |
|
730 listBoxModel->SetItemTextArray( countryListItems ); |
|
731 listBoxModel->SetOwnershipType( ELbmOwnsItemArray ); |
|
732 |
|
733 // Set the title text for the popup. |
|
734 HBufC* titleText = StringLoader::LoadLC( R_QTN_CLK_QTL_SELECT_COUNTRY ); |
|
735 popupListBox->SetTitleL( titleText->Des() ); |
|
736 CleanupStack::PopAndDestroy( titleText ); |
|
737 |
|
738 // Enable find for the listbox. |
|
739 popupListBox->EnableFind(); |
|
740 |
|
741 // Select the country which will be focused in the countryselection list |
|
742 TInt countryIndex( KZero ); |
|
743 |
|
744 if( EDataRejected == iDataAvailability ) |
|
745 { |
|
746 __PRINTS( "CAdtUpdaterContainer::ShowCountryListL : Data received from nitz has been rejected by user" ); |
|
747 |
|
748 CTzLocalizedCity* localizedCity = tzLocalizer->GetFrequentlyUsedZoneCityL( CTzLocalizedTimeZone::ECurrentZone ); |
|
749 CleanupStack::PushL( localizedCity ); |
|
750 |
|
751 countryIndex = IndexOfCountry( localizedCity->GroupId(), countryList ); |
|
752 |
|
753 CleanupStack::PopAndDestroy( localizedCity ); |
|
754 } |
|
755 else if( EDataNotAvailable == iDataAvailability ) |
|
756 { |
|
757 __PRINTS( "CAdtUpdaterContainer::ShowCountryListL : Data is not available" ); |
|
758 |
|
759 //Get the current Mcc from listener |
|
760 TInt currentMcc ( iListener->GetCurrentMcc()); |
|
761 |
|
762 if( currentMcc ) |
|
763 { |
|
764 CTzLocalizedCity* localizedCity( GetLocalizedCityL( currentMcc ) ); |
|
765 |
|
766 //Get the country index from country list |
|
767 if( localizedCity ) |
|
768 { |
|
769 countryIndex = IndexOfCountry( localizedCity->GroupId(), countryList ); |
|
770 } |
|
771 delete localizedCity; |
|
772 } |
|
773 |
|
774 } |
|
775 |
|
776 |
|
777 //Set the index of the time to be |
|
778 countryListBox->View()->SetCurrentItemIndex( countryIndex ); |
|
779 |
|
780 TInt cityGroupId( KErrCancel ); |
|
781 TInt selectedItem( 0 ); |
|
782 |
|
783 // check if the startup queries are enabled |
|
784 // show the country selection query only if enabled |
|
785 if ( iDisplayStartupQueries ) |
|
786 { |
|
787 if( popupListBox->ExecuteLD() ) |
|
788 { |
|
789 // Get the selected item index in the list. |
|
790 selectedItem = countryListBox->CurrentItemIndex(); |
|
791 } |
|
792 } |
|
793 // Get the text of the selected item. |
|
794 TPtrC selectedCountryName = countryListBox->Model()->ItemText( selectedItem ); |
|
795 |
|
796 // Get the group id of the selected country. |
|
797 CTzLocalizedCityGroup* tzLocalizedCityGroup = tzLocalizer->FindCityGroupByNameL( selectedCountryName ); |
|
798 CleanupStack::PushL( tzLocalizedCityGroup ); |
|
799 // Save the city group id. |
|
800 cityGroupId = tzLocalizedCityGroup->Id(); |
|
801 |
|
802 // Cleanup. |
|
803 CleanupStack::PopAndDestroy( tzLocalizedCityGroup ); |
|
804 |
|
805 // Cleanup |
|
806 CleanupStack::PopAndDestroy( countryList ); |
|
807 CleanupStack::PopAndDestroy( tzLocalizer ); |
|
808 CleanupStack::Pop( countryListItems ); |
|
809 if( iDisplayStartupQueries ) |
|
810 { |
|
811 CleanupStack::Pop( popupListBox ); |
|
812 } |
|
813 else |
|
814 { |
|
815 CleanupStack::PopAndDestroy( popupListBox ); |
|
816 } |
|
817 |
|
818 CleanupStack::PopAndDestroy( countryListBox ); |
|
819 |
|
820 __PRINTS( "CAdtUpdaterContainer::ShowCountryListL - Exit" ); |
|
821 |
|
822 // Return the cityGroupId. |
|
823 return cityGroupId; |
|
824 } |
|
825 |
|
826 // --------------------------------------------------------- |
|
827 // CAdtUpdaterContainer::ShowCityListL |
|
828 // rest of the details are commented in the header |
|
829 // --------------------------------------------------------- |
|
830 // |
|
831 TInt CAdtUpdaterContainer::ShowCityListL( TInt aGroupId ) |
|
832 { |
|
833 __PRINTS( "CAdtUpdaterContainer::ShowCityListL - Entry" ); |
|
834 |
|
835 TInt returnVal( ETrue ); |
|
836 TInt cityIndex( KErrNotFound ); |
|
837 // We get the city list from the group id from CTzLocalizer. |
|
838 // If the city list has only one city, no need to popup the list, |
|
839 // select the city directly. Else the list is popped. |
|
840 CTzLocalizer* tzLocalizer = CTzLocalizer::NewLC(); |
|
841 CTzLocalizedCityArray* cityList( NULL ); |
|
842 |
|
843 // Get the city list. |
|
844 cityList = tzLocalizer->GetCitiesInGroupL( aGroupId, |
|
845 CTzLocalizer::ETzAlphaNameAscending ); |
|
846 CleanupStack::PushL( cityList ); |
|
847 |
|
848 // We have only one city. |
|
849 if( KSingleCity == cityList->Count() ) |
|
850 { |
|
851 CTzLocalizedCity& localizedCity = cityList->At( KZero ); |
|
852 |
|
853 // Get the city name |
|
854 CTzLocalizedCity* tzLocalizedCity = tzLocalizer->FindCityByNameL( localizedCity.Name() ); |
|
855 CleanupStack::PushL( tzLocalizedCity ); |
|
856 |
|
857 // Get the timezone Id of the city. |
|
858 TInt timeZoneId = tzLocalizedCity->TimeZoneId(); |
|
859 |
|
860 // Set this id as the current zone. |
|
861 tzLocalizer->SetTimeZoneL( timeZoneId ); |
|
862 tzLocalizer->SetFrequentlyUsedZoneL( *tzLocalizedCity, CTzLocalizedTimeZone::ECurrentZone ); |
|
863 |
|
864 // Cleanup. |
|
865 CleanupStack::PopAndDestroy( tzLocalizedCity ); |
|
866 CleanupStack::PopAndDestroy( cityList ); |
|
867 CleanupStack::PopAndDestroy( tzLocalizer ); |
|
868 |
|
869 __PRINTS( "CAdtUpdaterContainer::ShowCityListL - Exit: In case of only one city" ); |
|
870 |
|
871 return returnVal; |
|
872 } |
|
873 |
|
874 // Listbox to display the city list. |
|
875 CAknSinglePopupMenuStyleListBox* cityListBox = new( ELeave ) CAknSinglePopupMenuStyleListBox; |
|
876 CleanupStack::PushL( cityListBox ); |
|
877 |
|
878 CAdtUpdaterPopupList* popupListBox = CAdtUpdaterPopupList::NewL( cityListBox, |
|
879 R_AVKON_SOFTKEYS_SELECT_BACK__SELECT, |
|
880 AknPopupLayouts::EMenuGraphicHeadingWindow ); |
|
881 CleanupStack::PushL( popupListBox ); |
|
882 |
|
883 // Setup the properties of the popupListBox. |
|
884 cityListBox->ConstructL( popupListBox, EAknListBoxSelectionList | EAknListBoxScrollBarSizeExcluded ); |
|
885 cityListBox->CreateScrollBarFrameL( ETrue ); |
|
886 cityListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
887 CEikScrollBarFrame::EAuto ); |
|
888 |
|
889 // Array to hold the cities. |
|
890 CDesCArrayFlat *cityListItems = new( ELeave ) CDesCArrayFlat( 1 ); |
|
891 CleanupStack::PushL( cityListItems ); |
|
892 |
|
893 for( TInt cityItem( 0 ); cityItem < cityList->Count(); cityItem++ ) |
|
894 { |
|
895 CTzLocalizedCity& localizedCity = cityList->At( cityItem ); |
|
896 |
|
897 // Check if the city name is blank. |
|
898 // If it is blank, ignore it. Empty name shouldn't be shown in the list. |
|
899 if( 0 != localizedCity.Name().Compare( KOneSpace ) ) |
|
900 { |
|
901 TBuf< KMaxCityLength > cityListItem; |
|
902 cityListItem.Insert( 0, localizedCity.Name() ); |
|
903 cityListItems->AppendL( cityListItem ); |
|
904 |
|
905 if( KErrNotFound == cityIndex ) |
|
906 { |
|
907 CTzLocalizedTimeZone* localizedTimeZone( NULL ); |
|
908 localizedTimeZone = tzLocalizer->GetLocalizedTimeZoneL( localizedCity.TimeZoneId() ); |
|
909 |
|
910 // Check whether it is the default city and set cityIndex. |
|
911 if( KZero == localizedTimeZone->StandardName().Compare( KDefault ) ) |
|
912 { |
|
913 cityIndex = cityItem; |
|
914 } |
|
915 delete localizedTimeZone; |
|
916 } |
|
917 } |
|
918 } |
|
919 |
|
920 // Set the item array to the listbox through listbox model. |
|
921 CTextListBoxModel* listBoxModel = cityListBox->Model(); |
|
922 listBoxModel->SetItemTextArray( cityListItems ); |
|
923 listBoxModel->SetOwnershipType( ELbmOwnsItemArray ); |
|
924 |
|
925 // Set the title text for the popup. |
|
926 HBufC* titleText = StringLoader::LoadLC( R_QTN_CLK_QTL_SELECT_CITY ); |
|
927 popupListBox->SetTitleL( titleText->Des() ); |
|
928 CleanupStack::PopAndDestroy( titleText ); |
|
929 |
|
930 // Enable find in the listbox. |
|
931 popupListBox->EnableFind(); |
|
932 |
|
933 // Focus the default city as the current item index. |
|
934 // In case default city is not found set the first listitem as the current focus. |
|
935 if( KErrNotFound == cityIndex ) |
|
936 { |
|
937 cityIndex = KZero; |
|
938 } |
|
939 cityListBox->SetCurrentItemIndex( cityIndex ); |
|
940 |
|
941 TInt selectedItemIndex( 0 ); |
|
942 |
|
943 // check if the startup queries are enabled |
|
944 // show the city selection query only if enabled |
|
945 if ( iDisplayStartupQueries ) |
|
946 { |
|
947 // Execute the dialog. |
|
948 if( popupListBox->ExecuteLD() ) |
|
949 { |
|
950 selectedItemIndex = cityListBox->CurrentItemIndex(); |
|
951 } |
|
952 else |
|
953 { |
|
954 returnVal = EFalse; |
|
955 } |
|
956 } |
|
957 |
|
958 TPtrC cityName = cityListBox->Model()->ItemText( selectedItemIndex ); |
|
959 |
|
960 // Find the timezone id by the name. |
|
961 CTzLocalizedCity* tzLocalizedCity = tzLocalizer->FindCityByNameL( cityName ); |
|
962 CleanupStack::PushL( tzLocalizedCity ); |
|
963 |
|
964 TInt timeZoneId = tzLocalizedCity->TimeZoneId(); |
|
965 |
|
966 // Set the found timezone id as teh current zone. |
|
967 tzLocalizer->SetTimeZoneL( timeZoneId ); |
|
968 tzLocalizer->SetFrequentlyUsedZoneL( *tzLocalizedCity, |
|
969 CTzLocalizedTimeZone::ECurrentZone ); |
|
970 |
|
971 // Cleanup. |
|
972 CleanupStack::PopAndDestroy( tzLocalizedCity ); |
|
973 // Cleanup. |
|
974 CleanupStack::Pop( cityListItems ); |
|
975 |
|
976 if( iDisplayStartupQueries ) |
|
977 { |
|
978 CleanupStack::Pop( popupListBox ); |
|
979 } |
|
980 else |
|
981 { |
|
982 CleanupStack::PopAndDestroy( popupListBox ); |
|
983 } |
|
984 CleanupStack::PopAndDestroy( cityListBox ); |
|
985 CleanupStack::PopAndDestroy( cityList ); |
|
986 CleanupStack::PopAndDestroy( tzLocalizer ); |
|
987 |
|
988 __PRINTS( "CAdtUpdaterContainer::ShowCityListL - Exit" ); |
|
989 |
|
990 // Return. |
|
991 return returnVal; |
|
992 } |
|
993 |
|
994 // --------------------------------------------------------- |
|
995 // CAdtUpdaterContainer::ShowDateQueryL |
|
996 // rest of the details are commented in the header |
|
997 // --------------------------------------------------------- |
|
998 // |
|
999 TBool CAdtUpdaterContainer::ShowDateQueryL() |
|
1000 { |
|
1001 __PRINTS( "CAdtUpdaterContainer::ShowDateQueryL - Entry" ); |
|
1002 |
|
1003 //Supress the application key |
|
1004 STATIC_CAST( CEikServAppUi*, CCoeEnv::Static()->AppUi() )->SuppressAppSwitching( ETrue ); |
|
1005 |
|
1006 TTime displayTime; |
|
1007 if( EDataRejected == iDataAvailability ) |
|
1008 { |
|
1009 //Get the home time as it is updated by data received by NITZ |
|
1010 displayTime.HomeTime(); |
|
1011 } |
|
1012 else |
|
1013 { |
|
1014 //Get the default value from cenrep |
|
1015 GetDefaultTimeAndDate( displayTime ); |
|
1016 } |
|
1017 |
|
1018 // check if the startup queries are enabled |
|
1019 // show the date query only if enabled |
|
1020 if ( iDisplayStartupQueries ) |
|
1021 { |
|
1022 // The Date query dialog. |
|
1023 CAdtUpdaterQueryDialog* dateQueryDialog = new ( ELeave ) CAdtUpdaterQueryDialog( displayTime ); |
|
1024 |
|
1025 if( dateQueryDialog->ExecuteLD( R_CLK_DATE_SETTING_QUERY_DIALOG ) ) |
|
1026 { |
|
1027 TTime homeTime; |
|
1028 homeTime.HomeTime(); |
|
1029 TDateTime homeDateTime = homeTime.DateTime(); |
|
1030 TDateTime newDateTime = displayTime.DateTime(); |
|
1031 newDateTime.SetHour( homeDateTime.Hour() ); |
|
1032 newDateTime.SetMinute( homeDateTime.Minute() ); |
|
1033 newDateTime.SetSecond( homeDateTime.Second() ); |
|
1034 newDateTime.SetMicroSecond( homeDateTime.MicroSecond() ); |
|
1035 displayTime = newDateTime; |
|
1036 |
|
1037 // Set the date entered by the user as the hometime. |
|
1038 RTz tzHandle; |
|
1039 User::LeaveIfError( tzHandle.Connect() ); |
|
1040 User::LeaveIfError( tzHandle.SetHomeTime( displayTime ) ); |
|
1041 tzHandle.Close(); |
|
1042 |
|
1043 __PRINTS( "CAdtUpdaterContainer::ShowDateQueryL - Exit: User has entered a date and pressed OK." ); |
|
1044 |
|
1045 return ETrue; |
|
1046 } |
|
1047 else |
|
1048 { |
|
1049 __PRINTS( "CAdtUpdaterContainer::ShowDateQueryL - Exit: User had pressed Cancel." ); |
|
1050 |
|
1051 // In case of poweroff key was pressed and shutdown is occuring. |
|
1052 return EFalse; |
|
1053 } |
|
1054 } |
|
1055 else |
|
1056 { |
|
1057 // return true, if queries has to be disabled for NTM |
|
1058 return ETrue; |
|
1059 } |
|
1060 } |
|
1061 |
|
1062 // --------------------------------------------------------- |
|
1063 // CAdtUpdaterContainer::ShowTimeQueryL |
|
1064 // rest of the details are commented in the header |
|
1065 // --------------------------------------------------------- |
|
1066 // |
|
1067 TBool CAdtUpdaterContainer::ShowTimeQueryL() |
|
1068 { |
|
1069 __PRINTS( "CAdtUpdaterContainer::ShowTimeQueryL - Entry" ); |
|
1070 |
|
1071 TTime displayTime; |
|
1072 if( EDataRejected == iDataAvailability ) |
|
1073 { |
|
1074 //Get the home time as it is updated by data received by NITZ |
|
1075 displayTime.HomeTime(); |
|
1076 } |
|
1077 else |
|
1078 { |
|
1079 //Get the default value from cenrep |
|
1080 GetDefaultTimeAndDate( displayTime ); |
|
1081 } |
|
1082 |
|
1083 // check if the startup queries are enabled |
|
1084 // show the time query only if enabled |
|
1085 if( iDisplayStartupQueries ) |
|
1086 { |
|
1087 // The Date query dialog. |
|
1088 CAdtUpdaterQueryDialog* timeQueryDialog = new ( ELeave ) CAdtUpdaterQueryDialog( displayTime ); |
|
1089 |
|
1090 if( timeQueryDialog->ExecuteLD( R_CLK_TIME_SETTING_QUERY_DIALOG ) ) |
|
1091 { |
|
1092 TTime homeTime; |
|
1093 homeTime.HomeTime(); |
|
1094 TDateTime homeDateTime = homeTime.DateTime(); |
|
1095 TDateTime newDateTime = displayTime.DateTime(); |
|
1096 newDateTime.SetYear( homeDateTime.Year() ); |
|
1097 newDateTime.SetMonth( homeDateTime.Month() ); |
|
1098 newDateTime.SetDay( homeDateTime.Day() ); |
|
1099 displayTime = newDateTime; |
|
1100 |
|
1101 // Set the date entered by the user as the hometime. |
|
1102 RTz tzHandle; |
|
1103 User::LeaveIfError( tzHandle.Connect() ); |
|
1104 User::LeaveIfError( tzHandle.SetHomeTime( displayTime ) ); |
|
1105 tzHandle.Close(); |
|
1106 |
|
1107 __PRINTS( "CAdtUpdaterContainer::ShowTimeQueryL - Exit: User has entered a time and pressed OK." ); |
|
1108 |
|
1109 //Enable the application key |
|
1110 STATIC_CAST( CEikServAppUi*, CCoeEnv::Static()->AppUi() )->SuppressAppSwitching( EFalse ); |
|
1111 |
|
1112 return ETrue; |
|
1113 } |
|
1114 else |
|
1115 { |
|
1116 __PRINTS( "CAdtUpdaterContainer::ShowTimeQueryL - Exit: User has pressed Cancel." ); |
|
1117 |
|
1118 // In case of poweroff key was pressed and shutdown is occuring. |
|
1119 return EFalse; |
|
1120 } |
|
1121 } |
|
1122 else |
|
1123 { |
|
1124 // return true, if queries has to be disabled for NTM |
|
1125 return ETrue; |
|
1126 } |
|
1127 |
|
1128 } |
|
1129 |
|
1130 // --------------------------------------------------------------------------- |
|
1131 // CAdtUpdaterContainer::GetDefaultTimeAndDate |
|
1132 // rest of the details are commented in headers |
|
1133 // --------------------------------------------------------------------------- |
|
1134 void CAdtUpdaterContainer::GetDefaultTimeAndDate( TTime& aTime ) |
|
1135 { |
|
1136 __PRINTS( "CAdtUpdaterContainer::GetDefaultTimeAndDate(): Entry" ); |
|
1137 |
|
1138 CRepository* repository( NULL ); |
|
1139 aTime.Set( KDefaultDateTimeValue ); |
|
1140 |
|
1141 TRAPD( errVal, repository = CRepository::NewL( KCRUidStartupConf ) ); |
|
1142 |
|
1143 // Get the KStartupDefaultTime key value from cenrep |
|
1144 if ( KErrNone == errVal ) |
|
1145 { |
|
1146 TBuf< KTimeFormatLength > defaultTime; |
|
1147 errVal = repository->Get( KStartupDefaultTime, defaultTime ); |
|
1148 if( KErrNone == errVal ) |
|
1149 { |
|
1150 // returns error if cenrep time format not valid |
|
1151 errVal = aTime.Set( defaultTime ); |
|
1152 } |
|
1153 } |
|
1154 delete repository; |
|
1155 |
|
1156 __PRINTS( "CStartupAppUi::GetDefaultTimeAndDate(): Exit" ); |
|
1157 } |
|
1158 |
|
1159 // --------------------------------------------------------------------------- |
|
1160 // CAdtUpdaterContainer::GetLocalizedCityL |
|
1161 // rest of the details are commented in headers |
|
1162 // --------------------------------------------------------------------------- |
|
1163 CTzLocalizedCity* CAdtUpdaterContainer::GetLocalizedCityL( TInt& aMcc ) |
|
1164 { |
|
1165 __PRINTS( "CAdtUpdaterContainer::GetLocalizedCityL : Entry" ); |
|
1166 |
|
1167 // The tzResolver object to get the timezone id. |
|
1168 CClockTimeZoneResolver* tzResolver = CClockTimeZoneResolver::NewL(); |
|
1169 |
|
1170 // Get the string from of mcc. |
|
1171 TBuf< KMaxMobileCountryCode > mobileCountryCodeBuf; |
|
1172 mobileCountryCodeBuf.Format( KMobileCountryCode, aMcc ); |
|
1173 |
|
1174 // Resolve the data to get the timezone id. |
|
1175 RArray< CTzId > aTzIdArray; |
|
1176 tzResolver->TzIdFromMccL( mobileCountryCodeBuf, aTzIdArray ); |
|
1177 |
|
1178 // Construct CTzLocalizer object to get the name of the zone. |
|
1179 CTzLocalizer* tzLocalizer = CTzLocalizer::NewL(); |
|
1180 CleanupStack::PushL( tzLocalizer ); |
|
1181 |
|
1182 CTzLocalizedCity* localizedCity( NULL ); |
|
1183 CTzLocalizedTimeZone* localizedTimeZone( NULL ); |
|
1184 |
|
1185 TInt anyTimeZoneId = aTzIdArray[ KZero ].TimeZoneNumericID(); |
|
1186 |
|
1187 if( anyTimeZoneId ) |
|
1188 { |
|
1189 __PRINTS( "CAdtUpdaterContainer::GetLocalizedCityL : we have valid timezoneids for the received mcc" ); |
|
1190 |
|
1191 TRAPD( errorVal, localizedTimeZone = tzLocalizer->GetLocalizedTimeZoneL( anyTimeZoneId ) ); |
|
1192 CleanupStack::PushL( localizedTimeZone ); |
|
1193 |
|
1194 if( KErrNone == errorVal ) |
|
1195 { |
|
1196 if( localizedTimeZone ) |
|
1197 { |
|
1198 __PRINTS( "CAdtUpdaterContainer::GetLocalizedCityL - Localized TimeZone" ); |
|
1199 |
|
1200 // Match found!! Get the city corresponding to this timezone. |
|
1201 localizedCity = tzLocalizer->GetDefaultCityL( localizedTimeZone->TimeZoneId() ); |
|
1202 } |
|
1203 } |
|
1204 |
|
1205 CleanupStack::PopAndDestroy( localizedTimeZone ); |
|
1206 CleanupStack::PopAndDestroy( tzLocalizer ); |
|
1207 } |
|
1208 aTzIdArray.Close(); |
|
1209 delete tzResolver; |
|
1210 |
|
1211 __PRINTS( "CAdtUpdaterContainer::GetLocalizedCityL : Exit" ); |
|
1212 |
|
1213 return localizedCity; |
|
1214 } |
|
1215 |
|
1216 // ----------------------------------------------------- |
|
1217 // CAdtUpdaterContainer::IndexOfCountry |
|
1218 // rest of the details are commented in the header |
|
1219 // ----------------------------------------------------- |
|
1220 // |
|
1221 TInt CAdtUpdaterContainer::IndexOfCountry( TInt aGroupId, CTzLocalizedCityGroupArray* aCountryList ) |
|
1222 { |
|
1223 __PRINTS( "CAdtUpdaterContainer::IndexOfCountry - Entry" ); |
|
1224 |
|
1225 TInt countrylistCount = aCountryList->Count(); |
|
1226 |
|
1227 for( TInt countryIndex = KZero; countryIndex < countrylistCount; countryIndex++ ) |
|
1228 { |
|
1229 if( aGroupId == aCountryList->At( countryIndex ).Id() ) |
|
1230 { |
|
1231 __PRINTS( "CAdtUpdaterContainer::IndexOfCountry : match found - Exit" ); |
|
1232 |
|
1233 return countryIndex; |
|
1234 } |
|
1235 } |
|
1236 |
|
1237 __PRINTS( "CAdtUpdaterContainer::IndexOfCountry - Exit" ); |
|
1238 |
|
1239 return KZero; |
|
1240 } |
|
1241 |
|
1242 // ----------------------------------------------------- |
|
1243 // CAdtUpdaterContainer::IsDstOnL |
|
1244 // rest of the details are commented in the header |
|
1245 // ----------------------------------------------------- |
|
1246 // |
|
1247 TBool CAdtUpdaterContainer::IsDstOnL( TInt aTimeZoneId ) |
|
1248 { |
|
1249 TBool retVal( EFalse ); |
|
1250 CTzId* tzId = CTzId::NewL( aTimeZoneId ); |
|
1251 CleanupStack::PushL( tzId ); |
|
1252 |
|
1253 RTz tz; |
|
1254 User::LeaveIfError( tz.Connect() ); |
|
1255 CleanupClosePushL( tz ); |
|
1256 |
|
1257 retVal = tz.IsDaylightSavingOnL( *tzId ); |
|
1258 |
|
1259 tz.Close(); |
|
1260 CleanupStack::PopAndDestroy( &tz ); |
|
1261 CleanupStack::PopAndDestroy( tzId ); |
|
1262 |
|
1263 return retVal; |
|
1264 } |
|
1265 |
|
1266 // ----------------------------------------------------- |
|
1267 // CAdtUpdaterContainer::IsFirstBoot |
|
1268 // rest of the details are commented in the header |
|
1269 // ----------------------------------------------------- |
|
1270 // |
|
1271 TBool CAdtUpdaterContainer::IsFirstBoot() |
|
1272 { |
|
1273 __PRINTS( "CAdtUpdaterContainer::FirstBoot - Entry" ); |
|
1274 |
|
1275 TInt firstBoot( NULL ); |
|
1276 |
|
1277 CRepository* repository(NULL); |
|
1278 |
|
1279 TRAPD( errVal, repository = CRepository::NewL( KCRUidStartup ) ); |
|
1280 |
|
1281 // Get the KStartupFirstBoot key value from cenrep |
|
1282 if ( KErrNone == errVal ) |
|
1283 { |
|
1284 errVal = repository->Get( KStartupFirstBoot, firstBoot ); |
|
1285 } |
|
1286 |
|
1287 __PRINT( "CAdtUpdaterContainer::IsFirstBoot : firstboot value : %d", firstBoot ); |
|
1288 |
|
1289 delete repository; |
|
1290 |
|
1291 __PRINTS( "CAdtUpdaterContainer::FirstBoot - Exit" ); |
|
1292 |
|
1293 return !( (TBool) firstBoot ); |
|
1294 } |
|
1295 |
|
1296 // ----------------------------------------------------- |
|
1297 // CAdtUpdaterContainer::IsSimPresent |
|
1298 // rest of the details are commented in the header |
|
1299 // ----------------------------------------------------- |
|
1300 // |
|
1301 TBool CAdtUpdaterContainer::IsSimPresent() |
|
1302 { |
|
1303 __PRINTS( "CAdtUpdaterContainer::IsSimPresent - Entry" ); |
|
1304 |
|
1305 //Property has been defined by startup app |
|
1306 //Retrieving the property value ,the property has been defined by startup application |
|
1307 TInt simStatus; |
|
1308 RProperty::Get( KPSUidStartup, KPSSimStatus, simStatus ); |
|
1309 |
|
1310 __PRINT( "CAdtUpdaterContainer::IsSimPresent :Sim status in phone : %d", simStatus ); |
|
1311 |
|
1312 if ( simStatus == ESimNotPresent ) |
|
1313 { |
|
1314 __PRINTS( "CAdtUpdaterContainer::IsSimPresent:Sim is not present - Exit" ); |
|
1315 |
|
1316 return EFalse; |
|
1317 } |
|
1318 else |
|
1319 { |
|
1320 __PRINTS( "CAdtUpdaterContainer::IsSimPresent:Sim is present - Exit" ); |
|
1321 |
|
1322 return ETrue; |
|
1323 } |
|
1324 } |
|
1325 |
|
1326 // ----------------------------------------------------- |
|
1327 // CAdtUpdaterContainer::IsNitzPluginActive |
|
1328 // rest of the details are commented in the header |
|
1329 // ----------------------------------------------------- |
|
1330 // |
|
1331 TBool CAdtUpdaterContainer::IsNitzPluginActive() |
|
1332 { |
|
1333 __PRINTS( "CAdtUpdaterListener::IsPluginActive : Entry" ); |
|
1334 |
|
1335 TBool pluginActive( EFalse ); |
|
1336 RClkSrvInterface clkSrvIf; |
|
1337 |
|
1338 // Connect to clockserver |
|
1339 TInt errorVal( clkSrvIf.Connect() ); |
|
1340 |
|
1341 // If the connection doesn't get established |
|
1342 if( KErrNone != errorVal ) |
|
1343 { |
|
1344 __PRINTS( "CAdtUpdaterListener::IsPluginActive : Couldn't able to connect to server." ); |
|
1345 |
|
1346 return pluginActive; |
|
1347 } |
|
1348 |
|
1349 // First check if Nitz is active. |
|
1350 errorVal = clkSrvIf.IsProtocolActive( KNitzPlugin, pluginActive ); |
|
1351 |
|
1352 // Protocol is not active. |
|
1353 if( pluginActive && KErrNone == errorVal ) |
|
1354 { |
|
1355 __PRINTS( "CAdtUpdaterListener::IsPluginActive : Plugin has been activated by clockserver." ); |
|
1356 |
|
1357 pluginActive = ETrue; |
|
1358 } |
|
1359 else |
|
1360 { |
|
1361 __PRINTS( "CAdtUpdaterListener::IsPluginActive : Plugin has not been activated by clockserver. " ); |
|
1362 |
|
1363 pluginActive = EFalse; |
|
1364 } |
|
1365 // Closing the session |
|
1366 clkSrvIf.Close(); |
|
1367 |
|
1368 __PRINTS( "CAdtUpdaterListener::IsPluginActive : Exit" ); |
|
1369 |
|
1370 return pluginActive; |
|
1371 } |
|
1372 |
|
1373 // --------------------------------------------------------------------------- |
|
1374 // CAdtUpdaterContainer::HiddenReset |
|
1375 // rest of the details are commented in header. |
|
1376 // --------------------------------------------------------------------------- |
|
1377 TBool CAdtUpdaterContainer::HiddenReset() |
|
1378 { |
|
1379 __PRINTS( "CAdtUpdaterContainer::HiddenReset : Entry" ); |
|
1380 |
|
1381 TBool retVal( EFalse ); |
|
1382 if( IsFirstBoot() ) |
|
1383 { |
|
1384 TInt startupReason( ENormalStartup ); |
|
1385 //Get the property value to know the reason of boot up like language switch, RFS, etc. |
|
1386 TInt errVal = RProperty::Get( KPSUidStartup, KPSStartupReason, startupReason ); |
|
1387 if( KErrNone != errVal ) |
|
1388 { |
|
1389 __PRINT( "CAdtUpdaterContainer::HiddenReset(): ENormalStartup get err %d", errVal ); |
|
1390 } |
|
1391 |
|
1392 __PRINT( "CAdtUpdaterContainer::HiddenReset(): ENormalStartup get err %d", startupReason ); |
|
1393 |
|
1394 retVal = ( startupReason != ENormalStartup ); |
|
1395 } |
|
1396 |
|
1397 __PRINTS( "CAdtUpdaterContainer::HiddenReset : Exit" ); |
|
1398 |
|
1399 return retVal; |
|
1400 } |
|
1401 |
|
1402 // --------------------------------------------------------------------------- |
|
1403 // CAdtUpdaterContainer::RTCStatus |
|
1404 // rest of the details are commented in header |
|
1405 // --------------------------------------------------------------------------- |
|
1406 TBool CAdtUpdaterContainer::RTCStatus() |
|
1407 { |
|
1408 __PRINTS( "CAdtUpdaterContainer::RTCStatus : Entry" ); |
|
1409 |
|
1410 TBool retVal( EFalse ); |
|
1411 |
|
1412 RStarterSession starterSession; |
|
1413 if( KErrNone == starterSession.Connect() ) |
|
1414 { |
|
1415 __PRINTS( "CAdtUpdaterContainer::RTCStatus(): Connected to Starter " ); |
|
1416 |
|
1417 retVal = starterSession.IsRTCTimeValid(); |
|
1418 starterSession.Close(); |
|
1419 } |
|
1420 |
|
1421 __PRINT( "CAdtUpdaterContainer::RTCStatus(): Exit, return %d ", retVal ); |
|
1422 |
|
1423 return retVal; |
|
1424 } |
|
1425 |
|
1426 // ----------------------------------------------------- |
|
1427 // CAdtUpdaterContainer::MarkFirstBoot |
|
1428 // rest of the details are commented in the header |
|
1429 // ----------------------------------------------------- |
|
1430 // |
|
1431 void CAdtUpdaterContainer::MarkFirstBoot() |
|
1432 { |
|
1433 __PRINTS( "CAdtUpdaterContainer::MarkFirstBoot - Entry" ); |
|
1434 |
|
1435 CRepository* cenRep( NULL ); |
|
1436 |
|
1437 TRAPD( errValue, cenRep = CRepository::NewL( KCRUidStartup ) ); |
|
1438 if ( KErrNone == errValue ) |
|
1439 { |
|
1440 errValue = cenRep->Set( KStartupFirstBoot, KFirstBootDone ); |
|
1441 } |
|
1442 |
|
1443 // Cleanup. |
|
1444 delete cenRep; |
|
1445 cenRep = NULL; |
|
1446 |
|
1447 __PRINTS( "CAdtUpdaterContainer::MarkFirstBoot - Exit" ); |
|
1448 } |
|
1449 |
|
1450 // --------------------------------------------------------- |
|
1451 // CAdtUpdaterListener::DeActivateNitzPlugin |
|
1452 // rest of the details are commented in the header |
|
1453 // --------------------------------------------------------- |
|
1454 // |
|
1455 void CAdtUpdaterContainer::DeActivateNitzPlugin() |
|
1456 { |
|
1457 __PRINTS( "CAdtUpdaterContainer::DeActivateNitzPlugin - Entry" ); |
|
1458 |
|
1459 RClkSrvInterface clkSrvIf; |
|
1460 // Connect to clockserver |
|
1461 TInt errorVal( clkSrvIf.Connect() ); |
|
1462 |
|
1463 // If the connection gets established |
|
1464 if( KErrNone == errorVal ) |
|
1465 { |
|
1466 clkSrvIf.DeActivateProtocol( KNitzPlugin ); |
|
1467 |
|
1468 //Closing the session |
|
1469 clkSrvIf.Close(); |
|
1470 } |
|
1471 |
|
1472 __PRINTS( "CAdtUpdaterContainer::DeActivateNitzPlugin - Exit" ); |
|
1473 } |
|
1474 |
|
1475 // ----------------------------------------------------- |
|
1476 // CAdtUpdaterContainer::Listener |
|
1477 // rest of the details are commented in the header |
|
1478 // ----------------------------------------------------- |
|
1479 // |
|
1480 CAdtUpdaterListener* CAdtUpdaterContainer::Listener() |
|
1481 { |
|
1482 __PRINTS( "CAdtUpdaterContainer::Listener - Entry" ); |
|
1483 |
|
1484 if( iListener ) |
|
1485 { |
|
1486 __PRINTS( "CAdtUpdaterContainer::Listener - Exit" ); |
|
1487 |
|
1488 return iListener; |
|
1489 } |
|
1490 |
|
1491 __PRINTS( "CAdtUpdaterContainer::Listener - Exit" ); |
|
1492 |
|
1493 return NULL; |
|
1494 } |
|
1495 |
|
1496 // ----------------------------------------------------- |
|
1497 // CAdtUpdaterContainer::QueryDialogsInDisplay |
|
1498 // rest of the details are commented in the header |
|
1499 // ----------------------------------------------------- |
|
1500 // |
|
1501 TBool CAdtUpdaterContainer::QueryDialogsInDisplay() |
|
1502 { |
|
1503 __PRINTS( "CAdtUpdaterContainer::QueryDialogsInDisplay - Entry" ); |
|
1504 |
|
1505 __PRINTS( "CAdtUpdaterContainer::QueryDialogsInDisplay - Exit" ); |
|
1506 |
|
1507 return iQueryDialogsInDisplay; |
|
1508 } |
|
1509 |
|
1510 // ----------------------------------------------------- |
|
1511 // CAdtUpdaterContainer::DisplayStartupQueriesL |
|
1512 // rest of the details are commented in the header |
|
1513 // ----------------------------------------------------- |
|
1514 // |
|
1515 TBool CAdtUpdaterContainer::DisplayStartupQueriesL() |
|
1516 { |
|
1517 __PRINTS( "CAdtUpdaterContainer::StartupQueriesEnabledL - Entry" ); |
|
1518 |
|
1519 TInt showQueries( 1 ); |
|
1520 |
|
1521 __PRINTS( "Before cenrep constrction" ); |
|
1522 CRepository *repository( NULL ); |
|
1523 |
|
1524 TRAPD( errorVal, repository = CRepository::NewL( KCRUidStartupConf ) ); |
|
1525 |
|
1526 __PRINT( "After construction, error value: %d", errorVal ); |
|
1527 |
|
1528 if( KErrNone == errorVal ) |
|
1529 { |
|
1530 TInt errorCode = repository->Get( KStartupQueries, showQueries ); |
|
1531 delete repository; |
|
1532 } |
|
1533 |
|
1534 __PRINTS( "CAdtUpdaterContainer::StartupQueriesEnabledL - Exit" ); |
|
1535 |
|
1536 return TBool( showQueries ); |
|
1537 } |
|
1538 // End of file |