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