videoscheduler/SchedulerServer/inc/CCseSchedulerServerEngine.h
branchRCL_3
changeset 22 826cea16efd9
parent 21 798ee5f1972c
child 23 13a33d82ad98
equal deleted inserted replaced
21:798ee5f1972c 22:826cea16efd9
     1 /*
       
     2 * Copyright (c) 2006 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 the License "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:    Interface for Scheduler Server's Engine class*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __CCSESCHEDULERSERVERENGINE_H
       
    21 #define __CCSESCHEDULERSERVERENGINE_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <ipvideo/MCseScheduleObserver.h>   // Observer so that CCseSchedulerTimer can inform engine.
       
    25 #include "MCsePluginControllerObserver.h"   // Observer so that CCseSchedulerTimer can inform engine.
       
    26 #include "CseSchedulerServer.pan"   // Panic codes
       
    27 
       
    28 
       
    29 // CONSTANTS
       
    30 // Usually we have only one scheduled event at a time so we set granularity to 1, but
       
    31 // in some rare cases we migth have more so we have to use array.
       
    32 const int KCseScheduleGranularity      		= 1;
       
    33 
       
    34 // MACROS
       
    35 // None
       
    36 
       
    37 // DATA TYPES
       
    38 // None
       
    39 
       
    40 // FUNCTION PROTOTYPES
       
    41 // None
       
    42 
       
    43 // FORWARD DECLARATIONS
       
    44 class CCseScheduleDB;
       
    45 class CCseSchedulerTimer;
       
    46 class CCseScheduledProgram;
       
    47 class CCseSchedulerServerSession;
       
    48 class CCseSchedulerServer;
       
    49 class CCseSchedulerPluginControllerBase;
       
    50 
       
    51 
       
    52 // CLASS DECLARATION
       
    53 // None
       
    54 
       
    55 /**
       
    56 * Server's "brain". Controls all subsession messages to current object for 
       
    57 * futher prosessing. Manages message list thru the reguest handler. Reads from 
       
    58 * the client address space and writes back to client address space. Controls 
       
    59 * sub objet request(s).
       
    60 */
       
    61 class CCseSchedulerServerEngine : public CObject,
       
    62 								  public MCsePluginControllerObserver
       
    63     {
       
    64     public: // Constructors and destructor
       
    65 
       
    66         /**
       
    67         * Two-phased constructor.
       
    68         * @param Reference to scheduler server
       
    69         * @return CCseSchedulerEngine pointer to CCseSchedulerEngine class
       
    70         */
       
    71         static CCseSchedulerServerEngine* NewL( CCseSchedulerServer& aServer );
       
    72 
       
    73         /**
       
    74         * Destructor.
       
    75         */
       
    76         virtual ~CCseSchedulerServerEngine();
       
    77         
       
    78     public: // From MCsePluginControllerObserver        
       
    79     	
       
    80     	void ScheduleCompletedSuccesfullyL( const TUint32 aDbIdentifier );
       
    81     	    	
       
    82     	void ScheduleCompletedWithErrorL( const TUint32 aDbIdentifier, TUint32 aCompletionCode );
       
    83     	    	
       
    84     	void IncreaseScheduleRunCountL( const TUint32 aDbIdentifier );
       
    85     	    	
       
    86     	TBool IsAllowedToRun( TUint32 aDbIdentifier );
       
    87     	    	
       
    88         void ScheduleNotValid( const TUint32 aDbIdentifier );
       
    89                 
       
    90         void RequestReschedule( );
       
    91                 
       
    92         void ClearingDone();
       
    93    
       
    94    public: // New methods     
       
    95         /**
       
    96 		* Plugin complete callback used with CIdle. Used to break call stack.
       
    97 		* @param    aPtr    Pointer back to CCseSchedulerUserInformer-class
       
    98 		* @return   Always EFalse.
       
    99 		*/
       
   100 		static TInt CompletitionCallback( TAny* aPtr );
       
   101 
       
   102 		/**
       
   103 		* Schedule complete callback handler. Removes schedule from "on run list",
       
   104 		* informs engine that schedule has comlete and checks if the plugin where
       
   105 		* schedule was run still needed.
       
   106 		* @return   Always EFalse
       
   107 		*/
       
   108 		TInt HandleCompletitionCallback();
       
   109 		
       
   110 		/**
       
   111          * Cleaner callback used with CIdle. Used to break call stack.         
       
   112          * @param    aPtr    Pointer back to CCseSchedulerUserInformer-class
       
   113          * @return   Always EFalse.
       
   114          */
       
   115 		static TInt CleanerCallback( TAny* aPtr );
       
   116 	
       
   117 		/**
       
   118 		 * Cleaner callback handler. Goes through all plugin contollers and clears them
       
   119 		 * (shutdowns all threads running plugins).		 
       
   120 		 * @return   Always EFalse		 
       
   121 		 */
       
   122 		TInt HandleCleanerCallback();
       
   123 
       
   124     public: // From CObject
       
   125         /**
       
   126         * Overwrites CObjects Close. Sets the AccesCount to zero.        
       
   127         * @return   None
       
   128         */
       
   129         void Close();        
       
   130 
       
   131     public: // New functions
       
   132     
       
   133         /**
       
   134         * Does the general message handling.
       
   135         * @param aMessage contains data from the client.
       
   136         * @return None.
       
   137         */
       
   138         void GeneralServiceL( const RMessage2& aMessage );
       
   139 
       
   140         /**
       
   141         * Service cancellation.
       
   142         * @param aMessage contains data from the client.
       
   143         * @return None.
       
   144         */
       
   145         void CancelService( const RMessage2& aMessage );       
       
   146         
       
   147         /**
       
   148         * Checks if scheduler is active atm (schedules in run or waitint)        
       
   149         * @return ETrue if active and EFalse if not.
       
   150         */
       
   151         TBool IsSchedulerActive() const;
       
   152         
       
   153         /**
       
   154         * Reschedules engine (get new "next schedule" from database and
       
   155         * resets timer).       
       
   156         * @return   None.
       
   157         */
       
   158 		void RescheduleL();
       
   159 		
       
   160 		/**
       
   161         * Reschedules engine (get new "next schedule" from database and
       
   162         * resets timer).       
       
   163         * @return   None.
       
   164         */
       
   165 		void RescheduleByPluginL( TInt32 aPluginUid );
       
   166 		
       
   167     private: // Constructors and destructor
       
   168 
       
   169         /**
       
   170         * C++ default constructor.
       
   171         * @param Reference to scheduler server.
       
   172         */
       
   173         CCseSchedulerServerEngine( CCseSchedulerServer& aServer );
       
   174 
       
   175         /**
       
   176         * By default Symbian 2nd phase constructor is private.
       
   177         */
       
   178         void ConstructL();                
       
   179     
       
   180 
       
   181     private: // New functions  
       
   182         /**
       
   183         * Panic the client on server side.        
       
   184         * @param    aPanic      Our panic code.
       
   185         * @param    aMessage    A message from client
       
   186         * @return   None.
       
   187         */
       
   188         void PanicClient( TCseSchedulerServPanic aPanic, 
       
   189                           const RMessage2& aMessage ) const;
       
   190         
       
   191         /**
       
   192         * Adds schedule to database
       
   193         * @param    aMessage    A message from client
       
   194         * @return   None.
       
   195         */                  
       
   196         void AddScheduleL( const RMessage2& aMessage );
       
   197         
       
   198         /**
       
   199         * Removes schedule from database
       
   200         * @param    aMessage    A message from client
       
   201         * @return   None.
       
   202         */        
       
   203         void RemoveScheduleL( const RMessage2& aMessage );
       
   204         
       
   205         /**
       
   206         * Gets all schedules from database
       
   207         * @param    aMessage    A message from client
       
   208         * @return   None.
       
   209         */
       
   210         void GetSchedulesL( const RMessage2& aMessage );
       
   211         
       
   212         /**
       
   213         * Adds schedule to database
       
   214         * @param    aMessage    A message from client
       
   215         * @return   None.
       
   216         */
       
   217         void GetScheduleL( const RMessage2& aMessage );
       
   218         
       
   219         /**
       
   220         * Gets externalize length of one specific schedule
       
   221         * @param    aMessage    A message from client
       
   222         * @return   None.
       
   223         */
       
   224         void GetScheduleLengthL( const RMessage2& aMessage );
       
   225         
       
   226         /**
       
   227         * Gets schedules based on application UID.
       
   228         * @param    aMessage    A message from client
       
   229         * @return   None.
       
   230         */
       
   231         void GetSchedulesByAppUidL( const RMessage2& aMessage );
       
   232 	    
       
   233 	    /**
       
   234         * Gets externalize length of the schedules of one application UID
       
   235         * @param    aMessage    A message from client
       
   236         * @return   None.
       
   237         */
       
   238 		void GetScheduleArrayLengthByAppUidL( const RMessage2& aMessage );
       
   239 
       
   240 		/**
       
   241         * Gets externalize length of the overlapping schedules
       
   242         * @param    aMessage    A message from client
       
   243         * @return   None.
       
   244         */
       
   245 		void GetOverlappingSchedulesLengthL( const RMessage2& aMessage );
       
   246 
       
   247 	    /**
       
   248         * Gets overlapping schedules of given timeframe
       
   249         * @param    aMessage    A message from client
       
   250         * @return   None.
       
   251         */
       
   252 		void GetOverlappingSchedulesL( const RMessage2& aMessage );
       
   253 		
       
   254 		/**
       
   255         * Gets startup schedules from database (schedules that were on run when
       
   256         * phone was shut down)
       
   257         * @return None.
       
   258         */
       
   259 		void EngineSchedulesStartup();
       
   260 		
       
   261 		/**
       
   262         * Gets externalize length of the schedules of one plugin UID
       
   263         * @param    aMessage    A message from client
       
   264         * @return   None.
       
   265         */
       
   266         void GetScheduleArrayLengthByPluginUidL( const RMessage2& aMessage );
       
   267         
       
   268         /**
       
   269         * Gets schedules based on plugin UID.
       
   270         * @param    aMessage    A message from client
       
   271         * @return   None.
       
   272         */
       
   273         void GetSchedulesByPluginUidL( const RMessage2& aMessage );
       
   274     
       
   275         /**
       
   276         * Gets externalize length of the schedules of one type.
       
   277         * @param    aMessage    A message from client
       
   278         * @return   None.
       
   279         */
       
   280         void GetScheduleArrayLengthByTypeL( const RMessage2& aMessage );
       
   281 
       
   282         /**
       
   283         * Gets schedules based on schedule type.
       
   284         * @param    aMessage    A message from client
       
   285         * @return   None.
       
   286         */
       
   287         void GetSchedulesByTypeL( const RMessage2& aMessage );
       
   288 
       
   289         /**
       
   290         * Gets externalize length of the schedules of specific timeframe.
       
   291         * @param    aMessage    A message from client
       
   292         * @return   None.
       
   293         */
       
   294         void GetScheduleArrayLengthByTimeframeL( const RMessage2& aMessage );
       
   295     
       
   296         /**
       
   297         * Gets schedules between given timeframe.
       
   298         * @param    aMessage    A message from client
       
   299         * @return   None.
       
   300         */
       
   301         void GetSchedulesByTimeframeL( const RMessage2& aMessage );
       
   302 		
       
   303     private:    // Data
       
   304         /**
       
   305         * DB class. Own.
       
   306         */
       
   307         CCseScheduleDB* iDb;
       
   308 
       
   309         /**
       
   310 		* Array holding all plugin controllers.
       
   311 		*/
       
   312         RPointerArray<CCseSchedulerPluginControllerBase> iPluginControllerArray;
       
   313         
       
   314         /**
       
   315         * CIdle, used to break call stack when schedule completes. Own.
       
   316         */ 
       
   317         CIdle* iCompletitionBreaker;
       
   318         
       
   319         /**
       
   320         * Reference to scheduler server
       
   321         */ 
       
   322         CCseSchedulerServer& iServer;
       
   323     };
       
   324 
       
   325 #endif // __CCSESCHEDULERSERVERENGINE_H
       
   326 
       
   327 // End of file
       
   328