28 #include "clkuialarmmodel.h" |
28 #include "clkuialarmmodel.h" |
29 #include "clock_debug.h" |
29 #include "clock_debug.h" |
30 |
30 |
31 // Constants |
31 // Constants |
32 const TInt KTimeStringLength( 25 ); |
32 const TInt KTimeStringLength( 25 ); |
33 const TInt KFirstAlarmIndex( 1 ); |
33 const TInt KFirstAlarmIndex( 0 ); |
34 const TInt KNewAlarmIndex( 0 ); |
|
35 |
34 |
36 // Literals |
35 // Literals |
37 _LIT( KFieldSeparator, "\t" ); |
36 _LIT( KFieldSeparator, "\t" ); |
38 _LIT( KReplaceWhitespaceChars, "\x0009\x000A\x000B\x000C\x000D\x2028\x2029" ); |
37 _LIT( KReplaceWhitespaceChars, "\x0009\x000A\x000B\x000C\x000D\x2028\x2029" ); |
39 |
38 |
149 // --------------------------------------------------------- |
148 // --------------------------------------------------------- |
150 // |
149 // |
151 TPtrC16 CClockAlarmArray::MdcaPoint( TInt aIndex ) const |
150 TPtrC16 CClockAlarmArray::MdcaPoint( TInt aIndex ) const |
152 { |
151 { |
153 __PRINTS( "CClockAlarmArray::MdcaPoint - Entry" ); |
152 __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; |
153 SClkAlarmInfo alarmInfo; |
184 TBuf< KTimeStringLength > timeString; |
154 TBuf< KTimeStringLength > timeString; |
185 TAlarmId alarmId; |
155 TAlarmId alarmId; |
186 |
156 |
187 // First get the sorted alarm information for the given index. |
157 // First get the sorted alarm information for the given index. |
489 // Reset the array. |
459 // Reset the array. |
490 iAlarmIdArray.Close(); |
460 iAlarmIdArray.Close(); |
491 // Get the ids from alarmserver. |
461 // Get the ids from alarmserver. |
492 iAlarmModel->GetClkAlarmIds( iAlarmIdArray ); |
462 iAlarmModel->GetClkAlarmIds( iAlarmIdArray ); |
493 |
463 |
494 // Add a dummy index for "New Alarm" Option as first item in the Id array. |
|
495 iAlarmIdArray.Insert( KNewAlarmIndex, KNewAlarmIndex ); |
|
496 |
464 |
497 SClkAlarmInfo alarmInfo; |
465 SClkAlarmInfo alarmInfo; |
498 TInt alarmCount( iAlarmIdArray.Count() ); |
466 TInt alarmCount( iAlarmIdArray.Count() ); |
499 |
467 |
500 // Set all alarm id entries which are notified/invalid to '0'. |
468 // Set all alarm id entries which are notified/invalid to '0'. |
546 |
514 |
547 // Get the alarms which are enabled and active. |
515 // Get the alarms which are enabled and active. |
548 TInt enabledAlarmCount( GetEnabledAlarmCount() ); |
516 TInt enabledAlarmCount( GetEnabledAlarmCount() ); |
549 |
517 |
550 // If info of an active alarm is needed. |
518 // If info of an active alarm is needed. |
551 if( aIndex <= enabledAlarmCount ) |
519 if( aIndex < enabledAlarmCount ) |
552 { |
520 { |
553 GetActiveAlarmInfo( aIndex, aAlarmId , aAlarmInfo ); |
521 GetActiveAlarmInfo( aIndex, aAlarmId , aAlarmInfo ); |
554 } |
522 } |
555 // Info of a disabled alarm is needed. |
523 // Info of a disabled alarm is needed. |
556 else |
524 else |
610 // First get the alarm id list from the alarm server. |
578 // First get the alarm id list from the alarm server. |
611 RArray< TAlarmId > alarmIdArray; |
579 RArray< TAlarmId > alarmIdArray; |
612 iAlarmModel->GetClkAlarmIds( alarmIdArray ); |
580 iAlarmModel->GetClkAlarmIds( alarmIdArray ); |
613 |
581 |
614 TInt alarmIdCount( alarmIdArray.Count() ); |
582 TInt alarmIdCount( alarmIdArray.Count() ); |
615 TInt alarmIndex( NULL ); |
583 TInt alarmIndex( 0 ); |
616 |
584 |
617 for( TInt index( NULL ); index < alarmIdCount; index++ ) |
585 for( TInt index( 0 ); index < alarmIdCount; index++ ) |
618 { |
586 { |
619 // Get information of each alarm. |
587 // Get information of each alarm. |
620 SClkAlarmInfo alarmInfo; |
588 SClkAlarmInfo alarmInfo; |
621 TInt errorValue( iAlarmModel->ClockAlarmInfo( alarmIdArray[ index ], alarmInfo ) ); |
589 TInt errorValue( iAlarmModel->ClockAlarmInfo( alarmIdArray[ index ], alarmInfo ) ); |
622 |
590 |
623 if( ( KErrNone == errorValue ) && |
591 if( !( ( KErrNone == errorValue ) && |
624 ( EAlarmStateInPreparation != alarmInfo.iState && |
592 ( EAlarmStateInPreparation != alarmInfo.iState && |
625 EAlarmStateNotified != alarmInfo.iState && |
593 EAlarmStateNotified != alarmInfo.iState && |
626 EAlarmStatusEnabled == alarmInfo.iStatus ) ) |
594 EAlarmStatusEnabled == alarmInfo.iStatus ) ) ) |
627 { |
595 { |
628 alarmIndex++; |
596 continue; |
629 } |
597 } |
|
598 |
630 if( aIndex == alarmIndex ) |
599 if( aIndex == alarmIndex ) |
631 { |
600 { |
632 // We have a match, return the values. |
601 // We have a match, return the values. |
633 aAlarmId = alarmIdArray[ index ]; |
602 aAlarmId = alarmIdArray[ index ]; |
634 aAlarmInfo = alarmInfo; |
603 aAlarmInfo = alarmInfo; |
635 alarmIdArray.Close(); |
604 alarmIdArray.Close(); |
636 |
605 |
637 // Break the loop. |
606 // Break the loop. |
638 return; |
607 return; |
639 } |
608 } |
640 } |
609 alarmIndex++; |
641 } |
610 } |
|
611 } |
642 |
612 |
643 // --------------------------------------------------------- |
613 // --------------------------------------------------------- |
644 // CClockAlarmArray::GetInActiveAlarmInfo |
614 // CClockAlarmArray::GetInActiveAlarmInfo |
645 // rest of the details are commented in the header |
615 // rest of the details are commented in the header |
646 // --------------------------------------------------------- |
616 // --------------------------------------------------------- |
653 TInt alarmIdCount( alarmIdArray.Count() ); |
623 TInt alarmIdCount( alarmIdArray.Count() ); |
654 TInt alarmIndex( NULL ); |
624 TInt alarmIndex( NULL ); |
655 |
625 |
656 // Get the alarms which are enabled and active. |
626 // Get the alarms which are enabled and active. |
657 TInt enabledAlarmCount = GetEnabledAlarmCount(); |
627 TInt enabledAlarmCount = GetEnabledAlarmCount(); |
658 |
628 |
659 for( TInt index( NULL ); index < alarmIdCount; index++ ) |
629 for( TInt index( 0 ); index < alarmIdCount; index++ ) |
660 { |
630 { |
661 // Get information of each alarm. |
631 // Get information of each alarm. |
662 SClkAlarmInfo alarmInfo; |
632 SClkAlarmInfo alarmInfo; |
663 TInt errorValue( iAlarmModel->ClockAlarmInfo( alarmIdArray[ index ], alarmInfo ) ); |
633 TInt errorValue( iAlarmModel->ClockAlarmInfo( alarmIdArray[ index ], alarmInfo ) ); |
664 |
634 |
665 if( ( KErrNone == errorValue ) && |
635 if( !( ( KErrNone == errorValue ) && |
666 ( EAlarmStateInPreparation != alarmInfo.iState && |
636 ( EAlarmStateInPreparation != alarmInfo.iState && |
667 EAlarmStateNotified != alarmInfo.iState && |
637 EAlarmStateNotified != alarmInfo.iState && |
668 EAlarmStatusEnabled != alarmInfo.iStatus ) ) |
638 EAlarmStatusEnabled != alarmInfo.iStatus ) ) ) |
669 { |
639 { |
670 alarmIndex++; |
640 continue; |
671 } |
641 } |
672 // Disabled alarms are always indexed after the enabled alarms. |
642 // Disabled alarms are always indexed after the enabled alarms. |
673 if( ( enabledAlarmCount + alarmIndex ) == aIndex ) |
643 if( ( enabledAlarmCount + alarmIndex ) == aIndex ) |
674 { |
644 { |
675 aAlarmId = alarmIdArray[ index ]; |
645 aAlarmId = alarmIdArray[ index ]; |