sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * Base class for implementations of ctframework interfaces sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef __CFSCLIENT_H__ sl@0: #define __CFSCLIENT_H__ sl@0: sl@0: #include "fstokencliserv.h" sl@0: #include sl@0: sl@0: class MCTToken; sl@0: class RFileStoreClientSession; sl@0: sl@0: /** sl@0: * Base class for implementations of ctframework interfaces. Derived classes sl@0: * inherit from this and also implement the appropriate interface. sl@0: * sl@0: * It provides asynchronous functionality for sending requests to the filetokens sl@0: * server and processing the responses. sl@0: * sl@0: * Some methods are const so they can be called by the cert apps client, whose sl@0: * interface contains several const methods. These methods need to create sl@0: * internal buffers, and this leads to iRequestDataBuf and iRequestPtr being sl@0: * mutable. sl@0: */ sl@0: NONSHARABLE_CLASS(CFSClient) : public CActive sl@0: { sl@0: public: sl@0: virtual ~CFSClient(); sl@0: sl@0: protected: sl@0: CFSClient(TInt aUID, MCTToken& aToken, RFileStoreClientSession& aClient); sl@0: TInt AllocRequestBuffer(TInt aReqdSize) const; sl@0: void FreeRequestBuffer() const; sl@0: void SendSyncRequestAndHandleOverflowL(TFSTokenMessages aMessage, sl@0: TInt aInitialBufSize, sl@0: const TIpcArgs& aArgs) const; sl@0: sl@0: protected: sl@0: // From CActive sl@0: virtual void DoCancel(); sl@0: virtual TInt RunError(TInt aError); sl@0: sl@0: protected: sl@0: /** sl@0: * Maintains state for async requests to filetokens server, and completes sl@0: * caller when required. sl@0: */ sl@0: class TAsyncRequest sl@0: { sl@0: public: sl@0: void operator()(TFSTokenMessages aRequest, TRequestStatus* aStatus); sl@0: void Complete(TInt aCompletionResult); sl@0: void Cancel(); sl@0: inline TFSTokenMessages OutstandingRequest() { return iRequest; } sl@0: public: sl@0: ~TAsyncRequest(); sl@0: private: sl@0: TFSTokenMessages iRequest; sl@0: TRequestStatus* iClientStatus; sl@0: }; sl@0: sl@0: TAsyncRequest iCurrentRequest; ///< The outstanding server request sl@0: sl@0: private: sl@0: mutable HBufC8* iRequestDataBuf; ///< Buffer for messages passed to the server sl@0: sl@0: protected: sl@0: MCTToken& iToken; ///< The token we belong to sl@0: TInt iInterfaceUID; ///< UID of the cryptoken interface we implement sl@0: RFileStoreClientSession& iClient; ///< Client session object for sending messages to the server sl@0: mutable TPtr8 iRequestPtr; ///< Buffer pointer for derived classes to use sl@0: }; sl@0: sl@0: #endif // __CFSCLIENT_H__