alarmui/src/AlmAlarmInfo.cpp
branchRCL_3
changeset 29 12af337248b1
parent 0 f979ecb2b13e
child 30 bd7edf625bdd
equal deleted inserted replaced
28:96907930389d 29:12af337248b1
    29 
    29 
    30 #include <AlmAlert.rsg>
    30 #include <AlmAlert.rsg>
    31 
    31 
    32 const TInt KAlarmNoteTextLength( 256 ); // KGlobalNoteTextLength
    32 const TInt KAlarmNoteTextLength( 256 ); // KGlobalNoteTextLength
    33 const TInt KDateTimeDescLen( 20 ); // enough space for // "16:54" or "1:56 am" or "10.10.2010"
    33 const TInt KDateTimeDescLen( 20 ); // enough space for // "16:54" or "1:56 am" or "10.10.2010"
    34 const TInt KClockAlarmType( -1 );
    34 // const TInt KClockAlarmType( -1 );
    35 _LIT( KWesternSubjectSeparator, ", " );
    35 // _LIT( KWesternSubjectSeparator, ", " );
    36 _LIT( KArabicSubjectSeparator, " \x060c" );
    36 // _LIT( KArabicSubjectSeparator, " \x060c" );
    37 _LIT( KNewLine, "\n" );
    37 // _LIT( KNewLine, "\n" );
    38 _LIT( KSpace, " " );
    38 // _LIT( KSpace, " " );
    39 
    39 
    40 
    40 
    41 // ============================ MEMBER FUNCTIONS ===============================
    41 // ============================ MEMBER FUNCTIONS ===============================
    42 
    42 
    43 // constructor
    43 // constructor
    44 CAlmAlarmInfo::CAlmAlarmInfo(CAlarmUtils* aAlarmUtils)
    44 CAlmAlarmInfo::CAlmAlarmInfo(CAlarmUtils* aAlarmUtils)
    45 : iAlarmUtils( aAlarmUtils )
    45 : iAlarmUtils( aAlarmUtils )
    46 {
    46 {
    47     TRACE_ENTRY_POINT;
    47     TRACE_ENTRY_POINT;
       
    48     
       
    49     iAlarmInfo = new SAlarmInfo;
       
    50     
    48     TRACE_EXIT_POINT;
    51     TRACE_EXIT_POINT;
    49 }
    52 }
    50 
    53 
    51 // destructor
    54 // destructor
    52 CAlmAlarmInfo::~CAlmAlarmInfo(void)
    55 CAlmAlarmInfo::~CAlmAlarmInfo(void)
    54     TRACE_ENTRY_POINT;
    57     TRACE_ENTRY_POINT;
    55     delete iSubject;
    58     delete iSubject;
    56     delete iLocation;
    59     delete iLocation;
    57     delete iDate;
    60     delete iDate;
    58     delete iTime;
    61     delete iTime;
       
    62     
       
    63     if( iAlarmInfo )
       
    64         {
       
    65         delete iAlarmInfo;
       
    66         iAlarmInfo = NULL;
       
    67         }
    59     TRACE_EXIT_POINT;
    68     TRACE_EXIT_POINT;
    60 }
    69 }
    61 
    70 
    62 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
    63 // Get the text for the alarm query.
    72 // Get the text for the alarm query.
    64 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    65 //
    74 //
    66 void CAlmAlarmInfo::GetAlarmLabelL( const TASShdAlarm& aAlarm, 
    75 void CAlmAlarmInfo::GetAlarmLabelL( const TASShdAlarm& /*aAlarm*/, 
    67                                     HBufC*& aText, 
    76                                     HBufC*& /*aText*/, 
    68                                     const CAlarmUtils::TAlarmType& aAlarmType )
    77                                     const CAlarmUtils::TAlarmType& /*aAlarmType*/ )
    69 {
    78 {
    70     /**
    79     /**
    71      *  Clock alarm:                  Other/unknown alarms:
    80      *  Clock alarm:                  Other/unknown alarms:
    72      *  ---------------------------   --------------------------- 
    81      *  ---------------------------   --------------------------- 
    73      *  | Clock alarm:     :::::: |   | 01.01.2010       :::::: | 
    82      *  | Clock alarm:     :::::: |   | 01.01.2010       :::::: | 
    99      *   To-Do:       time: "",      date: "01.01.2010", subject: "Subject",     location: "Location"
   108      *   To-Do:       time: "",      date: "01.01.2010", subject: "Subject",     location: "Location"
   100      */
   109      */
   101     TRACE_ENTRY_POINT;
   110     TRACE_ENTRY_POINT;
   102 
   111 
   103     // cover UI params...
   112     // cover UI params...
   104     TInt coverUIAlarmType( KClockAlarmType );
   113     // TInt coverUIAlarmType( KClockAlarmType );
   105 
   114 /*
   106     switch( aAlarmType )
   115     switch( aAlarmType )
   107     {
   116     {
   108         case CAlarmUtils::EAlarmTypeClock:
   117         case CAlarmUtils::EAlarmTypeClock:
   109         {
   118         {
   110             GetCoverUIParamsForClockAndOtherL( aAlarm, CAlarmUtils::EAlarmTypeClock );
   119             GetCoverUIParamsForClockAndOtherL( aAlarm, CAlarmUtils::EAlarmTypeClock );
   113         break;
   122         break;
   114 
   123 
   115         case CAlarmUtils::EAlarmTypeOther:
   124         case CAlarmUtils::EAlarmTypeOther:
   116         {
   125         {
   117             // For Cover UI - unknown alarms are handled as calendar meetings
   126             // For Cover UI - unknown alarms are handled as calendar meetings
   118             coverUIAlarmType = CCalEntry::EAppt;
   127             // coverUIAlarmType = CCalEntry::EAppt;
   119 
   128 
   120             GetCoverUIParamsForClockAndOtherL( aAlarm, CAlarmUtils::EAlarmTypeOther );
   129             GetCoverUIParamsForClockAndOtherL( aAlarm, CAlarmUtils::EAlarmTypeOther );
   121             SetupUnknownAlarmL( aText );
   130             SetupUnknownAlarmL( aText );
   122         }
   131         }
   123         break;
   132         break;
   137             CleanupStack::PushL( entry );
   146             CleanupStack::PushL( entry );
   138             CleanupStack::PushL( aText );
   147             CleanupStack::PushL( aText );
   139 
   148 
   140             // entry type
   149             // entry type
   141             CCalEntry::TType type = entry->EntryTypeL();
   150             CCalEntry::TType type = entry->EntryTypeL();
   142             coverUIAlarmType = type;
   151             // coverUIAlarmType = type;
   143 
   152 
   144             GetCoverUIParamsForCalendarL( entry );
   153             GetCoverUIParamsForCalendarL( entry );
   145 
   154 
   146             switch( type )
   155             switch( type )
   147             {
   156             {
   181     iAlarmUtils->NotifierDialogController()->AddAlarmAdditionalInfo( coverUIAlarmType, 
   190     iAlarmUtils->NotifierDialogController()->AddAlarmAdditionalInfo( coverUIAlarmType, 
   182                                                                      *iCoverTime, 
   191                                                                      *iCoverTime, 
   183                                                                      *iCoverDate, 
   192                                                                      *iCoverDate, 
   184                                                                      *iSubject, 
   193                                                                      *iSubject, 
   185                                                                      *iLocation );
   194                                                                      *iLocation );
   186     // ... and cleanup
       
   187     delete iSubject;   iSubject = NULL;
   195     delete iSubject;   iSubject = NULL;
   188     delete iLocation;  iLocation = NULL;
   196     delete iLocation;  iLocation = NULL;
   189     delete iDate;      iDate = NULL;
   197     delete iDate;      iDate = NULL;
   190     delete iTime;      iTime = NULL;
   198     delete iTime;      iTime = NULL;
   191     delete iCoverDate; iCoverDate = NULL;
   199     delete iCoverDate; iCoverDate = NULL;
   192     delete iCoverTime; iCoverTime = NULL;
   200     delete iCoverTime; iCoverTime = NULL;
   193 
   201 */
   194     TRACE_EXIT_POINT;
   202     TRACE_EXIT_POINT;
   195 }
   203 }
   196 
   204 
   197 // -----------------------------------------------------------------------------
   205 // -----------------------------------------------------------------------------
   198 // Get the text for the wake-up query.
   206 // Get the text for the wake-up query.
   201 void CAlmAlarmInfo::GetWakeupLabelL(HBufC*& aLabel)
   209 void CAlmAlarmInfo::GetWakeupLabelL(HBufC*& aLabel)
   202 {
   210 {
   203     TRACE_ENTRY_POINT;
   211     TRACE_ENTRY_POINT;
   204     aLabel = StringLoader::LoadL( R_EIKALARM_CONFIRMATION );
   212     aLabel = StringLoader::LoadL( R_EIKALARM_CONFIRMATION );
   205     TRACE_EXIT_POINT;
   213     TRACE_EXIT_POINT;
       
   214 }
       
   215 
       
   216 SAlarmInfo* CAlmAlarmInfo::GetAlarmInfo(TASShdAlarm aAlarm, CAlarmUtils::TAlarmType aAlarmType)
       
   217 {
       
   218     // Based on the alarm type, get the appropriate information
       
   219     switch( aAlarmType )
       
   220         {
       
   221         case CAlarmUtils::EAlarmTypeClock:
       
   222             {
       
   223             SetupClockAlarmL( aAlarm );
       
   224             // Set the alarm type
       
   225 			iAlarmInfo->iAlarmAlertType = CAlarmUtils::EAlarmTypeClock;
       
   226             }
       
   227         break;
       
   228 
       
   229         case CAlarmUtils::EAlarmTypeOther:
       
   230             {
       
   231             // TODO: Handle this case 
       
   232             SetupUnknownAlarmL( aAlarm );
       
   233             iAlarmInfo->iAlarmAlertType = CAlarmUtils::EAlarmTypeOther;
       
   234             }
       
   235         break;
       
   236 
       
   237         case CAlarmUtils::EAlarmTypeCalendar:
       
   238             {
       
   239             // Check phone restore mode before creating agenda session
       
   240             if( iAlarmUtils->IsPhoneInRestoreMode() )
       
   241                 {
       
   242                 User::Leave( KErrCancel );
       
   243                 }
       
   244             // Set the alarm type
       
   245             iAlarmInfo->iAlarmAlertType = CAlarmUtils::EAlarmTypeCalendar;
       
   246             
       
   247             // Fetch the calendar entry and instance time
       
   248             CCalEntry* entry = NULL;
       
   249             
       
   250             // TODO: Use agenda interface to fetch the entry details
       
   251             iAlarmUtils->FetchEntryL( entry );
       
   252             CleanupStack::PushL( entry );
       
   253             
       
   254             const TTime instanceTime( iAlarmUtils->AlarmData().iInstanceTime.TimeLocalL() );
       
   255 
       
   256             // Subject
       
   257             iAlarmInfo->iSubject = HBufC::NewL( KAlarmNoteTextLength - KDateTimeDescLen );
       
   258             iAlarmInfo->iSubject->Des().Append( entry->SummaryL().Left( iAlarmInfo->iSubject->Des().MaxLength() ) );
       
   259             iAlarmInfo->iSubject->Des().TrimAll();
       
   260 
       
   261             // Location
       
   262             iAlarmInfo->iLocation = HBufC::NewL( Max( 0, KAlarmNoteTextLength - KDateTimeDescLen - iAlarmInfo->iSubject->Length() ) );
       
   263             iAlarmInfo->iLocation->Des().Append( entry->LocationL().Left( iAlarmInfo->iLocation->Des().MaxLength() ) );
       
   264             iAlarmInfo->iLocation->Des().TrimAll();
       
   265 
       
   266             // Date
       
   267             iAlarmInfo->iDate = instanceTime;
       
   268 
       
   269             // Get the entry type
       
   270             CCalEntry::TType type = entry->EntryTypeL();
       
   271 
       
   272             // Based on the type of entry, get the information
       
   273             switch( type )
       
   274                 {
       
   275                 case CCalEntry::EAppt:
       
   276                 case CCalEntry::EReminder:
       
   277                     {
       
   278                     // TODO : Format text based on type of entry
       
   279                     // SetupAppointmentAlarmL( aAlarm );
       
   280                     iAlarmInfo->iTime = instanceTime;
       
   281                     iAlarmInfo->iIsTimed = ETrue;
       
   282                     }
       
   283                 break;
       
   284 
       
   285                 case CCalEntry::ETodo:
       
   286                     {
       
   287                     // TODO : Format text based on type of entry
       
   288                     //SetupToDoAlarmL( aAlarm );
       
   289                     iAlarmInfo->iAlarmAlertType = CAlarmUtils::EAlarmTypeTodo;
       
   290                     iAlarmInfo->iTime = TTime( 0 );
       
   291                     iAlarmInfo->iIsTimed = EFalse;
       
   292                     // No Location is there for todo alarms
       
   293                     iAlarmInfo->iLocation = HBufC::NewL( 0 );
       
   294                     }
       
   295                 break;
       
   296                 
       
   297                 case CCalEntry::EEvent:
       
   298                     {
       
   299                     // No time information for an all day event	
       
   300                     iAlarmInfo->iTime = TTime( 0 );
       
   301                     iAlarmInfo->iIsTimed = EFalse;
       
   302                     }
       
   303                 break;
       
   304                 
       
   305                 default:
       
   306                     {
       
   307                     // TODO : Format text based on type of entry
       
   308                     // SetupAnniversaryAlarmL( aAlarm );
       
   309                     iAlarmInfo->iTime = TTime( 0 );
       
   310                     }
       
   311                 break;
       
   312                 }
       
   313             CleanupStack::PopAndDestroy( entry );
       
   314             }
       
   315         break;
       
   316 
       
   317         default:
       
   318             __ASSERT_DEBUG( EFalse, User::Invariant() );
       
   319     }
       
   320     return iAlarmInfo;
   206 }
   321 }
   207 
   322 
   208 // =============================================================================
   323 // =============================================================================
   209 // ALARM SETUP METHODS
   324 // ALARM SETUP METHODS
   210 // =============================================================================
   325 // =============================================================================
   211 
   326 
       
   327 /*
   212 // -----------------------------------------------------------------------------
   328 // -----------------------------------------------------------------------------
   213 // Create alarm notification string for Clock alarm.
   329 // Create alarm notification string for Clock alarm.
   214 // "[Clock alarm:][\n][time][\n][Description]"
   330 // "[Clock alarm:][\n][time][\n][Description]"
   215 // -----------------------------------------------------------------------------
   331 // -----------------------------------------------------------------------------
   216 //
   332 //
   385 
   501 
   386     CleanupStack::Pop( aText );
   502     CleanupStack::Pop( aText );
   387     TRACE_EXIT_POINT;
   503     TRACE_EXIT_POINT;
   388 }
   504 }
   389 
   505 
   390 
   506 */
   391 
   507 
   392 // =============================================================================
   508 // =============================================================================
   393 // STRING UTILITY FUNCTIONS
   509 // STRING UTILITY FUNCTIONS
   394 // =============================================================================
   510 // =============================================================================
   395 
   511 
   413         aDest.Append( *iLocation );
   529         aDest.Append( *iLocation );
   414     }
   530     }
   415     TRACE_EXIT_POINT;
   531     TRACE_EXIT_POINT;
   416 }
   532 }
   417 
   533 
       
   534 /*
   418 // -----------------------------------------------------------------------------
   535 // -----------------------------------------------------------------------------
   419 // Create strings needed for calendar alarms.
   536 // Create strings needed for calendar alarms.
   420 // AVKON global note can't (currently) show more than 256 characters.  So no 
   537 // AVKON global note can't (currently) show more than 256 characters.  So no 
   421 // need to use more than KAlarmNoteTextLength -KDateTimeDescLen for subject 
   538 // need to use more than KAlarmNoteTextLength -KDateTimeDescLen for subject 
   422 // and location strings.
   539 // and location strings.
   514 
   631 
   515     CleanupStack::PopAndDestroy( timeFormat );
   632     CleanupStack::PopAndDestroy( timeFormat );
   516     CleanupStack::PopAndDestroy( dateFormat );
   633     CleanupStack::PopAndDestroy( dateFormat );
   517     TRACE_EXIT_POINT;
   634     TRACE_EXIT_POINT;
   518 }
   635 }
   519 
   636 */
       
   637 
       
   638 void CAlmAlarmInfo::SetupUnknownAlarmL(TASShdAlarm /* aAlarm */)
       
   639 {
       
   640     
       
   641 }
       
   642 
       
   643 void CAlmAlarmInfo::SetupClockAlarmL(TASShdAlarm aAlarm)
       
   644 {
       
   645     // The alarm subject
       
   646     iAlarmInfo->iSubject = aAlarm.Message().AllocL();
       
   647     iAlarmInfo->iSubject->Des().TrimAll();
       
   648 
       
   649     // Location must not be displayed for clock alarms
       
   650     iAlarmInfo->iLocation = HBufC::NewL( 0 );
       
   651 
       
   652     // The alarm time
       
   653     iAlarmInfo->iTime = aAlarm.NextDueTime();
       
   654 
       
   655     // Date must not be shown for clock alarms
       
   656     iAlarmInfo->iDate = TTime( 0 );
       
   657 }
       
   658 
       
   659 void CAlmAlarmInfo::SetupAppointmentAlarmL(TASShdAlarm /* aAlarm */)
       
   660 {
       
   661 
       
   662 }
       
   663 
       
   664 void CAlmAlarmInfo::SetupToDoAlarmL(TASShdAlarm /* aAlarm */)
       
   665 {
       
   666     
       
   667 }
       
   668 
       
   669 void CAlmAlarmInfo::SetupAnniversaryAlarmL(TASShdAlarm /* aAlarm */)
       
   670 {
       
   671     
       
   672 }
   520 
   673 
   521 // End of File
   674 // End of File