ipsservices/ipssosaoplugin/src/IpsSosAOSchedulerUtils.cpp
branchRCL_3
changeset 63 d189ee25cf9d
parent 29 6b8f3b30d0ec
child 64 3533d4323edc
equal deleted inserted replaced
61:dcf0eedfc1a3 63:d189ee25cf9d
    14 * Description: 
    14 * Description: 
    15 *     Functions to calculate timer intervals
    15 *     Functions to calculate timer intervals
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 #include "ipssosaopluginheaders.h"
    20 #include "emailtrace.h"
       
    21 #include "IpsSosAOSchedulerUtils.h"
       
    22 #include "ipssetdataextension.h"
       
    23 
       
    24 
       
    25 
    20 
    26 const TInt KAOSecondsIn24Hours = 86400;
    21 const TInt KAOSecondsIn24Hours = 86400;
    27 //const TUint KAOEveryDayMask = 0x7f;
    22 //const TUint KAOEveryDayMask = 0x7f;
    28 const TInt KA0DaysInWeek = 7;
    23 const TInt KA0DaysInWeek = 7;
    29 
    24 
    30 // ----------------------------------------------------------------------------
    25 // ----------------------------------------------------------------------------
    31 // ----------------------------------------------------------------------------
    26 // ----------------------------------------------------------------------------
    32 //
    27 //
    33 CIpsSosAOSchedulerUtils::CIpsSosAOSchedulerUtils(
    28 //<Qmail>
    34         const CIpsSetDataExtension& aExtentedSettings )
    29 CIpsSosAOSchedulerUtils::CIpsSosAOSchedulerUtils( CIpsSosAOSettingsHandler& aSettings ):
    35     : iExtentedSettings( aExtentedSettings )
    30         iSettings(aSettings)
       
    31 //</Qmail>
    36     {
    32     {
    37     FUNC_LOG;
    33     FUNC_LOG;
    38     }
    34     }
    39 
    35 
    40 // ----------------------------------------------------------------------------
    36 // ----------------------------------------------------------------------------
    54     }
    50     }
    55 
    51 
    56 // ----------------------------------------------------------------------------
    52 // ----------------------------------------------------------------------------
    57 // ----------------------------------------------------------------------------
    53 // ----------------------------------------------------------------------------
    58 //
    54 //
    59 CIpsSosAOSchedulerUtils* CIpsSosAOSchedulerUtils::NewL(
    55 //<Qmail>
    60         const CIpsSetDataExtension& aExtentedSettings )
    56 CIpsSosAOSchedulerUtils* CIpsSosAOSchedulerUtils::NewL(CIpsSosAOSettingsHandler& aSettings)
    61     {
    57 //</Qmail>
    62     FUNC_LOG;
    58     {
    63     CIpsSosAOSchedulerUtils* self = NewLC( aExtentedSettings );
    59     FUNC_LOG;
       
    60     //<Qmail>
       
    61     CIpsSosAOSchedulerUtils* self = NewLC(aSettings);
       
    62     //</Qmail>
    64     CleanupStack::Pop( self );
    63     CleanupStack::Pop( self );
    65 
    64 
    66     return self;
    65     return self;
    67     }
    66     }
    68 
    67 
    69 // ----------------------------------------------------------------------------
    68 // ----------------------------------------------------------------------------
    70 // ----------------------------------------------------------------------------
    69 // ----------------------------------------------------------------------------
    71 //
    70 //
    72 CIpsSosAOSchedulerUtils* CIpsSosAOSchedulerUtils::NewLC(
    71 //<Qmail>
    73         const CIpsSetDataExtension& aExtentedSettings )
    72 CIpsSosAOSchedulerUtils* CIpsSosAOSchedulerUtils::NewLC(CIpsSosAOSettingsHandler& aSettings)
       
    73 //</Qmail>
    74     {
    74     {
    75     FUNC_LOG;
    75     FUNC_LOG;
    76     CIpsSosAOSchedulerUtils* self =
    76     CIpsSosAOSchedulerUtils* self =
    77         new ( ELeave ) CIpsSosAOSchedulerUtils( aExtentedSettings );
    77             //<Qmail>
       
    78         new ( ELeave ) CIpsSosAOSchedulerUtils(aSettings);
       
    79     //</Qmail>
    78     CleanupStack::PushL( self );
    80     CleanupStack::PushL( self );
    79     self->ConstructL();
    81     self->ConstructL();
    80 
    82 
    81     return self;
    83     return self;
    82     }
    84     }
   218 
   220 
   219     // Get current and previous day and make sure it is selected
   221     // Get current and previous day and make sure it is selected
   220     TDay currentDay = aClock.DayNoInWeek();
   222     TDay currentDay = aClock.DayNoInWeek();
   221     TDay previousDay = GetPrevDay( currentDay );
   223     TDay previousDay = GetPrevDay( currentDay );
   222     TIpsSosAOValidConnectionDay result;
   224     TIpsSosAOValidConnectionDay result;
   223     
   225         
   224     
       
   225     // Connection can be made anyday
   226     // Connection can be made anyday
   226     if ( IsDaySelected( currentDay ) && IsDaySelected( previousDay ) )
   227     if ( IsDaySelected( currentDay ) && IsDaySelected( previousDay ) )
   227         {
   228         {
   228         
   229         
   229         result = EAOVCDConnectionAnyDay;        
   230         result = EAOVCDConnectionAnyDay;        
   240         {
   241         {
   241         
   242         
   242         result = EAOVCDConnectionPreviousDayOnly;
   243         result = EAOVCDConnectionPreviousDayOnly;
   243         }
   244         }
   244     // no selected days this is wron in settings side but still return anyday
   245     // no selected days this is wron in settings side but still return anyday
   245     else if ( iExtentedSettings.SelectedWeekDays() == 0 )
   246 	//<QMail>
       
   247     else if ( iSettings.SelectedWeekDays() == 0 )
   246         {
   248         {
   247         result = EAOVCDConnectionAnyDay;
   249         result = EAOVCDConnectionAnyDay;
   248         }
   250         }
       
   251 	//</QMail>
   249     // Connection is not allowed
   252     // Connection is not allowed
   250     else
   253     else
   251         {
   254         {
   252         
   255         
   253         result = EAOVCDNoConnection;
   256         result = EAOVCDNoConnection;
   254         } 
   257         } 
   255         
   258     
   256     return result;           
   259     return result;           
   257     }
   260     }
   258 
   261 
   259 // ----------------------------------------------------------------------------)
   262 // ----------------------------------------------------------------------------)
   260 // ----------------------------------------------------------------------------
   263 // ----------------------------------------------------------------------------
   380     {
   383     {
   381     FUNC_LOG;
   384     FUNC_LOG;
   382 
   385 
   383     TTime zeroTime( 0 );
   386     TTime zeroTime( 0 );
   384     TTime adjustedHomeTime = AdjustHomeTime( aClock );
   387     TTime adjustedHomeTime = AdjustHomeTime( aClock );
   385     TTime selectedTimeStart = iExtentedSettings.SelectedTimeStart();
   388 	//<QMail>
   386     TTime selectedTimeStop = iExtentedSettings.SelectedTimeStop();
   389     TTime selectedTimeStart = iSettings.SelectedTimeStart();
       
   390     TTime selectedTimeStop = iSettings.SelectedTimeStop();
       
   391 	//</QMail>
   387     adjustedHomeTime.SecondsFrom( zeroTime, aHome );
   392     adjustedHomeTime.SecondsFrom( zeroTime, aHome );
   388     selectedTimeStart.SecondsFrom( zeroTime, aStart );
   393     selectedTimeStart.SecondsFrom( zeroTime, aStart );
   389     selectedTimeStop.SecondsFrom( zeroTime, aStop );
   394     selectedTimeStop.SecondsFrom( zeroTime, aStop );
   390     
   395     
   391     }
   396     }
   494     
   499     
   495 // ----------------------------------------------------------------------------
   500 // ----------------------------------------------------------------------------
   496 // ----------------------------------------------------------------------------
   501 // ----------------------------------------------------------------------------
   497 //
   502 //
   498 TTimeIntervalSeconds CIpsSosAOSchedulerUtils::CalcSecsToNextScheduledDay(
   503 TTimeIntervalSeconds CIpsSosAOSchedulerUtils::CalcSecsToNextScheduledDay(
       
   504 //<QMail>
   499     const TTime& aClock,
   505     const TTime& aClock,
   500     const TTimeIntervalSeconds& aHome,
   506     const TTimeIntervalSeconds& aHome,
   501     const TBool aScheduledDay )
   507     const TBool aScheduledDay )
   502     {
   508     {
   503     FUNC_LOG;
   509     FUNC_LOG;
   504 
   510 
   505     TTimeIntervalSeconds seconds = 0;
   511     TTimeIntervalSeconds seconds = 0;
   506 
   512 
   507     // First check if all of the days are unchecked, which should not happen
   513     // First check if all of the days are unchecked, which should not happen
   508     // at all, but just in case
   514     // at all, but just in case
   509     if ( !iExtentedSettings.SelectedWeekDays() )
   515     
   510         {
   516     if ( !iSettings.SelectedWeekDays() )
   511         // Temporarly set all the days selected
   517         {
   512         return seconds;
   518         return seconds;
   513        /* __ASSERT_DEBUG( ( 
       
   514                 EFalse ), 
       
   515                 User::Panic( _L("AO"), KErrGeneral) );*/
       
   516         }
   519         }
   517 
   520 
   518     TBool hit = EFalse;
   521     TBool hit = EFalse;
       
   522     
   519     TDay today = aClock.DayNoInWeek();
   523     TDay today = aClock.DayNoInWeek();
   520     TDay dayAfter = GetNextDay( today );
   524     TDay dayAfter = GetNextDay( today );
   521     TInt dayCount = KErrNotFound;
   525     TInt dayCount = KErrNotFound;
   522     
   526     
   523     while ( dayAfter != today && !hit )
   527     while ( dayAfter != today && !hit )
   529 
   533 
   530     
   534     
   531     seconds = KAOSecondsIn24Hours - aHome.Int() +
   535     seconds = KAOSecondsIn24Hours - aHome.Int() +
   532         dayCount * KAOSecondsIn24Hours;
   536         dayCount * KAOSecondsIn24Hours;
   533 
   537 
   534     
   538     //</QMail>
   535     return seconds;       
   539     return seconds;       
   536     }
   540     }
   537 
   541 
   538 // ----------------------------------------------------------------------------
   542 // ----------------------------------------------------------------------------
   539 // ----------------------------------------------------------------------------
   543 // ----------------------------------------------------------------------------
   540 //
   544 //
       
   545 //<QMail>
   541 TBool CIpsSosAOSchedulerUtils::IsDaySelected( const TUint aDay ) const
   546 TBool CIpsSosAOSchedulerUtils::IsDaySelected( const TUint aDay ) const
   542     {
   547     {
   543     FUNC_LOG;
   548     FUNC_LOG;
   544     return ( iExtentedSettings.SelectedWeekDays() >> aDay ) & 0x01;
   549     return ( iSettings.SelectedWeekDays() >> aDay ) & 0x01;
       
   550     //</QMail>
   545     }
   551     }
   546 
   552 
   547 // End of File
   553 // End of File
   548 
   554