23
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Class to manage Bluetooth hardware and stack settings.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef BTENGSRVSETTINGSMGR_H
|
|
19 |
#define BTENGSRVSETTINGSMGR_H
|
|
20 |
|
|
21 |
#include <bluetooth/btpowercontrol.h>
|
|
22 |
#include <btfeaturescfg.h>
|
|
23 |
#ifndef __WINS__
|
|
24 |
#include <bluetooth/dutmode.h>
|
|
25 |
#endif //__WINS__
|
|
26 |
|
|
27 |
#include "btengprivatecrkeys.h"
|
|
28 |
#include "btengconstants.h"
|
|
29 |
#include "btengactive.h"
|
|
30 |
|
|
31 |
class CBTEngServer;
|
42
|
32 |
class CHbIndicatorSymbian;
|
23
|
33 |
|
|
34 |
|
|
35 |
/**
|
|
36 |
* ?one_line_short_description
|
|
37 |
* ?more_complete_description
|
|
38 |
*
|
|
39 |
* @code
|
|
40 |
* ?good_class_usage_example(s)
|
|
41 |
* @endcode
|
|
42 |
*
|
|
43 |
* @lib ?library
|
|
44 |
* @since S60 ?S60_version *** for example, S60 v3.0
|
|
45 |
*/
|
|
46 |
NONSHARABLE_CLASS( CBTEngSrvSettingsMgr ) : public CBase,
|
|
47 |
public MBTEngActiveObserver
|
|
48 |
{
|
|
49 |
|
|
50 |
public:
|
|
51 |
|
|
52 |
/**
|
|
53 |
* Two-phased constructor.
|
|
54 |
* @param aServer Pointer to server instance.
|
|
55 |
*/
|
|
56 |
static CBTEngSrvSettingsMgr* NewL( CBTEngServer* aServer );
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Destructor.
|
|
60 |
*/
|
|
61 |
virtual ~CBTEngSrvSettingsMgr();
|
|
62 |
|
|
63 |
/**
|
|
64 |
* Utility to get the Bluetooth hardware power state.
|
|
65 |
*
|
|
66 |
* @since Symbian^3
|
|
67 |
* @param aState On return, this will contain the current HW power state.
|
|
68 |
* @return KErrNone if successful, otherwise one of the system-wide error codes.
|
|
69 |
*/
|
|
70 |
TInt GetHwPowerState( TBTPowerState& aState );
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Set the Bluetooth hardware power state.
|
|
74 |
*
|
|
75 |
* @since Symbian^3
|
|
76 |
* @param aState The new power state.
|
|
77 |
*/
|
|
78 |
TInt SetHwPowerState( TBTPowerState aState );
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Set Bluetooth on or off. This function is for internal classes of bteng server
|
|
82 |
* for power management.
|
|
83 |
*
|
|
84 |
* @since Symbian^3
|
|
85 |
* @param aState The new power state.
|
|
86 |
* @param aTemporary Turn BT off after use (ETrue) or not (EFalse).
|
|
87 |
*/
|
|
88 |
void SetPowerStateL( TBTPowerState aState, TBool aTemporary );
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Set Bluetooth on or off upon a client power management request.
|
|
92 |
* This function is only for power management request from clients of bteng server.
|
|
93 |
*
|
|
94 |
* @since Symbian^3
|
|
95 |
* @param aState The new power state.
|
|
96 |
* @param aTemporary Turn BT off after use (ETrue) or not (EFalse).
|
|
97 |
*/
|
|
98 |
void SetPowerStateL( const RMessage2 aMessage );
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Initialize Bluetooth stack settings.
|
|
102 |
*
|
|
103 |
* @since S60 v3.2
|
|
104 |
* @param ?arg1 ?description
|
|
105 |
*/
|
|
106 |
void InitBTStackL();
|
|
107 |
|
|
108 |
/**
|
|
109 |
* Reset settings and disconnect all links.
|
|
110 |
*
|
|
111 |
* @since Symbian^3
|
|
112 |
*/
|
|
113 |
void StopBTStackL();
|
|
114 |
|
|
115 |
/**
|
28
|
116 |
* Handles a power event that HW power is going to turn off or
|
|
117 |
* has been changed turned on.
|
23
|
118 |
*
|
28
|
119 |
* @since Symbian^4
|
|
120 |
* @param aValue The new Bluetooth HW power state.
|
23
|
121 |
*/
|
28
|
122 |
void HandleHwPowerChangeL( TBTPowerState aValue );
|
23
|
123 |
|
|
124 |
/**
|
|
125 |
* ?description
|
|
126 |
*
|
|
127 |
* @since S60 v3.2
|
|
128 |
* @param ?arg1 ?description
|
|
129 |
*/
|
|
130 |
void SetUiIndicatorsL();
|
|
131 |
|
|
132 |
/**
|
|
133 |
* ?description
|
42
|
134 |
*
|
|
135 |
* @param aState Current State of the Bluetooth
|
23
|
136 |
*/
|
42
|
137 |
void SetIndicatorStateL( const TInt aState );
|
|
138 |
|
23
|
139 |
/**
|
|
140 |
* Update the Bluetooth visibility mode.
|
|
141 |
*
|
|
142 |
* @since Symbian^3
|
|
143 |
* @param ?arg1 ?description
|
|
144 |
*/
|
|
145 |
void SetVisibilityModeL( TBTVisibilityMode aMode, TInt aTime );
|
|
146 |
|
|
147 |
/**
|
|
148 |
* Update the Bluetooth visibility mode.
|
|
149 |
*
|
|
150 |
* @since Symbian^3
|
|
151 |
* @param ?arg1 ?description
|
|
152 |
*/
|
|
153 |
void UpdateVisibilityModeL( TInt aStackScanMode );
|
|
154 |
|
|
155 |
/**
|
|
156 |
* Set Device Under Test mode.
|
|
157 |
*
|
|
158 |
* @since Symbian^3
|
|
159 |
* @param aDutMode The mode to be set (DUT mode on or off).
|
|
160 |
*/
|
|
161 |
void SetDutMode( TInt aDutMode );
|
|
162 |
|
|
163 |
/**
|
|
164 |
* Timed visible mode has expired.
|
|
165 |
*
|
|
166 |
* @since Symbian^3
|
|
167 |
*/
|
|
168 |
void ScanModeTimerCompletedL();
|
|
169 |
|
|
170 |
/**
|
|
171 |
* Check whether BT should be turned off automatically.
|
|
172 |
*
|
|
173 |
* @since Symbian^3
|
|
174 |
*/
|
|
175 |
void CheckAutoPowerOffL();
|
|
176 |
|
|
177 |
/**
|
|
178 |
* Queue a timer if secure simple pairing debug mode has been enabled.
|
|
179 |
*
|
|
180 |
* @since Symbian^3
|
|
181 |
* @param aDebugMode State of Simple Pairing debug mode.
|
|
182 |
*/
|
|
183 |
void CheckSspDebugModeL( TBool aDebugMode );
|
|
184 |
|
|
185 |
/**
|
|
186 |
* Be informed that a session will be closed.
|
|
187 |
*
|
|
188 |
* @since Symbian^3
|
|
189 |
* @param aSession the session to be cloased.
|
|
190 |
*/
|
|
191 |
void SessionClosed(CSession2* aSession );
|
|
192 |
|
|
193 |
private:
|
|
194 |
|
|
195 |
// from base class MBTEngActiveObserver
|
|
196 |
|
|
197 |
/**
|
|
198 |
* From MBTEngActiveObserver.
|
|
199 |
* Callback to notify that an outstanding request has completed.
|
|
200 |
*
|
|
201 |
* @since Symbian^3
|
|
202 |
* @param aActive Pointer to the active object that completed.
|
|
203 |
* @param aStatus The status of the completed request.
|
|
204 |
*/
|
28
|
205 |
virtual void RequestCompletedL( CBTEngActive* aActive, TInt aStatus );
|
|
206 |
|
|
207 |
/**
|
|
208 |
* Callback for handling cancelation of an outstanding request.
|
|
209 |
*
|
|
210 |
* @param aId The ID that identifies the outstanding request.
|
|
211 |
*/
|
|
212 |
virtual void CancelRequest( TInt aRequestId );
|
|
213 |
|
23
|
214 |
/**
|
|
215 |
* From MBTEngActiveObserver.
|
|
216 |
* Callback to notify that an error has occurred in RunL.
|
|
217 |
*
|
|
218 |
* @since Symbian^3
|
|
219 |
* @param aActive Pointer to the active object that completed.
|
|
220 |
* @param aStatus The status of the completed request.
|
|
221 |
*/
|
28
|
222 |
virtual void HandleError( CBTEngActive* aActive, TInt aError );
|
23
|
223 |
|
|
224 |
private:
|
|
225 |
|
|
226 |
/**
|
|
227 |
* C++ default constructor.
|
|
228 |
*/
|
|
229 |
CBTEngSrvSettingsMgr( CBTEngServer* aServer );
|
|
230 |
|
|
231 |
/**
|
|
232 |
* Symbian second-phase constructor.
|
|
233 |
*/
|
|
234 |
void ConstructL();
|
|
235 |
|
|
236 |
/**
|
|
237 |
* Open a handle to the Bluetooth power manager, and
|
|
238 |
* initialize the power to off.
|
|
239 |
*
|
|
240 |
* @since Symbian^3
|
|
241 |
*/
|
|
242 |
void LoadBTPowerManagerL();
|
|
243 |
|
|
244 |
/**
|
|
245 |
* Checks if a client requests temporary power on/off, and keeps track
|
|
246 |
* of the number of clients requesting that.
|
|
247 |
*
|
|
248 |
* @since Symbian^3
|
|
249 |
* @param aCurrentState On return, will contain the current power state.
|
|
250 |
* @param aNewState The requested power state.
|
|
251 |
* @param aTemporary Indicates if this is about a tempororary state change.
|
|
252 |
*/
|
|
253 |
void CheckTemporaryPowerStateL( TBTPowerState& aCurrentState,
|
28
|
254 |
TBTPowerState aNewState, TBool aTemporary );
|
23
|
255 |
|
|
256 |
private: // data
|
|
257 |
|
|
258 |
#ifdef __WINS__
|
|
259 |
/**
|
|
260 |
* Current BT power state (power manager is not used in emulator).
|
|
261 |
*/
|
|
262 |
TBTPowerState iPowerState;
|
|
263 |
#endif //__WINS__
|
|
264 |
|
|
265 |
/**
|
|
266 |
* Flag indicating if BT is allowed to be turned on.
|
|
267 |
*/
|
|
268 |
BluetoothFeatures::TEnterpriseEnablementMode iEnterpriseEnablementMode;
|
|
269 |
|
|
270 |
/**
|
|
271 |
* Flag indicating if BT is going to be switched off automatically.
|
|
272 |
*/
|
|
273 |
TBool iAutoSwitchOff;
|
|
274 |
|
|
275 |
/**
|
|
276 |
* Number of clients that are using BT temporarily.
|
|
277 |
* Note that this is equal or less than the active number of links.
|
|
278 |
*/
|
|
279 |
TInt iAutoOffClients;
|
|
280 |
|
|
281 |
/**
|
|
282 |
* Flag indicating hidden mode has been set for temporary power on.
|
|
283 |
*/
|
|
284 |
TBool iRestoreVisibility;
|
|
285 |
|
|
286 |
/**
|
|
287 |
* BT power control.
|
|
288 |
*/
|
|
289 |
RBTPowerControl iPowerMgr;
|
|
290 |
|
|
291 |
/**
|
|
292 |
* Active object helper.
|
|
293 |
* Own.
|
|
294 |
*/
|
|
295 |
CBTEngActive* iActive;
|
|
296 |
|
|
297 |
/**
|
|
298 |
* The server instance.
|
|
299 |
* Not own.
|
|
300 |
*/
|
|
301 |
CBTEngServer* iServer;
|
|
302 |
|
|
303 |
/**
|
|
304 |
* Client-server message for power change requests.
|
|
305 |
*/
|
|
306 |
RMessage2 iMessage;
|
|
307 |
|
42
|
308 |
/**
|
|
309 |
* Orbit Indicator to display Bluetooth Status
|
|
310 |
*/
|
|
311 |
CHbIndicatorSymbian* iBTIndicator;
|
|
312 |
|
|
313 |
/*
|
|
314 |
* Indicator State
|
|
315 |
*/
|
|
316 |
TInt iIndicatorState;
|
23
|
317 |
};
|
|
318 |
|
|
319 |
|
|
320 |
#endif // BTENGSRVSETTINGS_H
|