|
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 CClockAlarmArray class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <coemain.h> |
|
20 #include <AknUtils.h> |
|
21 #include <clock.rsg> |
|
22 #include <centralrepository.h> |
|
23 #include <AknFepInternalCRKeys.h> |
|
24 #include <StringLoader.h> |
|
25 |
|
26 // User includes |
|
27 #include "clockalarmarray.h" |
|
28 #include "clkuialarmmodel.h" |
|
29 #include "clock_debug.h" |
|
30 |
|
31 // Constants |
|
32 const TInt KTimeStringLength( 25 ); |
|
33 const TInt KFirstAlarmIndex( 1 ); |
|
34 const TInt KNewAlarmIndex( 0 ); |
|
35 |
|
36 // Literals |
|
37 _LIT( KFieldSeparator, "\t" ); |
|
38 _LIT( KReplaceWhitespaceChars, "\x0009\x000A\x000B\x000C\x000D\x2028\x2029" ); |
|
39 |
|
40 // --------------------------------------------------------- |
|
41 // CClockAlarmArray::NewL |
|
42 // rest of the details are commented in the header |
|
43 // --------------------------------------------------------- |
|
44 // |
|
45 CClockAlarmArray* CClockAlarmArray::NewL( CClkUiAlarmModel* aAlarmModel, CCoeEnv* aCoeEnv ) |
|
46 { |
|
47 __PRINTS( "CClockAlarmArray::NewL - Entry" ); |
|
48 |
|
49 CClockAlarmArray* self = new( ELeave ) CClockAlarmArray; |
|
50 CleanupStack::PushL( self ); |
|
51 |
|
52 self->ConstructL( aAlarmModel, aCoeEnv ); |
|
53 |
|
54 CleanupStack::Pop( self ); |
|
55 |
|
56 __PRINTS( "CClockAlarmArray::NewL - Exit" ); |
|
57 |
|
58 return self; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------- |
|
62 // CClockAlarmArray::~CClockAlarmArray |
|
63 // rest of the details are commented in the header |
|
64 // --------------------------------------------------------- |
|
65 // |
|
66 CClockAlarmArray::~CClockAlarmArray() |
|
67 { |
|
68 __PRINTS( "CClockAlarmArray::~CClockAlarmArray - Entry" ); |
|
69 |
|
70 if( iOccuranceList ) |
|
71 { |
|
72 delete iOccuranceList; |
|
73 iOccuranceList = NULL; |
|
74 } |
|
75 if( iWorkDaysList ) |
|
76 { |
|
77 delete iWorkDaysList; |
|
78 iWorkDaysList = NULL; |
|
79 } |
|
80 if( iShortWorkDaysList ) |
|
81 { |
|
82 delete iShortWorkDaysList; |
|
83 iShortWorkDaysList = NULL; |
|
84 } |
|
85 if( iListBoxEntry ) |
|
86 { |
|
87 delete iListBoxEntry; |
|
88 iListBoxEntry = NULL; |
|
89 } |
|
90 if( iAlarmInactiveText ) |
|
91 { |
|
92 delete iAlarmInactiveText; |
|
93 iAlarmInactiveText = NULL; |
|
94 } |
|
95 if( iTimeFormat ) |
|
96 { |
|
97 delete iTimeFormat; |
|
98 iTimeFormat = NULL; |
|
99 } |
|
100 if( iDate ) |
|
101 { |
|
102 delete iDate; |
|
103 iDate = NULL; |
|
104 } |
|
105 if( iNewAlarmText ) |
|
106 { |
|
107 delete iNewAlarmText; |
|
108 iNewAlarmText = NULL; |
|
109 } |
|
110 |
|
111 iAlarmIdArray.Close(); |
|
112 |
|
113 __PRINTS( "CClockAlarmArray::~CClockAlarmArray - Exit" ); |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CClockAlarmArray::MdcaCount |
|
118 // rest of the details are commented in the header |
|
119 // --------------------------------------------------------- |
|
120 // |
|
121 TInt CClockAlarmArray::MdcaCount() const |
|
122 { |
|
123 __PRINTS( "CClockAlarmArray::MdcaCount - Entry" ); |
|
124 |
|
125 TInt itemCount( KFirstAlarmIndex ); |
|
126 // Iterate through the list and add only the active alarms. |
|
127 for( TInt index( KFirstAlarmIndex ); index < iAlarmIdArray.Count() && iAlarmIdArray[ index ] != 0; index++ ) |
|
128 { |
|
129 SClkAlarmInfo alarmInformation; |
|
130 TInt errorValue( iAlarmModel->ClockAlarmInfo( iAlarmIdArray[ index ], alarmInformation ) ); |
|
131 |
|
132 // We return only active alarms. |
|
133 if( ( KErrNone == errorValue ) && |
|
134 ( EAlarmStateInPreparation != alarmInformation.iState && |
|
135 EAlarmStateNotified != alarmInformation.iState ) ) |
|
136 { |
|
137 itemCount++; |
|
138 } |
|
139 } |
|
140 |
|
141 __PRINTS( "CClockAlarmArray::MdcaCount - Exit" ); |
|
142 |
|
143 return itemCount; |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------- |
|
147 // CClockAlarmArray::MdcaPoint |
|
148 // rest of the details are commented in the header |
|
149 // --------------------------------------------------------- |
|
150 // |
|
151 TPtrC16 CClockAlarmArray::MdcaPoint( TInt aIndex ) const |
|
152 { |
|
153 __PRINTS( "CClockAlarmArray::MdcaPoint - Entry" ); |
|
154 |
|
155 // Set "New Alarm" as the first index of the listitem. |
|
156 if( KNewAlarmIndex == aIndex ) |
|
157 { |
|
158 iListBoxEntry->Des().Zero(); |
|
159 |
|
160 TPtr listEntryPtr = iListBoxEntry->Des(); |
|
161 |
|
162 listEntryPtr.Append( KFieldSeparator ); |
|
163 |
|
164 //Single click integration |
|
165 listEntryPtr.Append( iNewAlarmText->Des() ); |
|
166 |
|
167 listEntryPtr.Append( KFieldSeparator ); |
|
168 |
|
169 |
|
170 listEntryPtr.Append( KFieldSeparator ); |
|
171 |
|
172 listEntryPtr.AppendNum( EBlankIconIndex ); |
|
173 |
|
174 listEntryPtr.Append( KFieldSeparator ); |
|
175 |
|
176 listEntryPtr.AppendNum( EBlankIconIndex ); |
|
177 |
|
178 __PRINTS( "CClockAlarmArray::MdcaPoint - Exit" ); |
|
179 |
|
180 return listEntryPtr; |
|
181 } |
|
182 |
|
183 SClkAlarmInfo alarmInfo; |
|
184 TBuf< KTimeStringLength > timeString; |
|
185 TAlarmId alarmId; |
|
186 |
|
187 // First get the sorted alarm information for the given index. |
|
188 GetSortedAlmIdInfo( aIndex, alarmId, alarmInfo ); |
|
189 // Re-initialize the item to construct a new listbox entry. |
|
190 iListBoxEntry->Des().Zero(); |
|
191 |
|
192 TPtr listEntryPtr = iListBoxEntry->Des(); |
|
193 |
|
194 // First format and construct the time part. |
|
195 TTime alarmTime = alarmInfo.iOrigExpiryTime; |
|
196 TDateTime alarmDateTime = alarmInfo.iAlarmTime.DateTime(); |
|
197 TInt alarmDay = alarmTime.DayNoInWeek(); |
|
198 |
|
199 // The timestring formatter. |
|
200 HBufC* formatString( NULL ); |
|
201 TRAP_IGNORE( |
|
202 formatString = StringLoader::LoadL( R_QTN_TIME_USUAL_WITH_ZERO, iEnv ); |
|
203 alarmTime.FormatL( timeString, *formatString ); ); |
|
204 |
|
205 AknTextUtils::LanguageSpecificNumberConversion( timeString ); |
|
206 |
|
207 // Go to the first item. |
|
208 listEntryPtr.Append( KFieldSeparator ); |
|
209 // First append the alarm expiry time. |
|
210 listEntryPtr.Append( timeString ); |
|
211 // Then append a space. |
|
212 listEntryPtr.Append( KSingleSpace ); |
|
213 |
|
214 // Here we append date or text depending on the type of the alarm. |
|
215 switch( alarmInfo.iRepeat ) |
|
216 { |
|
217 case EAlarmRepeatDefintionRepeatOnce: |
|
218 case EAlarmRepeatDefintionRepeatNext24Hours: |
|
219 { |
|
220 // For once only alarm, the date will have to be appended to the list item. |
|
221 TDateString dateString; |
|
222 alarmTime.FormatL( dateString, *iDate ); |
|
223 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( dateString ); |
|
224 |
|
225 CRepository* cenRep( NULL ); |
|
226 cenRep = CRepository::NewLC( KCRUidAknFep ); |
|
227 TInt displayLanguage; |
|
228 // Get the current display language from CenRep. |
|
229 cenRep->Get( KAknFepLastUsedUILanguage, displayLanguage ); |
|
230 |
|
231 // If Japanese |
|
232 if( displayLanguage == ELangJapanese ) |
|
233 { |
|
234 // First the date and |
|
235 listEntryPtr.Append( dateString ); |
|
236 listEntryPtr.Append( KSingleSpace ); |
|
237 // then the day. |
|
238 listEntryPtr.Append( ( *iShortWorkDaysList )[ alarmDay ] ); |
|
239 } |
|
240 else |
|
241 { |
|
242 // First the day and |
|
243 listEntryPtr.Append( ( *iShortWorkDaysList )[ alarmDay ] ); |
|
244 listEntryPtr.Append( KSingleSpace ); |
|
245 // then the date. |
|
246 listEntryPtr.Append( dateString ); |
|
247 } |
|
248 // Cleanup. |
|
249 CleanupStack::PopAndDestroy( cenRep ); |
|
250 } |
|
251 break; |
|
252 |
|
253 case EAlarmRepeatDefintionRepeatWeekly: |
|
254 { |
|
255 listEntryPtr.Append( ( *iWorkDaysList )[ alarmDay ] ); |
|
256 } |
|
257 break; |
|
258 |
|
259 case EAlarmRepeatDefintionRepeatDaily: |
|
260 { |
|
261 listEntryPtr.Append( ( *iOccuranceList )[ 2 ] ); |
|
262 } |
|
263 break; |
|
264 |
|
265 case EAlarmRepeatDefintionRepeatWorkday: |
|
266 { |
|
267 listEntryPtr.Append( ( *iOccuranceList )[ 3 ]); |
|
268 } |
|
269 break; |
|
270 |
|
271 default: |
|
272 { |
|
273 // Error if control comes here. addding space to avoid crash. |
|
274 listEntryPtr.Append( KSingleSpace ); |
|
275 } |
|
276 break; |
|
277 } |
|
278 // Go to the next item. |
|
279 listEntryPtr.Append( KFieldSeparator ); |
|
280 |
|
281 // Append the description. |
|
282 if( EAlarmStatusDisabled == alarmInfo.iStatus ) |
|
283 { |
|
284 listEntryPtr.Append( iAlarmInactiveText->Des() ); |
|
285 } |
|
286 else if( EAlarmStateSnoozed == alarmInfo.iState ) |
|
287 { |
|
288 // Reset the strings. |
|
289 timeString.Zero(); |
|
290 |
|
291 alarmInfo.iAlarmTime.FormatL( timeString, *iTimeFormat ); |
|
292 |
|
293 HBufC* alarmSnoozedText( NULL ); |
|
294 alarmSnoozedText = StringLoader::LoadL( R_QTN_CLK_ALARMS_VIEW_SNOOZED_ALARM, timeString, iEnv ); |
|
295 TPtr alarmSnoozedTextPtr = alarmSnoozedText->Des(); |
|
296 |
|
297 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( alarmSnoozedTextPtr ); |
|
298 |
|
299 listEntryPtr.Append( alarmSnoozedText->Des() ); |
|
300 |
|
301 // Cleanup. |
|
302 delete alarmSnoozedText; |
|
303 alarmSnoozedText = NULL; |
|
304 } |
|
305 else if( KErrNone < alarmInfo.iMessage.Length() ) |
|
306 { |
|
307 // Remove any extra white spaces or line feed and replace it with a blank character. |
|
308 TAlarmMessage alarmDescription( alarmInfo.iMessage ); |
|
309 |
|
310 AknTextUtils::ReplaceCharacters( alarmDescription, KReplaceWhitespaceChars, TChar(' ') ); |
|
311 alarmDescription.TrimAll(); |
|
312 |
|
313 listEntryPtr.Append( alarmDescription ); |
|
314 } |
|
315 else |
|
316 { |
|
317 listEntryPtr.Append( KSingleSpace ); |
|
318 } |
|
319 |
|
320 // Go to the next item. |
|
321 listEntryPtr.Append( KFieldSeparator ); |
|
322 |
|
323 // Append the icon. |
|
324 if( EAlarmRepeatDefintionRepeatWeekly == alarmInfo.iRepeat || |
|
325 EAlarmRepeatDefintionRepeatDaily == alarmInfo.iRepeat || |
|
326 EAlarmRepeatDefintionRepeatWorkday == alarmInfo.iRepeat ) |
|
327 { |
|
328 // For repeat icon. |
|
329 listEntryPtr.AppendNum( EAlarmRepeatIconIndex ); |
|
330 } |
|
331 else |
|
332 { |
|
333 listEntryPtr.AppendNum( EBlankIconIndex ); |
|
334 } |
|
335 |
|
336 // Go to the next item. |
|
337 listEntryPtr.Append( KFieldSeparator ); |
|
338 |
|
339 if( EAlarmStatusEnabled == alarmInfo.iStatus ) |
|
340 { |
|
341 // Show alarm icon. |
|
342 listEntryPtr.AppendNum( EAlarmActiveIconIndex ); |
|
343 } |
|
344 else |
|
345 { |
|
346 // Show nothing. |
|
347 listEntryPtr.AppendNum( EAlarmInActiveIconIndex ); |
|
348 } |
|
349 |
|
350 // Cleanup. |
|
351 delete formatString; |
|
352 |
|
353 __PRINTS( "CClockAlarmArray::MdcaPoint - Exit" ); |
|
354 |
|
355 // Return the constructed descriptor. |
|
356 return listEntryPtr; |
|
357 } |
|
358 |
|
359 // --------------------------------------------------------- |
|
360 // CClockAlarmArray::ListBoxIndex |
|
361 // rest of the details are commented in the header |
|
362 // --------------------------------------------------------- |
|
363 // |
|
364 TInt CClockAlarmArray::ListBoxIndex( TAlarmId aAlarmId ) |
|
365 { |
|
366 __PRINTS( "CClockAlarmArray::ListBoxIndex - Entry" ); |
|
367 |
|
368 // First get the alarm info. |
|
369 SClkAlarmInfo alarmInfo; |
|
370 TInt errorValue( iAlarmModel->ClockAlarmInfo( aAlarmId, alarmInfo ) ); |
|
371 |
|
372 if( ( KErrNone == errorValue ) && |
|
373 ( EAlarmStateInPreparation != alarmInfo.iState && |
|
374 EAlarmStateNotified != alarmInfo.iState && |
|
375 EAlarmStatusEnabled == alarmInfo.iStatus ) ) |
|
376 { |
|
377 // Returns enabled alarm's index. |
|
378 return GetEnabledAlarmIndex( aAlarmId, errorValue ); |
|
379 } |
|
380 else |
|
381 { |
|
382 // Returns disabled alarm's index. |
|
383 return GetDisabledAlarmIndex( aAlarmId, errorValue ); |
|
384 } |
|
385 } |
|
386 |
|
387 |
|
388 // --------------------------------------------------------- |
|
389 // CClockAlarmArray::GetEnabledAlarmIndex |
|
390 // rest of the details are commented in the header |
|
391 // --------------------------------------------------------- |
|
392 // |
|
393 TInt CClockAlarmArray::GetEnabledAlarmIndex( TAlarmId aAlarmId, TInt aErrorValue ) |
|
394 { |
|
395 TInt listItemIndex( KFirstAlarmIndex ); |
|
396 TInt enabledAlarmIndex( KErrNotFound ); |
|
397 TInt alarmCount( iAlarmIdArray.Count() ); |
|
398 |
|
399 // The order of alarms in the listbox is not always the same in the alarmarray |
|
400 // because disabled alarms are displayed in the end of the list and the next alarm |
|
401 // to expire is on top of the list. |
|
402 for( TInt index( KFirstAlarmIndex ); index < alarmCount; index++ ) |
|
403 { |
|
404 SClkAlarmInfo alarmInfo; |
|
405 TInt errorVal( iAlarmModel->ClockAlarmInfo( iAlarmIdArray[ index ], alarmInfo) ); |
|
406 |
|
407 if( ( KErrNone == aErrorValue ) && |
|
408 ( EAlarmStateInPreparation != alarmInfo.iState && |
|
409 EAlarmStateNotified != alarmInfo.iState && |
|
410 EAlarmStatusEnabled == alarmInfo.iStatus ) ) |
|
411 { |
|
412 if( aAlarmId == iAlarmIdArray[ index ] ) |
|
413 { |
|
414 enabledAlarmIndex = listItemIndex; |
|
415 } |
|
416 else |
|
417 { |
|
418 listItemIndex++; |
|
419 } |
|
420 } |
|
421 } |
|
422 |
|
423 return enabledAlarmIndex; |
|
424 } |
|
425 |
|
426 // --------------------------------------------------------- |
|
427 // CClockAlarmArray::GetDisabledAlarmIndex |
|
428 // rest of the details are commented in the header |
|
429 // --------------------------------------------------------- |
|
430 // |
|
431 TInt CClockAlarmArray::GetDisabledAlarmIndex( TAlarmId aAlarmId, TInt aErrorValue ) |
|
432 { |
|
433 TInt listItemIndex( KFirstAlarmIndex ); |
|
434 TInt disabledAlarmIndex( KErrNotFound ); |
|
435 |
|
436 // Calculate the index of deactivated alarm. |
|
437 // Get the enabled alarms count first and start counting from there for deactivated alarms. |
|
438 // The order of alarms in the listbox is not always the same in the alarmarray |
|
439 // because disabled alarms are displayed in the end of the list and the next alarm |
|
440 // to expire is on top of the list. |
|
441 for( TInt index( KFirstAlarmIndex ); index < iAlarmIdArray.Count(); index++ ) |
|
442 { |
|
443 SClkAlarmInfo alarmInfo; |
|
444 TInt errorVal( iAlarmModel->ClockAlarmInfo( iAlarmIdArray[ index ], alarmInfo ) ); |
|
445 |
|
446 if( ( KErrNone == aErrorValue ) && |
|
447 ( EAlarmStateInPreparation != alarmInfo.iState && |
|
448 EAlarmStateNotified != alarmInfo.iState && |
|
449 EAlarmStatusEnabled == alarmInfo.iStatus ) ) |
|
450 { |
|
451 listItemIndex++; |
|
452 } |
|
453 } |
|
454 |
|
455 // ListItemIndex contains the count of enabled alarms. Now count from here. |
|
456 for( TInt index( KFirstAlarmIndex ); index < iAlarmIdArray.Count(); index++ ) |
|
457 { |
|
458 SClkAlarmInfo alarmInfo; |
|
459 TInt errorVal( iAlarmModel->ClockAlarmInfo( iAlarmIdArray[ index ], alarmInfo ) ); |
|
460 |
|
461 if( ( KErrNone == aErrorValue ) && |
|
462 ( EAlarmStateInPreparation != alarmInfo.iState && |
|
463 EAlarmStateNotified != alarmInfo.iState && |
|
464 EAlarmStatusEnabled != alarmInfo.iStatus ) ) |
|
465 { |
|
466 if( aAlarmId == iAlarmIdArray[ index ] ) |
|
467 { |
|
468 disabledAlarmIndex = listItemIndex; |
|
469 } |
|
470 else |
|
471 { |
|
472 listItemIndex++; |
|
473 } |
|
474 } |
|
475 } |
|
476 |
|
477 return disabledAlarmIndex; |
|
478 } |
|
479 |
|
480 // --------------------------------------------------------- |
|
481 // CClockAlarmArray::InitIdList |
|
482 // rest of the details are commented in the header |
|
483 // --------------------------------------------------------- |
|
484 // |
|
485 void CClockAlarmArray::InitIdList() |
|
486 { |
|
487 __PRINTS( "CClockAlarmArray::InitIdList - Entry" ); |
|
488 |
|
489 // Reset the array. |
|
490 iAlarmIdArray.Close(); |
|
491 // Get the ids from alarmserver. |
|
492 iAlarmModel->GetClkAlarmIds( iAlarmIdArray ); |
|
493 |
|
494 // Add a dummy index for "New Alarm" Option as first item in the Id array. |
|
495 iAlarmIdArray.Insert( KNewAlarmIndex, KNewAlarmIndex ); |
|
496 |
|
497 SClkAlarmInfo alarmInfo; |
|
498 TInt alarmCount( iAlarmIdArray.Count() ); |
|
499 |
|
500 // Set all alarm id entries which are notified/invalid to '0'. |
|
501 for( TInt index( KFirstAlarmIndex ); index < alarmCount; index++ ) |
|
502 { |
|
503 TInt errorValue( iAlarmModel->ClockAlarmInfo( iAlarmIdArray[ index ], alarmInfo ) ); |
|
504 |
|
505 if( ( KErrNone != errorValue ) || |
|
506 ( EAlarmStateInPreparation == alarmInfo.iState || |
|
507 EAlarmStateNotified == alarmInfo.iState ) ) |
|
508 { |
|
509 iAlarmIdArray[ index ] = KErrNone; |
|
510 } |
|
511 } |
|
512 |
|
513 // Delete all the alarm entries in the alarm id array with value '0', as marked above. |
|
514 for( TInt index( KFirstAlarmIndex ); index < iAlarmIdArray.Count(); ) |
|
515 { |
|
516 if( KErrNone == iAlarmIdArray[ index ] ) |
|
517 { |
|
518 iAlarmIdArray.Remove( index ); |
|
519 index = KFirstAlarmIndex; |
|
520 } |
|
521 else |
|
522 { |
|
523 index++; |
|
524 } |
|
525 } |
|
526 |
|
527 __PRINTS( "CClockAlarmArray::InitIdList - Exit" ); |
|
528 } |
|
529 |
|
530 // --------------------------------------------------------- |
|
531 // CClockAlarmArray::GetSortedAlmIdInfo |
|
532 // rest of the details are commented in the header |
|
533 // --------------------------------------------------------- |
|
534 // |
|
535 void CClockAlarmArray::GetSortedAlmIdInfo( TInt aIndex, TAlarmId& aAlarmId, SClkAlarmInfo& aAlarmInfo ) const |
|
536 { |
|
537 __PRINTS( "CClockAlarmArray::NewL - Entry" ); |
|
538 |
|
539 // Function is declared as const. So using a local array instead of the data member. |
|
540 // First get the alarm id list from the alarm server. |
|
541 RArray< TAlarmId > alarmIdArray; |
|
542 iAlarmModel->GetClkAlarmIds( alarmIdArray ); |
|
543 |
|
544 // This will hold the count of alarms currently enabled( active ). |
|
545 TInt alarmIdCount( alarmIdArray.Count() ); |
|
546 |
|
547 // Get the alarms which are enabled and active. |
|
548 TInt enabledAlarmCount( GetEnabledAlarmCount() ); |
|
549 |
|
550 // If info of an active alarm is needed. |
|
551 if( aIndex <= enabledAlarmCount ) |
|
552 { |
|
553 GetActiveAlarmInfo( aIndex, aAlarmId , aAlarmInfo ); |
|
554 } |
|
555 // Info of a disabled alarm is needed. |
|
556 else |
|
557 { |
|
558 GetInActiveAlarmInfo( aIndex, aAlarmId , aAlarmInfo ); |
|
559 } |
|
560 |
|
561 // Sanity check, control should never come here. |
|
562 alarmIdArray.Close(); |
|
563 |
|
564 return; |
|
565 } |
|
566 |
|
567 // --------------------------------------------------------- |
|
568 // CClockAlarmArray::GetEnabledAlarmCount |
|
569 // rest of the details are commented in the header |
|
570 // --------------------------------------------------------- |
|
571 // |
|
572 TInt CClockAlarmArray::GetEnabledAlarmCount() const |
|
573 { |
|
574 // First get the alarm id list from the alarm server. |
|
575 RArray< TAlarmId > alarmIdArray; |
|
576 iAlarmModel->GetClkAlarmIds( alarmIdArray ); |
|
577 |
|
578 // This will hold the count of alarms currently enabled( active ). |
|
579 TInt alarmCount( NULL ); |
|
580 TInt alarmIdCount( alarmIdArray.Count() ); |
|
581 |
|
582 // Get the alarms which are enabled and active. |
|
583 for( TInt index( NULL ); index < alarmIdCount; index++ ) |
|
584 { |
|
585 // Get information of each alarm. |
|
586 SClkAlarmInfo alarmInfo; |
|
587 TInt errorValue( iAlarmModel->ClockAlarmInfo( alarmIdArray[ index ], alarmInfo ) ); |
|
588 |
|
589 if( ( KErrNone == errorValue ) && |
|
590 ( EAlarmStateInPreparation != alarmInfo.iState && |
|
591 EAlarmStateNotified != alarmInfo.iState && |
|
592 EAlarmStatusEnabled == alarmInfo.iStatus ) ) |
|
593 { |
|
594 alarmCount++; |
|
595 } |
|
596 } |
|
597 |
|
598 alarmIdArray.Close(); |
|
599 |
|
600 return alarmCount; |
|
601 } |
|
602 |
|
603 // --------------------------------------------------------- |
|
604 // CClockAlarmArray::GetActiveAlarmInfo |
|
605 // rest of the details are commented in the header |
|
606 // --------------------------------------------------------- |
|
607 // |
|
608 void CClockAlarmArray::GetActiveAlarmInfo( TInt aIndex, TAlarmId& aAlarmId, SClkAlarmInfo& aAlarmInfo ) const |
|
609 { |
|
610 // First get the alarm id list from the alarm server. |
|
611 RArray< TAlarmId > alarmIdArray; |
|
612 iAlarmModel->GetClkAlarmIds( alarmIdArray ); |
|
613 |
|
614 TInt alarmIdCount( alarmIdArray.Count() ); |
|
615 TInt alarmIndex( NULL ); |
|
616 |
|
617 for( TInt index( NULL ); index < alarmIdCount; index++ ) |
|
618 { |
|
619 // Get information of each alarm. |
|
620 SClkAlarmInfo alarmInfo; |
|
621 TInt errorValue( iAlarmModel->ClockAlarmInfo( alarmIdArray[ index ], alarmInfo ) ); |
|
622 |
|
623 if( ( KErrNone == errorValue ) && |
|
624 ( EAlarmStateInPreparation != alarmInfo.iState && |
|
625 EAlarmStateNotified != alarmInfo.iState && |
|
626 EAlarmStatusEnabled == alarmInfo.iStatus ) ) |
|
627 { |
|
628 alarmIndex++; |
|
629 } |
|
630 if( aIndex == alarmIndex ) |
|
631 { |
|
632 // We have a match, return the values. |
|
633 aAlarmId = alarmIdArray[ index ]; |
|
634 aAlarmInfo = alarmInfo; |
|
635 alarmIdArray.Close(); |
|
636 |
|
637 // Break the loop. |
|
638 return; |
|
639 } |
|
640 } |
|
641 } |
|
642 |
|
643 // --------------------------------------------------------- |
|
644 // CClockAlarmArray::GetInActiveAlarmInfo |
|
645 // rest of the details are commented in the header |
|
646 // --------------------------------------------------------- |
|
647 // |
|
648 void CClockAlarmArray::GetInActiveAlarmInfo( TInt aIndex, TAlarmId& aAlarmId, SClkAlarmInfo& aAlarmInfo ) const |
|
649 { |
|
650 RArray< TAlarmId > alarmIdArray; |
|
651 iAlarmModel->GetClkAlarmIds( alarmIdArray ); |
|
652 |
|
653 TInt alarmIdCount( alarmIdArray.Count() ); |
|
654 TInt alarmIndex( NULL ); |
|
655 |
|
656 // Get the alarms which are enabled and active. |
|
657 TInt enabledAlarmCount = GetEnabledAlarmCount(); |
|
658 |
|
659 for( TInt index( NULL ); index < alarmIdCount; index++ ) |
|
660 { |
|
661 // Get information of each alarm. |
|
662 SClkAlarmInfo alarmInfo; |
|
663 TInt errorValue( iAlarmModel->ClockAlarmInfo( alarmIdArray[ index ], alarmInfo ) ); |
|
664 |
|
665 if( ( KErrNone == errorValue ) && |
|
666 ( EAlarmStateInPreparation != alarmInfo.iState && |
|
667 EAlarmStateNotified != alarmInfo.iState && |
|
668 EAlarmStatusEnabled != alarmInfo.iStatus ) ) |
|
669 { |
|
670 alarmIndex++; |
|
671 } |
|
672 // Disabled alarms are always indexed after the enabled alarms. |
|
673 if( ( enabledAlarmCount + alarmIndex ) == aIndex ) |
|
674 { |
|
675 aAlarmId = alarmIdArray[ index ]; |
|
676 aAlarmInfo = alarmInfo; |
|
677 alarmIdArray.Close(); |
|
678 |
|
679 // Break the loop. |
|
680 return; |
|
681 } |
|
682 } |
|
683 } |
|
684 |
|
685 // --------------------------------------------------------- |
|
686 // CClockAlarmArray::ConstructL |
|
687 // rest of the details are commented in the header |
|
688 // --------------------------------------------------------- |
|
689 // |
|
690 void CClockAlarmArray::ConstructL( CClkUiAlarmModel* aAlarmModel, CCoeEnv* aCoeEnv ) |
|
691 { |
|
692 __PRINTS( "CClockAlarmArray::ConstructL - Entry" ); |
|
693 |
|
694 // Save the alarm model and the environment. |
|
695 iAlarmModel = aAlarmModel; |
|
696 iEnv = aCoeEnv; |
|
697 |
|
698 // The listbox item. |
|
699 iListBoxEntry = HBufC::NewLC( 175 ); |
|
700 CleanupStack::Pop( iListBoxEntry ); |
|
701 |
|
702 // Initialize the alarm id array. |
|
703 InitIdList(); |
|
704 |
|
705 // Read the string resources. |
|
706 iWorkDaysList = iEnv->ReadDesCArrayResourceL( R_CLOCK_WEEK_DAYS_ARRAY ); |
|
707 iShortWorkDaysList = iEnv->ReadDesCArrayResourceL( R_CLOCK_WEEK_DAYS_SHORT_ARRAY ); |
|
708 iOccuranceList = iEnv->ReadDesCArrayResourceL( R_CLOCK_ALARM_EDITOR_OCCU_ARRAY ); |
|
709 iNewAlarmText = StringLoader::LoadL( R_QTN_CLK_COMMAND_NEW_ALARM, iEnv ); |
|
710 iAlarmInactiveText = StringLoader::LoadL( R_QTN_CLOCK_ALARMS_VIEW_INACTIVE_ALARM, iEnv ); |
|
711 iDate = StringLoader::LoadL( R_QTN_DATE_WITHOUT_YEAR_WITH_ZERO, iEnv ); |
|
712 iTimeFormat = StringLoader::LoadL( R_QTN_TIME_USUAL_WITH_ZERO,iEnv ); |
|
713 |
|
714 __PRINTS( "CClockAlarmArray::ConstructL - Exit" ); |
|
715 } |
|
716 |
|
717 // --------------------------------------------------------- |
|
718 // CClockAlarmArray::CClockAlarmArray |
|
719 // rest of the details are commented in the header |
|
720 // --------------------------------------------------------- |
|
721 // |
|
722 CClockAlarmArray::CClockAlarmArray() |
|
723 { |
|
724 __PRINTS( "CClockAlarmArray::CClockAlarmArray - Entry" ); |
|
725 |
|
726 // No implementation yet. |
|
727 |
|
728 __PRINTS( "CClockAlarmArray::CClockAlarmArray - Exit" ); |
|
729 } |
|
730 |
|
731 // --------------------------------------------------------- |
|
732 // CClockAlarmArray::Power |
|
733 // rest of the details are commented in the header |
|
734 // --------------------------------------------------------- |
|
735 // |
|
736 TInt CClockAlarmArray::Power( TInt aNum ) const |
|
737 { |
|
738 __PRINTS( "CClockAlarmArray::Power - Entry" ); |
|
739 |
|
740 TInt returnValue( 1 ); |
|
741 |
|
742 // If 0, send the 1st item. |
|
743 if( KErrNone == aNum ) |
|
744 { |
|
745 __PRINTS( "CClockAlarmArray::Power - Exit" ); |
|
746 |
|
747 return returnValue; |
|
748 } |
|
749 |
|
750 // Iterate through the list for the match. |
|
751 for( TInt index( KErrNone ); index < aNum; index++ ) |
|
752 { |
|
753 returnValue = returnValue * 2; |
|
754 } |
|
755 |
|
756 __PRINTS( "CClockAlarmArray::Power - Exit" ); |
|
757 |
|
758 return returnValue; |
|
759 } |
|
760 |
|
761 // End of file |