|
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 CClockWorldView class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <aknViewAppUi.h> |
|
20 #include <StringLoader.h> |
|
21 #include <AknUtils.h> |
|
22 #include <clock.rsg> |
|
23 #include <aknnotewrappers.h> |
|
24 #include <aknlists.h> |
|
25 #include <tzlocalizer.h> |
|
26 #include <tzlocalizationdatatypes.h> |
|
27 #include <AknQueryDialog.h> |
|
28 #include <MGFetch.h> |
|
29 #include <hlplch.h> |
|
30 |
|
31 // User includes |
|
32 #include "clockworldview.h" |
|
33 #include "clockworldcontainer.h" |
|
34 #include "clockworldarray.h" |
|
35 #include "clockcityselectionlist.h" |
|
36 #include "clockdocument.h" |
|
37 #include "clockappui.h" |
|
38 #include "clock.h" |
|
39 #include "clock.hrh" |
|
40 #include "clockserverclt.h" |
|
41 #include "clock_debug.h" |
|
42 #include "clockworlditemprocessor.h" |
|
43 |
|
44 // Constants |
|
45 const TInt KSizeMaxCitiesText( 100 ); |
|
46 const TInt KNoCities( 0 ); |
|
47 const TInt KIntervalTime( 60000000 ); |
|
48 |
|
49 // Literals |
|
50 _LIT( KClockCitySelectionDll, "clockcityselectionlist.dll" ); |
|
51 |
|
52 // --------------------------------------------------------- |
|
53 // CClockWorldView::NewL |
|
54 // rest of the details are commented in the header |
|
55 // --------------------------------------------------------- |
|
56 // |
|
57 CClockWorldView* CClockWorldView::NewL() |
|
58 { |
|
59 __PRINTS( "CClockWorldView::NewL - Entry" ); |
|
60 |
|
61 CClockWorldView* self = new ( ELeave ) CClockWorldView; |
|
62 CleanupStack::PushL( self ); |
|
63 |
|
64 self->ConstructL(); |
|
65 |
|
66 CleanupStack::Pop( self ); |
|
67 |
|
68 __PRINTS( "CClockWorldView::NewL - Exit" ); |
|
69 |
|
70 return self; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------- |
|
74 // CClockWorldView::~CClockWorldView |
|
75 // rest of the details are commented in the header |
|
76 // --------------------------------------------------------- |
|
77 // |
|
78 CClockWorldView::~CClockWorldView() |
|
79 { |
|
80 __PRINTS( "CClockWorldView::~CClockWorldView - Entry" ); |
|
81 |
|
82 if( iWorldArray ) |
|
83 { |
|
84 delete iWorldArray; |
|
85 iWorldArray = NULL; |
|
86 } |
|
87 if( iContainer ) |
|
88 { |
|
89 ( AppUi() )->RemoveFromStack( iContainer ); |
|
90 delete iContainer; |
|
91 iContainer = NULL; |
|
92 } |
|
93 |
|
94 iClockCitySelector.Close(); |
|
95 |
|
96 if( iMaxCitiesAdded ) |
|
97 { |
|
98 delete iMaxCitiesAdded; |
|
99 iMaxCitiesAdded = NULL; |
|
100 } |
|
101 if( iTimer ) |
|
102 { |
|
103 delete iTimer; |
|
104 iTimer = NULL; |
|
105 } |
|
106 if( iItemProcessor ) |
|
107 { |
|
108 delete iItemProcessor; |
|
109 iItemProcessor = NULL; |
|
110 } |
|
111 |
|
112 __PRINTS( "CClockWorldView::~CClockWorldView - Exit" ); |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------- |
|
116 // CClockWorldView::Id |
|
117 // rest of the details are commented in the header |
|
118 // --------------------------------------------------------- |
|
119 // |
|
120 TUid CClockWorldView::Id() const |
|
121 { |
|
122 __PRINTS( "CClockWorldView::Id - Entry" ); |
|
123 |
|
124 __PRINTS( "CClockWorldView::Id - Entry" ); |
|
125 |
|
126 return KClockAppWorldViewId; |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // CClockWorldView::HandleCommandL |
|
131 // rest of the details are commented in the header |
|
132 // --------------------------------------------------------- |
|
133 // |
|
134 void CClockWorldView::HandleCommandL( TInt aCommand ) |
|
135 { |
|
136 __PRINTS( "CClockWorldView::HandleCommandL - Entry" ); |
|
137 |
|
138 switch( aCommand ) |
|
139 { |
|
140 case EClockWorldAddRegion: |
|
141 |
|
142 { |
|
143 // Add a city to the list. |
|
144 AddLocationL(); |
|
145 } |
|
146 break; |
|
147 |
|
148 case EClockWorldMyRegion: |
|
149 { |
|
150 //Single click integration |
|
151 // If current item is other than home location set it as new home |
|
152 // location |
|
153 if ( iContainer->ListBox()->CurrentItemIndex() > KZerothIndex ) |
|
154 { |
|
155 SetHomeLocationL(); |
|
156 } |
|
157 |
|
158 } |
|
159 break; |
|
160 |
|
161 case EClockWorldRemoveRegion: |
|
162 { |
|
163 // Remove the selected city from the list. |
|
164 RemoveLocationL(); |
|
165 } |
|
166 break; |
|
167 |
|
168 case EClockWorldAddImage: |
|
169 { |
|
170 // Change the image. |
|
171 AddImageL(); |
|
172 } |
|
173 break; |
|
174 |
|
175 case EClockWorldSettings: |
|
176 { |
|
177 // Let the appui handle the command. |
|
178 AppUi()->HandleCommandL( EClockSettings ); |
|
179 } |
|
180 break; |
|
181 |
|
182 case EAknCmdHelp: //EClockWorldHelp: |
|
183 { |
|
184 // Launch world clock help. |
|
185 HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), iAvkonAppUi->AppHelpContextL() ); |
|
186 } |
|
187 break; |
|
188 |
|
189 case EAknSoftkeyExit: |
|
190 { |
|
191 AppUi()->HandleCommandL( aCommand ); |
|
192 } |
|
193 break; |
|
194 |
|
195 case EClockWorldExit: |
|
196 { |
|
197 AppUi()->HandleCommandL( aCommand ); |
|
198 } |
|
199 break; |
|
200 |
|
201 case EAknCmdHideInBackground: |
|
202 { |
|
203 // Close the gallary, if open already. |
|
204 if( iCanceler ) |
|
205 { |
|
206 iCanceler->CancelFetcherL(); |
|
207 } |
|
208 } |
|
209 break; |
|
210 |
|
211 default: |
|
212 { |
|
213 // No impelementation yet. |
|
214 } |
|
215 break; |
|
216 } |
|
217 |
|
218 __PRINTS( "CClockWorldView::HandleCommandL - Exit" ); |
|
219 } |
|
220 |
|
221 // --------------------------------------------------------- |
|
222 // CClockWorldView::DynInitMenuPaneL |
|
223 // rest of the details are commented in the header |
|
224 // --------------------------------------------------------- |
|
225 // |
|
226 void CClockWorldView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
227 { |
|
228 __PRINTS( "CClockWorldView::DynInitMenuPaneL - Entry" ); |
|
229 |
|
230 //Single click integration |
|
231 if( R_CLOCK_WORLD_VIEW_MENUPANE != aResourceId ) |
|
232 |
|
233 { |
|
234 __PRINTS( "CClockWorldView::DynInitMenuPaneL - Exit" ); |
|
235 |
|
236 // We're not bother about other menupanes. |
|
237 return; |
|
238 } |
|
239 // TODO: For help. |
|
240 /*if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
241 { |
|
242 aMenuPane->DeleteMenuItem( EWorldClockHelp ); |
|
243 }*/ |
|
244 |
|
245 if( KNoCities == iWorldArray->MdcaCount() ) |
|
246 { |
|
247 //Single click integration |
|
248 aMenuPane->SetItemDimmed( EClockWorldRemoveRegion, ETrue ); |
|
249 aMenuPane->SetItemDimmed( EClockWorldAddImage, ETrue ); |
|
250 aMenuPane->SetItemDimmed( EClockWorldMyRegion, ETrue ); |
|
251 } |
|
252 |
|
253 // Add item is displayed only if the selection list is available. |
|
254 if( !iSelectionListAvailable ) |
|
255 { |
|
256 // Hide the Add menu option if loading DLL failed. |
|
257 aMenuPane->SetItemDimmed( EClockWorldAddRegion, ETrue ); |
|
258 } |
|
259 |
|
260 // Check if automatic-time update is On. |
|
261 RClkSrvInterface clockServerClt; |
|
262 // Connect to clockserver |
|
263 TInt errorVal( clockServerClt.Connect() ); |
|
264 // Check if timeupdate is On. |
|
265 TBool timeUpdateOn( EFalse ); |
|
266 if( KErrNone == errorVal ) |
|
267 { |
|
268 errorVal = clockServerClt.IsAutoTimeUpdateOn( timeUpdateOn ); |
|
269 } |
|
270 // Close the session with the server. |
|
271 clockServerClt.Close(); |
|
272 |
|
273 if( KZerothIndex == iContainer->ListBox()->CurrentItemIndex() && !timeUpdateOn ) |
|
274 { |
|
275 aMenuPane->DeleteMenuItem( EClockWorldMyRegion ); |
|
276 aMenuPane->DeleteMenuItem( EClockWorldAddImage ); |
|
277 aMenuPane->SetItemDimmed( EClockWorldRemoveRegion, ETrue); |
|
278 } |
|
279 |
|
280 |
|
281 |
|
282 __PRINTS( "CClockWorldView::DynInitMenuPaneL - Exit" ); |
|
283 } |
|
284 |
|
285 // --------------------------------------------------------- |
|
286 // CClockWorldView::DynInitMenuBarL |
|
287 // rest of the details are commented in the header |
|
288 // --------------------------------------------------------- |
|
289 // |
|
290 //single click integration |
|
291 void CClockWorldView::DynInitMenuBarL( TInt /*aResourceId*/, CEikMenuBar* aMenuBar ) |
|
292 |
|
293 { |
|
294 __PRINTS( "CClockWorldView::DynInitMenuBarL - Entry" ); |
|
295 |
|
296 //single click integration |
|
297 if( aMenuBar && ( IsSelectionListOpen() || IsGalleryOpen() ) ) |
|
298 { |
|
299 // If the selection list open, we should not display the menupane. |
|
300 aMenuBar->StopDisplayingMenuBar(); |
|
301 } |
|
302 |
|
303 |
|
304 __PRINTS( "CClockWorldView::DynInitMenuBarL - Exit" ); |
|
305 } |
|
306 |
|
307 // --------------------------------------------------------- |
|
308 // CClockWorldView::GetApplicationRect |
|
309 // rest of the details are commented in the header |
|
310 // --------------------------------------------------------- |
|
311 // |
|
312 TRect CClockWorldView::GetApplicationRect() |
|
313 { |
|
314 __PRINTS( "CClockWorldView::GetApplicationRect - Entry" ); |
|
315 |
|
316 __PRINTS( "CClockWorldView::GetApplicationRect - Exit" ); |
|
317 |
|
318 // Return the applicationrect from appui. |
|
319 return AppUi()->ApplicationRect(); |
|
320 } |
|
321 |
|
322 |
|
323 |
|
324 // --------------------------------------------------------- |
|
325 // CClockWorldView::HandleEnvChangeL |
|
326 // rest of the details are commented in the header |
|
327 // --------------------------------------------------------- |
|
328 // |
|
329 void CClockWorldView::HandleEnvChangeL( TClockEnvChanged aEnvChanged ) |
|
330 { |
|
331 __PRINTS( "CClockWorldView::HandleEnvChangeL - Entry" ); |
|
332 |
|
333 CClockDocument* clockDocument = static_cast< CClockDocument* > ( AppUi()->Document() ); |
|
334 |
|
335 // Here we check if the environment change was in the system time/zone, |
|
336 // we check if the current zone is different from the homecity item in the list |
|
337 // and if it is, then we update it with the new one. |
|
338 if( EEnvChanged == aEnvChanged && clockDocument->IsHomeCityItemAdded() ) |
|
339 { |
|
340 // Remove the previous home city. |
|
341 iWorldArray->RemoveCity( KZerothIndex ); |
|
342 |
|
343 // Add the current home city to the world clock view. |
|
344 iWorldArray->InsertHomeCityItem(); |
|
345 |
|
346 if( iContainer ) |
|
347 { |
|
348 // We update the first item in the list. |
|
349 iContainer->ListBox()->HandleItemAdditionL(); |
|
350 } |
|
351 } |
|
352 |
|
353 if( iContainer ) |
|
354 { |
|
355 // Update the container. |
|
356 |
|
357 iContainer->Refresh(); |
|
358 } |
|
359 |
|
360 __PRINTS( "CClockWorldView::HandleEnvChangeL - Exit" ); |
|
361 } |
|
362 |
|
363 // --------------------------------------------------------- |
|
364 // CClockWorldView::IsSelectionListOpen |
|
365 // rest of the details are commented in the header |
|
366 // --------------------------------------------------------- |
|
367 // |
|
368 TBool CClockWorldView::IsSelectionListOpen() |
|
369 { |
|
370 __PRINTS( "CClockWorldView::IsSelectionListOpen - Entry" ); |
|
371 |
|
372 __PRINTS( "CClockWorldView::IsSelectionListOpen - Exit" ); |
|
373 |
|
374 return iSelectionListOpen; |
|
375 } |
|
376 |
|
377 // --------------------------------------------------------- |
|
378 // CClockWorldView::IsGalleryOpen |
|
379 // rest of the details are commented in the header |
|
380 // --------------------------------------------------------- |
|
381 // |
|
382 TBool CClockWorldView::IsGalleryOpen() |
|
383 { |
|
384 __PRINTS( "CClockWorldView::IsGalleryOpen - Entry" ); |
|
385 |
|
386 __PRINTS( "CClockWorldView::IsGalleryOpen - Exit" ); |
|
387 |
|
388 return iGalleryOpen; |
|
389 } |
|
390 |
|
391 // -------------------------------------------------------- |
|
392 // CClockWorldView::TimerCallback |
|
393 // rest of the details are commented in the header |
|
394 // --------------------------------------------------------- |
|
395 // |
|
396 TInt CClockWorldView::TimerCallback( TAny* aThis ) |
|
397 { |
|
398 __PRINTS( "CClockWorldView::TimerCallback - Entry" ); |
|
399 |
|
400 CClockWorldView* self( STATIC_CAST( CClockWorldView*, aThis ) ); |
|
401 |
|
402 // Update the container. |
|
403 if( self->iContainer ) |
|
404 { |
|
405 |
|
406 self->iContainer->Refresh(); |
|
407 } |
|
408 |
|
409 TTime homeTime; |
|
410 homeTime.HomeTime(); |
|
411 TDateTime dateTime( homeTime.DateTime() ); |
|
412 if( 0 < dateTime.Second() ) |
|
413 { |
|
414 self->iTimer->Cancel(); |
|
415 self->iTimer->After( KIntervalTime - 1000000 * dateTime.Second() - dateTime.MicroSecond() ); |
|
416 } |
|
417 |
|
418 __PRINTS( "CClockWorldView::TimerCallback - Exit" ); |
|
419 |
|
420 return FALSE; |
|
421 } |
|
422 |
|
423 // --------------------------------------------------------- |
|
424 // CClockWorldView::ClockApplicationUi |
|
425 // rest of the details are commented in the header |
|
426 // --------------------------------------------------------- |
|
427 // |
|
428 CClockAppUi* CClockWorldView::ClockApplicationUi() |
|
429 { |
|
430 __PRINTS( "CClockWorldView::ClockApplicationUi - Entry" ); |
|
431 |
|
432 return static_cast< CClockAppUi* > ( AppUi() ); |
|
433 |
|
434 __PRINTS( "CClockWorldView::ClockApplicationUi - Exit" ); |
|
435 } |
|
436 |
|
437 // --------------------------------------------------------- |
|
438 // CClockWorldView::DoActivateL |
|
439 // rest of the details are commented in the header |
|
440 // --------------------------------------------------------- |
|
441 // |
|
442 void CClockWorldView::DoActivateL( const TVwsViewId& /*aPrevViewId*/, |
|
443 TUid /*aCustomMessageId*/, |
|
444 const TDesC8& /*aCustomMessage*/ ) |
|
445 { |
|
446 __PRINTS( "CClockWorldView::DoActivateL - Entry" ); |
|
447 |
|
448 iItemToFocus = KZerothIndex; |
|
449 |
|
450 // Insert the homecity item in the list. We do this only if Automatic-time update is Off. |
|
451 RClkSrvInterface clockServerClt; |
|
452 // Connect to clockserver |
|
453 TInt errorVal( clockServerClt.Connect() ); |
|
454 // Check if timeupdate is On. |
|
455 TBool timeUpdateOn( EFalse ); |
|
456 if( KErrNone == errorVal ) |
|
457 { |
|
458 errorVal = clockServerClt.IsAutoTimeUpdateOn( timeUpdateOn ); |
|
459 } |
|
460 // Close the session with the server. |
|
461 clockServerClt.Close(); |
|
462 |
|
463 CClockDocument* clockDocument = static_cast< CClockDocument* > ( AppUi()->Document() ); |
|
464 |
|
465 if( !iContainer ) |
|
466 { |
|
467 iContainer = CClockWorldContainer::NewL( this, ClientRect(), iWorldArray ); |
|
468 ( AppUi() )->AddToStackL( *this, iContainer ); |
|
469 iContainer->SetMopParent( this ); |
|
470 // Create the CClockWorldItemProcessor object to redraw each listitem |
|
471 iItemProcessor = CClockWorldItemProcessor::NewL( iContainer ); |
|
472 |
|
473 iWorldArray->SetItemProcessor( iItemProcessor ); |
|
474 // If automatic time update is OFF then set the empty text to NULL and insert the home city. |
|
475 if( !timeUpdateOn ) |
|
476 { |
|
477 iWorldArray->InsertHomeCityItem(); |
|
478 clockDocument->SetHomeCityItemAdded( ETrue ); |
|
479 |
|
480 // Update the listbox. |
|
481 iContainer->ListBox()->HandleItemAdditionL(); |
|
482 } |
|
483 else |
|
484 { |
|
485 clockDocument->SetHomeCityItemAdded( EFalse ); |
|
486 } |
|
487 } |
|
488 |
|
489 // This code will get executed, even if the container was constructed before, this code has to |
|
490 // get executed to ensure correct text is displayed when the list is empty. |
|
491 // Check if automatic time update is ON and home city is added. |
|
492 // then remove the home city. |
|
493 if( timeUpdateOn ) |
|
494 { |
|
495 // Check if home city is added. |
|
496 if( clockDocument->IsHomeCityItemAdded() ) |
|
497 { |
|
498 iWorldArray->RemoveCity( KZerothIndex ); |
|
499 clockDocument->SetHomeCityItemAdded( EFalse ); |
|
500 iContainer->ListBox()->HandleItemRemovalL(); |
|
501 } |
|
502 // Automatic time update is on.In case worldarray list is empty then display the no locations string. |
|
503 if( !iWorldArray->MdcaCount() ) |
|
504 { |
|
505 HBufC* noLocationBuf = StringLoader::LoadLC( R_WRLD_CLK_EMPTY_VIEW, iCoeEnv ); |
|
506 iContainer->ListBox()->View()->SetListEmptyTextL( noLocationBuf->Des() ); |
|
507 CleanupStack::PopAndDestroy( noLocationBuf ); |
|
508 } |
|
509 } |
|
510 else |
|
511 { |
|
512 // Check if home city is not inserted. |
|
513 if( !clockDocument->IsHomeCityItemAdded() ) |
|
514 { |
|
515 iWorldArray->InsertHomeCityItem(); |
|
516 clockDocument->SetHomeCityItemAdded( ETrue ); |
|
517 iContainer->ListBox()->HandleItemAdditionL(); |
|
518 } |
|
519 // If automatic time update is OFF then set the empty text to NULL and insert the home city. |
|
520 HBufC* noLocationBuf = HBufC::NewLC( 1 ); |
|
521 noLocationBuf->Des().Append( KSingleSpace ); |
|
522 iContainer->ListBox()->View()->SetListEmptyTextL( noLocationBuf->Des() ); |
|
523 CleanupStack::PopAndDestroy( noLocationBuf ); |
|
524 } |
|
525 |
|
526 if( clockDocument->IsHomeCityItemAdded() ) |
|
527 { |
|
528 // If home city is already added, |
|
529 // get the current home city and the previous home city. |
|
530 // Check for difference |
|
531 |
|
532 //Get the current home city. |
|
533 RTz tzHandle; |
|
534 User::LeaveIfError( tzHandle.Connect() ); |
|
535 |
|
536 // Get the timezone id. |
|
537 CTzId* currentTimeZoneId = tzHandle.GetTimeZoneIdL(); |
|
538 CleanupStack::PushL( currentTimeZoneId ); |
|
539 |
|
540 // Construct CTzLocalizer object to get the timezone from the id. |
|
541 CTzLocalizer* tzLocalizer = CTzLocalizer::NewLC(); |
|
542 |
|
543 // Get the frequently used localized city. |
|
544 CTzLocalizedCity* currentLocalizedCity = tzLocalizer->GetFrequentlyUsedZoneCityL( CTzLocalizedTimeZone::ECurrentZone ); |
|
545 CleanupStack::PushL( currentLocalizedCity ); |
|
546 |
|
547 TCityInfo cityInfo = iWorldArray->GetCity( KZerothIndex ); |
|
548 |
|
549 if( currentLocalizedCity->Name().Compare( cityInfo.iCity ) != 0 ) |
|
550 { |
|
551 iWorldArray->RemoveCity( KZerothIndex ); |
|
552 iWorldArray->InsertHomeCityItem(); |
|
553 iContainer->ListBox()->HandleItemAdditionL(); |
|
554 } |
|
555 |
|
556 // Cleanup. |
|
557 CleanupStack::PopAndDestroy( currentLocalizedCity ); |
|
558 CleanupStack::PopAndDestroy( tzLocalizer ); |
|
559 CleanupStack::PopAndDestroy( currentTimeZoneId ); |
|
560 |
|
561 tzHandle.Close(); |
|
562 } |
|
563 |
|
564 |
|
565 |
|
566 if( iWorldArray->MdcaCount() > 0 ) |
|
567 { |
|
568 // Always focus the first item. |
|
569 iContainer->ListBox()->SetCurrentItemIndexAndDraw( KZerothIndex ); |
|
570 iContainer->ListBox()->ScrollToMakeItemVisible( KZerothIndex ); |
|
571 } |
|
572 |
|
573 // Make the time item synchronize the current time every a minute. |
|
574 if( !iTimer ) |
|
575 { |
|
576 TTime time; |
|
577 time.HomeTime(); |
|
578 TDateTime dateTime = time.DateTime(); |
|
579 TCallBack callBack( TimerCallback, this ); |
|
580 iTimer = CPeriodic::NewL( CActive::EPriorityHigh ); |
|
581 iTimer->Start( TTimeIntervalMicroSeconds32( KIntervalTime - 1000000 * dateTime.Second() - dateTime.MicroSecond() ), |
|
582 TTimeIntervalMicroSeconds32( KIntervalTime ), callBack ); |
|
583 } |
|
584 |
|
585 // Activate the container. |
|
586 iContainer->ActivateL(); |
|
587 iContainer->SetRect( ClientRect() ); |
|
588 |
|
589 |
|
590 |
|
591 // Update the title pane text. |
|
592 ClockApplicationUi()->SetTitlePaneTextL( R_TITLE_WRLD_CLK ); |
|
593 |
|
594 // If opened from clock, display the navigation pane again. |
|
595 ClockApplicationUi()->MakeNavigationPaneVisible( ETrue, EClockAppWorldViewId ); |
|
596 |
|
597 __PRINTS( "CClockWorldView::DoActivateL - Exit" ); |
|
598 } |
|
599 |
|
600 // --------------------------------------------------------- |
|
601 // CClockWorldView::DoDeactivate |
|
602 // rest of the details are commented in the header |
|
603 // --------------------------------------------------------- |
|
604 // |
|
605 void CClockWorldView::DoDeactivate() |
|
606 { |
|
607 __PRINTS( "CClockWorldView::DoDeactivate - Entry" ); |
|
608 |
|
609 iItemToFocus = KZerothIndex; |
|
610 |
|
611 // Set the display text to space to avoid flickering when switching between views. |
|
612 TRAP_IGNORE( iContainer->ListBox()->View()->SetListEmptyTextL( KSingleSpace ) ); |
|
613 |
|
614 __PRINTS( "CClockWorldView::DoDeactivate - Exit" ); |
|
615 } |
|
616 |
|
617 // --------------------------------------------------------- |
|
618 // CClockWorldView::HandleForegroundEventL |
|
619 // rest of the details are commented in the header |
|
620 // --------------------------------------------------------- |
|
621 // |
|
622 void CClockWorldView::HandleForegroundEventL( TBool aForeground ) |
|
623 { |
|
624 |
|
625 if( aForeground && iContainer ) |
|
626 { |
|
627 RestartTimerL(); |
|
628 |
|
629 RClkSrvInterface clockServerClt; |
|
630 // Connect to clockserver |
|
631 TInt errorVal( clockServerClt.Connect() ); |
|
632 // Check if timeupdate is On. |
|
633 TBool timeUpdateOn( EFalse ); |
|
634 if( KErrNone == errorVal ) |
|
635 { |
|
636 errorVal = clockServerClt.IsAutoTimeUpdateOn( timeUpdateOn ); |
|
637 } |
|
638 // Close the session with the server. |
|
639 clockServerClt.Close(); |
|
640 |
|
641 CClockDocument* clockDocument = static_cast< CClockDocument* > ( AppUi()->Document() ); |
|
642 |
|
643 // This code will get executed, even if the container was constructed before, this code has to |
|
644 // get executed to ensure correct text is displayed when the list is empty. |
|
645 // Check if automatic time update is ON and home city is added. |
|
646 // then remove the home city. |
|
647 if( timeUpdateOn ) |
|
648 { |
|
649 // Check if home city is added. |
|
650 if( clockDocument->IsHomeCityItemAdded() ) |
|
651 { |
|
652 iWorldArray->RemoveCity( KZerothIndex ); |
|
653 clockDocument->SetHomeCityItemAdded( EFalse ); |
|
654 iContainer->ListBox()->HandleItemRemovalL(); |
|
655 if( iItemToFocus >= iWorldArray->MdcaCount() ) |
|
656 { |
|
657 iItemToFocus = iWorldArray->MdcaCount() - 1; |
|
658 } |
|
659 } |
|
660 // Automatic time update is on.In case worldarray list is empty then display the no locations string. |
|
661 if( !iWorldArray->MdcaCount() ) |
|
662 { |
|
663 HBufC* noLocationBuf = StringLoader::LoadLC( R_WRLD_CLK_EMPTY_VIEW, iCoeEnv ); |
|
664 iContainer->ListBox()->View()->SetListEmptyTextL( noLocationBuf->Des() ); |
|
665 CleanupStack::PopAndDestroy( noLocationBuf ); |
|
666 } |
|
667 } |
|
668 else |
|
669 { |
|
670 // Check if home city is not inserted. |
|
671 if( !clockDocument->IsHomeCityItemAdded() ) |
|
672 { |
|
673 iWorldArray->InsertHomeCityItem(); |
|
674 clockDocument->SetHomeCityItemAdded( ETrue ); |
|
675 iContainer->ListBox()->HandleItemAdditionL(); |
|
676 iItemToFocus = KZerothIndex; |
|
677 } |
|
678 // If automatic time update is OFF then set the empty text to NULL and insert the home city. |
|
679 HBufC* noLocationBuf = HBufC::NewLC( 1 ); |
|
680 noLocationBuf->Des().Append( KSingleSpace ); |
|
681 iContainer->ListBox()->View()->SetListEmptyTextL( noLocationBuf->Des() ); |
|
682 CleanupStack::PopAndDestroy( noLocationBuf ); |
|
683 } |
|
684 |
|
685 if( clockDocument->IsHomeCityItemAdded() ) |
|
686 { |
|
687 // If home city is already added, |
|
688 // get the current home city and the previous home city. |
|
689 // Check for difference |
|
690 |
|
691 //Get the current home city. |
|
692 RTz tzHandle; |
|
693 User::LeaveIfError( tzHandle.Connect() ); |
|
694 |
|
695 // Get the timezone id. |
|
696 CTzId* currentTimeZoneId = tzHandle.GetTimeZoneIdL(); |
|
697 CleanupStack::PushL( currentTimeZoneId ); |
|
698 |
|
699 // Construct CTzLocalizer object to get the timezone from the id. |
|
700 CTzLocalizer* tzLocalizer = CTzLocalizer::NewLC(); |
|
701 |
|
702 // Get the frequently used localized city. |
|
703 CTzLocalizedCity* currentLocalizedCity = tzLocalizer->GetFrequentlyUsedZoneCityL( CTzLocalizedTimeZone::ECurrentZone ); |
|
704 CleanupStack::PushL( currentLocalizedCity ); |
|
705 |
|
706 TCityInfo cityInfo = iWorldArray->GetCity( KZerothIndex ); |
|
707 |
|
708 if( currentLocalizedCity->Name().Compare( cityInfo.iCity ) != 0 ) |
|
709 { |
|
710 iWorldArray->RemoveCity( KZerothIndex ); |
|
711 iWorldArray->InsertHomeCityItem(); |
|
712 iContainer->ListBox()->HandleItemAdditionL(); |
|
713 } |
|
714 |
|
715 // Cleanup. |
|
716 CleanupStack::PopAndDestroy( currentLocalizedCity ); |
|
717 CleanupStack::PopAndDestroy( tzLocalizer ); |
|
718 CleanupStack::PopAndDestroy( currentTimeZoneId ); |
|
719 |
|
720 tzHandle.Close(); |
|
721 } |
|
722 |
|
723 if( iItemToFocus < iWorldArray->MdcaCount() && KZerothIndex < iItemToFocus ) |
|
724 { |
|
725 iContainer->ListBox()->SetCurrentItemIndexAndDraw( iItemToFocus ); |
|
726 iContainer->ListBox()->ScrollToMakeItemVisible( iItemToFocus ); |
|
727 } |
|
728 else |
|
729 { |
|
730 iContainer->ListBox()->SetCurrentItemIndexAndDraw( KZerothIndex ); |
|
731 iContainer->ListBox()->ScrollToMakeItemVisible( KZerothIndex ); |
|
732 } |
|
733 |
|
734 iContainer->Refresh(); |
|
735 } |
|
736 else |
|
737 { |
|
738 if( iContainer ) |
|
739 { |
|
740 iItemToFocus = iContainer->ListBox()->CurrentItemIndex(); |
|
741 } |
|
742 if( iTimer ) |
|
743 { |
|
744 StopTimerL(); |
|
745 } |
|
746 } |
|
747 } |
|
748 |
|
749 // --------------------------------------------------------- |
|
750 // CClockWorldView::ConstructL |
|
751 // rest of the details are commented in the header |
|
752 // --------------------------------------------------------- |
|
753 // |
|
754 void CClockWorldView::ConstructL() |
|
755 { |
|
756 __PRINTS( "CClockWorldView::ConstructL - Entry" ); |
|
757 |
|
758 // Construct the view first. |
|
759 BaseConstructL( R_CLOCK_WORLD_VIEW ); |
|
760 |
|
761 // Get the initial list from the document. |
|
762 CClockDocument* clockDocument = static_cast< CClockDocument* > ( AppUi()->Document() ); |
|
763 iWorldArray = CClockWorldArray::NewL( clockDocument->GetWorldClockList(), CEikonEnv::Static() ); |
|
764 |
|
765 // TODO: iClockSrvModel = clockDocument->ClockServerModel(); |
|
766 |
|
767 // Load the city/country selection dialog. |
|
768 TInt errorVal( iClockCitySelector.Load( KClockCitySelectionDll ) ); |
|
769 if( KErrNone != errorVal ) |
|
770 { |
|
771 iSelectionListAvailable = EFalse; |
|
772 } |
|
773 |
|
774 // Load the strings. |
|
775 iMaxCitiesAdded = StringLoader::LoadL( R_CLOCK_WORLD_NOTE_CITY_MAX, iCoeEnv ); |
|
776 // Convert numbers From Latin to Davanagiri/Arabic-indi digits. |
|
777 TBuf< KSizeMaxCitiesText > textBuf( iMaxCitiesAdded ->Des() ); |
|
778 AknTextUtils::LanguageSpecificNumberConversion( textBuf ); |
|
779 iMaxCitiesAdded->Des() = textBuf; |
|
780 |
|
781 __PRINTS( "CClockWorldView::ConstructL - Exit" ); |
|
782 } |
|
783 |
|
784 // --------------------------------------------------------- |
|
785 // CClockWorldView::CClockWorldView |
|
786 // rest of the details are commented in the header |
|
787 // --------------------------------------------------------- |
|
788 // |
|
789 CClockWorldView::CClockWorldView() |
|
790 { |
|
791 __PRINTS( "CClockWorldView::CClockWorldView - Entry" ); |
|
792 |
|
793 iSelectionListAvailable = ETrue; |
|
794 //single click integration |
|
795 iSelectionListOpen = EFalse; |
|
796 |
|
797 iGalleryOpen = EFalse; |
|
798 iItemToFocus = KZerothIndex; |
|
799 |
|
800 __PRINTS( "CClockWorldView::CClockWorldView - Exit" ); |
|
801 } |
|
802 |
|
803 // --------------------------------------------------------- |
|
804 // CClockWorldView::AddLocationL |
|
805 // rest of the details are commented in the header |
|
806 // --------------------------------------------------------- |
|
807 // |
|
808 void CClockWorldView::AddLocationL() |
|
809 { |
|
810 __PRINTS( "CClockWorldView::AddLocationL - Entry" ); |
|
811 |
|
812 // If limit of cities in the list has been reached. |
|
813 if( KMaxCitiesInList == iWorldArray->MdcaCount() ) |
|
814 { |
|
815 CAknInformationNote* infoNote = new( ELeave ) CAknInformationNote; |
|
816 infoNote->ExecuteLD( *iMaxCitiesAdded ); |
|
817 |
|
818 __PRINTS( "CClockWorldView::NewL - Entry" ); |
|
819 |
|
820 return; |
|
821 } |
|
822 |
|
823 // Hide the navigation pane. |
|
824 static_cast< CClockAppUi* > ( AppUi() )->MakeNavigationPaneVisible( EFalse, EClockAppWorldViewId ); |
|
825 |
|
826 // We've now opened the list. |
|
827 iSelectionListOpen = ETrue; |
|
828 |
|
829 // Load the first export in the library. |
|
830 TLibraryFunction libraryFunction = iClockCitySelector.Lookup( 1 ); |
|
831 // Construct the selection list. |
|
832 MClockCitySelectionList* selectionList = ( MClockCitySelectionList* ) libraryFunction(); |
|
833 // Sanity check. |
|
834 User::LeaveIfNull( selectionList ); |
|
835 // This will be filled the dialog, will have what the user has selected. |
|
836 TCityInfo cityInformation; |
|
837 // We add a dummy value for timezone id in the city info. We check for this value after the |
|
838 // dialog has been destroyed. If it is other than the dummy value, we continue to add the city |
|
839 // to the list. |
|
840 cityInformation.iTimeZoneId = KErrNotFound; |
|
841 // Construct the list. |
|
842 selectionList->ConstructL( &cityInformation ); |
|
843 // Launch the list. |
|
844 TInt returnVal( selectionList->ExecuteLD() ); |
|
845 |
|
846 // The list destroyed now. |
|
847 iSelectionListOpen = EFalse; |
|
848 |
|
849 |
|
850 // Update the title pane text. |
|
851 TVwsViewId viewId; |
|
852 AppUi()->GetActiveViewId( viewId ); |
|
853 if( viewId.iViewUid == KClockAppWorldViewId ) |
|
854 { |
|
855 static_cast< CClockAppUi* > ( AppUi() )->SetTitlePaneTextL( R_TITLE_WRLD_CLK ); |
|
856 // Show the navigation pane again. |
|
857 static_cast< CClockAppUi* > ( AppUi() )->MakeNavigationPaneVisible( ETrue, EClockAppWorldViewId ); |
|
858 } |
|
859 |
|
860 if( KClockHideInBackground == returnVal ) |
|
861 { |
|
862 AppUi()->HandleCommandL( EClockWorldExit ); |
|
863 |
|
864 __PRINTS( "CClockWorldView::AddLocationL - Exit" ); |
|
865 |
|
866 return; |
|
867 } |
|
868 |
|
869 // We first check if the cityinfo has been filled by the selection list. It will be |
|
870 // NULL if the user had pressed cancel. |
|
871 if( KErrNotFound == cityInformation.iTimeZoneId ) |
|
872 { |
|
873 __PRINTS( "CClockWorldView::AddLocationL - Exit" ); |
|
874 |
|
875 return; |
|
876 } |
|
877 |
|
878 // Check if the city is already added. |
|
879 TInt itemIndex( iWorldArray->GetListBoxIndex( cityInformation ) ); |
|
880 |
|
881 if( KErrNotFound == itemIndex ) |
|
882 { |
|
883 // First update the array. |
|
884 iWorldArray->AddCityL( cityInformation ); |
|
885 // Now the container. |
|
886 iContainer->ListBox()->HandleItemAdditionL(); |
|
887 iContainer->ListBox()->ScrollToMakeItemVisible( iWorldArray->MdcaCount() - 1 ); |
|
888 iContainer->ListBox()->SetCurrentItemIndexAndDraw( iContainer->ListBox()->BottomItemIndex() ); |
|
889 |
|
890 // Update the Document. |
|
891 CClockDocument *clockDocument = static_cast< CClockDocument* > ( AppUi()->Document() ); |
|
892 clockDocument->StoreDataL(); |
|
893 } |
|
894 else |
|
895 { |
|
896 iContainer->ListBox()->SetCurrentItemIndexAndDraw( itemIndex ); |
|
897 } |
|
898 |
|
899 RClkSrvInterface clkSrvInterface; |
|
900 User::LeaveIfError( clkSrvInterface.Connect() ); |
|
901 TBool timeUpdateOn( EFalse ); |
|
902 // Get the state of the plugin. |
|
903 clkSrvInterface.IsAutoTimeUpdateOn( timeUpdateOn ); |
|
904 clkSrvInterface.Close(); |
|
905 |
|
906 |
|
907 |
|
908 __PRINTS( "CClockWorldView::AddLocationL - Exit" ); |
|
909 } |
|
910 |
|
911 // --------------------------------------------------------- |
|
912 // CClockWorldView::RemoveLocationL |
|
913 // rest of the details are commented in the header |
|
914 // --------------------------------------------------------- |
|
915 // |
|
916 void CClockWorldView::RemoveLocationL() |
|
917 { |
|
918 __PRINTS( "CClockWorldView::RemoveLocationL - Entry" ); |
|
919 |
|
920 // Sanity check. |
|
921 if( KNoCities >= iWorldArray->MdcaCount() ) |
|
922 { |
|
923 __PRINTS( "CClockWorldView::NewL - Entry" ); |
|
924 |
|
925 return; |
|
926 } |
|
927 |
|
928 HBufC* queryText( NULL ); |
|
929 TInt currentListItem( iContainer->ListBox()->CurrentItemIndex() ); |
|
930 |
|
931 // Get information about the city selected. |
|
932 TCityInfo cityInformation( iWorldArray->GetCity( currentListItem ) ); |
|
933 |
|
934 // Construct the localizer. |
|
935 CTzLocalizer* tzLocalizer = CTzLocalizer::NewL(); |
|
936 CleanupStack::PushL( tzLocalizer ); |
|
937 CTzLocalizedCityArray* localizedCityList = tzLocalizer->GetCitiesInGroupL( cityInformation.iCityGroupId, |
|
938 CTzLocalizer::ETzAlphaNameAscending ); |
|
939 CleanupStack::PushL( localizedCityList ); |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 // If user says OK, remove the item from the list as well as from the MDesCArray. |
|
945 // Also update the Data with the CClockDocument |
|
946 |
|
947 TInt imageIndex( iWorldArray->GetImageIndex( currentListItem ) ); |
|
948 |
|
949 // Remove the image icon in case it is not loaded by the other listitems |
|
950 iContainer->RemoveImage( cityInformation.iImagePath, imageIndex, currentListItem ); |
|
951 |
|
952 // Update the world array. |
|
953 iWorldArray->RemoveCity( currentListItem ); |
|
954 |
|
955 if( currentListItem >= iWorldArray->MdcaCount() ) |
|
956 { |
|
957 currentListItem = iWorldArray->MdcaCount() - 1; |
|
958 } |
|
959 if( KNoCities <= currentListItem ) |
|
960 { |
|
961 // Make the list to display the previous item. |
|
962 iContainer->ListBox()->SetCurrentItemIndex( currentListItem ); |
|
963 } |
|
964 |
|
965 // Update the document. |
|
966 CClockDocument* clockDocument = static_cast< CClockDocument* > ( AppUi()->Document() ); |
|
967 clockDocument->StoreDataL(); |
|
968 // Update the container. |
|
969 iContainer->ListBox()->HandleItemRemovalL(); |
|
970 // If there are no more cities present, update the empty list text. |
|
971 if( KNoCities == iWorldArray->MdcaCount() ) |
|
972 { |
|
973 HBufC* noLocationBuf = StringLoader::LoadLC( R_WRLD_CLK_EMPTY_VIEW, iCoeEnv ); |
|
974 iContainer->ListBox()->View()->SetListEmptyTextL( noLocationBuf->Des() ); |
|
975 CleanupStack::PopAndDestroy( noLocationBuf ); |
|
976 } |
|
977 |
|
978 |
|
979 // Cleanup. |
|
980 |
|
981 CleanupStack::PopAndDestroy( localizedCityList ); |
|
982 CleanupStack::PopAndDestroy( tzLocalizer ); |
|
983 |
|
984 RClkSrvInterface clkSrvInterface; |
|
985 User::LeaveIfError( clkSrvInterface.Connect() ); |
|
986 TBool timeUpdateOn( EFalse ); |
|
987 // Get the state of the plugin. |
|
988 clkSrvInterface.IsAutoTimeUpdateOn( timeUpdateOn ); |
|
989 clkSrvInterface.Close(); |
|
990 |
|
991 |
|
992 |
|
993 // Redraw the container |
|
994 |
|
995 iContainer->Refresh(); |
|
996 |
|
997 __PRINTS( "CClockWorldView::RemoveLocationL - Exit" ); |
|
998 } |
|
999 |
|
1000 // --------------------------------------------------------- |
|
1001 // CClockWorldView::SetHomeLocationL |
|
1002 // rest of the details are commented in the header |
|
1003 // --------------------------------------------------------- |
|
1004 // |
|
1005 void CClockWorldView::SetHomeLocationL() |
|
1006 { |
|
1007 __PRINTS( "CClockWorldView::SetHomeLocationL - Entry" ); |
|
1008 |
|
1009 // Here first we check if Network time update is switched on. If so we ask the user if it needs to switched off |
|
1010 // before we reset the home location. |
|
1011 // First connect to the clockserver. |
|
1012 RClkSrvInterface clkSrvInterface; |
|
1013 User::LeaveIfError( clkSrvInterface.Connect() ); |
|
1014 |
|
1015 TBool timeUpdateOn( EFalse ); |
|
1016 |
|
1017 // Get the state of the plugin. |
|
1018 clkSrvInterface.IsAutoTimeUpdateOn( timeUpdateOn ); |
|
1019 |
|
1020 if( timeUpdateOn ) |
|
1021 { |
|
1022 CAknQueryDialog* queryDialog = CAknQueryDialog::NewL(); |
|
1023 // TODO: Resource. |
|
1024 if( !queryDialog->ExecuteLD( R_CLOCK_DIALOG_QUERY_NW_TIME_OFF ) ) |
|
1025 { |
|
1026 // User pressed 'No', we don't reset the home zone. |
|
1027 clkSrvInterface.Close(); |
|
1028 |
|
1029 __PRINTS( "CClockWorldView::NewL - Entry" ); |
|
1030 |
|
1031 return; |
|
1032 } |
|
1033 } |
|
1034 |
|
1035 // Now we confirm again with the user whether he really wants to update the home zone. |
|
1036 CAknQueryDialog* queryDialog = CAknQueryDialog::NewL(); |
|
1037 // TODO: Resource. |
|
1038 if( queryDialog->ExecuteLD( R_CLOCK_DIALOG_QUERY_REGION_AF_TIME ) ) |
|
1039 { |
|
1040 // First store the info of the currently focused item. |
|
1041 TInt cityIndex( iContainer->ListBox()->CurrentItemIndex() ); |
|
1042 TCityInfo cityInformation( iWorldArray->GetCity( cityIndex ) ); |
|
1043 |
|
1044 // The document. |
|
1045 CClockDocument* clockDocument = static_cast< CClockDocument* > ( AppUi()->Document() ); |
|
1046 |
|
1047 if( timeUpdateOn ) |
|
1048 { |
|
1049 // First switch automatic time update off. |
|
1050 clkSrvInterface.DeActivateAllProtocols(); |
|
1051 |
|
1052 // Here, the home city wasn't displayed previously, because automatic-time update |
|
1053 // was on. We've switched it Off and hence the home city has to be displayed. |
|
1054 |
|
1055 // Two things to be done here. |
|
1056 // First is to delete the currently selected item from its position. |
|
1057 // and then insert it at the zeroth position. |
|
1058 |
|
1059 // We ask the document object to reset the homezone. |
|
1060 clockDocument->SetHomeCityL( cityInformation ); |
|
1061 |
|
1062 // Now delete the item at that location and update the list. |
|
1063 TInt imageIndex( iWorldArray->GetImageIndex( cityIndex ) ); |
|
1064 |
|
1065 // Remove the image icon in case it is not loaded by the other listitems |
|
1066 iContainer->RemoveImage( cityInformation.iImagePath, imageIndex, cityIndex ); |
|
1067 |
|
1068 // Update the world array. |
|
1069 iWorldArray->RemoveCity( cityIndex ); |
|
1070 |
|
1071 // Update the container. |
|
1072 iContainer->ListBox()->HandleItemRemovalL(); |
|
1073 } |
|
1074 else |
|
1075 { |
|
1076 // Here we already have the home city being displayed as the first item. |
|
1077 // The things to be done here are these. |
|
1078 |
|
1079 // The current and the first list items need to be swapped. |
|
1080 // We ask the document object to reset the homezone. |
|
1081 clockDocument->SetHomeCityL( cityInformation ); |
|
1082 |
|
1083 // Now delete the item at the current location and update the list. |
|
1084 TInt imageIndex( iWorldArray->GetImageIndex( cityIndex ) ); |
|
1085 |
|
1086 // Remove the image icon in case it is not loaded by the other listitems |
|
1087 iContainer->RemoveImage( cityInformation.iImagePath, imageIndex, cityIndex ); |
|
1088 |
|
1089 // Update the world array. |
|
1090 iWorldArray->RemoveCity( cityIndex ); |
|
1091 |
|
1092 // Update the container. |
|
1093 iContainer->ListBox()->HandleItemRemovalL(); |
|
1094 |
|
1095 // Store the old city info. |
|
1096 TCityInfo oldHomeCityInfo( iWorldArray->GetCity( KZerothIndex ) ); |
|
1097 |
|
1098 // Now delete the first item and update the list. |
|
1099 iWorldArray->RemoveCity( KZerothIndex ); |
|
1100 |
|
1101 // Update the container. |
|
1102 iContainer->ListBox()->HandleItemRemovalL(); |
|
1103 |
|
1104 // Insert the old home city at the location where the new home city was. |
|
1105 iWorldArray->InsertOldHomeCityItem( oldHomeCityInfo, cityIndex - 1 ); |
|
1106 // Update the container. |
|
1107 iContainer->ListBox()->HandleItemAdditionL(); |
|
1108 } |
|
1109 // Insert the homecity at the top of the list and update it. |
|
1110 iWorldArray->InsertHomeCityItem(); |
|
1111 // Update the container. |
|
1112 iContainer->ListBox()->HandleItemAdditionL(); |
|
1113 iContainer->ListBox()->ScrollToMakeItemVisible( KZerothIndex ); |
|
1114 iContainer->ListBox()->SetCurrentItemIndexAndDraw( KZerothIndex ); |
|
1115 |
|
1116 // Update the Document. |
|
1117 clockDocument->StoreDataL(); |
|
1118 clockDocument->SetHomeCityItemAdded( ETrue ); |
|
1119 // Update the CBA( the MSK text ) |
|
1120 |
|
1121 |
|
1122 // Display confirmation to the user. |
|
1123 // Location name is country name if there is only one city in the list. |
|
1124 // else the city name. |
|
1125 CTzLocalizer* tzLocalizer = CTzLocalizer::NewL(); |
|
1126 CleanupStack::PushL( tzLocalizer ); |
|
1127 |
|
1128 // Get the city list for the country. |
|
1129 CTzLocalizedCityArray* cityList = tzLocalizer->GetCitiesInGroupL( cityInformation.iCityGroupId, CTzLocalizer::ETzAlphaNameAscending ); |
|
1130 CleanupStack::PushL( cityList ); |
|
1131 |
|
1132 // We choose what to display depending on the number of cities in the country. |
|
1133 HBufC* noteText( NULL ); |
|
1134 if( 1 == cityList->Count() ) |
|
1135 { |
|
1136 // TODO: Resource. |
|
1137 noteText = StringLoader::LoadLC( R_CLOCK_NOTE_TIME_CHANGED_COUNTRY, cityInformation.iCountry, iCoeEnv ); |
|
1138 } |
|
1139 else |
|
1140 { |
|
1141 // TODO: Resource. |
|
1142 noteText = StringLoader::LoadLC( R_CLOCK_NOTE_TIME_CHANGED_COUNTRY, cityInformation.iCity, iCoeEnv ); |
|
1143 } |
|
1144 |
|
1145 // Refresh the view. |
|
1146 |
|
1147 iContainer->Refresh(); |
|
1148 |
|
1149 // Display the Information note. |
|
1150 CAknInformationNote* informationNote = new( ELeave ) CAknInformationNote; |
|
1151 informationNote->ExecuteLD( *noteText ); |
|
1152 |
|
1153 // Cleanup. |
|
1154 CleanupStack::PopAndDestroy( noteText ); |
|
1155 CleanupStack::PopAndDestroy( cityList ); |
|
1156 CleanupStack::PopAndDestroy( tzLocalizer ); |
|
1157 } |
|
1158 |
|
1159 // Cleanup. |
|
1160 clkSrvInterface.Close(); |
|
1161 |
|
1162 __PRINTS( "CClockWorldView::SetHomeLocationL - Exit" ); |
|
1163 } |
|
1164 |
|
1165 // --------------------------------------------------------- |
|
1166 // CClockWorldView::AddImageL |
|
1167 // rest of the details are commented in the header |
|
1168 // --------------------------------------------------------- |
|
1169 // |
|
1170 void CClockWorldView::AddImageL() |
|
1171 { |
|
1172 __PRINTS( "CClockWorldView::AddImageL - Entry" ); |
|
1173 |
|
1174 CDesCArray* selectedFile = new( ELeave ) CDesCArrayFlat( 1 ); |
|
1175 CleanupStack::PushL( selectedFile ); |
|
1176 TBool result( EFalse ); |
|
1177 TInt currentIndex = iContainer->ListBox()->CurrentItemIndex(); |
|
1178 |
|
1179 // Hide the navigation pane. |
|
1180 CClockAppUi* appUi = static_cast< CClockAppUi* > ( AppUi() ); |
|
1181 appUi->MakeNavigationPaneVisible( EFalse, EClockAppWorldViewId ); |
|
1182 |
|
1183 // Launch and Fetch image from media gallery. |
|
1184 iGalleryOpen = ETrue; |
|
1185 |
|
1186 iCanceler = NULL; |
|
1187 result = MGFetch::RunL( *selectedFile, EImageFile, EFalse,KNullDesC(),KNullDesC(),NULL,iCanceler,NULL); |
|
1188 |
|
1189 iGalleryOpen = EFalse; |
|
1190 |
|
1191 // Show the navigation pane. |
|
1192 appUi->MakeNavigationPaneVisible( ETrue, EClockAppWorldViewId ); |
|
1193 |
|
1194 // If an image is selected by the user |
|
1195 if( result ) |
|
1196 { |
|
1197 TPtrC fileName = ( *selectedFile )[ KErrNone ]; |
|
1198 |
|
1199 |
|
1200 // Add the image for the currently focussed list item. |
|
1201 iContainer->UpdateImageL( fileName, currentIndex ); |
|
1202 iContainer->ListBox()->SetCurrentItemIndexAndDraw( currentIndex ); |
|
1203 |
|
1204 // Update the Document. |
|
1205 CClockDocument *clockDocument = static_cast< CClockDocument* > ( AppUi()->Document() ); |
|
1206 clockDocument->StoreDataL(); |
|
1207 } |
|
1208 |
|
1209 CleanupStack::PopAndDestroy( selectedFile ); |
|
1210 |
|
1211 __PRINTS( "CClockWorldView::AddImageL - Exit" ); |
|
1212 } |
|
1213 |
|
1214 // --------------------------------------------------------- |
|
1215 // CClockWorldView::RestartTimerL |
|
1216 // rest of the details are commented in the header |
|
1217 // --------------------------------------------------------- |
|
1218 // |
|
1219 void CClockWorldView::RestartTimerL() |
|
1220 { |
|
1221 if( !iTimer->IsActive() ) |
|
1222 { |
|
1223 TTime currentTime; |
|
1224 currentTime.HomeTime(); |
|
1225 |
|
1226 TDateTime currentDateTime( currentTime.DateTime() ); |
|
1227 iTimer->After(KIntervalTime - 1000000 * currentDateTime.Second() - currentDateTime.MicroSecond()); |
|
1228 } |
|
1229 } |
|
1230 |
|
1231 // --------------------------------------------------------- |
|
1232 // CClockWorldView::StopTimerL |
|
1233 // rest of the details are commented in the header |
|
1234 // --------------------------------------------------------- |
|
1235 // |
|
1236 void CClockWorldView::StopTimerL() |
|
1237 { |
|
1238 if( iTimer->IsActive() ) |
|
1239 { |
|
1240 iTimer->Cancel(); |
|
1241 } |
|
1242 } |
|
1243 |
|
1244 // End of file |