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