ipsservices/ipssosaoplugin/inc/IpsSosAOSchedulerUtils.h
changeset 23 2dc6caa42ec3
parent 18 578830873419
equal deleted inserted replaced
20:ecc8def7944a 23:2dc6caa42ec3
    15 *     Functions to calculate timer intervals
    15 *     Functions to calculate timer intervals
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 #ifndef IPSSOSAOSCHEDULERUTILS_H_
    20 #ifndef IPSSOSAOSCHEDULERUTILS_H
    21 #define IPSSOSAOSCHEDULERUTILS_H_
    21 #define IPSSOSAOSCHEDULERUTILS_H
    22 
    22 
    23 #include <e32base.h>
    23 #include <e32base.h>
    24 //<Qmail>
    24 //<Qmail>
    25 
    25 
    26 //</Qmail>
    26 //</Qmail>
    36     EAOVCDConnectionAnyDay,
    36     EAOVCDConnectionAnyDay,
    37     EAOVCDConnectionCurrentDay,
    37     EAOVCDConnectionCurrentDay,
    38     EAOVCDConnectionPreviousDayOnly
    38     EAOVCDConnectionPreviousDayOnly
    39     };
    39     };
    40 
    40 
       
    41 //<Qmail>
       
    42 class CIpsSosAOSettingsHandler;
       
    43 //</Qmail>
    41 /**
    44 /**
    42 *  Class CIpsSosAOSchedulerUtils 
    45 *  Class CIpsSosAOSchedulerUtils 
    43 *  
    46 *  
    44 *  calculates time to next interval according to 
    47 *  calculates time to next interval according to 
    45 *  mailbox's always online settings
    48 *  mailbox's always online settings
    46 * 
    49 * 
    47 *  NOTE: this class is taken from S60 Email client,
       
    48 *  Some parts of this class may not be used in FSEmail
       
    49 *    
       
    50 *  @since FSEmail 2.0
    50 *  @since FSEmail 2.0
    51 */
    51 */
       
    52 //<Qmail>
    52 NONSHARABLE_CLASS (CIpsSosAOSchedulerUtils) : public CBase
    53 NONSHARABLE_CLASS (CIpsSosAOSchedulerUtils) : public CBase
       
    54 //</Qmail>
    53     {
    55     {
    54 public:  // Constructors and destructor
    56 public:  // Constructors and destructor
    55 
    57 
    56     /**
    58     /**
    57     * NewLC
    59     * NewLC
    58     * @return, Constructed object
    60     * @return, Constructed object
    59     */
    61     */
    60     //<Qmail>
    62     //<Qmail>
    61     static CIpsSosAOSchedulerUtils* NewLC();
    63     static CIpsSosAOSchedulerUtils* NewLC(CIpsSosAOSettingsHandler& aSettings);
    62     //</Qmail>
    64     //</Qmail>
    63     /**
    65     /**
    64     * NewL
    66     * NewL
    65     * @return, Constructed object
    67     * @return, Constructed object
    66     */
    68     */
    67     //<Qmail>
    69     //<Qmail>
    68     static CIpsSosAOSchedulerUtils* NewL();
    70     static CIpsSosAOSchedulerUtils* NewL(CIpsSosAOSettingsHandler& aSettings);
    69     //</Qmail>
    71     //</Qmail>
    70     /**
    72     /**
    71     * Destructor
    73     * Destructor
    72     */
    74     */
    73     virtual ~CIpsSosAOSchedulerUtils();
    75     virtual ~CIpsSosAOSchedulerUtils();
    91 
    93 
    92     /**
    94     /**
    93     * Constructor
    95     * Constructor
    94     */
    96     */
    95     //<Qmail>
    97     //<Qmail>
    96     CIpsSosAOSchedulerUtils();
    98     CIpsSosAOSchedulerUtils(CIpsSosAOSettingsHandler& aSettings);
    97     //</Qmail>
    99     //</Qmail>
    98     /**
   100     /**
    99     * Symbian 2-phase constructor
   101     * Symbian 2-phase constructor
   100     */
   102     */
   101     void ConstructL();
   103     void ConstructL();
   102 
   104 	//<Qmail>
   103     /**
   105     /**
   104     *
   106     * gets time values needed to do cheduling
   105     */
   107     */
   106     void PrepareScheduling(
   108     void PrepareScheduling(
   107         TTime& aClock,
   109         TTime& aClock,
   108         TTimeIntervalSeconds& aHome,
   110         TTimeIntervalSeconds& aHome,
   109         TTimeIntervalSeconds& aStart,
   111         TTimeIntervalSeconds& aStart,
   110         TTimeIntervalSeconds& aStop );
   112         TTimeIntervalSeconds& aStop );
   111 
   113 
   112     /**
   114     /**
   113     *
   115     * Checks if now is an allowed time to connect
   114     */
   116     */
   115     TBool CanConnect(
   117     TBool CanConnect(
   116         const TTime& aClock,
   118         const TTime& aClock,
   117         TTimeIntervalSeconds& aHome,
   119         TTimeIntervalSeconds& aHome,
   118         TTimeIntervalSeconds& aStart,
   120         TTimeIntervalSeconds& aStart,
   119         TTimeIntervalSeconds& aStop );
   121         TTimeIntervalSeconds& aStop );
   120                         
   122                         
   121     /**
   123     /**
   122     *
   124     * performs connection checks based on day
   123     */
   125     */
   124     TIpsSosAOValidConnectionDay GetValidConnectionDay( 
   126     TIpsSosAOValidConnectionDay GetValidConnectionDay( 
   125         const TTime& aClock );
   127         const TTime& aClock );
   126         
   128         
   127     /**
   129     /**
   128     *
   130     * Gets next day
   129     */
   131     */
   130     TDay GetNextDay( 
   132     TDay GetNextDay( 
   131         const TDay aToday, 
   133         const TDay aToday, 
   132         const TInt aNth = 1 );
   134         const TInt aNth = 1 );
   133               
   135               
   134     /**
   136     /**
   135     *
   137     * Gets previous day
   136     */
   138     */
   137     TDay GetPrevDay( 
   139     TDay GetPrevDay( 
   138         const TDay aToday, 
   140         const TDay aToday, 
   139         const TInt aNth = 1 );
   141         const TInt aNth = 1 );
   140         
   142         
   141     /**
   143     /**
   142     *
   144     * Checks if given time in sync window
   143     */
   145     */
   144     TBool IsValidTimeToConnect( 
   146     TBool IsValidTimeToConnect( 
   145         const TIpsSosAOValidConnectionDay aValidDay,
   147         const TIpsSosAOValidConnectionDay aValidDay,
   146         TTimeIntervalSeconds& aHome,
   148         TTimeIntervalSeconds& aHome,
   147         TTimeIntervalSeconds& aStart,
   149         TTimeIntervalSeconds& aStart,
   148         TTimeIntervalSeconds& aStop );
   150         TTimeIntervalSeconds& aStop );
   149 
   151 
   150     /**
   152     /**
   151     *
   153     * Creates hometime with hours, minutes and seconds only
   152     */
   154     */
   153     TDateTime AdjustHomeTime( 
   155     TDateTime AdjustHomeTime( 
   154         const TTime& aClock );
   156         const TTime& aClock );
   155             
   157             
   156     /**
   158     /**
   157     *
   159     * Converts time to seconds
   158     */
   160     */
   159     void Times2Seconds(
   161     void Times2Seconds(
   160         const TTime& aClock,
   162         const TTime& aClock,
   161         TTimeIntervalSeconds& aHome,
   163         TTimeIntervalSeconds& aHome,
   162         TTimeIntervalSeconds& aStart,
   164         TTimeIntervalSeconds& aStart,
   163         TTimeIntervalSeconds& aStop );
   165         TTimeIntervalSeconds& aStop );
   164                 
   166                 
   165     /**
   167     /**
   166     *
   168     * Creates valid start and stop times
   167     */
   169     */
   168     void OrganizeStartAndStopTimes(
   170     void OrganizeStartAndStopTimes(
   169         TTimeIntervalSeconds& aHome,
   171         TTimeIntervalSeconds& aHome,
   170         TTimeIntervalSeconds& aStart,
   172         TTimeIntervalSeconds& aStart,
   171         TTimeIntervalSeconds& aStop );
   173         TTimeIntervalSeconds& aStop );
   172                     
   174                     
   173     /**
   175     /**
   174     *
   176     * How many seconds to next connection/disconnection
   175     */
   177     */
   176     void CalculateSecondsToNextMark(
   178     void CalculateSecondsToNextMark(
   177         const TIpsSosAOConnectionType aConnectionStatus,
   179         const TIpsSosAOConnectionType aConnectionStatus,
   178         TTimeIntervalSeconds& aSeconds,
   180         TTimeIntervalSeconds& aSeconds,
   179         const TTime& aClock,
   181         const TTime& aClock,
   180         const TTimeIntervalSeconds& aHome,
   182         const TTimeIntervalSeconds& aHome,
   181         const TTimeIntervalSeconds& aStart,
   183         const TTimeIntervalSeconds& aStart,
   182         const TTimeIntervalSeconds& aStop );
   184         const TTimeIntervalSeconds& aStop );
   183 
   185 
   184     /**
   186     /**
   185     *
   187     * How many seconds to next day we are allowed to connect
   186     */
   188     */
   187     TTimeIntervalSeconds CalcSecsToNextScheduledDay(
   189     TTimeIntervalSeconds CalcSecsToNextScheduledDay(
   188         const TTime& aClock, 
   190         const TTime& aClock, 
   189         const TTimeIntervalSeconds& aHome,
   191         const TTimeIntervalSeconds& aHome,
   190         const TBool aScheduledDay );
   192         const TBool aScheduledDay );
   191 
   193 
   192     /**
   194     /**
   193     *
   195     * Sub routine for CalculateSecondsToNextMark
   194     */
   196     */
   195     void CalcSecsToMark(
   197     void CalcSecsToMark(
   196         TTimeIntervalSeconds& aSeconds,
   198         TTimeIntervalSeconds& aSeconds,
   197         const TTime& aClock,
   199         const TTime& aClock,
   198         const TTimeIntervalSeconds& aHome,
   200         const TTimeIntervalSeconds& aHome,
   199         const TTimeIntervalSeconds& aBonus,
   201         const TTimeIntervalSeconds& aBonus,
   200         const TBool aScheduledDay );
   202         const TBool aScheduledDay );
   201 
   203 
   202     /**
   204     /**
   203     *
   205     * Checks is given day selected to be synced
   204     */
   206     */
   205     TBool IsDaySelected( const TUint aDay ) const;
   207     TBool IsDaySelected( const TUint aDay ) const;
   206         
   208     //</Qmail>
   207 private:
   209 private:
   208 
   210 
   209     // Reference to extended settings
       
   210     //<Qmail>
       
   211     
   211     
       
   212     //<Qmail>
       
   213     CIpsSosAOSettingsHandler& iSettings;
   212     //</Qmail>
   214     //</Qmail>
   213     };
   215     };
   214 
   216 
   215 
   217 
   216 #endif /*IPSSOSAOSCHEDULERUTILS_H_*/
   218 #endif /*IPSSOSAOSCHEDULERUTILS_H*/