sensorservices/sensorserver/inc/server/sensrvserver.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Sensor server main class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef SENSRVSERVER_H
       
    20 #define SENSRVSERVER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include "sensrvclientserver.h"
       
    24 
       
    25 // ----------------------------------------------------------------------------------------
       
    26 // Sensor Server's policy
       
    27 // ----------------------------------------------------------------------------------------
       
    28 
       
    29 // Total number of ranges
       
    30 const TUint KSensrvPolicyRangeCount = 3;
       
    31 
       
    32 // Definition of the ranges of IPC numbers
       
    33 const TInt KSensrvRanges[KSensrvPolicyRangeCount] =
       
    34     {
       
    35     ESensrvSrvReqQueryChannels,  // 0th range. Channel listening operations
       
    36     ESensrvSrvReqShutdownServer, // 1st range, Server shutdown
       
    37     ESensrvSrvReqEnd             // 2nd range, non implemented function end of range check; ENotSupported
       
    38     };
       
    39 
       
    40 // Policy to implement for each of the above ranges
       
    41 const TUint8 KSensrvElementsIndex[KSensrvPolicyRangeCount] =
       
    42     {
       
    43     CPolicyServer::EAlwaysPass,  // Applies to 0th range
       
    44     0,                           // Applies to 1st range
       
    45     CPolicyServer::ENotSupported // Applies to 2nd range (out of range IPC)
       
    46     };
       
    47 
       
    48 // Specific capability checks
       
    49 const CPolicyServer::TPolicyElement KSensrvElements[] =
       
    50     {
       
    51     { _INIT_SECURITY_POLICY_S0( KSensrvTestFrameworkUid ),    CPolicyServer::EPanicClient } // Policy "0", i.e. access is allowed only for test framework
       
    52     };
       
    53 
       
    54 // Package all the above together into a policy
       
    55 const CPolicyServer::TPolicy KSensrvPolicy =
       
    56     {
       
    57     CPolicyServer::EAlwaysPass, // All connect attempts to Sensor Server pass
       
    58     KSensrvPolicyRangeCount,    // Number of ranges
       
    59     KSensrvRanges,              // Ranges array
       
    60     KSensrvElementsIndex,       // Elements <-> ranges index
       
    61     KSensrvElements,            // Array of elements
       
    62     };
       
    63 
       
    64 // Forward declarations
       
    65 class CSensrvProxyManager;
       
    66 class TSensrvResourceChannelInfo;
       
    67 
       
    68 /**
       
    69 *  Sensor server main class
       
    70 *
       
    71 *  @since S60 5.0
       
    72 */
       
    73 class CSensrvServer : public CPolicyServer
       
    74     {
       
    75     public:  // Constructors and destructor
       
    76         
       
    77 
       
    78         /**
       
    79         * Creates a new server.
       
    80         *
       
    81         * @since S60 5.0
       
    82         * @return A pointer to the created object.
       
    83         */
       
    84         static CSensrvServer* NewL();
       
    85         
       
    86         /**
       
    87         * Creates a new server. Newly created instance is left in the cleanup stack.
       
    88         *
       
    89         * @since S60 5.0
       
    90         * @return A pointer to the created object.
       
    91         */
       
    92         static CSensrvServer* NewLC();
       
    93 
       
    94         /**
       
    95         * Destructor.
       
    96         */
       
    97         virtual ~CSensrvServer();
       
    98 
       
    99         /**
       
   100         * Notifies clients that a change has happened in available channels.
       
   101         *
       
   102         * @since S60 5.0
       
   103         * @param[in] aChangedChannel Channel information of the channel.
       
   104         * @param[in] aChangeType If ESensrvChannelAdded, channel is a newly available
       
   105         *                        channel. 
       
   106         *                        If ESensrvChannelRemoved, channel was removed and is  
       
   107         *                        no longer available.
       
   108         */
       
   109         void NotifyChannelChange(const TSensrvResourceChannelInfo& aChangedChannel,
       
   110                                  TSensrvChannelChangeType aChangeType );
       
   111     private:
       
   112 
       
   113         /**
       
   114         * C++ constructor.
       
   115         */
       
   116         CSensrvServer( const TServerType aType = EUnsharableSessions );
       
   117         /**
       
   118         * By default Symbian 2nd phase constructor is private.
       
   119         */
       
   120         void ConstructL();
       
   121         
       
   122         /**
       
   123         * Creates a new session when client connects.
       
   124         *
       
   125         * @since S60 5.0
       
   126         *
       
   127         * @param aVersion Version
       
   128         * @param aMessage 'connect' message from the client
       
   129         * @return Pointer to created session or leaves with codes
       
   130         *         KErrNotSupported if versions does not match
       
   131         *         KErrNoMemory if creation of new session fails.
       
   132         */
       
   133         CSession2* NewSessionL( const TVersion& aVersion,
       
   134                                 const RMessage2& aMessage ) const;
       
   135         /**
       
   136         * Panics the server thread
       
   137         *
       
   138         * @since S60 5.0
       
   139         * @param aCategory Panicer's id 
       
   140         * @param aPanic    Reason of panic 
       
   141         * @return void
       
   142         */
       
   143         void Panic( const TDesC& aCategory, const TInt aReason );
       
   144         
       
   145         /**
       
   146         * Gets a reference to the session iterator of this server.
       
   147         *
       
   148         * @since S60 5.0
       
   149         * @return Reference to the session iterator.
       
   150         */
       
   151         inline TDblQueIter<CSession2>* SessionIterator() { return &iSessionIter; };
       
   152         
       
   153     private:    // Data
       
   154 
       
   155         /**
       
   156         * Proxy manager that handles all proxies. 
       
   157         * Own.
       
   158         */
       
   159         CSensrvProxyManager* iProxyManager;
       
   160     };
       
   161 
       
   162 
       
   163 
       
   164 #endif // SENSRVSERVER_H