psmservices/psmserver/inc/server/psmsrvserver.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     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:  PSM server main class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef PSMSRVSERVER_H
       
    20 #define PSMSRVSERVER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include "psmclientserver.h"
       
    24 
       
    25 // Total number of ranges
       
    26 const TUint KPsmSrvPolicyRangeCount = 2;
       
    27 
       
    28 // Definition of the ranges of IPC numbers
       
    29 const TInt KPsmSrvRanges[KPsmSrvPolicyRangeCount] =
       
    30     {
       
    31     EPsmServerNotifyModeChange,  // 0th range. basic operations
       
    32     EPsmServerReqEnd             // 3rd range, non implemented functions; ENotSupported
       
    33     };
       
    34 
       
    35 // Policy to implement for each of the above ranges
       
    36 const TUint8 KPsmSrvElementsIndex[KPsmSrvPolicyRangeCount] =
       
    37     {
       
    38     0,                           // Applies to 0th range
       
    39     CPolicyServer::ENotSupported // Applies to 1st range (out of range IPC)
       
    40     };
       
    41 
       
    42 // Specific capability checks
       
    43 const CPolicyServer::TPolicyElement KPsmSrvElements[] =
       
    44     {
       
    45     { _INIT_SECURITY_POLICY_C2( ECapabilityReadDeviceData, ECapabilityWriteDeviceData ), 
       
    46                                     CPolicyServer::EFailClient }  // Policy "0"
       
    47     };
       
    48 
       
    49 // Package all the above together into a policy
       
    50 const CPolicyServer::TPolicy KPsmSrvPolicy =
       
    51     {
       
    52     CPolicyServer::EAlwaysPass, // All connect attempts to PSM Server pass
       
    53     KPsmSrvPolicyRangeCount,    // Number of ranges
       
    54     KPsmSrvRanges,              // Ranges array
       
    55     KPsmSrvElementsIndex,       // Elements <-> ranges index
       
    56     KPsmSrvElements,            // Array of elements
       
    57     };
       
    58 
       
    59 
       
    60 // FORWARD DECLARATIONS
       
    61 class CPsmManager;
       
    62 class CPsmSrvShutdown;
       
    63 
       
    64 /**
       
    65  *  PSM server main class
       
    66  *
       
    67  *  @since S60 5.0
       
    68  */
       
    69 class CPsmSrvServer : public CPolicyServer
       
    70     {
       
    71 
       
    72     friend class CPsmSrvShutdown;
       
    73 
       
    74     public:  // Constructors and destructor
       
    75 
       
    76         /**
       
    77          * Creates a new server.
       
    78          *
       
    79          * @return A pointer to the created object.
       
    80          */
       
    81         static CPsmSrvServer* NewL();
       
    82 
       
    83         /**
       
    84          * Creates a new server. Newly created instance is left in the cleanup stack.
       
    85          *
       
    86          * @return A pointer to the created object.
       
    87          */
       
    88         static CPsmSrvServer* NewLC();
       
    89 
       
    90         /**
       
    91          * Destructor.
       
    92          */
       
    93         virtual ~CPsmSrvServer();
       
    94 
       
    95     public:
       
    96 
       
    97         /**
       
    98          * Indicates that session is closed
       
    99          */
       
   100         void SessionClosed();
       
   101 
       
   102     private:
       
   103 
       
   104         /**
       
   105          * C++ constructor.
       
   106          */
       
   107         CPsmSrvServer( const TServerType aType = EUnsharableSessions );
       
   108 
       
   109         /**
       
   110          * By default Symbian 2nd phase constructor is private.
       
   111          */
       
   112         void ConstructL();
       
   113 
       
   114         /**
       
   115          * Creates a new session when client connects.
       
   116          *
       
   117          * @param aVersion Version
       
   118          * @param aMessage 'connect' message from the client
       
   119          * @return Pointer to created session or leaves with codes
       
   120          *         KErrNotSupported if versions does not match
       
   121          *         KErrNoMemory if creation of new session fails.
       
   122          */
       
   123         CSession2* NewSessionL( const TVersion& aVersion,
       
   124                                 const RMessage2& aMessage ) const;
       
   125 
       
   126         /**
       
   127          * Checks can we shut down server
       
   128          *
       
   129          * @return KErrNotReady if server cannot be shut down yet.
       
   130          */
       
   131         TInt ShutdownServer();
       
   132 
       
   133         /**
       
   134          * Panics the server thread
       
   135          *
       
   136          * @param aCategory Panicer's id 
       
   137          * @param aPanic    Reason of panic 
       
   138          */
       
   139         void Panic( const TDesC& aCategory, const TInt aReason );
       
   140 
       
   141         /**
       
   142          * Gets a reference to the session iterator of this server.
       
   143          *
       
   144          * @return Reference to the session iterator.
       
   145          */
       
   146         inline TDblQueIter<CSession2>* SessionIterator() { return &iSessionIter; };
       
   147 
       
   148     private:    // Data
       
   149 
       
   150         /**
       
   151          * Main class of this server
       
   152          */
       
   153         CPsmManager* iPsmManager;
       
   154 
       
   155         /**
       
   156          * Timer to terminate server
       
   157          */
       
   158         CPsmSrvShutdown* iShutdown;
       
   159 
       
   160     };
       
   161 
       
   162 #endif // PSMSRVSERVER_H