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