|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This is the source file for the CClockAlarmEditorImpl class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <e32cmn.h> |
|
20 #include <avkon.rsg> |
|
21 #include <clock.rsg> |
|
22 #include <akntitle.h> |
|
23 #include <eikspane.h> |
|
24 #include <aknpopupsettingpage.h> |
|
25 #include <StringLoader.h> |
|
26 #include <wakeupalarm.h> |
|
27 #include <bautils.h> |
|
28 #include <asshddefs.h> |
|
29 #include <tz.h> |
|
30 #include <vtzrules.h> |
|
31 #include <aknnotewrappers.h> |
|
32 #include <centralrepository.h> |
|
33 #include <hlplch.h> |
|
34 |
|
35 // User includes |
|
36 #include "clockalarmeditorimpl.h" |
|
37 #include "clock.hrh" |
|
38 #include "clock.h" |
|
39 #include "clockmainview.h" |
|
40 #include "clockprivatecrkeys.h" |
|
41 #include "clkcommon.h" |
|
42 #include "clock_debug.h" |
|
43 |
|
44 // Constants |
|
45 const TInt KZerothDay( 0 ); |
|
46 const TInt KDaysInWeek( 7 ); |
|
47 const TInt KFirstLine( 1 ); |
|
48 const TInt KNextDayIndex( 1 ); |
|
49 const TInt KRepeatOnceIndex( 0 ); |
|
50 const TInt KWithIn24HoursIndex( 1 ); |
|
51 const TInt KDailyIndex( 2 ); |
|
52 const TInt KWorkdaysIndex( 3 ); |
|
53 const TInt KWeeklyIndex( 4 ); |
|
54 const TInt KCurrentDayIndex( 0 ); |
|
55 const TInt KMaxCharsInNote( 32 ); |
|
56 const TInt KZerothRule( 0 ); |
|
57 const TInt KOneMinuteInMicrosecond( 1000000 * 60 ); |
|
58 const TInt KNoDifference( 0 ); |
|
59 const TInt KOneHour( 1 ); |
|
60 const TInt KOneHourInMinute( 60 ); |
|
61 const TInt KOneMinute( 1 ); |
|
62 |
|
63 // Literals |
|
64 _LIT( KEmptyString, "" ); |
|
65 _LIT( KSoundName, "a" ); |
|
66 _LIT( KClockResource, "\\resource\\apps\\clock.rsc" ); |
|
67 _LIT( KDateTimeFormatter, "%-B%:0%J%:1%T%:3%+B" ); // For the date and time displayed in the rollover note. |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // CClockAlarmEditorImpl::NewL |
|
71 // rest of the details are commented in the header |
|
72 // --------------------------------------------------------- |
|
73 // |
|
74 CClockAlarmEditorImpl* CClockAlarmEditorImpl::NewL( TAlarmId& aAlarmId ) |
|
75 { |
|
76 __PRINTS( "CClockAlarmEditorImpl::NewL - Entry" ); |
|
77 |
|
78 CClockAlarmEditorImpl* self = new( ELeave ) CClockAlarmEditorImpl( aAlarmId ); |
|
79 |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL(); |
|
82 CleanupStack::Pop( self ); |
|
83 |
|
84 __PRINTS( "CClockAlarmEditorImpl::NewL - Exit" ); |
|
85 |
|
86 return self; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------- |
|
90 // CClockAlarmEditorImpl::~CClockAlarmEditorImpl |
|
91 // rest of the details are commented in the header |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 CClockAlarmEditorImpl::~CClockAlarmEditorImpl() |
|
95 { |
|
96 __PRINTS( "CClockAlarmEditorImpl::~CClockAlarmEditorImpl - Entry" ); |
|
97 |
|
98 iCoeEnv->DeleteResourceFile( iOffset ); |
|
99 |
|
100 // Don't set the title pane text. |
|
101 TRAP_IGNORE( SetTitleL( EFalse ) ); |
|
102 |
|
103 // Close the session with alarm server. |
|
104 iAlarmSrvSes.Close(); |
|
105 |
|
106 __PRINTS( "CClockAlarmEditorImpl::~CClockAlarmEditorImpl - Exit" ); |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------- |
|
110 // CClockAlarmEditorImpl::LoadAlarmInformationL |
|
111 // rest of the details are commented in the header |
|
112 // --------------------------------------------------------- |
|
113 // |
|
114 void CClockAlarmEditorImpl::LoadAlarmInformationL( SClkAlarmInfo& aAlarmInfo, TBool aEditAlarm ) |
|
115 { |
|
116 __PRINTS( "CClockAlarmEditorImpl::LoadAlarmInformationL - Entry" ); |
|
117 |
|
118 // First store the alarm time. |
|
119 iAlarmInfo.iAlarmTime = aAlarmInfo.iAlarmTime; |
|
120 iAlarmForEditing = aEditAlarm; |
|
121 |
|
122 // If the user is setting a new alarm, the default repeat type is once only alarm. |
|
123 // The Description is "Alarm" by default too. |
|
124 if( !iAlarmForEditing ) |
|
125 { |
|
126 iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatNext24Hours; |
|
127 |
|
128 // Here we have to load the default description. |
|
129 HBufC* defaultDescription = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_EDITOR_DESC_DEFAULT, iCoeEnv ); |
|
130 iAlarmInfo.iMessage.Copy( defaultDescription->Des() ); |
|
131 // Cleanup |
|
132 CleanupStack::PopAndDestroy( defaultDescription ); |
|
133 } |
|
134 // Otherwise, we read the info from the structure given. We're interested only in the |
|
135 // repeat type and the message. |
|
136 else |
|
137 { |
|
138 // The repeat type. |
|
139 iAlarmInfo.iRepeat = aAlarmInfo.iRepeat; |
|
140 |
|
141 // As per the ui spec, if the user doesn't change the default description, we need to |
|
142 // leave it blank. Now when we're reading the alarm description, if we find it blank, |
|
143 // while displaying we need to display the default text. |
|
144 if( ( aAlarmInfo.iMessage == KEmptyString ) || |
|
145 ( aAlarmInfo.iMessage == KSingleSpace ) ) |
|
146 { |
|
147 // Here we have to load the default description. |
|
148 HBufC* defaultDescription = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_EDITOR_DESC_DEFAULT, iCoeEnv ); |
|
149 iAlarmInfo.iMessage.Copy( defaultDescription->Des() ); |
|
150 // Cleanup |
|
151 CleanupStack::PopAndDestroy( defaultDescription ); |
|
152 } |
|
153 else |
|
154 { |
|
155 // Copy the description. |
|
156 iAlarmInfo.iMessage = aAlarmInfo.iMessage; |
|
157 } |
|
158 } |
|
159 |
|
160 // The other information we need is the day of the alarm and the repeat type. |
|
161 GetSelectedAlmDayIndex(); |
|
162 GetSelectedOccIndex(); |
|
163 |
|
164 __PRINTS( "CClockAlarmEditorImpl::LoadAlarmInformationL - Exit" ); |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------- |
|
168 // rest of the details are commented in the header |
|
169 // --------------------------------------------------------- |
|
170 // |
|
171 TInt CClockAlarmEditorImpl::ExecuteLD() |
|
172 { |
|
173 // Execute the form. |
|
174 return CAknForm::ExecuteLD( R_CLOCK_ALARM_EDITOR ); |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------- |
|
178 // CClockAlarmEditorImpl::SetInitialCurrentLineL |
|
179 // rest of the details are commented in the header |
|
180 // --------------------------------------------------------- |
|
181 // |
|
182 void CClockAlarmEditorImpl::SetInitialCurrentLineL() |
|
183 { |
|
184 __PRINTS( "CClockAlarmEditorImpl::SetInitialCurrentLineL - Entry" ); |
|
185 |
|
186 // Let the form update itself first. |
|
187 CAknForm::SetInitialCurrentLine(); |
|
188 |
|
189 // We don't display the alarm day selection item for repeated alarms of type daily, next 24 hours and |
|
190 // workdays. So when this functions is called, we check for the type and update the form accordingly. |
|
191 if( KWithIn24HoursIndex == iOccuranceIndex || |
|
192 KDailyIndex == iOccuranceIndex || |
|
193 KWorkdaysIndex == iOccuranceIndex ) |
|
194 { |
|
195 DeleteAlmDayCtrlL(); |
|
196 } |
|
197 |
|
198 __PRINTS( "CClockAlarmEditorImpl::SetInitialCurrentLineL - Exit" ); |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------- |
|
202 // CClockAlarmEditorImpl::SaveFormDataL |
|
203 // rest of the details are commented in the header |
|
204 // --------------------------------------------------------- |
|
205 // |
|
206 TInt CClockAlarmEditorImpl::SaveFormDataL() |
|
207 { |
|
208 __PRINTS( "CClockAlarmEditorImpl::SaveFormDataL - Entry" ); |
|
209 |
|
210 // First read the time from the form. |
|
211 TTime timeFromForm; |
|
212 |
|
213 // We check if the control is there. |
|
214 // Then we get the time from the time editor. |
|
215 if( ControlOrNull( EControlTimeEditor ) ) |
|
216 { |
|
217 timeFromForm = TTimeEditorValue( EControlTimeEditor ); |
|
218 } |
|
219 |
|
220 // Construct the alarm time. |
|
221 // The hometime. |
|
222 TTime homeTime; |
|
223 homeTime.HomeTime(); |
|
224 // The home date time. |
|
225 TDateTime homeDateTime = homeTime.DateTime(); |
|
226 // The alarm date time. |
|
227 TDateTime alarmDateTime = timeFromForm.DateTime(); |
|
228 // Set the month, day, year. |
|
229 alarmDateTime.SetMonth( homeDateTime.Month() ); |
|
230 alarmDateTime.SetDay( homeDateTime.Day() ); |
|
231 alarmDateTime.SetYear( homeDateTime.Year() ); |
|
232 // We have the alarm time. |
|
233 timeFromForm = alarmDateTime; |
|
234 |
|
235 // Get the actual alarm time based on the alarm type and the current time. |
|
236 GetActualAlarmTime( homeTime, timeFromForm ); |
|
237 |
|
238 alarmDateTime = timeFromForm.DateTime(); |
|
239 |
|
240 // Update the alarm information variable. |
|
241 iAlarmInfo.iAlarmTime = timeFromForm; |
|
242 |
|
243 // Now lets update the occurance details. |
|
244 switch( iOccuranceIndex ) |
|
245 { |
|
246 case KRepeatOnceIndex: |
|
247 { |
|
248 iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatOnce; |
|
249 } |
|
250 break; |
|
251 |
|
252 case KWithIn24HoursIndex: |
|
253 { |
|
254 iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatNext24Hours; |
|
255 } |
|
256 break; |
|
257 |
|
258 case KDailyIndex: |
|
259 { |
|
260 iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatDaily; |
|
261 } |
|
262 break; |
|
263 |
|
264 case KWeeklyIndex: |
|
265 { |
|
266 iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatWeekly; |
|
267 } |
|
268 break; |
|
269 |
|
270 case KWorkdaysIndex: |
|
271 { |
|
272 iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatWorkday; |
|
273 } |
|
274 break; |
|
275 |
|
276 default: |
|
277 { |
|
278 // No implementation yet. |
|
279 } |
|
280 break; |
|
281 } |
|
282 |
|
283 // Get the description from the form. |
|
284 GetEdwinText( iAlarmInfo.iMessage, EControlTextEditor ); |
|
285 |
|
286 // We check if the desc is the default one. If so, we save it as blank. |
|
287 HBufC* defaultDescription = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_EDITOR_DESC_DEFAULT, iCoeEnv ); |
|
288 |
|
289 if( iAlarmInfo.iMessage == defaultDescription->Des() ) |
|
290 { |
|
291 // Make the description blank. |
|
292 iAlarmInfo.iMessage = KSingleSpace; |
|
293 } |
|
294 // Cleanup. |
|
295 CleanupStack::PopAndDestroy( defaultDescription ); |
|
296 |
|
297 // The alarm sound. |
|
298 iAlarmInfo.iSound = KSoundName; |
|
299 |
|
300 // Set the alarm, here we connect to the alarm server and set the alarm. |
|
301 SetAlarmL(); |
|
302 |
|
303 // Check if DST rule gets applied in 24hrs. If so we don't display the remaining time. |
|
304 TBool displayRemainingTime( ETrue ); |
|
305 if( !iAlarmForEditing ) |
|
306 { |
|
307 displayRemainingTime = CheckForDstChangesL(); |
|
308 } |
|
309 |
|
310 // Don't display the remaining time if dst changes are applicable. |
|
311 if( displayRemainingTime ) |
|
312 { |
|
313 DisplayRemainingTimeL(); |
|
314 } |
|
315 |
|
316 // Save the previous alarm time value. |
|
317 SetPreviousAlarmTimeL( iAlarmInfo.iAlarmTime ); |
|
318 |
|
319 __PRINTS( "CClockAlarmEditorImpl::SaveFormDataL - Exit" ); |
|
320 |
|
321 return KErrNone; |
|
322 } |
|
323 |
|
324 // --------------------------------------------------------- |
|
325 // CClockAlarmEditorImpl::OkToExitL |
|
326 // rest of the details are commented in the header |
|
327 // --------------------------------------------------------- |
|
328 // |
|
329 TBool CClockAlarmEditorImpl::OkToExitL( TInt aButtonId ) |
|
330 { |
|
331 __PRINTS( "CClockAlarmEditorImpl::OkToExitL - Entry" ); |
|
332 |
|
333 TBool returnVal( ETrue ); |
|
334 |
|
335 switch( aButtonId ) |
|
336 { |
|
337 case EAknSoftkeyOptions: |
|
338 { |
|
339 DisplayMenuL(); |
|
340 returnVal = EFalse ; |
|
341 } |
|
342 break; |
|
343 |
|
344 case EAknSoftkeyDone: |
|
345 { |
|
346 SaveFormDataL(); |
|
347 } |
|
348 break; |
|
349 |
|
350 case EAknSoftkeyChange: |
|
351 { |
|
352 //Single click integration |
|
353 CEikCaptionedControl* line=CurrentLine(); |
|
354 TInt type=line->iControlType; |
|
355 TBool isPopUp= ( type && EAknCtPopupField ) || ( type == EAknCtPopupFieldText ); |
|
356 if ( isPopUp ) |
|
357 { |
|
358 CAknPopupField* ctrl = static_cast<CAknPopupField*>( line->iControl ); |
|
359 ctrl->ActivateSelectionListL(); |
|
360 } |
|
361 returnVal = EFalse ; |
|
362 } |
|
363 break; |
|
364 |
|
365 case EClockAlarmExit: |
|
366 { |
|
367 // Form is closed with returnval ETrue. |
|
368 } |
|
369 break; |
|
370 |
|
371 case EClockAlarmDelete: |
|
372 { |
|
373 // Form is closed with returnval ETrue. |
|
374 } |
|
375 break; |
|
376 |
|
377 case EClockAlarmDiscardChanges: |
|
378 { |
|
379 // Form is closed with return value ETrue. |
|
380 } |
|
381 break; |
|
382 |
|
383 default: |
|
384 { |
|
385 returnVal = EFalse ; |
|
386 } |
|
387 break; |
|
388 } |
|
389 |
|
390 __PRINTS( "CClockAlarmEditorImpl::OkToExitL - Exit" ); |
|
391 |
|
392 return returnVal; |
|
393 } |
|
394 |
|
395 // --------------------------------------------------------- |
|
396 // CClockAlarmEditorImpl::PreLayoutDynInitL |
|
397 // rest of the details are commented in the header |
|
398 // --------------------------------------------------------- |
|
399 // |
|
400 void CClockAlarmEditorImpl::PreLayoutDynInitL() |
|
401 { |
|
402 __PRINTS( "CClockAlarmEditorImpl::PreLayoutDynInitL - Entry" ); |
|
403 |
|
404 // Set the title text. |
|
405 SetTitleL( ETrue ); |
|
406 |
|
407 //Single click integration |
|
408 CAknPopupFieldText* repeatPopupFieldText = |
|
409 static_cast< CAknPopupFieldText* > (Control( EControlOccurancePopup ) ); |
|
410 if ( repeatPopupFieldText ) |
|
411 { |
|
412 repeatPopupFieldText->SetCurrentValueIndex( iOccuranceIndex ); |
|
413 } |
|
414 |
|
415 // Set the value in the time editor control. |
|
416 SetTTimeEditorValue( EControlTimeEditor, iAlarmInfo.iAlarmTime ); |
|
417 |
|
418 //Single click integration |
|
419 // Set the value to be displayed in the control. |
|
420 CAknPopupFieldText* alarmDaySelectionControl = |
|
421 static_cast< CAknPopupFieldText* > ( Control( EControlAlarmDayPopup ) ); |
|
422 |
|
423 if ( alarmDaySelectionControl ) |
|
424 { |
|
425 alarmDaySelectionControl->SetCurrentValueIndex( iDayIndex ); |
|
426 } |
|
427 |
|
428 // Now the alarm description. |
|
429 HBufC* alarmDescription = HBufC::NewL( KMaxAlarmMessageLength ); |
|
430 CleanupStack::PushL( alarmDescription ); |
|
431 // Copy the alarm description. |
|
432 alarmDescription->Des().Copy( iAlarmInfo.iMessage ); |
|
433 // Set the text in the editor. |
|
434 SetEdwinTextL( EControlTextEditor, alarmDescription ); |
|
435 // Cleanup |
|
436 CleanupStack::PopAndDestroy( alarmDescription ); |
|
437 |
|
438 // We don't display the alarm day selection item for repeated alarms of type daily, next 24 hours and |
|
439 // workdays. So when this functions is called, we check for the type and update the form accordingly. |
|
440 if( KWithIn24HoursIndex == iOccuranceIndex || |
|
441 KDailyIndex == iOccuranceIndex || |
|
442 KWorkdaysIndex == iOccuranceIndex ) |
|
443 { |
|
444 DeleteAlmDayCtrlL(); |
|
445 } |
|
446 |
|
447 __PRINTS( "CClockAlarmEditorImpl::PreLayoutDynInitL - Exit" ); |
|
448 } |
|
449 |
|
450 // --------------------------------------------------------- |
|
451 // CClockAlarmEditor::PostLayoutDynInitL |
|
452 // rest of the details are commented in the header |
|
453 // --------------------------------------------------------- |
|
454 // |
|
455 void CClockAlarmEditorImpl::PostLayoutDynInitL() |
|
456 { |
|
457 __PRINTS( "CClockAlarmEditorImpl::PostLayoutDynInitL - Entry" ); |
|
458 |
|
459 LineChangedL( EControlTimeEditor ); |
|
460 |
|
461 // Call the base class PostLayoutDynInitL() |
|
462 CAknForm::PostLayoutDynInitL(); |
|
463 |
|
464 __PRINTS( "CClockAlarmEditorImpl::PostLayoutDynInitL - Exit" ); |
|
465 } |
|
466 |
|
467 // --------------------------------------------------------- |
|
468 // CClockAlarmEditorImpl::ProcessCommandL |
|
469 // rest of the details are commented in the header |
|
470 // --------------------------------------------------------- |
|
471 // |
|
472 void CClockAlarmEditorImpl::ProcessCommandL( TInt aCommandId ) |
|
473 { |
|
474 __PRINTS( "CClockAlarmEditorImpl::ProcessCommandL - Entry" ); |
|
475 |
|
476 // For hiding options menu. |
|
477 HideMenu(); |
|
478 |
|
479 switch( aCommandId ) |
|
480 { |
|
481 case EClockAlarmChange: |
|
482 { |
|
483 //Single click integration |
|
484 CEikCaptionedControl* line=CurrentLine(); |
|
485 TInt type=line->iControlType; |
|
486 TBool isPopUp=( type && EAknCtPopupField ) || ( type == EAknCtPopupFieldText ); |
|
487 if ( isPopUp ) |
|
488 { |
|
489 CAknPopupField* ctrl = static_cast<CAknPopupField*>( line->iControl ); |
|
490 ctrl->ActivateSelectionListL(); |
|
491 } |
|
492 |
|
493 } |
|
494 break; |
|
495 |
|
496 case EClockAlarmDelete: |
|
497 { |
|
498 // TryExitL will in turn call OkToExitL. |
|
499 TryExitL( EClockAlarmDelete ); |
|
500 } |
|
501 break; |
|
502 |
|
503 case EClockAlarmDiscardChanges: |
|
504 { |
|
505 TryExitL( EClockAlarmDiscardChanges ); |
|
506 } |
|
507 break; |
|
508 |
|
509 case EClockAlarmHelp: |
|
510 { |
|
511 // Launch help content |
|
512 HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), iAvkonAppUi->AppHelpContextL() ); |
|
513 } |
|
514 break; |
|
515 |
|
516 case EClockAlarmExit: |
|
517 { |
|
518 TryExitL( EClockAlarmExit ); |
|
519 } |
|
520 break; |
|
521 |
|
522 default: |
|
523 { |
|
524 // No implementation yet. |
|
525 } |
|
526 break; |
|
527 |
|
528 } |
|
529 |
|
530 __PRINTS( "CClockAlarmEditorImpl::ProcessCommandL - Exit" ); |
|
531 } |
|
532 |
|
533 // --------------------------------------------------------- |
|
534 // CClockAlarmEditor::DynInitMenuPaneL |
|
535 // rest of the details are commented in the header |
|
536 // --------------------------------------------------------- |
|
537 // |
|
538 void CClockAlarmEditorImpl::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
539 { |
|
540 __PRINTS( "CClockAlarmEditorImpl::DynInitMenuPaneL - Entry" ); |
|
541 |
|
542 if( aResourceId != R_CLOCK_ALARM_EDITOR_MENUPANE ) |
|
543 { |
|
544 return; |
|
545 } |
|
546 |
|
547 // Execute the following commands if the resource belongs to alarmeditor. |
|
548 // Display the menu items based on the current focused control. |
|
549 if( ( EControlTextEditor == iSelectedControl ) || |
|
550 ( EControlTimeEditor == iSelectedControl ) ) |
|
551 { |
|
552 aMenuPane->SetItemDimmed( EClockAlarmChange, ETrue ); |
|
553 } |
|
554 |
|
555 // Do not show Delete option when editing an alarm. |
|
556 // Do not show Discard changes option if its a new alarm. |
|
557 if( iAlarmForEditing ) |
|
558 { |
|
559 aMenuPane->SetItemDimmed( EClockAlarmDelete, ETrue ); |
|
560 } |
|
561 else |
|
562 { |
|
563 aMenuPane->SetItemDimmed( EClockAlarmDiscardChanges, ETrue ); |
|
564 } |
|
565 |
|
566 __PRINTS( "CClockAlarmEditorImpl::DynInitMenuPaneL - Exit" ); |
|
567 } |
|
568 |
|
569 // --------------------------------------------------------- |
|
570 // CClockAlarmEditor::ConstructL |
|
571 // rest of the details are commented in the header |
|
572 // --------------------------------------------------------- |
|
573 // |
|
574 void CClockAlarmEditorImpl::ConstructL() |
|
575 { |
|
576 __PRINTS( "CClockAlarmEditorImpl::ConstructL - Entry" ); |
|
577 |
|
578 // Open the resource file. |
|
579 TFileName filename( KClockResource ); |
|
580 |
|
581 // Get the nearest language file. |
|
582 BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), filename ); |
|
583 // The offset holds the location of the resource file loaded in the memory. |
|
584 iOffset = iCoeEnv->AddResourceFileL( filename ); |
|
585 |
|
586 // This will finally hold the alarm information. |
|
587 iObserver = NULL; |
|
588 |
|
589 CAknDialog::ConstructL( R_CLOCK_ALARM_EDITOR_MENUBAR ); |
|
590 |
|
591 // Initialize member data. |
|
592 iSelectedControl = KFirstLine; |
|
593 iOccuranceIndex = KZerothDay; |
|
594 iDayIndex = KZerothDay; |
|
595 iShowAlarmDayControl = ETrue; |
|
596 |
|
597 // Connect to the alarm server. |
|
598 User::LeaveIfError( iAlarmSrvSes.Connect() ); |
|
599 |
|
600 // Get the alarm information if the alarm ID has been sent by the client. |
|
601 SClkAlarmInfo alarmInfo; |
|
602 TBool editAlarm( ETrue ); |
|
603 TInt returnVal( NULL ); |
|
604 if( iAlarmId ) |
|
605 { |
|
606 // Try to get the alarm information from the alarm server. |
|
607 returnVal = GetAlarmInformationL( iAlarmId, alarmInfo ); |
|
608 } |
|
609 |
|
610 // Check for valid alarm id or new alarm. |
|
611 if( KErrNone != returnVal || !iAlarmId ) |
|
612 { |
|
613 // We dont have a valid alarm ID or the client wants to |
|
614 // set a new alarm. So get the default alarm values. |
|
615 GetPreviousAlarmTimeL( alarmInfo ); |
|
616 editAlarm = EFalse; |
|
617 } |
|
618 |
|
619 // Load the above information to the form. |
|
620 LoadAlarmInformationL( alarmInfo, editAlarm ); |
|
621 |
|
622 __PRINTS( "CClockAlarmEditorImpl::ConstructL - Exit" ); |
|
623 } |
|
624 |
|
625 // --------------------------------------------------------- |
|
626 // CClockAlarmEditor::CClockAlarmEditorImpl |
|
627 // rest of the details are commented in the header |
|
628 // --------------------------------------------------------- |
|
629 // |
|
630 CClockAlarmEditorImpl::CClockAlarmEditorImpl( TAlarmId& aAlarmId ) : iAlarmId( aAlarmId ) |
|
631 { |
|
632 __PRINTS( "CClockAlarmEditorImpl::CClockAlarmEditor - Entry" ); |
|
633 |
|
634 // No implementation yet. |
|
635 |
|
636 __PRINTS( "CClockAlarmEditorImpl::CClockAlarmEditor - Exit" ); |
|
637 } |
|
638 |
|
639 // --------------------------------------------------------- |
|
640 // CClockAlarmEditorImpl::HandleOccuranceCmdL |
|
641 // rest of the details are commented in the header |
|
642 // --------------------------------------------------------- |
|
643 // |
|
644 void CClockAlarmEditorImpl::HandleOccuranceCmdL() |
|
645 { |
|
646 __PRINTS( "CClockAlarmEditorImpl::HandleOccuranceCmdL - Entry" ); |
|
647 |
|
648 TInt occuranceIndex( iOccuranceIndex ); |
|
649 |
|
650 //Single click integration |
|
651 CAknPopupFieldText* repeatPopupFieldText = |
|
652 (CAknPopupFieldText*)Control( EControlOccurancePopup ); |
|
653 if( repeatPopupFieldText ) |
|
654 { |
|
655 occuranceIndex = repeatPopupFieldText->CurrentValueIndex(); |
|
656 } |
|
657 |
|
658 // Choose the repeat type depending on what is chosen by the user. |
|
659 |
|
660 switch( occuranceIndex ) |
|
661 |
|
662 { |
|
663 case KRepeatOnceIndex: |
|
664 { |
|
665 iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatOnce; |
|
666 } |
|
667 break; |
|
668 |
|
669 case KWithIn24HoursIndex: |
|
670 { |
|
671 iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatNext24Hours; |
|
672 } |
|
673 break; |
|
674 |
|
675 case KDailyIndex: |
|
676 { |
|
677 iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatDaily; |
|
678 } |
|
679 break; |
|
680 |
|
681 case KWorkdaysIndex: |
|
682 { |
|
683 iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatWorkday; |
|
684 } |
|
685 break; |
|
686 |
|
687 case KWeeklyIndex: |
|
688 { |
|
689 iAlarmInfo.iRepeat = EAlarmRepeatDefintionRepeatWeekly; |
|
690 } |
|
691 break; |
|
692 |
|
693 default: |
|
694 { |
|
695 // No implementation yet. |
|
696 } |
|
697 break; |
|
698 } |
|
699 |
|
700 // Get the new occurance index |
|
701 GetSelectedOccIndex(); |
|
702 |
|
703 // We don't display the alarm day selection item for repeated alarms of type daily, next 24 hours and |
|
704 // workdays. So when this functions is called, we check for the type and update the form accordingly. |
|
705 if( KWithIn24HoursIndex == iOccuranceIndex || |
|
706 KDailyIndex == iOccuranceIndex || |
|
707 KWorkdaysIndex == iOccuranceIndex ) |
|
708 { |
|
709 DeleteAlmDayCtrlL(); |
|
710 } |
|
711 // If it is not present, we need to create it. |
|
712 else |
|
713 { |
|
714 CreateAlmDayCtrlL(); |
|
715 } |
|
716 |
|
717 __PRINTS( "CClockAlarmEditorImpl::HandleOccuranceCmdL - Exit" ); |
|
718 } |
|
719 |
|
720 // --------------------------------------------------------- |
|
721 // CClockAlarmEditorImpl::HandleAlarmDayCmdL |
|
722 // rest of the details are commented in the header |
|
723 // --------------------------------------------------------- |
|
724 // |
|
725 void CClockAlarmEditorImpl::HandleAlarmDayCmdL() |
|
726 { |
|
727 __PRINTS( "CClockAlarmEditorImpl::HandleAlarmDayCmdL - Entry" ); |
|
728 //Single click integration |
|
729 // Get the value to be stored in iDayIndex |
|
730 CAknPopupFieldText* alarmDaySelectionControl = |
|
731 (CAknPopupFieldText*)Control( EControlAlarmDayPopup ); |
|
732 |
|
733 if ( alarmDaySelectionControl ) |
|
734 { |
|
735 iDayIndex = alarmDaySelectionControl->CurrentValueIndex(); |
|
736 } |
|
737 } |
|
738 |
|
739 // --------------------------------------------------------- |
|
740 // CClockAlarmEditorImpl::GetSelectedOccIndex |
|
741 // rest of the details are commented in the header |
|
742 // --------------------------------------------------------- |
|
743 // |
|
744 void CClockAlarmEditorImpl::GetSelectedOccIndex() |
|
745 { |
|
746 __PRINTS( "CClockAlarmEditorImpl::GetSelectedOccIndex - Entry" ); |
|
747 |
|
748 // Check the repeat type of the alarm and return the appropriate index. |
|
749 switch( iAlarmInfo.iRepeat ) |
|
750 { |
|
751 case EAlarmRepeatDefintionRepeatOnce: |
|
752 { |
|
753 iOccuranceIndex = KRepeatOnceIndex; |
|
754 } |
|
755 break; |
|
756 |
|
757 case EAlarmRepeatDefintionRepeatNext24Hours: |
|
758 { |
|
759 iOccuranceIndex = KWithIn24HoursIndex; |
|
760 } |
|
761 break; |
|
762 |
|
763 case EAlarmRepeatDefintionRepeatDaily: |
|
764 { |
|
765 iOccuranceIndex = KDailyIndex; |
|
766 } |
|
767 break; |
|
768 |
|
769 case EAlarmRepeatDefintionRepeatWorkday: |
|
770 { |
|
771 iOccuranceIndex = KWorkdaysIndex; |
|
772 } |
|
773 break; |
|
774 case EAlarmRepeatDefintionRepeatWeekly: |
|
775 { |
|
776 iOccuranceIndex = KWeeklyIndex; |
|
777 } |
|
778 break; |
|
779 |
|
780 default: |
|
781 { |
|
782 // No implementation yet. |
|
783 } |
|
784 break; |
|
785 } |
|
786 |
|
787 __PRINTS( "CClockAlarmEditorImpl::GetSelectedOccIndex - Exit" ); |
|
788 } |
|
789 |
|
790 // --------------------------------------------------------- |
|
791 // CClockAlarmEditorImpl::GetSelectedAlmDayIndex |
|
792 // rest of the details are commented in the header |
|
793 // --------------------------------------------------------- |
|
794 // |
|
795 void CClockAlarmEditorImpl::GetSelectedAlmDayIndex() |
|
796 { |
|
797 __PRINTS( "CClockAlarmEditorImpl::GetSelectedAlmDayIndex - Entry" ); |
|
798 |
|
799 TTime alarmTime = iAlarmInfo.iAlarmTime; |
|
800 TDay weekDay; |
|
801 |
|
802 // If its a new alarm, we need to calculate the alarm day. |
|
803 if( !iAlarmForEditing ) |
|
804 { |
|
805 TDateTime alarmDateTime = alarmTime.DateTime(); |
|
806 |
|
807 TTime homeTime; |
|
808 homeTime.HomeTime(); |
|
809 |
|
810 alarmDateTime.SetDay( homeTime.DateTime().Day() ); |
|
811 alarmDateTime.SetMonth( homeTime.DateTime().Month() ); |
|
812 alarmDateTime.SetYear( homeTime.DateTime().Year() ); |
|
813 alarmTime = alarmDateTime; |
|
814 |
|
815 // Move the alarm time to tomorrow, if the alarm time is in the past. |
|
816 if( alarmTime < homeTime ) |
|
817 { |
|
818 TTimeIntervalDays intervalDays( KFirstLine ); |
|
819 alarmTime = alarmTime + intervalDays; |
|
820 } |
|
821 } |
|
822 // Select the alarm day. |
|
823 weekDay = alarmTime.DayNoInWeek(); |
|
824 iDayIndex = ( TDay ) weekDay; |
|
825 |
|
826 __PRINTS( "CClockAlarmEditorImpl::GetSelectedAlmDayIndex - Exit" ); |
|
827 } |
|
828 |
|
829 // --------------------------------------------------------- |
|
830 // CClockAlarmEditorImpl::CreateAlmDayCtrlL |
|
831 // rest of the details are commented in the header |
|
832 // --------------------------------------------------------- |
|
833 // |
|
834 void CClockAlarmEditorImpl::CreateAlmDayCtrlL() |
|
835 { |
|
836 __PRINTS( "CClockAlarmEditorImpl::CreateAlmDayCtrlL - Entry" ); |
|
837 |
|
838 TTime aNewAlmTime, aCurrTime; |
|
839 TInt dayIndex = iDayIndex ; |
|
840 |
|
841 // We construct the alarm day control only if it is not already there. |
|
842 if( !iShowAlarmDayControl ) |
|
843 { |
|
844 // Get the current system time |
|
845 aCurrTime.HomeTime(); |
|
846 CEikTTimeEditor* tTimeEditor=(CEikTTimeEditor*)Control(KFirstLine); |
|
847 aNewAlmTime = tTimeEditor->GetTTime(); |
|
848 |
|
849 TDateTime aTimeChange = aNewAlmTime.DateTime(); |
|
850 |
|
851 aTimeChange.SetYear(aCurrTime.DateTime().Year()); |
|
852 aTimeChange.SetMonth(aCurrTime.DateTime().Month()); |
|
853 aTimeChange.SetDay(aCurrTime.DateTime().Day()); |
|
854 |
|
855 TTime tmpTimeChange(aTimeChange); |
|
856 aNewAlmTime = tmpTimeChange; |
|
857 |
|
858 if ( aNewAlmTime > aCurrTime ) |
|
859 { |
|
860 dayIndex = aCurrTime.DayNoInWeek(); |
|
861 } |
|
862 else |
|
863 { |
|
864 dayIndex = aCurrTime.DayNoInWeek() >= 6?0:(aCurrTime.DayNoInWeek()+1); |
|
865 } |
|
866 |
|
867 // First get the number of lines present. |
|
868 TInt lineCount = GetNumberOfLinesOnPage( KZerothDay ); |
|
869 |
|
870 // Insert the line at the position above. |
|
871 InsertLineL( lineCount, R_CLOCK_ALARMDAY_POPUP_LINE, KZerothDay); |
|
872 |
|
873 CAknPopupFieldText* iAlmDayCtrl = static_cast< CAknPopupFieldText* > ( Control( EControlAlarmDayPopup ) ); |
|
874 iAlmDayCtrl->SetCurrentValueIndex( dayIndex ); |
|
875 |
|
876 // Set the flag to indicate that the alarm day control is present in the form. |
|
877 iShowAlarmDayControl = ETrue; |
|
878 |
|
879 // Update the page. |
|
880 UpdatePageL( ETrue ); |
|
881 } |
|
882 iDayIndex = dayIndex; |
|
883 |
|
884 __PRINTS( "CClockAlarmEditorImpl::CreateAlmDayCtrlL - Exit" ); |
|
885 } |
|
886 |
|
887 // --------------------------------------------------------- |
|
888 // CClockAlarmEditorImpl::DeleteAlmDayCtrlL |
|
889 // rest of the details are commented in the header |
|
890 // --------------------------------------------------------- |
|
891 // |
|
892 void CClockAlarmEditorImpl::DeleteAlmDayCtrlL() |
|
893 { |
|
894 __PRINTS( "CClockAlarmEditorImpl::DeleteAlmDayCtrlL - Entry" ); |
|
895 |
|
896 // Delete the control only if it is present. |
|
897 //Single click integration |
|
898 if( iShowAlarmDayControl ) |
|
899 { |
|
900 iShowAlarmDayControl = EFalse; |
|
901 // Delete the control. |
|
902 DeleteLine( EControlAlarmDayPopup ); |
|
903 // Update the form. |
|
904 UpdatePageL( ETrue ); |
|
905 |
|
906 } |
|
907 |
|
908 __PRINTS( "CClockAlarmEditorImpl::DeleteAlmDayCtrlL - Exit" ); |
|
909 } |
|
910 |
|
911 // --------------------------------------------------------- |
|
912 // CClockAlarmEditorImpl::SetTitleL |
|
913 // rest of the details are commented in the header |
|
914 // --------------------------------------------------------- |
|
915 // |
|
916 void CClockAlarmEditorImpl::SetTitleL( TBool aNonDefault ) |
|
917 { |
|
918 __PRINTS( "CClockAlarmEditorImpl::SetTitleL - Entry" ); |
|
919 |
|
920 // First get the title pane from appui. |
|
921 CAknTitlePane* titlePane = |
|
922 static_cast< CAknTitlePane* > |
|
923 ( iEikonEnv->AppUiFactory()->StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
924 |
|
925 if( aNonDefault ) |
|
926 { |
|
927 // Read the title text from resource. |
|
928 HBufC* titleText = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_EDITOR_TITLE, iEikonEnv ); |
|
929 TPtr titleTextPtr = titleText->Des(); |
|
930 // For converting text |
|
931 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( titleTextPtr ); |
|
932 // Set the text in the title pane. |
|
933 titlePane->SetTextL( *titleText ); |
|
934 // Cleanup. |
|
935 CleanupStack::PopAndDestroy( titleText ); |
|
936 } |
|
937 else |
|
938 { |
|
939 titlePane->SetTextToDefaultL(); |
|
940 } |
|
941 |
|
942 __PRINTS( "CClockAlarmEditorImpl::SetTitleL - Exit" ); |
|
943 } |
|
944 |
|
945 // --------------------------------------------------------- |
|
946 // CClockAlarmEditorImpl::SetAlarmL |
|
947 // rest of the details are commented in the header |
|
948 // --------------------------------------------------------- |
|
949 // |
|
950 void CClockAlarmEditorImpl::SetAlarmL() |
|
951 { |
|
952 __PRINTS( "CClockAlarmEditorImpl::SetAlarmL - Entry" ); |
|
953 |
|
954 // Here we connect to the alarm server to set the alarm. We don't need to use the alarm model |
|
955 // as the alarm editor doesn't need any notification from the alarm server about changes. |
|
956 RASCliSession alarmSrvSes; |
|
957 TASShdAlarm newAlarm; |
|
958 // Connect to the alarm server. |
|
959 User::LeaveIfError( alarmSrvSes.Connect() ); |
|
960 |
|
961 // Build the alarm properties from the info provided. |
|
962 newAlarm.Category() = KAlarmClockOne; |
|
963 newAlarm.Message() = iAlarmInfo.iMessage; |
|
964 newAlarm.OriginalExpiryTime() = iAlarmInfo.iAlarmTime; |
|
965 newAlarm.RepeatDefinition() = iAlarmInfo.iRepeat; |
|
966 newAlarm.SoundName() = iAlarmInfo.iSound; |
|
967 newAlarm.NextDueTime() = iAlarmInfo.iAlarmTime; |
|
968 |
|
969 // SSM related change. |
|
970 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT |
|
971 newAlarm.SetWakeup( ETrue ); |
|
972 #else |
|
973 newAlarm.ClientFlags().Set( KWakeupAlarmFlagIndex ); |
|
974 #endif |
|
975 |
|
976 // This will add the alarm with the alarm server. |
|
977 alarmSrvSes.AlarmAdd( newAlarm ); |
|
978 |
|
979 // Save the new alarm id. |
|
980 iAlarmId = newAlarm.Id(); |
|
981 |
|
982 // Close the session with alarmserver. |
|
983 alarmSrvSes.Close(); |
|
984 |
|
985 // Update the alarm info. |
|
986 GetAlarmInformationL( iAlarmId, iAlarmInfo ); |
|
987 |
|
988 __PRINTS( "CClockAlarmEditorImpl::SetAlarmL - Exit" ); |
|
989 } |
|
990 // --------------------------------------------------------- |
|
991 // CClockAlarmEditorImpl::GetActualAlarmTime |
|
992 // rest of the details are commented in the header |
|
993 // --------------------------------------------------------- |
|
994 // |
|
995 void CClockAlarmEditorImpl::GetActualAlarmTime( const TTime& aHomeTime, TTime& aTimeFromForm ) |
|
996 { |
|
997 __PRINTS( "CClockAlarmEditorImpl::GetActualAlarmTime - Entry" ); |
|
998 |
|
999 // Get the current day of the week. |
|
1000 TInt currentDay( aHomeTime.DayNoInWeek() ); |
|
1001 |
|
1002 if( ( EAlarmRepeatDefintionRepeatOnce == iOccuranceIndex ) || |
|
1003 ( EAlarmRepeatDefintionRepeatWeekly == iOccuranceIndex ) ) |
|
1004 { |
|
1005 TInt dateOffset( KZerothDay ); |
|
1006 |
|
1007 if( currentDay < iDayIndex ) |
|
1008 { |
|
1009 dateOffset = iDayIndex - currentDay; |
|
1010 } |
|
1011 else if( currentDay > iDayIndex ) |
|
1012 { |
|
1013 dateOffset = KDaysInWeek - ( currentDay - iDayIndex ); |
|
1014 } |
|
1015 else if( currentDay == iDayIndex ) |
|
1016 { |
|
1017 // This is the case where we check if the time set by the user is in the past. |
|
1018 // So we add 7 days to the alarm day. |
|
1019 if( aTimeFromForm > aHomeTime ) |
|
1020 { |
|
1021 dateOffset = KZerothDay; |
|
1022 } |
|
1023 else |
|
1024 { |
|
1025 dateOffset = KDaysInWeek; |
|
1026 } |
|
1027 } |
|
1028 aTimeFromForm += TTimeIntervalDays( dateOffset ); |
|
1029 } |
|
1030 else if( EAlarmRepeatDefintionRepeatNext24Hours == iOccuranceIndex ) |
|
1031 { |
|
1032 TInt dayIndex( KCurrentDayIndex ); |
|
1033 if( aTimeFromForm < aHomeTime ) |
|
1034 { |
|
1035 dayIndex = KNextDayIndex; |
|
1036 } |
|
1037 aTimeFromForm += TTimeIntervalDays( dayIndex ); |
|
1038 } |
|
1039 |
|
1040 __PRINTS( "CClockAlarmEditorImpl::GetActualAlarmTime - Exit" ); |
|
1041 } |
|
1042 |
|
1043 // --------------------------------------------------------- |
|
1044 // CClockAlarmEditorImpl::GetAlarmInformationL |
|
1045 // rest of the details are commented in the header |
|
1046 // --------------------------------------------------------- |
|
1047 // |
|
1048 TInt CClockAlarmEditorImpl::GetAlarmInformationL( TAlarmId aExistingAlarmId, |
|
1049 SClkAlarmInfo& aAlarmInfo ) |
|
1050 { |
|
1051 __PRINTS( "CClockAlarmEditorImpl::GetAlarmInformationL - Entry" ); |
|
1052 |
|
1053 TASShdAlarm tempAlarm; |
|
1054 |
|
1055 TInt returnVal = iAlarmSrvSes.GetAlarmDetails( aExistingAlarmId, tempAlarm ); |
|
1056 |
|
1057 if( KErrNone == returnVal ) |
|
1058 { |
|
1059 aAlarmInfo.iAlarmTime = tempAlarm.NextDueTime(); |
|
1060 aAlarmInfo.iMessage = tempAlarm.Message(); |
|
1061 aAlarmInfo.iOrigExpiryTime = tempAlarm.OriginalExpiryTime(); |
|
1062 aAlarmInfo.iRepeat = tempAlarm.RepeatDefinition(); |
|
1063 aAlarmInfo.iSound = tempAlarm.SoundName(); |
|
1064 aAlarmInfo.iState = tempAlarm.State(); |
|
1065 aAlarmInfo.iStatus = tempAlarm.Status(); |
|
1066 iAlarmSrvSes.GetAlarmCategory( aExistingAlarmId, aAlarmInfo.iCategory ); |
|
1067 } |
|
1068 |
|
1069 __PRINTS( "CClockAlarmEditorImpl::GetAlarmInformationL - Exit" ); |
|
1070 |
|
1071 return returnVal; |
|
1072 } |
|
1073 |
|
1074 // --------------------------------------------------------- |
|
1075 // CClockAlarmEditorImpl::GetPreviousAlarmTimeL |
|
1076 // rest of the details are commented in the header |
|
1077 // --------------------------------------------------------- |
|
1078 // |
|
1079 void CClockAlarmEditorImpl::GetPreviousAlarmTimeL( SClkAlarmInfo& aAlarmInfo ) |
|
1080 { |
|
1081 __PRINTS( "CClockAlarmEditorImpl::GetPreviousAlarmTimeL - Entry" ); |
|
1082 |
|
1083 // Get the previous alarm time value from cenrep. |
|
1084 CRepository* cenRep( NULL ); |
|
1085 TInt alarmTimeHour( NULL ); |
|
1086 TTime homeTime; |
|
1087 homeTime.HomeTime(); |
|
1088 TDateTime homeDateTime( homeTime.DateTime() ); |
|
1089 |
|
1090 // Open the repository. |
|
1091 TRAPD( errVal, cenRep = CRepository::NewL( KCRUidNitz ) ); |
|
1092 if( KErrNone == errVal ) |
|
1093 { |
|
1094 CleanupStack::PushL( cenRep ); |
|
1095 |
|
1096 // Read the key. |
|
1097 errVal = cenRep->Get( KPreviousAlarmTime, alarmTimeHour ); |
|
1098 |
|
1099 // Update the time. |
|
1100 homeDateTime.SetHour( alarmTimeHour / 60 ); |
|
1101 homeDateTime.SetMinute( alarmTimeHour % 60 ); |
|
1102 homeDateTime.SetSecond( NULL ); |
|
1103 homeDateTime.SetMicroSecond( NULL ); |
|
1104 |
|
1105 homeTime = homeDateTime; |
|
1106 |
|
1107 // Save the alarm time in the info. |
|
1108 aAlarmInfo.iAlarmTime = homeTime.Int64(); |
|
1109 |
|
1110 // Cleanup. |
|
1111 CleanupStack::PopAndDestroy( cenRep ); |
|
1112 |
|
1113 __PRINTS( "CClockAlarmEditorImpl::GetPreviousAlarmTimeL - Exit" ); |
|
1114 |
|
1115 return; |
|
1116 } |
|
1117 |
|
1118 // If there is a problem with opening cenrep, we fill the default time. |
|
1119 // Set the hour minute and second. |
|
1120 homeDateTime.SetHour( 9 ); |
|
1121 homeDateTime.SetMinute( 0 ); |
|
1122 homeDateTime.SetSecond( 0 ); |
|
1123 homeTime = homeDateTime; |
|
1124 |
|
1125 // Save the alarm time in the info. |
|
1126 aAlarmInfo.iAlarmTime = homeTime.Int64(); |
|
1127 |
|
1128 __PRINTS( "CClockAlarmEditorImpl::GetPreviousAlarmTimeL - Exit" ); |
|
1129 } |
|
1130 |
|
1131 // --------------------------------------------------------- |
|
1132 // CClockAlarmEditorImpl::SetPreviousAlarmTimeL |
|
1133 // rest of the details are commented in the header |
|
1134 // --------------------------------------------------------- |
|
1135 // |
|
1136 void CClockAlarmEditorImpl::SetPreviousAlarmTimeL( TTime& aTime ) |
|
1137 { |
|
1138 __PRINTS( "CClockAlarmEditorImpl::SetPreviousAlarmTimeL - Entry" ); |
|
1139 |
|
1140 CRepository* cenRep( NULL ); |
|
1141 TInt alarmTimeMinutes( NULL ); |
|
1142 |
|
1143 // Open the repository. |
|
1144 TRAPD( errVal, cenRep = CRepository::NewL( KCRUidNitz ) ); |
|
1145 if( KErrNone == errVal ) |
|
1146 { |
|
1147 CleanupStack::PushL( cenRep ); |
|
1148 |
|
1149 // Get the high and low alarm time values. |
|
1150 alarmTimeMinutes = aTime.DateTime().Hour() * 60 + aTime.DateTime().Minute(); |
|
1151 |
|
1152 // Set the values in cenrep. |
|
1153 cenRep->Set( KPreviousAlarmTime, alarmTimeMinutes ); |
|
1154 |
|
1155 // Cleanup. |
|
1156 CleanupStack::PopAndDestroy( cenRep ); |
|
1157 |
|
1158 __PRINTS( "CClockAlarmEditorImpl::GetPreviousAlarmTimeL - Exit" ); |
|
1159 |
|
1160 return; |
|
1161 } |
|
1162 |
|
1163 __PRINTS( "CClockAlarmEditorImpl::SetPreviousAlarmTimeL - Exit" ); |
|
1164 } |
|
1165 |
|
1166 |
|
1167 // --------------------------------------------------------- |
|
1168 // CClockAlarmEditorImpl::CheckForDstChangesL |
|
1169 // rest of the details are commented in the header |
|
1170 // --------------------------------------------------------- |
|
1171 // |
|
1172 TBool CClockAlarmEditorImpl::CheckForDstChangesL() |
|
1173 { |
|
1174 __PRINTS( "CClockAlarmEditorImpl::CheckForDstChangesL - Entry" ); |
|
1175 |
|
1176 // User to be notified whether DST rollover happens in a day or |
|
1177 // has happen within a day if he tries to change the time. |
|
1178 TBool returnValue( ETrue ); |
|
1179 |
|
1180 // Establish connection with RTz to get the timezone ID |
|
1181 RTz tzHandle; |
|
1182 User::LeaveIfError( tzHandle.Connect() ); |
|
1183 CleanupClosePushL( tzHandle ); |
|
1184 |
|
1185 // The timezone ID (current) |
|
1186 CTzId* currentTZId = tzHandle.GetTimeZoneIdL(); |
|
1187 CleanupStack::PushL( currentTZId ); |
|
1188 |
|
1189 // The current time in UTC |
|
1190 TTime currentTime; |
|
1191 currentTime.UniversalTime(); |
|
1192 |
|
1193 // hometime (local time) |
|
1194 TTime homeTime; |
|
1195 homeTime.HomeTime(); |
|
1196 |
|
1197 //(Year, Month, Day, Hour, Minute, Second, Micrsecond) |
|
1198 TDateTime dateTime( homeTime.DateTime().Year(), EJanuary, 1, FALSE, FALSE, FALSE, FALSE ); |
|
1199 |
|
1200 TTime tempTime( dateTime ); |
|
1201 |
|
1202 // Get the current rules for the timezone |
|
1203 CTzRules* currentRules = tzHandle.GetTimeZoneRulesL( *currentTZId, tempTime, currentTime, ETzUtcTimeReference ); |
|
1204 CleanupStack::PushL( currentRules ); |
|
1205 |
|
1206 // CVTzActualisedRules encapsulates the rules for a specific year. |
|
1207 // Every year has a dummy rule and further DST rules if DST is applicable (if Ohlson provides them) |
|
1208 CVTzActualisedRules *vActualisedRules = CVTzActualisedRules::NewL( |
|
1209 homeTime.DateTime().Year(), |
|
1210 homeTime.DateTime().Year()); |
|
1211 CleanupStack::PushL( vActualisedRules ); |
|
1212 |
|
1213 // The dummy rule is always the begining of the year. |
|
1214 // For example there is only 1 rule for India/NewDelhi but USA/Atlanta has 3 rules. |
|
1215 currentRules->GetActualisedRulesL( *vActualisedRules ); |
|
1216 |
|
1217 const TInt ruleCount( vActualisedRules->Count() ); |
|
1218 TInt ruleMatchIndex( KNoDifference ); |
|
1219 |
|
1220 TTimeIntervalSeconds secondsDifference; |
|
1221 TTime ruleMatchTime; |
|
1222 |
|
1223 // Fetch lowest time offset for the year residing at aTime. |
|
1224 // This is used to determine if DST is on. |
|
1225 for( TInt ruleIndex( FALSE ); ruleIndex < ruleCount; ++ruleIndex ) |
|
1226 { |
|
1227 const TVTzActualisedRule& actualisedRule = ( *vActualisedRules )[ ruleIndex ]; |
|
1228 |
|
1229 // Only check for the same year as requested (aTime) |
|
1230 if( actualisedRule.iTimeOfChange.DateTime().Year() == homeTime.DateTime().Year() ) |
|
1231 { |
|
1232 iAlarmInfo.iAlarmTime.SecondsFrom( actualisedRule.iTimeOfChange, secondsDifference ); |
|
1233 // Considering the time reference is important as America (North & South) uses |
|
1234 // the Wall time (local time) reference where as whole of Europe refers to time |
|
1235 // in terms of UTC time. Correspondingly, the choise of local time or utc time |
|
1236 // has to be made. |
|
1237 TTime ruleTime; |
|
1238 |
|
1239 if( ETzUtcTimeReference == actualisedRule.iTimeReference ) |
|
1240 { |
|
1241 ruleTime = currentTime; |
|
1242 } |
|
1243 else if( ETzWallTimeReference == actualisedRule.iTimeReference ) |
|
1244 { |
|
1245 ruleTime = homeTime; |
|
1246 } |
|
1247 else if( ETzStdTimeReference == actualisedRule.iTimeReference ) |
|
1248 { |
|
1249 // TODO: Testing so far hasn't encountered a rule in this time reference. |
|
1250 // If in case an error is found, corresponding code can be added here. |
|
1251 // No support from symbian for this. |
|
1252 } |
|
1253 |
|
1254 TDateTime sevenDays( FALSE, EJanuary, KDaysInWeek, FALSE, FALSE, FALSE, FALSE ); |
|
1255 TTime tempTime( sevenDays ); |
|
1256 TTime newTime( ruleTime.Int64() + tempTime.Int64() ); |
|
1257 |
|
1258 TTimeIntervalDays temp; |
|
1259 temp = newTime.DaysFrom( ruleTime ); |
|
1260 |
|
1261 if( ( secondsDifference.Int() >= KNoDifference ) && |
|
1262 ( newTime > iAlarmInfo.iAlarmTime ) && |
|
1263 ( actualisedRule.iTimeOfChange < iAlarmInfo.iAlarmTime ) && |
|
1264 ( ruleTime < actualisedRule.iTimeOfChange ) ) |
|
1265 { |
|
1266 // If there is a match, save the index and break. |
|
1267 // We've got the rule and there's no need to continue with other rules. |
|
1268 ruleMatchIndex = ruleIndex; |
|
1269 ruleMatchTime = actualisedRule.iTimeOfChange; |
|
1270 break; |
|
1271 } |
|
1272 } |
|
1273 } |
|
1274 |
|
1275 if( ruleMatchIndex > KZerothRule ) |
|
1276 { |
|
1277 // There's a match, display the information note about DST change. |
|
1278 TTime displayTime; |
|
1279 TTimeIntervalHours oneHour( KOneHour ); |
|
1280 |
|
1281 displayTime = iAlarmInfo.iAlarmTime; |
|
1282 |
|
1283 TBuf< KMaxCharsInNote > dateTimeString; |
|
1284 |
|
1285 // dateString will have "11:59 pm" - as above, but no seconds |
|
1286 displayTime.FormatL( dateTimeString, KDateTimeFormatter ); |
|
1287 |
|
1288 // If This note is displayed, |
|
1289 CAknInformationNote* informationNote = new( ELeave ) CAknInformationNote( ETrue ); |
|
1290 |
|
1291 HBufC* noteText = StringLoader::LoadLC( |
|
1292 R_QTN_CLOCK_NOTE_ALARM_DST_ROLLOVER, |
|
1293 dateTimeString, |
|
1294 iCoeEnv); |
|
1295 TInt error = informationNote->ExecuteLD( noteText->Des() ); |
|
1296 |
|
1297 // Don't display the second note. Not necessary to show both notes. |
|
1298 returnValue = ETrue; |
|
1299 CleanupStack::PopAndDestroy( noteText ); |
|
1300 } |
|
1301 |
|
1302 tzHandle.Close(); |
|
1303 CleanupStack::PopAndDestroy( vActualisedRules); |
|
1304 CleanupStack::PopAndDestroy( currentRules ); |
|
1305 CleanupStack::PopAndDestroy( currentTZId ); |
|
1306 CleanupStack::PopAndDestroy( &tzHandle ); |
|
1307 |
|
1308 __PRINTS( "CClockAlarmEditorImpl::CheckForDstChangesL - Exit" ); |
|
1309 |
|
1310 return returnValue; |
|
1311 } |
|
1312 |
|
1313 // --------------------------------------------------------- |
|
1314 // CClockAlarmEditorImpl::DisplayRemainingTimeL |
|
1315 // rest of the details are commented in the header |
|
1316 // --------------------------------------------------------- |
|
1317 // |
|
1318 void CClockAlarmEditorImpl::DisplayRemainingTimeL() |
|
1319 { |
|
1320 __PRINTS( "CClockAlarmEditorImpl::DisplayRemainingTimeL - Entry" ); |
|
1321 |
|
1322 HBufC* stringHolder( NULL ); |
|
1323 |
|
1324 TTime currentTime; |
|
1325 currentTime.HomeTime(); |
|
1326 |
|
1327 TTime alarmTime = iAlarmInfo.iOrigExpiryTime; |
|
1328 TBool oneDayDifference( EFalse ); |
|
1329 |
|
1330 // Check for the day of the alarm. |
|
1331 if( currentTime < alarmTime ) |
|
1332 { |
|
1333 currentTime += TTimeIntervalDays( 1 ); |
|
1334 // Check if the alarm is for the current day. |
|
1335 oneDayDifference = ( currentTime < alarmTime )? ETrue : EFalse; |
|
1336 } |
|
1337 |
|
1338 TInt alarmDay( alarmTime.DayNoInWeek() ); |
|
1339 const TInt KTimeStringLength( 10 ); |
|
1340 TBuf< KTimeStringLength > timeString; |
|
1341 |
|
1342 HBufC* timeFormat = StringLoader::LoadLC( R_QTN_TIME_USUAL_WITH_ZERO, iCoeEnv ); |
|
1343 CleanupStack::Pop( timeFormat ); |
|
1344 |
|
1345 alarmTime.FormatL( timeString, *timeFormat ); |
|
1346 |
|
1347 CDesCArrayFlat* stringArray = new( ELeave ) CDesCArrayFlat( 2 ); |
|
1348 CDesCArrayFlat* workDaysList = iCoeEnv->ReadDesCArrayResourceL( R_CLOCK_WEEK_DAYS_ARRAY ); |
|
1349 |
|
1350 // The day on which alarm is set. |
|
1351 stringArray->AppendL( ( *workDaysList )[ alarmDay ] ); |
|
1352 // The time string. |
|
1353 stringArray->AppendL( timeString ); |
|
1354 |
|
1355 // Choose the appropriate Repeat type. |
|
1356 switch( iAlarmInfo.iRepeat ) |
|
1357 { |
|
1358 case EAlarmRepeatDefintionRepeatNext24Hours: |
|
1359 case EAlarmRepeatDefintionRepeatOnce: |
|
1360 { |
|
1361 if( oneDayDifference ) |
|
1362 { |
|
1363 stringHolder = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_NOTE_ONCE_NEXT, *stringArray, iEikonEnv ); |
|
1364 } |
|
1365 } |
|
1366 break; |
|
1367 |
|
1368 case EAlarmRepeatDefintionRepeatDaily: |
|
1369 { |
|
1370 stringHolder = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_NOTE_DAY_CLK, timeString, iEikonEnv ); |
|
1371 } |
|
1372 break; |
|
1373 |
|
1374 case EAlarmRepeatDefintionRepeatWeekly: |
|
1375 { |
|
1376 stringHolder = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_NOTE_WEEK_CLK, *stringArray, iEikonEnv ); |
|
1377 } |
|
1378 break; |
|
1379 |
|
1380 case EAlarmRepeatDefintionRepeatWorkday: |
|
1381 { |
|
1382 stringHolder = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_NOTE_WDAY_CLK, timeString, iEikonEnv ); |
|
1383 } |
|
1384 break; |
|
1385 |
|
1386 default: |
|
1387 { |
|
1388 // No implementation yet. |
|
1389 } |
|
1390 break; |
|
1391 } |
|
1392 |
|
1393 // Cleanup. |
|
1394 delete timeFormat; |
|
1395 delete stringArray; |
|
1396 delete workDaysList; |
|
1397 |
|
1398 // Need to show the confirmation note. |
|
1399 if( ( EAlarmStatusEnabled == iAlarmInfo.iStatus ) && stringHolder ) |
|
1400 { |
|
1401 // TODO: to be verified todo this or not. |
|
1402 CAknConfirmationNote* confirmationNote = new( ELeave ) CAknConfirmationNote( ETrue ); |
|
1403 |
|
1404 TPtr stringHolderPtr = stringHolder->Des(); |
|
1405 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( stringHolderPtr ); |
|
1406 |
|
1407 confirmationNote->ExecuteLD( *stringHolder ); |
|
1408 |
|
1409 // Cleanup |
|
1410 CleanupStack::PopAndDestroy( stringHolder ); |
|
1411 } |
|
1412 |
|
1413 // Dislpay the second note. |
|
1414 if( !oneDayDifference ) |
|
1415 { |
|
1416 TTime homeTime; |
|
1417 homeTime.HomeTime(); |
|
1418 |
|
1419 TDateTime currentDate( homeTime.DateTime() ); |
|
1420 TDateTime alarmDate( iAlarmInfo.iAlarmTime.DateTime() ); |
|
1421 |
|
1422 alarmDate.SetYear( currentDate.Year() ); |
|
1423 alarmDate.SetMonth( currentDate.Month() ); |
|
1424 alarmDate.SetDay( currentDate.Day() ); |
|
1425 |
|
1426 TTime newAlarmTime( alarmDate ); |
|
1427 |
|
1428 if( newAlarmTime < homeTime ) |
|
1429 { |
|
1430 newAlarmTime += TTimeIntervalDays( 1 ); |
|
1431 } |
|
1432 |
|
1433 // Construct the remaining time. |
|
1434 TTimeIntervalMicroSeconds remainingTime( newAlarmTime.MicroSecondsFrom( homeTime ) ); |
|
1435 TInt64 tempInt = ( remainingTime.Int64() ) / KOneMinuteInMicrosecond; |
|
1436 TInt remainingMinutes = I64INT( tempInt ); |
|
1437 |
|
1438 CArrayFix< TInt >* timeArray = new( ELeave ) CArrayFixFlat< TInt >( 2 ); |
|
1439 CleanupStack::PushL( timeArray ); |
|
1440 |
|
1441 TInt remainingHours( remainingMinutes / KOneHourInMinute ); |
|
1442 |
|
1443 remainingMinutes -= remainingHours * KOneHourInMinute; |
|
1444 |
|
1445 timeArray->AppendL( remainingHours ); |
|
1446 timeArray->AppendL( remainingMinutes ); |
|
1447 |
|
1448 // Alarm is with in 1 day. Choose the appropriate strings to be displayed. |
|
1449 switch( remainingHours ) |
|
1450 { |
|
1451 case KOneMinute: |
|
1452 { |
|
1453 if( KOneMinute == remainingMinutes ) |
|
1454 { |
|
1455 stringHolder = StringLoader::LoadLC( R_CLOCK_ALARM_CONF_SINGULAR, *timeArray, iEikonEnv ); |
|
1456 } |
|
1457 else |
|
1458 { |
|
1459 stringHolder = StringLoader::LoadLC( R_CLOCK_ALARM_CONF_HOUR_SEV_MIN, *timeArray, iEikonEnv ); |
|
1460 } |
|
1461 } |
|
1462 break; |
|
1463 |
|
1464 default: |
|
1465 { |
|
1466 if( KOneMinute == remainingMinutes ) |
|
1467 { |
|
1468 stringHolder = StringLoader::LoadLC( R_CLOCK_ALARM_CONF_SEV_HOURS_MIN, *timeArray, iEikonEnv ); |
|
1469 } |
|
1470 else |
|
1471 { |
|
1472 stringHolder = StringLoader::LoadLC( R_CLOCK_ALARM_CONF_PLURAL, *timeArray, iEikonEnv ); |
|
1473 } |
|
1474 } |
|
1475 break; |
|
1476 } |
|
1477 |
|
1478 // TODO: to be verified todo this or not. |
|
1479 if( ( EAlarmStatusEnabled == iAlarmInfo.iStatus ) && stringHolder ) |
|
1480 { |
|
1481 CAknConfirmationNote* confirmationNote = new( ELeave ) CAknConfirmationNote( ETrue ); |
|
1482 |
|
1483 TPtr stringHolderPtr = stringHolder->Des(); |
|
1484 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( stringHolderPtr ); |
|
1485 |
|
1486 confirmationNote->ExecuteLD( *stringHolder ); |
|
1487 } |
|
1488 |
|
1489 // Cleanup. |
|
1490 CleanupStack::PopAndDestroy( stringHolder ); |
|
1491 CleanupStack::PopAndDestroy( timeArray ); |
|
1492 } |
|
1493 |
|
1494 __PRINTS( "CClockAlarmEditorImpl::DisplayRemainingTimeL - Exit" ); |
|
1495 } |
|
1496 |
|
1497 // --------------------------------------------------------- |
|
1498 // CClockAlarmEditorImpl::HandleEdwinEventL |
|
1499 // rest of the details are commented in the header |
|
1500 // --------------------------------------------------------- |
|
1501 // |
|
1502 void CClockAlarmEditorImpl::HandleEdwinEventL( CEikEdwin* /*aEdwin*/, |
|
1503 TEdwinEvent /*aEventType*/ ) |
|
1504 { |
|
1505 __PRINTS( "CClockAlarmEditorImpl::HandleEdwinEventL - Entry" ); |
|
1506 |
|
1507 // No implementation yet. |
|
1508 |
|
1509 __PRINTS( "CClockAlarmEditorImpl::HandleEdwinEventL - Exit" ); |
|
1510 } |
|
1511 |
|
1512 // --------------------------------------------------------- |
|
1513 // CClockAlarmEditorImpl::OfferKeyEventL |
|
1514 // rest of the details are commented in the header |
|
1515 // --------------------------------------------------------- |
|
1516 // |
|
1517 TKeyResponse CClockAlarmEditorImpl::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
1518 { |
|
1519 __PRINTS( "CClockAlarmEditorImpl::OfferKeyEventL - Entry" ); |
|
1520 |
|
1521 if( EEventKey == aType ) |
|
1522 { |
|
1523 if( EStdKeyNo == aKeyEvent.iScanCode ) |
|
1524 { |
|
1525 // This indicates that Call End key was pressed. |
|
1526 // The application is hidden in the background. |
|
1527 TryExitL( EClockAlarmExit ); |
|
1528 |
|
1529 __PRINTS( "CClockAlarmEditorImpl::OfferKeyEventL - Exit" ); |
|
1530 |
|
1531 return EKeyWasConsumed; |
|
1532 } |
|
1533 } |
|
1534 |
|
1535 __PRINTS( "CClockAlarmEditorImpl::OfferKeyEventL - Exit" ); |
|
1536 |
|
1537 // Allow the form to update itself and then return. |
|
1538 return CAknForm::OfferKeyEventL( aKeyEvent, aType ); |
|
1539 } |
|
1540 |
|
1541 |
|
1542 // --------------------------------------------------------- |
|
1543 // CClockAlarmEditorImpl::LineChangedL |
|
1544 // rest of the details are commented in the header |
|
1545 // --------------------------------------------------------- |
|
1546 // |
|
1547 void CClockAlarmEditorImpl::LineChangedL( TInt aControlId ) |
|
1548 { |
|
1549 __PRINTS( "CClockAlarmEditorImpl::LineChangedL - Entry" ); |
|
1550 |
|
1551 // First get the control that is focused. |
|
1552 iSelectedControl = aControlId; |
|
1553 |
|
1554 // Modify the cba. |
|
1555 CEikButtonGroupContainer& bgContainer = ButtonGroupContainer(); |
|
1556 bgContainer.SetCommandSetL( R_CLOCK_ALARM_EDITOR_CBA ); |
|
1557 |
|
1558 // Now depending on the occurance, the Change command should be dimmed or displayed. |
|
1559 if( ( EControlTextEditor == iSelectedControl ) || |
|
1560 ( EControlTimeEditor == iSelectedControl ) ) |
|
1561 { |
|
1562 bgContainer.MakeCommandVisible( EAknSoftkeyChange, EFalse ); |
|
1563 } |
|
1564 else if( ( EControlAlarmDayPopup == iSelectedControl ) || |
|
1565 ( EControlOccurancePopup == iSelectedControl ) ) |
|
1566 { |
|
1567 bgContainer.MakeCommandVisible( EAknSoftkeyChange, ETrue ); |
|
1568 } |
|
1569 else |
|
1570 { |
|
1571 // Blank block, to avoid PC-Lint warning. |
|
1572 } |
|
1573 |
|
1574 // Redraw the cba. |
|
1575 bgContainer.DrawNow(); |
|
1576 |
|
1577 __PRINTS( "CClockAlarmEditorImpl::LineChangedL - Exit" ); |
|
1578 } |
|
1579 |
|
1580 //Single click integration |
|
1581 // --------------------------------------------------------- |
|
1582 // CClockAlarmEditorImpl::HandleControlStateChangeL |
|
1583 // Handles state change events from form controls |
|
1584 // --------------------------------------------------------- |
|
1585 // |
|
1586 void CClockAlarmEditorImpl::HandleControlStateChangeL( TInt aControlId ) |
|
1587 { |
|
1588 if ( aControlId == EControlOccurancePopup ) |
|
1589 { |
|
1590 HandleOccuranceCmdL(); |
|
1591 } |
|
1592 else if ( aControlId == EControlAlarmDayPopup ) |
|
1593 { |
|
1594 HandleAlarmDayCmdL(); |
|
1595 } |
|
1596 } |
|
1597 |
|
1598 |
|
1599 // End of file |