os/security/cryptoservices/filebasedcertificateandkeystores/source/generic/client/CFStokenclient.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/filebasedcertificateandkeystores/source/generic/client/CFStokenclient.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,109 @@
1.4 +/*
1.5 +* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include "CFStokenclient.h"
1.23 +#include "clientutils.h"
1.24 +#include "clientfactories.h"
1.25 +
1.26 +// Information strings returned by MCTToken::Information()
1.27 +_LIT(KVersion, "1.00");
1.28 +_LIT(KSerialNo, "0");
1.29 +_LIT(KManufacturer, "Nokia Corporation and/or its subsidiary(-ies).");
1.30 +
1.31 +MCTToken* CFSTokenClient::NewL(ETokenEnum aTokenTypeVal, MCTTokenType* aTokenType, RFileStoreClientSession& aClient)
1.32 +{
1.33 + __ASSERT_DEBUG(aTokenType, FSTokenPanic(EBadArgument));
1.34 +
1.35 +// Destroyed by MCTToken::Release() (refcounted)
1.36 + CFSTokenClient* me = new (ELeave) CFSTokenClient(aTokenTypeVal, aTokenType, aClient);
1.37 + return (static_cast<MCTToken*>(me));
1.38 +}
1.39 +
1.40 +CFSTokenClient::CFSTokenClient(ETokenEnum aTokenTypeVal, MCTTokenType* aTokenType, RFileStoreClientSession& aClient)
1.41 +: iTokenEnum(aTokenTypeVal),
1.42 + iTokenType(aTokenType),
1.43 + iRefCount(0),
1.44 + iClient(aClient)
1.45 +{
1.46 + ASSERT(iTokenEnum < ETotalTokensSupported);
1.47 +}
1.48 +
1.49 +MCTTokenType& CFSTokenClient::TokenType()
1.50 +{
1.51 + __ASSERT_DEBUG(iTokenType, FSTokenPanic(ENotInitialised));
1.52 + return (*iTokenType);
1.53 +}
1.54 +
1.55 +const TDesC& CFSTokenClient::Label()
1.56 +{
1.57 + RSupportedTokensArray supportedTokens;
1.58 + const TDesC* token = supportedTokens[iTokenEnum];
1.59 + return (*token);
1.60 +}
1.61 +
1.62 +TCTTokenHandle CFSTokenClient::Handle()
1.63 +{
1.64 + __ASSERT_DEBUG(iTokenType, FSTokenPanic(ENotInitialised));
1.65 + return (TCTTokenHandle(iTokenType->Type(), iTokenEnum));
1.66 +}
1.67 +
1.68 +TInt& CFSTokenClient::ReferenceCount()
1.69 +{
1.70 + return (iRefCount);
1.71 +}
1.72 +
1.73 +void CFSTokenClient::DoGetInterface(TUid aRequiredInterface, MCTTokenInterface*& aReturnedInterface, TRequestStatus& aStatus)
1.74 + {
1.75 + // No longer calls server to get the interface - just creates a client object of the appropriate type
1.76 +
1.77 + aReturnedInterface = NULL;
1.78 + TRAPD(result, aReturnedInterface = CClientInterfaceFactory::ClientInterfaceL(aRequiredInterface.iUid, *this, iClient));
1.79 + if (result != KErrNone)
1.80 + {
1.81 + Release();
1.82 + }
1.83 +
1.84 + // Complete the TRequestStatus here since not asynchronous
1.85 + TRequestStatus* status = &aStatus;
1.86 + User::RequestComplete(status, result);
1.87 + }
1.88 +
1.89 +TBool CFSTokenClient::DoCancelGetInterface()
1.90 +{// Not an asynchronous call for current file store, so nothing to do
1.91 + return (EFalse);
1.92 +}
1.93 +
1.94 +const TDesC& CFSTokenClient::Information(TTokenInformation aRequiredInformation)
1.95 + {
1.96 + switch (aRequiredInformation)
1.97 + {
1.98 + case EVersion:
1.99 + return KVersion;
1.100 +
1.101 + case ESerialNo:
1.102 + return KSerialNo;
1.103 +
1.104 + case EManufacturer:
1.105 + return KManufacturer;
1.106 +
1.107 + default:
1.108 + FSTokenPanic(EBadArgument);
1.109 + }
1.110 +
1.111 + return KNullDesC;
1.112 + }