alarmui/src/AlmAlarmInfo.cpp
changeset 18 c198609911f9
parent 0 f979ecb2b13e
child 23 fd30d51f876b
equal deleted inserted replaced
0:f979ecb2b13e 18:c198609911f9
    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->iIsClockAlarm = ETrue;
       
   226             }
       
   227         break;
       
   228 
       
   229         case CAlarmUtils::EAlarmTypeOther:
       
   230             {
       
   231             // TODO: Handle this case 
       
   232             SetupUnknownAlarmL( aAlarm );
       
   233             iAlarmInfo->iIsClockAlarm = ETrue;
       
   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->iIsClockAlarm = EFalse;
       
   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                     }
       
   282                 break;
       
   283 
       
   284                 case CCalEntry::ETodo:
       
   285                     {
       
   286                     // TODO : Format text based on type of entry
       
   287                     // SetupToDoAlarmL( aAlarm );
       
   288                     iAlarmInfo->iTime = TTime( 0 );
       
   289                     }
       
   290                 break;
       
   291 
       
   292                 default:
       
   293                     {
       
   294                     // TODO : Format text based on type of entry
       
   295                     // SetupAnniversaryAlarmL( aAlarm );
       
   296                     iAlarmInfo->iTime = TTime( 0 );
       
   297                     }
       
   298                 break;
       
   299                 }
       
   300             CleanupStack::PopAndDestroy( entry );
       
   301             }
       
   302         break;
       
   303 
       
   304         default:
       
   305             __ASSERT_DEBUG( EFalse, User::Invariant() );
       
   306     }
       
   307     return iAlarmInfo;
   206 }
   308 }
   207 
   309 
   208 // =============================================================================
   310 // =============================================================================
   209 // ALARM SETUP METHODS
   311 // ALARM SETUP METHODS
   210 // =============================================================================
   312 // =============================================================================
   211 
   313 
       
   314 /*
   212 // -----------------------------------------------------------------------------
   315 // -----------------------------------------------------------------------------
   213 // Create alarm notification string for Clock alarm.
   316 // Create alarm notification string for Clock alarm.
   214 // "[Clock alarm:][\n][time][\n][Description]"
   317 // "[Clock alarm:][\n][time][\n][Description]"
   215 // -----------------------------------------------------------------------------
   318 // -----------------------------------------------------------------------------
   216 //
   319 //
   385 
   488 
   386     CleanupStack::Pop( aText );
   489     CleanupStack::Pop( aText );
   387     TRACE_EXIT_POINT;
   490     TRACE_EXIT_POINT;
   388 }
   491 }
   389 
   492 
   390 
   493 */
   391 
   494 
   392 // =============================================================================
   495 // =============================================================================
   393 // STRING UTILITY FUNCTIONS
   496 // STRING UTILITY FUNCTIONS
   394 // =============================================================================
   497 // =============================================================================
   395 
   498 
   413         aDest.Append( *iLocation );
   516         aDest.Append( *iLocation );
   414     }
   517     }
   415     TRACE_EXIT_POINT;
   518     TRACE_EXIT_POINT;
   416 }
   519 }
   417 
   520 
       
   521 /*
   418 // -----------------------------------------------------------------------------
   522 // -----------------------------------------------------------------------------
   419 // Create strings needed for calendar alarms.
   523 // Create strings needed for calendar alarms.
   420 // AVKON global note can't (currently) show more than 256 characters.  So no 
   524 // AVKON global note can't (currently) show more than 256 characters.  So no 
   421 // need to use more than KAlarmNoteTextLength -KDateTimeDescLen for subject 
   525 // need to use more than KAlarmNoteTextLength -KDateTimeDescLen for subject 
   422 // and location strings.
   526 // and location strings.
   514 
   618 
   515     CleanupStack::PopAndDestroy( timeFormat );
   619     CleanupStack::PopAndDestroy( timeFormat );
   516     CleanupStack::PopAndDestroy( dateFormat );
   620     CleanupStack::PopAndDestroy( dateFormat );
   517     TRACE_EXIT_POINT;
   621     TRACE_EXIT_POINT;
   518 }
   622 }
   519 
   623 */
       
   624 
       
   625 void CAlmAlarmInfo::SetupUnknownAlarmL(TASShdAlarm /* aAlarm */)
       
   626 {
       
   627     
       
   628 }
       
   629 
       
   630 void CAlmAlarmInfo::SetupClockAlarmL(TASShdAlarm aAlarm)
       
   631 {
       
   632     // The alarm subject
       
   633     iAlarmInfo->iSubject = aAlarm.Message().AllocL();
       
   634     iAlarmInfo->iSubject->Des().TrimAll();
       
   635 
       
   636     // Location must not be displayed for clock alarms
       
   637     iAlarmInfo->iLocation = HBufC::NewL( 0 );
       
   638 
       
   639     // The alarm time
       
   640     iAlarmInfo->iTime = aAlarm.NextDueTime();
       
   641 
       
   642     // Date must not be shown for clock alarms
       
   643     iAlarmInfo->iDate = TTime( 0 );
       
   644 }
       
   645 
       
   646 void CAlmAlarmInfo::SetupAppointmentAlarmL(TASShdAlarm /* aAlarm */)
       
   647 {
       
   648 
       
   649 }
       
   650 
       
   651 void CAlmAlarmInfo::SetupToDoAlarmL(TASShdAlarm /* aAlarm */)
       
   652 {
       
   653     
       
   654 }
       
   655 
       
   656 void CAlmAlarmInfo::SetupAnniversaryAlarmL(TASShdAlarm /* aAlarm */)
       
   657 {
       
   658     
       
   659 }
   520 
   660 
   521 // End of File
   661 // End of File