|
1 /* |
|
2 * Copyright (c) 2005-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 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: Base class for wlan engine operations |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CORE_OPERATION_BASE_H |
|
20 #define CORE_OPERATION_BASE_H |
|
21 |
|
22 #include "core_types.h" |
|
23 |
|
24 class core_server_c; |
|
25 class abs_core_driverif_c; |
|
26 class abs_core_server_callback_c; |
|
27 |
|
28 /** |
|
29 * Base class for wlan engine operations |
|
30 * |
|
31 * @lib wlmserversrv.lib |
|
32 * @since S60 v3.1 |
|
33 */ |
|
34 NONSHARABLE_CLASS( core_operation_base_c ) |
|
35 { |
|
36 |
|
37 public: |
|
38 |
|
39 /** |
|
40 * Defines the possible operation states used in the state machine |
|
41 * of the base class. |
|
42 */ |
|
43 enum core_base_state_e |
|
44 { |
|
45 core_base_state_init = 0, |
|
46 core_base_state_load_drivers, |
|
47 core_base_state_user_cancel, |
|
48 core_base_state_next, |
|
49 core_base_state_MAX |
|
50 }; |
|
51 |
|
52 /** |
|
53 * Defines the possible feature flags an operation can have. |
|
54 */ |
|
55 enum core_base_flag_e |
|
56 { |
|
57 /** |
|
58 * No special features. |
|
59 */ |
|
60 core_base_flag_none = 0, |
|
61 /** |
|
62 * Operation needs drivers. The drivers will be automatically |
|
63 * loaded if not yet loaded. |
|
64 */ |
|
65 core_base_flag_drivers_needed = 1, |
|
66 /** |
|
67 * Operation needs a onnection to a WLAN AP. This flag is used |
|
68 * to clear the operation queue from connection related operations |
|
69 * after a connection has been closed. |
|
70 */ |
|
71 core_base_flag_connection_needed = 2, |
|
72 /** |
|
73 * Only one instance of the operation is allowed in the operation |
|
74 * queue. |
|
75 */ |
|
76 core_base_flag_only_one_instance = 4, |
|
77 /** |
|
78 * The operation is a roam operation. |
|
79 */ |
|
80 core_base_flag_roam_operation = 8 |
|
81 }; |
|
82 |
|
83 core_operation_base_c( |
|
84 core_operation_type_e type, |
|
85 u32_t request_id, |
|
86 core_server_c* server, |
|
87 abs_core_driverif_c* drivers, |
|
88 abs_core_server_callback_c* adaptation, |
|
89 u32_t feature_flags ); |
|
90 |
|
91 virtual ~core_operation_base_c(); |
|
92 |
|
93 /** |
|
94 * starts the operation |
|
95 * |
|
96 * @since S60 v3.1 |
|
97 * @return status of the operation: |
|
98 * core_error_request_pending if the operation is not finished, |
|
99 * otherwise the status code of the finished operation |
|
100 */ |
|
101 core_error_e start_operation(); |
|
102 |
|
103 /** |
|
104 * callback to previously made asynchronous request |
|
105 * |
|
106 * @since S60 v3.1 |
|
107 * @param request_status Status of the completed request. |
|
108 * @return status of the operation: |
|
109 * core_error_request_pending if the operation is not finished, |
|
110 * otherwise the status code of the finished operation |
|
111 */ |
|
112 core_error_e continue_operation( |
|
113 core_error_e request_status ); |
|
114 |
|
115 /** |
|
116 * cancels the operation |
|
117 * |
|
118 * @since S60 v3.1 |
|
119 * @return status of the operation: |
|
120 * core_error_request_pending if the operation is not finished, |
|
121 * otherwise the status code of the finished operation |
|
122 */ |
|
123 core_error_e cancel_operation(); |
|
124 |
|
125 /** |
|
126 * User cancels the operation |
|
127 * |
|
128 * @since S60 v3.2 |
|
129 * @param do_graceful_cancel Whether cancel should be graceful or forced. |
|
130 */ |
|
131 void user_cancel_operation( |
|
132 bool_t do_graceful_cancel ); |
|
133 |
|
134 /** |
|
135 * returns the request_id related to this operation |
|
136 * |
|
137 * @since S60 v3.1 |
|
138 * @return enum specifying operation type |
|
139 */ |
|
140 u32_t request_id() const; |
|
141 |
|
142 /** |
|
143 * returns the operation type |
|
144 * |
|
145 * @since S60 v3.1 |
|
146 * @return enum specifying operation type |
|
147 */ |
|
148 core_operation_type_e operation_type() const; |
|
149 |
|
150 /** |
|
151 * whether operation is executing or not ("in queue") |
|
152 * |
|
153 * @since S60 v3.1 |
|
154 * @return true or false |
|
155 */ |
|
156 bool_t is_executing() const; |
|
157 |
|
158 /** |
|
159 * Check whether the operation has the given feature flags. |
|
160 * |
|
161 * @since S60 v3.1 |
|
162 * @param u32_t The feature flags to check for. |
|
163 * @return Whether the operation has the given feature flags. |
|
164 */ |
|
165 bool_t is_flags( |
|
166 u32_t feature_flags ) const; |
|
167 |
|
168 protected: |
|
169 |
|
170 /** |
|
171 * This method is called when a pending request has been completed |
|
172 * and sub-operations are pending. |
|
173 * |
|
174 * @since S60 v3.1 |
|
175 * @return status of the operation: |
|
176 * core_error_request_pending if the operation is not finished, |
|
177 * otherwise the status code of the finished operation |
|
178 */ |
|
179 virtual core_error_e next_state() = 0; |
|
180 |
|
181 /** |
|
182 * This method is called when the operation needs to be canceled. |
|
183 * |
|
184 * @since S60 v3.1 |
|
185 * @return status of the operation: |
|
186 * core_error_request_pending if the operation is not finished, |
|
187 * otherwise the status code of the finished operation |
|
188 */ |
|
189 virtual core_error_e cancel(); |
|
190 |
|
191 /** |
|
192 * This method is called when user want the operation to be canceled. |
|
193 * |
|
194 * @since S60 v3.2 |
|
195 * @param do_graceful_cancel Whether cancel should be graceful or forced. |
|
196 */ |
|
197 virtual void user_cancel( |
|
198 bool_t do_graceful_cancel ); |
|
199 |
|
200 /** |
|
201 * Change to another state. |
|
202 * |
|
203 * @since S60 v3.1 |
|
204 * @param state The new state. |
|
205 * @return status of the operation: |
|
206 * core_error_request_pending if the operation is not finished, |
|
207 * otherwise the status code of the finished operation |
|
208 */ |
|
209 core_error_e goto_state( |
|
210 u32_t state ); |
|
211 |
|
212 /** |
|
213 * Start a sub-operation and advance to the next state if |
|
214 * operation completes successfully. |
|
215 * |
|
216 * If the sub-operation fails, will initiate canceling. |
|
217 * |
|
218 * @since S60 v3.1 |
|
219 * @param sub_operation The sub-operation to start. |
|
220 * @return status of the operation: |
|
221 * core_error_request_pending if the operation is not finished, |
|
222 * otherwise the status code of the finished operation |
|
223 */ |
|
224 core_error_e run_sub_operation( |
|
225 core_operation_base_c* sub_operation ); |
|
226 |
|
227 /** |
|
228 * Start a sub-operation and advance to the next state if |
|
229 * operation completes successfully. |
|
230 * |
|
231 * If the sub-operation fails, will initiate canceling. |
|
232 * |
|
233 * @since S60 v3.1 |
|
234 * @param sub_operation The sub-operation to start. |
|
235 * @param state The new state. |
|
236 * @return status of the operation: |
|
237 * core_error_request_pending if the operation is not finished, |
|
238 * otherwise the status code of the finished operation |
|
239 */ |
|
240 core_error_e run_sub_operation( |
|
241 core_operation_base_c* sub_operation, |
|
242 u32_t state ); |
|
243 |
|
244 /** |
|
245 * Change to another state asynchronously. |
|
246 * |
|
247 * @since S60 v3.1 |
|
248 * @param state The new state. |
|
249 * @param delay Delay before changing state in microseconds. |
|
250 * @return Returns always core_error_request_pending. |
|
251 */ |
|
252 core_error_e asynch_goto( |
|
253 u32_t state, |
|
254 u32_t delay = CORE_TIMER_IMMEDIATELY ); |
|
255 |
|
256 /** |
|
257 * The asynchronous version of the default user cancel handler. |
|
258 * |
|
259 * This method is meant for situations where the cancel cannot |
|
260 * proceed because the operation is waiting for an event. |
|
261 * |
|
262 * @since S60 v3.2 |
|
263 */ |
|
264 void asynch_default_user_cancel(); |
|
265 |
|
266 protected: // data |
|
267 |
|
268 /** |
|
269 * Request_id is used for identifying the initial caller. |
|
270 */ |
|
271 u32_t request_id_m; |
|
272 |
|
273 /** |
|
274 * Pointer to the core_server instance. |
|
275 * Not owned by this pointer. |
|
276 */ |
|
277 core_server_c* server_m; |
|
278 |
|
279 /** |
|
280 * Pointer to low-level management functionality. |
|
281 * Not owned by this pointer. |
|
282 */ |
|
283 abs_core_driverif_c* drivers_m; |
|
284 |
|
285 /** |
|
286 * Pointer to the upper-level management functionality. |
|
287 * Not owned by this pointer. |
|
288 */ |
|
289 abs_core_server_callback_c* adaptation_m; |
|
290 |
|
291 /** |
|
292 * Has this operation been started or not. |
|
293 */ |
|
294 bool_t is_executing_m; |
|
295 |
|
296 /** |
|
297 * Whether this operation is currently being canceled. |
|
298 */ |
|
299 bool_t is_canceling_m; |
|
300 |
|
301 /** |
|
302 * Internal state of the operation. |
|
303 */ |
|
304 u32_t operation_state_m; |
|
305 |
|
306 /** |
|
307 * The pending sub-operation. |
|
308 */ |
|
309 core_operation_base_c* sub_operation_m; |
|
310 |
|
311 /** |
|
312 * Operation failure reason. |
|
313 */ |
|
314 core_error_e failure_reason_m; |
|
315 |
|
316 private: // data |
|
317 |
|
318 /** |
|
319 * specifies the type of the operation (e.g. connect, scan, ...) |
|
320 */ |
|
321 core_operation_type_e operation_type_m; |
|
322 |
|
323 /** |
|
324 * Defines the features of the operation. |
|
325 */ |
|
326 u32_t feature_flags_m; |
|
327 |
|
328 }; |
|
329 |
|
330 #endif // CORE_OPERATION_BASE_H |