ipsservices/ipssosaoplugin/inc/IpsSosAOSchedulerUtils.h
changeset 0 8466d47a6819
child 24 d189ee25cf9d
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *     Functions to calculate timer intervals
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef IPSSOSAOSCHEDULERUTILS_H_
       
    21 #define IPSSOSAOSCHEDULERUTILS_H_
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 class CIpsSetDataExtension;
       
    26 
       
    27 enum TIpsSosAOConnectionType
       
    28     {
       
    29     EAOCDisconnectAfter = 0,
       
    30     EAOCConnectAfter
       
    31     };
       
    32         
       
    33 enum TIpsSosAOValidConnectionDay
       
    34     {
       
    35     EAOVCDNoConnection = 0,
       
    36     EAOVCDConnectionAnyDay,
       
    37     EAOVCDConnectionCurrentDay,
       
    38     EAOVCDConnectionPreviousDayOnly
       
    39     };
       
    40 
       
    41 /**
       
    42 *  Class CIpsSosAOSchedulerUtils 
       
    43 *  
       
    44 *  calculates time to next interval according to 
       
    45 *  mailbox's always online settings
       
    46 * 
       
    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
       
    51 */
       
    52 class CIpsSosAOSchedulerUtils : public CBase
       
    53     {
       
    54 public:  // Constructors and destructor
       
    55 
       
    56     /**
       
    57     * NewLC
       
    58     * @return, Constructed object
       
    59     */
       
    60     static CIpsSosAOSchedulerUtils* NewLC(
       
    61         const CIpsSetDataExtension& aExtentedSettings );
       
    62 
       
    63     /**
       
    64     * NewL
       
    65     * @return, Constructed object
       
    66     */
       
    67     static CIpsSosAOSchedulerUtils* NewL(
       
    68         const CIpsSetDataExtension& aExtentedSettings );
       
    69 
       
    70     /**
       
    71     * Destructor
       
    72     */
       
    73     virtual ~CIpsSosAOSchedulerUtils();
       
    74 
       
    75 public: 
       
    76         
       
    77     /**
       
    78     * checks is mailbox allowed to connect from settings
       
    79     * NOTE: not used in FSEmail 2.0
       
    80     */
       
    81     TBool CanConnect();
       
    82         
       
    83     /**
       
    84     * Calculates seconds to next interval time according to
       
    85     * mailbox settings
       
    86     */
       
    87     TIpsSosAOConnectionType SecondsToNextMark( 
       
    88         TTimeIntervalSeconds& aSeconds );
       
    89     
       
    90 private:
       
    91 
       
    92     /**
       
    93     * Constructor
       
    94     */
       
    95     CIpsSosAOSchedulerUtils(
       
    96         const CIpsSetDataExtension& aExtentedSettings );
       
    97 
       
    98     /**
       
    99     * Symbian 2-phase constructor
       
   100     */
       
   101     void ConstructL();
       
   102 
       
   103     /**
       
   104     *
       
   105     */
       
   106     void PrepareScheduling(
       
   107         TTime& aClock,
       
   108         TTimeIntervalSeconds& aHome,
       
   109         TTimeIntervalSeconds& aStart,
       
   110         TTimeIntervalSeconds& aStop );
       
   111 
       
   112     /**
       
   113     *
       
   114     */
       
   115     TBool CanConnect(
       
   116         const TTime& aClock,
       
   117         TTimeIntervalSeconds& aHome,
       
   118         TTimeIntervalSeconds& aStart,
       
   119         TTimeIntervalSeconds& aStop );
       
   120                         
       
   121     /**
       
   122     *
       
   123     */
       
   124     TIpsSosAOValidConnectionDay GetValidConnectionDay( 
       
   125         const TTime& aClock );
       
   126         
       
   127     /**
       
   128     *
       
   129     */
       
   130     TDay GetNextDay( 
       
   131         const TDay aToday, 
       
   132         const TInt aNth = 1 );
       
   133               
       
   134     /**
       
   135     *
       
   136     */
       
   137     TDay GetPrevDay( 
       
   138         const TDay aToday, 
       
   139         const TInt aNth = 1 );
       
   140         
       
   141     /**
       
   142     *
       
   143     */
       
   144     TBool IsValidTimeToConnect( 
       
   145         const TIpsSosAOValidConnectionDay aValidDay,
       
   146         TTimeIntervalSeconds& aHome,
       
   147         TTimeIntervalSeconds& aStart,
       
   148         TTimeIntervalSeconds& aStop );
       
   149 
       
   150     /**
       
   151     *
       
   152     */
       
   153     TDateTime AdjustHomeTime( 
       
   154         const TTime& aClock );
       
   155             
       
   156     /**
       
   157     *
       
   158     */
       
   159     void Times2Seconds(
       
   160         const TTime& aClock,
       
   161         TTimeIntervalSeconds& aHome,
       
   162         TTimeIntervalSeconds& aStart,
       
   163         TTimeIntervalSeconds& aStop );
       
   164                 
       
   165     /**
       
   166     *
       
   167     */
       
   168     void OrganizeStartAndStopTimes(
       
   169         TTimeIntervalSeconds& aHome,
       
   170         TTimeIntervalSeconds& aStart,
       
   171         TTimeIntervalSeconds& aStop );
       
   172                     
       
   173     /**
       
   174     *
       
   175     */
       
   176     void CalculateSecondsToNextMark(
       
   177         const TIpsSosAOConnectionType aConnectionStatus,
       
   178         TTimeIntervalSeconds& aSeconds,
       
   179         const TTime& aClock,
       
   180         const TTimeIntervalSeconds& aHome,
       
   181         const TTimeIntervalSeconds& aStart,
       
   182         const TTimeIntervalSeconds& aStop );
       
   183 
       
   184     /**
       
   185     *
       
   186     */
       
   187     TTimeIntervalSeconds CalcSecsToNextScheduledDay(
       
   188         const TTime& aClock, 
       
   189         const TTimeIntervalSeconds& aHome,
       
   190         const TBool aScheduledDay );
       
   191 
       
   192     /**
       
   193     *
       
   194     */
       
   195     void CalcSecsToMark(
       
   196         TTimeIntervalSeconds& aSeconds,
       
   197         const TTime& aClock,
       
   198         const TTimeIntervalSeconds& aHome,
       
   199         const TTimeIntervalSeconds& aBonus,
       
   200         const TBool aScheduledDay );
       
   201 
       
   202     /**
       
   203     *
       
   204     */
       
   205     TBool IsDaySelected( const TUint aDay ) const;
       
   206         
       
   207 private:
       
   208 
       
   209     // Reference to extended settings
       
   210     const CIpsSetDataExtension&  iExtentedSettings;
       
   211     };
       
   212 
       
   213 
       
   214 #endif /*IPSSOSAOSCHEDULERUTILS_H_*/