|
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 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 * Declaration of class CRequestCompleteCallback.h |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef REQUEST_COMPLETE_CALLBACK_H |
|
22 #define REQUEST_COMPLETE_CALLBACK_H |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include <e32base.h> |
|
27 |
|
28 // CLASS DECLARATION |
|
29 |
|
30 /** |
|
31 * Active object to transfer a request completion to a callback. |
|
32 * NOTE: This object handles only completion, but not cancellation. It does not |
|
33 * make ('own') the request, therefore it cannot possibly cancel. |
|
34 * Users of this object must make sure that the request is already completed |
|
35 * or cancelled before this object is cancelled/deleted. DoCancel() of this |
|
36 * object panics (to avoid the hang). |
|
37 */ |
|
38 class CRequestCompleteCallback: public CActive |
|
39 { |
|
40 |
|
41 public: // Constructors and destructor |
|
42 |
|
43 /** |
|
44 * Constructor. |
|
45 */ |
|
46 CRequestCompleteCallback(); |
|
47 |
|
48 /** |
|
49 * Destructor. |
|
50 */ |
|
51 virtual ~CRequestCompleteCallback(); |
|
52 |
|
53 public: // new methods |
|
54 |
|
55 /** |
|
56 * Start waiting for completion. A request (on iStatus of this object) |
|
57 * must be outstanding. |
|
58 * @param aCallback Callback to call when request completes. |
|
59 * Note that the callback is called only once per CallbackOnCompletion() |
|
60 * invocation (like in CAsyncOneShot etc.), and repeated callbacks are |
|
61 * not supported. Therefore, the callback function must return EFalse. |
|
62 */ |
|
63 void CallbackOnCompletion( const TCallBack& aCallback ); |
|
64 |
|
65 public: // from CActive |
|
66 |
|
67 /** |
|
68 * Cancel protocol implementation: panic |
|
69 * This object cannot cancel the request. |
|
70 */ |
|
71 void DoCancel(); |
|
72 |
|
73 /** |
|
74 * Request completed: call the callback. |
|
75 */ |
|
76 void RunL(); |
|
77 |
|
78 private: // data |
|
79 |
|
80 TCallBack iCallback; ///< The callback. |
|
81 |
|
82 }; |
|
83 |
|
84 #endif /* def REQUEST_COMPLETE_CALLBACK_H */ |