metadataengine/server/inc/mdsserver.h
changeset 0 c53acadfccc6
child 1 acef663c1218
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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:  This is Metadata engine server file*
       
    15 */
       
    16 
       
    17 #ifndef __MDSSERVER_H__
       
    18 #define __MDSSERVER_H__
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32base.h>
       
    22 #include <e32cmn.h>
       
    23 
       
    24 #include "mdccommon.pan"
       
    25 
       
    26 #include "mdsdiskspacenotifier.h"
       
    27 #include "mdebackuprestoreobserver.h"
       
    28 #include "mdsshutdownobserver.h"
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CMdSObjectLockList;
       
    32 class CMdSNotifier;
       
    33 class CMdSMaintenanceEngine;
       
    34 class CMdSManipulationEngine;
       
    35 class CMdSSqLiteConnection;
       
    36 class CMdEBackupRestoreWatcherAO;
       
    37 class CMdsSchema;
       
    38 class CMdCSerializationBuffer;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 * CMdSServer.
       
    44 *  An instance of class CMdSServer is the main server class
       
    45 */
       
    46 class CMdSServer : public CPolicyServer, public MMdSDiskSpaceNotifierObserver, 
       
    47                    public MMdEBackupRestoreObserver,
       
    48                    public MMDSShutdownObserver
       
    49                    
       
    50     {
       
    51     public : // From MMdSDiskSpaceNotifierObserver
       
    52     	void HandleDiskSpaceNotificationL(TDiskSpaceDirection aCrossDirection);
       
    53 
       
    54 		void HandleDiskSpaceError(TInt aError);
       
    55 		
       
    56 	public: // From MMdEBackupRestoreObserver
       
    57 		// Called when backup & restore watcher notices starting back up.
       
    58 		void HandleBackup();
       
    59 		// Called when backup & restore watcher notices starting restore.
       
    60 		void HandleRestore();
       
    61 		// Called when backup or watcher is completed and normal operation continues.
       
    62 		void ResumeOperation();	
       
    63 		
       
    64 	public: // MMDSShutdownObserver
       
    65 	        
       
    66 	        void ShutdownNotification();
       
    67 	        
       
    68 	        void RestartNotification();
       
    69     
       
    70     public : // Constructors and destructors
       
    71 
       
    72 	    /**
       
    73 	    * Constructs a new metadata server implementation.
       
    74 	    *
       
    75 	    * @return  metadata server implementation
       
    76 	    */
       
    77         static CMdSServer* NewL();
       
    78 
       
    79 	    /**
       
    80 	    * Constructs a new metadata server implementation and leaves the server implementation
       
    81 	    * in the cleanup stack.
       
    82 	    *
       
    83 	    * @return  metadata server implementation
       
    84 	    */
       
    85         static CMdSServer* NewLC();
       
    86 
       
    87 	    /**
       
    88 	    * Destructor.
       
    89 	    */
       
    90         virtual ~CMdSServer();
       
    91 
       
    92     public: // New functions
       
    93 
       
    94         /**
       
    95         * ThreadFunction.
       
    96         * Main function for the server thread.
       
    97         * @param aStarted A semaphore to be flagged when server
       
    98         *                 has been started.
       
    99         * @return Error code.
       
   100         */
       
   101         static TInt ThreadFunction( TAny* aStarted );
       
   102 
       
   103         /**
       
   104         * IncrementSessions.
       
   105         * Increments the count of the active sessions for this server.
       
   106         */
       
   107         void IncrementSessions();
       
   108 
       
   109         /**
       
   110         * DecrementSessions.
       
   111         * Decrements the count of the active sessions for this server.
       
   112         * If no more sessions are in use the server terminates.
       
   113         */
       
   114         void DecrementSessions();
       
   115 
       
   116         /**
       
   117         * Reference to the schema
       
   118         */
       
   119         CMdsSchema& Schema();
       
   120 
       
   121         /**
       
   122         * Get lock list
       
   123         */
       
   124         CMdSObjectLockList& LockList();
       
   125 
       
   126         /**
       
   127         * Get notifier
       
   128         */
       
   129         CMdSNotifier& Notifier();
       
   130 
       
   131         /**
       
   132         * Get maintenance engine
       
   133         */
       
   134         
       
   135         CMdSMaintenanceEngine& Maintenance();
       
   136         
       
   137         /**
       
   138         * Get manipulator engine
       
   139         */
       
   140         
       
   141         CMdSManipulationEngine& Manipulate();
       
   142 
       
   143         /**
       
   144         * PanicClient.
       
   145         * Panics the client.
       
   146         * @param aMessage The message channel to the client.
       
   147         * @param aReason The reason code for the panic.
       
   148         */
       
   149         static void PanicClient( const RMessage2& aMessage, TInt aReason );
       
   150         
       
   151         TBool DiskFull() const;
       
   152         
       
   153         TBool BackupOrRestoreRunning() const;
       
   154 
       
   155         TInt SetHarvestingPrioritizationChunkL( const RMessagePtr2 aMessage, TInt aParam );
       
   156 
       
   157         TInt AddHarvestingPrioritizationObserver( RMessagePtr2 aMessage );
       
   158 
       
   159         TInt CancelHarvestingPrioritizationObserver();
       
   160 
       
   161         TBool ReserveSpaceHarvestingPrioritizationUri( const TDesC16& aUri );
       
   162 
       
   163         TBool StartAddingHarvestingPrioritizationUrisL();
       
   164         
       
   165         TBool AddHarvestingPrioritizationUriL( TDesC16& aUri );
       
   166 
       
   167         void NotifyHarvestingPrioritizationObserver( TInt aStatus ) const;
       
   168 
       
   169         /** 
       
   170          * ResetDBL
       
   171          * resets DB, should be called only in DEBUG build
       
   172          */
       
   173         TInt ResetDBL();
       
   174 
       
   175     protected: // Functions from base classes
       
   176 
       
   177         /**
       
   178         * From CActive, RunError.
       
   179         * Processes any errors.
       
   180         * @param aError The leave code reported.
       
   181         * @result return KErrNone if leave is handled.
       
   182         */
       
   183         TInt RunError( TInt aError );
       
   184         
       
   185         /**
       
   186         * From CPolicyServer.
       
   187         * Handles capability checking for certain server requests.
       
   188         * @result return one of TCustomResult set {EPass, EFail, EAsync}.
       
   189         */
       
   190         CPolicyServer::TCustomResult CustomSecurityCheckL( 
       
   191                                                 const RMessage2 &aMsg,
       
   192                                                 TInt &aAction,
       
   193                                                 TSecurityInfo &aMissing);
       
   194 
       
   195         /**
       
   196         * From CPolicyServer.
       
   197         * Handles xxxx.
       
   198         * @result return one of TCustomResult set {EPass, EFail, EAsync}.
       
   199         */
       
   200         CPolicyServer::TCustomResult CustomFailureActionL(
       
   201                                                 const RMessage2 &aMsg,
       
   202                                                 TInt aAction,
       
   203                                                 const TSecurityInfo &aMissing);
       
   204 
       
   205 
       
   206     private: // Constructors and destructors
       
   207 
       
   208         /**
       
   209          * CMdEServer.
       
   210          * C++ default constructor.
       
   211          * @param aPriority priority for this thread.
       
   212          */
       
   213         CMdSServer( TInt aPriority );
       
   214 
       
   215         /**
       
   216          * ConstructL.
       
   217          * 2nd phase constructor.
       
   218          */
       
   219         void ConstructL();
       
   220 
       
   221         /**
       
   222          * InitializeL
       
   223          * Do part of internal resources initializations
       
   224          * used together with DeInitialize to ResetDB functionality
       
   225          */
       
   226         void InitializeL();
       
   227 
       
   228         /**
       
   229          * DeInitializeL
       
   230          * Do part of internal resources deinitializations
       
   231          * used together with Initialize to ResetDB functionality
       
   232          */
       
   233         void DeInitializeL();
       
   234         
       
   235         void CheckInitSriptL();
       
   236         
       
   237     private: // New methods
       
   238 
       
   239         /**
       
   240         * PanicServer.
       
   241         * Panics the server.
       
   242         * @param aPanic The panic code.
       
   243         */
       
   244         static void PanicServer( TMetadataPanic aPanic );
       
   245 
       
   246         /**
       
   247         * ThreadFunctionL.
       
   248         * Second stage startup for the server thread.
       
   249         */
       
   250         static void ThreadFunctionL();
       
   251 
       
   252         friend TInt E32Main();
       
   253 
       
   254     private: // Functions from base classes
       
   255 
       
   256         /**
       
   257         * From CServer, NewSessionL.
       
   258         * Creates a time server session.
       
   259         * @param aVersion The client version.
       
   260         * @return Pointer to new session.
       
   261         */
       
   262         CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const;
       
   263 
       
   264     private: // Data
       
   265 
       
   266         /**
       
   267         * iSessionCount, the number of session owned by this server.
       
   268         */
       
   269         TInt iSessionCount;
       
   270         
       
   271         /**
       
   272         * class for installing and maintaining the database
       
   273         */
       
   274         CMdSMaintenanceEngine* iMaintenance;
       
   275 
       
   276 		/**
       
   277 		* Default DB connection for default namespace.
       
   278 		*/
       
   279 		CMdSSqLiteConnection* iDefaultDBConnection;
       
   280 
       
   281         /**
       
   282         * The internal schema
       
   283         */
       
   284         CMdsSchema* iSchema;
       
   285 
       
   286         /**
       
   287         * Server status. If other than KErrNone, prevents client sessions.
       
   288         */
       
   289         TInt iServerErrorStatus;
       
   290         
       
   291         /**
       
   292         * Locked object list.
       
   293         */
       
   294        	CMdSObjectLockList* iLockList;
       
   295        
       
   296 		/**
       
   297 		* Notifier engine
       
   298 		*/
       
   299 		CMdSNotifier* iNotifier;
       
   300 
       
   301         /**
       
   302         * Object adding, removing and modification.
       
   303         * upper proxy layer, provides validation and such.
       
   304         */
       
   305         CMdSManipulationEngine* iManipulate;
       
   306         
       
   307         /**
       
   308         * Garbage collector notifier for situations where free disk space is getting low.
       
   309         */
       
   310         CMdSDiskSpaceNotifierAO* iDiskSpaceGarbageCollectorNotifier;
       
   311         
       
   312         /**
       
   313         * Notifier for situations where free disk space runs out.
       
   314         */
       
   315         CMdSDiskSpaceNotifierAO* iDiskFullNotifier;
       
   316         
       
   317         CMdEBackupRestoreWatcherAO* iBURWatcher;
       
   318         
       
   319         TBool iBackupOrRestoreRunning;
       
   320         
       
   321         RChunk iHarvestingPrioritizationChunk;
       
   322         CMdCSerializationBuffer* iHarvestingPrioritizationSerializationBuffer;
       
   323         TUint32 iHarvestingPrioritizationLimit;
       
   324         TInt32 iHarvestingPrioritizationUriCount;
       
   325         TBool iHarvestingPrioritizationLocked; // adding of new URIs allowed
       
   326 
       
   327         TInt32 iHarvestingPrioritizationBufferUriCount;
       
   328         TUint32 iHarvestingPrioritizationBufferUriOffset;
       
   329 
       
   330         RMessagePtr2 iHarvestingPrioritizationObserver;
       
   331         
       
   332         CMDSShutdownObserver* iShutdownObserver;
       
   333         
       
   334         TBool iShutdown;
       
   335     };
       
   336 
       
   337 #endif // __MDSSERVER_H__
       
   338 
       
   339 // End of File