homesync/contentmanager/cmserver/cmscheduler/inc/cmscheduler.h
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     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:  Main class in the CM Scheduler component
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef _CMSCHEDULER_H
       
    20 #define _CMSCHEDULER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <rconnmon.h>
       
    24 #include "cmserver.h"
       
    25 #include "cmsettings.h"
       
    26 
       
    27 /* Forward declarations. */
       
    28 class CCmCommsDbNotifier;
       
    29 class CCmCenrepNotifier;
       
    30 class CCmSettingsEngine;
       
    31 class MCmSettings;
       
    32 
       
    33 /**
       
    34  *  CCmScheduler class
       
    35  *  Part of CM Scheduler
       
    36  *  @lib cmscheduler.lib
       
    37  *  @since S60 v5.1
       
    38  */
       
    39 class CCmScheduler : public CActive,
       
    40                      public MConnectionMonitorObserver
       
    41     {
       
    42     private: // Enumerations
       
    43 
       
    44     // Scheduler states
       
    45     enum TCmSchedulerState
       
    46         {
       
    47         ECmScStateOffline = 0,  // Don't start processing
       
    48         ECmScStateOnline        // Start processing
       
    49         };
       
    50 
       
    51     public:  // Constructors and destructor
       
    52 
       
    53         /**
       
    54          * Two-phased constructor.
       
    55          */
       
    56         IMPORT_C static CCmScheduler* NewL( MCmServiceObserver& aServer,
       
    57                                    MCmSettings& aSettings );
       
    58 
       
    59         /**
       
    60          * Destructor.
       
    61          */
       
    62         virtual ~CCmScheduler();
       
    63 
       
    64         /**
       
    65          * Enabled connection monitor events
       
    66          *
       
    67          * @since S60 5.1
       
    68          * @param aEnable, ETrue if enabled, EFalse otherwise
       
    69          */
       
    70         void SetEnabledL( TBool aEnable );
       
    71 
       
    72         /**
       
    73          * Called when service is executed
       
    74          *
       
    75          * @since S60 5.1
       
    76          * @param aService, executed service
       
    77          * @param aErr, error code
       
    78          */
       
    79         IMPORT_C void ServiceExecuted( TCmService aService, TInt aErr );
       
    80 
       
    81         /**
       
    82          * Sets service where execution starts
       
    83          *
       
    84          * @since S60 5.1
       
    85          * @param aService, service to be executed
       
    86          */
       
    87         IMPORT_C void SetServiceToExecute( TCmService aService );
       
    88 
       
    89         /**
       
    90          * Called by commsdb notifier when wlan scan state is changed
       
    91          *
       
    92          * @since S60 5.1
       
    93          * @param aState, Scan interval
       
    94          */
       
    95         void WlanScanStateChanged( TInt aState );
       
    96 
       
    97         /**
       
    98          * Called by cenrep notifier when profile has been changed
       
    99          *
       
   100          * @since S60 5.1
       
   101          * @param aProfile, current profile
       
   102          */
       
   103         void ProfileChangedL( TInt aProfile );
       
   104 
       
   105         /**
       
   106          * Sets scheduled service state
       
   107          *
       
   108          * @since S60 5.1
       
   109          * @param TBool, ETrue = running
       
   110          *               EFalse = not running
       
   111          */
       
   112         IMPORT_C void SetScheduledServiceState( TBool aState );
       
   113 
       
   114 
       
   115     protected:
       
   116 
       
   117     // From base class MConnectionMonitorObserver
       
   118 
       
   119         /**
       
   120          * From MConnectionMonitorObserver
       
   121          * see base class definition
       
   122          */
       
   123         void EventL( const CConnMonEventBase &aConnMonEvent );
       
   124 
       
   125      // From base class CActive
       
   126 
       
   127         /**
       
   128          * From CActive
       
   129          * see base class definition
       
   130          */
       
   131         void RunL();
       
   132 
       
   133         /**
       
   134          * From CActive
       
   135          * see base class definition
       
   136          */
       
   137         void DoCancel();
       
   138 
       
   139         /**
       
   140          * From CActive
       
   141          * see base class definition
       
   142          */
       
   143         TInt RunError( TInt aError );
       
   144 
       
   145     private:
       
   146 
       
   147         /**
       
   148          * Tries to execute service
       
   149          *
       
   150          * @since S60 5.1
       
   151          * @param aService, service to be executed
       
   152          */
       
   153         void TryToExecuteService( TCmService aService );
       
   154 
       
   155         /**
       
   156          * Tries to start timer
       
   157          *
       
   158          * @since S60 5.1
       
   159          */
       
   160         void TryToStartRetryTimer();
       
   161 
       
   162         /**
       
   163          * Cancels timer
       
   164          *
       
   165          * @since S60 5.1
       
   166          */
       
   167         void CancelTimer();
       
   168 
       
   169         /**
       
   170          * Handles connection event
       
   171          *
       
   172          * @since S60 5.1
       
   173          * @param aConnMonEvent The event information.
       
   174          */
       
   175         void HandleConnectionEventL(
       
   176                     const CConnMonEventBase& aConnMonEvent );
       
   177 
       
   178         /**
       
   179          * Checks if client application is running
       
   180          *
       
   181          * @since S60 5.1
       
   182          * @return TBool, ETrue if running, EFalse otherwise
       
   183          */
       
   184         TBool ApplicationRunning();
       
   185 
       
   186         /**
       
   187          * Checks if iap is available
       
   188          *
       
   189          * @since S60 5.1
       
   190          * @param aConnMonEvent The event information.
       
   191          * @return TBool, ETrue if iap is available, EFalse otherwise
       
   192          */
       
   193         TBool CheckIapAvailabilityL(
       
   194                         const CConnMonEventBase& aConnMonEvent );
       
   195 
       
   196 	private:
       
   197 
       
   198         /**
       
   199          * C++ default constructor.
       
   200          */
       
   201         CCmScheduler( MCmServiceObserver& aServer,
       
   202                       MCmSettings& aSettings );
       
   203 
       
   204         /**
       
   205          * By default Symbian 2nd phase constructor is private.
       
   206          */
       
   207         void ConstructL();
       
   208 
       
   209     private:
       
   210 
       
   211         /**
       
   212          * Service observer
       
   213          */
       
   214         MCmServiceObserver&                     iServer;
       
   215 		
       
   216         /**
       
   217          * Settings handler
       
   218          */
       
   219         MCmSettings&                            iSettings;
       
   220 		
       
   221         /**
       
   222          * Service state
       
   223          */
       
   224         TBool                                   iScheduledServiceRunning;
       
   225 		
       
   226         /**
       
   227          * Connection monitor state
       
   228          */
       
   229         TBool                                   iEnabled;
       
   230 		
       
   231         /**
       
   232          * Scheduler state
       
   233          */
       
   234         TCmSchedulerState                       iState;
       
   235 		
       
   236         /**
       
   237          * Timer counter
       
   238          */
       
   239         TInt                                    iTimerCount;
       
   240 		
       
   241         /**
       
   242          * Service to be executed
       
   243          */
       
   244         TCmService                              iServiceToExecute;
       
   245 		
       
   246         /**
       
   247          * Harvest execution flag
       
   248          */
       
   249         TBool                                   iExecuteHarvest;
       
   250 		
       
   251         /**
       
   252          * Scheduler started operation
       
   253          */
       
   254         TBool                                   iSchedulerInitiated;
       
   255 		
       
   256         /**
       
   257          * Connection monitor
       
   258          */
       
   259         RConnectionMonitor                      iConnMon;
       
   260 		
       
   261         /**
       
   262          * Timer for service execution
       
   263          */
       
   264         RTimer                                  iTimer;
       
   265 		
       
   266         /**
       
   267          * Comms database notifier
       
   268          */
       
   269         CCmCommsDbNotifier*                     iNotifier;           // owned
       
   270 		
       
   271         /**
       
   272          * Cenral repository notifier
       
   273          */
       
   274         CCmCenrepNotifier*                      iRepositoryNotifier; // owned
       
   275 		
       
   276         /**
       
   277          * Current profile
       
   278          */
       
   279         TInt                                    iCurrentProfile;
       
   280 		
       
   281         /**
       
   282          * Wlan scan state
       
   283          */
       
   284         TInt                                    iWlanScanState;
       
   285 		
       
   286         /**
       
   287          * Store preprocessing flag
       
   288          */
       
   289         TBool                                   iStorePreprocessed;
       
   290 		
       
   291         /**
       
   292          * Last sync time
       
   293          */
       
   294         TTime                                   iLastSyncTime;
       
   295     };
       
   296 
       
   297 
       
   298 #endif //  _CMSCHEDULER_H