meetingrequest/mrcommon/src/esmrentryhelper.cpp
branchRCL_3
changeset 16 4ce476e64c59
parent 0 8466d47a6819
child 24 b5fbb9b25d57
equal deleted inserted replaced
13:0396474f30f5 16:4ce476e64c59
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include "emailtrace.h"
    21 #include "emailtrace.h"
    22 #include "esmrentryhelper.h"
    22 #include "esmrentryhelper.h"
    23 #include "esmrhelper.h"
    23 #include "esmrhelper.h"
       
    24 #include "esmrdef.h"
    24 
    25 
    25 // From System
    26 // From System
    26 #include <calentry.h>
    27 #include <calentry.h>
    27 #include <caltime.h>
    28 #include <caltime.h>
    28 #include <calrrule.h>
    29 #include <calrrule.h>
    29 #include <caluser.h>
    30 #include <caluser.h>
    30 #include <msvids.h>
    31 #include <msvids.h>
    31 #include <MsgMailUIDs.h>
    32 #include <msgmailuids.h>
    32 #include <cmrmailboxutils.h>
    33 #include <cmrmailboxutils.h>
    33 
    34 #include <caleninterimutils2.h>
       
    35 
       
    36 // unnamed naespace for local definitions
       
    37 namespace { // codescanner::namespace
       
    38 
       
    39 // Definition for zero interval
       
    40 const TInt KZeroInterval( 0 );
       
    41 
       
    42 }
    34 
    43 
    35 // ======== MEMBER FUNCTIONS ========
    44 // ======== MEMBER FUNCTIONS ========
    36 
    45 
    37 // ----------------------------------------------------------------------------
    46 // ----------------------------------------------------------------------------
    38 // ESMREntryHelper::SendingMailBoxL
    47 // ESMREntryHelper::SendingMailBoxL
   152         }
   161         }
   153     return retVal;
   162     return retVal;
   154     }
   163     }
   155 
   164 
   156 // ----------------------------------------------------------------------------
   165 // ----------------------------------------------------------------------------
       
   166 // ESMREntryHelper::IsAllDayEventL
       
   167 // ----------------------------------------------------------------------------
       
   168 //
       
   169 EXPORT_C TBool ESMREntryHelper::IsAllDayEventL( const CCalEntry& aEntry )
       
   170     {
       
   171     FUNC_LOG;
       
   172     TBool retVal( EFalse );
       
   173    
       
   174     TDateTime start = aEntry.StartTimeL().TimeLocalL().DateTime();
       
   175     TDateTime end = aEntry.EndTimeL().TimeLocalL().DateTime();
       
   176 
       
   177     // All-day events: 
       
   178     // From one days 00:00:00 to at least next days 00:00:00.
       
   179     // Start times hour, minute and second need to be the same.
       
   180     // Start and end time days need to be different
       
   181     if( start.Hour() == end.Hour() && 
       
   182             start.Minute() == end.Minute() &&
       
   183                 start.Second() == end.Second() && 
       
   184                     start.Day() != end.Day() )
       
   185         {
       
   186         if( start.Hour() == 0 && 
       
   187                 start.Minute() == 0 &&
       
   188                     start.Second() == 0 )
       
   189             {
       
   190             retVal = ETrue;
       
   191             }
       
   192         }
       
   193 
       
   194     return retVal;
       
   195     }
       
   196 
       
   197 // ----------------------------------------------------------------------------
   157 // ESMREntryHelper::OccursInPastL
   198 // ESMREntryHelper::OccursInPastL
   158 // ----------------------------------------------------------------------------
   199 // ----------------------------------------------------------------------------
   159 //
   200 //
   160 EXPORT_C TBool ESMREntryHelper::OccursInPastL( const CCalEntry& aEntry )
   201 EXPORT_C TBool ESMREntryHelper::OccursInPastL( const CCalEntry& aEntry )
   161     {
   202     {
   249         retVal = ETrue;
   290         retVal = ETrue;
   250         }
   291         }
   251     return retVal;
   292     return retVal;
   252     }
   293     }
   253 
   294 
       
   295 // ----------------------------------------------------------------------------
       
   296 // ESMREntryHelper::EventTypeL
       
   297 // ----------------------------------------------------------------------------
       
   298 //
       
   299 EXPORT_C TESMRCalendarEventType ESMREntryHelper::EventTypeL(
       
   300             const CCalEntry& aCalEntry )
       
   301     {
       
   302     FUNC_LOG;
       
   303     
       
   304     TESMRCalendarEventType type( EESMREventTypeNone );
       
   305     
       
   306     switch ( aCalEntry.EntryTypeL() )
       
   307         {
       
   308         case CCalEntry::EAppt:
       
   309             if ( CCalenInterimUtils2::IsMeetingRequestL( 
       
   310                     const_cast< CCalEntry& >( aCalEntry ) ) )
       
   311                 {
       
   312                 type = EESMREventTypeMeetingRequest;
       
   313                 }
       
   314             else
       
   315                 {
       
   316                 type = EESMREventTypeAppt;
       
   317                 }
       
   318             break;
       
   319             
       
   320         case CCalEntry::ETodo:
       
   321             type = EESMREventTypeETodo;
       
   322             break;
       
   323             
       
   324         case CCalEntry::EEvent:
       
   325             type = EESMREventTypeEEvent;
       
   326             break;
       
   327             
       
   328         case CCalEntry::EReminder:
       
   329             type = EESMREventTypeEReminder;
       
   330             break;
       
   331             
       
   332         case CCalEntry::EAnniv:
       
   333             type = EESMREventTypeEAnniv;
       
   334             break;
       
   335             
       
   336         }
       
   337 
       
   338     return type;
       
   339     }
       
   340 
       
   341 // ----------------------------------------------------------------------------
       
   342 // ESMREntryHelper::SetInstanceStartAndEndL
       
   343 // ----------------------------------------------------------------------------
       
   344 //
       
   345 EXPORT_C void ESMREntryHelper::SetInstanceStartAndEndL(
       
   346         CCalEntry& aChild,
       
   347         const CCalEntry& aParent,
       
   348         const TCalTime& aChildStart )
       
   349     {
       
   350     TTime parentStart( aParent.StartTimeL().TimeUtcL() );
       
   351     TTime parentEnd( aParent.EndTimeL().TimeUtcL() );
       
   352     const TTime KNullTime( Time::NullTTime() );
       
   353 
       
   354     if ( KNullTime == parentStart ||
       
   355          KNullTime == parentEnd ||
       
   356          KNullTime == aChildStart.TimeUtcL() )
       
   357         {
       
   358         // Invalid time --> Leaving
       
   359         User::Leave( KErrArgument );
       
   360         }
       
   361 
       
   362     TTimeIntervalMicroSeconds duration( KZeroInterval );
       
   363     duration = parentEnd.MicroSecondsFrom( parentStart );
       
   364     TCalTime childStart;
       
   365     TCalTime childEnd;
       
   366     
       
   367     // Meeting time mode is Fixed Utc
       
   368     if( aChild.EntryTypeL() == CCalEntry::EAppt )
       
   369         {
       
   370         const TTime startTime = aChildStart.TimeUtcL();
       
   371         childStart.SetTimeUtcL( startTime );
       
   372         childEnd.SetTimeUtcL( startTime + duration );   
       
   373         }
       
   374     
       
   375     // Anniversary time mode is local floating
       
   376     if( aChild.EntryTypeL() == CCalEntry::EAnniv )
       
   377         {
       
   378         const TTime startTime = aChildStart.TimeLocalL();
       
   379         childStart.SetTimeLocalFloatingL( startTime );
       
   380         childEnd.SetTimeLocalFloatingL( startTime + duration );  
       
   381         }
       
   382 
       
   383     aChild.SetStartAndEndTimeL( childStart, childEnd );
       
   384     }
       
   385 
       
   386 // ----------------------------------------------------------------------------
       
   387 // ESMREntryHelper::CheckRepeatUntilValidityL
       
   388 // ----------------------------------------------------------------------------
       
   389 //
       
   390 EXPORT_C void ESMREntryHelper::CheckRepeatUntilValidityL(
       
   391         CCalEntry& aEntry,
       
   392         const TCalTime& aInstanceTime )
       
   393     {    
       
   394     if ( ESMREntryHelper::IsRepeatingMeetingL(aEntry) &&
       
   395          !ESMREntryHelper::IsModifyingEntryL(aEntry) )
       
   396         {
       
   397         TCalRRule originalRRule;
       
   398         if ( aEntry.GetRRuleL( originalRRule ) )
       
   399             {
       
   400             TCalTime endTime = aEntry.EndTimeL();
       
   401             TCalTime startTime = aEntry.StartTimeL();
       
   402 
       
   403             TTimeIntervalMicroSeconds duration =
       
   404                 endTime.TimeLocalL().MicroSecondsFrom(
       
   405                         startTime.TimeLocalL() );
       
   406 
       
   407             TTime instanceEndTime( aInstanceTime.TimeLocalL() );
       
   408             instanceEndTime += duration;
       
   409             TCalTime repeatUntilTime = originalRRule.Until();
       
   410             
       
   411             TDateTime repeat = repeatUntilTime.TimeLocalL().DateTime();
       
   412             TDateTime instanceEndDatetime = instanceEndTime.DateTime();
       
   413 
       
   414             if ( repeatUntilTime.TimeLocalL() < instanceEndTime )
       
   415                 {
       
   416                 // reset the recurrence so, that the repeat until
       
   417                 // time is included in repeat range. This is done,
       
   418                 // because when setting the instance start and end
       
   419                 // time, the CCalEntry implementation clears the
       
   420                 // recurrence information if the end time is
       
   421                 // after repeat until end time.
       
   422                 // CCalEntry forces the repeat until time to be
       
   423                 // same than last entry's start time when storing the
       
   424                 // entry to db. Reason uknown.
       
   425                 TCalRRule rRule = originalRRule;
       
   426 
       
   427                 TCalTime newUntil;
       
   428                 newUntil.SetTimeLocalL( instanceEndTime );
       
   429                 rRule.SetUntil( newUntil );
       
   430                 
       
   431                 aEntry.SetRRuleL( rRule );
       
   432                 }
       
   433             }
       
   434         }
       
   435     }
       
   436 
   254 //  End of File
   437 //  End of File
   255 
   438