|
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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_NCDBASEOPERATIONPROXY_H |
|
20 #define C_NCDBASEOPERATIONPROXY_H |
|
21 |
|
22 #include "catalogsbase.h" |
|
23 #include "catalogsbaseimpl.h" |
|
24 #include "ncdoperation.h" |
|
25 #include "ncdprogress.h" |
|
26 #include "ncdsendableprogress.h" |
|
27 #include "ncdoperationfunctionids.h" |
|
28 |
|
29 class MNcdSendable; |
|
30 class MNcdOperationProxyRemoveHandler; |
|
31 class CNcdQuery; |
|
32 class MCatalogsClientServer; |
|
33 class CNcdNodeProxy; |
|
34 class MNcdClientLocalizer; |
|
35 class CNcdNodeManagerProxy; |
|
36 |
|
37 /** |
|
38 * Operation proxy base class. |
|
39 * |
|
40 * Implements common functionality for operation proxys. This class is |
|
41 * abstract. |
|
42 */ |
|
43 class CNcdBaseOperationProxy : |
|
44 public CCatalogsBase<CActive> |
|
45 { |
|
46 public: // from MNcdOperation |
|
47 |
|
48 /** |
|
49 * @see MNcdOperation::OperationStateL() |
|
50 */ |
|
51 MNcdOperation::TState DoOperationStateL() const; |
|
52 |
|
53 |
|
54 /** |
|
55 * @see MNcdOperation::StartOperationL() |
|
56 */ |
|
57 void DoStartOperationL(); |
|
58 |
|
59 /** |
|
60 * @see MNcdOperation::CancelOperation() |
|
61 */ |
|
62 void DoCancelOperation(); |
|
63 |
|
64 /** |
|
65 * @see MNcdOperation::Progress() |
|
66 */ |
|
67 TNcdProgress DoProgress() const; |
|
68 |
|
69 |
|
70 /** |
|
71 * @see MNcdOperation::CompleteQuery() |
|
72 */ |
|
73 void DoCompleteQueryL( MNcdQuery& aQuery ); |
|
74 |
|
75 /** |
|
76 * @see MNcdOperation::Node() |
|
77 */ |
|
78 MNcdNode* DoNode(); |
|
79 |
|
80 protected: |
|
81 |
|
82 /** |
|
83 * Constructor |
|
84 * |
|
85 * @param aSession is the session that is used between |
|
86 * the proxy and the server. |
|
87 * @param aHandle is the handle that identifies the serverside |
|
88 * object that this proxy uses. |
|
89 * @param aRemoveHandler An observer that is called during destruction. |
|
90 * @param aNode The node this operation was started from. |
|
91 */ |
|
92 CNcdBaseOperationProxy( MNcdClientLocalizer* aLocalizer); |
|
93 |
|
94 /** |
|
95 * ConstructL |
|
96 * |
|
97 * @param aNodeManager Pointer to node manager. Used to handle expired |
|
98 * nodes. Ownership is not transferred. |
|
99 * |
|
100 */ |
|
101 virtual void ConstructL( MCatalogsClientServer& aSession, TInt aHandle, |
|
102 MNcdOperationProxyRemoveHandler* aRemoveHandler, CNcdNodeProxy* aNode, |
|
103 CNcdNodeManagerProxy* aNodeManager ); |
|
104 |
|
105 virtual ~CNcdBaseOperationProxy(); |
|
106 |
|
107 |
|
108 /** |
|
109 * Handles messages completed by the server side operation. |
|
110 * |
|
111 * @return Symbian error code. |
|
112 */ |
|
113 virtual void HandleCompletedMessage( |
|
114 TNcdOperationMessageCompletionId aCompletionId, |
|
115 RReadStream& aReadStream, |
|
116 TInt aDataLength ); |
|
117 |
|
118 /** |
|
119 * Sends a continue message. |
|
120 */ |
|
121 virtual void SendContinueMessageL(); |
|
122 |
|
123 |
|
124 /** |
|
125 * Sends a release message |
|
126 */ |
|
127 virtual void SendReleaseMessage(); |
|
128 |
|
129 |
|
130 /** |
|
131 * Inits send and receive buffers. |
|
132 * |
|
133 * @param aSendSize Size of the send buffer. |
|
134 * @param aSendSize Size of the receive buffer. |
|
135 */ |
|
136 void InitBuffersL( TInt aSendSize, TInt aReceiveSize ); |
|
137 |
|
138 /** |
|
139 * Initiates a progress callback. |
|
140 * Defined here so that the base class can initiate the callback. |
|
141 * Implemented in child classes. |
|
142 */ |
|
143 virtual void ProgressCallback() = 0; |
|
144 |
|
145 /** |
|
146 * Initiates a query received callback. |
|
147 * Defined here so that the base class can initiate the callback. |
|
148 * Implemented in child classes. |
|
149 */ |
|
150 virtual void QueryReceivedCallback( CNcdQuery* aQuery ) = 0; |
|
151 |
|
152 /** |
|
153 * Initiates a complete callback. |
|
154 * Defined here so that the base class can initiate the callback. |
|
155 * Implemented in child classes. |
|
156 * |
|
157 * @param aError System wide error code. |
|
158 */ |
|
159 virtual void CompleteCallback( TInt aError ) = 0; |
|
160 |
|
161 |
|
162 /** |
|
163 * Used to initialize the operation during construction. |
|
164 * |
|
165 * If either the proxy or the server-side operation need some data from |
|
166 * each other during construction, this method should be called in |
|
167 * proxy's ConstructL after proxybase's ConstructL has been called. |
|
168 * |
|
169 * The proxy implementation should create a data buffer containing the |
|
170 * initialization data in CreateInitilizationBufferL. |
|
171 * |
|
172 * The proxy implementation should read initialization data received from |
|
173 * the server in InitializationCallback() |
|
174 */ |
|
175 virtual void InitializeOperationL(); |
|
176 |
|
177 |
|
178 /** |
|
179 * Creates a buffer that contains initialization data that is sent to |
|
180 * the server-side operation during InitializeOperation() |
|
181 * |
|
182 * Creates an empty buffer by default |
|
183 * |
|
184 * This should be redefined in the implementation class if it uses |
|
185 * initialization |
|
186 */ |
|
187 virtual HBufC8* CreateInitializationBufferL(); |
|
188 |
|
189 |
|
190 /** |
|
191 * Initializes the proxy with data received from the server |
|
192 * |
|
193 * Does nothing by default. |
|
194 * @note aReadStream is closed by the base class |
|
195 */ |
|
196 virtual void InitializationCallback( RReadStream& aReadStream, |
|
197 TInt aDataLength ); |
|
198 |
|
199 |
|
200 /** |
|
201 * Setter for operation state |
|
202 * |
|
203 * @param aState Operation state. |
|
204 */ |
|
205 void SetState( MNcdOperation::TState aState ); |
|
206 |
|
207 |
|
208 /** |
|
209 * Getter for the progress variable. |
|
210 * |
|
211 * @return TSendableProgress& |
|
212 */ |
|
213 TNcdSendableProgress& SendableProgress(); |
|
214 |
|
215 /** |
|
216 * @return CNcdNodeManagerProxy* Node manager. |
|
217 * Ownership is not transferred. |
|
218 */ |
|
219 CNcdNodeManagerProxy* NodeManager() const; |
|
220 |
|
221 /** |
|
222 * @return CNcdNodeProxy* Node. |
|
223 * Ownership is not transferred. |
|
224 */ |
|
225 CNcdNodeProxy* NodeProxy() const; |
|
226 |
|
227 /** |
|
228 * Updates the purchase history with the latest operation error code |
|
229 * and sets the latest operation time to the current universal time. |
|
230 * |
|
231 * @param aErrorCode Error code of the last purchase related operation. |
|
232 */ |
|
233 void UpdateOperationInfoToPurchaseHistoryL( TInt aErrorCode ); |
|
234 |
|
235 |
|
236 // from base class CActive |
|
237 |
|
238 protected: // CActive |
|
239 |
|
240 /** |
|
241 * @see CActive::RunL |
|
242 */ |
|
243 void RunL(); |
|
244 |
|
245 /** |
|
246 * @see CActive::DoCancel |
|
247 */ |
|
248 void DoCancel(); |
|
249 |
|
250 /** |
|
251 * @see CActive::RunError |
|
252 */ |
|
253 TInt RunError( TInt aError ); |
|
254 |
|
255 public: |
|
256 |
|
257 /** |
|
258 * ClientServerSession |
|
259 * |
|
260 * @return MCatalogsClientServer& an object that contains |
|
261 * the client server session information |
|
262 */ |
|
263 virtual MCatalogsClientServer& ClientServerSession() const; |
|
264 |
|
265 |
|
266 /** |
|
267 * Handle |
|
268 * |
|
269 * @return TInt a handle that identifies the server side object |
|
270 * that this proxy uses. |
|
271 */ |
|
272 virtual TInt Handle() const; |
|
273 |
|
274 |
|
275 /** |
|
276 * Gives a non-modifiable descriptor for message sending. |
|
277 * @return TDesC8 The non-modifiable send buffer. Uses the |
|
278 * HBufC8 buffer that is owned by the object of this class. |
|
279 * @exception KErrNotFound if buffer does not exist. |
|
280 */ |
|
281 virtual const TDesC8& SendBuf8L(); |
|
282 |
|
283 /** |
|
284 * Changes the send buffer. |
|
285 * The ownership is transferred. |
|
286 * @param aBuffer is the new buffer that will replace the existing |
|
287 * 8-bit buffer. The old buffer is deleted. |
|
288 * The new buffer will be used for message sending. |
|
289 */ |
|
290 virtual void SetSendBuf8( HBufC8* aBuffer ); |
|
291 |
|
292 |
|
293 protected: |
|
294 |
|
295 /** |
|
296 * Op proxy remove handler. |
|
297 */ |
|
298 MNcdOperationProxyRemoveHandler* iRemoveHandler; |
|
299 |
|
300 /** |
|
301 * Pending query object. |
|
302 */ |
|
303 CNcdQuery* iQuery; |
|
304 |
|
305 |
|
306 private: // data |
|
307 |
|
308 /** |
|
309 * Node manager for example for expired nodes handling. |
|
310 * Not own. |
|
311 */ |
|
312 CNcdNodeManagerProxy* iNodeManager; |
|
313 |
|
314 /** |
|
315 * The node this operation was started from. |
|
316 */ |
|
317 CNcdNodeProxy* iNode; |
|
318 |
|
319 /** |
|
320 * State of the operation. |
|
321 */ |
|
322 MNcdOperation::TState iState; |
|
323 |
|
324 /** |
|
325 * Progress of the operation. |
|
326 */ |
|
327 TNcdSendableProgress iProgress; |
|
328 |
|
329 |
|
330 HBufC8* iReceiveBuffer; |
|
331 |
|
332 /** |
|
333 * Interface for communicating to the server-side. |
|
334 */ |
|
335 MCatalogsClientServer* iSession; |
|
336 |
|
337 /** |
|
338 * Handle to identify the server-side counterpart for object of this |
|
339 * class. |
|
340 */ |
|
341 TInt iHandle; |
|
342 |
|
343 |
|
344 // Variables for 8-bit transactions |
|
345 |
|
346 /** |
|
347 * Descriptor for message sending to the server-side. |
|
348 * Own. |
|
349 */ |
|
350 HBufC8* iSendHeapBuf8; |
|
351 |
|
352 |
|
353 CBufBase* iSendBuffer; |
|
354 TPtr8 iSendPtr; |
|
355 |
|
356 /** |
|
357 * String localizer, not own. |
|
358 */ |
|
359 MNcdClientLocalizer* iStringLocalizer; |
|
360 }; |
|
361 |
|
362 |
|
363 #endif // C_NCDBASEOPERATIONPROXY_H |