66
|
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 CClockMainView class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System includes
|
|
19 |
#include <clock.rsg>
|
|
20 |
#include <avkon.hrh>
|
|
21 |
#include <aknViewAppUi.h>
|
|
22 |
#include <aknnotewrappers.h>
|
|
23 |
#include <aknlists.h>
|
|
24 |
#include <StringLoader.h>
|
|
25 |
#include <tz.h>
|
|
26 |
#include <vtzrules.h>
|
|
27 |
#include <clockalarmeditor.h>
|
|
28 |
#include <hlplch.h>
|
|
29 |
#include <touchfeedback.h>
|
|
30 |
|
|
31 |
// User includes
|
|
32 |
#include "clockmainview.h"
|
|
33 |
#include "clockmaincontainer.h"
|
|
34 |
#include "clockalarmarray.h"
|
|
35 |
#include "clockappui.h"
|
|
36 |
#include "clockdocument.h"
|
|
37 |
#include "clock.h"
|
|
38 |
#include "clock.hrh"
|
|
39 |
#include "clkuialarmmodel.h"
|
|
40 |
#include "clkuialarmidleobserver.h"
|
|
41 |
#include "clkcommon.h"
|
|
42 |
#include "clock_debug.h"
|
|
43 |
|
|
44 |
// Constants
|
|
45 |
const TInt KMaxCharsInNote( 32 );
|
|
46 |
const TInt KZerothRule( 0 );
|
|
47 |
const TInt KDaysInWeek( 7 );
|
|
48 |
const TInt KOneMinuteInMicrosecond( 1000000 * 60 );
|
|
49 |
const TInt KOneHourInMinute( 60 );
|
|
50 |
const TInt KOneMinute( 1 );
|
|
51 |
const TInt KOneHour( 1 );
|
|
52 |
const TInt KNoDifference( 0 );
|
|
53 |
|
|
54 |
_LIT( KDateTimeFormatter, "%-B%:0%J%:1%T%:3%+B" ); // For the date and time displayed in the rollover note.
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
// Literals
|
|
59 |
|
|
60 |
// ---------------------------------------------------------
|
|
61 |
// CClockMainView::NewL
|
|
62 |
// rest of the details are commented in the header
|
|
63 |
// ---------------------------------------------------------
|
|
64 |
//
|
|
65 |
CClockMainView* CClockMainView::NewL( CClkUiAlarmModel* aAlarmModel )
|
|
66 |
{
|
|
67 |
__PRINTS( "CClockMainView::NewL - Entry" );
|
|
68 |
|
|
69 |
CClockMainView* self = new ( ELeave ) CClockMainView;
|
|
70 |
CleanupStack::PushL( self );
|
|
71 |
|
|
72 |
self->ConstructL( aAlarmModel );
|
|
73 |
|
|
74 |
CleanupStack::Pop( self );
|
|
75 |
|
|
76 |
__PRINTS( "CClockMainView::NewL - Exit" );
|
|
77 |
|
|
78 |
return self;
|
|
79 |
}
|
|
80 |
|
|
81 |
// ---------------------------------------------------------
|
|
82 |
// CClockMainView::ConstructL
|
|
83 |
// rest of the details are commented in the header
|
|
84 |
// ---------------------------------------------------------
|
|
85 |
//
|
|
86 |
void CClockMainView::ConstructL( CClkUiAlarmModel* aAlarmModel )
|
|
87 |
{
|
|
88 |
__PRINTS( "CClockMainView::ConstructL - Entry" );
|
|
89 |
|
|
90 |
BaseConstructL( R_CLOCK_MAIN_VIEW );
|
|
91 |
|
|
92 |
// Save the model.
|
|
93 |
iAlarmModel = aAlarmModel;
|
|
94 |
|
|
95 |
// Construct the alarm array.
|
|
96 |
iAlarmArray = CClockAlarmArray::NewL( iAlarmModel, iCoeEnv );
|
|
97 |
|
|
98 |
if( !iModelObserver )
|
|
99 |
{
|
|
100 |
iModelObserver = CClkUiAlarmIdleObserver::NewL( this, KAlarmIdleObserverPriority );
|
|
101 |
// Set the observer for the model.
|
|
102 |
iAlarmModel->SetModelObserver( iModelObserver );
|
|
103 |
}
|
|
104 |
|
|
105 |
__PRINTS( "CClockMainView::ConstructL - Exit" );
|
|
106 |
}
|
|
107 |
|
|
108 |
// ---------------------------------------------------------
|
|
109 |
// CClockMainView::CClockMainView
|
|
110 |
// rest of the details are commented in the header
|
|
111 |
// ---------------------------------------------------------
|
|
112 |
//
|
|
113 |
//Single click integration
|
|
114 |
CClockMainView::CClockMainView()
|
|
115 |
|
|
116 |
{
|
|
117 |
__PRINTS( "CClockMainView::CClockMainView - Entry" );
|
|
118 |
|
|
119 |
// No implementation yet.
|
|
120 |
|
|
121 |
__PRINTS( "CClockMainView::CClockMainView - Exit" );
|
|
122 |
}
|
|
123 |
|
|
124 |
// ---------------------------------------------------------
|
|
125 |
// CClockMainView::SetNewAlarmL
|
|
126 |
// rest of the details are commented in the header
|
|
127 |
// ---------------------------------------------------------
|
|
128 |
//
|
|
129 |
void CClockMainView::SetNewAlarmL()
|
|
130 |
{
|
|
131 |
__PRINTS( "CClockMainView::SetNewAlarmL - Entry" );
|
|
132 |
|
|
133 |
// Hide the navigation pane.
|
|
134 |
CClockAppUi* appUi = static_cast< CClockAppUi* > ( AppUi() );
|
|
135 |
appUi->MakeNavigationPaneVisible( EFalse, EClockAppMainViewId );
|
|
136 |
|
|
137 |
// Mark the alarm editor as open.
|
|
138 |
iAlarmEditorOpen = ETrue;
|
|
139 |
|
|
140 |
// Construct the alarm editor.
|
|
141 |
CClockAlarmEditor *alarmEditor = CClockAlarmEditor::NewL();
|
|
142 |
|
|
143 |
// Launch the editor. iAlarmId will give either alarm ID
|
|
144 |
// or EClockAlarmExit or EClockAlarmDelete.
|
|
145 |
iAlarmId = alarmEditor->LaunchL();
|
|
146 |
|
|
147 |
// Update the title pane text.
|
|
148 |
static_cast< CClockAppUi* > ( AppUi() )->SetTitlePaneTextL( R_CLOCK_TITLE_MAIN_VIEW );
|
|
149 |
|
|
150 |
// Show the navigation pane again.
|
|
151 |
appUi->MakeNavigationPaneVisible( ETrue, EClockAppMainViewId );
|
|
152 |
|
|
153 |
if( EClockAlarmExit == iAlarmId )
|
|
154 |
{
|
|
155 |
// Mark the alarm editor as closed.
|
|
156 |
iAlarmEditorOpen = EFalse;
|
|
157 |
|
|
158 |
// Cleanup.
|
|
159 |
if( alarmEditor )
|
|
160 |
{
|
|
161 |
delete alarmEditor;
|
|
162 |
alarmEditor = NULL;
|
|
163 |
}
|
|
164 |
|
|
165 |
|
|
166 |
// Let the appui handle the exit.
|
|
167 |
AppUi()->HandleCommandL( EClockAlarmExit );
|
|
168 |
|
|
169 |
__PRINTS( "CClockMainView::SetNewAlarmL:EClockAlarmExit - Exit" );
|
|
170 |
|
|
171 |
return;
|
|
172 |
}
|
|
173 |
|
|
174 |
if( EClockAlarmDelete == iAlarmId )
|
|
175 |
{
|
|
176 |
|
|
177 |
// Mark the alarm editor as closed.
|
|
178 |
iAlarmEditorOpen = EFalse;
|
|
179 |
|
|
180 |
// Cleanup.
|
|
181 |
if( alarmEditor )
|
|
182 |
{
|
|
183 |
delete alarmEditor;
|
|
184 |
alarmEditor = NULL;
|
|
185 |
}
|
|
186 |
|
|
187 |
// Do nothing. Just close the form without saving any data.
|
|
188 |
__PRINTS( "CClockMainView::SetNewAlarmL:EClockAlarmDelete - Exit" );
|
|
189 |
|
|
190 |
return;
|
|
191 |
}
|
|
192 |
|
|
193 |
// If the user pressed cancel and if the alarm id is valid.
|
|
194 |
if( KErrNone != iAlarmId )
|
|
195 |
{
|
|
196 |
// Update the latest alarm details.
|
|
197 |
iAlarmModel->ClockAlarmInfo( iAlarmId, iAlarmInfo );
|
|
198 |
|
|
199 |
if(CheckForDstChangesL())
|
|
200 |
{
|
|
201 |
DisplayRemainingTimeL();
|
|
202 |
}
|
|
203 |
|
|
204 |
// First update the model with the latest alarm id.
|
|
205 |
iAlarmModel->SaveLatestAlarmId( iAlarmId );
|
|
206 |
|
|
207 |
// Update the container with the newly added alarm.
|
|
208 |
iContainer->UpdateAlarmListL( iAlarmInfo, iAlarmId );
|
|
209 |
|
|
210 |
|
|
211 |
}
|
|
212 |
else
|
|
213 |
{
|
|
214 |
// No implementation yet.
|
|
215 |
}
|
|
216 |
|
|
217 |
// Mark the alarm editor as closed.
|
|
218 |
iAlarmEditorOpen = EFalse;
|
|
219 |
|
|
220 |
// Cleanup.
|
|
221 |
if( alarmEditor )
|
|
222 |
{
|
|
223 |
delete alarmEditor;
|
|
224 |
alarmEditor = NULL;
|
|
225 |
}
|
|
226 |
|
|
227 |
|
|
228 |
__PRINTS( "CClockMainView::SetNewAlarmL - Exit" );
|
|
229 |
}
|
|
230 |
|
|
231 |
// ---------------------------------------------------------
|
|
232 |
//papercut clock2 Remove_Snooze Start - rajender
|
|
233 |
// CClockMainView::RemoveSnoozeL
|
|
234 |
// rest of the details are commented in the header
|
|
235 |
// ---------------------------------------------------------
|
|
236 |
//
|
|
237 |
void CClockMainView::RemoveSnoozeL()
|
|
238 |
{
|
|
239 |
__PRINTS( "CClockMainView::RemoveSnoozeL - Entry" );
|
|
240 |
// First get the index of the selected item in the list.
|
|
241 |
TInt itemIndex( iContainer->ListBox()->CurrentItemIndex() );
|
|
242 |
|
|
243 |
if( KErrNone > itemIndex )
|
|
244 |
{
|
|
245 |
__PRINTS( "CClockMainView::RemoveSnoozeL - Exit" );
|
|
246 |
return;
|
|
247 |
}
|
|
248 |
|
|
249 |
SClkAlarmInfo alarmInfo;
|
|
250 |
TAlarmId alarmId;
|
|
251 |
// Get the alarm id from alarm model.
|
|
252 |
iAlarmArray->GetSortedAlmIdInfo( itemIndex, alarmId, alarmInfo );
|
|
253 |
|
|
254 |
// Delete the alarm.
|
|
255 |
User::LeaveIfError( iAlarmModel->AlarmRemoveSnooze( alarmId ) );
|
|
256 |
|
|
257 |
// Update the container.
|
|
258 |
iContainer->ListBox()->HandleItemAdditionL();
|
|
259 |
|
|
260 |
// Display the confirmation note to the user about alarm deletion.
|
|
261 |
//CAknConfirmationNote* confNote = new( ELeave ) CAknConfirmationNote;
|
|
262 |
//HBufC* confNoteText = StringLoader::LoadLC( R_QTN_CLOCK_SNOOZE_NOTE_REMOVED, iCoeEnv );
|
|
263 |
// Display the note.
|
|
264 |
//confNote->ExecuteLD( *confNoteText );
|
|
265 |
// Cleanup.
|
|
266 |
//CleanupStack::PopAndDestroy( confNoteText );
|
|
267 |
|
|
268 |
__PRINTS( "CClockMainView::RemoveSnoozeL - Exit" );
|
|
269 |
|
|
270 |
}
|
|
271 |
|
|
272 |
// ---------------------------------------------------------
|
|
273 |
// CClockMainView::RemoveAlarmL
|
|
274 |
// rest of the details are commented in the header
|
|
275 |
// ---------------------------------------------------------
|
|
276 |
//
|
|
277 |
void CClockMainView::RemoveAlarmL( TAlarmId aAlarmId )
|
|
278 |
{
|
|
279 |
__PRINTS( "CClockMainView::RemoveAlarmL - Entry" );
|
|
280 |
|
|
281 |
// First get the index of the selected item in the list.
|
|
282 |
TInt itemIndex( iAlarmArray->ListBoxIndex( aAlarmId ) );
|
|
283 |
|
|
284 |
if( KErrNone > itemIndex )
|
|
285 |
{
|
|
286 |
__PRINTS( "CClockMainView::RemoveAlarmL - Exit" );
|
|
287 |
|
|
288 |
return;
|
|
289 |
}
|
|
290 |
// Delete the alarm.
|
|
291 |
User::LeaveIfError( iAlarmModel->DeleteClockAlarm( aAlarmId ) );
|
|
292 |
// Update the container.
|
|
293 |
iContainer->RemoveAlarmL( itemIndex );
|
|
294 |
|
|
295 |
__PRINTS( "CClockMainView::RemoveAlarmL - Exit" );
|
|
296 |
}
|
|
297 |
|
|
298 |
// ---------------------------------------------------------
|
|
299 |
// CClockMainView::RemoveAlarmL
|
|
300 |
// rest of the details are commented in the header
|
|
301 |
// ---------------------------------------------------------
|
|
302 |
//
|
|
303 |
void CClockMainView::RemoveAlarmL()
|
|
304 |
{
|
|
305 |
__PRINTS( "CClockMainView::RemoveAlarmL - Entry" );
|
|
306 |
|
|
307 |
// First get the index of the selected item in the list.
|
|
308 |
TInt itemIndex( iContainer->ListBox()->CurrentItemIndex() );
|
|
309 |
|
|
310 |
if( KErrNone > itemIndex )
|
|
311 |
{
|
|
312 |
__PRINTS( "CClockMainView::RemoveAlarmL - Exit" );
|
|
313 |
|
|
314 |
return;
|
|
315 |
}
|
|
316 |
|
|
317 |
|
|
318 |
SClkAlarmInfo alarmInfo;
|
|
319 |
TAlarmId alarmId;
|
|
320 |
// Get the alarm id from alarm model.
|
|
321 |
iAlarmArray->GetSortedAlmIdInfo( itemIndex, alarmId, alarmInfo );
|
|
322 |
|
|
323 |
// Delete the alarm.
|
|
324 |
User::LeaveIfError( iAlarmModel->DeleteClockAlarm( alarmId ) );
|
|
325 |
// Update the container.
|
|
326 |
iContainer->RemoveAlarmL( itemIndex );
|
|
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
332 |
__PRINTS( "CClockMainView::RemoveAlarmL - Exit" );
|
|
333 |
}
|
|
334 |
|
|
335 |
// ---------------------------------------------------------
|
|
336 |
// CClockMainView::ActivateAlarmL
|
|
337 |
// rest of the details are commented in the header
|
|
338 |
// ---------------------------------------------------------
|
|
339 |
//
|
|
340 |
void CClockMainView::ActivateAlarmL()
|
|
341 |
{
|
|
342 |
__PRINTS( "CClockMainView::ActivateAlarmL - Entry" );
|
|
343 |
|
|
344 |
// First get the focused list item.
|
|
345 |
TInt itemIndex( iContainer->ListBox()->CurrentItemIndex() );
|
|
346 |
// Id of the alarm to be activated.
|
|
347 |
TAlarmId alarmId;
|
|
348 |
// Dummy alarm info.
|
|
349 |
SClkAlarmInfo alarmInfo;
|
|
350 |
|
|
351 |
// Get the id of the alarm at the index in the list.
|
|
352 |
iAlarmArray->GetSortedAlmIdInfo( itemIndex, alarmId, alarmInfo );
|
|
353 |
|
|
354 |
// Activate the alarm.
|
|
355 |
User::LeaveIfError( iAlarmModel->ClockAlarmEnable( alarmId, EAlarmStatusEnabled ) );
|
|
356 |
// Update the listbox.
|
|
357 |
iContainer->ListBox()->SetCurrentItemIndexAndDraw( iAlarmArray->ListBoxIndex( alarmId ) );
|
|
358 |
|
|
359 |
__PRINTS( "CClockMainView::ActivateAlarmL - Exit" );
|
|
360 |
}
|
|
361 |
|
|
362 |
// ---------------------------------------------------------
|
|
363 |
// CClockMainView::DeactivateAlarmL
|
|
364 |
// rest of the details are commented in the header
|
|
365 |
// ---------------------------------------------------------
|
|
366 |
//
|
|
367 |
void CClockMainView::DeactivateAlarmL()
|
|
368 |
{
|
|
369 |
__PRINTS( "CClockMainView::DeactivateAlarmL - Entry" );
|
|
370 |
|
|
371 |
// First get the focused list item.
|
|
372 |
TInt itemIndex( iContainer->ListBox()->CurrentItemIndex() );
|
|
373 |
// Id of the alarm to be deactivated.
|
|
374 |
TAlarmId alarmId;
|
|
375 |
// Dummy alarm info.
|
|
376 |
SClkAlarmInfo alarmInfo;
|
|
377 |
|
|
378 |
// Get the id of the alarm at the index in the list.
|
|
379 |
iAlarmArray->GetSortedAlmIdInfo( itemIndex, alarmId, alarmInfo );
|
|
380 |
|
|
381 |
// Deactivate the alarm.
|
|
382 |
User::LeaveIfError( iAlarmModel->ClockAlarmEnable( alarmId, EAlarmStatusDisabled ) );
|
|
383 |
// Update the listbox.
|
|
384 |
iContainer->ListBox()->SetCurrentItemIndexAndDraw( iAlarmArray->ListBoxIndex( alarmId ) );
|
|
385 |
|
|
386 |
__PRINTS( "CClockMainView::DeactivateAlarmL - Exit" );
|
|
387 |
}
|
|
388 |
|
|
389 |
// ---------------------------------------------------------
|
|
390 |
// CClockMainView::ResetAlarmL
|
|
391 |
// rest of the details are commented in the header
|
|
392 |
// ---------------------------------------------------------
|
|
393 |
//
|
|
394 |
void CClockMainView::ResetAlarmL()
|
|
395 |
{
|
|
396 |
__PRINTS( "CClockMainView::ResetAlarmL - Entry" );
|
|
397 |
|
|
398 |
// First get the focused list item.
|
|
399 |
TInt itemIndex( iContainer->ListBox()->CurrentItemIndex() );
|
|
400 |
// Id of the alarm to be deactivated.
|
|
401 |
TAlarmId alarmId;
|
|
402 |
// Dummy alarm info.
|
|
403 |
SClkAlarmInfo alarmInfo;
|
|
404 |
|
|
405 |
// Get the id of the alarm at the index in the list.
|
|
406 |
iAlarmArray->GetSortedAlmIdInfo( itemIndex, alarmId, alarmInfo );
|
|
407 |
|
|
408 |
// Hide the navigation pane.
|
|
409 |
CClockAppUi* appUi = static_cast< CClockAppUi* > ( AppUi() );
|
|
410 |
appUi->MakeNavigationPaneVisible( EFalse, EClockAppMainViewId );
|
|
411 |
|
|
412 |
// Mark the alarm editor as open.
|
|
413 |
iAlarmEditorOpen = ETrue;
|
|
414 |
|
|
415 |
// Construct the alarm editor.
|
|
416 |
CClockAlarmEditor* alarmEditor = CClockAlarmEditor::NewL( alarmId );
|
|
417 |
|
|
418 |
// Launch the editor.iAlarmId will give either alarm ID
|
|
419 |
// or EClockAlarmExit or EClockAlarmDelete.
|
|
420 |
iAlarmId = alarmEditor->LaunchL();
|
|
421 |
|
|
422 |
// Update the title pane text.
|
|
423 |
static_cast< CClockAppUi* > ( AppUi() )->SetTitlePaneTextL( R_CLOCK_TITLE_MAIN_VIEW );
|
|
424 |
|
|
425 |
// Show the navigation pane again.
|
|
426 |
appUi->MakeNavigationPaneVisible( ETrue, EClockAppMainViewId );
|
|
427 |
|
|
428 |
if( EClockAlarmDelete == iAlarmId )
|
|
429 |
{
|
|
430 |
// Mark the alarm editor as closed.
|
|
431 |
iAlarmEditorOpen = EFalse;
|
|
432 |
|
|
433 |
if( alarmEditor )
|
|
434 |
{
|
|
435 |
delete alarmEditor;
|
|
436 |
alarmEditor = NULL;
|
|
437 |
}
|
|
438 |
__PRINTS( "CClockMainView::ResetAlarmL:EClockAlarmDelete - Exit" );
|
|
439 |
|
|
440 |
// do the removing of the alarm
|
|
441 |
RemoveAlarmL( alarmId );
|
|
442 |
|
|
443 |
return;
|
|
444 |
}
|
|
445 |
|
|
446 |
if( EClockAlarmExit == iAlarmId )
|
|
447 |
{
|
|
448 |
// Mark the alarm editor as closed.
|
|
449 |
iAlarmEditorOpen = EFalse;
|
|
450 |
|
|
451 |
if( alarmEditor )
|
|
452 |
{
|
|
453 |
delete alarmEditor;
|
|
454 |
alarmEditor = NULL;
|
|
455 |
}
|
|
456 |
|
|
457 |
// Let the appui handle the exit.
|
|
458 |
AppUi()->HandleCommandL( EClockAlarmExit );
|
|
459 |
|
|
460 |
__PRINTS( "CClockMainView::ResetAlarmL:EClockAlarmExit - Exit" );
|
|
461 |
|
|
462 |
return;
|
|
463 |
}
|
|
464 |
|
|
465 |
if( EClockAlarmDiscardChanges == iAlarmId )
|
|
466 |
{
|
|
467 |
// Mark the alarm editor as closed.
|
|
468 |
iAlarmEditorOpen = EFalse;
|
|
469 |
|
|
470 |
// Cleanup.
|
|
471 |
if( alarmEditor )
|
|
472 |
{
|
|
473 |
delete alarmEditor;
|
|
474 |
alarmEditor = NULL;
|
|
475 |
}
|
|
476 |
|
|
477 |
// Dont do anything. Simply return.
|
|
478 |
|
|
479 |
__PRINTS( "CClockMainView::ResetAlarmL:EClockAlarmDiscardChanges - Exit" );
|
|
480 |
|
|
481 |
return;
|
|
482 |
}
|
|
483 |
|
|
484 |
// If the user pressed cancel and if the alarm id is valid.
|
|
485 |
if( KErrNone != iAlarmId )
|
|
486 |
{
|
|
487 |
// Delete the previous alarm.
|
|
488 |
User::LeaveIfError( iAlarmModel->DeleteClockAlarm( alarmId ) );
|
|
489 |
|
|
490 |
// Remove this alarm from the list.
|
|
491 |
iContainer->RemoveAlarmL( itemIndex );
|
|
492 |
|
|
493 |
// Update the latest alarm details.
|
|
494 |
iAlarmModel->ClockAlarmInfo( iAlarmId, iAlarmInfo );
|
|
495 |
|
|
496 |
if(CheckForDstChangesL())
|
|
497 |
{
|
|
498 |
DisplayRemainingTimeL();
|
|
499 |
}
|
|
500 |
|
|
501 |
// First update the model with the latest alarm id.
|
|
502 |
iAlarmModel->SaveLatestAlarmId( iAlarmId );
|
|
503 |
|
|
504 |
// Update the container with the new alarm.
|
|
505 |
iContainer->UpdateAlarmListL( iAlarmInfo, iAlarmId );
|
|
506 |
}
|
|
507 |
|
|
508 |
// Mark the alarm editor as closed.
|
|
509 |
iAlarmEditorOpen = EFalse;
|
|
510 |
|
|
511 |
if( alarmEditor )
|
|
512 |
{
|
|
513 |
delete alarmEditor;
|
|
514 |
alarmEditor = NULL;
|
|
515 |
}
|
|
516 |
|
|
517 |
|
|
518 |
__PRINTS( "CClockMainView::ResetAlarmL - Exit" );
|
|
519 |
}
|
|
520 |
|
|
521 |
// ---------------------------------------------------------
|
|
522 |
// CClockMainView::~CClockMainView
|
|
523 |
// rest of the details are commented in the header
|
|
524 |
// ---------------------------------------------------------
|
|
525 |
//
|
|
526 |
CClockMainView::~CClockMainView()
|
|
527 |
{
|
|
528 |
__PRINTS( "CClockMainView::~CClockMainView - Entry" );
|
|
529 |
|
|
530 |
if( iAlarmArray )
|
|
531 |
{
|
|
532 |
delete iAlarmArray;
|
|
533 |
iAlarmArray = NULL;
|
|
534 |
}
|
|
535 |
if( iContainer )
|
|
536 |
{
|
|
537 |
( AppUi() )->RemoveFromStack( iContainer );
|
|
538 |
delete iContainer;
|
|
539 |
iContainer = NULL;
|
|
540 |
}
|
|
541 |
if( iModelObserver )
|
|
542 |
{
|
|
543 |
if( iAlarmModel )
|
|
544 |
{
|
|
545 |
iAlarmModel->SetModelObserver( NULL );
|
|
546 |
}
|
|
547 |
delete iModelObserver;
|
|
548 |
iModelObserver = NULL;
|
|
549 |
}
|
|
550 |
|
|
551 |
__PRINTS( "CClockMainView::~CClockMainView - Exit" );
|
|
552 |
}
|
|
553 |
|
|
554 |
// ---------------------------------------------------------
|
|
555 |
// CClockMainView::Id
|
|
556 |
// rest of the details are commented in the header
|
|
557 |
// ---------------------------------------------------------
|
|
558 |
//
|
|
559 |
TUid CClockMainView::Id() const
|
|
560 |
{
|
|
561 |
__PRINTS( "CClockMainView::Id - Entry" );
|
|
562 |
|
|
563 |
__PRINTS( "CClockMainView::Id - Exit" );
|
|
564 |
|
|
565 |
return KClockAppMainViewId;
|
|
566 |
}
|
|
567 |
|
|
568 |
// ---------------------------------------------------------
|
|
569 |
// CClockMainView::DoActivateL
|
|
570 |
// rest of the details are commented in the header
|
|
571 |
// ---------------------------------------------------------
|
|
572 |
//
|
|
573 |
void CClockMainView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
|
|
574 |
TUid aCustomMessageId,
|
|
575 |
const TDesC8& /*aCustomMessage*/ )
|
|
576 |
{
|
|
577 |
__PRINTS( "CClockMainView::DoActivateL - Entry" );
|
|
578 |
|
|
579 |
if( KClockHideInBackground == aCustomMessageId.iUid )
|
|
580 |
{
|
|
581 |
CClockAppUi* appUi = static_cast< CClockAppUi* > ( AppUi() );
|
|
582 |
|
|
583 |
// Enable bring-to-foreground on view activation.
|
|
584 |
appUi->SetCustomControl( 0 );
|
|
585 |
}
|
|
586 |
|
|
587 |
// Re-initialize the alarm id array.
|
|
588 |
iAlarmArray->InitIdList();
|
|
589 |
|
|
590 |
// To update the scroll bar when opened from indicator pane.
|
|
591 |
if( iContainer )
|
|
592 |
{
|
|
593 |
iContainer->ListBox()->SetCurrentItemIndexAndDraw( KZerothIndex );
|
|
594 |
}
|
|
595 |
|
|
596 |
CClockAppUi* clockAppUi( static_cast< CClockAppUi* > ( AppUi() ) );
|
|
597 |
if( !iContainer )
|
|
598 |
{
|
|
599 |
iContainer = CClockMainContainer::NewL( this, ClientRect(), iAlarmArray );
|
|
600 |
( AppUi() )->AddToStackL( *this, iContainer );
|
|
601 |
iContainer->SetMopParent( this );
|
|
602 |
|
|
603 |
if( clockAppUi->IsAppExitHidden() )
|
|
604 |
{
|
|
605 |
iContainer->ListBox()->SetCurrentItemIndexAndDraw( KZerothIndex );
|
|
606 |
clockAppUi->SetAppHidden( EFalse );
|
|
607 |
|
|
608 |
}
|
|
609 |
else
|
|
610 |
{
|
|
611 |
|
|
612 |
// Focus on the "New Alarm" whenever the main view is activated
|
|
613 |
|
|
614 |
|
|
615 |
iContainer->ListBox()->SetCurrentItemIndexAndDraw( KErrNone);
|
|
616 |
}
|
|
617 |
}
|
|
618 |
|
|
619 |
// Update the date and day text.
|
|
620 |
iContainer->SetDayInfoL();
|
|
621 |
|
|
622 |
// Update the location information text.
|
|
623 |
iContainer->SetZoneInfoL();
|
|
624 |
|
|
625 |
// Update the DST information in the container.
|
|
626 |
iContainer->UpdateDSTStateL();
|
|
627 |
|
|
628 |
// Update the title pane text.
|
|
629 |
clockAppUi->SetTitlePaneTextL( R_CLOCK_TITLE_MAIN_VIEW );
|
|
630 |
|
|
631 |
// If opened from clock, display the navigation pane again.
|
|
632 |
clockAppUi->MakeNavigationPaneVisible( ETrue, EClockAppMainViewId );
|
|
633 |
|
|
634 |
// Activate the container.
|
|
635 |
if( clockAppUi->TransitionOngoing() )
|
|
636 |
{
|
|
637 |
//clockAppUi->DoAppearTransition( iContainer );
|
|
638 |
iContainer->ActivateL();
|
|
639 |
}
|
|
640 |
else
|
|
641 |
{
|
|
642 |
iContainer->ActivateL();
|
|
643 |
}
|
|
644 |
|
|
645 |
__PRINTS( "CClockMainView::DoActivateL - Exit" );
|
|
646 |
}
|
|
647 |
|
|
648 |
// ---------------------------------------------------------
|
|
649 |
// CClockMainView::DoDeactivate
|
|
650 |
// rest of the details are commented in the header
|
|
651 |
// ---------------------------------------------------------
|
|
652 |
//
|
|
653 |
void CClockMainView::DoDeactivate()
|
|
654 |
{
|
|
655 |
__PRINTS( "CClockMainView::DoDeactivate - Entry" );
|
|
656 |
|
|
657 |
// Ask the document to save the user data in the document file.
|
|
658 |
CClockDocument* clockDocument = static_cast< CClockDocument* > ( AppUi()->Document() );
|
|
659 |
|
|
660 |
|
|
661 |
if( iContainer )
|
|
662 |
{
|
|
663 |
CClockAppUi* clockAppUi( static_cast< CClockAppUi* > ( AppUi() ) );
|
|
664 |
if( clockAppUi->TransitionOngoing() )
|
|
665 |
{
|
|
666 |
//clockAppUi->DoDisappearTransition( iContainer );
|
|
667 |
}
|
|
668 |
// First remove the container from the control stack
|
|
669 |
( AppUi() )->RemoveFromStack( iContainer );
|
|
670 |
// And then destroy it.
|
|
671 |
delete iContainer;
|
|
672 |
iContainer = NULL;
|
|
673 |
}
|
|
674 |
|
|
675 |
__PRINTS( "CClockMainView::DoDeactivate - Exit" );
|
|
676 |
}
|
|
677 |
|
|
678 |
// ---------------------------------------------------------
|
|
679 |
// CClockMainView::HandleCommandL
|
|
680 |
// rest of the details are commented in the header
|
|
681 |
// ---------------------------------------------------------
|
|
682 |
//
|
|
683 |
void CClockMainView::HandleCommandL( TInt aCommand )
|
|
684 |
{
|
|
685 |
__PRINTS( "CClockMainView::HandleCommandL - Entry" );
|
|
686 |
|
|
687 |
switch( aCommand )
|
|
688 |
{
|
|
689 |
//Single click integration
|
|
690 |
case EClockSelect:
|
|
691 |
{
|
|
692 |
ResetAlarmL();
|
|
693 |
}
|
|
694 |
break;
|
|
695 |
|
|
696 |
case EClockNewAlarm:
|
|
697 |
{
|
|
698 |
// Display the alarm editor for the user to set the alarm.
|
|
699 |
SetNewAlarmL();
|
|
700 |
}
|
|
701 |
break;
|
|
702 |
|
|
703 |
case EClockResetAlarm:
|
|
704 |
{
|
|
705 |
// Reset the chosen alarm.
|
|
706 |
ResetAlarmL();
|
|
707 |
}
|
|
708 |
break;
|
|
709 |
|
|
710 |
case EClockDeactivateAlarm:
|
|
711 |
{
|
|
712 |
// Deactivate the focused alarm item in the list.
|
|
713 |
DeactivateAlarmL();
|
|
714 |
}
|
|
715 |
break;
|
|
716 |
|
|
717 |
case EClockActivateAlarm:
|
|
718 |
{
|
|
719 |
// Activate the focused alarm item in the list.
|
|
720 |
ActivateAlarmL();
|
|
721 |
}
|
|
722 |
break;
|
|
723 |
|
|
724 |
case EClockRemoveAlarm:
|
|
725 |
{
|
|
726 |
// Delete the selected alarm.
|
|
727 |
RemoveAlarmL();
|
|
728 |
}
|
|
729 |
break;
|
|
730 |
case EClockRemoveSnooze:
|
|
731 |
{
|
|
732 |
// Remove snooze on the selected alarm
|
|
733 |
RemoveSnoozeL();
|
|
734 |
}
|
|
735 |
break;
|
|
736 |
case EClockSwitchClockType:
|
|
737 |
{
|
|
738 |
// Switches clock type
|
|
739 |
SwitchClockTypeL();
|
|
740 |
}
|
|
741 |
break;
|
|
742 |
case EClockSettings:
|
|
743 |
{
|
|
744 |
// Let the appui handle the command.
|
|
745 |
AppUi()->HandleCommandL( EClockSettings );
|
|
746 |
}
|
|
747 |
break;
|
|
748 |
|
|
749 |
case EClockMainViewExit:
|
|
750 |
case EAknSoftkeyExit:
|
|
751 |
{
|
|
752 |
AppUi()->HandleCommandL( aCommand );
|
|
753 |
}
|
|
754 |
break;
|
|
755 |
|
|
756 |
case EAknCmdHelp: //EClockWorldHelp:
|
|
757 |
{
|
|
758 |
// Launch clock main view specific help.
|
|
759 |
HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), iAvkonAppUi->AppHelpContextL() );
|
|
760 |
}
|
|
761 |
break;
|
|
762 |
|
|
763 |
default:
|
|
764 |
{
|
|
765 |
// No implementation yet.
|
|
766 |
}
|
|
767 |
break;
|
|
768 |
}
|
|
769 |
|
|
770 |
__PRINTS( "CClockMainView::HandleCommandL - Exit" );
|
|
771 |
}
|
|
772 |
|
|
773 |
// ---------------------------------------------------------
|
|
774 |
// CClockMainView::HandleUpdateL
|
|
775 |
// rest of the details are commented in the header
|
|
776 |
// ---------------------------------------------------------
|
|
777 |
//
|
|
778 |
void CClockMainView::HandleUpdateL( TInt /*aReason*/ )
|
|
779 |
{
|
|
780 |
__PRINTS( "CClockMainView::HandleUpdateL - Entry" );
|
|
781 |
|
|
782 |
// Get the currently focussed item.
|
|
783 |
TInt currentlyFocussedItem( KErrNotFound );
|
|
784 |
if( iContainer )
|
|
785 |
{
|
|
786 |
currentlyFocussedItem = iContainer->ListBox()->CurrentItemIndex();
|
|
787 |
}
|
|
788 |
// Update the alarm array.
|
|
789 |
iAlarmArray->InitIdList();
|
|
790 |
|
|
791 |
// We redraw the container when an update is received from the uimodel (be it alarm or clockserver).
|
|
792 |
if( iContainer )
|
|
793 |
{
|
|
794 |
iContainer->DrawNow();
|
|
795 |
iContainer->ListBox()->HandleItemAdditionL();
|
|
796 |
|
|
797 |
// In case the currently focussed item is invalid,set the focus to last item and set the msk text accordingly.
|
|
798 |
if( KErrNotFound == currentlyFocussedItem )
|
|
799 |
{
|
|
800 |
TInt itemCount = iContainer->ListBox()->Model()->ItemTextArray()->MdcaCount();
|
|
801 |
if( itemCount > 0 )
|
|
802 |
{
|
|
803 |
iContainer->ListBox()->SetCurrentItemIndexAndDraw( itemCount -1 );
|
|
804 |
}
|
|
805 |
else
|
|
806 |
{
|
|
807 |
iContainer->ListBox()->SetCurrentItemIndexAndDraw( KZeroAlarms );
|
|
808 |
}
|
|
809 |
|
|
810 |
|
|
811 |
}
|
|
812 |
}
|
|
813 |
|
|
814 |
__PRINTS( "CClockMainView::HandleUpdateL - Exit" );
|
|
815 |
}
|
|
816 |
|
|
817 |
// ---------------------------------------------------------
|
|
818 |
// CClockMainView::DynInitMenuPaneL
|
|
819 |
// rest of the details are commented in the header
|
|
820 |
// ---------------------------------------------------------
|
|
821 |
//
|
|
822 |
void CClockMainView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
|
|
823 |
{
|
|
824 |
__PRINTS( "CClockMainView::DynInitMenuPaneL - Entry" );
|
|
825 |
|
|
826 |
//Single click integration
|
|
827 |
if( ( R_CLOCK_MAIN_VIEW_MENUPANE != aResourceId ) )
|
|
828 |
|
|
829 |
|
|
830 |
{
|
|
831 |
__PRINTS( "CClockMainView::DynInitMenuPaneL - Exit" );
|
|
832 |
|
|
833 |
return;
|
|
834 |
}
|
|
835 |
|
|
836 |
// TODO: Initialize FeatureManager and remove Help option if its not supported.
|
|
837 |
/*if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
|
|
838 |
{
|
|
839 |
aMenuPane->DeleteMenuItem( EAlarmHelpAlarmClock );
|
|
840 |
}*/
|
|
841 |
|
|
842 |
|
|
843 |
TInt alarmCount = iAlarmArray->MdcaCount();
|
|
844 |
TBool deleteRemoveSnooze( EFalse );
|
|
845 |
|
|
846 |
// There are no alarms set
|
|
847 |
if( KZeroAlarms >= alarmCount || iContainer->IsNewAlaramButtonFocused() )
|
|
848 |
{
|
|
849 |
// There are no alarms set. Remove the irrelevant options from the menu.
|
|
850 |
aMenuPane->DeleteMenuItem( EClockResetAlarm );
|
|
851 |
aMenuPane->DeleteMenuItem( EClockRemoveAlarm );
|
|
852 |
aMenuPane->DeleteMenuItem( EClockActivateAlarm );
|
|
853 |
aMenuPane->DeleteMenuItem( EClockDeactivateAlarm );
|
|
854 |
deleteRemoveSnooze = ETrue;
|
|
855 |
}
|
|
856 |
else
|
|
857 |
{
|
|
858 |
// There is atleast one alarm set. Get the details to update the menu.
|
|
859 |
SClkAlarmInfo alarmInfo;
|
|
860 |
TAlarmId alarmId;
|
|
861 |
|
|
862 |
|
|
863 |
iAlarmArray->GetSortedAlmIdInfo( iContainer->ListBox()->CurrentItemIndex(), alarmId, alarmInfo );
|
|
864 |
|
|
865 |
if( alarmInfo.iStatus == EAlarmStatusEnabled )
|
|
866 |
{
|
|
867 |
// Alarm is already active. Remove the activate option.
|
|
868 |
aMenuPane->DeleteMenuItem( EClockActivateAlarm );
|
|
869 |
|
|
870 |
|
|
871 |
|
|
872 |
if( ( EAlarmRepeatDefintionRepeatOnce == alarmInfo.iRepeat ) ||
|
|
873 |
( EAlarmRepeatDefintionRepeatNext24Hours == alarmInfo.iRepeat) )
|
|
874 |
{
|
|
875 |
// Alarm is not recurring. Remove the deactivate option from the menu.
|
|
876 |
aMenuPane->DeleteMenuItem( EClockDeactivateAlarm );
|
|
877 |
// no snooze removing needed for not recurring
|
|
878 |
deleteRemoveSnooze = ETrue;
|
|
879 |
}
|
|
880 |
// if the alarm is not snoozed, Remove the 'Remove snooze' option
|
|
881 |
if (alarmInfo.iState != EAlarmStateSnoozed )
|
|
882 |
{
|
|
883 |
deleteRemoveSnooze = ETrue;
|
|
884 |
}
|
|
885 |
}
|
|
886 |
else
|
|
887 |
{
|
|
888 |
// Alarm is already inactive. Remove the deactivate option from the menu.
|
|
889 |
aMenuPane->DeleteMenuItem( EClockDeactivateAlarm );
|
|
890 |
deleteRemoveSnooze = ETrue;
|
|
891 |
}
|
|
892 |
}
|
|
893 |
if( deleteRemoveSnooze )
|
|
894 |
{
|
|
895 |
aMenuPane->DeleteMenuItem( EClockRemoveSnooze );
|
|
896 |
}
|
|
897 |
|
|
898 |
__PRINTS( "CClockMainView::DynInitMenuPaneL - Exit" );
|
|
899 |
}
|
|
900 |
|
|
901 |
// ---------------------------------------------------------
|
|
902 |
// CClockMainView::DynInitMenuBarL
|
|
903 |
// rest of the details are commented in the header
|
|
904 |
// ---------------------------------------------------------
|
|
905 |
//
|
|
906 |
//Single click integration
|
|
907 |
void CClockMainView::DynInitMenuBarL( TInt /*aResourceId*/, CEikMenuBar* /*aMenuBar*/ )
|
|
908 |
|
|
909 |
{
|
|
910 |
__PRINTS( "CClockMainView::DynInitMenuBarL - Entry" );
|
|
911 |
|
|
912 |
|
|
913 |
|
|
914 |
__PRINTS( "CClockMainView::DynInitMenuBarL - Exit" );
|
|
915 |
}
|
|
916 |
|
|
917 |
// ---------------------------------------------------------
|
|
918 |
// CClockMainView::HandleForegroundEventL
|
|
919 |
// rest of the details are commented in the header
|
|
920 |
// ---------------------------------------------------------
|
|
921 |
//
|
|
922 |
void CClockMainView::HandleForegroundEventL( TBool aForeground )
|
|
923 |
{
|
|
924 |
__PRINTS( "CClockMainView::HandleForegroundEventL - Entry" );
|
|
925 |
|
|
926 |
if( aForeground )
|
|
927 |
{
|
|
928 |
CClockAppUi* clockAppUi( static_cast< CClockAppUi* > ( AppUi() ) );
|
|
929 |
if( clockAppUi->IsAppExitHidden() )
|
|
930 |
{
|
|
931 |
if( iContainer )
|
|
932 |
{
|
|
933 |
iContainer->ResetMarqueeLabelL();
|
|
934 |
iContainer->ListBox()->SetCurrentItemIndexAndDraw( KZerothIndex );
|
|
935 |
}
|
|
936 |
clockAppUi->SetAppHidden( EFalse );
|
|
937 |
|
|
938 |
}
|
|
939 |
}
|
|
940 |
|
|
941 |
__PRINTS( "CClockMainView::HandleForegroundEventL - Exit" );
|
|
942 |
}
|
|
943 |
// ---------------------------------------------------------
|
|
944 |
// CClockMainView::GetApplicationRect
|
|
945 |
// rest of the details are commented in the header
|
|
946 |
// ---------------------------------------------------------
|
|
947 |
//
|
|
948 |
TRect CClockMainView::GetApplicationRect()
|
|
949 |
{
|
|
950 |
__PRINTS( "CClockMainView::GetApplicationRect - Entry" );
|
|
951 |
|
|
952 |
__PRINTS( "CClockMainView::GetApplicationRect - Exit" );
|
|
953 |
|
|
954 |
// Return the applicationrect from appui.
|
|
955 |
return AppUi()->ApplicationRect();
|
|
956 |
}
|
|
957 |
|
|
958 |
|
|
959 |
|
|
960 |
// ---------------------------------------------------------
|
|
961 |
// CClockMainView::HandleEnvChangeL
|
|
962 |
// rest of the details are commented in the header
|
|
963 |
// ---------------------------------------------------------
|
|
964 |
//
|
|
965 |
void CClockMainView::HandleEnvChangeL( TClockEnvChanged /*aEnvChanged*/ )
|
|
966 |
{
|
|
967 |
__PRINTS( "CClockMainView::HandleEnvChangeL - Entry" );
|
|
968 |
|
|
969 |
if( iContainer )
|
|
970 |
{
|
|
971 |
// Update the main view information.
|
|
972 |
iContainer->SetDayInfoL();
|
|
973 |
|
|
974 |
// Update the location information text.
|
|
975 |
iContainer->SetZoneInfoL();
|
|
976 |
|
|
977 |
// Update the DST information.
|
|
978 |
iContainer->UpdateDSTStateL();
|
|
979 |
|
|
980 |
// Update the container.
|
|
981 |
iContainer->DrawNow();
|
|
982 |
}
|
|
983 |
|
|
984 |
__PRINTS( "CClockMainView::HandleEnvChangeL - Exit" );
|
|
985 |
}
|
|
986 |
|
|
987 |
// ---------------------------------------------------------
|
|
988 |
// CClockMainView::IsAlarmEditorOpen
|
|
989 |
// rest of the details are commented in the header
|
|
990 |
// ---------------------------------------------------------
|
|
991 |
//
|
|
992 |
TBool CClockMainView::IsAlarmEditorOpen()
|
|
993 |
{
|
|
994 |
__PRINTS( "CClockMainView::IsAlarmEditorOpen - Entry" );
|
|
995 |
|
|
996 |
__PRINTS( "CClockMainView::IsAlarmEditorOpen - Exit" );
|
|
997 |
|
|
998 |
return iAlarmEditorOpen;
|
|
999 |
}
|
|
1000 |
|
|
1001 |
// ---------------------------------------------------------
|
|
1002 |
// CClockMainView::ClockApplicationUi
|
|
1003 |
// rest of the details are commented in the header
|
|
1004 |
// ---------------------------------------------------------
|
|
1005 |
//
|
|
1006 |
CClockAppUi* CClockMainView::ClockApplicationUi()
|
|
1007 |
{
|
|
1008 |
__PRINTS( "CClockMainView::ClockApplicationUi - Entry" );
|
|
1009 |
|
|
1010 |
__PRINTS( "CClockMainView::ClockApplicationUi - Exit" );
|
|
1011 |
|
|
1012 |
return static_cast< CClockAppUi* > ( AppUi() );
|
|
1013 |
}
|
|
1014 |
|
|
1015 |
// ---------------------------------------------------------
|
|
1016 |
// CClockAlarmEditorImpl::DisplayRemainingTimeL
|
|
1017 |
// rest of the details are commented in the header
|
|
1018 |
// ---------------------------------------------------------
|
|
1019 |
//
|
|
1020 |
void CClockMainView::DisplayRemainingTimeL()
|
|
1021 |
{
|
|
1022 |
__PRINTS( "CClockAlarmEditorImpl::DisplayRemainingTimeL - Entry" );
|
|
1023 |
|
|
1024 |
HBufC* stringHolder( NULL );
|
|
1025 |
|
|
1026 |
TTime currentTime;
|
|
1027 |
currentTime.HomeTime();
|
|
1028 |
|
|
1029 |
TTime alarmTime = iAlarmInfo.iOrigExpiryTime;
|
|
1030 |
TBool oneDayDifference( EFalse );
|
|
1031 |
|
|
1032 |
// Check for the day of the alarm.
|
|
1033 |
if( currentTime < alarmTime )
|
|
1034 |
{
|
|
1035 |
currentTime += TTimeIntervalDays( 1 );
|
|
1036 |
// Check if the alarm is for the current day.
|
|
1037 |
oneDayDifference = ( currentTime < alarmTime )? ETrue : EFalse;
|
|
1038 |
}
|
|
1039 |
|
|
1040 |
TInt alarmDay( alarmTime.DayNoInWeek() );
|
|
1041 |
const TInt KTimeStringLength( 10 );
|
|
1042 |
TBuf< KTimeStringLength > timeString;
|
|
1043 |
|
|
1044 |
HBufC* timeFormat = StringLoader::LoadLC( R_QTN_TIME_USUAL_WITH_ZERO, iCoeEnv );
|
|
1045 |
CleanupStack::Pop( timeFormat );
|
|
1046 |
|
|
1047 |
alarmTime.FormatL( timeString, *timeFormat );
|
|
1048 |
|
|
1049 |
CDesCArrayFlat* stringArray = new( ELeave ) CDesCArrayFlat( 2 );
|
|
1050 |
CDesCArrayFlat* workDaysList = iCoeEnv->ReadDesCArrayResourceL( R_CLOCK_WEEK_DAYS_ARRAY );
|
|
1051 |
|
|
1052 |
// The day on which alarm is set.
|
|
1053 |
stringArray->AppendL( ( *workDaysList )[ alarmDay ] );
|
|
1054 |
// The time string.
|
|
1055 |
stringArray->AppendL( timeString );
|
|
1056 |
|
|
1057 |
// Choose the appropriate Repeat type.
|
|
1058 |
switch( iAlarmInfo.iRepeat )
|
|
1059 |
{
|
|
1060 |
case EAlarmRepeatDefintionRepeatNext24Hours:
|
|
1061 |
case EAlarmRepeatDefintionRepeatOnce:
|
|
1062 |
{
|
|
1063 |
if( oneDayDifference )
|
|
1064 |
{
|
|
1065 |
stringHolder = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_NOTE_ONCE_NEXT, *stringArray, iEikonEnv );
|
|
1066 |
}
|
|
1067 |
}
|
|
1068 |
break;
|
|
1069 |
|
|
1070 |
case EAlarmRepeatDefintionRepeatDaily:
|
|
1071 |
{
|
|
1072 |
stringHolder = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_NOTE_DAY_CLK, timeString, iEikonEnv );
|
|
1073 |
}
|
|
1074 |
break;
|
|
1075 |
|
|
1076 |
case EAlarmRepeatDefintionRepeatWeekly:
|
|
1077 |
{
|
|
1078 |
stringHolder = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_NOTE_WEEK_CLK, *stringArray, iEikonEnv );
|
|
1079 |
}
|
|
1080 |
break;
|
|
1081 |
|
|
1082 |
case EAlarmRepeatDefintionRepeatWorkday:
|
|
1083 |
{
|
|
1084 |
stringHolder = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_NOTE_WDAY_CLK, timeString, iEikonEnv );
|
|
1085 |
}
|
|
1086 |
break;
|
|
1087 |
|
|
1088 |
default:
|
|
1089 |
{
|
|
1090 |
// No implementation yet.
|
|
1091 |
}
|
|
1092 |
break;
|
|
1093 |
}
|
|
1094 |
|
|
1095 |
// Cleanup.
|
|
1096 |
delete timeFormat;
|
|
1097 |
delete stringArray;
|
|
1098 |
delete workDaysList;
|
|
1099 |
|
|
1100 |
// Need to show the confirmation note.
|
|
1101 |
if( ( EAlarmStatusEnabled == iAlarmInfo.iStatus ) && stringHolder )
|
|
1102 |
{
|
|
1103 |
// TODO: to be verified todo this or not.
|
|
1104 |
CAknConfirmationNote* confirmationNote = new( ELeave ) CAknConfirmationNote( ETrue );
|
|
1105 |
|
|
1106 |
TPtr stringHolderPtr = stringHolder->Des();
|
|
1107 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( stringHolderPtr );
|
|
1108 |
|
|
1109 |
confirmationNote->ExecuteLD( *stringHolder );
|
|
1110 |
|
|
1111 |
// Cleanup
|
|
1112 |
CleanupStack::PopAndDestroy( stringHolder );
|
|
1113 |
}
|
|
1114 |
|
|
1115 |
// Dislpay the second note.
|
|
1116 |
if( !oneDayDifference )
|
|
1117 |
{
|
|
1118 |
TTime homeTime;
|
|
1119 |
homeTime.HomeTime();
|
|
1120 |
|
|
1121 |
TDateTime currentDate( homeTime.DateTime() );
|
|
1122 |
TDateTime alarmDate( iAlarmInfo.iAlarmTime.DateTime() );
|
|
1123 |
|
|
1124 |
alarmDate.SetYear( currentDate.Year() );
|
|
1125 |
alarmDate.SetMonth( currentDate.Month() );
|
|
1126 |
alarmDate.SetDay( currentDate.Day() );
|
|
1127 |
|
|
1128 |
TTime newAlarmTime( alarmDate );
|
|
1129 |
|
|
1130 |
if( newAlarmTime < homeTime )
|
|
1131 |
{
|
|
1132 |
newAlarmTime += TTimeIntervalDays( 1 );
|
|
1133 |
}
|
|
1134 |
|
|
1135 |
// Construct the remaining time.
|
|
1136 |
TTimeIntervalMicroSeconds remainingTime( newAlarmTime.MicroSecondsFrom( homeTime ) );
|
|
1137 |
TInt64 tempInt = ( remainingTime.Int64() ) / KOneMinuteInMicrosecond;
|
|
1138 |
TInt remainingMinutes = I64INT( tempInt );
|
|
1139 |
|
|
1140 |
CArrayFix< TInt >* timeArray = new( ELeave ) CArrayFixFlat< TInt >( 2 );
|
|
1141 |
CleanupStack::PushL( timeArray );
|
|
1142 |
|
|
1143 |
TInt remainingHours( remainingMinutes / KOneHourInMinute );
|
|
1144 |
|
|
1145 |
remainingMinutes -= remainingHours * KOneHourInMinute;
|
|
1146 |
|
|
1147 |
timeArray->AppendL( remainingHours );
|
|
1148 |
timeArray->AppendL( remainingMinutes );
|
|
1149 |
|
|
1150 |
// Alarm is with in 1 day. Choose the appropriate strings to be displayed.
|
|
1151 |
switch( remainingHours )
|
|
1152 |
{
|
|
1153 |
case KOneMinute:
|
|
1154 |
{
|
|
1155 |
if( KOneMinute == remainingMinutes )
|
|
1156 |
{
|
|
1157 |
stringHolder = StringLoader::LoadLC( R_CLOCK_ALARM_CONF_SINGULAR, *timeArray, iEikonEnv );
|
|
1158 |
}
|
|
1159 |
else
|
|
1160 |
{
|
|
1161 |
stringHolder = StringLoader::LoadLC( R_CLOCK_ALARM_CONF_HOUR_SEV_MIN, *timeArray, iEikonEnv );
|
|
1162 |
}
|
|
1163 |
}
|
|
1164 |
break;
|
|
1165 |
|
|
1166 |
default:
|
|
1167 |
{
|
|
1168 |
if( KOneMinute == remainingMinutes )
|
|
1169 |
{
|
|
1170 |
stringHolder = StringLoader::LoadLC( R_CLOCK_ALARM_CONF_SEV_HOURS_MIN, *timeArray, iEikonEnv );
|
|
1171 |
}
|
|
1172 |
else
|
|
1173 |
{
|
|
1174 |
stringHolder = StringLoader::LoadLC( R_CLOCK_ALARM_CONF_PLURAL, *timeArray, iEikonEnv );
|
|
1175 |
}
|
|
1176 |
}
|
|
1177 |
break;
|
|
1178 |
}
|
|
1179 |
|
|
1180 |
// TODO: to be verified todo this or not.
|
|
1181 |
if( ( EAlarmStatusEnabled == iAlarmInfo.iStatus ) && stringHolder )
|
|
1182 |
{
|
|
1183 |
CAknConfirmationNote* confirmationNote = new( ELeave ) CAknConfirmationNote( ETrue );
|
|
1184 |
|
|
1185 |
TPtr stringHolderPtr = stringHolder->Des();
|
|
1186 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( stringHolderPtr );
|
|
1187 |
|
|
1188 |
confirmationNote->ExecuteLD( *stringHolder );
|
|
1189 |
}
|
|
1190 |
|
|
1191 |
// Cleanup.
|
|
1192 |
CleanupStack::PopAndDestroy( stringHolder );
|
|
1193 |
CleanupStack::PopAndDestroy( timeArray );
|
|
1194 |
}
|
|
1195 |
|
|
1196 |
__PRINTS( "CClockAlarmEditorImpl::DisplayRemainingTimeL - Exit" );
|
|
1197 |
}
|
|
1198 |
|
|
1199 |
// ---------------------------------------------------------
|
|
1200 |
// CClockAlarmEditorImpl::CheckForDstChangesL
|
|
1201 |
// rest of the details are commented in the header
|
|
1202 |
// ---------------------------------------------------------
|
|
1203 |
//
|
|
1204 |
TBool CClockMainView::CheckForDstChangesL()
|
|
1205 |
{
|
|
1206 |
__PRINTS( "CClockAlarmEditorImpl::CheckForDstChangesL - Entry" );
|
|
1207 |
|
|
1208 |
// User to be notified whether DST rollover happens in a day or
|
|
1209 |
// has happen within a day if he tries to change the time.
|
|
1210 |
TBool returnValue( ETrue );
|
|
1211 |
|
|
1212 |
// Establish connection with RTz to get the timezone ID
|
|
1213 |
RTz tzHandle;
|
|
1214 |
User::LeaveIfError( tzHandle.Connect() );
|
|
1215 |
CleanupClosePushL( tzHandle );
|
|
1216 |
|
|
1217 |
// The timezone ID (current)
|
|
1218 |
CTzId* currentTZId = tzHandle.GetTimeZoneIdL();
|
|
1219 |
CleanupStack::PushL( currentTZId );
|
|
1220 |
|
|
1221 |
// The current time in UTC
|
|
1222 |
TTime currentTime;
|
|
1223 |
currentTime.UniversalTime();
|
|
1224 |
|
|
1225 |
// hometime (local time)
|
|
1226 |
TTime homeTime;
|
|
1227 |
homeTime.HomeTime();
|
|
1228 |
|
|
1229 |
//(Year, Month, Day, Hour, Minute, Second, Micrsecond)
|
|
1230 |
TDateTime dateTime( homeTime.DateTime().Year(), EJanuary, 1, FALSE, FALSE, FALSE, FALSE );
|
|
1231 |
|
|
1232 |
TTime tempTime( dateTime );
|
|
1233 |
|
|
1234 |
// Get the current rules for the timezone
|
|
1235 |
CTzRules* currentRules = tzHandle.GetTimeZoneRulesL( *currentTZId, tempTime, currentTime, ETzUtcTimeReference );
|
|
1236 |
CleanupStack::PushL( currentRules );
|
|
1237 |
|
|
1238 |
// CVTzActualisedRules encapsulates the rules for a specific year.
|
|
1239 |
// Every year has a dummy rule and further DST rules if DST is applicable (if Ohlson provides them)
|
|
1240 |
CVTzActualisedRules *vActualisedRules = CVTzActualisedRules::NewL(
|
|
1241 |
homeTime.DateTime().Year(),
|
|
1242 |
homeTime.DateTime().Year());
|
|
1243 |
CleanupStack::PushL( vActualisedRules );
|
|
1244 |
|
|
1245 |
// The dummy rule is always the begining of the year.
|
|
1246 |
// For example there is only 1 rule for India/NewDelhi but USA/Atlanta has 3 rules.
|
|
1247 |
currentRules->GetActualisedRulesL( *vActualisedRules );
|
|
1248 |
|
|
1249 |
const TInt ruleCount( vActualisedRules->Count() );
|
|
1250 |
TInt ruleMatchIndex( KNoDifference );
|
|
1251 |
|
|
1252 |
TTimeIntervalSeconds secondsDifference;
|
|
1253 |
TTime ruleMatchTime;
|
|
1254 |
|
|
1255 |
// Fetch lowest time offset for the year residing at aTime.
|
|
1256 |
// This is used to determine if DST is on.
|
|
1257 |
for( TInt ruleIndex( FALSE ); ruleIndex < ruleCount; ++ruleIndex )
|
|
1258 |
{
|
|
1259 |
const TVTzActualisedRule& actualisedRule = ( *vActualisedRules )[ ruleIndex ];
|
|
1260 |
|
|
1261 |
// Only check for the same year as requested (aTime)
|
|
1262 |
if( actualisedRule.iTimeOfChange.DateTime().Year() == homeTime.DateTime().Year() )
|
|
1263 |
{
|
|
1264 |
iAlarmInfo.iAlarmTime.SecondsFrom( actualisedRule.iTimeOfChange, secondsDifference );
|
|
1265 |
// Considering the time reference is important as America (North & South) uses
|
|
1266 |
// the Wall time (local time) reference where as whole of Europe refers to time
|
|
1267 |
// in terms of UTC time. Correspondingly, the choise of local time or utc time
|
|
1268 |
// has to be made.
|
|
1269 |
TTime ruleTime;
|
|
1270 |
|
|
1271 |
if( ETzUtcTimeReference == actualisedRule.iTimeReference )
|
|
1272 |
{
|
|
1273 |
ruleTime = currentTime;
|
|
1274 |
}
|
|
1275 |
else if( ETzWallTimeReference == actualisedRule.iTimeReference )
|
|
1276 |
{
|
|
1277 |
ruleTime = homeTime;
|
|
1278 |
}
|
|
1279 |
else if( ETzStdTimeReference == actualisedRule.iTimeReference )
|
|
1280 |
{
|
|
1281 |
// TODO: Testing so far hasn't encountered a rule in this time reference.
|
|
1282 |
// If in case an error is found, corresponding code can be added here.
|
|
1283 |
// No support from symbian for this.
|
|
1284 |
}
|
|
1285 |
|
|
1286 |
TDateTime sevenDays( FALSE, EJanuary, KDaysInWeek, FALSE, FALSE, FALSE, FALSE );
|
|
1287 |
TTime tempTime( sevenDays );
|
|
1288 |
TTime newTime( ruleTime.Int64() + tempTime.Int64() );
|
|
1289 |
|
|
1290 |
TTimeIntervalDays temp;
|
|
1291 |
temp = newTime.DaysFrom( ruleTime );
|
|
1292 |
|
|
1293 |
if( ( secondsDifference.Int() >= KNoDifference ) &&
|
|
1294 |
( newTime > iAlarmInfo.iAlarmTime ) &&
|
|
1295 |
( actualisedRule.iTimeOfChange < iAlarmInfo.iAlarmTime ) &&
|
|
1296 |
( ruleTime < actualisedRule.iTimeOfChange ) )
|
|
1297 |
{
|
|
1298 |
// If there is a match, save the index and break.
|
|
1299 |
// We've got the rule and there's no need to continue with other rules.
|
|
1300 |
ruleMatchIndex = ruleIndex;
|
|
1301 |
ruleMatchTime = actualisedRule.iTimeOfChange;
|
|
1302 |
break;
|
|
1303 |
}
|
|
1304 |
}
|
|
1305 |
}
|
|
1306 |
|
|
1307 |
if( ruleMatchIndex > KZerothRule )
|
|
1308 |
{
|
|
1309 |
// There's a match, display the information note about DST change.
|
|
1310 |
TTime displayTime;
|
|
1311 |
TTimeIntervalHours oneHour( KOneHour );
|
|
1312 |
|
|
1313 |
displayTime = iAlarmInfo.iAlarmTime;
|
|
1314 |
|
|
1315 |
TBuf< KMaxCharsInNote > dateTimeString;
|
|
1316 |
|
|
1317 |
// dateString will have "11:59 pm" - as above, but no seconds
|
|
1318 |
displayTime.FormatL( dateTimeString, KDateTimeFormatter );
|
|
1319 |
|
|
1320 |
// If This note is displayed,
|
|
1321 |
CAknInformationNote* informationNote = new( ELeave ) CAknInformationNote( ETrue );
|
|
1322 |
|
|
1323 |
HBufC* noteText = StringLoader::LoadLC(
|
|
1324 |
R_QTN_CLOCK_NOTE_ALARM_DST_ROLLOVER,
|
|
1325 |
dateTimeString,
|
|
1326 |
iCoeEnv);
|
|
1327 |
TInt error = informationNote->ExecuteLD( noteText->Des() );
|
|
1328 |
|
|
1329 |
// Don't display the second note. Not necessary to show both notes.
|
|
1330 |
returnValue = ETrue;
|
|
1331 |
CleanupStack::PopAndDestroy( noteText );
|
|
1332 |
}
|
|
1333 |
|
|
1334 |
tzHandle.Close();
|
|
1335 |
CleanupStack::PopAndDestroy( vActualisedRules);
|
|
1336 |
CleanupStack::PopAndDestroy( currentRules );
|
|
1337 |
CleanupStack::PopAndDestroy( currentTZId );
|
|
1338 |
CleanupStack::PopAndDestroy( &tzHandle );
|
|
1339 |
|
|
1340 |
__PRINTS( "CClockAlarmEditorImpl::CheckForDstChangesL - Exit" );
|
|
1341 |
|
|
1342 |
return returnValue;
|
|
1343 |
}
|
|
1344 |
|
|
1345 |
void CClockMainView::GiveVibes()
|
|
1346 |
{
|
|
1347 |
CClockAppUi* clockAppUi( static_cast< CClockAppUi* > ( AppUi() ) );
|
|
1348 |
if ( clockAppUi->GetFeedback() &&
|
|
1349 |
clockAppUi->GetFeedback()->TouchFeedbackSupported() )
|
|
1350 |
{
|
|
1351 |
clockAppUi->GetFeedback()->InstantFeedback( ETouchFeedbackBasic );
|
|
1352 |
}
|
|
1353 |
}
|
|
1354 |
|
|
1355 |
void CClockMainView::SwitchClockTypeL()
|
|
1356 |
{
|
|
1357 |
TLocale phoneLocale;
|
|
1358 |
// Set the new clock format with the locale.
|
|
1359 |
phoneLocale.SetClockFormat( ( EClockAnalog == phoneLocale.ClockFormat() )
|
|
1360 |
? EClockDigital : EClockAnalog );
|
|
1361 |
phoneLocale.Set();
|
|
1362 |
if( iContainer )
|
|
1363 |
{
|
|
1364 |
iContainer->SwitchClockTypeL();
|
|
1365 |
}
|
|
1366 |
}
|
|
1367 |
|
|
1368 |
// End of file
|