|
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: The source file for the CClkDateTimeView class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System Includes |
|
19 #include <e32std.h> |
|
20 #include <aknsettingpage.h> |
|
21 #include <bacntf.h> |
|
22 #include <aknViewAppUi.h> |
|
23 #include <hlplch.h> |
|
24 #include <aknnotewrappers.h> |
|
25 #include <aknpopupsettingpage.h> |
|
26 #include <aknmfnesettingpage.h> |
|
27 #include <AknQueryDialog.h> |
|
28 #include <bautils.h> |
|
29 #include <AknWaitDialog.h> |
|
30 #include <aknslidersettingpage.h> |
|
31 #include <akntitle.h> |
|
32 #include <aknPopup.h> |
|
33 #include <aknlists.h> |
|
34 #include <e32math.h> |
|
35 #include <e32property.h> |
|
36 #include <CoreApplicationUIsSDKCRKeys.h> |
|
37 #include <CFLDFileListContainer.h> |
|
38 #include <akncheckboxsettingpage.h> |
|
39 #include <starterclient.h> |
|
40 #include <vtzrules.h> |
|
41 #include <clockdomaincrkeys.h> |
|
42 #include <centralrepository.h> |
|
43 #include <tzdefines.h> |
|
44 #include <f32file.h> |
|
45 #include <AknUtils.h> |
|
46 #include <AknDateFormatUtils.h> |
|
47 #include <featmgr.h> |
|
48 #include <DRMHelper.h> |
|
49 #include <StringLoader.h> |
|
50 #include <tz.h> |
|
51 #include <tzlocalizer.h> |
|
52 #include <tzlocalizationdatatypes.h> |
|
53 #include <data_caging_path_literals.hrh> |
|
54 #include <ProfileEngineDomainConstants.h> |
|
55 #include <clock.rsg> |
|
56 #include <AknGlobalNote.h> |
|
57 #include <featdiscovery.h> |
|
58 #include <ProfileEngineDomainCRKeys.h> |
|
59 #include <mediafilelist.h> |
|
60 |
|
61 // User Includes |
|
62 #include "clkuiclksrvmodel.h" |
|
63 #include "clkuialarmmodel.h" |
|
64 #include "clkdatetimeviewcontainer.h" |
|
65 #include "clkuiclksrvidleobserver.h" |
|
66 #include "clkdatetimeview.hrh" |
|
67 #include "clkdatetimeviewextension.h" |
|
68 #include "clkdatetimeviewpopuplistinher.h" |
|
69 #include "clockprivatecrkeys.h" |
|
70 #include "clkcommon.h" |
|
71 #include "clock.h" |
|
72 #include "clkdatetimeview.h" |
|
73 #include "clockappui.h" |
|
74 |
|
75 // Constants |
|
76 const TInt KClkSrvListenerPriority( -0x0003 ); |
|
77 const TInt KClkSrvIdleObserverPriority( -0x0005 ); |
|
78 const TInt KInitialBufferLength( 250 ); |
|
79 const TInt KSeparIndex( 1 ); |
|
80 const TInt KIntervalTime( 60000000 ); |
|
81 const TInt KArrayGranularity( 24 ); |
|
82 const TInt KMaxDataLength( 120 ); |
|
83 const TInt KHour( 60 ); |
|
84 |
|
85 const TInt KHoursInDay( 24 ); |
|
86 const TInt KNoDifference( 0 ); |
|
87 const TUid KClkDateTimeViewPluginId = { 271065965 }; |
|
88 const TInt KZeroVal( 0 ); |
|
89 const TInt KCountryAndOffsetLength( 50 ); |
|
90 const TInt KOffsetStringLength( 64 ); |
|
91 |
|
92 // Literals |
|
93 _LIT( KHeader, " \t" ); |
|
94 _LIT( KEmptyField, " " ); |
|
95 _LIT( KDelimiter, "\t\t" ); |
|
96 _LIT( KFLDResourceFileName, "clock.rsc" ); |
|
97 _LIT( KPlusGMT, " \x202A+" ); |
|
98 _LIT( KMinusGMT, " \x202A" ); |
|
99 _LIT( KPDF, " \x202C" ); |
|
100 _LIT( KZeroGMT, " " ); |
|
101 _LIT( KZero, "0" ); |
|
102 _LIT( KResourceDrive, "Z:" ); |
|
103 _LIT( KHardCodedDigitalAlarmTone, "z:\\data\\sounds\\digital\\clock.aac" ); |
|
104 |
|
105 // --------------------------------------------------------- |
|
106 // CClkDateTimeView::NewLC |
|
107 // rest of the details are commented in the header |
|
108 // --------------------------------------------------------- |
|
109 EXPORT_C CClkDateTimeView* CClkDateTimeView::NewLC( TUid aViewId, TBool aClockUse ) |
|
110 { |
|
111 CClkDateTimeView* self = new ( ELeave ) CClkDateTimeView; |
|
112 CleanupStack::PushL( self ); |
|
113 self->ConstructL( aViewId, aClockUse ); |
|
114 return self; |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------- |
|
118 // CClkDateTimeView::~CClkDateTimeView |
|
119 // rest of the details are commented in the header |
|
120 // --------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C CClkDateTimeView::~CClkDateTimeView() |
|
123 { |
|
124 if( iDateFrmtItemLists ) |
|
125 { |
|
126 delete iDateFrmtItemLists; |
|
127 iDateFrmtItemLists = NULL; |
|
128 } |
|
129 if( iDateSeparItemLists ) |
|
130 { |
|
131 delete iDateSeparItemLists; |
|
132 iDateSeparItemLists = NULL; |
|
133 } |
|
134 if( iTimeSeparItemLists ) |
|
135 { |
|
136 delete iTimeSeparItemLists; |
|
137 iTimeSeparItemLists = NULL; |
|
138 } |
|
139 |
|
140 DeleteResourceBuf(); |
|
141 |
|
142 if( iExtension ) |
|
143 { |
|
144 delete iExtension; |
|
145 iExtension = NULL; |
|
146 } |
|
147 |
|
148 iCoeEnv->DeleteResourceFile( iOffset ); |
|
149 |
|
150 if( iContainer ) |
|
151 { |
|
152 AppUi()->RemoveFromStack( iContainer ); |
|
153 delete iContainer; |
|
154 iContainer = NULL; |
|
155 } |
|
156 if( iTimer ) |
|
157 { |
|
158 delete iTimer; |
|
159 iTimer = NULL; |
|
160 } |
|
161 if( iNotifier ) |
|
162 { |
|
163 delete iNotifier; |
|
164 iNotifier = NULL; |
|
165 } |
|
166 if( iSrvModel ) |
|
167 { |
|
168 delete iSrvModel; |
|
169 iSrvModel = NULL; |
|
170 } |
|
171 if( iModelObserver ) |
|
172 { |
|
173 delete iModelObserver; |
|
174 iModelObserver = NULL; |
|
175 } |
|
176 if( iSoundOffTxt ) |
|
177 { |
|
178 delete iSoundOffTxt; |
|
179 iSoundOffTxt = NULL; |
|
180 } |
|
181 if( iDefaultToneTxt ) |
|
182 { |
|
183 delete iDefaultToneTxt; |
|
184 iDefaultToneTxt = NULL; |
|
185 } |
|
186 if( iToneListHeader ) |
|
187 { |
|
188 delete iToneListHeader; |
|
189 iToneListHeader = NULL; |
|
190 } |
|
191 if( iGMTString ) |
|
192 { |
|
193 delete iGMTString; |
|
194 iGMTString = NULL; |
|
195 } |
|
196 if( iZoneString ) |
|
197 { |
|
198 delete iZoneString; |
|
199 iZoneString = NULL; |
|
200 } |
|
201 |
|
202 FeatureManager::UnInitializeLib(); |
|
203 |
|
204 if( iDRMHelper ) |
|
205 { |
|
206 delete iDRMHelper; |
|
207 iDRMHelper = NULL; |
|
208 } |
|
209 if( iItem ) |
|
210 { |
|
211 delete iItem; |
|
212 iItem = NULL; |
|
213 } |
|
214 } |
|
215 |
|
216 // --------------------------------------------------------- |
|
217 // CClkDateTimeView::Id |
|
218 // rest of the details are commented in the header |
|
219 // --------------------------------------------------------- |
|
220 // |
|
221 TUid CClkDateTimeView::Id() const |
|
222 { |
|
223 if( iExtension->UsedByGS() ) |
|
224 { |
|
225 return KClkDateTimeViewPluginId; |
|
226 } |
|
227 else |
|
228 { |
|
229 return KClkDateTimeViewId; |
|
230 } |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------- |
|
234 // CClkDateTimeView::HandleCommandL |
|
235 // rest of the details are commented in the header |
|
236 // --------------------------------------------------------- |
|
237 // |
|
238 void CClkDateTimeView::HandleCommandL( TInt aCommandId ) |
|
239 { |
|
240 if( iExtension->AlarmToneListInUse() ) |
|
241 { |
|
242 // Tone list is in use. Do not handle any other events. |
|
243 return; |
|
244 } |
|
245 |
|
246 switch ( aCommandId ) |
|
247 { |
|
248 case EAknSoftkeyBack: |
|
249 { |
|
250 HandleBackCmdL(); |
|
251 } |
|
252 break; |
|
253 |
|
254 case EAknSoftkeyChange: |
|
255 { |
|
256 if( iItemList->MdcaCount() ) |
|
257 { |
|
258 iMenuChange = EFalse; |
|
259 HandleChangeCmdL( iContainer->ListBox()->CurrentItemIndex() ); |
|
260 } |
|
261 } |
|
262 break; |
|
263 |
|
264 case EClkSettChangeCmd: |
|
265 { |
|
266 if( iItemList->MdcaCount() ) |
|
267 { |
|
268 iMenuChange = ETrue; |
|
269 HandleChangeCmdL( iContainer->ListBox()->CurrentItemIndex() ); |
|
270 } |
|
271 } |
|
272 break; |
|
273 |
|
274 case EAknCmdHelp: |
|
275 { |
|
276 if( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
277 { |
|
278 CArrayFix< TCoeHelpContext >* buf = AppUi()->AppHelpContextL(); |
|
279 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), buf ); |
|
280 } |
|
281 } |
|
282 break; |
|
283 |
|
284 case EClkSettDateCmd: |
|
285 { |
|
286 HandleDateCmdL(); |
|
287 } |
|
288 break; |
|
289 |
|
290 case EClkSettTimeCmd: |
|
291 { |
|
292 HandleTimeCmdL(); |
|
293 } |
|
294 break; |
|
295 |
|
296 case EClkSettZoneCmd: |
|
297 { |
|
298 HandleZoneCmdL(); |
|
299 } |
|
300 break; |
|
301 |
|
302 case EClkSettDateFrmtCmd: |
|
303 { |
|
304 HandleDateFrmtCmdL(); |
|
305 } |
|
306 break; |
|
307 |
|
308 case EClkSettDateSeparCmd: |
|
309 { |
|
310 HandleDateSeparCmdL(); |
|
311 } |
|
312 break; |
|
313 |
|
314 case EClkSettTimeFrmtCmd: |
|
315 { |
|
316 HandleTimeFrmtCmdL(); |
|
317 } |
|
318 break; |
|
319 |
|
320 case EClkSettTimeSeparCmd: |
|
321 { |
|
322 HandleTimeSeparCmdL(); |
|
323 } |
|
324 break; |
|
325 |
|
326 case EClkSettAutomaticTimeUpdateCmd: |
|
327 { |
|
328 HandleAutomaticTimeUpdateCmdL(); |
|
329 } |
|
330 break; |
|
331 |
|
332 case EClkSettWorkDaysCmd: |
|
333 { |
|
334 HandleWorkDaysCmdL(); |
|
335 } |
|
336 break; |
|
337 |
|
338 case EClkSettClockTypeCmd: |
|
339 { |
|
340 HandleClockTypeCmdL(); |
|
341 } |
|
342 break; |
|
343 |
|
344 case EClkSettToneCmd: |
|
345 { |
|
346 HandleClockAlarmToneCmdL(); |
|
347 } |
|
348 break; |
|
349 |
|
350 case EClkSettSnoozeTimeCmd: |
|
351 { |
|
352 HandleClockSnoozeTimeCmdL(); |
|
353 } |
|
354 break; |
|
355 |
|
356 case EClkSettExitCmd: |
|
357 { |
|
358 if( iExtension->UsedByGS() ) |
|
359 { |
|
360 // The GS should handle the command. |
|
361 AppUi()->HandleCommandL( EAknCmdExit ); |
|
362 } |
|
363 else |
|
364 { |
|
365 // CClockAppUi should handle the command. |
|
366 AppUi()->HandleCommandL( EClkSettExitCmd ); |
|
367 } |
|
368 } |
|
369 break; |
|
370 |
|
371 default: |
|
372 { |
|
373 __ASSERT_DEBUG( EClkSettDateCmd > aCommandId, Panic( EClkDateTimeViewBadCommandId ) ); |
|
374 } |
|
375 break; |
|
376 } |
|
377 } |
|
378 |
|
379 // --------------------------------------------------------- |
|
380 // CClkDateTimeView::HandleUpdateL |
|
381 // rest of the details are commented in the header |
|
382 // --------------------------------------------------------- |
|
383 // |
|
384 void CClkDateTimeView::HandleUpdateL( TInt /*aNotification*/ ) |
|
385 { |
|
386 HandleSettingsChangeL( !EChangesMidnightCrossover ); |
|
387 } |
|
388 |
|
389 //---------------------------------------------------------- |
|
390 // CClkDateTimeView::InitCurrentItem |
|
391 // rest of the details are commented in the header |
|
392 // --------------------------------------------------------- |
|
393 // |
|
394 EXPORT_C void CClkDateTimeView::InitCurrentItem() |
|
395 { |
|
396 iCurrentItem = 0; |
|
397 iTopItem = 0; |
|
398 } |
|
399 |
|
400 // --------------------------------------------------------- |
|
401 // CClkDateTimeView::HandleSettingsChangeL |
|
402 // rest of the details are commented in the header |
|
403 // --------------------------------------------------------- |
|
404 // |
|
405 void CClkDateTimeView::HandleSettingsChangeL( const TInt aChange ) |
|
406 { |
|
407 if( iContainer ) |
|
408 { |
|
409 SettingsL(); |
|
410 UpdateAllL(); |
|
411 |
|
412 //Updates the time and time zone when DST is on/off |
|
413 ConstructGmtStringL(); |
|
414 |
|
415 UpdateListBoxL( EClkSettZone ); |
|
416 |
|
417 if ( ( EChangesMidnightCrossover & aChange ) && ( iContainer->ListBox()->TopItemIndex() < EClkSettDateFrmt ) ) |
|
418 { |
|
419 iContainer->ListBox()->DrawItem( EClkSettDate ); |
|
420 } |
|
421 } |
|
422 } |
|
423 |
|
424 // --------------------------------------------------------- |
|
425 // CClkDateTimeView::IncCurrentItem |
|
426 // rest of the details are commented in the header |
|
427 // --------------------------------------------------------- |
|
428 // |
|
429 void CClkDateTimeView::IncCurrentItem() |
|
430 { |
|
431 if( ( iListItemCount - 1 ) > iCurrentItem ) |
|
432 { |
|
433 iCurrentItem++; |
|
434 } |
|
435 if( ( !IsClockInUse() ) && ( ( iCurrentItem - 1 ) == iContainer->ListBox()->BottomItemIndex() ) ) |
|
436 { |
|
437 if( iCurrentItem < iNumOfItemsInView ) |
|
438 { |
|
439 iTopItem = 0; |
|
440 } |
|
441 else if( iTopItem < ( iListItemCount - iNumOfItemsInView ) ) |
|
442 { |
|
443 iTopItem++; |
|
444 } |
|
445 } |
|
446 } |
|
447 |
|
448 // --------------------------------------------------------- |
|
449 // CClkDateTimeView::DecCurrentItem |
|
450 // rest of the details are commented in the header |
|
451 // --------------------------------------------------------- |
|
452 // |
|
453 void CClkDateTimeView::DecCurrentItem() |
|
454 { |
|
455 if( 0 < iCurrentItem ) |
|
456 { |
|
457 iCurrentItem--; |
|
458 } |
|
459 if( ( !IsClockInUse() ) && ( ( iCurrentItem + 1 ) == iContainer->ListBox()->TopItemIndex() ) ) |
|
460 { |
|
461 if ( iCurrentItem >= ( iListItemCount - iNumOfItemsInView ) ) |
|
462 { |
|
463 iTopItem = iListItemCount - iNumOfItemsInView; |
|
464 } |
|
465 else if ( iTopItem > 0 ) |
|
466 { |
|
467 iTopItem--; |
|
468 } |
|
469 } |
|
470 } |
|
471 |
|
472 // --------------------------------------------------------- |
|
473 // CClkDateTimeView::IsClockInUse |
|
474 // rest of the details are commented in the header |
|
475 // --------------------------------------------------------- |
|
476 // |
|
477 TBool CClkDateTimeView::IsClockInUse() const |
|
478 { |
|
479 return iIsClockInUse; |
|
480 } |
|
481 |
|
482 // --------------------------------------------------------- |
|
483 // CClkDateTimeView::PrevViewId |
|
484 // rest of the details are commented in the header |
|
485 // --------------------------------------------------------- |
|
486 // |
|
487 TVwsViewId CClkDateTimeView::PrevViewId() const |
|
488 { |
|
489 return iPrevViewId; |
|
490 } |
|
491 |
|
492 // --------------------------------------------------------- |
|
493 // CClkDateTimeView::HandleChangeCmdL |
|
494 // rest of the details are commented in the header |
|
495 // --------------------------------------------------------- |
|
496 // |
|
497 void CClkDateTimeView::HandleChangeCmdL( const TInt aItemId ) |
|
498 { |
|
499 switch( aItemId ) |
|
500 { |
|
501 case EClkSettDate: |
|
502 { |
|
503 HandleCommandL( EClkSettDateCmd ); |
|
504 } |
|
505 break; |
|
506 |
|
507 case EClkSettDateFrmt: |
|
508 { |
|
509 HandleCommandL( EClkSettDateFrmtCmd ); |
|
510 } |
|
511 break; |
|
512 |
|
513 case EClkSettDateSepar: |
|
514 { |
|
515 HandleCommandL( EClkSettDateSeparCmd ); |
|
516 } |
|
517 break; |
|
518 |
|
519 case EClkSettTime: |
|
520 { |
|
521 HandleCommandL( EClkSettTimeCmd ); |
|
522 } |
|
523 break; |
|
524 |
|
525 case EClkSettZone: |
|
526 { |
|
527 HandleCommandL( EClkSettZoneCmd ); |
|
528 } |
|
529 break; |
|
530 |
|
531 case EClkSettTimeFrmt: |
|
532 { |
|
533 HandleCommandL( EClkSettTimeFrmtCmd ); |
|
534 } |
|
535 break; |
|
536 |
|
537 case EClkSettTimeSepar: |
|
538 { |
|
539 HandleCommandL( EClkSettTimeSeparCmd ); |
|
540 } |
|
541 break; |
|
542 |
|
543 case EClkSettClockType: |
|
544 { |
|
545 HandleCommandL( EClkSettClockTypeCmd ); |
|
546 } |
|
547 break; |
|
548 |
|
549 case EClkSettTone: |
|
550 { |
|
551 HandleCommandL( EClkSettToneCmd ); |
|
552 } |
|
553 break; |
|
554 |
|
555 case EClkSettAutomaticTimeUpdate: |
|
556 { |
|
557 HandleCommandL( EClkSettAutomaticTimeUpdateCmd ); |
|
558 } |
|
559 break; |
|
560 |
|
561 case EClkSettSnoozeTime: |
|
562 { |
|
563 HandleCommandL( EClkSettSnoozeTimeCmd ); |
|
564 } |
|
565 break; |
|
566 |
|
567 case EClkSettWorkDays: |
|
568 { |
|
569 HandleCommandL( EClkSettWorkDaysCmd ); |
|
570 } |
|
571 break; |
|
572 |
|
573 default: |
|
574 { |
|
575 __ASSERT_DEBUG( EFalse, Panic( EClkDateTimeViewBadItemIndex ) ); |
|
576 } |
|
577 break; |
|
578 } |
|
579 } |
|
580 |
|
581 // --------------------------------------------------------- |
|
582 // CClkDateTimeView::DoActivateL |
|
583 // rest of the details are commented in the header |
|
584 // --------------------------------------------------------- |
|
585 // |
|
586 void CClkDateTimeView::DoActivateL( const TVwsViewId& aPrevViewId, |
|
587 TUid /*aCustomMessageId*/, |
|
588 const TDesC8& /*aCustomMessage*/ ) |
|
589 { |
|
590 // Checks whether aPrevViewId.iAppUid is the same AppUid, to which this view belongs. |
|
591 if( iPrevViewId.iAppUid == aPrevViewId.iAppUid ) |
|
592 { |
|
593 iPrevViewId = aPrevViewId; |
|
594 } |
|
595 |
|
596 if( !iModelObserver ) |
|
597 { |
|
598 iModelObserver = CClkUiClkSrvIdleObserver::NewL( this, KClkSrvIdleObserverPriority ); |
|
599 iSrvModel->SetModelObserver( iModelObserver ); |
|
600 } |
|
601 |
|
602 iExtension->StartListeningL(); |
|
603 |
|
604 if( !iContainer ) |
|
605 { |
|
606 iContainer = CClkDateTimeViewContainer::NewL( this ); |
|
607 iContainer->SetMopParent( this ); |
|
608 |
|
609 CAknSettingStyleListBox* listBox = new( ELeave ) CAknSettingStyleListBox; |
|
610 CleanupStack::PushL( listBox ); |
|
611 listBox->ConstructL( iContainer, EAknListBoxSelectionList ); |
|
612 listBox->CreateScrollBarFrameL( ETrue ); |
|
613 listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
614 listBox->SetListBoxObserver( this ); |
|
615 iItemList = listBox->Model()->ItemTextArray(); |
|
616 iItemArray = ( CDesCArray* ) iItemList; |
|
617 iContainer->SetListBox( listBox ); |
|
618 CleanupStack::Pop( listBox ); |
|
619 |
|
620 SettingsL(); |
|
621 ConstructGmtStringL(); |
|
622 iExtension->ConstructWorkDaysStrL(); |
|
623 PopulateListBoxL(); |
|
624 |
|
625 TRect mainPaneRect; |
|
626 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
627 iContainer->SetRect( mainPaneRect ); |
|
628 } |
|
629 |
|
630 AppUi()->AddToStackL( *this, iContainer ); |
|
631 |
|
632 // Make the time item synchronize the current time every a minute. |
|
633 if( !iTimer ) |
|
634 { |
|
635 TTime time; |
|
636 time.HomeTime(); |
|
637 TDateTime dateTime = time.DateTime(); |
|
638 TCallBack callBack( TimerCallback, this ); |
|
639 iTimer = CPeriodic::NewL( CActive::EPriorityHigh ); |
|
640 iTimer->Start( TTimeIntervalMicroSeconds32( KIntervalTime - 1000000 * dateTime.Second() - dateTime.MicroSecond() ), |
|
641 TTimeIntervalMicroSeconds32( KIntervalTime ), callBack ); |
|
642 } |
|
643 |
|
644 if( !IsClockInUse() ) |
|
645 { |
|
646 iNumOfItemsInView = iContainer->ListBox()->BottomItemIndex() - iContainer->ListBox()->TopItemIndex() + 1; |
|
647 iContainer->ListBox()->SetTopItemIndex( iTopItem ); |
|
648 } |
|
649 if( 0 < iCurrentItem ) |
|
650 { |
|
651 iContainer->ListBox()->SetCurrentItemIndex( iCurrentItem ); |
|
652 } |
|
653 iContainer->ActivateL(); |
|
654 |
|
655 // Check if the alarm note exists. |
|
656 CheckAlarmToneExistsL(); |
|
657 } |
|
658 |
|
659 // --------------------------------------------------------- |
|
660 // CClkDateTimeView::DoDeactivate |
|
661 // rest of the details are commented in the header |
|
662 // --------------------------------------------------------- |
|
663 // |
|
664 void CClkDateTimeView::DoDeactivate() |
|
665 { |
|
666 if( iModelObserver ) |
|
667 { |
|
668 iSrvModel->SetModelObserver( NULL ); |
|
669 delete iModelObserver; |
|
670 iModelObserver = NULL; |
|
671 } |
|
672 if ( iContainer ) |
|
673 { |
|
674 AppUi()->RemoveFromStack( iContainer ); |
|
675 } |
|
676 |
|
677 iExtension->StopListening(); |
|
678 |
|
679 if( iTimer ) |
|
680 { |
|
681 delete iTimer; |
|
682 iTimer = NULL; |
|
683 } |
|
684 if( iContainer ) |
|
685 { |
|
686 delete iContainer; |
|
687 iContainer = NULL; |
|
688 } |
|
689 } |
|
690 |
|
691 // --------------------------------------------------------- |
|
692 // CClkDateTimeView::HandleListBoxEventL |
|
693 // rest of the details are commented in the header |
|
694 // --------------------------------------------------------- |
|
695 // |
|
696 void CClkDateTimeView::HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType ) |
|
697 { |
|
698 if ( ( aListBox == iContainer->ListBox() ) && |
|
699 ( EEventEnterKeyPressed == aEventType || |
|
700 |
|
701 EEventItemSingleClicked == aEventType ) ) |
|
702 |
|
703 { |
|
704 HandleChangeCmdL( iContainer->ListBox()->CurrentItemIndex() ); |
|
705 } |
|
706 } |
|
707 |
|
708 // --------------------------------------------------------- |
|
709 // CClkDateTimeView::ConstructL |
|
710 // rest of the details are commented in the header |
|
711 // --------------------------------------------------------- |
|
712 // |
|
713 void CClkDateTimeView::ConstructL( TUid aViewId, TBool aClockUse ) |
|
714 { |
|
715 TFileName filename( KRESOURCE ); |
|
716 |
|
717 FeatureManager::InitializeLibL(); |
|
718 BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), filename ); |
|
719 iOffset = iCoeEnv->AddResourceFileL( filename ); |
|
720 |
|
721 GetResourcesL(); |
|
722 BaseConstructL( R_CLK_DATE_TIME_SETT_VIEW ); |
|
723 |
|
724 iExtension = CClkDateTimeViewExtension::NewL( this, iCoeEnv ); |
|
725 TUid id = { 0x102818E9 }; |
|
726 |
|
727 if( aViewId == id ) |
|
728 { |
|
729 iExtension->SetUsedByGS(); |
|
730 } |
|
731 |
|
732 // Set AppUid to which this view belongs. |
|
733 iPrevViewId = ViewId(); |
|
734 iIsClockInUse = aClockUse; |
|
735 iViewId = aViewId; |
|
736 |
|
737 iDateFrmtItemLists = iCoeEnv->ReadDesCArrayResourceL( R_DATE_TIME_DATE_FRMT_ARRAY ); |
|
738 iDateSeparItemLists = iCoeEnv->ReadDesCArrayResourceL( R_DATE_TIME_DATE_SEPAR_ARRAY ); |
|
739 iTimeSeparItemLists = iCoeEnv->ReadDesCArrayResourceL( R_DATE_TIME_TIME_SEPAR_ARRAY ); |
|
740 |
|
741 iSoundOffTxt = StringLoader::LoadL( R_QTN_TC_OFF, iCoeEnv ); |
|
742 iDefaultToneTxt = StringLoader::LoadL( R_QTN_MODE_DEFAULT_TONE, iCoeEnv ); |
|
743 iToneListHeader = StringLoader::LoadL( R_QTN_TC_POPUP_HEADING, iCoeEnv ); |
|
744 |
|
745 TCallBack callback( DoNotiferCallbackL, this ); |
|
746 iNotifier = CEnvironmentChangeNotifier::NewL( KNotiferPriority, callback ); |
|
747 iNotifier->Start(); |
|
748 iSrvModel = CClkUiClkSrvModel::NewL( NULL, KClkSrvListenerPriority ); |
|
749 iSrvModel->Start(); |
|
750 |
|
751 iListItemCount = 0; |
|
752 iDRMHelper = CDRMHelper::NewL( *CCoeEnv::Static() ); |
|
753 |
|
754 iItem = HBufC::NewL( KInitialBufferLength ); |
|
755 |
|
756 iExtension->SetAlarmToneListInUse( EFalse ); |
|
757 } |
|
758 |
|
759 // --------------------------------------------------------- |
|
760 // CClkDateTimeView::GetResourcesL |
|
761 // rest of the details are commented in the header |
|
762 // --------------------------------------------------------- |
|
763 // |
|
764 void CClkDateTimeView::GetResourcesL() |
|
765 { |
|
766 iDate = StringLoader::LoadL( R_QTN_CLK_SETT_DATE, iCoeEnv ); |
|
767 iDateFrmt = StringLoader::LoadL( R_QTN_CLK_SETT_DATE_FORMAT, iCoeEnv ); |
|
768 iDateSepar = StringLoader::LoadL( R_QTN_CLK_SETT_DATE_SEPARATOR, iCoeEnv ); |
|
769 iTime = StringLoader::LoadL( R_QTN_CLK_SETT_TIME, iCoeEnv ); |
|
770 iZone = StringLoader::LoadL( R_QTN_CLK_SETT_ZONE, iCoeEnv ); |
|
771 iTimeFrmt = StringLoader::LoadL( R_QTN_CLK_SETT_TIME_FORMAT, iCoeEnv ); |
|
772 iTimeSepar = StringLoader::LoadL( R_QTN_CLK_SETT_TIME_SEPARATOR, iCoeEnv ); |
|
773 iAutomaticTimeUpdateString = StringLoader::LoadL( R_QTN_CLK_SETT_NETWORK_TIME, iCoeEnv ); |
|
774 iClockType = StringLoader::LoadL( R_QTN_CLK_SETT_CLOCK_TYPE, iCoeEnv ); |
|
775 iAbbrev24H = StringLoader::LoadL( R_QTN_CLK_SETT_ABBREV_24_HOUR, iCoeEnv ); |
|
776 iAbbrev12H = StringLoader::LoadL( R_QTN_CLK_SETT_ABBREV_12_HOUR, iCoeEnv ); |
|
777 iLocalTime = StringLoader::LoadL( R_QTN_CLK_NITZ_LOCAL_TIME, iCoeEnv ); |
|
778 iAutomaticTimeUpdateOn = StringLoader::LoadL( R_QTN_CLK_SETT_NWT_ON, iCoeEnv ); |
|
779 iAutomaticTimeUpdateOff = StringLoader::LoadL( R_QTN_CLK_SETT_NWT_OFF, iCoeEnv ); |
|
780 iAnalog = StringLoader::LoadL( R_QTN_CLK_SETT_TYPE_ANALOG, iCoeEnv ); |
|
781 iDigital = StringLoader::LoadL( R_QTN_CLK_SETT_TYPE_DIGITAL, iCoeEnv ); |
|
782 iTone = StringLoader::LoadL( R_QTN_CLK_SETT_ALARM_TONE, iCoeEnv ); |
|
783 iTimeZone = StringLoader::LoadL( R_QTN_CLK_SET_GMT, iCoeEnv ); |
|
784 iGMTPrefixTxt = StringLoader::LoadL( R_QTN_CLK_NITZ_GMT, iCoeEnv ); |
|
785 } |
|
786 |
|
787 // --------------------------------------------------------- |
|
788 // CClkDateTimeView::PopulateListBoxL |
|
789 // rest of the details are commented in the header |
|
790 // --------------------------------------------------------- |
|
791 // |
|
792 void CClkDateTimeView::PopulateListBoxL() |
|
793 { |
|
794 MakeTimeItemL(); |
|
795 iItemArray->AppendL( *iItem ); |
|
796 |
|
797 MakeZoneItemL(); |
|
798 iItemArray->AppendL( *iItem ); |
|
799 |
|
800 MakeDateItemL(); |
|
801 iItemArray->AppendL( *iItem ); |
|
802 |
|
803 MakeDateFormatItem(); |
|
804 iItemArray->AppendL( *iItem ); |
|
805 |
|
806 MakeDateSeparItem(); |
|
807 iItemArray->AppendL( *iItem ); |
|
808 |
|
809 MakeTimeFormatItem(); |
|
810 iItemArray->AppendL( *iItem ); |
|
811 |
|
812 MakeTimeSeparItem(); |
|
813 iItemArray->AppendL( *iItem ); |
|
814 |
|
815 MakeClockTypeItem(); |
|
816 iItemArray->AppendL( *iItem ); |
|
817 |
|
818 MakeClockAlarmToneItem(); |
|
819 iItemArray->AppendL( *iItem ); |
|
820 |
|
821 MakeClockSnoozeTimeItemL(); |
|
822 iItemArray->AppendL( *iItem ); |
|
823 |
|
824 MakeWorkDaysItemL(); |
|
825 iItemArray->AppendL( *iItem ); |
|
826 |
|
827 MakeAutomaticTimeUpdateItem(); |
|
828 iItemArray->AppendL( *iItem ); |
|
829 |
|
830 iListItemCount = iItemArray->Count(); |
|
831 } |
|
832 |
|
833 // --------------------------------------------------------- |
|
834 // CClkDateTimeView::UpdateListBoxL |
|
835 // rest of the details are commented in the header |
|
836 // --------------------------------------------------------- |
|
837 // |
|
838 void CClkDateTimeView::UpdateListBoxL( TInt aItemId ) |
|
839 { |
|
840 switch ( aItemId ) |
|
841 { |
|
842 case EClkSettDate: |
|
843 { |
|
844 MakeDateItemL(); |
|
845 } |
|
846 break; |
|
847 |
|
848 case EClkSettDateFrmt: |
|
849 { |
|
850 MakeDateFormatItem(); |
|
851 } |
|
852 break; |
|
853 |
|
854 case EClkSettDateSepar: |
|
855 { |
|
856 MakeDateSeparItem(); |
|
857 } |
|
858 break; |
|
859 |
|
860 case EClkSettTime: |
|
861 { |
|
862 MakeTimeItemL(); |
|
863 } |
|
864 break; |
|
865 |
|
866 case EClkSettZone: |
|
867 { |
|
868 MakeZoneItemL(); |
|
869 } |
|
870 break; |
|
871 |
|
872 case EClkSettTimeFrmt: |
|
873 { |
|
874 MakeTimeFormatItem(); |
|
875 } |
|
876 break; |
|
877 |
|
878 case EClkSettTimeSepar: |
|
879 { |
|
880 MakeTimeSeparItem(); |
|
881 } |
|
882 break; |
|
883 |
|
884 case EClkSettSnoozeTime: |
|
885 { |
|
886 MakeClockSnoozeTimeItemL(); |
|
887 } |
|
888 break; |
|
889 |
|
890 case EClkSettAutomaticTimeUpdate: |
|
891 { |
|
892 MakeAutomaticTimeUpdateItem(); |
|
893 } |
|
894 break; |
|
895 |
|
896 case EClkSettWorkDays: |
|
897 { |
|
898 MakeWorkDaysItemL(); |
|
899 } |
|
900 break; |
|
901 |
|
902 case EClkSettClockType: |
|
903 { |
|
904 MakeClockTypeItem(); |
|
905 } |
|
906 break; |
|
907 |
|
908 case EClkSettTone: |
|
909 { |
|
910 MakeClockAlarmToneItem(); |
|
911 } |
|
912 break; |
|
913 |
|
914 default: |
|
915 { |
|
916 __ASSERT_DEBUG( EFalse, Panic( EClkDateTimeViewBadItemIndex ) ); |
|
917 } |
|
918 break; |
|
919 } |
|
920 iItemArray->Delete( aItemId ); |
|
921 iItemArray->InsertL( aItemId, *iItem ); |
|
922 iContainer->DrawNow(); |
|
923 } |
|
924 |
|
925 // --------------------------------------------------------- |
|
926 // CClkDateTimeView::UpdateAllL |
|
927 // rest of the details are commented in the header |
|
928 // --------------------------------------------------------- |
|
929 // |
|
930 void CClkDateTimeView::UpdateAllL() |
|
931 { |
|
932 iItemArray->Reset(); |
|
933 PopulateListBoxL(); |
|
934 } |
|
935 |
|
936 // --------------------------------------------------------- |
|
937 // CClkDateTimeView::SetDateTimeL |
|
938 // rest of the details are commented in the header |
|
939 // --------------------------------------------------------- |
|
940 // |
|
941 TInt CClkDateTimeView::SetDateTimeL( TTime& aTime ) |
|
942 { |
|
943 TTime noDST( aTime ); |
|
944 RTz tz; |
|
945 User::LeaveIfError( tz.Connect() ); |
|
946 CleanupClosePushL( tz ); |
|
947 TInt ret( tz.SetHomeTime( noDST ) ); |
|
948 CleanupStack::PopAndDestroy( &tz ); |
|
949 if( KErrNone == ret ) |
|
950 { |
|
951 iDateTimeInfo.iTime = aTime; |
|
952 } |
|
953 return ret; |
|
954 } |
|
955 |
|
956 // --------------------------------------------------------- |
|
957 // CClkDateTimeView::SetDateFormat |
|
958 // rest of the details are commented in the header |
|
959 // --------------------------------------------------------- |
|
960 // |
|
961 void CClkDateTimeView::SetDateFormat() |
|
962 { |
|
963 TLocale locale; |
|
964 locale.SetDateFormat( iDateTimeInfo.iDateFormat ); |
|
965 locale.Set(); |
|
966 } |
|
967 |
|
968 // --------------------------------------------------------- |
|
969 // CClkDateTimeView::SetDateSeparator |
|
970 // rest of the details are commented in the header |
|
971 // --------------------------------------------------------- |
|
972 // |
|
973 void CClkDateTimeView::SetDateSeparator() |
|
974 { |
|
975 TLocale locale; |
|
976 TChar separ( ( ( *iDateSeparItemLists )[ iDateTimeInfo.iDateSepar ] )[ 0 ] ); |
|
977 locale.SetDateSeparator( separ, KSeparIndex ); |
|
978 locale.SetDateSeparator( separ, KSeparIndex + 1 ); |
|
979 locale.Set(); |
|
980 } |
|
981 |
|
982 // --------------------------------------------------------- |
|
983 // CClkDateTimeView::SetTimeFormat |
|
984 // rest of the details are commented in the header |
|
985 // --------------------------------------------------------- |
|
986 // |
|
987 void CClkDateTimeView::SetTimeFormat() |
|
988 { |
|
989 TLocale locale; |
|
990 locale.SetTimeFormat( iDateTimeInfo.iTimeFormat ); |
|
991 locale.Set(); |
|
992 } |
|
993 |
|
994 // --------------------------------------------------------- |
|
995 // CClkDateTimeView::SetTimeSeparator |
|
996 // rest of the details are commented in the header |
|
997 // --------------------------------------------------------- |
|
998 // |
|
999 void CClkDateTimeView::SetTimeSeparator() |
|
1000 { |
|
1001 TLocale phoneLocale; |
|
1002 |
|
1003 // Read the latest time separator. |
|
1004 TChar timeSeparator( ( ( *iTimeSeparItemLists ) [ iDateTimeInfo.iTimeSepar ] ) [ KZerothIndex ] ); |
|
1005 // Set the same with the locale. |
|
1006 phoneLocale.SetTimeSeparator( timeSeparator, KSeparIndex ); |
|
1007 phoneLocale.SetTimeSeparator( timeSeparator, KSeparIndex + 1 ); |
|
1008 phoneLocale.Set(); |
|
1009 } |
|
1010 |
|
1011 // --------------------------------------------------------- |
|
1012 // CClkDateTimeView::SetClockType |
|
1013 // rest of the details are commented in the header |
|
1014 // --------------------------------------------------------- |
|
1015 // |
|
1016 void CClkDateTimeView::SetClockType() |
|
1017 { |
|
1018 TLocale phoneLocale; |
|
1019 |
|
1020 // Set the new clock format with the locale. |
|
1021 phoneLocale.SetClockFormat( iDateTimeInfo.iClockFormat ); |
|
1022 phoneLocale.Set(); |
|
1023 } |
|
1024 |
|
1025 // --------------------------------------------------------- |
|
1026 // CClkDateTimeView::GetActiveProtocolL |
|
1027 // rest of the details are commented in the header |
|
1028 // --------------------------------------------------------- |
|
1029 // |
|
1030 void CClkDateTimeView::GetActiveProtocolL() |
|
1031 { |
|
1032 // Read the active protocol from central repository. |
|
1033 CRepository* cenRep( NULL ); |
|
1034 TInt activeProtocol( NULL ); |
|
1035 |
|
1036 // Open the repository. |
|
1037 TRAPD( errVal, cenRep = CRepository::NewL( KCRUidNitz ) ); |
|
1038 if( KErrNone == errVal ) |
|
1039 { |
|
1040 CleanupStack::PushL( cenRep ); |
|
1041 |
|
1042 // Read the key. |
|
1043 errVal = cenRep->Get( KActiveProtocol, activeProtocol ); |
|
1044 iExtension->SetActiveProtocol( activeProtocol ); |
|
1045 |
|
1046 // Cleanup. |
|
1047 CleanupStack::PopAndDestroy( cenRep ); |
|
1048 } |
|
1049 } |
|
1050 |
|
1051 // --------------------------------------------------------- |
|
1052 // CClkDateTimeView::SettingsL |
|
1053 // rest of the details are commented in the header |
|
1054 // --------------------------------------------------------- |
|
1055 // |
|
1056 void CClkDateTimeView::SettingsL() |
|
1057 { |
|
1058 TLocale locale; |
|
1059 iDateTimeInfo.iTime.HomeTime(); |
|
1060 iDateTimeInfo.iDateFormat = locale.DateFormat(); |
|
1061 |
|
1062 iExtension->SetWorkDays( locale.WorkDays() ); |
|
1063 |
|
1064 TBuf< 1 > current; |
|
1065 |
|
1066 current.Fill( locale.DateSeparator( KSeparIndex ), 1 ); |
|
1067 iDateSeparItemLists->Find( current, iDateTimeInfo.iDateSepar ); |
|
1068 iDateTimeInfo.iTimeFormat = locale.TimeFormat(); |
|
1069 |
|
1070 current.Fill( locale.TimeSeparator( KSeparIndex ), 1 ); |
|
1071 iTimeSeparItemLists->Find( current, iDateTimeInfo.iTimeSepar ); |
|
1072 iDateTimeInfo.iClockFormat = locale.ClockFormat(); |
|
1073 |
|
1074 GetActiveProtocolL(); |
|
1075 |
|
1076 iDateTimeInfo.iGMTOffset = User::UTCOffset(); |
|
1077 |
|
1078 CRepository* repository = CRepository::NewL( KCRUidClockApp ); |
|
1079 CleanupStack::PushL( repository ); |
|
1080 |
|
1081 iAlarmToneName.Zero(); |
|
1082 if( repository->Get( KClockAppDefaultSoundFile, iDefaultAlarmToneName ) != KErrNone ) |
|
1083 { |
|
1084 iDefaultAlarmToneName = KHardCodedDigitalAlarmTone; |
|
1085 } |
|
1086 |
|
1087 if( repository->Get( KClockAppSoundFile, iAlarmToneName ) != KErrNone ) |
|
1088 { |
|
1089 iAlarmToneName = iDefaultAlarmToneName; |
|
1090 } |
|
1091 CleanupStack::PopAndDestroy( repository ); |
|
1092 |
|
1093 // Get the current snooze time value |
|
1094 CRepository* snoozeTime = CRepository::NewL( KCRUidClockApp ); |
|
1095 TInt snoozeTimeVale = 0; |
|
1096 snoozeTime->Get( KClockAppSnoozeTime, snoozeTimeVale ); |
|
1097 iExtension->SetSnoozeTimeValue( snoozeTimeVale ); |
|
1098 |
|
1099 delete snoozeTime; |
|
1100 |
|
1101 iExtension->ConstructWorkDaysStrL(); |
|
1102 } |
|
1103 |
|
1104 // --------------------------------------------------------- |
|
1105 // CClkDateTimeView::MakeDateItemL |
|
1106 // rest of the details are commented in the header |
|
1107 // --------------------------------------------------------- |
|
1108 // |
|
1109 void CClkDateTimeView::MakeDateItemL() |
|
1110 { |
|
1111 // Make/Construct the date setting item. |
|
1112 // First the header. |
|
1113 InsertToItem( KHeader() ); |
|
1114 // Then the prompt string "Date" |
|
1115 AppendToItem( *iDate ); |
|
1116 // Go to the value of the item. |
|
1117 AppendToItem( KDelimiter() ); |
|
1118 |
|
1119 HBufC* dateFormatString = StringLoader::LoadLC( R_QTN_DATE_USUAL_WITH_ZERO, iCoeEnv ); |
|
1120 // Format the date string. |
|
1121 iDateTimeInfo.iTime.FormatL( iValue, *dateFormatString ); |
|
1122 // For mirrored languages. |
|
1123 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( iValue ); |
|
1124 // Append the value to the item. |
|
1125 AppendToItem( iValue ); |
|
1126 // Cleanup. |
|
1127 CleanupStack::PopAndDestroy( dateFormatString ); |
|
1128 } |
|
1129 |
|
1130 // --------------------------------------------------------- |
|
1131 // CClkDateTimeView::MakeDateFormatItem |
|
1132 // rest of the details are commented in the header |
|
1133 // --------------------------------------------------------- |
|
1134 // |
|
1135 void CClkDateTimeView::MakeDateFormatItem() |
|
1136 { |
|
1137 // Make/Construct the date setting item. |
|
1138 // First the header. |
|
1139 InsertToItem( KHeader() ); |
|
1140 // Then the prompt string "Date Format" |
|
1141 AppendToItem( *iDateFrmt ); |
|
1142 // Go to the value of the item. |
|
1143 AppendToItem( KDelimiter() ); |
|
1144 |
|
1145 // The enumeration defined in Avkon corresponds to the ordering in the setting list. |
|
1146 TInt formatItemIndex( AknDateFormatUtils::MapSymbianDateFormatToVisualDateFormat( iDateTimeInfo.iDateFormat, NULL ) ); |
|
1147 |
|
1148 if( ( KZerothIndex > formatItemIndex ) || |
|
1149 ( formatItemIndex >= iDateFrmtItemLists->Count() ) ) |
|
1150 { |
|
1151 // If we can't find the item. |
|
1152 return; |
|
1153 } |
|
1154 |
|
1155 // Read the value. |
|
1156 iValue = ( *iDateFrmtItemLists )[ formatItemIndex ]; |
|
1157 // Append the value to the item. |
|
1158 AppendToItem( iValue ); |
|
1159 } |
|
1160 |
|
1161 // --------------------------------------------------------- |
|
1162 // CClkDateTimeView::MakeDateSeparItem |
|
1163 // rest of the details are commented in the header |
|
1164 // --------------------------------------------------------- |
|
1165 // |
|
1166 void CClkDateTimeView::MakeDateSeparItem() |
|
1167 { |
|
1168 InsertToItem( KHeader() ); |
|
1169 AppendToItem( *iDateSepar ); |
|
1170 AppendToItem( KDelimiter() ); |
|
1171 |
|
1172 if( ( iDateTimeInfo.iDateSepar >= 0 ) && ( iDateTimeInfo.iDateSepar < iDateSeparItemLists->Count() ) ) |
|
1173 { |
|
1174 AppendToItem( ( *iDateSeparItemLists )[ iDateTimeInfo.iDateSepar ] ); |
|
1175 } |
|
1176 } |
|
1177 |
|
1178 // --------------------------------------------------------- |
|
1179 // CClkDateTimeView::MakeTimeItemL |
|
1180 // rest of the details are commented in the header |
|
1181 // --------------------------------------------------------- |
|
1182 // |
|
1183 void CClkDateTimeView::MakeTimeItemL() |
|
1184 { |
|
1185 InsertToItem( KHeader() ); |
|
1186 AppendToItem( *iTime ); |
|
1187 AppendToItem( KDelimiter() ); |
|
1188 |
|
1189 HBufC* format = StringLoader::LoadLC( R_QTN_TIME_USUAL_WITH_ZERO, iCoeEnv ); |
|
1190 iDateTimeInfo.iTime.FormatL( iValue, *format ); |
|
1191 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( iValue ); |
|
1192 |
|
1193 AppendToItem( iValue ); |
|
1194 CleanupStack::PopAndDestroy( format ); |
|
1195 } |
|
1196 |
|
1197 |
|
1198 // --------------------------------------------------------- |
|
1199 // CClkDateTimeView::MakeZoneItemL |
|
1200 // rest of the details are commented in the header |
|
1201 // --------------------------------------------------------- |
|
1202 // |
|
1203 void CClkDateTimeView::MakeZoneItemL() |
|
1204 { |
|
1205 InsertToItem( KHeader() ); |
|
1206 AppendToItem( *iZone ); |
|
1207 AppendToItem( KDelimiter() ); |
|
1208 |
|
1209 if( iExtension->GetActiveProtocol() ) |
|
1210 { |
|
1211 // TODO: Append only country name if any plugin is active. |
|
1212 // First we get the current timezone id. Then we get the city group the id belongs to. |
|
1213 |
|
1214 // This will hold the country name. |
|
1215 TBuf< KCountryAndOffsetLength > locationName; |
|
1216 // This will hold the offset. |
|
1217 TBuf< KOffsetStringLength > offsetString; |
|
1218 TInt gmtOffset( FALSE ); |
|
1219 |
|
1220 // Arrays for the timezone ids and their respective offsets. |
|
1221 RArray< TInt > timeZoneIds; |
|
1222 RArray< TInt > zoneOffsets; |
|
1223 |
|
1224 // Connect to the timezone server. |
|
1225 RTz tzHandle; |
|
1226 User::LeaveIfError( tzHandle.Connect() ); |
|
1227 CleanupClosePushL( tzHandle ); |
|
1228 |
|
1229 // Get the current timezone id. |
|
1230 CTzId* timeZoneId; |
|
1231 timeZoneId = tzHandle.GetTimeZoneIdL(); |
|
1232 CleanupStack::PushL( timeZoneId ); |
|
1233 |
|
1234 // Get the offset for the timezone id. |
|
1235 timeZoneIds.Append( timeZoneId->TimeZoneNumericID() ); |
|
1236 tzHandle.GetOffsetsForTimeZoneIdsL( timeZoneIds, zoneOffsets ); |
|
1237 |
|
1238 TInt tempOffset( zoneOffsets[ KErrNone ] ); |
|
1239 gmtOffset = tempOffset; |
|
1240 |
|
1241 // Check for DST and update the offset. |
|
1242 if( IsDstOnL( timeZoneIds[ KErrNone ] ) ) |
|
1243 { |
|
1244 TInt32 dstOffset; |
|
1245 // Get the offset. |
|
1246 GetOffSetWithDstL( dstOffset, *timeZoneId ); |
|
1247 gmtOffset = dstOffset; |
|
1248 } |
|
1249 |
|
1250 timeZoneIds.Close(); |
|
1251 zoneOffsets.Close(); |
|
1252 |
|
1253 // We use the localizer to get the country list. |
|
1254 iExtension->UnLocalisedCity( ETrue ); |
|
1255 |
|
1256 CTzLocalizedTimeZone* tzLocTimeZone(NULL); |
|
1257 CTzLocalizer* tzLocalizer(NULL); |
|
1258 TRAPD( err, tzLocalizer = CTzLocalizer::NewL() ); |
|
1259 if( tzLocalizer && ( !err ) ) |
|
1260 { |
|
1261 CleanupStack::PushL( tzLocalizer ); |
|
1262 TRAPD( err, tzLocTimeZone = tzLocalizer->GetLocalizedTimeZoneL( timeZoneId->TimeZoneNumericID( ) ) ); |
|
1263 if( ( tzLocTimeZone ) && ( !err ) ) |
|
1264 { |
|
1265 CleanupStack::PushL( tzLocTimeZone ); |
|
1266 // First get the city. |
|
1267 CTzLocalizedCity* localizedCity = tzLocalizer->GetFrequentlyUsedZoneCityL( CTzLocalizedTimeZone::ECurrentZone ); |
|
1268 CleanupStack::PushL( localizedCity ); |
|
1269 |
|
1270 // Now the country list. |
|
1271 CTzLocalizedCityGroupArray* countryList = tzLocalizer->GetAllCityGroupsL( CTzLocalizer::ETzAlphaNameAscending ); |
|
1272 CleanupStack::PushL( countryList ); |
|
1273 |
|
1274 // Here we get the index of the country to which the city belongs to. |
|
1275 TInt countryIndex = IndexOfCountry( localizedCity->GroupId(), countryList ); |
|
1276 locationName.Copy( countryList->At( countryIndex ).Name() ); |
|
1277 |
|
1278 // Cleanup. |
|
1279 CleanupStack::PopAndDestroy( countryList ); |
|
1280 CleanupStack::PopAndDestroy( localizedCity ); |
|
1281 CleanupStack::PopAndDestroy( tzLocTimeZone ); |
|
1282 |
|
1283 iExtension->UnLocalisedCity( EFalse ); |
|
1284 } |
|
1285 CleanupStack::PopAndDestroy( tzLocalizer ); |
|
1286 } |
|
1287 // Cleanup. |
|
1288 CleanupStack::PopAndDestroy( timeZoneId ); |
|
1289 CleanupStack::PopAndDestroy( &tzHandle ); |
|
1290 |
|
1291 // Now we have to start constructing the GMT string. |
|
1292 TInt tempInt( gmtOffset ); |
|
1293 TInt hoursInOffset( tempInt / KHour ); |
|
1294 TInt minutesInOffset( KErrNone ); |
|
1295 |
|
1296 TGmtOffsetText gmtOffsetText; |
|
1297 if( KErrNone < tempInt ) |
|
1298 { |
|
1299 minutesInOffset = gmtOffset - hoursInOffset * KHour; |
|
1300 offsetString += KPlusGMT; |
|
1301 } |
|
1302 else if( KErrNone > tempInt ) |
|
1303 { |
|
1304 minutesInOffset = -( gmtOffset - hoursInOffset * KHour ); |
|
1305 offsetString += KMinusGMT; |
|
1306 } |
|
1307 else |
|
1308 { |
|
1309 offsetString += KZeroGMT; |
|
1310 } |
|
1311 |
|
1312 gmtOffsetText.Num( hoursInOffset ); |
|
1313 offsetString += gmtOffsetText; |
|
1314 |
|
1315 const TInt KSeparIndex( 1 ); |
|
1316 |
|
1317 offsetString.Append( TLocale().TimeSeparator( KSeparIndex ) ); |
|
1318 if( KErrNone <= minutesInOffset && 10 > minutesInOffset ) |
|
1319 { |
|
1320 offsetString += KZero; |
|
1321 } |
|
1322 // The final offset string. |
|
1323 gmtOffsetText.Num( minutesInOffset ); |
|
1324 offsetString += gmtOffsetText; |
|
1325 offsetString += KPDF; |
|
1326 |
|
1327 if( iGMTString ) |
|
1328 { |
|
1329 delete iGMTString; |
|
1330 iGMTString = NULL; |
|
1331 } |
|
1332 |
|
1333 // Construct the final string to be displayed. |
|
1334 iGMTString = HBufC::NewL( iGMTPrefixTxt->Length() + offsetString.Length() + locationName.Length() + 1 ); |
|
1335 TPtr gmtStringPtr = iGMTString->Des(); |
|
1336 |
|
1337 // First the GMT text. |
|
1338 gmtStringPtr += *iGMTPrefixTxt; |
|
1339 // The offsetstring. |
|
1340 gmtStringPtr += offsetString; |
|
1341 // One space. |
|
1342 gmtStringPtr += KSingleSpace; |
|
1343 // Then the country name. |
|
1344 gmtStringPtr += locationName; |
|
1345 // For mirrored languages. |
|
1346 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( gmtStringPtr ); |
|
1347 AppendToItem( *iGMTString ); |
|
1348 } |
|
1349 else |
|
1350 { |
|
1351 TPtr ptr = iZoneString->Des(); |
|
1352 AknTextUtils::LanguageSpecificNumberConversion( ptr ); |
|
1353 AppendToItem( *iZoneString ); |
|
1354 } |
|
1355 } |
|
1356 |
|
1357 // --------------------------------------------------------- |
|
1358 // CClkDateTimeView::MakeTimeFormatItem |
|
1359 // rest of the details are commented in the header |
|
1360 // --------------------------------------------------------- |
|
1361 // |
|
1362 void CClkDateTimeView::MakeTimeFormatItem() |
|
1363 { |
|
1364 InsertToItem( KHeader() ); |
|
1365 AppendToItem( *iTimeFrmt ); |
|
1366 AppendToItem( KDelimiter() ); |
|
1367 |
|
1368 if( ETime24 == iDateTimeInfo.iTimeFormat ) |
|
1369 { |
|
1370 iValue = *iAbbrev24H; |
|
1371 } |
|
1372 else if( ETime12 == iDateTimeInfo.iTimeFormat ) |
|
1373 { |
|
1374 iValue = *iAbbrev12H; |
|
1375 } |
|
1376 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( iValue ); |
|
1377 |
|
1378 AppendToItem( iValue ); |
|
1379 } |
|
1380 |
|
1381 // --------------------------------------------------------- |
|
1382 // CClkDateTimeView::MakeTimeSeparItem |
|
1383 // rest of the details are commented in the header |
|
1384 // --------------------------------------------------------- |
|
1385 // |
|
1386 void CClkDateTimeView::MakeTimeSeparItem() |
|
1387 { |
|
1388 InsertToItem( KHeader() ); |
|
1389 AppendToItem( *iTimeSepar ); |
|
1390 AppendToItem( KDelimiter() ); |
|
1391 if( ( iDateTimeInfo.iTimeSepar >= 0 ) && ( iDateTimeInfo.iTimeSepar < iTimeSeparItemLists->Count() ) ) |
|
1392 { |
|
1393 AppendToItem( ( *iTimeSeparItemLists )[ iDateTimeInfo.iTimeSepar ] ); |
|
1394 } |
|
1395 } |
|
1396 |
|
1397 // --------------------------------------------------------- |
|
1398 // CClkDateTimeView::MakeAutomaticTimeUpdateItem |
|
1399 // rest of the details are commented in the header |
|
1400 // --------------------------------------------------------- |
|
1401 // |
|
1402 void CClkDateTimeView::MakeAutomaticTimeUpdateItem() |
|
1403 { |
|
1404 InsertToItem( KHeader() ); |
|
1405 AppendToItem( *iAutomaticTimeUpdateString ) ; |
|
1406 AppendToItem( KDelimiter() ); |
|
1407 if( iExtension->GetActiveProtocol() ) |
|
1408 { |
|
1409 AppendToItem( *iAutomaticTimeUpdateOn ); |
|
1410 } |
|
1411 else |
|
1412 { |
|
1413 AppendToItem( *iAutomaticTimeUpdateOff ); |
|
1414 } |
|
1415 } |
|
1416 |
|
1417 // --------------------------------------------------------- |
|
1418 // CClkDateTimeView::MakeClockTypeItem |
|
1419 // rest of the details are commented in the header |
|
1420 // --------------------------------------------------------- |
|
1421 // |
|
1422 void CClkDateTimeView::MakeClockTypeItem() |
|
1423 { |
|
1424 InsertToItem( KHeader() ); |
|
1425 AppendToItem( *iClockType ); |
|
1426 AppendToItem( KDelimiter() ); |
|
1427 if( EClockAnalog == iDateTimeInfo.iClockFormat ) |
|
1428 { |
|
1429 AppendToItem( *iAnalog ); |
|
1430 } |
|
1431 else if( EClockDigital == iDateTimeInfo.iClockFormat ) |
|
1432 { |
|
1433 AppendToItem( *iDigital ); |
|
1434 } |
|
1435 } |
|
1436 |
|
1437 // --------------------------------------------------------- |
|
1438 // CClkDateTimeView::MakeClockAlarmToneItem |
|
1439 // rest of the details are commented in the header |
|
1440 // --------------------------------------------------------- |
|
1441 // |
|
1442 void CClkDateTimeView::MakeClockAlarmToneItem() |
|
1443 { |
|
1444 InsertToItem( KHeader() ); |
|
1445 AppendToItem( *iTone ); |
|
1446 AppendToItem( KDelimiter() ); |
|
1447 TParse parser; |
|
1448 TFileName fileName = iExtension->GetSilentToneStr()->Des(); |
|
1449 |
|
1450 if( ( iAlarmToneName.Compare( fileName ) == 0 ) || ( iAlarmToneName.Length() == 0 ) ) |
|
1451 { |
|
1452 AppendToItem( *iSoundOffTxt ); |
|
1453 } |
|
1454 else if( iAlarmToneName.Compare( iDefaultAlarmToneName ) == 0 ) |
|
1455 { |
|
1456 AppendToItem( *iDefaultToneTxt ); |
|
1457 } |
|
1458 else if( KErrNone == parser.Set( iAlarmToneName, NULL, NULL ) ) |
|
1459 { |
|
1460 AppendToItem( parser.NameAndExt() ); |
|
1461 } |
|
1462 else |
|
1463 { |
|
1464 AppendToItem( KEmptyField() ); |
|
1465 } |
|
1466 } |
|
1467 |
|
1468 // --------------------------------------------------------- |
|
1469 // CClkDateTimeView::MakeClockSnoozeTimeItemL |
|
1470 // rest of the details are commented in the header |
|
1471 // --------------------------------------------------------- |
|
1472 // |
|
1473 void CClkDateTimeView::MakeClockSnoozeTimeItemL() |
|
1474 { |
|
1475 InsertToItem( KHeader() ); |
|
1476 AppendToItem( *( iExtension->GetAlarmSnoozeTimeStr() ) ); |
|
1477 AppendToItem( KDelimiter() ); |
|
1478 |
|
1479 iExtension->MakeSnoozeTimeItemL(); |
|
1480 AppendToItem( *( iExtension->GetSnoozeTimeStr() ) ); |
|
1481 } |
|
1482 |
|
1483 // --------------------------------------------------------- |
|
1484 // CClkDateTimeView::AppendToItem |
|
1485 // rest of the details are commented in the header |
|
1486 // --------------------------------------------------------- |
|
1487 // |
|
1488 void CClkDateTimeView::AppendToItem( const TDesC& aDes ) |
|
1489 { |
|
1490 TInt len = aDes.Length(); |
|
1491 TPtr ptr = iItem->Des(); |
|
1492 |
|
1493 TInt bufferleft = ptr.MaxLength() - ptr.Length(); |
|
1494 |
|
1495 if( bufferleft <= len ) |
|
1496 { |
|
1497 iItem = iItem->ReAlloc( ptr.Length() + len ); |
|
1498 ptr = iItem->Des(); |
|
1499 } |
|
1500 ptr.Append( aDes ); |
|
1501 } |
|
1502 |
|
1503 |
|
1504 // --------------------------------------------------------- |
|
1505 // CClkDateTimeView::InsertToItem |
|
1506 // rest of the details are commented in the header |
|
1507 // --------------------------------------------------------- |
|
1508 // |
|
1509 void CClkDateTimeView::InsertToItem( const TDesC& aDes ) |
|
1510 { |
|
1511 TPtr ptr = iItem->Des(); |
|
1512 ptr = aDes; |
|
1513 } |
|
1514 |
|
1515 // --------------------------------------------------------- |
|
1516 // CClkDateTimeView::DeleteResourceBuf |
|
1517 // rest of the details are commented in the header |
|
1518 // --------------------------------------------------------- |
|
1519 // |
|
1520 void CClkDateTimeView::DeleteResourceBuf() |
|
1521 { |
|
1522 if( iDate ) |
|
1523 { |
|
1524 delete iDate; |
|
1525 iDate = NULL; |
|
1526 } |
|
1527 if( iDateFrmt ) |
|
1528 { |
|
1529 delete iDateFrmt; |
|
1530 iDateFrmt = NULL; |
|
1531 } |
|
1532 if( iDateSepar ) |
|
1533 { |
|
1534 delete iDateSepar; |
|
1535 iDateSepar = NULL; |
|
1536 } |
|
1537 if( iTime ) |
|
1538 { |
|
1539 delete iTime; |
|
1540 iTime = NULL; |
|
1541 } |
|
1542 if( iZone ) |
|
1543 { |
|
1544 delete iZone; |
|
1545 iZone = NULL; |
|
1546 } |
|
1547 if( iTimeFrmt ) |
|
1548 { |
|
1549 delete iTimeFrmt; |
|
1550 iTimeFrmt = NULL; |
|
1551 } |
|
1552 if( iTimeSepar ) |
|
1553 { |
|
1554 delete iTimeSepar; |
|
1555 iTimeSepar = NULL; |
|
1556 } |
|
1557 if( iAutomaticTimeUpdateString ) |
|
1558 { |
|
1559 delete iAutomaticTimeUpdateString; |
|
1560 iAutomaticTimeUpdateString = NULL; |
|
1561 } |
|
1562 if( iClockType ) |
|
1563 { |
|
1564 delete iClockType; |
|
1565 iClockType = NULL; |
|
1566 } |
|
1567 if( iAbbrev24H ) |
|
1568 { |
|
1569 delete iAbbrev24H; |
|
1570 iAbbrev24H = NULL; |
|
1571 } |
|
1572 if( iAbbrev12H ) |
|
1573 { |
|
1574 delete iAbbrev12H; |
|
1575 iAbbrev12H = NULL; |
|
1576 } |
|
1577 if( iAutomaticTimeUpdateOn ) |
|
1578 { |
|
1579 delete iAutomaticTimeUpdateOn; |
|
1580 iAutomaticTimeUpdateOn = NULL; |
|
1581 } |
|
1582 if( iLocalTime ) |
|
1583 { |
|
1584 delete iLocalTime; |
|
1585 iLocalTime = NULL; |
|
1586 } |
|
1587 if( iAutomaticTimeUpdateOff ) |
|
1588 { |
|
1589 delete iAutomaticTimeUpdateOff; |
|
1590 iAutomaticTimeUpdateOff = NULL; |
|
1591 } |
|
1592 if( iAnalog ) |
|
1593 { |
|
1594 delete iAnalog; |
|
1595 iAnalog = NULL; |
|
1596 } |
|
1597 if( iDigital ) |
|
1598 { |
|
1599 delete iDigital; |
|
1600 iDigital = NULL; |
|
1601 } |
|
1602 if( iTone ) |
|
1603 { |
|
1604 delete iTone; |
|
1605 iTone = NULL; |
|
1606 } |
|
1607 if( iTimeZone ) |
|
1608 { |
|
1609 delete iTimeZone; |
|
1610 iTimeZone = NULL; |
|
1611 } |
|
1612 if( iGMTPrefixTxt ) |
|
1613 { |
|
1614 delete iGMTPrefixTxt; |
|
1615 iGMTPrefixTxt = NULL; |
|
1616 } |
|
1617 iExtension->DeleteResourceBuf(); |
|
1618 } |
|
1619 |
|
1620 // --------------------------------------------------------- |
|
1621 // CClkDateTimeView::DateFmt |
|
1622 // rest of the details are commented in the header |
|
1623 // --------------------------------------------------------- |
|
1624 TInt CClkDateTimeView::DateFmt() |
|
1625 { |
|
1626 TLocale locale; |
|
1627 return locale.DateFormat(); |
|
1628 } |
|
1629 |
|
1630 // --------------------------------------------------------- |
|
1631 // CClkDateTimeView::HandleBackCmdL |
|
1632 // rest of the details are commented in the header |
|
1633 // --------------------------------------------------------- |
|
1634 // |
|
1635 void CClkDateTimeView::HandleBackCmdL() |
|
1636 { |
|
1637 iCurrentItem = 0; |
|
1638 iTopItem = 0; |
|
1639 if ( iIsClockInUse ) |
|
1640 { |
|
1641 AppUi()->ActivateLocalViewL( iPrevViewId.iViewUid ); |
|
1642 } |
|
1643 else |
|
1644 { |
|
1645 AppUi()->ActivateLocalViewL( iViewId ); |
|
1646 } |
|
1647 } |
|
1648 |
|
1649 // --------------------------------------------------------- |
|
1650 // CClkDateTimeView::HandleDateCmdL |
|
1651 // rest of the details are commented in the header |
|
1652 // --------------------------------------------------------- |
|
1653 // |
|
1654 void CClkDateTimeView::HandleDateCmdL() |
|
1655 { |
|
1656 |
|
1657 |
|
1658 TTime newTime( iDateTimeInfo.iTime ); |
|
1659 CAknDateSettingPage* dlg = new( ELeave ) CAknDateSettingPage( R_DATE_TIME_DATE_PAGE, newTime ); |
|
1660 |
|
1661 if( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ) ) |
|
1662 { |
|
1663 TTime currentTime; |
|
1664 currentTime.HomeTime(); |
|
1665 |
|
1666 TDateTime currentDateTime( currentTime.DateTime() ); |
|
1667 TDateTime newDateTime( newTime.DateTime() ); |
|
1668 |
|
1669 // Get the new date |
|
1670 newDateTime.SetHour( currentDateTime.Hour() ); |
|
1671 newDateTime.SetMinute(currentDateTime.Minute()); |
|
1672 newDateTime.SetSecond( currentDateTime.Second() ); |
|
1673 newDateTime.SetMicroSecond( currentDateTime.MicroSecond() ); |
|
1674 newTime = newDateTime; |
|
1675 |
|
1676 if( KErrNone == SetDateTimeL( newTime ) ) |
|
1677 { |
|
1678 //Updates the time zone when a DST is on/off |
|
1679 ConstructGmtStringL(); |
|
1680 |
|
1681 UpdateListBoxL( EClkSettZone ); |
|
1682 if( iExtension->GetActiveProtocol() ) |
|
1683 { |
|
1684 iDateTimeInfo.iNITZ = EFalse; |
|
1685 iSrvModel->DeActivateAllProtocols(); |
|
1686 iExtension->SetActiveProtocol( EFalse ); |
|
1687 ShowAutomaticTimeUpdateOffNoteL(); |
|
1688 } |
|
1689 else |
|
1690 { |
|
1691 UpdateListBoxL( EClkSettDate ); |
|
1692 } |
|
1693 |
|
1694 // Show alarm exists note only if the date has changed. |
|
1695 TTimeIntervalDays deltaDays = currentTime.DaysFrom( newTime ); |
|
1696 deltaDays = Abs( deltaDays.Int() ); |
|
1697 if( 0 != deltaDays.Int() ) |
|
1698 { |
|
1699 ShowAlarmExistNoteL(); |
|
1700 } |
|
1701 } |
|
1702 } |
|
1703 } |
|
1704 |
|
1705 // --------------------------------------------------------- |
|
1706 // CClkDateTimeView::HandleDateFrmtCmdL |
|
1707 // rest of the details are commented in the header |
|
1708 // --------------------------------------------------------- |
|
1709 // |
|
1710 void CClkDateTimeView::HandleDateFrmtCmdL() |
|
1711 { |
|
1712 TInt index(0); |
|
1713 |
|
1714 // The enumeration defined in Avkon corresponds to the ordering in the setting list. |
|
1715 index = AknDateFormatUtils::MapSymbianDateFormatToVisualDateFormat( iDateTimeInfo.iDateFormat, NULL ); |
|
1716 |
|
1717 TInt ret( QueryPopupSettingPageL( *iDateFrmtItemLists, index, *iDateFrmt ) ); |
|
1718 if ( index != ret ) |
|
1719 { |
|
1720 TAknVisualDateFormat format = ( TAknVisualDateFormat )ret; |
|
1721 iDateTimeInfo.iDateFormat = AknDateFormatUtils::MapVisualDateFormatToSymbianDateFormat( format, NULL ); |
|
1722 SetDateFormat(); |
|
1723 UpdateListBoxL( EClkSettDateFrmt ); |
|
1724 UpdateListBoxL( EClkSettDate ); |
|
1725 } |
|
1726 } |
|
1727 |
|
1728 // --------------------------------------------------------- |
|
1729 // CClkDateTimeView::HandleDateSeparCmdL |
|
1730 // rest of the details are commented in the header |
|
1731 // --------------------------------------------------------- |
|
1732 // |
|
1733 void CClkDateTimeView::HandleDateSeparCmdL() |
|
1734 { |
|
1735 TInt index( iDateTimeInfo.iDateSepar ); |
|
1736 TInt ret( QueryPopupSettingPageL( *iDateSeparItemLists, index, *iDateSepar ) ); |
|
1737 if ( index != ret ) |
|
1738 { |
|
1739 // Obtain the current visual date format |
|
1740 TAknVisualDateFormat visualDateFormat = AknDateFormatUtils::MapSymbianDateFormatToVisualDateFormat( iDateTimeInfo.iDateFormat, NULL ); |
|
1741 |
|
1742 iDateTimeInfo.iDateSepar = ret; |
|
1743 SetDateSeparator(); |
|
1744 |
|
1745 // Set again the visual format |
|
1746 iDateTimeInfo.iDateFormat = AknDateFormatUtils::MapVisualDateFormatToSymbianDateFormat( visualDateFormat, NULL ); |
|
1747 SetDateFormat(); |
|
1748 |
|
1749 UpdateListBoxL( EClkSettDateSepar ); |
|
1750 UpdateListBoxL( EClkSettDateFrmt ); |
|
1751 UpdateListBoxL( EClkSettDate ); |
|
1752 } |
|
1753 } |
|
1754 |
|
1755 // --------------------------------------------------------- |
|
1756 // CClkDateTimeView::HandleTimeCmdL |
|
1757 // rest of the details are commented in the header |
|
1758 // --------------------------------------------------------- |
|
1759 // |
|
1760 void CClkDateTimeView::HandleTimeCmdL() |
|
1761 { |
|
1762 |
|
1763 // User to be notified whether DST rollover happens in a day or has happen within a day if he tries to change the time. |
|
1764 TBool dstStatus = CheckForDSTChangesL(); |
|
1765 |
|
1766 if( !dstStatus ) |
|
1767 { |
|
1768 TTime newTime( iDateTimeInfo.iTime ); |
|
1769 |
|
1770 CAknTimeSettingPage* dlg = new ( ELeave ) CAknTimeSettingPage( R_DATE_TIME_TIME_PAGE, newTime ); |
|
1771 if( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ) ) |
|
1772 { |
|
1773 |
|
1774 if( iExtension->GetActiveProtocol() ) |
|
1775 { |
|
1776 // User pressed Yes. We disable Automatic time update here. |
|
1777 iDateTimeInfo.iNITZ = EFalse; |
|
1778 iSrvModel->DeActivateAllProtocols(); |
|
1779 iExtension->SetActiveProtocol( EFalse ); |
|
1780 ShowAutomaticTimeUpdateOffNoteL(); |
|
1781 } |
|
1782 TTime current; |
|
1783 current.HomeTime(); |
|
1784 TDateTime cTime( current.DateTime() ); |
|
1785 TDateTime atime( newTime.DateTime() ); |
|
1786 |
|
1787 |
|
1788 atime.SetYear( cTime.Year() ); |
|
1789 atime.SetMonth( cTime.Month() ); |
|
1790 atime.SetDay( cTime.Day() ); |
|
1791 newTime = atime; |
|
1792 if( KErrNone == SetDateTimeL( newTime ) ) |
|
1793 { |
|
1794 UpdateListBoxL( EClkSettTime ); |
|
1795 if( iExtension->GetActiveProtocol() ) |
|
1796 { |
|
1797 iDateTimeInfo.iNITZ = EFalse; |
|
1798 iSrvModel->DeActivateAllProtocols(); |
|
1799 iExtension->SetActiveProtocol( EFalse ); |
|
1800 ShowAutomaticTimeUpdateOffNoteL(); |
|
1801 } |
|
1802 else |
|
1803 { |
|
1804 UpdateListBoxL( EClkSettTime ); |
|
1805 } |
|
1806 } |
|
1807 } |
|
1808 } |
|
1809 } |
|
1810 |
|
1811 // --------------------------------------------------------- |
|
1812 // CClkDateTimeView::HandleZoneCmdL |
|
1813 // rest of the details are commented in the header |
|
1814 // --------------------------------------------------------- |
|
1815 // |
|
1816 void CClkDateTimeView::HandleZoneCmdL() |
|
1817 { |
|
1818 if( iExtension->GetActiveProtocol() ) |
|
1819 { |
|
1820 // If automatic time update is On, we need to ask the user if he wishes to disable it. |
|
1821 |
|
1822 SelectZoneL( ETrue ); |
|
1823 |
|
1824 } |
|
1825 else |
|
1826 { |
|
1827 // We continues without any queries. |
|
1828 SelectZoneL( EFalse ); |
|
1829 } |
|
1830 |
|
1831 // Update the list. |
|
1832 UpdateListBoxL( EClkSettZone ); |
|
1833 UpdateListBoxL( EClkSettTime ); |
|
1834 UpdateListBoxL( EClkSettAutomaticTimeUpdate ); |
|
1835 } |
|
1836 |
|
1837 // --------------------------------------------------------- |
|
1838 // CClkDateTimeView::IsDstOnL |
|
1839 // rest of the details are commented in the header |
|
1840 // --------------------------------------------------------- |
|
1841 // |
|
1842 TBool CClkDateTimeView::IsDstOnL( TInt aTimeZoneId ) |
|
1843 { |
|
1844 TBool returnVal( EFalse ); |
|
1845 |
|
1846 // Construct the timezone id object. |
|
1847 CTzId* timeZoneId = CTzId::NewL( aTimeZoneId ); |
|
1848 CleanupStack::PushL( timeZoneId ); |
|
1849 |
|
1850 // Connect to the timezone server. |
|
1851 RTz tzHandle; |
|
1852 User::LeaveIfError( tzHandle.Connect() ); |
|
1853 CleanupClosePushL( tzHandle ); |
|
1854 |
|
1855 // Request DST status. |
|
1856 returnVal = tzHandle.IsDaylightSavingOnL( *timeZoneId ); |
|
1857 |
|
1858 // Cleanup. |
|
1859 tzHandle.Close(); |
|
1860 CleanupStack::PopAndDestroy( &tzHandle ); |
|
1861 CleanupStack::PopAndDestroy( timeZoneId ); |
|
1862 |
|
1863 // Return the status. |
|
1864 return returnVal; |
|
1865 } |
|
1866 |
|
1867 // --------------------------------------------------------- |
|
1868 // CClkDateTimeView::IndexofCountry |
|
1869 // rest of the details are commented in the header |
|
1870 // --------------------------------------------------------- |
|
1871 // |
|
1872 TInt CClkDateTimeView::IndexOfCountry( TInt aGroupId, CTzLocalizedCityGroupArray* aCountryList ) |
|
1873 { |
|
1874 TInt countryCount( aCountryList->Count() ); |
|
1875 |
|
1876 // Find the matching city groupd id. Return the index of the corresponding country in the list. |
|
1877 for( TInt index( KZerothIndex ); index < countryCount; index++ ) |
|
1878 { |
|
1879 if( aGroupId == aCountryList->At( index ).Id() ) |
|
1880 { |
|
1881 return index; |
|
1882 } |
|
1883 } |
|
1884 return 1; |
|
1885 } |
|
1886 |
|
1887 // --------------------------------------------------------- |
|
1888 // CClkDateTimeView::SelectZoneL |
|
1889 // rest of the details are commented in the header |
|
1890 // --------------------------------------------------------- |
|
1891 // |
|
1892 void CClkDateTimeView::SelectZoneL( TBool aTimeUpdateState ) |
|
1893 { |
|
1894 CTzLocalizer* locCities = CTzLocalizer::NewL(); |
|
1895 CleanupStack::PushL( locCities ); |
|
1896 |
|
1897 CTzLocalizedCityGroupArray* countryList = locCities->GetAllCityGroupsL( CTzLocalizer::ETzAlphaNameAscending ); |
|
1898 CleanupStack::PushL( countryList ); |
|
1899 |
|
1900 TInt selectedItem; |
|
1901 CTzLocalizedCity* city( NULL ); |
|
1902 |
|
1903 // Create listbox and PUSH it |
|
1904 CAknSinglePopupMenuStyleListBox* listBox = new ( ELeave ) CAknSinglePopupMenuStyleListBox; |
|
1905 |
|
1906 CleanupStack::PushL( listBox ); |
|
1907 |
|
1908 //Create a popupList for displaying the country list. |
|
1909 CClkDateTimeViewPopupListInher* popupCountryList = CClkDateTimeViewPopupListInher::NewL( |
|
1910 listBox, R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, |
|
1911 AknPopupLayouts::EMenuWindow ); |
|
1912 CleanupStack::PushL( popupCountryList ); |
|
1913 |
|
1914 listBox->ConstructL( popupCountryList, EAknListBoxSelectionList | EAknListBoxScrollBarSizeExcluded ); |
|
1915 listBox->CreateScrollBarFrameL( ETrue ); |
|
1916 listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
1917 CEikScrollBarFrame::EAuto ); |
|
1918 |
|
1919 // Enable Marquee for the list |
|
1920 listBox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue ); |
|
1921 |
|
1922 CDesCArrayFlat* country = new (ELeave) CDesCArrayFlat( KArrayGranularity ); |
|
1923 if( !iExtension->IsUnLocalisedCity() ) |
|
1924 { |
|
1925 // Get the Group Id of current city, so that it can be shown as selected |
|
1926 // when the country list is popped up. |
|
1927 city = locCities->GetFrequentlyUsedZoneCityL( CTzLocalizedTimeZone::ECurrentZone ); |
|
1928 CleanupStack::PushL( city ); |
|
1929 } |
|
1930 |
|
1931 for( TInt index = 0; index < countryList->Count(); index++ ) |
|
1932 { |
|
1933 TBuf< KMaxDataLength > cityGroup( ( countryList->At( index ) ).Name() ); |
|
1934 country->AppendL( cityGroup ); |
|
1935 } |
|
1936 |
|
1937 CTextListBoxModel* countryModel=listBox->Model(); |
|
1938 countryModel->SetItemTextArray( country ); |
|
1939 countryModel->SetOwnershipType( ELbmOwnsItemArray ); |
|
1940 |
|
1941 // Set the title for the popup List |
|
1942 HBufC* countryTitle = StringLoader::LoadLC( R_CLOCK_SELECT_COUNTRY ); |
|
1943 popupCountryList->SetTitleL( countryTitle->Des() ); |
|
1944 CleanupStack::PopAndDestroy( countryTitle ); |
|
1945 popupCountryList->EnableFind(); |
|
1946 |
|
1947 if( !iExtension->IsUnLocalisedCity() ) |
|
1948 { |
|
1949 // Set the focus on the current selected country. |
|
1950 listBox->View()->SetCurrentItemIndex( IndexOfCountry( city->GroupId(), countryList ) ); |
|
1951 } |
|
1952 if( popupCountryList->ExecuteLD() ) |
|
1953 { |
|
1954 TInt zone; |
|
1955 selectedItem = listBox->View()->CurrentItemIndex(); |
|
1956 |
|
1957 CTzLocalizedCityArray* cityList = locCities->GetCitiesInGroupL( |
|
1958 ( countryList->At( selectedItem ) ).Id(), |
|
1959 CTzLocalizer::ETzAlphaNameAscending ); |
|
1960 |
|
1961 CleanupStack::PushL( cityList ); |
|
1962 |
|
1963 RTz rTz; |
|
1964 User::LeaveIfError( rTz.Connect() ); |
|
1965 CleanupClosePushL( rTz ); |
|
1966 |
|
1967 RArray< TInt > zones; |
|
1968 CleanupClosePushL( zones ); |
|
1969 RArray< TInt > offsets; |
|
1970 CleanupClosePushL( offsets ); |
|
1971 TInt offset; |
|
1972 |
|
1973 if( cityList->Count() == 1 ) |
|
1974 { |
|
1975 zone = 0; |
|
1976 zones.Append( ( cityList->At( zone ) ).TimeZoneId() ); |
|
1977 rTz.GetOffsetsForTimeZoneIdsL( zones, offsets ); |
|
1978 offset = offsets[ 0 ]; |
|
1979 |
|
1980 if( IsDstOnL( zones[ 0 ] ) ) |
|
1981 { |
|
1982 TInt32 dstOffset; |
|
1983 |
|
1984 // Create an object of CTzId |
|
1985 CTzId* tzId = CTzId::NewL( ( cityList->At( zone ) ).TimeZoneId() ); |
|
1986 CleanupStack::PushL( tzId ); |
|
1987 |
|
1988 // Get the offset |
|
1989 GetOffSetWithDstL( dstOffset, *tzId ); |
|
1990 CleanupStack::PopAndDestroy( tzId ); |
|
1991 |
|
1992 MakeGmtOffsetStringL( dstOffset ); // offset + KDSTOffset); |
|
1993 } |
|
1994 else |
|
1995 { |
|
1996 MakeGmtOffsetStringL( offset ); |
|
1997 } |
|
1998 |
|
1999 |
|
2000 TBuf< KMaxDataLength > string; |
|
2001 string.Copy( iGMTString->Des() ); |
|
2002 string.Append( KSingleSpace ); |
|
2003 string.Append( ( countryList->At( selectedItem ) ).Name() ); |
|
2004 |
|
2005 if( iZoneString ) |
|
2006 { |
|
2007 delete iZoneString; |
|
2008 iZoneString = NULL; |
|
2009 } |
|
2010 iZoneString = string.Alloc(); |
|
2011 locCities->SetTimeZoneL( ( cityList->At( zone ) ).TimeZoneId() ); |
|
2012 |
|
2013 if( aTimeUpdateState ) |
|
2014 { |
|
2015 iSrvModel->DeActivateAllProtocols(); |
|
2016 iDateTimeInfo.iNITZ = EFalse; |
|
2017 iExtension->SetActiveProtocol( EFalse ); |
|
2018 } |
|
2019 |
|
2020 TTime newTime; |
|
2021 newTime.HomeTime(); |
|
2022 iDateTimeInfo.iTime = newTime; |
|
2023 |
|
2024 locCities->SetFrequentlyUsedZoneL( cityList->At( zone ), CTzLocalizedTimeZone::ECurrentZone ); |
|
2025 } |
|
2026 else |
|
2027 { |
|
2028 CAknSinglePopupMenuStyleListBox* cityListBox = new( ELeave ) CAknSinglePopupMenuStyleListBox; |
|
2029 |
|
2030 CleanupStack::PushL( cityListBox ); |
|
2031 |
|
2032 // Create a new popupList to display the city list for a country. |
|
2033 CClkDateTimeViewPopupListInher* popupCityList = CClkDateTimeViewPopupListInher::NewL( |
|
2034 cityListBox, R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, |
|
2035 AknPopupLayouts::EMenuWindow ); |
|
2036 CleanupStack::PushL( popupCityList ); |
|
2037 |
|
2038 cityListBox->ConstructL( popupCityList, EAknListBoxSelectionList | EAknListBoxScrollBarSizeExcluded ); |
|
2039 cityListBox->CreateScrollBarFrameL( ETrue ); |
|
2040 cityListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
2041 |
|
2042 // Enable Marquee for the list |
|
2043 cityListBox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue ); |
|
2044 |
|
2045 CDesCArrayFlat* city= new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
2046 |
|
2047 for( TInt i = 0; i < cityList->Count(); i++ ) |
|
2048 { |
|
2049 zones.Append( ( cityList->At( i ) ).TimeZoneId() ); |
|
2050 } |
|
2051 |
|
2052 rTz.GetOffsetsForTimeZoneIdsL( zones, offsets ); |
|
2053 |
|
2054 for( TInt i = 0; i < cityList->Count(); i++ ) |
|
2055 { |
|
2056 offset = offsets[ i ]; |
|
2057 |
|
2058 if( IsDstOnL( zones[ i ] ) ) |
|
2059 { |
|
2060 TInt32 dstOffset; |
|
2061 |
|
2062 // Create an object of CTzId |
|
2063 CTzId* tzId = CTzId::NewL( ( cityList->At( i ) ).TimeZoneId() ); |
|
2064 CleanupStack::PushL( tzId ); |
|
2065 |
|
2066 // Get the offset |
|
2067 GetOffSetWithDstL( dstOffset, *tzId ); |
|
2068 CleanupStack::PopAndDestroy( tzId ); |
|
2069 |
|
2070 MakeGmtOffsetStringL( dstOffset ); |
|
2071 } |
|
2072 else |
|
2073 { |
|
2074 MakeGmtOffsetStringL( offset ); |
|
2075 } |
|
2076 |
|
2077 TBuf< KMaxDataLength > a; |
|
2078 a.Copy( iGMTString->Des() ); |
|
2079 a.Append( KSingleSpace ); |
|
2080 a.Append( ( cityList->At( i ) ).Name() ); |
|
2081 city->AppendL( a ); |
|
2082 } |
|
2083 |
|
2084 zones.Reset(); |
|
2085 offsets.Reset(); |
|
2086 |
|
2087 CTextListBoxModel* cityModel = cityListBox->Model(); |
|
2088 cityModel->SetItemTextArray( city ); |
|
2089 cityModel->SetOwnershipType( ELbmOwnsItemArray ); |
|
2090 |
|
2091 //Set the title for the citylist popup |
|
2092 HBufC* cityTitle = StringLoader::LoadLC( R_CLOCK_SELECT_CITY ); |
|
2093 popupCityList->SetTitleL( cityTitle->Des() ); |
|
2094 CleanupStack::PopAndDestroy( cityTitle ); |
|
2095 popupCityList->EnableFind(); |
|
2096 |
|
2097 if( popupCityList->ExecuteLD() ) |
|
2098 { |
|
2099 zone = cityListBox->CurrentItemIndex(); |
|
2100 zones.Append( ( cityList->At( zone ) ).TimeZoneId() ); |
|
2101 rTz.GetOffsetsForTimeZoneIdsL( zones, offsets ); |
|
2102 offset = offsets[ 0 ]; |
|
2103 |
|
2104 if( IsDstOnL( zones[ 0 ] ) ) |
|
2105 { |
|
2106 TInt32 dstOffset; |
|
2107 |
|
2108 // Create an object of CTzId |
|
2109 CTzId* tzId = CTzId::NewL( ( cityList->At( zone ) ).TimeZoneId() ); |
|
2110 CleanupStack::PushL( tzId ); |
|
2111 |
|
2112 // Get the offset |
|
2113 GetOffSetWithDstL( dstOffset, *tzId ); |
|
2114 CleanupStack::PopAndDestroy( tzId ); |
|
2115 |
|
2116 MakeGmtOffsetStringL( dstOffset ); |
|
2117 } |
|
2118 else |
|
2119 { |
|
2120 MakeGmtOffsetStringL( offset ); |
|
2121 } |
|
2122 |
|
2123 TBuf< KMaxDataLength > string; |
|
2124 string.Copy( iGMTString->Des() ); |
|
2125 string.Append( KSingleSpace ); |
|
2126 string.Append( ( cityList->At( zone ) ).Name() ); |
|
2127 |
|
2128 if( iZoneString ) |
|
2129 { |
|
2130 delete iZoneString; |
|
2131 iZoneString = NULL; |
|
2132 } |
|
2133 iZoneString = string.Alloc(); |
|
2134 locCities->SetTimeZoneL( ( cityList->At( zone ) ).TimeZoneId() ); |
|
2135 |
|
2136 if( aTimeUpdateState ) |
|
2137 { |
|
2138 // Switch automatic time update to Off. |
|
2139 iSrvModel->DeActivateAllProtocols(); |
|
2140 iDateTimeInfo.iNITZ = EFalse; |
|
2141 iExtension->SetActiveProtocol( EFalse ); |
|
2142 } |
|
2143 |
|
2144 TTime newTime; |
|
2145 newTime.HomeTime(); |
|
2146 iDateTimeInfo.iTime = newTime; |
|
2147 |
|
2148 locCities->SetFrequentlyUsedZoneL( cityList->At( zone ), CTzLocalizedTimeZone::ECurrentZone ); |
|
2149 } |
|
2150 CleanupStack::Pop( popupCityList ); |
|
2151 CleanupStack::PopAndDestroy( cityListBox ); |
|
2152 } |
|
2153 CleanupStack::PopAndDestroy( &offsets ); |
|
2154 CleanupStack::PopAndDestroy( &zones ); |
|
2155 CleanupStack::PopAndDestroy( &rTz ); |
|
2156 CleanupStack::PopAndDestroy( cityList ); |
|
2157 } |
|
2158 |
|
2159 if( !iExtension->IsUnLocalisedCity() ) |
|
2160 { |
|
2161 // pop and destroy only if it has been pushed into the stack |
|
2162 CleanupStack::PopAndDestroy( city ); |
|
2163 } |
|
2164 CleanupStack::Pop( popupCountryList ); |
|
2165 CleanupStack::PopAndDestroy( listBox ); |
|
2166 CleanupStack::PopAndDestroy( countryList ); |
|
2167 CleanupStack::PopAndDestroy( locCities ); |
|
2168 } |
|
2169 |
|
2170 // --------------------------------------------------------- |
|
2171 // CClkDateTimeView::HandleTimeFrmtCmdL |
|
2172 // rest of the details are commented in the header |
|
2173 // --------------------------------------------------------- |
|
2174 // |
|
2175 void CClkDateTimeView::HandleTimeFrmtCmdL() |
|
2176 { |
|
2177 if( iMenuChange ) |
|
2178 { |
|
2179 CDesCArrayFlat* timeFrmtItemLists = new( ELeave ) CDesCArrayFlat( 2 ); |
|
2180 CleanupStack::PushL( timeFrmtItemLists ); |
|
2181 |
|
2182 TBuf< KMaxValueLength > tmp; |
|
2183 tmp = *iAbbrev24H; |
|
2184 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( tmp ); |
|
2185 timeFrmtItemLists->AppendL( tmp ); |
|
2186 |
|
2187 tmp = *iAbbrev12H; |
|
2188 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( tmp ); |
|
2189 timeFrmtItemLists->AppendL( tmp ); |
|
2190 |
|
2191 TInt index( ( ETime24 == iDateTimeInfo.iTimeFormat ) ? 0 : 1 ); |
|
2192 TInt ret( QueryPopupSettingPageL( *timeFrmtItemLists, index, *iTimeFrmt ) ); |
|
2193 CleanupStack::PopAndDestroy( timeFrmtItemLists ); |
|
2194 if( index != ret ) |
|
2195 { |
|
2196 if( 0 == ret ) |
|
2197 { |
|
2198 iDateTimeInfo.iTimeFormat = ETime24; |
|
2199 } |
|
2200 else |
|
2201 { |
|
2202 iDateTimeInfo.iTimeFormat = ETime12; |
|
2203 } |
|
2204 } |
|
2205 } |
|
2206 else |
|
2207 { |
|
2208 if ( ETime24 == iDateTimeInfo.iTimeFormat ) |
|
2209 { |
|
2210 iDateTimeInfo.iTimeFormat = ETime12; |
|
2211 } |
|
2212 else |
|
2213 { |
|
2214 iDateTimeInfo.iTimeFormat = ETime24; |
|
2215 } |
|
2216 } |
|
2217 SetTimeFormat(); |
|
2218 UpdateListBoxL( EClkSettTimeFrmt ); |
|
2219 UpdateListBoxL( EClkSettTime ); |
|
2220 if( iMenuChange ) |
|
2221 { |
|
2222 iMenuChange = EFalse; |
|
2223 } |
|
2224 else |
|
2225 { |
|
2226 if( EClkSettTime >= iContainer->ListBox()->TopItemIndex() ) |
|
2227 { |
|
2228 iContainer->ListBox()->DrawItem( EClkSettTime ); |
|
2229 } |
|
2230 iContainer->ListBox()->DrawItem( EClkSettTimeFrmt ); |
|
2231 } |
|
2232 } |
|
2233 |
|
2234 // --------------------------------------------------------- |
|
2235 // CClkDateTimeView::HandleTimeSeparCmdL |
|
2236 // rest of the details are commented in the header |
|
2237 // --------------------------------------------------------- |
|
2238 // |
|
2239 void CClkDateTimeView::HandleTimeSeparCmdL() |
|
2240 { |
|
2241 if( iMenuChange ) |
|
2242 { |
|
2243 TInt index( iDateTimeInfo.iTimeSepar ); |
|
2244 TInt ret( QueryPopupSettingPageL( *iTimeSeparItemLists, index, *iTimeSepar ) ); |
|
2245 if( index != ret ) |
|
2246 { |
|
2247 iDateTimeInfo.iTimeSepar = ret; |
|
2248 } |
|
2249 } |
|
2250 else |
|
2251 { |
|
2252 if ( iDateTimeInfo.iTimeSepar ) |
|
2253 { |
|
2254 iDateTimeInfo.iTimeSepar = EFalse; |
|
2255 } |
|
2256 else |
|
2257 { |
|
2258 iDateTimeInfo.iTimeSepar = ETrue; |
|
2259 } |
|
2260 } |
|
2261 SetTimeSeparator(); |
|
2262 SetTimeFormat(); |
|
2263 UpdateListBoxL( EClkSettTimeSepar ); |
|
2264 UpdateListBoxL( EClkSettTime ); |
|
2265 if( iMenuChange ) |
|
2266 { |
|
2267 iMenuChange = EFalse; |
|
2268 } |
|
2269 else |
|
2270 { |
|
2271 iContainer->ListBox()->DrawItem( EClkSettTimeSepar ); |
|
2272 } |
|
2273 } |
|
2274 |
|
2275 // --------------------------------------------------------- |
|
2276 // CClkDateTimeView::UnregisterAndReregisterL |
|
2277 // rest of the details are commented in the header |
|
2278 // --------------------------------------------------------- |
|
2279 // |
|
2280 |
|
2281 void CClkDateTimeView::UnregisterAndReregisterL() |
|
2282 { |
|
2283 CAknWaitDialog* aquireNetwork = new ( ELeave ) CAknWaitDialog( NULL, ETrue ); |
|
2284 aquireNetwork->ExecuteLD( R_CLOCK_WAIT_NOTE_NITZ ); |
|
2285 RStarterSession rSession; |
|
2286 User::LeaveIfError( rSession.Connect() ); |
|
2287 User::LeaveIfError( rSession.ResetNetwork() ); |
|
2288 rSession.Close(); |
|
2289 aquireNetwork->ProcessFinishedL(); |
|
2290 } |
|
2291 |
|
2292 // --------------------------------------------------------- |
|
2293 // CClkDateTimeView::HandleNitzCmdL |
|
2294 // rest of the details are commented in the header |
|
2295 // --------------------------------------------------------- |
|
2296 // |
|
2297 void CClkDateTimeView::HandleAutomaticTimeUpdateCmdL( TBool aDraw ) |
|
2298 { |
|
2299 if( iMenuChange ) |
|
2300 { |
|
2301 TInt selectedIndex( iExtension->QueryPopupSettingPageL() ); |
|
2302 |
|
2303 // Get the current automatic time update state.. |
|
2304 GetActiveProtocolL(); |
|
2305 |
|
2306 // Case where user selects ON. |
|
2307 if( selectedIndex && ( KErrCancel != selectedIndex ) ) |
|
2308 { |
|
2309 // If user presses same AUDT state as set. We just return. |
|
2310 if( selectedIndex == iExtension->GetActiveProtocol() ) |
|
2311 { |
|
2312 iMenuChange = EFalse; |
|
2313 return; |
|
2314 } |
|
2315 // User selected an item other than Off. |
|
2316 ActivateAllPluginL(); |
|
2317 } |
|
2318 else if( KZerothIndex == selectedIndex ) |
|
2319 { |
|
2320 iDateTimeInfo.iNITZ = EFalse; |
|
2321 iSrvModel->DeActivateAllProtocols(); |
|
2322 iExtension->SetActiveProtocol(EFalse ); |
|
2323 } |
|
2324 } |
|
2325 else |
|
2326 { |
|
2327 if( iExtension->GetActiveProtocol() ) |
|
2328 { |
|
2329 iDateTimeInfo.iNITZ = EFalse; |
|
2330 iSrvModel->DeActivateAllProtocols(); |
|
2331 iExtension->SetActiveProtocol( EFalse); |
|
2332 } |
|
2333 else |
|
2334 { |
|
2335 ActivateAllPluginL(); |
|
2336 } |
|
2337 } |
|
2338 |
|
2339 // Update the listbox. |
|
2340 SettingsL(); |
|
2341 UpdateAllL(); |
|
2342 iContainer->ListBox()->HandleItemAdditionL(); |
|
2343 |
|
2344 // Reset the menuchange flag. |
|
2345 if( iMenuChange ) |
|
2346 { |
|
2347 iMenuChange = EFalse; |
|
2348 } |
|
2349 else |
|
2350 { |
|
2351 if( aDraw ) |
|
2352 { |
|
2353 iContainer->ListBox()->DrawItem( EClkSettAutomaticTimeUpdate ); |
|
2354 iContainer->ListBox()->UpdateScrollBarsL(); |
|
2355 } |
|
2356 } |
|
2357 } |
|
2358 |
|
2359 // --------------------------------------------------------- |
|
2360 // CClkDateTimeView::HandleClockTypeCmdL |
|
2361 // rest of the details are commented in the header |
|
2362 // --------------------------------------------------------- |
|
2363 // |
|
2364 void CClkDateTimeView::HandleClockTypeCmdL() |
|
2365 { |
|
2366 if( iMenuChange ) |
|
2367 { |
|
2368 // If Change is pressed from options. |
|
2369 CDesCArrayFlat* clockTypeList = new( ELeave ) CDesCArrayFlat( 2 ); |
|
2370 CleanupStack::PushL( clockTypeList ); |
|
2371 // Append the items. |
|
2372 clockTypeList->AppendL( *iAnalog ); |
|
2373 clockTypeList->AppendL( *iDigital ); |
|
2374 // Take the current item index. |
|
2375 TInt currentItemIndex( ( EClockAnalog == iDateTimeInfo.iClockFormat ) ? 0 : 1 ); |
|
2376 // Display the query page. |
|
2377 TInt returnVal( QueryPopupSettingPageL( *clockTypeList, currentItemIndex, *iClockType ) ); |
|
2378 // Cleanup. |
|
2379 CleanupStack::PopAndDestroy( clockTypeList ); |
|
2380 if( currentItemIndex != returnVal ) |
|
2381 { |
|
2382 iDateTimeInfo.iClockFormat = returnVal ? EClockDigital : EClockAnalog; |
|
2383 } |
|
2384 } |
|
2385 else |
|
2386 { |
|
2387 // If MSK change is pressed. |
|
2388 if( EClockAnalog == iDateTimeInfo.iClockFormat ) |
|
2389 { |
|
2390 iDateTimeInfo.iClockFormat = EClockDigital; |
|
2391 } |
|
2392 else |
|
2393 { |
|
2394 iDateTimeInfo.iClockFormat = EClockAnalog; |
|
2395 } |
|
2396 } |
|
2397 |
|
2398 // Update the locale data. |
|
2399 SetClockType(); |
|
2400 // Update the listbox. |
|
2401 UpdateListBoxL( EClkSettClockType ); |
|
2402 if( iMenuChange ) |
|
2403 { |
|
2404 iMenuChange = EFalse; |
|
2405 } |
|
2406 else |
|
2407 { |
|
2408 iContainer->ListBox()->DrawItem( EClkSettClockType ); |
|
2409 } |
|
2410 } |
|
2411 |
|
2412 // --------------------------------------------------------- |
|
2413 // CClkDateTimeView::OpenFileListResourceLC |
|
2414 // rest of the details are commented in the header |
|
2415 // --------------------------------------------------------- |
|
2416 // |
|
2417 void CClkDateTimeView::OpenFileListResourceLC( RConeResourceLoader& aResourceLoader ) |
|
2418 { |
|
2419 TFileName fileName( KResourceDrive ); |
|
2420 |
|
2421 // Construct the full filename. |
|
2422 fileName.Append( KDC_APP_RESOURCE_DIR ); |
|
2423 fileName.Append( KFLDResourceFileName ); |
|
2424 |
|
2425 // Open the file. |
|
2426 aResourceLoader.OpenL( fileName ); |
|
2427 // Cleanup. |
|
2428 CleanupClosePushL( aResourceLoader ); |
|
2429 } |
|
2430 |
|
2431 // --------------------------------------------------------- |
|
2432 // CClkDateTimeView::HandleClockAlarmToneCmdL |
|
2433 // rest of the details are commented in the header |
|
2434 // --------------------------------------------------------- |
|
2435 // |
|
2436 void CClkDateTimeView::HandleClockAlarmToneCmdL() |
|
2437 { |
|
2438 // Set the flag to indicate that the tone selection list is in use. |
|
2439 iExtension->SetAlarmToneListInUse( ETrue ); |
|
2440 |
|
2441 CMediaFileList* list = CMediaFileList::NewL(); |
|
2442 CleanupStack::PushL( list ); |
|
2443 |
|
2444 TInt nullItem( KErrNotFound ); |
|
2445 |
|
2446 // default tone |
|
2447 list->SetNullItemL( iDefaultToneTxt->Des(), iDefaultAlarmToneName, |
|
2448 CMediaFileList::EMediaFileTypeAudio, |
|
2449 CMediaFileList::ENullItemIconDefaultTone ); |
|
2450 |
|
2451 // off |
|
2452 list->SetNullItemL( iSoundOffTxt->Des(), iExtension->GetSilentToneStr()->Des(), |
|
2453 CMediaFileList::EMediaFileTypeAudio, |
|
2454 CMediaFileList::ENullItemIconOff ); |
|
2455 |
|
2456 |
|
2457 list->SetAttrL( CMediaFileList::EAttrAutomatedType, CDRMHelper::EAutomatedTypeClockAlarm ); |
|
2458 list->SetAttrL( CMediaFileList::EAttrExcludeFolder, CMediaFileList::EMediaFileTypeVideo ); |
|
2459 |
|
2460 // Launch the list. ETrue is returned if OK is pressed. EFalse otherwise. |
|
2461 TBool ok( list->ShowMediaFileListL( &iAlarmToneName, &nullItem, NULL, NULL ) ); |
|
2462 |
|
2463 // Cleanup. |
|
2464 CleanupStack::PopAndDestroy( list ); |
|
2465 if( ok ) |
|
2466 { |
|
2467 // User has selected the tone and pressed OK. |
|
2468 // Holder for the old alarm tone. |
|
2469 TFileName oldAlarmTone; |
|
2470 |
|
2471 // Get the old tone from repository. |
|
2472 CRepository* cenRep = CRepository::NewLC( KCRUidClockApp ); |
|
2473 cenRep->Get( KClockAppSoundFile, oldAlarmTone ); |
|
2474 // Unregister the old tone. |
|
2475 UnRegisterSound( oldAlarmTone ); |
|
2476 // Set the new tone. |
|
2477 cenRep->Set( KClockAppSoundFile, iAlarmToneName ); |
|
2478 |
|
2479 // Update the listbox. |
|
2480 UpdateListBoxL( EClkSettTone ); |
|
2481 |
|
2482 // Cleanup. |
|
2483 CleanupStack::PopAndDestroy( cenRep ); |
|
2484 } |
|
2485 iExtension->SetAlarmToneListInUse( EFalse ); |
|
2486 } |
|
2487 |
|
2488 // --------------------------------------------------------- |
|
2489 // CClkDateTimeView::HandleClockSnoozeTimeCmdL |
|
2490 // rest of the details are commented in the header |
|
2491 // --------------------------------------------------------- |
|
2492 // |
|
2493 void CClkDateTimeView::HandleClockSnoozeTimeCmdL() |
|
2494 { |
|
2495 // Get the current snooze value. |
|
2496 TInt snoozeTimeValue( iExtension->GetSnoozeTimeValue() ); |
|
2497 |
|
2498 // Construct the slider dialog. |
|
2499 CAknSliderSettingPage* sliderDlg = new ( ELeave ) CAknSliderSettingPage( R_SNOOZE_TIME_SETTING_PAGE, snoozeTimeValue ); |
|
2500 // Launch the same. |
|
2501 sliderDlg->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ); |
|
2502 |
|
2503 // Update the new value in repository. |
|
2504 CRepository* cenRep = CRepository::NewLC( KCRUidClockApp ); |
|
2505 cenRep->Set( KClockAppSnoozeTime , snoozeTimeValue ); |
|
2506 // Cleanup. |
|
2507 CleanupStack::PopAndDestroy( cenRep ); |
|
2508 |
|
2509 // Update the extention. |
|
2510 iExtension->SetSnoozeTimeValue( snoozeTimeValue ); |
|
2511 |
|
2512 // Update the list. |
|
2513 UpdateListBoxL( EClkSettSnoozeTime ); |
|
2514 } |
|
2515 |
|
2516 // --------------------------------------------------------- |
|
2517 // CClkDateTimeView::QueryPopupSettingPageL |
|
2518 // rest of the details are commented in the header |
|
2519 // --------------------------------------------------------- |
|
2520 // |
|
2521 TInt CClkDateTimeView::QueryPopupSettingPageL( CDesCArray& aItemArray, TInt aIndex, const TDesC& aLabel ) |
|
2522 { |
|
2523 TInt returnVal( aIndex ); |
|
2524 // Construct the text array for the page. |
|
2525 CAknQueryValueTextArray* valueTextArray = CAknQueryValueTextArray::NewL(); |
|
2526 valueTextArray->SetArray( aItemArray ); |
|
2527 |
|
2528 // Construct the text value. |
|
2529 CAknQueryValueText* queryValue = CAknQueryValueText::NewL(); |
|
2530 queryValue->SetArrayL( valueTextArray ); |
|
2531 queryValue->SetCurrentValueIndex( aIndex ); |
|
2532 |
|
2533 CAknPopupSettingPage* settingPageDialog = new( ELeave ) CAknPopupSettingPage( R_DATE_TIME_POPUP_PAGE_MSK, *queryValue ); |
|
2534 CleanupStack::PushL( settingPageDialog ); |
|
2535 // Set the header text. |
|
2536 settingPageDialog->SetSettingTextL( aLabel ); |
|
2537 CleanupStack::Pop( settingPageDialog ); |
|
2538 |
|
2539 if( iExtension->IsAutoTimeUpdatePageOpen() ) |
|
2540 { |
|
2541 // We store the values only when we open the auto time update page. |
|
2542 // Store the query text, text array and setting page pointers for dynamic updation. |
|
2543 iExtension->SetQueryTextArray( valueTextArray ); |
|
2544 iExtension->SetQueryValueText( queryValue ); |
|
2545 iExtension->SetPopupSettingPage( settingPageDialog ); |
|
2546 } |
|
2547 |
|
2548 // Launch the dialog. |
|
2549 settingPageDialog->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ); |
|
2550 |
|
2551 if( iExtension->IsAutoTimeUpdatePageOpen() ) |
|
2552 { |
|
2553 // Get the updated query text values. |
|
2554 queryValue = iExtension->GetQueryValueText(); |
|
2555 valueTextArray = iExtension->GetQueryTextArray(); |
|
2556 } |
|
2557 returnVal = queryValue->CurrentValueIndex(); |
|
2558 |
|
2559 // Cleanup. |
|
2560 delete queryValue; |
|
2561 delete valueTextArray; |
|
2562 |
|
2563 // Return the selected item. |
|
2564 return returnVal; |
|
2565 } |
|
2566 |
|
2567 // --------------------------------------------------------- |
|
2568 // CClkDateTimeView::DoNotiferCallbackL |
|
2569 // rest of the details are commented in the header |
|
2570 // --------------------------------------------------------- |
|
2571 // |
|
2572 TInt CClkDateTimeView::DoNotiferCallbackL( TAny* aThis ) |
|
2573 { |
|
2574 CClkDateTimeView* selfObj = static_cast< CClkDateTimeView* > ( aThis ); |
|
2575 // Get the changes in the environment. |
|
2576 TInt envChanges( selfObj->iNotifier->Change() ); |
|
2577 if( envChanges & ( EChangesMidnightCrossover | EChangesLocale | EChangesSystemTime ) ) |
|
2578 { |
|
2579 // We handle only these changes in the environment. |
|
2580 selfObj->HandleSettingsChangeL( envChanges ); |
|
2581 } |
|
2582 return FALSE; |
|
2583 } |
|
2584 |
|
2585 // --------------------------------------------------------- |
|
2586 // CClkDateTimeView::ShowAutomaticTimeUpdateOffNoteL |
|
2587 // rest of the details are commented in the header |
|
2588 // --------------------------------------------------------- |
|
2589 // |
|
2590 void CClkDateTimeView::ShowAutomaticTimeUpdateOffNoteL() |
|
2591 { |
|
2592 HBufC* string = iCoeEnv->AllocReadResourceLC( R_DATE_TIME_NITZ_SET_OFF_NOTE ); |
|
2593 CAknConfirmationNote* note = new ( ELeave ) CAknConfirmationNote; |
|
2594 note->ExecuteLD( *string ); |
|
2595 CleanupStack::PopAndDestroy( string ); |
|
2596 } |
|
2597 |
|
2598 // -------------------------------------------------------- |
|
2599 // CClkDateTimeView::TimerCallback |
|
2600 // rest of the details are commented in the header |
|
2601 // --------------------------------------------------------- |
|
2602 // |
|
2603 TInt CClkDateTimeView::TimerCallback( TAny* aThis ) |
|
2604 { |
|
2605 CClkDateTimeView* self = STATIC_CAST( CClkDateTimeView*, aThis ); |
|
2606 ( self->iDateTimeInfo ).iTime.HomeTime(); |
|
2607 if ( self->iContainer ) |
|
2608 { |
|
2609 TRAP_IGNORE( self->UpdateListBoxL( EClkSettTime ) ); |
|
2610 // The time item is displayed. |
|
2611 if ( EClkSettDateFrmt> self->iContainer->ListBox()->BottomItemIndex() ) |
|
2612 { |
|
2613 self->iContainer->ListBox()->DrawItem( EClkSettTime ); |
|
2614 } |
|
2615 } |
|
2616 TTime time; |
|
2617 time.HomeTime(); |
|
2618 TDateTime dateTime = time.DateTime(); |
|
2619 if ( 0 < dateTime.Second() ) |
|
2620 { |
|
2621 self->iTimer->Cancel(); |
|
2622 self->iTimer->After( KIntervalTime - 1000000 * dateTime.Second() - dateTime.MicroSecond() ); |
|
2623 } |
|
2624 return FALSE; |
|
2625 } |
|
2626 |
|
2627 |
|
2628 // -------------------------------------------------------- |
|
2629 // CClkDateTimeView::MakeGmtOffsetStringL |
|
2630 // rest of the details are commented in the header |
|
2631 // --------------------------------------------------------- |
|
2632 // |
|
2633 void CClkDateTimeView::MakeGmtOffsetStringL( TInt aUtcOffset ) |
|
2634 { |
|
2635 TBuf< 64 > offsetString; |
|
2636 TInt gmtOffset( aUtcOffset ); |
|
2637 TInt tmp( gmtOffset ); |
|
2638 TInt hours( tmp / KHour ); |
|
2639 TInt minutes( 0 ); |
|
2640 TGmtOffsetText num; |
|
2641 if ( 0 < tmp ) |
|
2642 { |
|
2643 minutes = gmtOffset - hours * KHour; |
|
2644 offsetString += KPlusGMT; |
|
2645 } |
|
2646 else if ( 0 > tmp ) |
|
2647 { |
|
2648 minutes = -( gmtOffset - hours * KHour ); |
|
2649 offsetString += KMinusGMT; |
|
2650 } |
|
2651 else |
|
2652 { |
|
2653 offsetString += KZeroGMT; |
|
2654 } |
|
2655 num.Num( hours ); |
|
2656 offsetString += num; |
|
2657 const TInt KSeparIndex( 1 ); |
|
2658 offsetString.Append( TLocale().TimeSeparator( KSeparIndex ) ); |
|
2659 if ( ( 0 <= minutes ) && ( minutes < 10 ) ) |
|
2660 { |
|
2661 offsetString += KZero; |
|
2662 } |
|
2663 num.Num( minutes ); |
|
2664 offsetString += num; |
|
2665 offsetString += KPDF; |
|
2666 |
|
2667 if( iGMTString ) |
|
2668 { |
|
2669 delete iGMTString; |
|
2670 iGMTString = NULL; |
|
2671 } |
|
2672 iGMTString = HBufC::NewL( iGMTPrefixTxt->Length() + offsetString.Length() ); |
|
2673 TPtr ptr = iGMTString->Des(); |
|
2674 ptr += *iGMTPrefixTxt; |
|
2675 ptr += offsetString; |
|
2676 |
|
2677 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
2678 } |
|
2679 |
|
2680 // --------------------------------------------------------- |
|
2681 // CClkDateTimeView::DeleteResFile |
|
2682 // rest of the details are commented in the header |
|
2683 // --------------------------------------------------------- |
|
2684 // |
|
2685 void CClkDateTimeView::DeleteResFile( TAny* aThis ) |
|
2686 { |
|
2687 CClkDateTimeView* self = STATIC_CAST( CClkDateTimeView*, aThis ); |
|
2688 |
|
2689 self->iCoeEnv->DeleteResourceFile( self->iResourceOffset ); |
|
2690 self->iResourceOffset = 0; |
|
2691 } |
|
2692 |
|
2693 // --------------------------------------------------------- |
|
2694 // CClkDateTimeView::DynInitMenuPaneL |
|
2695 // rest of the details are commented in the header |
|
2696 // --------------------------------------------------------- |
|
2697 // |
|
2698 void CClkDateTimeView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
2699 { |
|
2700 if( R_CLK_DATE_TIME_OPTION_POPUPMENU == aResourceId ) |
|
2701 { |
|
2702 if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
2703 { |
|
2704 aMenuPane->DeleteMenuItem( EAknCmdHelp ); |
|
2705 } |
|
2706 } |
|
2707 } |
|
2708 |
|
2709 // --------------------------------------------------------- |
|
2710 // CClkDateTimeView::UnRegisterSound |
|
2711 // rest of the details are commented in the header |
|
2712 // --------------------------------------------------------- |
|
2713 // |
|
2714 void CClkDateTimeView::UnRegisterSound( const TFileName& aFile ) |
|
2715 { |
|
2716 TInt err( KErrNone ); |
|
2717 TBool automated = EFalse; |
|
2718 err = iDRMHelper->CanSetAutomated( aFile, automated ); |
|
2719 |
|
2720 if( err == KErrNone && automated ) |
|
2721 { |
|
2722 iDRMHelper->RemoveAutomated( aFile ); |
|
2723 } |
|
2724 } |
|
2725 |
|
2726 // --------------------------------------------------------------------------------------------- |
|
2727 // CClkDateTimeView::ConstructGmtStringL |
|
2728 // rest of the details are commented in the header |
|
2729 // --------------------------------------------------------------------------------------------- |
|
2730 // |
|
2731 void CClkDateTimeView::ConstructGmtStringL() |
|
2732 { |
|
2733 TBuf< 64 > offsetString; |
|
2734 TBuf< 50 > locationName; // can be city or country |
|
2735 TInt gmtOffset( 0 ); |
|
2736 |
|
2737 RArray< TInt > zones; |
|
2738 RArray< TInt > offsets; |
|
2739 |
|
2740 RTz tz; |
|
2741 User::LeaveIfError( tz.Connect() ); |
|
2742 CleanupClosePushL( tz ); |
|
2743 |
|
2744 CTzId* tzID; |
|
2745 tzID = tz.GetTimeZoneIdL(); |
|
2746 CleanupStack::PushL( tzID ); |
|
2747 |
|
2748 zones.Append( tzID->TimeZoneNumericID() ); |
|
2749 tz.GetOffsetsForTimeZoneIdsL( zones, offsets ); |
|
2750 |
|
2751 TInt offset( offsets[ 0 ] ); |
|
2752 gmtOffset = offset; |
|
2753 |
|
2754 if( IsDstOnL( zones[ 0 ] ) ) |
|
2755 { |
|
2756 TInt32 dstOffset; |
|
2757 |
|
2758 // Get the offset |
|
2759 GetOffSetWithDstL( dstOffset, *tzID ); |
|
2760 |
|
2761 gmtOffset = dstOffset; |
|
2762 } |
|
2763 |
|
2764 zones.Close(); |
|
2765 offsets.Close(); |
|
2766 |
|
2767 iExtension->UnLocalisedCity( ETrue ); |
|
2768 |
|
2769 CTzLocalizedTimeZone* tzLocTimeZone(NULL); |
|
2770 CTzLocalizer* tzLocalizer(NULL); |
|
2771 TRAPD(err,tzLocalizer = CTzLocalizer::NewL()); |
|
2772 if( tzLocalizer && ( !err) ) |
|
2773 { |
|
2774 CleanupStack::PushL(tzLocalizer); |
|
2775 TRAPD( err,tzLocTimeZone =tzLocalizer->GetLocalizedTimeZoneL( tzID->TimeZoneNumericID() ) ); |
|
2776 |
|
2777 if( ( tzLocTimeZone ) && ( !err ) ) |
|
2778 { |
|
2779 |
|
2780 CleanupStack::PushL(tzLocTimeZone); |
|
2781 CTzLocalizedCity* city = tzLocalizer->GetFrequentlyUsedZoneCityL( CTzLocalizedTimeZone::ECurrentZone ); |
|
2782 CleanupStack::PushL( city ); |
|
2783 |
|
2784 CTzLocalizedCityGroupArray* countryList = tzLocalizer->GetAllCityGroupsL( CTzLocalizer::ETzAlphaNameAscending ); |
|
2785 CleanupStack::PushL( countryList ); |
|
2786 |
|
2787 TInt countryIndex = IndexOfCountry( city->GroupId(), countryList ); |
|
2788 |
|
2789 CTzLocalizedCityArray* cityList = tzLocalizer->GetCitiesInGroupL( ( countryList->At( countryIndex ) ).Id(), |
|
2790 CTzLocalizer::ETzAlphaNameAscending ); |
|
2791 CleanupStack::PushL( cityList ); |
|
2792 |
|
2793 if( cityList->Count() == 1 ) |
|
2794 { |
|
2795 locationName.Copy( countryList->At( countryIndex ).Name() ); |
|
2796 } |
|
2797 else |
|
2798 { |
|
2799 locationName.Copy( city->Name() ); |
|
2800 } |
|
2801 |
|
2802 CleanupStack::PopAndDestroy( cityList ); |
|
2803 CleanupStack::PopAndDestroy( countryList ); |
|
2804 |
|
2805 CleanupStack::PopAndDestroy( city ); |
|
2806 CleanupStack::PopAndDestroy(tzLocTimeZone); |
|
2807 |
|
2808 iExtension->UnLocalisedCity( EFalse ); |
|
2809 } |
|
2810 CleanupStack::PopAndDestroy( tzLocalizer ); |
|
2811 |
|
2812 } |
|
2813 CleanupStack::PopAndDestroy( tzID ); |
|
2814 CleanupStack::PopAndDestroy( &tz ); |
|
2815 |
|
2816 |
|
2817 TInt tmp( gmtOffset ); |
|
2818 TInt hours( tmp / KHour ); |
|
2819 TInt minutes( 0 ); |
|
2820 |
|
2821 TGmtOffsetText num; |
|
2822 if( 0 < tmp ) |
|
2823 { |
|
2824 minutes = gmtOffset - hours * KHour; |
|
2825 offsetString += KPlusGMT; |
|
2826 } |
|
2827 else if( 0 > tmp ) |
|
2828 { |
|
2829 minutes = -( gmtOffset - hours * KHour ); |
|
2830 offsetString += KMinusGMT; //KSpace; |
|
2831 } |
|
2832 else |
|
2833 { |
|
2834 offsetString += KZeroGMT; |
|
2835 } |
|
2836 num.Num( hours ); |
|
2837 offsetString += num; |
|
2838 const TInt KSeparIndex( 1 ); |
|
2839 offsetString.Append( TLocale().TimeSeparator( KSeparIndex ) ); |
|
2840 if ( 0 <= minutes && minutes < 10 ) |
|
2841 { |
|
2842 offsetString += KZero; |
|
2843 } |
|
2844 num.Num( minutes ); |
|
2845 offsetString += num; |
|
2846 offsetString += KPDF; |
|
2847 |
|
2848 if( iGMTString ) |
|
2849 { |
|
2850 delete iGMTString; |
|
2851 iGMTString = NULL; |
|
2852 } |
|
2853 iGMTString = HBufC::NewL( iGMTPrefixTxt->Length() + offsetString.Length() + locationName.Length() + 1 ); |
|
2854 TPtr ptr = iGMTString->Des(); |
|
2855 ptr += *iGMTPrefixTxt; |
|
2856 ptr += offsetString; |
|
2857 ptr += KSingleSpace; |
|
2858 ptr += locationName; |
|
2859 |
|
2860 if( iZoneString ) |
|
2861 { |
|
2862 delete iZoneString; |
|
2863 iZoneString = NULL; |
|
2864 } |
|
2865 iZoneString = iGMTString->Alloc(); |
|
2866 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
2867 } |
|
2868 |
|
2869 // --------------------------------------------------------------------------------------------- |
|
2870 // CClkDateTimeView::MakeWorkDaysItemL |
|
2871 // rest of the details are commented in the header |
|
2872 // --------------------------------------------------------------------------------------------- |
|
2873 // |
|
2874 void CClkDateTimeView::MakeWorkDaysItemL() |
|
2875 { |
|
2876 InsertToItem( KHeader() ); |
|
2877 HBufC* str = StringLoader::LoadLC( R_QTN_CLK_SETT_WORKDAYS, iCoeEnv ); |
|
2878 AppendToItem( str->Des() ); |
|
2879 AppendToItem( KDelimiter() ); |
|
2880 AppendToItem( *( iExtension->GetWorkDaysStr() ) ); |
|
2881 CleanupStack::PopAndDestroy( str ); |
|
2882 } |
|
2883 |
|
2884 // --------------------------------------------------------------------------------------------- |
|
2885 // CClkDateTimeView::HandleWorkDaysCmdL |
|
2886 // rest of the details are commented in the header |
|
2887 // --------------------------------------------------------------------------------------------- |
|
2888 // |
|
2889 void CClkDateTimeView::HandleWorkDaysCmdL() |
|
2890 { |
|
2891 TUint workDays = iExtension->GetWorkDays(); |
|
2892 |
|
2893 CDesCArrayFlat* workDaysList = iExtension->GetWorkDaysList(); |
|
2894 |
|
2895 CSelectionItemList* selectionList = new ( ELeave ) CSelectionItemList( 7 ); |
|
2896 |
|
2897 for( TInt i( 0 ) ; i < workDaysList->MdcaCount(); i++ ) |
|
2898 { |
|
2899 TBuf< 256 > itemText( ( *workDaysList )[ i ] ); |
|
2900 CSelectableItem* item ; |
|
2901 |
|
2902 TReal pow; |
|
2903 Math::Pow( pow, 2, i ); |
|
2904 TInt flag = workDays & ( TInt )pow; |
|
2905 |
|
2906 if( flag ) |
|
2907 { |
|
2908 item = new( ELeave ) CSelectableItem( itemText, ETrue ); |
|
2909 } |
|
2910 else |
|
2911 { |
|
2912 item = new( ELeave ) CSelectableItem( itemText, EFalse ); |
|
2913 } |
|
2914 |
|
2915 item->ConstructL(); |
|
2916 selectionList->AppendL( item ); |
|
2917 } |
|
2918 |
|
2919 TBool wrkDayDefined = EFalse; |
|
2920 |
|
2921 HBufC* str = StringLoader::LoadLC( R_QTN_CLK_SETT_WORKDAYS, iCoeEnv ); |
|
2922 CleanupStack::Pop( str ); |
|
2923 |
|
2924 do |
|
2925 { |
|
2926 CAknCheckBoxSettingPage* dlg = new( ELeave ) CAknCheckBoxSettingPage( R_DATE_TIME_WORKDAYS_CHECKBOX_PAGE_MSK , selectionList ); |
|
2927 |
|
2928 CleanupStack::PushL( dlg ); |
|
2929 CleanupStack::PushL( str ); |
|
2930 dlg->SetSettingTextL( str->Des() ); |
|
2931 CleanupStack::Pop( str ); |
|
2932 CleanupStack::Pop( dlg ); |
|
2933 |
|
2934 if( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ) ) |
|
2935 { |
|
2936 for( TInt i = 0; i < selectionList->Count(); i++ ) |
|
2937 { |
|
2938 TBuf< 2 > tt; |
|
2939 CSelectableItem* item = ( *selectionList )[ i ]; |
|
2940 if( item->SelectionStatus() ) |
|
2941 { |
|
2942 TReal pow; |
|
2943 Math::Pow( pow, 2, i ); |
|
2944 |
|
2945 workDays = ( workDays | ( TInt )pow ); |
|
2946 } |
|
2947 else |
|
2948 { |
|
2949 TReal pow; |
|
2950 Math::Pow( pow, 2, i ); |
|
2951 workDays = workDays & ( 127 - ( TInt )pow ); |
|
2952 } |
|
2953 } |
|
2954 if( workDays > 0 ) |
|
2955 { |
|
2956 iExtension->SetWorkDays( workDays ); |
|
2957 iExtension->ConstructWorkDaysStrL(); |
|
2958 |
|
2959 wrkDayDefined = ETrue; |
|
2960 SetWorkDays(); |
|
2961 UpdateListBoxL( EClkSettWorkDays ); |
|
2962 } |
|
2963 else |
|
2964 { |
|
2965 // Nothing is selected show a dialog and loop |
|
2966 HBufC* str = StringLoader::LoadLC( R_QTN_CLK_SETT_WORKDAYS_NOTE_ONE, iCoeEnv ); |
|
2967 CleanupStack::Pop( str ); |
|
2968 CAknInformationNote* ptr = new ( ELeave ) CAknInformationNote( ETrue ); |
|
2969 ptr->ExecuteLD( str->Des() ); |
|
2970 delete str; |
|
2971 } |
|
2972 } |
|
2973 else |
|
2974 { |
|
2975 // User pressed cancel |
|
2976 TLocale t; |
|
2977 iExtension->SetWorkDays( t.WorkDays() ); |
|
2978 break; |
|
2979 } |
|
2980 |
|
2981 } while( !wrkDayDefined ); |
|
2982 |
|
2983 delete str; |
|
2984 |
|
2985 if( selectionList ) |
|
2986 { |
|
2987 // To avoid old selection to come up again. |
|
2988 selectionList->ResetAndDestroy(); |
|
2989 delete selectionList; |
|
2990 selectionList = NULL; |
|
2991 } |
|
2992 } |
|
2993 |
|
2994 // --------------------------------------------------------------------------------------------- |
|
2995 // CClkDateTimeView::SetWorkDays |
|
2996 // rest of the details are commented in the header |
|
2997 // --------------------------------------------------------------------------------------------- |
|
2998 // |
|
2999 void CClkDateTimeView::SetWorkDays() |
|
3000 { |
|
3001 TLocale locale; |
|
3002 locale.SetWorkDays( iExtension->GetWorkDays() ); |
|
3003 locale.Set(); |
|
3004 } |
|
3005 |
|
3006 |
|
3007 #ifdef _DEBUG |
|
3008 // --------------------------------------------------------- |
|
3009 // Panic |
|
3010 // rest of the details are commented in the header |
|
3011 // --------------------------------------------------------- |
|
3012 // |
|
3013 GLDEF_C void Panic( TClkDateTimeViewPanic aPanic ) |
|
3014 { |
|
3015 _LIT( KClkDateTimePanic, "CLK-DATE-TIME-PANIC" ); |
|
3016 User::Panic( KClkDateTimePanic, aPanic ); |
|
3017 } |
|
3018 #endif // _DEBUG |
|
3019 |
|
3020 |
|
3021 // --------------------------------------------------------- |
|
3022 // CClkDateTimeView::HandleNotifyString |
|
3023 // rest of the details are commented in the header |
|
3024 // --------------------------------------------------------- |
|
3025 // |
|
3026 void CClkDateTimeView::UpdateDTViewL( TUint32 aId, const TDesC16& aNewValue ) |
|
3027 { |
|
3028 if( aId == KClockAppSoundFile ) |
|
3029 { |
|
3030 UnRegisterSound( iAlarmToneName ); |
|
3031 iAlarmToneName = aNewValue; |
|
3032 UpdateListBoxL( EClkSettTone ); |
|
3033 } |
|
3034 else if ( aId == KClockAppSnoozeTime ) |
|
3035 { |
|
3036 SettingsL(); |
|
3037 UpdateListBoxL( EClkSettSnoozeTime ); |
|
3038 } |
|
3039 } |
|
3040 |
|
3041 // --------------------------------------------------------- |
|
3042 // CClkDateTimeView::GetAutoTimeUpdateStr |
|
3043 // rest of the details are commented in the header |
|
3044 // --------------------------------------------------------- |
|
3045 // |
|
3046 HBufC& CClkDateTimeView::GetAutoTimeUpdateStr( TBool aStrVal ) |
|
3047 { |
|
3048 if( aStrVal ) |
|
3049 { |
|
3050 return *iAutomaticTimeUpdateOn; |
|
3051 } |
|
3052 else |
|
3053 { |
|
3054 return *iAutomaticTimeUpdateOff; |
|
3055 } |
|
3056 } |
|
3057 |
|
3058 // --------------------------------------------------------- |
|
3059 // CClkDateTimeView::ClockApplicationUi |
|
3060 // rest of the details are commented in the header |
|
3061 // --------------------------------------------------------- |
|
3062 // |
|
3063 CClockAppUi* CClkDateTimeView::ClockApplicationUi() |
|
3064 { |
|
3065 //__PRINTS( "CClkDateTimeView::ClockApplicationUi - Entry" ); |
|
3066 |
|
3067 //__PRINTS( "CClkDateTimeView::ClockApplicationUi - Exit" ); |
|
3068 |
|
3069 return static_cast< CClockAppUi* > ( AppUi() ); |
|
3070 } |
|
3071 |
|
3072 // --------------------------------------------------------- |
|
3073 // CClkDateTimeView::ShowAlarmExistNoteL |
|
3074 // rest of the details are commented in the header |
|
3075 // --------------------------------------------------------- |
|
3076 // |
|
3077 void CClkDateTimeView::ShowAlarmExistNoteL() |
|
3078 { |
|
3079 TInt validAlmCount = 0; |
|
3080 TInt count = 0; |
|
3081 TTime homeTime; |
|
3082 HBufC* alarmsExists; |
|
3083 |
|
3084 CClkUiAlarmModel* almModel; |
|
3085 RArray< TAlarmId > almIdArray; |
|
3086 SClkAlarmInfo alarmInfo; |
|
3087 |
|
3088 homeTime.HomeTime(); |
|
3089 almModel = CClkUiAlarmModel::NewL( NULL, KAlarmListenerPriority ); |
|
3090 CleanupStack::PushL( almModel ); |
|
3091 |
|
3092 almModel->GetClkAlarmIds( almIdArray ); |
|
3093 count = almIdArray.Count(); |
|
3094 |
|
3095 // Check whether there is atleast one alarm active or not. |
|
3096 for( TInt i = 0; i< count; i++ ) |
|
3097 { |
|
3098 TInt err = almModel->ClockAlarmInfo( almIdArray[ i ], alarmInfo ); |
|
3099 |
|
3100 if( err== KErrNone && alarmInfo.iState != EAlarmStateInPreparation && alarmInfo.iState != EAlarmStateNotified ) |
|
3101 { |
|
3102 if( homeTime < alarmInfo.iAlarmTime ) |
|
3103 { |
|
3104 // There is an active alarm defined which is affected by date change. |
|
3105 validAlmCount++; |
|
3106 } |
|
3107 |
|
3108 if( validAlmCount > 1 ) |
|
3109 { |
|
3110 // More than one alarm no need to query further. |
|
3111 break; |
|
3112 } |
|
3113 } |
|
3114 } |
|
3115 |
|
3116 if( validAlmCount != 0 ) |
|
3117 { |
|
3118 if( validAlmCount > 1 ) |
|
3119 { |
|
3120 alarmsExists = iCoeEnv->AllocReadResourceLC( R_QTN_CLK_NOTE_MULTI_ALARM_DATE_CHANGE ); |
|
3121 } |
|
3122 else |
|
3123 { |
|
3124 alarmsExists = iCoeEnv->AllocReadResourceLC( R_QTN_CLK_NOTE_ALARM_DATE_CHANGE ); |
|
3125 } |
|
3126 |
|
3127 CAknInformationNote* note = new ( ELeave ) CAknInformationNote; |
|
3128 note->ExecuteLD( *alarmsExists ); |
|
3129 CleanupStack::PopAndDestroy( alarmsExists ); |
|
3130 } |
|
3131 |
|
3132 CleanupStack::PopAndDestroy( almModel ); |
|
3133 almIdArray.Close(); |
|
3134 } |
|
3135 |
|
3136 // --------------------------------------------------------- |
|
3137 // CClkDateTimeView::HandleForegroundEventL |
|
3138 // rest of the details are commented in the header |
|
3139 // --------------------------------------------------------- |
|
3140 // |
|
3141 void CClkDateTimeView::HandleForegroundEventL( TBool aForeground ) |
|
3142 { |
|
3143 if( aForeground && iContainer ) |
|
3144 { |
|
3145 SettingsL(); |
|
3146 UpdateAllL(); |
|
3147 |
|
3148 UpdateListBoxL( EClkSettSnoozeTime ); |
|
3149 |
|
3150 // Check if the alarm tone exists. |
|
3151 CheckAlarmToneExistsL(); |
|
3152 } |
|
3153 else |
|
3154 { |
|
3155 CAknView::HandleForegroundEventL( aForeground ); |
|
3156 } |
|
3157 } |
|
3158 |
|
3159 // --------------------------------------------------------- |
|
3160 // CClkDateTimeView::GetOffSetWithDstL |
|
3161 // rest of the details are commented in the header |
|
3162 // --------------------------------------------------------- |
|
3163 // |
|
3164 void CClkDateTimeView::GetOffSetWithDstL( TInt32& aDstOffset, const CTzId& aTzId ) |
|
3165 { |
|
3166 RTz rTz; |
|
3167 User::LeaveIfError( rTz.Connect() ); |
|
3168 CleanupClosePushL( rTz ); |
|
3169 |
|
3170 // Local time |
|
3171 TTime homeTime; |
|
3172 homeTime.HomeTime(); |
|
3173 |
|
3174 TDateTime dateTime; |
|
3175 dateTime = homeTime.DateTime(); |
|
3176 |
|
3177 // Get the CTzRules for the current year and for the given time zone id. |
|
3178 CTzRules* tzRules = rTz.GetTimeZoneRulesL( aTzId, |
|
3179 dateTime.Year(), |
|
3180 dateTime.Year(), |
|
3181 ETzWallTimeReference ); |
|
3182 CleanupStack::PushL( tzRules ); |
|
3183 |
|
3184 // Get the Actualised rules for the same year. These are the DST rules from which we get the iNewOffset. |
|
3185 CVTzActualisedRules *vActualisedRules = CVTzActualisedRules::NewL( |
|
3186 homeTime.DateTime().Year(), |
|
3187 homeTime.DateTime().Year() ); |
|
3188 CleanupStack::PushL( vActualisedRules ); |
|
3189 tzRules->GetActualisedRulesL( *vActualisedRules ); |
|
3190 |
|
3191 // This way of fetching initial offset is being used rather than tzRules->InitialStdTimeOffset() |
|
3192 // because in some cases, the offset returned is incorrect. (For ex: Argentina and Canada/Iqaluit) |
|
3193 RArray< TInt > timeZones; |
|
3194 RArray< TInt > zoneOffsets; |
|
3195 |
|
3196 // Append the current timezone ID and request for the standard offset |
|
3197 timeZones.Append( aTzId.TimeZoneNumericID() ); |
|
3198 rTz.GetOffsetsForTimeZoneIdsL( timeZones, zoneOffsets ); |
|
3199 |
|
3200 // The initial offset or the standard offset (w/o DST) |
|
3201 TInt initialTimeZoneOffset = zoneOffsets[ 0 ]; |
|
3202 |
|
3203 // Close the resource handles |
|
3204 timeZones.Close(); |
|
3205 zoneOffsets.Close(); |
|
3206 |
|
3207 // The number of actualised rules |
|
3208 TInt ruleCount = vActualisedRules->Count(); |
|
3209 |
|
3210 for( TInt ruleIndex( KZerothIndex ); ruleIndex < ruleCount; ruleIndex++ ) |
|
3211 { |
|
3212 const TVTzActualisedRule& tVTzactRule = ( *vActualisedRules )[ ruleIndex ]; |
|
3213 |
|
3214 // If the standard offset and the new offset do not match then we have a dst offset. |
|
3215 // Technically if a timezone has DST then it can have a max of two offsets. One is the standard which doesn't show the |
|
3216 // DST usage, and the other is the DST offset which is standard offset + the amount of DST |
|
3217 if( initialTimeZoneOffset != tVTzactRule.iNewOffset ) |
|
3218 { |
|
3219 aDstOffset = tVTzactRule.iNewOffset; |
|
3220 CleanupStack::PopAndDestroy( vActualisedRules ); |
|
3221 CleanupStack::PopAndDestroy( tzRules ); |
|
3222 CleanupStack::PopAndDestroy( &rTz ); |
|
3223 return; |
|
3224 } |
|
3225 } |
|
3226 CleanupStack::PopAndDestroy( vActualisedRules ); |
|
3227 CleanupStack::PopAndDestroy( tzRules ); |
|
3228 CleanupStack::PopAndDestroy( &rTz ); |
|
3229 } |
|
3230 |
|
3231 // --------------------------------------------------------- |
|
3232 // CClkDateTimeView::CheckForDSTChangesL |
|
3233 // rest of the details are commented in the header |
|
3234 // --------------------------------------------------------- |
|
3235 // |
|
3236 TBool CClkDateTimeView::CheckForDSTChangesL() |
|
3237 { |
|
3238 // Establish connection with RTz to get the timezone ID |
|
3239 RTz tzHandle; |
|
3240 User::LeaveIfError( tzHandle.Connect() ); |
|
3241 CleanupClosePushL( tzHandle ); |
|
3242 |
|
3243 CTzId* timeZoneId = tzHandle.GetTimeZoneIdL(); |
|
3244 CleanupStack::PushL( timeZoneId ); |
|
3245 |
|
3246 // The current time in UTC |
|
3247 TTime currentTime; |
|
3248 currentTime.UniversalTime(); |
|
3249 |
|
3250 TTime homeTime; |
|
3251 homeTime.HomeTime(); |
|
3252 |
|
3253 TDateTime dateTime( homeTime.DateTime().Year(), EJanuary, 1, 0, 0, 0, 0 ); |
|
3254 |
|
3255 TTime tempTime( dateTime ); |
|
3256 |
|
3257 // Get the current rules for the timezone |
|
3258 CTzRules* currentRules = tzHandle.GetTimeZoneRulesL( *timeZoneId, tempTime, currentTime, ETzUtcTimeReference ); |
|
3259 CleanupStack::PushL( currentRules ); |
|
3260 |
|
3261 // Get the initial timezone offset |
|
3262 TInt32 initialTimeZoneOffset = currentRules->InitialStdTimeOffset(); |
|
3263 |
|
3264 // CVTzActualisedRules encapsulates the rules for a specific year. |
|
3265 // Every year has a dummy rule and further DST rules if DST is applicable (if Ohlson provides them) |
|
3266 CVTzActualisedRules *vActualisedRules = CVTzActualisedRules::NewL( |
|
3267 homeTime.DateTime().Year(), |
|
3268 homeTime.DateTime().Year()); |
|
3269 CleanupStack::PushL( vActualisedRules ); |
|
3270 |
|
3271 // The dummy rule is always the begining of the year. |
|
3272 // For example there is only 1 rule for India/NewDelhi but USA/Atlanta has 3 rules. |
|
3273 currentRules->GetActualisedRulesL( *vActualisedRules ); |
|
3274 |
|
3275 const TInt ruleCount = vActualisedRules->Count(); |
|
3276 TInt ruleMatchIndex = KZerothIndex; |
|
3277 |
|
3278 TTimeIntervalHours hourDifference; |
|
3279 TTime ruleMatchTime( KZeroVal ); |
|
3280 TTzTimeReference ruleMatchTimeReference( ETzUtcTimeReference ); |
|
3281 TInt32 ruleMatchTimeOffset( KZeroVal ); |
|
3282 |
|
3283 // Fetch lowest time offset for the year residing at aTime. |
|
3284 // This is used to determine if DST is on. |
|
3285 for ( TInt ruleIndex = KZerothIndex; ruleIndex < ruleCount; ++ruleIndex ) |
|
3286 { |
|
3287 const TVTzActualisedRule& actualisedRule = ( *vActualisedRules )[ ruleIndex ]; |
|
3288 |
|
3289 // Only check for the same year as requested (aTime) |
|
3290 if( actualisedRule.iTimeOfChange.DateTime().Year() == homeTime.DateTime().Year()) |
|
3291 { |
|
3292 // Considering the time reference is important as America (North & South) uses |
|
3293 // the Wall time (local time) reference where as whole of Europe refers to time |
|
3294 // in terms of UTC time. Correspondingly, the choise of local time or utc time |
|
3295 // has to be made. |
|
3296 switch( actualisedRule.iTimeReference ) |
|
3297 { |
|
3298 case ETzUtcTimeReference: |
|
3299 { |
|
3300 currentTime.HoursFrom( actualisedRule.iTimeOfChange, hourDifference ); |
|
3301 } |
|
3302 break; |
|
3303 |
|
3304 case ETzWallTimeReference: |
|
3305 { |
|
3306 homeTime.HoursFrom( actualisedRule.iTimeOfChange, hourDifference ); |
|
3307 } |
|
3308 break; |
|
3309 |
|
3310 case ETzStdTimeReference: |
|
3311 { |
|
3312 // TODO: Testing so far hasn't encountered a rule in this time reference. |
|
3313 // If in case an error is found, corresponding code can be added here. |
|
3314 } |
|
3315 break; |
|
3316 |
|
3317 default: |
|
3318 break; |
|
3319 } |
|
3320 if( ( KHoursInDay > Abs( hourDifference.Int() ) ) && tzHandle.IsDaylightSavingOnL( *timeZoneId,actualisedRule.iTimeOfChange ) ) |
|
3321 { |
|
3322 // If there is a match, save the index and break. |
|
3323 // We've got the rule and there's no need to continue with other rules. |
|
3324 ruleMatchIndex = ruleIndex; |
|
3325 ruleMatchTime = actualisedRule.iTimeOfChange; |
|
3326 ruleMatchTimeReference = actualisedRule.iTimeReference; |
|
3327 ruleMatchTimeOffset = actualisedRule.iNewOffset; |
|
3328 break; |
|
3329 } |
|
3330 } |
|
3331 } |
|
3332 |
|
3333 TBool errorInNote = EFalse; |
|
3334 |
|
3335 if( ruleMatchIndex > KZerothIndex ) |
|
3336 { |
|
3337 // There's a match. Display a confirmation note accordingly. |
|
3338 CAknQueryDialog* note = CAknQueryDialog::NewL(); |
|
3339 |
|
3340 TTimeIntervalSeconds secsDifference; |
|
3341 |
|
3342 // Considering the time reference is important as America (North & South) uses |
|
3343 // the Wall time (local time) reference where as whole of Europe refers to time |
|
3344 // in terms of UTC time. Correspondingly, the choise of local time or utc time |
|
3345 // has to be made. |
|
3346 switch( ruleMatchTimeReference ) |
|
3347 { |
|
3348 case ETzUtcTimeReference: |
|
3349 { |
|
3350 currentTime.SecondsFrom( ruleMatchTime, secsDifference ); |
|
3351 } |
|
3352 break; |
|
3353 |
|
3354 case ETzWallTimeReference: |
|
3355 { |
|
3356 homeTime.SecondsFrom( ruleMatchTime, secsDifference ); |
|
3357 |
|
3358 // During rollback, the time goes back by 1 hour. In which case, the difference will be negative, |
|
3359 // but it should really be positive. So compare if the timezone offsets are equal. If so, make the |
|
3360 // difference positive. |
|
3361 if( ( ruleMatchTimeOffset == initialTimeZoneOffset ) && |
|
3362 ( 3600 >= Abs( secsDifference.Int() ) ) && |
|
3363 ( KErrNone > secsDifference.Int() ) && |
|
3364 ( homeTime < ruleMatchTime ) && |
|
3365 ( !tzHandle.IsDaylightSavingOnL( *timeZoneId ) ) ) |
|
3366 { |
|
3367 secsDifference = - ( secsDifference.Int() ); |
|
3368 } |
|
3369 } |
|
3370 break; |
|
3371 |
|
3372 case ETzStdTimeReference: |
|
3373 { |
|
3374 // TODO: Testing so far hasn't encountered a rule in this time reference. |
|
3375 // If in case an error is found, corresponding code can be added here. |
|
3376 } |
|
3377 break; |
|
3378 |
|
3379 default: |
|
3380 break; |
|
3381 } |
|
3382 |
|
3383 |
|
3384 |
|
3385 if( KNoDifference < secsDifference.Int() ) |
|
3386 { |
|
3387 // Rollover has happened. |
|
3388 if( !( note->ExecuteLD( R_QTN_CLK_QUERY_TIME_DST_PAST ) ) ) |
|
3389 { |
|
3390 errorInNote = ETrue; |
|
3391 } |
|
3392 } |
|
3393 else |
|
3394 { |
|
3395 // Rollover is yet to happen. |
|
3396 if( !( note->ExecuteLD( R_QTN_CLK_QUERY_TIME_DST_COMING ) ) ) |
|
3397 { |
|
3398 errorInNote = ETrue; |
|
3399 } |
|
3400 } |
|
3401 |
|
3402 if( errorInNote ) |
|
3403 { |
|
3404 tzHandle.Close(); |
|
3405 CleanupStack::PopAndDestroy( vActualisedRules ); |
|
3406 CleanupStack::PopAndDestroy( currentRules ); |
|
3407 CleanupStack::PopAndDestroy( timeZoneId ); |
|
3408 CleanupStack::PopAndDestroy( &tzHandle ); |
|
3409 |
|
3410 return errorInNote; |
|
3411 } |
|
3412 } |
|
3413 |
|
3414 tzHandle.Close(); |
|
3415 CleanupStack::PopAndDestroy( vActualisedRules ); |
|
3416 CleanupStack::PopAndDestroy( currentRules ); |
|
3417 CleanupStack::PopAndDestroy( timeZoneId ); |
|
3418 CleanupStack::PopAndDestroy( &tzHandle ); |
|
3419 return errorInNote; |
|
3420 } |
|
3421 |
|
3422 // --------------------------------------------------------- |
|
3423 // CClkDateTimeView::ActivateAllPluginL |
|
3424 // rest of the details are commented in the header |
|
3425 // --------------------------------------------------------- |
|
3426 // |
|
3427 void CClkDateTimeView::ActivateAllPluginL() |
|
3428 { |
|
3429 TInt connectionErr( KErrNone ); |
|
3430 TInt networkStatus; |
|
3431 |
|
3432 // Check if the phone is online. |
|
3433 CRepository* repository = CRepository::NewL( KCRUidCoreApplicationUIs ); |
|
3434 connectionErr = repository->Get( KCoreAppUIsNetworkConnectionAllowed, networkStatus ); |
|
3435 delete repository; |
|
3436 |
|
3437 if( FeatureManager::FeatureSupported( KFeatureIdProtocolCdma ) ) |
|
3438 { |
|
3439 iDateTimeInfo.iNITZ = ETrue; |
|
3440 iSrvModel->ActivateAllProtocols(); |
|
3441 iExtension->SetActiveProtocol( ETrue ); |
|
3442 } |
|
3443 else |
|
3444 { |
|
3445 if( KErrNone == connectionErr ) |
|
3446 { |
|
3447 if( networkStatus ) |
|
3448 { |
|
3449 // Inform user that all active connections would be reset. |
|
3450 CAknQueryDialog* askingRebootNote = CAknQueryDialog::NewL(); |
|
3451 if( askingRebootNote->ExecuteLD( R_ASK_RESET_CONNECTION ) ) |
|
3452 { |
|
3453 // User pressed OK. |
|
3454 iDateTimeInfo.iNITZ = ETrue; |
|
3455 iSrvModel->ActivateAllProtocols(); |
|
3456 iExtension->SetActiveProtocol( ETrue ); |
|
3457 UnregisterAndReregisterL(); |
|
3458 } |
|
3459 } |
|
3460 else |
|
3461 { |
|
3462 iDateTimeInfo.iNITZ = ETrue; |
|
3463 iSrvModel->ActivateAllProtocols(); |
|
3464 iExtension->SetActiveProtocol( ETrue ); |
|
3465 |
|
3466 // Inform the user that time will be updated when phone goes online. |
|
3467 HBufC* phoneOfflineMsg = iCoeEnv->AllocReadResourceLC( R_CLK_NOTE_OFFLINE_NITZ_ON ); |
|
3468 CAknInformationNote* note = new ( ELeave ) CAknInformationNote; |
|
3469 note->ExecuteLD( *phoneOfflineMsg ); |
|
3470 // Cleanup. |
|
3471 CleanupStack::PopAndDestroy( phoneOfflineMsg ); |
|
3472 } |
|
3473 } |
|
3474 } |
|
3475 } |
|
3476 |
|
3477 // --------------------------------------------------------- |
|
3478 // CClkDateTimeView::CheckAlarmToneExistsL |
|
3479 // rest of the details are commented in the header |
|
3480 // --------------------------------------------------------- |
|
3481 // |
|
3482 void CClkDateTimeView::CheckAlarmToneExistsL() |
|
3483 { |
|
3484 // Connect to the file server. |
|
3485 RFile alarmToneFile; |
|
3486 RFs fileServerHandle; |
|
3487 User::LeaveIfError( fileServerHandle.Connect() ); |
|
3488 |
|
3489 // Check if the alarm tone that user has selected exists. |
|
3490 TInt returnVal( alarmToneFile.Open( fileServerHandle, iAlarmToneName, EFileRead ) ); |
|
3491 if( KErrNotFound == returnVal ) |
|
3492 { |
|
3493 // Display a note to the user that the tone is missing. |
|
3494 CAknGlobalNote* missingToneNote = CAknGlobalNote::NewL(); |
|
3495 // Get the file name. |
|
3496 TParse fileParse; |
|
3497 fileParse.Set( iAlarmToneName, NULL, NULL ); |
|
3498 |
|
3499 // Read the string. |
|
3500 HBufC* noteText = StringLoader::LoadLC( R_CLOCK_ALARM_TONE_MISSING, fileParse.NameAndExt(), iCoeEnv ); |
|
3501 // Display the note. |
|
3502 missingToneNote->ShowNoteL( EAknGlobalInformationNote, *noteText ); |
|
3503 // Cleanup. |
|
3504 CleanupStack::PopAndDestroy( noteText ); |
|
3505 delete missingToneNote; |
|
3506 |
|
3507 UnRegisterSound( iAlarmToneName ); |
|
3508 // The selected alarm tone is not present, use the default one. |
|
3509 iAlarmToneName = iDefaultAlarmToneName; |
|
3510 |
|
3511 // Update the cenrep with the same. |
|
3512 CRepository* repository = CRepository::NewL( KCRUidClockApp ); |
|
3513 repository->Set( KClockAppSoundFile, iAlarmToneName ); |
|
3514 delete repository; |
|
3515 |
|
3516 // Refresh the view to reflect the changes. |
|
3517 HandleSettingsChangeL( KErrNone ); |
|
3518 |
|
3519 } |
|
3520 // Cleanup. |
|
3521 alarmToneFile.Close(); |
|
3522 fileServerHandle.Close(); |
|
3523 } |
|
3524 |
|
3525 // End of File |