alarmui/src/AlmAlarmInfo.cpp
branchRCL_3
changeset 30 bd7edf625bdd
parent 29 12af337248b1
equal deleted inserted replaced
29:12af337248b1 30:bd7edf625bdd
    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     
       
    51     TRACE_EXIT_POINT;
    48     TRACE_EXIT_POINT;
    52 }
    49 }
    53 
    50 
    54 // destructor
    51 // destructor
    55 CAlmAlarmInfo::~CAlmAlarmInfo(void)
    52 CAlmAlarmInfo::~CAlmAlarmInfo(void)
    57     TRACE_ENTRY_POINT;
    54     TRACE_ENTRY_POINT;
    58     delete iSubject;
    55     delete iSubject;
    59     delete iLocation;
    56     delete iLocation;
    60     delete iDate;
    57     delete iDate;
    61     delete iTime;
    58     delete iTime;
    62     
       
    63     if( iAlarmInfo )
       
    64         {
       
    65         delete iAlarmInfo;
       
    66         iAlarmInfo = NULL;
       
    67         }
       
    68     TRACE_EXIT_POINT;
    59     TRACE_EXIT_POINT;
    69 }
    60 }
    70 
    61 
    71 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------
    72 // Get the text for the alarm query.
    63 // Get the text for the alarm query.
    73 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
    74 //
    65 //
    75 void CAlmAlarmInfo::GetAlarmLabelL( const TASShdAlarm& /*aAlarm*/, 
    66 void CAlmAlarmInfo::GetAlarmLabelL( const TASShdAlarm& aAlarm, 
    76                                     HBufC*& /*aText*/, 
    67                                     HBufC*& aText, 
    77                                     const CAlarmUtils::TAlarmType& /*aAlarmType*/ )
    68                                     const CAlarmUtils::TAlarmType& aAlarmType )
    78 {
    69 {
    79     /**
    70     /**
    80      *  Clock alarm:                  Other/unknown alarms:
    71      *  Clock alarm:                  Other/unknown alarms:
    81      *  ---------------------------   --------------------------- 
    72      *  ---------------------------   --------------------------- 
    82      *  | Clock alarm:     :::::: |   | 01.01.2010       :::::: | 
    73      *  | Clock alarm:     :::::: |   | 01.01.2010       :::::: | 
   108      *   To-Do:       time: "",      date: "01.01.2010", subject: "Subject",     location: "Location"
    99      *   To-Do:       time: "",      date: "01.01.2010", subject: "Subject",     location: "Location"
   109      */
   100      */
   110     TRACE_ENTRY_POINT;
   101     TRACE_ENTRY_POINT;
   111 
   102 
   112     // cover UI params...
   103     // cover UI params...
   113     // TInt coverUIAlarmType( KClockAlarmType );
   104     TInt coverUIAlarmType( KClockAlarmType );
   114 /*
   105 
   115     switch( aAlarmType )
   106     switch( aAlarmType )
   116     {
   107     {
   117         case CAlarmUtils::EAlarmTypeClock:
   108         case CAlarmUtils::EAlarmTypeClock:
   118         {
   109         {
   119             GetCoverUIParamsForClockAndOtherL( aAlarm, CAlarmUtils::EAlarmTypeClock );
   110             GetCoverUIParamsForClockAndOtherL( aAlarm, CAlarmUtils::EAlarmTypeClock );
   122         break;
   113         break;
   123 
   114 
   124         case CAlarmUtils::EAlarmTypeOther:
   115         case CAlarmUtils::EAlarmTypeOther:
   125         {
   116         {
   126             // For Cover UI - unknown alarms are handled as calendar meetings
   117             // For Cover UI - unknown alarms are handled as calendar meetings
   127             // coverUIAlarmType = CCalEntry::EAppt;
   118             coverUIAlarmType = CCalEntry::EAppt;
   128 
   119 
   129             GetCoverUIParamsForClockAndOtherL( aAlarm, CAlarmUtils::EAlarmTypeOther );
   120             GetCoverUIParamsForClockAndOtherL( aAlarm, CAlarmUtils::EAlarmTypeOther );
   130             SetupUnknownAlarmL( aText );
   121             SetupUnknownAlarmL( aText );
   131         }
   122         }
   132         break;
   123         break;
   146             CleanupStack::PushL( entry );
   137             CleanupStack::PushL( entry );
   147             CleanupStack::PushL( aText );
   138             CleanupStack::PushL( aText );
   148 
   139 
   149             // entry type
   140             // entry type
   150             CCalEntry::TType type = entry->EntryTypeL();
   141             CCalEntry::TType type = entry->EntryTypeL();
   151             // coverUIAlarmType = type;
   142             coverUIAlarmType = type;
   152 
   143 
   153             GetCoverUIParamsForCalendarL( entry );
   144             GetCoverUIParamsForCalendarL( entry );
   154 
   145 
   155             switch( type )
   146             switch( type )
   156             {
   147             {
   190     iAlarmUtils->NotifierDialogController()->AddAlarmAdditionalInfo( coverUIAlarmType, 
   181     iAlarmUtils->NotifierDialogController()->AddAlarmAdditionalInfo( coverUIAlarmType, 
   191                                                                      *iCoverTime, 
   182                                                                      *iCoverTime, 
   192                                                                      *iCoverDate, 
   183                                                                      *iCoverDate, 
   193                                                                      *iSubject, 
   184                                                                      *iSubject, 
   194                                                                      *iLocation );
   185                                                                      *iLocation );
       
   186     // ... and cleanup
   195     delete iSubject;   iSubject = NULL;
   187     delete iSubject;   iSubject = NULL;
   196     delete iLocation;  iLocation = NULL;
   188     delete iLocation;  iLocation = NULL;
   197     delete iDate;      iDate = NULL;
   189     delete iDate;      iDate = NULL;
   198     delete iTime;      iTime = NULL;
   190     delete iTime;      iTime = NULL;
   199     delete iCoverDate; iCoverDate = NULL;
   191     delete iCoverDate; iCoverDate = NULL;
   200     delete iCoverTime; iCoverTime = NULL;
   192     delete iCoverTime; iCoverTime = NULL;
   201 */
   193 
   202     TRACE_EXIT_POINT;
   194     TRACE_EXIT_POINT;
   203 }
   195 }
   204 
   196 
   205 // -----------------------------------------------------------------------------
   197 // -----------------------------------------------------------------------------
   206 // Get the text for the wake-up query.
   198 // Get the text for the wake-up query.
   209 void CAlmAlarmInfo::GetWakeupLabelL(HBufC*& aLabel)
   201 void CAlmAlarmInfo::GetWakeupLabelL(HBufC*& aLabel)
   210 {
   202 {
   211     TRACE_ENTRY_POINT;
   203     TRACE_ENTRY_POINT;
   212     aLabel = StringLoader::LoadL( R_EIKALARM_CONFIRMATION );
   204     aLabel = StringLoader::LoadL( R_EIKALARM_CONFIRMATION );
   213     TRACE_EXIT_POINT;
   205     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;
       
   321 }
   206 }
   322 
   207 
   323 // =============================================================================
   208 // =============================================================================
   324 // ALARM SETUP METHODS
   209 // ALARM SETUP METHODS
   325 // =============================================================================
   210 // =============================================================================
   326 
   211 
   327 /*
       
   328 // -----------------------------------------------------------------------------
   212 // -----------------------------------------------------------------------------
   329 // Create alarm notification string for Clock alarm.
   213 // Create alarm notification string for Clock alarm.
   330 // "[Clock alarm:][\n][time][\n][Description]"
   214 // "[Clock alarm:][\n][time][\n][Description]"
   331 // -----------------------------------------------------------------------------
   215 // -----------------------------------------------------------------------------
   332 //
   216 //
   501 
   385 
   502     CleanupStack::Pop( aText );
   386     CleanupStack::Pop( aText );
   503     TRACE_EXIT_POINT;
   387     TRACE_EXIT_POINT;
   504 }
   388 }
   505 
   389 
   506 */
   390 
   507 
   391 
   508 // =============================================================================
   392 // =============================================================================
   509 // STRING UTILITY FUNCTIONS
   393 // STRING UTILITY FUNCTIONS
   510 // =============================================================================
   394 // =============================================================================
   511 
   395 
   529         aDest.Append( *iLocation );
   413         aDest.Append( *iLocation );
   530     }
   414     }
   531     TRACE_EXIT_POINT;
   415     TRACE_EXIT_POINT;
   532 }
   416 }
   533 
   417 
   534 /*
       
   535 // -----------------------------------------------------------------------------
   418 // -----------------------------------------------------------------------------
   536 // Create strings needed for calendar alarms.
   419 // Create strings needed for calendar alarms.
   537 // AVKON global note can't (currently) show more than 256 characters.  So no 
   420 // AVKON global note can't (currently) show more than 256 characters.  So no 
   538 // need to use more than KAlarmNoteTextLength -KDateTimeDescLen for subject 
   421 // need to use more than KAlarmNoteTextLength -KDateTimeDescLen for subject 
   539 // and location strings.
   422 // and location strings.
   631 
   514 
   632     CleanupStack::PopAndDestroy( timeFormat );
   515     CleanupStack::PopAndDestroy( timeFormat );
   633     CleanupStack::PopAndDestroy( dateFormat );
   516     CleanupStack::PopAndDestroy( dateFormat );
   634     TRACE_EXIT_POINT;
   517     TRACE_EXIT_POINT;
   635 }
   518 }
   636 */
   519 
   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 }
       
   673 
   520 
   674 // End of File
   521 // End of File