|
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: Active object helper class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef BTENGACTIVE_H |
|
21 #define BTENGACTIVE_H |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 |
|
26 class CBTEngActive; |
|
27 |
|
28 /** ?description */ |
|
29 //const ?type ?constant_var = ?constant; |
|
30 |
|
31 |
|
32 /** |
|
33 * Class MBTEngActiveObserver |
|
34 * |
|
35 * Callback class for receiving a completed active object event. |
|
36 * Users of CBTEngActive need to derive from this class. |
|
37 * |
|
38 * @lib bteng*.lib |
|
39 * @since S60 v3.2 |
|
40 */ |
|
41 class MBTEngActiveObserver |
|
42 { |
|
43 |
|
44 public: |
|
45 |
|
46 /** |
|
47 * Callback to notify that an outstanding request has completed. |
|
48 * |
|
49 * @since S60 v3.2 |
|
50 * @param aActive Pointer to the active object that completed. |
|
51 * @param aId The ID that identifies the outstanding request. |
|
52 * @param aStatus The status of the completed request. |
|
53 */ |
|
54 virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, |
|
55 TInt aStatus ) = 0; |
|
56 |
|
57 /** |
|
58 * Callback to notify that an error has occurred in RunL. |
|
59 * |
|
60 * @param aActive Pointer to the active object that completed. |
|
61 * @param aId The ID that identifies the outstanding request. |
|
62 * @param aStatus The status of the completed request. |
|
63 */ |
|
64 virtual void HandleError( CBTEngActive* aActive, TInt aId, |
|
65 TInt aError ) = 0; |
|
66 |
|
67 }; |
|
68 |
|
69 |
|
70 /** |
|
71 * Class CBTEngActive |
|
72 * |
|
73 * ?more_complete_description |
|
74 * |
|
75 * @lib bteng*.lib |
|
76 * @since S60 v3.2 |
|
77 */ |
|
78 NONSHARABLE_CLASS( CBTEngActive ) : public CActive |
|
79 { |
|
80 |
|
81 public: |
|
82 |
|
83 /** |
|
84 * Two-phase constructor |
|
85 * |
|
86 * @since S60 v3.2 |
|
87 * @param aObserver Pointer to callback interface that receives notification |
|
88 * that the request has been completed. |
|
89 * @return Pointer to the constructed CBTEngActive object. |
|
90 */ |
|
91 static CBTEngActive* NewL( MBTEngActiveObserver& aObserver, |
|
92 TInt aId, TInt aPriority ); |
|
93 |
|
94 /** |
|
95 * Destructor |
|
96 */ |
|
97 virtual ~CBTEngActive(); |
|
98 |
|
99 /** |
|
100 * Get the request ID of this active object. |
|
101 * |
|
102 * @since S60 v3.2 |
|
103 * @return The request ID of this active object. |
|
104 */ |
|
105 inline TInt RequestId(); |
|
106 |
|
107 /** |
|
108 * Set a new request ID for this active object. |
|
109 * |
|
110 * @since S60 v3.2 |
|
111 * @param The new request ID of this active object. |
|
112 */ |
|
113 inline void SetRequestId( TInt aId ); |
|
114 |
|
115 /** |
|
116 * Activate the active object. |
|
117 * |
|
118 * @since S60 v3.2 |
|
119 */ |
|
120 inline void GoActive(); |
|
121 |
|
122 /** |
|
123 * Cancel an outstanding request. |
|
124 * |
|
125 * @since S60 v3.2 |
|
126 */ |
|
127 inline void CancelRequest(); |
|
128 |
|
129 /** |
|
130 * Get a reference to the active object request status. |
|
131 * |
|
132 * @since S60 v3.2 |
|
133 * @return Reference to the active object request status. |
|
134 */ |
|
135 TRequestStatus& RequestStatus(); |
|
136 |
|
137 // from base class CActive |
|
138 |
|
139 /** |
|
140 * From CActive. |
|
141 * Called by the active scheduler when the request has been cancelled. |
|
142 * |
|
143 * @since S60 v3.2 |
|
144 */ |
|
145 void DoCancel(); |
|
146 |
|
147 /** |
|
148 * From CActive. |
|
149 * Called by the active scheduler when the request has been completed. |
|
150 * |
|
151 * @since S60 v3.2 |
|
152 */ |
|
153 void RunL(); |
|
154 |
|
155 /** |
|
156 * From CActive. |
|
157 * Called by the active scheduler when an error in RunL has occurred. |
|
158 * |
|
159 * @since S60 v3.2 |
|
160 */ |
|
161 TInt RunError( TInt aError ); |
|
162 |
|
163 private: |
|
164 |
|
165 /** |
|
166 * C++ default constructor |
|
167 * |
|
168 * @since S60 v3.2 |
|
169 * @param aObserver Pointer to callback interface that receives notification |
|
170 * that the request has been completed. |
|
171 * @param aId ID of the request (for the client to keep track of multiple |
|
172 * active objects). |
|
173 * @param aPriority Priority of |
|
174 */ |
|
175 CBTEngActive( MBTEngActiveObserver& aObserver, TInt aId, TInt aPriority ); |
|
176 |
|
177 /** |
|
178 * Symbian 2nd-phase constructor |
|
179 * |
|
180 * @since S60 v3.2 |
|
181 */ |
|
182 void ConstructL(); |
|
183 |
|
184 private: // data |
|
185 |
|
186 /** |
|
187 * ID of the request (used only by our client). |
|
188 */ |
|
189 TInt iRequestId; |
|
190 |
|
191 /** |
|
192 * Our observer. |
|
193 * Not own. |
|
194 */ |
|
195 MBTEngActiveObserver& iObserver; |
|
196 |
|
197 }; |
|
198 |
|
199 |
|
200 #include "btengactive.inl" |
|
201 |
|
202 |
|
203 #endif // BTENGACTIVE_H |