os/security/cryptoservices/filebasedcertificateandkeystores/test/ttestplugin/cdummytokenclient1.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/filebasedcertificateandkeystores/test/ttestplugin/cdummytokenclient1.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,95 @@
1.4 +/*
1.5 +* Copyright (c) 2006-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 "cdummytokenclient.h"
1.23 +#include "cdummykeystoreclient.h"
1.24 +
1.25 +_LIT(KTokenString, "Dummy KeyStore Manager1");
1.26 +
1.27 +
1.28 +MCTToken* CDummyTokenClient::NewL(MCTTokenType* aTokenType)
1.29 + {
1.30 + CDummyTokenClient* self = new (ELeave) CDummyTokenClient(aTokenType);
1.31 + return static_cast<MCTToken*>(self);
1.32 + }
1.33 +
1.34 +CDummyTokenClient::CDummyTokenClient(MCTTokenType* aTokenType)
1.35 + : iTokenType(aTokenType),
1.36 + iRefCount(0)
1.37 + {
1.38 + }
1.39 +
1.40 +MCTTokenType& CDummyTokenClient::TokenType()
1.41 + {
1.42 + return *iTokenType;
1.43 + }
1.44 +
1.45 +const TDesC& CDummyTokenClient::Label()
1.46 + {
1.47 + return KTokenString();
1.48 + }
1.49 +
1.50 +TCTTokenHandle CDummyTokenClient::Handle()
1.51 + {
1.52 + return (TCTTokenHandle(iTokenType->Type(), 0));
1.53 + }
1.54 +
1.55 +TInt& CDummyTokenClient::ReferenceCount()
1.56 + {
1.57 + return iRefCount;
1.58 + }
1.59 +
1.60 +void CDummyTokenClient::DoGetInterface(TUid aRequiredInterface, MCTTokenInterface*& aReturnedInterface, TRequestStatus& aStatus)
1.61 + {
1.62 + // No longer calls server to get the interface - just creates a client object of the appropriate type
1.63 + TUid userUid = {0x101F7334};
1.64 + #ifndef KEYSTORE_INTERFACE
1.65 + TUid managerUid = {0x101F7335};
1.66 + #endif // KEYSTORE_INTERFACE
1.67 +
1.68 + // Complete the TRequestStatus here since not asynchronous
1.69 + TRequestStatus* status = &aStatus;
1.70 + aReturnedInterface = NULL;
1.71 + TInt err = KErrGeneral;
1.72 +
1.73 + if(userUid == aRequiredInterface
1.74 + #ifndef KEYSTORE_INTERFACE
1.75 + || managerUid == aRequiredInterface
1.76 + #endif //KEYSTORE_INTERFACE
1.77 + )
1.78 + {
1.79 + TRAP(err, aReturnedInterface = CDummyKeyStoreClient::NewKeyStoreInterfaceL(*this));
1.80 + }
1.81 +
1.82 + if (NULL == aReturnedInterface)
1.83 + {
1.84 + Release();
1.85 + }
1.86 +
1.87 + User::RequestComplete(status, err);
1.88 + }
1.89 +
1.90 +TBool CDummyTokenClient::DoCancelGetInterface()
1.91 + {// Not an asynchronous call for current file store, so nothing to do
1.92 + return EFalse;
1.93 + }
1.94 +
1.95 +const TDesC& CDummyTokenClient::Information(TTokenInformation /*aRequiredInformation*/)
1.96 + {
1.97 + return KNullDesC;
1.98 + }