|
1 /* |
|
2 * Copyright (c) 2004-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 "CSWICertStoreToken.h" |
|
20 #include "CSWICertStoreTokenType.h" |
|
21 #include <swicertstore.h> |
|
22 |
|
23 _LIT(KSWICertStoreTokenLabel, "SWI cert store"); |
|
24 _LIT(KSWICertStoreVersion, "1.00"); |
|
25 _LIT(KSWICertStoreSerialNo, "N/A"); |
|
26 _LIT(KSWICertStoreManufacturer, "Symbian Software Ltd."); |
|
27 |
|
28 CSWICertStoreToken::CSWICertStoreToken(CCTTokenType& aTokenType) : |
|
29 iTokenType(aTokenType) |
|
30 { |
|
31 } |
|
32 |
|
33 CSWICertStoreToken::~CSWICertStoreToken() |
|
34 { |
|
35 } |
|
36 |
|
37 MCTTokenType& CSWICertStoreToken::TokenType() |
|
38 { |
|
39 return iTokenType; |
|
40 } |
|
41 |
|
42 const TDesC& CSWICertStoreToken::Label() |
|
43 { |
|
44 return KSWICertStoreTokenLabel; |
|
45 } |
|
46 |
|
47 TCTTokenHandle CSWICertStoreToken::Handle() |
|
48 { |
|
49 TUid tokenTypeUid = { KSWICertStoreTokenTypeUid }; |
|
50 return TCTTokenHandle(tokenTypeUid, 0); |
|
51 } |
|
52 |
|
53 TInt& CSWICertStoreToken::ReferenceCount() |
|
54 { |
|
55 return iRefCount; |
|
56 } |
|
57 |
|
58 void CSWICertStoreToken::DoGetInterface(TUid aRequiredInterface, |
|
59 MCTTokenInterface*& aReturnedInterface, |
|
60 TRequestStatus& aStatus) |
|
61 { |
|
62 TInt result = KErrNone; |
|
63 |
|
64 if (aRequiredInterface.iUid != KInterfaceCertStore) |
|
65 { |
|
66 result = KErrNotSupported; |
|
67 } |
|
68 else |
|
69 { |
|
70 if (!iCertStore) |
|
71 { |
|
72 TRAP(result, iCertStore = CSWICertStore::NewL(*this, iTokenType.Fs())); |
|
73 } |
|
74 } |
|
75 |
|
76 if (result != KErrNone) |
|
77 { |
|
78 Release(); |
|
79 } |
|
80 else |
|
81 { |
|
82 ++iInterfaceRefCount; |
|
83 aReturnedInterface = static_cast<MCTCertStore*>(iCertStore); |
|
84 } |
|
85 |
|
86 TRequestStatus* stat = &aStatus; |
|
87 User::RequestComplete(stat, result); |
|
88 } |
|
89 |
|
90 TBool CSWICertStoreToken::DoCancelGetInterface() |
|
91 { |
|
92 return EFalse; |
|
93 } |
|
94 |
|
95 const TDesC& CSWICertStoreToken::Information(TTokenInformation aRequiredInformation) |
|
96 { |
|
97 //there is no support for localisation here |
|
98 switch (aRequiredInformation) |
|
99 { |
|
100 case EVersion: |
|
101 return KSWICertStoreVersion; |
|
102 |
|
103 case ESerialNo: |
|
104 return KSWICertStoreSerialNo; |
|
105 |
|
106 case EManufacturer: |
|
107 return KSWICertStoreManufacturer; |
|
108 |
|
109 default: |
|
110 return KNullDesC; |
|
111 } |
|
112 } |
|
113 |
|
114 TBool CSWICertStoreToken::ReleaseInterface() |
|
115 { |
|
116 // Decrement the interface's reference count and return whether it should be |
|
117 // deleted. Called by CSWICertStore's DoRelease method. |
|
118 |
|
119 TBool canDelete = --iInterfaceRefCount == 0; |
|
120 if (canDelete) |
|
121 { |
|
122 iCertStore = NULL; |
|
123 } |
|
124 return canDelete; |
|
125 } |