os/security/cryptoservices/filebasedcertificateandkeystores/source/generic/client/CFSClient.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 * Base class for implementations of ctframework interfaces
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file 
    22  @internalTechnology
    23 */
    24  
    25 #ifndef __CFSCLIENT_H__
    26 #define __CFSCLIENT_H__
    27 
    28 #include "fstokencliserv.h"
    29 #include <e32base.h>
    30 
    31 class MCTToken;
    32 class RFileStoreClientSession;
    33 
    34 /**
    35  * Base class for implementations of ctframework interfaces.  Derived classes
    36  * inherit from this and also implement the appropriate interface.
    37  *
    38  * It provides asynchronous functionality for sending requests to the filetokens
    39  * server and processing the responses.
    40  *
    41  * Some methods are const so they can be called by the cert apps client, whose
    42  * interface contains several const methods.  These methods need to create
    43  * internal buffers, and this leads to iRequestDataBuf and iRequestPtr being
    44  * mutable.
    45  */
    46 NONSHARABLE_CLASS(CFSClient) : public CActive
    47 	{
    48 public:
    49 	virtual ~CFSClient();
    50 	
    51 protected:
    52 	CFSClient(TInt aUID, MCTToken& aToken, RFileStoreClientSession& aClient);
    53 	TInt AllocRequestBuffer(TInt aReqdSize) const;
    54 	void FreeRequestBuffer() const;
    55 	void SendSyncRequestAndHandleOverflowL(TFSTokenMessages aMessage,
    56 										   TInt aInitialBufSize,
    57 										   const TIpcArgs& aArgs) const;
    58 
    59 protected:
    60 	// From CActive
    61 	virtual void DoCancel();	
    62 	virtual TInt RunError(TInt aError);
    63 	
    64 protected:
    65 	/**
    66 	 * Maintains state for async requests to filetokens server, and completes
    67 	 * caller when required.
    68 	 */
    69 	class TAsyncRequest
    70 	{
    71 	public:
    72 		void operator()(TFSTokenMessages aRequest, TRequestStatus* aStatus);
    73 		void Complete(TInt aCompletionResult);			
    74 		void Cancel();
    75 		inline TFSTokenMessages OutstandingRequest() { return iRequest; }
    76 	public:
    77 		~TAsyncRequest();
    78 	private:
    79 		TFSTokenMessages iRequest;
    80 		TRequestStatus* iClientStatus;
    81 	};
    82 	
    83 	TAsyncRequest iCurrentRequest;		///< The outstanding server request
    84 	
    85 private:
    86 	mutable HBufC8* iRequestDataBuf;  	///< Buffer for messages passed to the server
    87 	
    88 protected:
    89 	MCTToken& iToken;					///< The token we belong to
    90 	TInt iInterfaceUID;					///< UID of the cryptoken interface we implement
    91 	RFileStoreClientSession& iClient;	///< Client session object for sending messages to the server
    92 	mutable TPtr8 iRequestPtr;			///< Buffer pointer for derived classes to use
    93 	};
    94 
    95 #endif	//	__CFSCLIENT_H__