os/security/cryptoservices/filebasedcertificateandkeystores/source/certapps/client/CFSCertAppsClient.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/filebasedcertificateandkeystores/source/certapps/client/CFSCertAppsClient.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,116 @@
1.4 +/*
1.5 +* Copyright (c) 2002-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 "CFSCertAppsClient.h"
1.23 +#include "fsmarshaller.h"
1.24 +#include "clientutils.h"
1.25 +#include "clientsession.h"
1.26 +#include <certificateapps.h>
1.27 +
1.28 +const TInt KDefaultBufferSize = 256;
1.29 +
1.30 +MCTTokenInterface* CFSCertAppsClient::NewInterfaceL(MCTToken& aToken,
1.31 + RFileStoreClientSession& aClient)
1.32 + {
1.33 + // Destroyed by MCTTokenInterface::DoRelease() (no refcounting)
1.34 + return new (ELeave) CFSCertAppsClient(KInterfaceCertApps, aToken, aClient);
1.35 + }
1.36 +
1.37 +CFSCertAppsClient::CFSCertAppsClient(TInt aUID,
1.38 + MCTToken& aToken,
1.39 + RFileStoreClientSession& aClient) :
1.40 + CFSClient(aUID, aToken, aClient)
1.41 + {
1.42 + }
1.43 +
1.44 +CFSCertAppsClient::~CFSCertAppsClient()
1.45 + {
1.46 + }
1.47 +
1.48 +void CFSCertAppsClient::DoRelease()
1.49 + {
1.50 + MCTTokenInterface::DoRelease();
1.51 + }
1.52 +
1.53 +MCTToken& CFSCertAppsClient::Token()
1.54 + {
1.55 + return iToken;
1.56 + }
1.57 +
1.58 +void CFSCertAppsClient::RunL()
1.59 + {
1.60 + // RunL should never get called
1.61 + __ASSERT_DEBUG(EFalse, FSTokenPanic(EInvalidRequest));
1.62 + }
1.63 +
1.64 +void CFSCertAppsClient::AddL(const TCertificateAppInfo& aClient)
1.65 + {
1.66 + // Package up the certificate app info into a buffer. It is
1.67 + // then sent as the second parameter (index 1)
1.68 + TPckgC<TCertificateAppInfo> pckg(aClient);
1.69 + User::LeaveIfError(iClient.SendRequest(EAddApp, TIpcArgs(0, &pckg)));
1.70 + }
1.71 +
1.72 +void CFSCertAppsClient::RemoveL(const TUid& aUid)
1.73 + {
1.74 + // Package up Uid
1.75 + TPckgC<TUid> pckg(aUid);
1.76 + User::LeaveIfError(iClient.SendRequest(ERemoveApp, TIpcArgs(0, &pckg)));
1.77 + }
1.78 +
1.79 +TInt CFSCertAppsClient::ApplicationCountL() const
1.80 + {
1.81 + // Parameter is a package of TInt which is returned from the server
1.82 + TInt appCount = 0;
1.83 + TPckg<TInt> pckg(appCount);
1.84 + User::LeaveIfError(iClient.SendRequest(EGetAppCount, TIpcArgs(0, &pckg)));
1.85 + return appCount;
1.86 + }
1.87 +
1.88 +void CFSCertAppsClient::ApplicationsL(RArray<TCertificateAppInfo>& aAppArray) const
1.89 + {
1.90 + // This message contains the following parameters:
1.91 + // Param2: [OUT] TDes8 - The buffer to write into; if buffer size too
1.92 + // small then will return KErrOverflow with param 2 being
1.93 + // required size
1.94 +
1.95 + TRAPD(err, DoApplicationsL(aAppArray));
1.96 + FreeRequestBuffer();
1.97 + User::LeaveIfError(err);
1.98 + }
1.99 +
1.100 +void CFSCertAppsClient::DoApplicationsL(RArray<TCertificateAppInfo>& aAppArray) const
1.101 + {
1.102 + TIpcArgs args(0, 0, &iRequestPtr);
1.103 + SendSyncRequestAndHandleOverflowL(EGetApps, KDefaultBufferSize, args);
1.104 + TokenDataMarshaller::ReadL(iRequestPtr, aAppArray);
1.105 + }
1.106 +
1.107 +void CFSCertAppsClient::ApplicationL(const TUid& aUid, TCertificateAppInfo& aInfo) const
1.108 + {
1.109 + // The parameters for the ApplicationL function are as follows:
1.110 + // Param1: [IN] TUid - The Uid of the app to retrieve
1.111 + // Param2: [OUT] TCertificateAppInfo - The app info returned
1.112 +
1.113 + // Package everything up and ship them
1.114 + TPckgC<TUid> pckgUid(aUid);
1.115 + TPckg<TCertificateAppInfo> pckgInfo(aInfo);
1.116 +
1.117 + TIpcArgs args(0, &pckgUid, &pckgInfo);
1.118 + User::LeaveIfError(iClient.SendRequest(EGetApplication, args));
1.119 + }