os/security/cryptoservices/filebasedcertificateandkeystores/source/generic/server/fsserver.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2004-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 the License "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: 
    15 *
    16 */
    17 
    18 
    19 /**
    20  @file 
    21  @internalTechnology
    22 */
    23  
    24 #ifndef __FSSERVER_H__
    25 #define __FSSERVER_H__
    26 
    27 #define FILECERTSTORE_SERVER
    28 
    29 #include <e32base.h>
    30 #include "fstokencliserv.h"
    31 #include "tokentypesenum.h"
    32 
    33 class CFSKeyStoreServer;
    34 class CFSCertStoreServer;
    35 class CFSCertAppsServer;
    36 
    37 /**
    38  * Implements shutdown of the server.  When the last client disconnects, this
    39  * class is activated, and when the timer expires, causes the server to
    40  * close.
    41  */
    42 class CShutdown : public CTimer
    43 	{
    44 	enum {KServerShutdownDelay=0x200000};	//	approx 2s
    45 public:
    46 	inline CShutdown();
    47 	inline void ConstructL();
    48 	inline void Start();
    49 private:
    50 	void RunL();
    51 	};
    52 
    53 
    54 /** Filetokens server class, manages sessions. */
    55 class CTokenServer : public CServer2
    56 	{
    57 public:
    58 	static CServer2* NewLC();
    59 public:
    60 	~CTokenServer();
    61 public:	
    62 	void AddSession();
    63 	void DropSession();
    64 	CFSKeyStoreServer& KeyStoreServerL() const;
    65 	CFSCertStoreServer& CertStoreServerL() const;
    66 	CFSCertAppsServer& CertAppsServerL() const;
    67 private:
    68 	// For CServer2
    69 	virtual CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
    70 private:
    71 	CTokenServer();
    72 	void ConstructL();
    73 private:
    74 	TInt iSessionCount;
    75 	CShutdown iShutdown;
    76 
    77 	// Ah, I knew there was a good use for that mutable keyword...
    78 	mutable CFSKeyStoreServer* iKeyStoreServer;
    79 	mutable CFSCertStoreServer* iCertStoreServer;
    80 	mutable CFSCertAppsServer* iCertAppsServer;
    81 	};								
    82 
    83 /**
    84  * Base class for session objects.
    85  */
    86 class CTokenServerSession : public CSession2
    87 	{
    88 public:
    89 	CTokenServerSession();
    90 	virtual ~CTokenServerSession();
    91 public:
    92 	inline CTokenServer& Server();
    93 protected:
    94 	virtual void DoServiceL(const RMessage2& aMessage) = 0;
    95 private:
    96 	virtual void CreateL();
    97 	virtual void ServiceError(const RMessage2& aMessage, TInt aError);
    98 	virtual void ServiceL(const RMessage2& aMessage);
    99 private:
   100 	};
   101 
   102 #endif	//	__FSSERVER_H__