|
1 /* |
|
2 * Copyright (c) 2006 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 "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: Implementation of DevToken |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <e32debug.h> |
|
21 #include "DevToken.h" |
|
22 #include "DevTokenUtils.h" |
|
23 #include "DevTokenInterfaceFactory.h" |
|
24 #include "DevtokenLog.h" |
|
25 |
|
26 // Information strings returned by MCTToken::Information() |
|
27 _LIT(KVersion, "1.00"); |
|
28 _LIT(KSerialNo, "0"); |
|
29 _LIT(KManufacturer, "Nokia"); |
|
30 |
|
31 // ======== MEMBER FUNCTIONS ======== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // MCTToken* CDevToken::NewL() |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 MCTToken* CDevToken::NewL(EDevTokenEnum aTokenTypeVal, |
|
38 MCTTokenType* aTokenType, |
|
39 RDevTokenClientSession& aClient) |
|
40 { |
|
41 __ASSERT_DEBUG(aTokenType, DevTokenPanic(EBadArgument)); |
|
42 //Destroyed by MCTToken::Release() (refcounted) |
|
43 CDevToken* me = new (ELeave) CDevToken(aTokenTypeVal, aTokenType, aClient); |
|
44 return (static_cast<MCTToken*>(me)); |
|
45 } |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CDevToken::CDevToken() |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CDevToken::CDevToken(EDevTokenEnum aTokenTypeVal, MCTTokenType* aTokenType, RDevTokenClientSession& aClient) |
|
53 : iTokenEnum(aTokenTypeVal), |
|
54 iTokenType(aTokenType), |
|
55 iRefCount(0), |
|
56 iClientSession(aClient) |
|
57 { |
|
58 ASSERT(iTokenEnum < ETotalTokensSupported); |
|
59 } |
|
60 |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // MCTTokenType& CDevToken::TokenType() |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 MCTTokenType& CDevToken::TokenType() |
|
67 { |
|
68 __ASSERT_DEBUG(iTokenType, DevTokenPanic(ENotInitialised)); |
|
69 return (*iTokenType); |
|
70 } |
|
71 |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // const TDesC& CDevToken::Label() |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 const TDesC& CDevToken::Label() |
|
78 { |
|
79 RSupportedTokensArray supportedTokens; |
|
80 const TDesC* token = supportedTokens[iTokenEnum]; |
|
81 return (*token); |
|
82 } |
|
83 |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // TCTTokenHandle CDevToken::Handle() |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 TCTTokenHandle CDevToken::Handle() |
|
90 { |
|
91 __ASSERT_DEBUG(iTokenType, DevTokenPanic(ENotInitialised)); |
|
92 return (TCTTokenHandle(iTokenType->Type(), iTokenEnum)); |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // TInt& CDevToken::ReferenceCount() |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 TInt& CDevToken::ReferenceCount() |
|
101 { |
|
102 return (iRefCount); |
|
103 } |
|
104 |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CDevToken::DoGetInterface() |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CDevToken::DoGetInterface(TUid aRequiredInterface, |
|
111 MCTTokenInterface*& aReturnedInterface, |
|
112 TRequestStatus& aStatus) |
|
113 { |
|
114 // No longer calls server to get the interface - just creates a client object of the appropriate type |
|
115 TRACE_PRINT("--> DoGetInterface 1"); |
|
116 aReturnedInterface = NULL; |
|
117 TRAPD(result, aReturnedInterface = DevTokenInterfaceFactory::ClientInterfaceL(aRequiredInterface.iUid, *this, iClientSession)); |
|
118 TRACE_PRINT("--> DoGetInterface 2") |
|
119 if (result != KErrNone) |
|
120 { |
|
121 TRACE_PRINT("-->DoGetInterface 3") |
|
122 Release(); |
|
123 } |
|
124 |
|
125 //Complete the TRequestStatus here since not asynchronous |
|
126 TRequestStatus* status = &aStatus; |
|
127 User::RequestComplete(status, result); |
|
128 } |
|
129 |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // TBool CDevToken::DoCancelGetInterface() |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 TBool CDevToken::DoCancelGetInterface() |
|
136 {//Not an asynchronous call for current file store, so nothing to do |
|
137 return (EFalse); |
|
138 } |
|
139 |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CDevToken::Information(TTokenInformation aRequiredInformation) |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 const TDesC& CDevToken::Information(TTokenInformation aRequiredInformation) |
|
146 { |
|
147 switch ( aRequiredInformation ) |
|
148 { |
|
149 case EVersion: |
|
150 return KVersion; |
|
151 |
|
152 case ESerialNo: |
|
153 return KSerialNo; |
|
154 |
|
155 case EManufacturer: |
|
156 return KManufacturer; |
|
157 |
|
158 default: |
|
159 DevTokenPanic(EBadArgument); |
|
160 } |
|
161 |
|
162 return KNullDesC; |
|
163 } |
|
164 |
|
165 //EOF |
|
166 |