os/security/cryptoservices/filebasedcertificateandkeystores/source/certapps/client/CFSCertAppsClient.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) 2002-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 "CFSCertAppsClient.h"
sl@0
    20
#include "fsmarshaller.h"
sl@0
    21
#include "clientutils.h"
sl@0
    22
#include "clientsession.h"
sl@0
    23
#include <certificateapps.h>
sl@0
    24
sl@0
    25
const TInt KDefaultBufferSize = 256;
sl@0
    26
sl@0
    27
MCTTokenInterface* CFSCertAppsClient::NewInterfaceL(MCTToken& aToken, 
sl@0
    28
													RFileStoreClientSession& aClient)
sl@0
    29
	{
sl@0
    30
	// Destroyed by MCTTokenInterface::DoRelease() (no refcounting)
sl@0
    31
	return new (ELeave) CFSCertAppsClient(KInterfaceCertApps, aToken, aClient);
sl@0
    32
	}
sl@0
    33
sl@0
    34
CFSCertAppsClient::CFSCertAppsClient(TInt aUID,
sl@0
    35
									 MCTToken& aToken, 
sl@0
    36
									 RFileStoreClientSession& aClient) :
sl@0
    37
	CFSClient(aUID, aToken, aClient)	
sl@0
    38
	{
sl@0
    39
	}
sl@0
    40
sl@0
    41
CFSCertAppsClient::~CFSCertAppsClient()
sl@0
    42
	{
sl@0
    43
	}
sl@0
    44
sl@0
    45
void CFSCertAppsClient::DoRelease()
sl@0
    46
	{
sl@0
    47
	MCTTokenInterface::DoRelease();
sl@0
    48
	}
sl@0
    49
sl@0
    50
MCTToken& CFSCertAppsClient::Token()
sl@0
    51
	{
sl@0
    52
	return iToken;
sl@0
    53
	}
sl@0
    54
sl@0
    55
void CFSCertAppsClient::RunL()
sl@0
    56
	{
sl@0
    57
	// RunL should never get called
sl@0
    58
	__ASSERT_DEBUG(EFalse, FSTokenPanic(EInvalidRequest));
sl@0
    59
	}
sl@0
    60
sl@0
    61
void CFSCertAppsClient::AddL(const TCertificateAppInfo& aClient)
sl@0
    62
	{
sl@0
    63
	// Package up the certificate app info into a buffer. It is 
sl@0
    64
	// then sent as the second parameter (index 1)
sl@0
    65
	TPckgC<TCertificateAppInfo> pckg(aClient);
sl@0
    66
	User::LeaveIfError(iClient.SendRequest(EAddApp, TIpcArgs(0, &pckg)));
sl@0
    67
	}
sl@0
    68
sl@0
    69
void CFSCertAppsClient::RemoveL(const TUid& aUid)
sl@0
    70
	{
sl@0
    71
	// Package up Uid
sl@0
    72
	TPckgC<TUid> pckg(aUid);
sl@0
    73
	User::LeaveIfError(iClient.SendRequest(ERemoveApp, TIpcArgs(0, &pckg)));
sl@0
    74
	}
sl@0
    75
sl@0
    76
TInt CFSCertAppsClient::ApplicationCountL() const
sl@0
    77
	{
sl@0
    78
	// Parameter is a package of TInt which is returned from the server
sl@0
    79
	TInt appCount = 0;
sl@0
    80
	TPckg<TInt> pckg(appCount);
sl@0
    81
	User::LeaveIfError(iClient.SendRequest(EGetAppCount, TIpcArgs(0, &pckg)));
sl@0
    82
	return appCount;
sl@0
    83
	}
sl@0
    84
sl@0
    85
void CFSCertAppsClient::ApplicationsL(RArray<TCertificateAppInfo>& aAppArray) const
sl@0
    86
	{
sl@0
    87
	// This message contains the following parameters:
sl@0
    88
	// Param2: [OUT] TDes8 - The buffer to write into; if buffer size too
sl@0
    89
	//               small then will return KErrOverflow with param 2 being 
sl@0
    90
	//               required size
sl@0
    91
sl@0
    92
	TRAPD(err, DoApplicationsL(aAppArray));
sl@0
    93
	FreeRequestBuffer();
sl@0
    94
	User::LeaveIfError(err);
sl@0
    95
	}
sl@0
    96
sl@0
    97
void CFSCertAppsClient::DoApplicationsL(RArray<TCertificateAppInfo>& aAppArray) const
sl@0
    98
	{
sl@0
    99
	TIpcArgs args(0, 0, &iRequestPtr);
sl@0
   100
	SendSyncRequestAndHandleOverflowL(EGetApps, KDefaultBufferSize, args);
sl@0
   101
	TokenDataMarshaller::ReadL(iRequestPtr, aAppArray);
sl@0
   102
	}
sl@0
   103
sl@0
   104
void CFSCertAppsClient::ApplicationL(const TUid& aUid, TCertificateAppInfo& aInfo) const
sl@0
   105
	{
sl@0
   106
	// The parameters for the ApplicationL function are as follows:
sl@0
   107
	// Param1: [IN] TUid - The Uid of the app to retrieve
sl@0
   108
	// Param2: [OUT] TCertificateAppInfo - The app info returned
sl@0
   109
sl@0
   110
	// Package everything up and ship them
sl@0
   111
	TPckgC<TUid> pckgUid(aUid);
sl@0
   112
	TPckg<TCertificateAppInfo> pckgInfo(aInfo);
sl@0
   113
sl@0
   114
	TIpcArgs args(0, &pckgUid, &pckgInfo);
sl@0
   115
	User::LeaveIfError(iClient.SendRequest(EGetApplication, args));
sl@0
   116
	}