Update contrib.
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include <swicertstore.h>
20 #include "CSWICertStoreImpl.h"
21 #include "CSWICertStoreToken.h"
22 #include "CSWICertStoreTokenType.h"
24 _LIT(KSWICertStorePanic, "CSWICertStore");
26 EXPORT_C CCTTokenType* CSWICertStore::CreateTokenTypeL()
28 // This method is just here so we don't have to declare
29 // CSWICertStoreTokenType in the exported header
30 return CSWICertStoreTokenType::NewL();
33 EXPORT_C CSWICertStore* CSWICertStore::NewL(RFs& aFs)
35 // This method relies on the fact that we know the implementation of the swi
36 // cert store token type is synchronous
39 MCTTokenType* tokenType = CSWICertStoreTokenType::NewL(aFs);
40 CleanupReleasePushL(*tokenType);
44 MCTToken* token = NULL;
45 TUid tokenTypeUid = { KSWICertStoreTokenTypeUid };
46 TCTTokenHandle tokenHandle(tokenTypeUid, CSWICertStoreTokenType::ESWICertStore);
47 tokenType->OpenToken(tokenHandle, token, stat);
48 User::WaitForRequest(stat);
49 User::LeaveIfError(stat.Int());
50 CleanupReleasePushL(*token);
53 MCTTokenInterface* tokenIf = NULL;
54 token->GetInterface(TUid::Uid(KInterfaceCertStore), tokenIf, stat);
55 User::WaitForRequest(stat);
56 User::LeaveIfError(stat.Int());
58 __ASSERT_ALWAYS(tokenIf, User::Panic(KSWICertStorePanic, 1));
60 // Release token and token type
61 CleanupStack::PopAndDestroy(2, tokenType);
63 return static_cast<CSWICertStore*>(tokenIf);
66 CSWICertStore* CSWICertStore::NewL(CSWICertStoreToken& aToken, RFs& aFs)
68 CSWICertStore* self = new (ELeave) CSWICertStore(aToken);
69 CleanupStack::PushL(self);
70 self->ConstructL(aFs);
71 CleanupStack::Pop(self);
75 CSWICertStore::CSWICertStore(CSWICertStoreToken& aToken) :
80 void CSWICertStore::ConstructL(RFs& aFs)
82 iImpl = CSWICertStoreImpl::NewL(iToken, aFs);
85 void CSWICertStore::DoRelease()
87 if (iToken.ReleaseInterface())
93 CSWICertStore::~CSWICertStore()
98 MCTToken& CSWICertStore::Token()
103 void CSWICertStore::List(RMPointerArray<CCTCertInfo>& aCerts,
104 const CCertAttributeFilter& aFilter,
105 TRequestStatus& aStatus)
107 TRAPD(err, iImpl->ListL(aCerts, aFilter));
108 TRequestStatus* status = &aStatus;
109 User::RequestComplete(status, err);
112 void CSWICertStore::CancelList()
116 void CSWICertStore::GetCert(CCTCertInfo*& aCertInfo,
117 const TCTTokenObjectHandle& aHandle,
118 TRequestStatus& aStatus)
120 TRAPD(err, aCertInfo = iImpl->GetCertL(aHandle));
121 TRequestStatus* status = &aStatus;
122 User::RequestComplete(status, err);
125 void CSWICertStore::CancelGetCert()
129 void CSWICertStore::Applications(const CCTCertInfo& aCertInfo,
130 RArray<TUid>& aApplications,
131 TRequestStatus& aStatus)
133 TRAPD(err, iImpl->ApplicationsL(aCertInfo.Handle(), aApplications));
134 TRequestStatus* status = &aStatus;
135 User::RequestComplete(status, err);
138 void CSWICertStore::CancelApplications()
142 void CSWICertStore::IsApplicable(const CCTCertInfo& aCertInfo,
144 TBool& aIsApplicable,
145 TRequestStatus& aStatus)
147 TRAPD(err, aIsApplicable = iImpl->IsApplicableL(aCertInfo.Handle(), aApplication));
148 TRequestStatus* status = &aStatus;
149 User::RequestComplete(status, err);
152 void CSWICertStore::CancelIsApplicable()
156 void CSWICertStore::Trusted(const CCTCertInfo& aCertInfo,
158 TRequestStatus& aStatus)
160 TRAPD(err, aTrusted = iImpl->TrustedL(aCertInfo.Handle()));
161 TRequestStatus* status = &aStatus;
162 User::RequestComplete(status, err);
165 void CSWICertStore::CancelTrusted()
169 void CSWICertStore::Retrieve(const CCTCertInfo& aCertInfo,
171 TRequestStatus& aStatus)
173 TRAPD(err, iImpl->RetrieveL(aCertInfo.Handle(), aEncodedCert));
174 TRequestStatus* status = &aStatus;
175 User::RequestComplete(status, err);
178 void CSWICertStore::CancelRetrieve()
182 EXPORT_C const TCertMetaInfo& CSWICertStore::CertMetaInfoL(const CCTCertInfo& aCertInfo)
184 return iImpl->CertMetaInfoL(aCertInfo.Handle());