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