devicediagnosticsfw/diagresultsdb/server/inc/diagresultsdbserver.h
branchRCL_3
changeset 61 b183ec05bd8c
parent 59 13d7c31c74e0
child 62 19bba8228ff0
equal deleted inserted replaced
59:13d7c31c74e0 61:b183ec05bd8c
     1 /*
       
     2 * Copyright (c) 2007-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:  Symbian OS server results database.
       
    15 *  libraries   : 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef DIAG_RESULTS_DB_SERVER_H
       
    21 #define DIAG_RESULTS_DB_SERVER_H
       
    22 
       
    23 #include "diagresultsdatabasecommon.h"
       
    24 
       
    25 //System includes
       
    26 #include <e32base.h>
       
    27 #include <f32file.h>
       
    28 
       
    29 /**
       
    30 * Results database symbian OS server class. Creates server sessions and keeps
       
    31 * track of the session counts.
       
    32 *
       
    33 * @since S60 v5.0
       
    34 **/
       
    35 class CDiagResultsDbServer : public CPolicyServer
       
    36 	{
       
    37 public:
       
    38 
       
    39     /**
       
    40     * Destructor
       
    41     **/ 
       
    42 	~CDiagResultsDbServer();
       
    43 	
       
    44 	/**
       
    45 	* NewLC. 
       
    46 	* @param aPolicy Security policy that is defined at the end of this file.
       
    47 	**/
       
    48 	static void NewLC(const TPolicy &aPolicy);
       
    49 	
       
    50 	/**
       
    51 	* Create a new server session.
       
    52 	* @param aVersion version of the server.
       
    53 	* @param aMessage
       
    54 	* @return a new session.
       
    55 	**/
       
    56 	virtual CSession2 *NewSessionL(const TVersion &aVersion, const RMessage2 &/*aMessage*/) const;
       
    57 	
       
    58 	/**
       
    59 	* Run server i.e. first create cleanup stack and active scheduler. This server is CActive based.
       
    60 	* @return Symbian error code or KErrNone.
       
    61 	**/
       
    62 	static TInt RunServer();
       
    63 	static void RunServerL();
       
    64 	
       
    65 public: // New methods
       
    66 
       
    67     /**
       
    68     * Create object container that is needed when handling subsession.
       
    69     * @return object container.
       
    70     **/
       
    71 	CObjectCon* NewContainerL();
       
    72 	
       
    73 	/**
       
    74 	* Remove object container from container index.
       
    75 	* @param aCon container to be removed.
       
    76 	**/
       
    77 	void RemoveContainer(CObjectCon* aCon);
       
    78 	
       
    79     /**
       
    80 	* Decrease session count by one. ServerSession uses this function when client dies.
       
    81 	**/
       
    82 	void DecreaseSessionCount();
       
    83 	
       
    84 	/**
       
    85 	* Increase session count by one. ServerSession uses this function when client dies.
       
    86 	**/
       
    87 	void IncreaseSessionCount();
       
    88 	
       
    89 	/**
       
    90 	* Returns the number of active sessions.
       
    91 	* @return Session count.
       
    92 	**/
       
    93 	TInt SessionCount();
       
    94 	
       
    95 	/**
       
    96 	* Custom security check. From CPolicyServer.
       
    97 	**/
       
    98 	TCustomResult CustomSecurityCheckL(const RMessage2 &aMsg, TInt &aAction, TSecurityInfo &aMissing);
       
    99 	
       
   100 protected:
       
   101     /**
       
   102     * Constructor.
       
   103     * @param aPriority Priority of this server. Should be pretty high.
       
   104     * @param aPolicy Security policy of this server.
       
   105     **/
       
   106 	CDiagResultsDbServer(TInt aPriority, const TPolicy &aPolicy);
       
   107 
       
   108 private:
       
   109 
       
   110     /**
       
   111     * ConstructL.
       
   112     **/
       
   113 	void ConstructL();
       
   114 	
       
   115 private: // Data
       
   116 
       
   117     // For creating object container instances
       
   118 	CObjectConIx* iContainerIndex;  
       
   119 	
       
   120 	// The number of active sessions 
       
   121 	TInt iSessionCount;
       
   122 	};
       
   123 
       
   124 // Security policy definition.
       
   125 // ReadDeviceData + WriteDeviceData is needed.
       
   126 const CPolicyServer::TPolicyElement elements[] = 
       
   127 	{
       
   128 		{_INIT_SECURITY_POLICY_C2(ECapabilityReadDeviceData, ECapabilityWriteDeviceData),
       
   129 			 CPolicyServer::EFailClient},
       
   130 	};
       
   131 
       
   132 const TInt ranges[2] = 
       
   133 		{
       
   134 		0,
       
   135 		DiagResultsDbCommon::ENotSupported,
       
   136 		
       
   137 		};
       
   138 
       
   139 const TUint8 elementsIndex[2] = 
       
   140 		{
       
   141 		CPolicyServer::ECustomCheck, //ReadDeviceData + WriteDeviceData for all clients.
       
   142         CPolicyServer::ENotSupported,
       
   143 		};
       
   144 
       
   145 const CPolicyServer::TPolicy policy = 
       
   146 	{
       
   147 	CPolicyServer::EAlwaysPass,	// on connect
       
   148 	2,		// range count
       
   149 	ranges, 
       
   150   	elementsIndex,
       
   151 	elements,
       
   152   	};    
       
   153     
       
   154 #endif //DIAG_RESULTS_DB_SERVER_H