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