backsteppingsrv/inc/bsserver.h
changeset 0 79c6a41cd166
child 101 9e077f9a342c
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2007 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:  BS Server - implemenration of CServer2 
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CBSSERVER_H
       
    20 #define C_CBSSERVER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <eikenv.h>
       
    24 #include <eikappui.h>
       
    25 
       
    26 #include "bspanic.h"
       
    27 
       
    28 class CBSEngine;
       
    29 
       
    30 /**
       
    31  * Back Stepping server implementation
       
    32  *
       
    33  * @since Series 60 3.2
       
    34  */
       
    35 
       
    36 class CBSServer : public CServer2
       
    37     {
       
    38     /**
       
    39      * EIkonEnv for the server process.
       
    40      *
       
    41      * @since Series 60 3.2
       
    42      */
       
    43     class CBSEikonEnv : public CEikonEnv
       
    44         {
       
    45     public:
       
    46         void DestroyEnvironment();
       
    47         void ConstructL();
       
    48         };
       
    49 
       
    50     /**
       
    51      * EikAppUi for the server process.
       
    52      * Inform engine if focused application was changed
       
    53      *
       
    54      * @since Series 60 3.2
       
    55      */
       
    56     class CBSAppUi : public CEikAppUi
       
    57         {
       
    58     public:
       
    59         ~CBSAppUi();
       
    60         void ConstructL();
       
    61         void HandleWsEventL( const TWsEvent& aEvent,
       
    62             CCoeControl* aDestination );
       
    63         void ForwardEventL( const TWsEvent& aEvent );
       
    64         CBSEngine* iEngine;
       
    65         };
       
    66 
       
    67 public:
       
    68 
       
    69     static CBSServer* NewLC();
       
    70 
       
    71     /**
       
    72      * Destructor.
       
    73      */
       
    74     virtual ~CBSServer();
       
    75 
       
    76     /**
       
    77      * Return the reference to the engine.
       
    78      *
       
    79      * @since Series 60 3.2
       
    80      * @return engine reference
       
    81      */
       
    82     CBSEngine& Engine();
       
    83 
       
    84     /**
       
    85      * Increment session count
       
    86      *
       
    87      * @since Series 60 3.2     
       
    88      */
       
    89     void IncrementSessions();
       
    90 
       
    91     /**
       
    92      * Decrement session count
       
    93      * Stops server if last session was closed
       
    94      * @since Series 60 3.2
       
    95      */
       
    96     void DecrementSessions();
       
    97 
       
    98     /**
       
    99      * First stage startup for the server thread. 
       
   100      *
       
   101      * @since Series 60 3.2
       
   102      * @return return KErrNone or panics thread
       
   103      */
       
   104     static TInt ThreadFunction();
       
   105 
       
   106     /**
       
   107      * Panic client. 
       
   108      *
       
   109      * @since Series 60 3.2
       
   110      * @param aMessage RMessage2
       
   111      * @param aPanic panic code
       
   112      */
       
   113     static void PanicClient( const RMessage2& aMessage, 
       
   114         TBSEnginePanic aPanic );
       
   115 
       
   116 protected:
       
   117 
       
   118     // from base class CActive
       
   119     /**
       
   120      * From CActive.
       
   121      * Process any errors.
       
   122      *
       
   123      * @since Series 60 3.2
       
   124      * @param aError the leave code reported
       
   125      * @return return KErrNone if leave is handled
       
   126      */
       
   127     TInt RunError( TInt aError );
       
   128 
       
   129 private:
       
   130 
       
   131     /**
       
   132      * Constructs the server. 
       
   133      *
       
   134      * @since Series 60 3.2
       
   135      * @param aPriority CServer2 input parameter
       
   136      */
       
   137     CBSServer( TInt aPriority );
       
   138 
       
   139     void ConstructL();
       
   140 
       
   141     /**
       
   142      * Panic the server. 
       
   143      *
       
   144      * @since Series 60 3.2
       
   145      * @param aPanic the panic code
       
   146      */
       
   147     static void PanicServer( TBSEnginePanic aPanic );
       
   148 
       
   149     /**
       
   150      * Second stage startup for the server thread.
       
   151      *
       
   152      * @since Series 60 3.2
       
   153      */
       
   154     static void ThreadFunctionL();
       
   155 
       
   156     /**
       
   157      * Create a  server session, and return a pointer to the created object.
       
   158      * @param aVersion the client version 
       
   159      * @param aMessage RMessage2 
       
   160      * @return pointer to new session
       
   161      */
       
   162     CSession2* NewSessionL( const TVersion& aVersion,
       
   163         const RMessage2& aMessage ) const;
       
   164 
       
   165 private:
       
   166     // data
       
   167     /**
       
   168      * Instance of engine
       
   169      * Own.
       
   170      */
       
   171     CBSEngine* iEngine;
       
   172 
       
   173     /*
       
   174      * Session count
       
   175      */
       
   176     TInt iSessionCount;
       
   177     };
       
   178 
       
   179 #endif // C_CBSSERVER_H