|
1 /* |
|
2 * Copyright (c) 2004 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: Dummy Token and TokenType for Client/Server |
|
15 * information interchange |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CWIMDUMMYTOKEN_H |
|
22 #define CWIMDUMMYTOKEN_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <ct.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CWimDummyTokenType; |
|
29 |
|
30 |
|
31 // CLASS DECLARATION |
|
32 |
|
33 /** |
|
34 * Class for token handling. |
|
35 * Messaging between WimClient and WimServer requires a reference to token, |
|
36 * which cannot be a null reference. Because the use of actual token is not |
|
37 * required and because it would consume memory for no reason, dummy token is |
|
38 * used. |
|
39 * |
|
40 * @lib WimUtil.lib |
|
41 * @since Series60 3.0 |
|
42 */ |
|
43 class CWimDummyToken : public CBase, public MCTToken |
|
44 { |
|
45 public: // Constructors and destructor |
|
46 |
|
47 /** |
|
48 * Two-phased constructor. |
|
49 */ |
|
50 static CWimDummyToken* NewL( MCTTokenType& aTokenType ); |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 virtual ~CWimDummyToken(); |
|
56 |
|
57 public: // New functions |
|
58 |
|
59 /** |
|
60 * Sets serial number to token |
|
61 * @param Serian number to be set |
|
62 */ |
|
63 void SetSerialNumber( TDesC& aSerialNumber ); |
|
64 |
|
65 public: // Functions from base class MCTToken |
|
66 |
|
67 /** |
|
68 * Returns a reference to this token's label. |
|
69 * @return A Reference to this token's label. |
|
70 */ |
|
71 const TDesC& Label(); |
|
72 |
|
73 /** |
|
74 * Returns the associated token type. |
|
75 * @return A reference to token's token type |
|
76 */ |
|
77 MCTTokenType& TokenType(); |
|
78 |
|
79 /** |
|
80 * Returns the token's handle which is TCTTokenHandle class. |
|
81 * @return tokens handle |
|
82 */ |
|
83 TCTTokenHandle Handle(); |
|
84 |
|
85 /** |
|
86 * Returns the specified information string about the token. |
|
87 * @param aRequiredInformation (IN) Specifies the required information |
|
88 * needed from the token. See value from TTokenInformation. |
|
89 * @return TDesC& (OUT) Information string of the token, or KNullDesC, |
|
90 * if token information cannot be given |
|
91 */ |
|
92 const TDesC& Information( TTokenInformation aRequiredInformation ); |
|
93 |
|
94 /** |
|
95 * Notifies the client when the token has been removed. Notify is |
|
96 * given by changing the status code of given TRequestStatus. |
|
97 * The caller should give listener's TRequestStatus in pending state |
|
98 * to this function. |
|
99 * Note: this is not an asynchronous call, it only stores the |
|
100 * address of given TRequestStatus for later notifications. |
|
101 * @param aStatus (IN/OUT) Async. request status. |
|
102 * KErrPending, token is on it's place |
|
103 * KErrCancel, caller has cancelled to notify token removal |
|
104 * KErrHardwareNotAvailable, token is removed |
|
105 * Any other system error code |
|
106 * @return void |
|
107 */ |
|
108 void NotifyOnRemoval( TRequestStatus& aStatus ); |
|
109 |
|
110 /** |
|
111 * Cancels the NotifyOnRemoval request. |
|
112 * @return void |
|
113 */ |
|
114 void CancelNotify(); |
|
115 |
|
116 /** |
|
117 * Returns a reference to a variable to be used as a reference counter |
|
118 * @return A reference to reference counter |
|
119 */ |
|
120 TInt& ReferenceCount(); |
|
121 |
|
122 protected: // Functions from base class MCTToken |
|
123 |
|
124 /** |
|
125 * Returns a reference to pointer of an interface object. |
|
126 * The caller owns all the parameters. |
|
127 * @param aRequiredInterface (IN) The UID of the interface that |
|
128 * should be returned |
|
129 * @param aReturnedInterface (OUT). This will be set to a pointer to |
|
130 * the returned interface on success and |
|
131 * to NULL if it isn't supported by this token |
|
132 * @param aStatus (IN/OUT) Async. request status. |
|
133 * KErrNone, if all ok and interface returned |
|
134 * KErrCancel, if call canceled |
|
135 * KErrNotSupported, if interface not supported |
|
136 * KErrHardwareNotAvailable, if Wim card suddenly removed |
|
137 * Any other system wide error code (e.g. KErrNoMemory) |
|
138 * @return void |
|
139 */ |
|
140 void DoGetInterface( TUid aRequiredInterface, |
|
141 MCTTokenInterface*& aReturnedInterface, |
|
142 TRequestStatus& aStatus ); |
|
143 |
|
144 /** |
|
145 * Cancels DoGetInterface operation. |
|
146 * @return Boolean value: true, if cancel is appropriate, false if |
|
147 * cancel is not appropriate |
|
148 */ |
|
149 TBool DoCancelGetInterface(); |
|
150 |
|
151 private: |
|
152 |
|
153 /** |
|
154 * C++ default constructor. |
|
155 */ |
|
156 CWimDummyToken( MCTTokenType& aTokenType ); |
|
157 |
|
158 /** |
|
159 * By default Symbian 2nd phase constructor is private. |
|
160 */ |
|
161 void ConstructL(); |
|
162 |
|
163 private: // Data |
|
164 |
|
165 MCTTokenType& iTokenType; |
|
166 // A variable needed for reference counting |
|
167 TInt iCount; |
|
168 // Serial number of the token |
|
169 HBufC* iSerialNumber; |
|
170 |
|
171 }; |
|
172 |
|
173 class CWimDummyTokenType : public CCTTokenType |
|
174 { |
|
175 public: // Constructors and destructor |
|
176 |
|
177 /** |
|
178 * Two-phased constructor. |
|
179 */ |
|
180 static CWimDummyTokenType* NewL(); |
|
181 |
|
182 /** |
|
183 * Destructor. |
|
184 */ |
|
185 virtual ~CWimDummyTokenType(); |
|
186 |
|
187 public: // Functions from base class MCTTokenType |
|
188 |
|
189 /** |
|
190 * Lists all the tokens of this type. Caller owns all parameters and |
|
191 * is responsible to destroy all objects in the received RCPointerArray. |
|
192 * @param aTokens (OUT) The returned tokens are added to this array. |
|
193 * @param aStatus (IN/OUT). Asyncronous return status: |
|
194 * KErrNone, if no errors occurred |
|
195 * KErrNotFound, if Wim information not found |
|
196 * KErrCancel, if list operation cancelled |
|
197 * Any other system wide error code |
|
198 * @return void |
|
199 */ |
|
200 void List( RCPointerArray<HBufC>& aTokens, |
|
201 TRequestStatus& aStatus ); |
|
202 |
|
203 /** |
|
204 * Cancel a list operation. |
|
205 * @return void |
|
206 */ |
|
207 void CancelList(); |
|
208 |
|
209 /** |
|
210 * Opens a specified token with token info. |
|
211 * The caller owns all the parameters. |
|
212 * @param aTokenInfo (IN) The info of the required token (token label) |
|
213 * @param aToken (OUT) The returned token. |
|
214 * @param aStatus (IN/OUT) Asynchronous return status. |
|
215 * KErrNone, if token opening succeeded |
|
216 * KErrNotFound, if token not found by aTokenInfo |
|
217 * Any other system wide error code |
|
218 * @return void |
|
219 */ |
|
220 void OpenToken( const TDesC& aTokenInfo, |
|
221 MCTToken*& aToken, |
|
222 TRequestStatus& aStatus ); |
|
223 |
|
224 /** |
|
225 * Opens a specified token with handle |
|
226 * The caller owns all the parameters. |
|
227 * @param aHandle (IN) The handle of the required token |
|
228 * @param aToken (OUT) The returned token. |
|
229 * @param aStatus (IN/OUT) Asynchronous return status. |
|
230 * KErrNone, if token opening succeeded |
|
231 * KErrNotFound, if token not found by aHandle |
|
232 * Any other system wide error code |
|
233 * @return void |
|
234 */ |
|
235 void OpenToken( TCTTokenHandle aHandle, |
|
236 MCTToken*& aToken, |
|
237 TRequestStatus& aStatus ); |
|
238 |
|
239 /** |
|
240 * Cancel an OpenToken operation. |
|
241 * @return void |
|
242 */ |
|
243 void CancelOpenToken(); |
|
244 |
|
245 private: // Constructors |
|
246 |
|
247 /** |
|
248 * Second phase constructor |
|
249 */ |
|
250 void ConstructL(); |
|
251 |
|
252 /** |
|
253 * Default constructor |
|
254 */ |
|
255 CWimDummyTokenType(); |
|
256 |
|
257 }; |
|
258 |
|
259 #endif // CWIMDUMMYTOKEN_H |
|
260 |
|
261 // End of File |