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