cryptoservices/filebasedcertificateandkeystores/source/generic/client/CFStokenclient.cpp
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 #include "CFStokenclient.h"
       
    20 #include "clientutils.h"
       
    21 #include "clientfactories.h"
       
    22 
       
    23 // Information strings returned by MCTToken::Information()
       
    24 _LIT(KVersion, "1.00");
       
    25 _LIT(KSerialNo, "0");
       
    26 _LIT(KManufacturer, "Symbian Ltd.");
       
    27 
       
    28 MCTToken* CFSTokenClient::NewL(ETokenEnum aTokenTypeVal, MCTTokenType* aTokenType, RFileStoreClientSession& aClient)
       
    29 {
       
    30 	__ASSERT_DEBUG(aTokenType, FSTokenPanic(EBadArgument));
       
    31 
       
    32 //	Destroyed by MCTToken::Release() (refcounted)
       
    33 	CFSTokenClient* me = new (ELeave) CFSTokenClient(aTokenTypeVal, aTokenType, aClient);
       
    34 	return (static_cast<MCTToken*>(me));
       
    35 }
       
    36 
       
    37 CFSTokenClient::CFSTokenClient(ETokenEnum aTokenTypeVal, MCTTokenType* aTokenType, RFileStoreClientSession& aClient)
       
    38 :	iTokenEnum(aTokenTypeVal),
       
    39 	iTokenType(aTokenType),
       
    40 	iRefCount(0),
       
    41 	iClient(aClient)
       
    42 {
       
    43     ASSERT(iTokenEnum < ETotalTokensSupported);
       
    44 }
       
    45 
       
    46 MCTTokenType& CFSTokenClient::TokenType()
       
    47 {
       
    48 	__ASSERT_DEBUG(iTokenType, FSTokenPanic(ENotInitialised));
       
    49 	return (*iTokenType);
       
    50 }
       
    51 
       
    52 const TDesC& CFSTokenClient::Label()
       
    53 {
       
    54     RSupportedTokensArray supportedTokens;
       
    55 	const TDesC* token = supportedTokens[iTokenEnum];
       
    56 	return (*token);
       
    57 }
       
    58 
       
    59 TCTTokenHandle CFSTokenClient::Handle()
       
    60 {
       
    61 	__ASSERT_DEBUG(iTokenType, FSTokenPanic(ENotInitialised));
       
    62 	return (TCTTokenHandle(iTokenType->Type(), iTokenEnum));
       
    63 }
       
    64 
       
    65 TInt& CFSTokenClient::ReferenceCount()
       
    66 {
       
    67 	return (iRefCount);
       
    68 }
       
    69 
       
    70 void CFSTokenClient::DoGetInterface(TUid aRequiredInterface, MCTTokenInterface*& aReturnedInterface, TRequestStatus& aStatus)
       
    71 	{
       
    72 	// No longer calls server to get the interface - just creates a client object of the appropriate type
       
    73 	
       
    74 	aReturnedInterface = NULL;
       
    75 	TRAPD(result, aReturnedInterface = CClientInterfaceFactory::ClientInterfaceL(aRequiredInterface.iUid, *this, iClient));
       
    76 	if (result != KErrNone)
       
    77 		{
       
    78 		Release();
       
    79 		}
       
    80 	
       
    81 	//	Complete the TRequestStatus here since not asynchronous
       
    82 	TRequestStatus* status = &aStatus;
       
    83 	User::RequestComplete(status, result);		
       
    84 	}
       
    85 
       
    86 TBool CFSTokenClient::DoCancelGetInterface()
       
    87 {//	Not an asynchronous call for current file store, so nothing to do
       
    88 	return (EFalse);
       
    89 }
       
    90 
       
    91 const TDesC& CFSTokenClient::Information(TTokenInformation aRequiredInformation)
       
    92 	{
       
    93 	switch (aRequiredInformation)
       
    94 		{
       
    95 		case EVersion:
       
    96 			return KVersion;
       
    97 
       
    98 		case ESerialNo:
       
    99 			return KSerialNo;
       
   100 
       
   101 		case EManufacturer:
       
   102 			return KManufacturer;
       
   103 		
       
   104 		default:
       
   105 			FSTokenPanic(EBadArgument);
       
   106 		}
       
   107 	
       
   108 	return KNullDesC;
       
   109 	}