|
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: Helper class for handling Bluetooth Baseband-related |
|
15 * connection management. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef BTENGSRVBBCONNECTIONMGR_H |
|
22 #define BTENGSRVBBCONNECTIONMGR_H |
|
23 |
|
24 |
|
25 #include <bt_sock.h> |
|
26 |
|
27 #include "btengactive.h" |
|
28 |
|
29 class CBTEngActive; |
|
30 |
|
31 /** ?description */ |
|
32 //const ?type ?constant_var = ?constant; |
|
33 |
|
34 |
|
35 /** |
|
36 * ?one_line_short_description |
|
37 * |
|
38 * ?more_complete_description |
|
39 * |
|
40 * @lib ?library |
|
41 * @since S60 v3.2 |
|
42 */ |
|
43 NONSHARABLE_CLASS( CBTEngSrvBBConnMgr ) : public CBase, |
|
44 public MBluetoothPhysicalLinksNotifier, |
|
45 public MBTEngActiveObserver |
|
46 { |
|
47 |
|
48 public: |
|
49 |
|
50 /** |
|
51 * Two-phase constructor |
|
52 */ |
|
53 static CBTEngSrvBBConnMgr* NewL(RSocketServ& aSockServ); |
|
54 |
|
55 /** |
|
56 * Destructor |
|
57 */ |
|
58 virtual ~CBTEngSrvBBConnMgr(); |
|
59 |
|
60 /** |
|
61 * Subscribes to relevant events from BT Baseband, and also WLAN events. |
|
62 * |
|
63 * @since S60 v3.2 |
|
64 */ |
|
65 void Subscribe(); |
|
66 |
|
67 /** |
|
68 * Stops listening to BT Baseband and WLAN events. |
|
69 * |
|
70 * @since S60 v3.2 |
|
71 */ |
|
72 void Unsubscribe(); |
|
73 |
|
74 /** |
|
75 * Attempts to re-arrange the topology into a single piconet if necessary. |
|
76 * |
|
77 * @since S60 v3.2 |
|
78 * @param ?arg1 ?description |
|
79 * @param ?arg2 ?description |
|
80 * @return ?description |
|
81 */ |
|
82 TInt ManageTopology( TBool aPrepDiscovery ); |
|
83 |
|
84 /** |
|
85 * Gets the addresses of all connected Bluetooth devices. |
|
86 * |
|
87 * @since S60 v3.2 |
|
88 * @param On return, holds the addresses of connected BT devices. |
|
89 */ |
|
90 void GetConnectedAddressesL( RBTDevAddrArray& aAddrArray ); |
|
91 |
|
92 /** |
|
93 * Disconnect all Bluetooth baseband connections. |
|
94 * |
|
95 * @since S60 v3.2 |
|
96 * @param ?arg1 ?description |
|
97 * @param ?arg2 ?description |
|
98 * @return ?description |
|
99 */ |
|
100 void DisconnectAllLinksL( TCallBack& aCallBack ); |
|
101 |
|
102 /** |
|
103 * Indicate to turn off BT when idle. |
|
104 * |
|
105 * @since S60 v5.0 |
|
106 * @param aEnable Enable or disable automatic power off. |
|
107 * @param aCallBack re-use DisconnectAll callback. |
|
108 */ |
|
109 void SetAutoSwitchOff( TBool aEnable, TCallBack& aCallBack ); |
|
110 |
|
111 // from base class MBluetoothPhysicalLinksNotifier |
|
112 |
|
113 /** |
|
114 * From MBluetoothPhysicalLinksNotifier. |
|
115 * Notification of a requested connection coming up. Not used here. |
|
116 * |
|
117 * @since S60 v3.2 |
|
118 * @param ?arg1 ?description |
|
119 */ |
|
120 virtual void HandleCreateConnectionCompleteL( TInt aErr ); |
|
121 |
|
122 /** |
|
123 * From MBluetoothPhysicalLinksNotifier. |
|
124 * Notification of a requested disconnection having taken |
|
125 * place. Not used here. |
|
126 * |
|
127 * @since S60 v3.2 |
|
128 * @param ?arg1 ?description |
|
129 */ |
|
130 virtual void HandleDisconnectCompleteL( TInt aErr ); |
|
131 |
|
132 /** |
|
133 * From MBluetoothPhysicalLinksNotifier. |
|
134 * Notification that all existing connections have been torn down. |
|
135 * |
|
136 * @since S60 v3.2 |
|
137 * @param ?arg1 ?description |
|
138 */ |
|
139 virtual void HandleDisconnectAllCompleteL( TInt aErr ); |
|
140 |
|
141 // from base class MBTEngActiveObserver |
|
142 |
|
143 /** |
|
144 * From MBTEngActiveObserver. |
|
145 * Callback to notify that an outstanding request has completed. |
|
146 * |
|
147 * @since S60 v3.2 |
|
148 * @param aActive Pointer to the active object that completed. |
|
149 * @param aId The ID that identifies the outstanding request. |
|
150 * @param aStatus The status of the completed request. |
|
151 */ |
|
152 virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, |
|
153 TInt aStatus ); |
|
154 |
|
155 /** |
|
156 * From MBTEngActiveObserver. |
|
157 * Callback to notify that an error has occurred in RunL. |
|
158 * |
|
159 * @since S60 v3.2 |
|
160 * @param aActive Pointer to the active object that completed. |
|
161 * @param aId The ID that identifies the outstanding request. |
|
162 * @param aStatus The status of the completed request. |
|
163 */ |
|
164 virtual void HandleError( CBTEngActive* aActive, TInt aId, |
|
165 TInt aError ); |
|
166 |
|
167 private: |
|
168 |
|
169 /** |
|
170 * C++ default constructor |
|
171 */ |
|
172 CBTEngSrvBBConnMgr(RSocketServ& aSockServ); |
|
173 |
|
174 /** |
|
175 * Symbian 2nd-phase constructor |
|
176 */ |
|
177 void ConstructL(); |
|
178 |
|
179 /** |
|
180 * Gets the WLAN connection status, if activated. |
|
181 * |
|
182 * @since S60 v3.2 |
|
183 * @return ETrue if a WLAN connection is active, otherwise EFalse. |
|
184 */ |
|
185 TBool GetWlanStatus(); |
|
186 |
|
187 private: // data |
|
188 |
|
189 /** |
|
190 * Flag to indicate if we should monitor WLAN connection status. |
|
191 */ |
|
192 TBool iWlanSupported; |
|
193 |
|
194 /** |
|
195 * Flag to indicate that BT is to be switched off when active. |
|
196 */ |
|
197 TBool iAutoSwitchOff; |
|
198 |
|
199 /** |
|
200 * ?description_of_member |
|
201 */ |
|
202 RProperty iLinkCountProperty; |
|
203 |
|
204 /** |
|
205 * ?description_of_member |
|
206 */ |
|
207 RProperty iWlanStatusProperty; |
|
208 |
|
209 /** |
|
210 * Session with the socket server. Not own! |
|
211 */ |
|
212 RSocketServ& iSockServ; |
|
213 |
|
214 /** |
|
215 * BT Link Manager socket. |
|
216 * Own. |
|
217 */ |
|
218 CBluetoothPhysicalLinks* iPhyLinks; |
|
219 |
|
220 /** |
|
221 * Active object for monitoring BT link count. |
|
222 * Own. |
|
223 */ |
|
224 CBTEngActive* iLinkCountWatcher; |
|
225 |
|
226 /** |
|
227 * Active object for monitoring BT link count. |
|
228 * Own. |
|
229 */ |
|
230 CBTEngActive* iWlanWatcher; |
|
231 |
|
232 /** |
|
233 * Callback function to call when disconnecting all links has completed. |
|
234 * Not own. |
|
235 */ |
|
236 TCallBack iCallBack; |
|
237 |
|
238 }; |
|
239 |
|
240 |
|
241 #endif // BTENGSRVBBCONNECTIONMGR_H |