88 * @since S60 S60 v3.2 |
87 * @since S60 S60 v3.2 |
89 */ |
88 */ |
90 NONSHARABLE_CLASS( CBTEngServer ) : public CPolicyServer |
89 NONSHARABLE_CLASS( CBTEngServer ) : public CPolicyServer |
91 { |
90 { |
92 |
91 |
93 friend class CBTEngSrvSession; |
|
94 friend class CBTEngSrvState; |
|
95 friend class CBTEngSrvPluginMgr; |
92 friend class CBTEngSrvPluginMgr; |
96 friend class CBTEngSrvKeyWatcher; |
|
97 friend class CBTEngPairMan; |
93 friend class CBTEngPairMan; |
98 |
94 |
99 public: |
95 public: |
100 |
96 |
|
97 /** Enumeration of bitmask for keeping track of different timers. */ |
|
98 enum TTimerQueued |
|
99 { |
|
100 ENone = 0x00, |
|
101 EScanModeTimer = 0x01, |
|
102 EIdleTimer = 0x02, |
|
103 EAutoPowerOffTimer = 0x04, |
|
104 ESspDebugModeTimer = 0x08 |
|
105 }; |
|
106 |
|
107 /** |
|
108 * Two-phased constructor. |
|
109 */ |
101 static CBTEngServer* NewLC(); |
110 static CBTEngServer* NewLC(); |
102 |
111 |
|
112 /** |
|
113 * Destructor. |
|
114 */ |
103 virtual ~CBTEngServer(); |
115 virtual ~CBTEngServer(); |
104 |
116 |
105 /** |
117 /** |
|
118 * Getter for power change state machine instance. |
|
119 * |
|
120 * @since Symbian^3 |
|
121 * @return Pointer to instance of state machine. |
|
122 */ |
|
123 inline CBTEngSrvState* StateMachine() const |
|
124 { return iServerState; } |
|
125 |
|
126 /** |
|
127 * Getter for settings manager instance. |
|
128 * |
|
129 * @since Symbian^3 |
|
130 * @return Pointer to instance of settings manager. |
|
131 */ |
|
132 inline CBTEngSrvSettingsMgr* SettingsManager() const |
|
133 { return iSettingsMgr; } |
|
134 |
|
135 /** |
|
136 * Getter for plug-in manager instance. |
|
137 * |
|
138 * @since Symbian^3 |
|
139 * @return Pointer to instance of plug-in manager. |
|
140 */ |
|
141 inline CBTEngSrvPluginMgr* PluginManager() const |
|
142 { return iPluginMgr; } |
|
143 |
|
144 /** |
|
145 * Getter for baseband connection manager instance. |
|
146 * |
|
147 * @since Symbian^3 |
|
148 * @return Pointer to instance of baseband connection manager. |
|
149 */ |
|
150 inline CBTEngSrvBBConnMgr* BasebandConnectionManager() const |
|
151 { return iBBConnMgr; } |
|
152 |
|
153 /** |
|
154 * Getter for pairing manager. Ownership is not transferred. |
|
155 * |
|
156 * @since Symbian^3 |
|
157 * @return Pointer to instance of baseband connection manager. |
|
158 */ |
|
159 inline CBTEngPairMan* PairManager() const |
|
160 { return iPairMan; } |
|
161 |
|
162 /** |
|
163 * Getter for socket server session. |
|
164 * This handle can be used for creating subsessions. |
|
165 * |
|
166 * @since Symbian^3 |
|
167 * @return Reference to session with the socket server. |
|
168 */ |
|
169 inline RSocketServ& SocketServer() |
|
170 { return iSocketServ; } |
|
171 |
|
172 /** |
|
173 * Getter for registry server session. |
|
174 * This handle can be used for creating subsessions. |
|
175 * |
|
176 * @since Symbian^3 |
|
177 * @return Reference to session with the registry server. |
|
178 */ |
|
179 inline RBTRegServ& RegistrServer() |
|
180 { return iBTRegServ; } |
|
181 |
|
182 /** |
|
183 * Set Bluetooth on or off |
|
184 * |
|
185 * @since S60 v3.2 |
|
186 * @param aState The new power state. |
|
187 * @param aTemporary Turn BT off after use (ETrue) or not (EFalse). |
|
188 */ |
|
189 void SetPowerStateL( TBTPowerState aState, TBool aTemporary ); |
|
190 |
|
191 /** |
|
192 * Set Bluetooth on or off upon a client power management request. |
|
193 * This function is only for power management request from clients of bteng server. |
|
194 * |
|
195 * @since Symbian^3 |
|
196 * @param aMessage The message containing the detail of power management request. |
|
197 */ |
|
198 void SetPowerStateL( const RMessage2 aMessage ); |
|
199 |
|
200 /** |
106 * ?description |
201 * ?description |
107 * |
202 * |
108 * @since S60 v3.2 |
203 * @since S60 v3.2 |
109 * @param aState The new power state. |
204 * @param ?arg1 ?description |
110 * @param aTemp Turn BT off after use (ETrue) or not (EFalse). |
205 */ |
111 */ |
206 void DisconnectAllL(); |
112 void SetPowerStateL( TBTPowerStateValue aState, TBool aTemporary ); |
|
113 |
207 |
114 /** |
208 /** |
115 * ?description |
209 * ?description |
116 * |
210 * |
117 * @since S60 v3.2 |
211 * @since S60 v3.2 |
118 * @param ?arg1 ?description |
212 * @param ?arg1 ?description |
119 */ |
213 */ |
120 void SetVisibilityModeL( TBTVisibilityMode aMode, TInt aTime ); |
214 void DisconnectAllCompleted(); |
121 |
215 |
122 /** |
216 /** |
123 * ?description |
217 * ?description |
124 * |
218 * |
125 * @since S60 v3.2 |
219 * @since S60 v3.2 |
126 * @param ?arg1 ?description |
220 * @param ?arg1 ?description |
127 */ |
221 */ |
128 void UpdateVisibilityModeL( TInt aStackScanMode ); |
|
129 |
|
130 /** |
|
131 * ?description |
|
132 * |
|
133 * @since S60 v3.2 |
|
134 * @param ?arg1 ?description |
|
135 */ |
|
136 void DisconnectAllL(); |
|
137 |
|
138 /** |
|
139 * ?description |
|
140 * |
|
141 * @since S60 v3.2 |
|
142 * @param ?arg1 ?description |
|
143 */ |
|
144 void SetDutMode( TInt aDutMode ); |
|
145 |
|
146 /** |
|
147 * ?description |
|
148 * |
|
149 * @since S60 v3.2 |
|
150 * @param ?arg1 ?description |
|
151 */ |
|
152 void ScanModeTimerCompletedL(); |
|
153 |
|
154 /** |
|
155 * ?description |
|
156 * |
|
157 * @since S60 v3.2 |
|
158 * @param ?arg1 ?description |
|
159 */ |
|
160 void DisconnectAllCompleted(); |
|
161 |
|
162 /** |
|
163 * ?description |
|
164 * |
|
165 * @since S60 v3.2 |
|
166 * @param ?arg1 ?description |
|
167 */ |
|
168 void DispatchPluginMessageL( const RMessage2& aMessage ); |
222 void DispatchPluginMessageL( const RMessage2& aMessage ); |
169 |
223 |
170 /** |
224 /** |
171 * Increment the session count. |
225 * Increment the session count. |
172 * |
226 * |
173 * @since S60 v3.2 |
227 * @since S60 v3.2 |
174 */ |
228 */ |
175 void AddSession(); |
229 void AddSession(); |
176 |
230 |
177 /** |
231 /** |
178 * Decrement the session count. |
232 * Decrement the session count. |
179 * |
233 * |
180 * @since S60 v3.2 |
234 * @since Symbian^3 |
|
235 * @param aSession the session to be cloased. |
181 * @param aAutoOff Indicator if this session had requested BT temporary on. |
236 * @param aAutoOff Indicator if this session had requested BT temporary on. |
182 */ |
237 */ |
183 void RemoveSession( TBool aAutoOff ); |
238 void RemoveSession(CSession2* aSession, TBool aAutoOff ); |
184 |
239 |
185 /** |
240 /** |
186 * ?description |
241 * Queue a new timer. |
187 * |
242 * |
188 * @since S60 v3.2 |
243 * @since Symbian^3 |
189 * @param ?arg1 ?description |
244 * @param aTimer Identifier for the timer to be queued. |
190 */ |
245 * @param aInterval The interval for timer callback. |
191 void SetUiIndicatorsL(); |
246 */ |
192 |
247 void QueueTimer( CBTEngServer::TTimerQueued aTimer, TInt64 aInterval ); |
193 /** |
248 |
194 * ?description |
249 /** |
195 * |
250 * Remove a queued timer. |
196 * @since S60 v3.2 |
251 * |
197 * @param ?arg1 ?description |
252 * @since Symbian^3 |
198 */ |
253 * @param aTimer Identifier for the timer to be removed. |
199 void SetIndicatorStateL( const TInt aIndicator, const TInt aState ); |
254 */ |
200 |
255 void RemoveTimer( CBTEngServer::TTimerQueued aTimer ); |
201 /** |
256 |
202 * Check whether BT should be turned off automatically. |
257 /** |
203 * |
258 * Check if a specific timer is currently queued. |
204 * @since S60 v5.0 |
259 * |
205 */ |
260 * @since Symbian^3 |
206 void CheckAutoPowerOffL(); |
261 * @param aTimer Identifier for the timer to check. |
207 |
262 */ |
208 /** |
263 inline TBool IsTimerQueued( CBTEngServer::TTimerQueued aTimer ) const |
209 * Utility to get HW power state. |
264 { return ( iTimerQueued & aTimer ); } |
210 * |
265 |
211 * @since S60 v5.1 |
266 /** |
212 * @param aState On return, this will contain the current HW power state. |
267 * Returns the service (limited to services managed in bteng scope) |
213 * @return KErrNone if successful, otherwise one of the system-wide error codes. |
268 * level connection status of the specified device. |
214 */ |
269 * |
215 TInt GetHwPowerState( TBTPowerStateValue& aState ); |
270 * @param aAddr the address of the device |
216 |
271 * @return one of TBTEngConnectionStatus enums |
217 /** |
272 */ |
218 * queue a timer if Simple Pairing debug mode has been enabled. |
273 TBTEngConnectionStatus IsDeviceConnected( const TBTDevAddr& aAddr ); |
219 * |
|
220 * @since S60 v3.2 |
|
221 * @param aDebugMode State of Simple Pairing debug mode. |
|
222 */ |
|
223 void CheckSspDebugModeL( TBool aDebugMode ); |
|
224 |
|
225 /** |
|
226 * Gets the access to pairing manager. Ownership is not transferred. |
|
227 * @return the pairing manager |
|
228 */ |
|
229 CBTEngPairMan& PairManager(); |
|
230 |
|
231 /** |
|
232 * Be informed when registry remote device table is changed |
|
233 */ |
|
234 void RemoteRegistryChangeDetected(); |
|
235 |
|
236 /** |
|
237 * gets the reference of socket server session |
|
238 */ |
|
239 RSocketServ& SocketServ(); |
|
240 |
|
241 /** |
|
242 * gets the reference of registry session. |
|
243 */ |
|
244 RBTRegServ& BTRegServ(); |
|
245 |
|
246 /** |
|
247 * Returns the service (limited to services managed in bteng scope) |
|
248 * level connection status of the specified device. |
|
249 * |
|
250 * @param aAddr the address of the device |
|
251 * @return one of TBTEngConnectionStatus enums |
|
252 */ |
|
253 TBTEngConnectionStatus IsDeviceConnected( const TBTDevAddr& aAddr ); |
|
254 |
|
255 // from base class CPolicyServer |
|
256 |
|
257 /** |
|
258 * From CPolicyServer. |
|
259 * ?description |
|
260 * |
|
261 * @since S60 v3.2 |
|
262 * @param ?arg1 ?description |
|
263 */ |
|
264 virtual CSession2* NewSessionL( const TVersion& aVersion, |
|
265 const RMessage2& aMessage ) const; |
|
266 |
|
267 // from base class MBTPowerManagerObserver |
|
268 |
|
269 BluetoothFeatures::TEnterpriseEnablementMode EnterpriseEnablementMode() const; |
|
270 |
|
271 private: |
|
272 |
|
273 CBTEngServer(); |
|
274 |
|
275 void ConstructL(); |
|
276 |
274 |
277 /** |
275 /** |
278 * Checks if power is off and no session are connected, and |
276 * Checks if power is off and no session are connected, and |
279 * starts a shutdown timer if so. |
277 * starts a shutdown timer if so. |
280 * |
278 * |
281 * @since S60 v3.2 |
279 * @since S60 v3.2 |
282 * @param ?arg1 ?description |
280 * @param ?arg1 ?description |
283 */ |
281 */ |
284 void CheckIdle(); |
282 void CheckIdle(); |
285 |
283 |
286 /** |
284 /** |
287 * ?description |
285 * ?description |
288 * |
286 * |
289 * @since S60 v3.2 |
287 * @since S60 v3.2 |
290 * @param ?arg1 ?description |
288 * @param ?arg1 ?description |
291 */ |
289 */ |
292 TInt SetPowerState( TBool aState ); |
|
293 |
|
294 /** |
|
295 * ?description |
|
296 * |
|
297 * @since S60 v3.2 |
|
298 * @param ?arg1 ?description |
|
299 */ |
|
300 TInt SetLocalNameL(); |
|
301 |
|
302 TInt GetLocalNameFromRegistryL(TDes& aName); |
|
303 |
|
304 /** |
|
305 * ?description |
|
306 * |
|
307 * @since S60 v3.2 |
|
308 * @param ?arg1 ?description |
|
309 */ |
|
310 void SetClassOfDeviceL(); |
|
311 |
|
312 /** |
|
313 * ?description |
|
314 * |
|
315 * @since S60 v3.2 |
|
316 * @param ?arg1 ?description |
|
317 */ |
|
318 void InitBTStackL(); |
|
319 |
|
320 /** |
|
321 * ?description |
|
322 * |
|
323 * @since S60 v3.2 |
|
324 * @param ?arg1 ?description |
|
325 */ |
|
326 void StopBTStackL(); |
|
327 |
|
328 /** |
|
329 * ?description |
|
330 * |
|
331 * @since S60 v3.2 |
|
332 * @param ?arg1 ?description |
|
333 */ |
|
334 void UpdateCenRepPowerKeyL( TBTPowerStateValue aValue ); |
|
335 |
|
336 /** |
|
337 * ?description |
|
338 * |
|
339 * @since S60 v3.2 |
|
340 * @param ?arg1 ?description |
|
341 */ |
|
342 void LoadBTPowerManagerL(); |
|
343 |
|
344 /** |
|
345 * ?description |
|
346 * |
|
347 * @since S60 v3.2 |
|
348 * @param ?arg1 ?description |
|
349 */ |
|
350 void ManageDIServiceL( TBool aState ); |
290 void ManageDIServiceL( TBool aState ); |
351 |
291 |
352 /** |
292 /** |
353 * Reads the product-specific IDs for this phone from central repository. |
293 * Callback function for completion of disconnecting all |
354 * These values are used in the BT Device Information profile. |
294 * Bluetoooth Baseband links. |
355 * |
|
356 * @since S60 v3.2 |
|
357 * @param aVendorId On return, holds the vendor ID for this phone. |
|
358 * @param aProductId On return, holds the product ID for this phone. |
|
359 */ |
|
360 void GetProductIdsL( TInt& aVendorId, TInt& aProductId ); |
|
361 |
|
362 /** |
|
363 * Checks if a client requests temporary power on/off, and keeps track |
|
364 * of the number of clients requesting that. |
|
365 * |
|
366 * @since S60 v5.0 |
|
367 * @param aCurrentState On return, will contain the current power state. |
|
368 * @param aNewState The requested power state. |
|
369 * @param aTemporary Indicates if this is about a tempororary state change. |
|
370 */ |
|
371 void CheckTemporaryPowerStateL( TBTPowerStateValue& aCurrentState, |
|
372 TBTPowerStateValue aNewState, |
|
373 TBool aTemporary ); |
|
374 |
|
375 /** |
|
376 * Callback function for expiry of CDeltaTimer timer of temporary |
|
377 * visibility mode. |
|
378 * |
295 * |
379 * @since S60 v3.2 |
296 * @since S60 v3.2 |
380 * @param aPtr Pointer to ourselves. |
297 * @param aPtr Pointer to ourselves. |
381 * @return Result |
298 * @return Result |
382 */ |
299 */ |
383 static TInt ScanModeTimerCallBack( TAny* aPtr ); |
|
384 |
|
385 /** |
|
386 * Callback function for completion of disconnecting all |
|
387 * Bluetoooth Baseband links. |
|
388 * |
|
389 * @since S60 v3.2 |
|
390 * @param aPtr Pointer to ourselves. |
|
391 * @return Result |
|
392 */ |
|
393 static TInt DisconnectAllCallBack( TAny* aPtr ); |
300 static TInt DisconnectAllCallBack( TAny* aPtr ); |
394 |
301 |
395 /** |
|
396 * Callback function for expiriy CDeltaTimer timer of server idle timeout. |
|
397 * |
|
398 * @since S60 v3.2 |
|
399 * @param aPtr Pointer to ourselves. |
|
400 * @return Result |
|
401 */ |
|
402 static TInt IdleTimerCallBack( TAny* aPtr ); |
|
403 |
|
404 /** |
|
405 * Callback function for expiriy CDeltaTimer timer of |
|
406 * Simple Pairing Debug Mode. |
|
407 * |
|
408 * @since S60 v3.2 |
|
409 * @param aPtr Pointer to ourselves. |
|
410 * @return Result |
|
411 */ |
|
412 static TInt DebugModeTimerCallBack( TAny* aPtr ); |
|
413 |
|
414 /** |
302 /** |
415 * Callback function for turning BT off automatically after all |
303 * Callback function for turning BT off automatically after all |
416 * connections are gone. |
304 * connections are gone. |
417 * |
305 * |
418 * @since S60 v5.0 |
306 * @since S60 v5.0 |
419 * @param aPtr Pointer to ourselves. |
307 * @param aPtr Pointer to ourselves. |
420 * @return Result |
308 * @return Result |
421 */ |
309 */ |
422 static TInt AutoPowerOffCallBack( TAny* aPtr ); |
310 static TInt AutoPowerOffCallBack( TAny* aPtr ); |
423 |
311 |
|
312 // from base class CPolicyServer |
|
313 |
|
314 /** |
|
315 * From CPolicyServer. |
|
316 * ?description |
|
317 * |
|
318 * @since S60 v3.2 |
|
319 * @param ?arg1 ?description |
|
320 */ |
|
321 virtual CSession2* NewSessionL( const TVersion& aVersion, |
|
322 const RMessage2& aMessage ) const; |
|
323 |
|
324 private: |
|
325 |
|
326 CBTEngServer(); |
|
327 |
|
328 void ConstructL(); |
|
329 |
|
330 /** |
|
331 * Reads the product-specific IDs for this phone from central repository. |
|
332 * These values are used in the BT Device Information profile. |
|
333 * |
|
334 * @since S60 v3.2 |
|
335 * @param aVendorId On return, holds the vendor ID for this phone. |
|
336 * @param aProductId On return, holds the product ID for this phone. |
|
337 */ |
|
338 void GetProductIdsL( TInt& aVendorId, TInt& aProductId ); |
|
339 |
|
340 /** |
|
341 * Callback function for expiry of CDeltaTimer timer of temporary |
|
342 * visibility mode. |
|
343 * |
|
344 * @since S60 v3.2 |
|
345 * @param aPtr Pointer to ourselves. |
|
346 * @return Result |
|
347 */ |
|
348 static TInt ScanModeTimerCallBack( TAny* aPtr ); |
|
349 |
|
350 /** |
|
351 * Callback function for expiriy CDeltaTimer timer of server idle timeout. |
|
352 * |
|
353 * @since S60 v3.2 |
|
354 * @param aPtr Pointer to ourselves. |
|
355 * @return Result |
|
356 */ |
|
357 static TInt IdleTimerCallBack( TAny* aPtr ); |
|
358 |
|
359 /** |
|
360 * Callback function for expiriy CDeltaTimer timer of |
|
361 * Simple Pairing Debug Mode. |
|
362 * |
|
363 * @since S60 v3.2 |
|
364 * @param aPtr Pointer to ourselves. |
|
365 * @return Result |
|
366 */ |
|
367 static TInt DebugModeTimerCallBack( TAny* aPtr ); |
|
368 |
424 private: // data |
369 private: // data |
425 |
370 |
426 /** |
371 /** |
427 * Counter of the number of open sessions, which is used to |
372 * Counter of the number of open sessions, which is used to |
428 * stop the server when no session exists and Bluetooth is off. |
373 * stop the server when no session exists and Bluetooth is off. |