pkiutilities/DeviceToken/Inc/DTClient.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2006 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 "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:   The header file of DTClient
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __DTCLIENT_H__
       
    21 #define __DTCLIENT_H__
       
    22 
       
    23 #include <e32base.h>
       
    24 #include "DevTokenCliServ.h"
       
    25 
       
    26 class MCTToken;
       
    27 class RDevTokenClientSession;
       
    28 
       
    29 /**
       
    30  * Base class for implementations of ctframework interfaces.  Derived classes
       
    31  * inherit from this and also implement the appropriate interface.
       
    32  * It provides asynchronous functionality for sending requests to the filetokens
       
    33  * server and processing the responses.
       
    34  * Some methods are const so they can be called by the cert apps client, whose
       
    35  * interface contains several const methods.  These methods need to create
       
    36  * internal buffers, and this leads to iRequestDataBuf and iRequestPtr being
       
    37  * mutable.
       
    38  *
       
    39  *  @lib DevTokenClient.dll
       
    40  *  @since S60 v3.2
       
    41  */
       
    42 class CDTClient : public CActive
       
    43     {
       
    44     public:
       
    45         virtual ~CDTClient();
       
    46 
       
    47     protected:
       
    48         
       
    49         CDTClient(TInt aUID, MCTToken& aToken, RDevTokenClientSession& aClient);
       
    50         
       
    51         TInt AllocRequestBuffer(TInt aReqdSize) const;
       
    52         
       
    53         void FreeRequestBuffer() const;
       
    54         
       
    55         void SendSyncRequestAndHandleOverflowL(TDevTokenMessages aMessage,
       
    56                                                TInt aInitialBufSize,
       
    57                                                const TIpcArgs& aArgs) const;
       
    58 
       
    59     protected:
       
    60         // From CActive
       
    61         virtual void DoCancel();  
       
    62         
       
    63         virtual TInt RunError(TInt aError);
       
    64 
       
    65     protected:
       
    66         /**
       
    67         * Maintains state for async requests to device tokens server, and completes
       
    68         * caller when required.
       
    69         */
       
    70         class TAsyncRequest
       
    71             {
       
    72             public:
       
    73                
       
    74                 void operator()(TDevTokenMessages aRequest, TRequestStatus* aStatus);
       
    75                
       
    76                 void Complete(TInt aCompletionResult);      
       
    77                
       
    78                 void Cancel();
       
    79                
       
    80                 inline TDevTokenMessages OutstandingRequest() { return iRequest; }
       
    81             
       
    82             public:
       
    83               
       
    84                 ~TAsyncRequest();
       
    85             
       
    86             private:
       
    87               
       
    88                 TDevTokenMessages iRequest;
       
    89               
       
    90                 TRequestStatus* iClientStatus;
       
    91             };
       
    92         
       
    93         //The outstanding server request
       
    94         TAsyncRequest iCurrentRequest;    
       
    95 
       
    96     private:
       
    97         //Buffer for messages passed to the server
       
    98         mutable HBufC8* iRequestDataBuf;    
       
    99     
       
   100     protected:
       
   101         // The token we belong to
       
   102         MCTToken& iToken;        
       
   103        
       
   104         // UID of the cryptoken interface we implement
       
   105         TInt iInterfaceUID;        
       
   106        
       
   107         // Client session object for sending messages to the server
       
   108         RDevTokenClientSession& iClientSession; 
       
   109        
       
   110         // Buffer pointer for derived classes to use
       
   111         mutable TPtr8 iRequestPtr;
       
   112     };
       
   113 
       
   114 #endif  //  __DTCLIENT_H__
       
   115 
       
   116 //EOF
       
   117