cryptoservices/filebasedcertificateandkeystores/test/thwkeystore/client/thwtokentypeclient.cpp
changeset 15 da2ae96f639b
equal deleted inserted replaced
10:afc583cfa176 15:da2ae96f639b
       
     1 /*
       
     2 * Copyright (c) 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 "thwtokentypeclient.h"
       
    20 #include "thwtokenclient.h"
       
    21 
       
    22 _LIT(KTokenDesc, "Default Token");
       
    23 	
       
    24 CCTTokenType* CHardwareTokenTypeClient::NewL()
       
    25 	{
       
    26 	//	Destroyed by call to CCTTokenType::Release (refcounted)
       
    27 	CHardwareTokenTypeClient* self = new (ELeave) CHardwareTokenTypeClient();
       
    28 	CleanupStack::PushL(self);
       
    29 	self->ConstructL();
       
    30 	CleanupStack::Pop(self);
       
    31 
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 CHardwareTokenTypeClient::CHardwareTokenTypeClient()
       
    36 	{
       
    37 	}
       
    38 
       
    39 CHardwareTokenTypeClient::~CHardwareTokenTypeClient()
       
    40 	{
       
    41 	}
       
    42 
       
    43 void CHardwareTokenTypeClient::ConstructL()
       
    44 	{
       
    45 	}
       
    46 	
       
    47 void CHardwareTokenTypeClient::List(RCPointerArray<HBufC>& aTokens, TRequestStatus& aStatus)
       
    48 	{
       
    49 	HBufC* name = NULL;
       
    50 	TRAPD(err, name = KTokenDesc().AllocL());
       
    51 	
       
    52 	if(KErrNone == err)
       
    53 		{
       
    54 		err = aTokens.Append(name);
       
    55 		}
       
    56 
       
    57 	if(KErrNone != err)
       
    58 		{
       
    59 		delete name;
       
    60 		}
       
    61 	
       
    62 	TRequestStatus* status = &aStatus;
       
    63 	User::RequestComplete(status, err);
       
    64 	}
       
    65 
       
    66 void CHardwareTokenTypeClient::CancelList()
       
    67 	{
       
    68 	// implementation not asynchronous
       
    69 	}
       
    70 
       
    71 void CHardwareTokenTypeClient::OpenToken(const TDesC& /*aTokenInfo*/, MCTToken*& aToken, TRequestStatus& aStatus)
       
    72 	{
       
    73 	// Token Information not used. TokenClient will be created for all tokeninfo
       
    74 	aToken = NULL;
       
    75 	TRAPD(err, aToken = CHardwareTokenClient::NewL(this));
       
    76 
       
    77 	//	Token opened, increment our reference count
       
    78 	if(err == KErrNone)
       
    79 		{
       
    80 		IncReferenceCount();
       
    81 		}
       
    82 
       
    83 	TRequestStatus* status = &aStatus;
       
    84 	User::RequestComplete(status, err);
       
    85 	}
       
    86 
       
    87 void CHardwareTokenTypeClient::OpenToken(TCTTokenHandle /*aHandle*/, MCTToken*& aToken, TRequestStatus& aStatus)
       
    88 	{
       
    89 	aToken = NULL;
       
    90 	TRAPD(err, aToken = CHardwareTokenClient::NewL(this));
       
    91 
       
    92 	//	Token opened, increment our reference count
       
    93 	if(NULL != aToken)
       
    94 		{
       
    95 		IncReferenceCount();
       
    96 		}
       
    97 
       
    98 	TRequestStatus* status = &aStatus;
       
    99 	User::RequestComplete(status, err);
       
   100 	}
       
   101 
       
   102 void CHardwareTokenTypeClient::CancelOpenToken()
       
   103 	{
       
   104 	// implementation not asynchronous
       
   105 	}