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