os/security/cryptoservices/filebasedcertificateandkeystores/source/generic/client/CFStokenclient.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#include "CFStokenclient.h"
sl@0
    20
#include "clientutils.h"
sl@0
    21
#include "clientfactories.h"
sl@0
    22
sl@0
    23
// Information strings returned by MCTToken::Information()
sl@0
    24
_LIT(KVersion, "1.00");
sl@0
    25
_LIT(KSerialNo, "0");
sl@0
    26
_LIT(KManufacturer, "Nokia Corporation and/or its subsidiary(-ies).");
sl@0
    27
sl@0
    28
MCTToken* CFSTokenClient::NewL(ETokenEnum aTokenTypeVal, MCTTokenType* aTokenType, RFileStoreClientSession& aClient)
sl@0
    29
{
sl@0
    30
	__ASSERT_DEBUG(aTokenType, FSTokenPanic(EBadArgument));
sl@0
    31
sl@0
    32
//	Destroyed by MCTToken::Release() (refcounted)
sl@0
    33
	CFSTokenClient* me = new (ELeave) CFSTokenClient(aTokenTypeVal, aTokenType, aClient);
sl@0
    34
	return (static_cast<MCTToken*>(me));
sl@0
    35
}
sl@0
    36
sl@0
    37
CFSTokenClient::CFSTokenClient(ETokenEnum aTokenTypeVal, MCTTokenType* aTokenType, RFileStoreClientSession& aClient)
sl@0
    38
:	iTokenEnum(aTokenTypeVal),
sl@0
    39
	iTokenType(aTokenType),
sl@0
    40
	iRefCount(0),
sl@0
    41
	iClient(aClient)
sl@0
    42
{
sl@0
    43
    ASSERT(iTokenEnum < ETotalTokensSupported);
sl@0
    44
}
sl@0
    45
sl@0
    46
MCTTokenType& CFSTokenClient::TokenType()
sl@0
    47
{
sl@0
    48
	__ASSERT_DEBUG(iTokenType, FSTokenPanic(ENotInitialised));
sl@0
    49
	return (*iTokenType);
sl@0
    50
}
sl@0
    51
sl@0
    52
const TDesC& CFSTokenClient::Label()
sl@0
    53
{
sl@0
    54
    RSupportedTokensArray supportedTokens;
sl@0
    55
	const TDesC* token = supportedTokens[iTokenEnum];
sl@0
    56
	return (*token);
sl@0
    57
}
sl@0
    58
sl@0
    59
TCTTokenHandle CFSTokenClient::Handle()
sl@0
    60
{
sl@0
    61
	__ASSERT_DEBUG(iTokenType, FSTokenPanic(ENotInitialised));
sl@0
    62
	return (TCTTokenHandle(iTokenType->Type(), iTokenEnum));
sl@0
    63
}
sl@0
    64
sl@0
    65
TInt& CFSTokenClient::ReferenceCount()
sl@0
    66
{
sl@0
    67
	return (iRefCount);
sl@0
    68
}
sl@0
    69
sl@0
    70
void CFSTokenClient::DoGetInterface(TUid aRequiredInterface, MCTTokenInterface*& aReturnedInterface, TRequestStatus& aStatus)
sl@0
    71
	{
sl@0
    72
	// No longer calls server to get the interface - just creates a client object of the appropriate type
sl@0
    73
	
sl@0
    74
	aReturnedInterface = NULL;
sl@0
    75
	TRAPD(result, aReturnedInterface = CClientInterfaceFactory::ClientInterfaceL(aRequiredInterface.iUid, *this, iClient));
sl@0
    76
	if (result != KErrNone)
sl@0
    77
		{
sl@0
    78
		Release();
sl@0
    79
		}
sl@0
    80
	
sl@0
    81
	//	Complete the TRequestStatus here since not asynchronous
sl@0
    82
	TRequestStatus* status = &aStatus;
sl@0
    83
	User::RequestComplete(status, result);		
sl@0
    84
	}
sl@0
    85
sl@0
    86
TBool CFSTokenClient::DoCancelGetInterface()
sl@0
    87
{//	Not an asynchronous call for current file store, so nothing to do
sl@0
    88
	return (EFalse);
sl@0
    89
}
sl@0
    90
sl@0
    91
const TDesC& CFSTokenClient::Information(TTokenInformation aRequiredInformation)
sl@0
    92
	{
sl@0
    93
	switch (aRequiredInformation)
sl@0
    94
		{
sl@0
    95
		case EVersion:
sl@0
    96
			return KVersion;
sl@0
    97
sl@0
    98
		case ESerialNo:
sl@0
    99
			return KSerialNo;
sl@0
   100
sl@0
   101
		case EManufacturer:
sl@0
   102
			return KManufacturer;
sl@0
   103
		
sl@0
   104
		default:
sl@0
   105
			FSTokenPanic(EBadArgument);
sl@0
   106
		}
sl@0
   107
	
sl@0
   108
	return KNullDesC;
sl@0
   109
	}