author | zecke <zecke> | 2005-01-09 16:27:40 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-01-09 16:27:40 (UTC) |
commit | ebd352b30b5b0278e613e1d1ecc60a5fc7756961 (patch) (unidiff) | |
tree | 0a7967a8cf668bf06fd949fbc7e1c9c33043fc60 | |
parent | c6432d421a0ec3d158bf40309e98fc0386c4a287 (diff) | |
download | opie-ebd352b30b5b0278e613e1d1ecc60a5fc7756961.zip opie-ebd352b30b5b0278e613e1d1ecc60a5fc7756961.tar.gz opie-ebd352b30b5b0278e613e1d1ecc60a5fc7756961.tar.bz2 |
-Do not access the Array out of bounds
-Check that there is a driver before asking
to query a non existant
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/OTGateway.cpp | 1 | ||||
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/OTGateway.h | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp index e8137dd..1b61a2e 100644 --- a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp | |||
@@ -1,531 +1,532 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qfile.h> | 2 | #include <qfile.h> |
3 | #include <qdir.h> | 3 | #include <qdir.h> |
4 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
5 | #include <qpixmap.h> | 5 | #include <qpixmap.h> |
6 | #include <qvector.h> | 6 | #include <qvector.h> |
7 | #include <qpe/resource.h> | 7 | #include <qpe/resource.h> |
8 | 8 | ||
9 | #include <opie2/odebug.h> | 9 | #include <opie2/odebug.h> |
10 | 10 | ||
11 | #include <bluezlib.h> | 11 | #include <bluezlib.h> |
12 | 12 | ||
13 | #include <OTDevice.h> | 13 | #include <OTDevice.h> |
14 | #include <OTDriver.h> | 14 | #include <OTDriver.h> |
15 | #include <OTInquiry.h> | 15 | #include <OTInquiry.h> |
16 | #include <OTDriverList.h> | 16 | #include <OTDriverList.h> |
17 | #include <OTDeviceAddress.h> | 17 | #include <OTDeviceAddress.h> |
18 | #include <OTGateway.h> | 18 | #include <OTGateway.h> |
19 | 19 | ||
20 | using namespace Opietooth2; | 20 | using namespace Opietooth2; |
21 | 21 | ||
22 | // single instance | 22 | // single instance |
23 | OTGateway * OTGateway::SingleGateway = 0; | 23 | OTGateway * OTGateway::SingleGateway = 0; |
24 | int OTGateway::UseCount = 0; | 24 | int OTGateway::UseCount = 0; |
25 | 25 | ||
26 | OTGateway * OTGateway::getOTGateway( void ) { | 26 | OTGateway * OTGateway::getOTGateway( void ) { |
27 | if(SingleGateway == 0 ) { | 27 | if(SingleGateway == 0 ) { |
28 | SingleGateway = new OTGateway(); | 28 | SingleGateway = new OTGateway(); |
29 | } | 29 | } |
30 | 30 | ||
31 | UseCount ++; | 31 | UseCount ++; |
32 | return SingleGateway; | 32 | return SingleGateway; |
33 | } | 33 | } |
34 | 34 | ||
35 | void OTGateway::releaseOTGateway( void ) { | 35 | void OTGateway::releaseOTGateway( void ) { |
36 | UseCount --; | 36 | UseCount --; |
37 | if( UseCount == 0 ) { | 37 | if( UseCount == 0 ) { |
38 | delete SingleGateway; | 38 | delete SingleGateway; |
39 | SingleGateway = 0; | 39 | SingleGateway = 0; |
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
43 | // open bluetooth system | 43 | // open bluetooth system |
44 | OTGateway::OTGateway( void ) : QObject( 0, "OTGateway" ), | 44 | OTGateway::OTGateway( void ) : QObject( 0, "OTGateway" ), |
45 | AllDrivers( this ), | 45 | AllDrivers( this ), |
46 | AllPeers() { | 46 | AllPeers() { |
47 | 47 | ||
48 | ErrorConnectCount = 0; | 48 | ErrorConnectCount = 0; |
49 | TheOTDevice = 0; | 49 | TheOTDevice = 0; |
50 | Scanning = 0; | 50 | Scanning = 0; |
51 | AllPeersModified = 0; | 51 | AllPeersModified = 0; |
52 | AllPeers.setAutoDelete( TRUE ); | 52 | AllPeers.setAutoDelete( TRUE ); |
53 | 53 | ||
54 | if ( ( HciCtl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) { | 54 | if ( ( HciCtl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) { |
55 | SLOT_ShowError( tr( "error opening hci socket" ) ); | 55 | SLOT_ShowError( tr( "error opening hci socket" ) ); |
56 | return; | 56 | return; |
57 | } | 57 | } |
58 | 58 | ||
59 | // load all known devices | 59 | // load all known devices |
60 | updateDrivers(); | 60 | updateDrivers(); |
61 | 61 | ||
62 | // load all peers we have ever seen | 62 | // load all peers we have ever seen |
63 | loadKnownPeers(); | 63 | loadKnownPeers(); |
64 | 64 | ||
65 | // iterate over drivers and find active connections | 65 | // iterate over drivers and find active connections |
66 | // adding/updating peers | 66 | // adding/updating peers |
67 | loadActiveConnections(); | 67 | loadActiveConnections(); |
68 | 68 | ||
69 | // check every 4 seconds the state of BT | 69 | // check every 4 seconds the state of BT |
70 | timerEvent(0); | 70 | timerEvent(0); |
71 | RefreshTimer = -1; | 71 | RefreshTimer = -1; |
72 | setRefreshTimer( 4000 ); | 72 | setRefreshTimer( 4000 ); |
73 | 73 | ||
74 | // load known link keys | 74 | // load known link keys |
75 | readLinkKeys(); | 75 | readLinkKeys(); |
76 | } | 76 | } |
77 | 77 | ||
78 | // close bluetooth system | 78 | // close bluetooth system |
79 | OTGateway::~OTGateway( void ) { | 79 | OTGateway::~OTGateway( void ) { |
80 | 80 | ||
81 | if( AllPeersModified ) { | 81 | if( AllPeersModified ) { |
82 | saveKnownPeers(); | 82 | saveKnownPeers(); |
83 | } | 83 | } |
84 | 84 | ||
85 | if( Scanning ) | 85 | if( Scanning ) |
86 | delete Scanning; | 86 | delete Scanning; |
87 | 87 | ||
88 | if( TheOTDevice ) | 88 | if( TheOTDevice ) |
89 | delete TheOTDevice; | 89 | delete TheOTDevice; |
90 | 90 | ||
91 | if( HciCtl >= 0 ) { | 91 | if( HciCtl >= 0 ) { |
92 | ::close( HciCtl ); | 92 | ::close( HciCtl ); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void OTGateway::setRefreshTimer( int T ) { | 96 | void OTGateway::setRefreshTimer( int T ) { |
97 | if( RefreshTimer != -1 ) { | 97 | if( RefreshTimer != -1 ) { |
98 | killTimer( RefreshTimer ); | 98 | killTimer( RefreshTimer ); |
99 | } | 99 | } |
100 | 100 | ||
101 | if( T == 0 ) | 101 | if( T == 0 ) |
102 | T = 4000; | 102 | T = 4000; |
103 | RefreshTimer = startTimer( T ); | 103 | RefreshTimer = startTimer( T ); |
104 | } | 104 | } |
105 | 105 | ||
106 | OTDevice * OTGateway::getOTDevice( ) { | 106 | OTDevice * OTGateway::getOTDevice( ) { |
107 | if( TheOTDevice == 0 ) { | 107 | if( TheOTDevice == 0 ) { |
108 | // load bluetooth device and check state | 108 | // load bluetooth device and check state |
109 | TheOTDevice = new OTDevice( this ); | 109 | TheOTDevice = new OTDevice( this ); |
110 | connect( TheOTDevice, | 110 | connect( TheOTDevice, |
111 | SIGNAL( isEnabled( int, bool ) ), | 111 | SIGNAL( isEnabled( int, bool ) ), |
112 | this, | 112 | this, |
113 | SLOT( SLOT_Enabled( int, bool ) ) ); | 113 | SLOT( SLOT_Enabled( int, bool ) ) ); |
114 | 114 | ||
115 | connect( TheOTDevice, | 115 | connect( TheOTDevice, |
116 | SIGNAL( error( const QString & ) ), | 116 | SIGNAL( error( const QString & ) ), |
117 | this, | 117 | this, |
118 | SLOT( SLOT_ShowError( const QString & ) ) ); | 118 | SLOT( SLOT_ShowError( const QString & ) ) ); |
119 | } | 119 | } |
120 | 120 | ||
121 | return TheOTDevice; | 121 | return TheOTDevice; |
122 | } | 122 | } |
123 | 123 | ||
124 | // start bluetooth (if stopped) | 124 | // start bluetooth (if stopped) |
125 | // return TRUE if started | 125 | // return TRUE if started |
126 | void OTGateway::SLOT_SetEnabled( bool Mode ) { | 126 | void OTGateway::SLOT_SetEnabled( bool Mode ) { |
127 | if( Mode ) { | 127 | if( Mode ) { |
128 | SLOT_Enable(); | 128 | SLOT_Enable(); |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | SLOT_Disable(); | 131 | SLOT_Disable(); |
132 | } | 132 | } |
133 | 133 | ||
134 | void OTGateway::SLOT_Enable() { | 134 | void OTGateway::SLOT_Enable() { |
135 | getOTDevice()->attach(); | 135 | getOTDevice()->attach(); |
136 | } | 136 | } |
137 | 137 | ||
138 | void OTGateway::SLOT_Disable() { | 138 | void OTGateway::SLOT_Disable() { |
139 | getOTDevice()->detach(); | 139 | getOTDevice()->detach(); |
140 | } | 140 | } |
141 | 141 | ||
142 | bool OTGateway::needsEnabling() { | 142 | bool OTGateway::needsEnabling() { |
143 | return getOTDevice()->needsAttach(); | 143 | return getOTDevice()->needsAttach(); |
144 | } | 144 | } |
145 | 145 | ||
146 | bool OTGateway::isEnabled() { | 146 | bool OTGateway::isEnabled() { |
147 | if( getOTDevice()->deviceNr() >= 0 && | 147 | if( getOTDevice()->deviceNr() >= 0 && |
148 | AllDrivers.count() != 0 && | ||
148 | driver( getOTDevice()->deviceNr() )->isUp() ) | 149 | driver( getOTDevice()->deviceNr() )->isUp() ) |
149 | return TRUE; | 150 | return TRUE; |
150 | 151 | ||
151 | // else check system | 152 | // else check system |
152 | return getOTDevice()->isAttached(); | 153 | return getOTDevice()->isAttached(); |
153 | } | 154 | } |
154 | 155 | ||
155 | void OTGateway::SLOT_ShowError( const QString & S ) { | 156 | void OTGateway::SLOT_ShowError( const QString & S ) { |
156 | 157 | ||
157 | odebug << S << oendl; | 158 | odebug << S << oendl; |
158 | 159 | ||
159 | if( ErrorConnectCount > 0 ) { | 160 | if( ErrorConnectCount > 0 ) { |
160 | // pass error | 161 | // pass error |
161 | emit error( QString( "<p>" ) + S + "</p>" ); | 162 | emit error( QString( "<p>" ) + S + "</p>" ); |
162 | return; | 163 | return; |
163 | } | 164 | } |
164 | 165 | ||
165 | QMessageBox::warning( 0, | 166 | QMessageBox::warning( 0, |
166 | tr("OTGateway error"), | 167 | tr("OTGateway error"), |
167 | S ); | 168 | S ); |
168 | } | 169 | } |
169 | 170 | ||
170 | void OTGateway::connectNotify( const char * S ) { | 171 | void OTGateway::connectNotify( const char * S ) { |
171 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { | 172 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { |
172 | ErrorConnectCount ++; | 173 | ErrorConnectCount ++; |
173 | } | 174 | } |
174 | } | 175 | } |
175 | 176 | ||
176 | void OTGateway::disconnectNotify( const char * S ) { | 177 | void OTGateway::disconnectNotify( const char * S ) { |
177 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { | 178 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { |
178 | ErrorConnectCount --; | 179 | ErrorConnectCount --; |
179 | } | 180 | } |
180 | } | 181 | } |
181 | 182 | ||
182 | void OTGateway::timerEvent( QTimerEvent * ) { | 183 | void OTGateway::timerEvent( QTimerEvent * ) { |
183 | 184 | ||
184 | OTDriver * D; | 185 | OTDriver * D; |
185 | unsigned int oldc = AllDrivers.count(); | 186 | unsigned int oldc = AllDrivers.count(); |
186 | bool old; | 187 | bool old; |
187 | 188 | ||
188 | AllDrivers.update(); | 189 | AllDrivers.update(); |
189 | 190 | ||
190 | if( oldc != AllDrivers.count() ) { | 191 | if( oldc != AllDrivers.count() ) { |
191 | updateDrivers(); | 192 | updateDrivers(); |
192 | } else { | 193 | } else { |
193 | for( unsigned int i = 0; | 194 | for( unsigned int i = 0; |
194 | i < AllDrivers.count(); | 195 | i < AllDrivers.count(); |
195 | i ++ ) { | 196 | i ++ ) { |
196 | D = AllDrivers[i]; | 197 | D = AllDrivers[i]; |
197 | old = D->isUp(); | 198 | old = D->isUp(); |
198 | if( D->currentState() >= 0 ) { | 199 | if( D->currentState() >= 0 ) { |
199 | if( old != D->isUp() ) { | 200 | if( old != D->isUp() ) { |
200 | emit stateChange( D, D->isUp() ); | 201 | emit stateChange( D, D->isUp() ); |
201 | } | 202 | } |
202 | } else { | 203 | } else { |
203 | // if one driver is unable to provide info | 204 | // if one driver is unable to provide info |
204 | // we refresh all devices | 205 | // we refresh all devices |
205 | updateDrivers(); | 206 | updateDrivers(); |
206 | return; | 207 | return; |
207 | } | 208 | } |
208 | } | 209 | } |
209 | } | 210 | } |
210 | } | 211 | } |
211 | 212 | ||
212 | void OTGateway::SLOT_Enabled( int id, bool Up ) { | 213 | void OTGateway::SLOT_Enabled( int id, bool Up ) { |
213 | odebug << "device " << id << " state " << Up << oendl; | 214 | odebug << "device " << id << " state " << Up << oendl; |
214 | if( Up ) { | 215 | if( Up ) { |
215 | // device is up -> detect it | 216 | // device is up -> detect it |
216 | updateDrivers(); | 217 | updateDrivers(); |
217 | if( (unsigned)id >= AllDrivers.count() ) { | 218 | if( (unsigned)id >= AllDrivers.count() ) { |
218 | // to make sure that the driver really IS detected | 219 | // to make sure that the driver really IS detected |
219 | AllDrivers[id]->bringUp(); | 220 | AllDrivers[id]->bringUp(); |
220 | } | 221 | } |
221 | } // if DOWN device already down | 222 | } // if DOWN device already down |
222 | emit deviceEnabled( Up ); | 223 | emit deviceEnabled( Up ); |
223 | } | 224 | } |
224 | 225 | ||
225 | void OTGateway::updateDrivers( void ) { | 226 | void OTGateway::updateDrivers( void ) { |
226 | OTDriver * D; | 227 | OTDriver * D; |
227 | 228 | ||
228 | AllDrivers.update(); | 229 | AllDrivers.update(); |
229 | 230 | ||
230 | odebug << "updated drivers. now " << AllDrivers.count() << oendl; | 231 | odebug << "updated drivers. now " << AllDrivers.count() << oendl; |
231 | 232 | ||
232 | // connect signals for each driver | 233 | // connect signals for each driver |
233 | for( unsigned int i = 0; | 234 | for( unsigned int i = 0; |
234 | i < AllDrivers.count(); | 235 | i < AllDrivers.count(); |
235 | i ++ ) { | 236 | i ++ ) { |
236 | D = AllDrivers[i]; | 237 | D = AllDrivers[i]; |
237 | 238 | ||
238 | connect( D, | 239 | connect( D, |
239 | SIGNAL( error( const QString & ) ), | 240 | SIGNAL( error( const QString & ) ), |
240 | this, | 241 | this, |
241 | SLOT( SLOT_ShowError( const QString & ) ) | 242 | SLOT( SLOT_ShowError( const QString & ) ) |
242 | ); | 243 | ); |
243 | 244 | ||
244 | connect( D, | 245 | connect( D, |
245 | SIGNAL( stateChange( OTDriver *, bool ) ), | 246 | SIGNAL( stateChange( OTDriver *, bool ) ), |
246 | this, | 247 | this, |
247 | SIGNAL( stateChange( OTDriver *, bool ) ) | 248 | SIGNAL( stateChange( OTDriver *, bool ) ) |
248 | ); | 249 | ); |
249 | 250 | ||
250 | connect( D, | 251 | connect( D, |
251 | SIGNAL( driverDisappeared( OTDriver * ) ), | 252 | SIGNAL( driverDisappeared( OTDriver * ) ), |
252 | this, | 253 | this, |
253 | SLOT( SLOT_DriverDisappeared( OTDriver * ) ) | 254 | SLOT( SLOT_DriverDisappeared( OTDriver * ) ) |
254 | ); | 255 | ); |
255 | } | 256 | } |
256 | 257 | ||
257 | // verify main device too | 258 | // verify main device too |
258 | if( TheOTDevice ) | 259 | if( TheOTDevice ) |
259 | TheOTDevice->checkAttach(); | 260 | TheOTDevice->checkAttach(); |
260 | 261 | ||
261 | // set to default scanning hardware | 262 | // set to default scanning hardware |
262 | setScanWith( 0 ); | 263 | setScanWith( 0 ); |
263 | 264 | ||
264 | emit driverListChanged(); | 265 | emit driverListChanged(); |
265 | } | 266 | } |
266 | 267 | ||
267 | void OTGateway::SLOT_DriverDisappeared( OTDriver * D ) { | 268 | void OTGateway::SLOT_DriverDisappeared( OTDriver * D ) { |
268 | odebug << "Driver " << D->devname() << " when offline" << oendl; | 269 | odebug << "Driver " << D->devname() << " when offline" << oendl; |
269 | updateDrivers(); | 270 | updateDrivers(); |
270 | } | 271 | } |
271 | 272 | ||
272 | void OTGateway::scanNeighbourhood( OTDriver * D ) { | 273 | void OTGateway::scanNeighbourhood( OTDriver * D ) { |
273 | 274 | ||
274 | if( Scanning ) { | 275 | if( Scanning ) { |
275 | stopScanOfNeighbourhood(); | 276 | stopScanOfNeighbourhood(); |
276 | } | 277 | } |
277 | 278 | ||
278 | if( D ) { | 279 | if( D ) { |
279 | setScanWith( D ); | 280 | setScanWith( D ); |
280 | } | 281 | } |
281 | 282 | ||
282 | Scanning = new OTInquiry( scanWith() ); | 283 | Scanning = new OTInquiry( scanWith() ); |
283 | 284 | ||
284 | connect( Scanning, | 285 | connect( Scanning, |
285 | SIGNAL( peerFound( OTPeer *, bool )), | 286 | SIGNAL( peerFound( OTPeer *, bool )), |
286 | this, | 287 | this, |
287 | SLOT( SLOT_PeerDetected( OTPeer *, bool ) ) | 288 | SLOT( SLOT_PeerDetected( OTPeer *, bool ) ) |
288 | ); | 289 | ); |
289 | connect( Scanning, | 290 | connect( Scanning, |
290 | SIGNAL( finished()), | 291 | SIGNAL( finished()), |
291 | this, | 292 | this, |
292 | SLOT( SLOT_FinishedDetecting() ) | 293 | SLOT( SLOT_FinishedDetecting() ) |
293 | ); | 294 | ); |
294 | 295 | ||
295 | // start scanning | 296 | // start scanning |
296 | Scanning->inquire( 30.0 ); | 297 | Scanning->inquire( 30.0 ); |
297 | } | 298 | } |
298 | 299 | ||
299 | OTPeer* OTGateway::findPeer( const OTDeviceAddress & Addr ) { | 300 | OTPeer* OTGateway::findPeer( const OTDeviceAddress & Addr ) { |
300 | for( unsigned int i = 0 ; i < AllPeers.count(); i ++ ) { | 301 | for( unsigned int i = 0 ; i < AllPeers.count(); i ++ ) { |
301 | if( AllPeers[i]->address() == Addr ) { | 302 | if( AllPeers[i]->address() == Addr ) { |
302 | return AllPeers[i]; | 303 | return AllPeers[i]; |
303 | } | 304 | } |
304 | } | 305 | } |
305 | return 0; | 306 | return 0; |
306 | } | 307 | } |
307 | 308 | ||
308 | OTDriver* OTGateway::findDriver( const OTDeviceAddress & Addr ) { | 309 | OTDriver* OTGateway::findDriver( const OTDeviceAddress & Addr ) { |
309 | for( unsigned int i = 0 ; i < AllDrivers.count(); i ++ ) { | 310 | for( unsigned int i = 0 ; i < AllDrivers.count(); i ++ ) { |
310 | if( AllDrivers[i]->address() == Addr ) { | 311 | if( AllDrivers[i]->address() == Addr ) { |
311 | return AllDrivers[i]; | 312 | return AllDrivers[i]; |
312 | } | 313 | } |
313 | } | 314 | } |
314 | return 0; | 315 | return 0; |
315 | } | 316 | } |
316 | 317 | ||
317 | void OTGateway::SLOT_PeerDetected( OTPeer * P, bool IsNew ) { | 318 | void OTGateway::SLOT_PeerDetected( OTPeer * P, bool IsNew ) { |
318 | 319 | ||
319 | if( IsNew ) { | 320 | if( IsNew ) { |
320 | // new peer | 321 | // new peer |
321 | odebug << "New peer " << P->name() << oendl; | 322 | odebug << "New peer " << P->name() << oendl; |
322 | addPeer( P ); | 323 | addPeer( P ); |
323 | } | 324 | } |
324 | 325 | ||
325 | emit detectedPeer( P, IsNew ); | 326 | emit detectedPeer( P, IsNew ); |
326 | } | 327 | } |
327 | 328 | ||
328 | void OTGateway::addPeer( OTPeer * P ) { | 329 | void OTGateway::addPeer( OTPeer * P ) { |
329 | AllPeers.resize( AllPeers.size()+1); | 330 | AllPeers.resize( AllPeers.size()+1); |
330 | AllPeers.insert( AllPeers.size()-1, P ); | 331 | AllPeers.insert( AllPeers.size()-1, P ); |
331 | AllPeersModified = 1; | 332 | AllPeersModified = 1; |
332 | } | 333 | } |
333 | 334 | ||
334 | void OTGateway::removePeer( OTPeer * P ) { | 335 | void OTGateway::removePeer( OTPeer * P ) { |
335 | int i = AllPeers.find( P ); | 336 | int i = AllPeers.find( P ); |
336 | if( i ) { | 337 | if( i ) { |
337 | AllPeers.remove( i ); | 338 | AllPeers.remove( i ); |
338 | AllPeersModified = 1; | 339 | AllPeersModified = 1; |
339 | } | 340 | } |
340 | } | 341 | } |
341 | 342 | ||
342 | void OTGateway::stopScanOfNeighbourhood( void ) { | 343 | void OTGateway::stopScanOfNeighbourhood( void ) { |
343 | if( Scanning ) { | 344 | if( Scanning ) { |
344 | delete Scanning; | 345 | delete Scanning; |
345 | Scanning = 0; | 346 | Scanning = 0; |
346 | } | 347 | } |
347 | } | 348 | } |
348 | 349 | ||
349 | void OTGateway::SLOT_FinishedDetecting() { | 350 | void OTGateway::SLOT_FinishedDetecting() { |
350 | stopScanOfNeighbourhood(); | 351 | stopScanOfNeighbourhood(); |
351 | emit finishedDetecting(); | 352 | emit finishedDetecting(); |
352 | } | 353 | } |
353 | 354 | ||
354 | const char * OTGateway::deviceTypeToName( int cls ) { | 355 | const char * OTGateway::deviceTypeToName( int cls ) { |
355 | switch ( (cls & 0x001F00) >> 8) { | 356 | switch ( (cls & 0x001F00) >> 8) { |
356 | case 0x00: | 357 | case 0x00: |
357 | return "misc"; | 358 | return "misc"; |
358 | case 0x01: | 359 | case 0x01: |
359 | return "computer"; | 360 | return "computer"; |
360 | case 0x02: | 361 | case 0x02: |
361 | return "phone"; | 362 | return "phone"; |
362 | case 0x03: | 363 | case 0x03: |
363 | return "lan"; | 364 | return "lan"; |
364 | case 0x04: | 365 | case 0x04: |
365 | return "av"; | 366 | return "av"; |
366 | case 0x05: | 367 | case 0x05: |
367 | return "peripheral"; | 368 | return "peripheral"; |
368 | case 0x06: | 369 | case 0x06: |
369 | return "imaging"; | 370 | return "imaging"; |
370 | case 0x07: | 371 | case 0x07: |
371 | default : | 372 | default : |
372 | break; | 373 | break; |
373 | } | 374 | } |
374 | return "unknown"; | 375 | return "unknown"; |
375 | } | 376 | } |
376 | 377 | ||
377 | PANConnectionVector OTGateway::getPANConnections( void ) { | 378 | PANConnectionVector OTGateway::getPANConnections( void ) { |
378 | PANConnectionVector V; | 379 | PANConnectionVector V; |
379 | 380 | ||
380 | struct bnep_connlist_req req; | 381 | struct bnep_connlist_req req; |
381 | struct bnep_conninfo ci[48]; | 382 | struct bnep_conninfo ci[48]; |
382 | 383 | ||
383 | V.setAutoDelete(TRUE); | 384 | V.setAutoDelete(TRUE); |
384 | 385 | ||
385 | int ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP); | 386 | int ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP); |
386 | if (ctl < 0) { | 387 | if (ctl < 0) { |
387 | odebug << "Failed to open control socket" << oendl; | 388 | odebug << "Failed to open control socket" << oendl; |
388 | return V; | 389 | return V; |
389 | } | 390 | } |
390 | 391 | ||
391 | req.cnum = 48; | 392 | req.cnum = 48; |
392 | req.ci = ci; | 393 | req.ci = ci; |
393 | if (ioctl(ctl, BNEPGETCONNLIST, &req)) { | 394 | if (ioctl(ctl, BNEPGETCONNLIST, &req)) { |
394 | odebug << "Failed to get connection list" << oendl; | 395 | odebug << "Failed to get connection list" << oendl; |
395 | ::close( ctl ); | 396 | ::close( ctl ); |
396 | return V; | 397 | return V; |
397 | } | 398 | } |
398 | 399 | ||
399 | for ( unsigned i=0; i < req.cnum; i++) { | 400 | for ( unsigned i=0; i < req.cnum; i++) { |
400 | V.resize( V.size() + 1 ); | 401 | V.resize( V.size() + 1 ); |
401 | if( ci[i].role == BNEP_SVC_PANU ) { | 402 | if( ci[i].role == BNEP_SVC_PANU ) { |
402 | // we are the client | 403 | // we are the client |
403 | V.insert( V.size()-1, new OTPANConnection( | 404 | V.insert( V.size()-1, new OTPANConnection( |
404 | ci[i].device, | 405 | ci[i].device, |
405 | batostr((bdaddr_t *) ci[i].dst) | 406 | batostr((bdaddr_t *) ci[i].dst) |
406 | ) ); | 407 | ) ); |
407 | } | 408 | } |
408 | } | 409 | } |
409 | 410 | ||
410 | ::close( ctl ); | 411 | ::close( ctl ); |
411 | return V; | 412 | return V; |
412 | } | 413 | } |
413 | 414 | ||
414 | struct link_key { | 415 | struct link_key { |
415 | bdaddr_t sba; | 416 | bdaddr_t sba; |
416 | bdaddr_t dba; | 417 | bdaddr_t dba; |
417 | uint8_t key[16]; | 418 | uint8_t key[16]; |
418 | uint8_t type; | 419 | uint8_t type; |
419 | time_t time; | 420 | time_t time; |
420 | }; | 421 | }; |
421 | 422 | ||
422 | void OTGateway::readLinkKeys( void ) { | 423 | void OTGateway::readLinkKeys( void ) { |
423 | 424 | ||
424 | struct link_key k; | 425 | struct link_key k; |
425 | int rv; | 426 | int rv; |
426 | 427 | ||
427 | AllKeys.truncate(0); | 428 | AllKeys.truncate(0); |
428 | 429 | ||
429 | QFile F( "/etc/bluetooth/link_key" ); | 430 | QFile F( "/etc/bluetooth/link_key" ); |
430 | 431 | ||
431 | if( ! F.open( IO_ReadOnly ) ) { | 432 | if( ! F.open( IO_ReadOnly ) ) { |
432 | emit error( tr("Cannot open link_key file") ); | 433 | emit error( tr("Cannot open link_key file") ); |
433 | return; | 434 | return; |
434 | } | 435 | } |
435 | 436 | ||
436 | while( 1 ) { | 437 | while( 1 ) { |
437 | rv = F.readBlock( (char *)&k, sizeof( k ) ); | 438 | rv = F.readBlock( (char *)&k, sizeof( k ) ); |
438 | if( rv == 0 ) | 439 | if( rv == 0 ) |
439 | // EOF | 440 | // EOF |
440 | break; | 441 | break; |
441 | 442 | ||
442 | if( rv < 0 ) { | 443 | if( rv < 0 ) { |
443 | emit error( tr("Read error in link key file") ); | 444 | emit error( tr("Read error in link key file") ); |
444 | } | 445 | } |
445 | 446 | ||
446 | AllKeys.resize( AllKeys.size()+1 ); | 447 | AllKeys.resize( AllKeys.size()+1 ); |
447 | AllKeys[ AllKeys.size()-1 ].From.setBDAddr( k.sba ); | 448 | AllKeys[ AllKeys.size()-1 ].From.setBDAddr( k.sba ); |
448 | AllKeys[ AllKeys.size()-1 ].To.setBDAddr( k.dba ); | 449 | AllKeys[ AllKeys.size()-1 ].To.setBDAddr( k.dba ); |
449 | } | 450 | } |
450 | } | 451 | } |
451 | 452 | ||
452 | bool OTGateway::removeLinkKey( unsigned int Index ) { | 453 | bool OTGateway::removeLinkKey( unsigned int Index ) { |
453 | OTLinkKey & LK = AllKeys[Index]; | 454 | OTLinkKey & LK = AllKeys[Index]; |
454 | 455 | ||
455 | struct link_key k; | 456 | struct link_key k; |
456 | int rv; | 457 | int rv; |
457 | 458 | ||
458 | QFile F( "/etc/bluetooth/link_key" ); | 459 | QFile F( "/etc/bluetooth/link_key" ); |
459 | QFile OutF( "/etc/bluetooth/newlink_key" ); | 460 | QFile OutF( "/etc/bluetooth/newlink_key" ); |
460 | 461 | ||
461 | if( ! F.open( IO_ReadOnly ) ) { | 462 | if( ! F.open( IO_ReadOnly ) ) { |
462 | emit error( tr("Cannot open link_key file") ); | 463 | emit error( tr("Cannot open link_key file") ); |
463 | return 0; | 464 | return 0; |
464 | } | 465 | } |
465 | 466 | ||
466 | if( ! OutF.open( IO_WriteOnly | IO_Truncate ) ) { | 467 | if( ! OutF.open( IO_WriteOnly | IO_Truncate ) ) { |
467 | emit error( tr("Cannot open temporary link_key file") ); | 468 | emit error( tr("Cannot open temporary link_key file") ); |
468 | return 0; | 469 | return 0; |
469 | } | 470 | } |
470 | 471 | ||
471 | while( 1 ) { | 472 | while( 1 ) { |
472 | rv = F.readBlock( (char *)&k, sizeof( k ) ); | 473 | rv = F.readBlock( (char *)&k, sizeof( k ) ); |
473 | if( rv == 0 ) | 474 | if( rv == 0 ) |
474 | // EOF | 475 | // EOF |
475 | break; | 476 | break; |
476 | 477 | ||
477 | if( rv < 0 ) { | 478 | if( rv < 0 ) { |
478 | emit error( tr("Read error in link key file") ); | 479 | emit error( tr("Read error in link key file") ); |
479 | return 0; | 480 | return 0; |
480 | } | 481 | } |
481 | 482 | ||
482 | if( LK.from() != OTDeviceAddress( k.sba ) || | 483 | if( LK.from() != OTDeviceAddress( k.sba ) || |
483 | LK.to() != OTDeviceAddress( k.dba ) ) { | 484 | LK.to() != OTDeviceAddress( k.dba ) ) { |
484 | // copy | 485 | // copy |
485 | OutF.writeBlock( (char *)&k, sizeof( k ) ); | 486 | OutF.writeBlock( (char *)&k, sizeof( k ) ); |
486 | } // else remove this key | 487 | } // else remove this key |
487 | } | 488 | } |
488 | 489 | ||
489 | // rename files | 490 | // rename files |
490 | QDir D( "/etc/bluetooth" ); | 491 | QDir D( "/etc/bluetooth" ); |
491 | 492 | ||
492 | D.remove( "link_key" ); | 493 | D.remove( "link_key" ); |
493 | D.rename( "newlink_key", "link_key" ); | 494 | D.rename( "newlink_key", "link_key" ); |
494 | 495 | ||
495 | // restart hcid | 496 | // restart hcid |
496 | system( "/etc/init.d/hcid stop" ); | 497 | system( "/etc/init.d/hcid stop" ); |
497 | system( "/etc/init.d/hcid start" ); | 498 | system( "/etc/init.d/hcid start" ); |
498 | 499 | ||
499 | // remove from table | 500 | // remove from table |
500 | if( Index < (AllKeys.size()-1) ) { | 501 | if( Index < (AllKeys.size()-1) ) { |
501 | // collapse array | 502 | // collapse array |
502 | AllKeys[Index] = AllKeys[AllKeys.size()-1]; | 503 | AllKeys[Index] = AllKeys[AllKeys.size()-1]; |
503 | } | 504 | } |
504 | 505 | ||
505 | // remove last element | 506 | // remove last element |
506 | AllKeys.resize( AllKeys.size()-1 ); | 507 | AllKeys.resize( AllKeys.size()-1 ); |
507 | 508 | ||
508 | return 1; | 509 | return 1; |
509 | } | 510 | } |
510 | 511 | ||
511 | #define MAXCONNECTIONS 10 | 512 | #define MAXCONNECTIONS 10 |
512 | void OTGateway::loadActiveConnections( void ) { | 513 | void OTGateway::loadActiveConnections( void ) { |
513 | 514 | ||
514 | struct hci_conn_list_req *cl; | 515 | struct hci_conn_list_req *cl; |
515 | struct hci_conn_info *ci; | 516 | struct hci_conn_info *ci; |
516 | OTDeviceAddress Addr; | 517 | OTDeviceAddress Addr; |
517 | OTPeer * P; | 518 | OTPeer * P; |
518 | 519 | ||
519 | if (!(cl = (struct hci_conn_list_req *)malloc( | 520 | if (!(cl = (struct hci_conn_list_req *)malloc( |
520 | MAXCONNECTIONS * sizeof(*ci) + sizeof(*cl)))) { | 521 | MAXCONNECTIONS * sizeof(*ci) + sizeof(*cl)))) { |
521 | emit error( tr("Can't allocate memory") ); | 522 | emit error( tr("Can't allocate memory") ); |
522 | return; | 523 | return; |
523 | } | 524 | } |
524 | memset( cl, 0, MAXCONNECTIONS * sizeof(*ci) + sizeof(*cl) ); | 525 | memset( cl, 0, MAXCONNECTIONS * sizeof(*ci) + sizeof(*cl) ); |
525 | 526 | ||
526 | for( unsigned int i = 0; | 527 | for( unsigned int i = 0; |
527 | i < AllDrivers.count(); | 528 | i < AllDrivers.count(); |
528 | i ++ ) { | 529 | i ++ ) { |
529 | 530 | ||
530 | if( ! AllDrivers[i]->isUp() ) { | 531 | if( ! AllDrivers[i]->isUp() ) { |
531 | continue; | 532 | continue; |
diff --git a/noncore/settings/networksettings2/opietooth2/OTGateway.h b/noncore/settings/networksettings2/opietooth2/OTGateway.h index d97ef35..11c6b30 100644 --- a/noncore/settings/networksettings2/opietooth2/OTGateway.h +++ b/noncore/settings/networksettings2/opietooth2/OTGateway.h | |||
@@ -1,200 +1,200 @@ | |||
1 | #ifndef OTGATEWAY_H | 1 | #ifndef OTGATEWAY_H |
2 | #define OTGATEWAY_H | 2 | #define OTGATEWAY_H |
3 | 3 | ||
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | #include <qvector.h> | 5 | #include <qvector.h> |
6 | #include <qmap.h> | 6 | #include <qmap.h> |
7 | 7 | ||
8 | #include <OTDriverList.h> | 8 | #include <OTDriverList.h> |
9 | #include <OTInquiry.h> | 9 | #include <OTInquiry.h> |
10 | 10 | ||
11 | class QPixmap; | 11 | class QPixmap; |
12 | 12 | ||
13 | namespace Opietooth2 { | 13 | namespace Opietooth2 { |
14 | 14 | ||
15 | class OTDriverList; | 15 | class OTDriverList; |
16 | class OTDriver; | 16 | class OTDriver; |
17 | class OTDevice; | 17 | class OTDevice; |
18 | class OTPeer; | 18 | class OTPeer; |
19 | class OTInquiry; | 19 | class OTInquiry; |
20 | class OTPANConnection; | 20 | class OTPANConnection; |
21 | class OTLinkKey; | 21 | class OTLinkKey; |
22 | 22 | ||
23 | typedef QVector<OTPeer> PeerVector; | 23 | typedef QVector<OTPeer> PeerVector; |
24 | typedef QVector<OTPANConnection> PANConnectionVector; | 24 | typedef QVector<OTPANConnection> PANConnectionVector; |
25 | typedef QArray<OTLinkKey> LinkKeyArray; | 25 | typedef QArray<OTLinkKey> LinkKeyArray; |
26 | 26 | ||
27 | class OTLinkKey { | 27 | class OTLinkKey { |
28 | 28 | ||
29 | public : | 29 | public : |
30 | 30 | ||
31 | OTLinkKey( const OTDeviceAddress & F, | 31 | OTLinkKey( const OTDeviceAddress & F, |
32 | const OTDeviceAddress & T ) { | 32 | const OTDeviceAddress & T ) { |
33 | From = F; | 33 | From = F; |
34 | To = T; | 34 | To = T; |
35 | } | 35 | } |
36 | 36 | ||
37 | const OTDeviceAddress & to() | 37 | const OTDeviceAddress & to() |
38 | { return To; } | 38 | { return To; } |
39 | const OTDeviceAddress & from() | 39 | const OTDeviceAddress & from() |
40 | { return From; } | 40 | { return From; } |
41 | 41 | ||
42 | OTDeviceAddress From; | 42 | OTDeviceAddress From; |
43 | OTDeviceAddress To; | 43 | OTDeviceAddress To; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | class OTPANConnection { | 46 | class OTPANConnection { |
47 | 47 | ||
48 | public : | 48 | public : |
49 | 49 | ||
50 | OTPANConnection( const QString & Dev, const QString & CT ) { | 50 | OTPANConnection( const QString & Dev, const QString & CT ) { |
51 | Device = Dev; | 51 | Device = Dev; |
52 | ConnectedTo = CT; | 52 | ConnectedTo = CT; |
53 | } | 53 | } |
54 | 54 | ||
55 | QString Device; | 55 | QString Device; |
56 | QString ConnectedTo; | 56 | QString ConnectedTo; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | 59 | ||
60 | class OTGateway : public QObject { | 60 | class OTGateway : public QObject { |
61 | 61 | ||
62 | Q_OBJECT | 62 | Q_OBJECT |
63 | 63 | ||
64 | public : | 64 | public : |
65 | 65 | ||
66 | // single instance | 66 | // single instance |
67 | static OTGateway * getOTGateway( void ); | 67 | static OTGateway * getOTGateway( void ); |
68 | static void releaseOTGateway( void ); | 68 | static void releaseOTGateway( void ); |
69 | // convert device type as class to name for that class | 69 | // convert device type as class to name for that class |
70 | static const char * deviceTypeToName( int Cls ); | 70 | static const char * deviceTypeToName( int Cls ); |
71 | 71 | ||
72 | // open bluetooth system | 72 | // open bluetooth system |
73 | OTGateway( void ); | 73 | OTGateway( void ); |
74 | // close bluetooth system | 74 | // close bluetooth system |
75 | ~OTGateway( void ); | 75 | ~OTGateway( void ); |
76 | 76 | ||
77 | // get access to system device | 77 | // get access to system device |
78 | OTDevice * getOTDevice(); | 78 | OTDevice * getOTDevice(); |
79 | 79 | ||
80 | // return true if this device needs enabling of bluetooth | 80 | // return true if this device needs enabling of bluetooth |
81 | bool needsEnabling(); | 81 | bool needsEnabling(); |
82 | // return true if system is running | 82 | // return true if system is running |
83 | bool isEnabled(); | 83 | bool isEnabled(); |
84 | void setRefreshTimer( int MilleSecs ); | 84 | void setRefreshTimer( int MilleSecs ); |
85 | // return socket to HCI raw layer | 85 | // return socket to HCI raw layer |
86 | inline int getSocket() | 86 | inline int getSocket() |
87 | { return HciCtl; } | 87 | { return HciCtl; } |
88 | 88 | ||
89 | OTDriverList & getDriverList() | 89 | OTDriverList & getDriverList() |
90 | { return AllDrivers; } | 90 | { return AllDrivers; } |
91 | OTDriver * driver( int nr ) | 91 | OTDriver * driver( int nr ) |
92 | { return AllDrivers[nr]; } | 92 | { return AllDrivers.count() == 0 ? 0 : AllDrivers[nr]; } |
93 | void updateDrivers(); | 93 | void updateDrivers(); |
94 | 94 | ||
95 | PANConnectionVector getPANConnections(); | 95 | PANConnectionVector getPANConnections(); |
96 | 96 | ||
97 | // scan neighbourhood using device | 97 | // scan neighbourhood using device |
98 | void scanNeighbourhood( OTDriver * D = 0 ); | 98 | void scanNeighbourhood( OTDriver * D = 0 ); |
99 | void stopScanOfNeighbourhood(void ); | 99 | void stopScanOfNeighbourhood(void ); |
100 | void setScanWith( OTDriver * D = 0 ) | 100 | void setScanWith( OTDriver * D = 0 ) |
101 | { ScanWith = (D) ? D : | 101 | { ScanWith = (D) ? D : |
102 | (AllDrivers.count() ) ? AllDrivers[0] : 0; } | 102 | (AllDrivers.count() ) ? AllDrivers[0] : 0; } |
103 | OTDriver * scanWith( void ) | 103 | OTDriver * scanWith( void ) |
104 | { return ScanWith; } | 104 | { return ScanWith; } |
105 | 105 | ||
106 | // get list of all detected peers | 106 | // get list of all detected peers |
107 | inline const PeerVector & peers( void ) | 107 | inline const PeerVector & peers( void ) |
108 | { return AllPeers; } | 108 | { return AllPeers; } |
109 | // ping peer to see if it is up | 109 | // ping peer to see if it is up |
110 | bool isPeerUp( const OTDeviceAddress & PAddr, | 110 | bool isPeerUp( const OTDeviceAddress & PAddr, |
111 | int timeoutInSec = 1, | 111 | int timeoutInSec = 1, |
112 | int timeoutInUSec = 0, | 112 | int timeoutInUSec = 0, |
113 | int retry = 1 ); | 113 | int retry = 1 ); |
114 | OTPeer * findPeer( const OTDeviceAddress & Addr ); | 114 | OTPeer * findPeer( const OTDeviceAddress & Addr ); |
115 | void removePeer( OTPeer * P ); | 115 | void removePeer( OTPeer * P ); |
116 | void addPeer( OTPeer * P ); | 116 | void addPeer( OTPeer * P ); |
117 | 117 | ||
118 | OTDriver * findDriver( const OTDeviceAddress & Addr ); | 118 | OTDriver * findDriver( const OTDeviceAddress & Addr ); |
119 | 119 | ||
120 | inline const LinkKeyArray & getLinkKeys() const | 120 | inline const LinkKeyArray & getLinkKeys() const |
121 | { return AllKeys; } | 121 | { return AllKeys; } |
122 | bool removeLinkKey( unsigned int index ); | 122 | bool removeLinkKey( unsigned int index ); |
123 | 123 | ||
124 | // return device number if we are connected over any device | 124 | // return device number if we are connected over any device |
125 | // to the channel | 125 | // to the channel |
126 | // else returns -1 | 126 | // else returns -1 |
127 | int connectedToRFCommChannel( const OTDeviceAddress & Addr, int channel ); | 127 | int connectedToRFCommChannel( const OTDeviceAddress & Addr, int channel ); |
128 | int getFreeRFCommDevice( void ); | 128 | int getFreeRFCommDevice( void ); |
129 | // return 0 if properly released | 129 | // return 0 if properly released |
130 | int releaseRFCommDevice( int DevNr ); | 130 | int releaseRFCommDevice( int DevNr ); |
131 | 131 | ||
132 | public slots : | 132 | public slots : |
133 | 133 | ||
134 | // start bluetooth system | 134 | // start bluetooth system |
135 | void SLOT_SetEnabled( bool ); | 135 | void SLOT_SetEnabled( bool ); |
136 | void SLOT_Enable(); | 136 | void SLOT_Enable(); |
137 | void SLOT_Disable(); | 137 | void SLOT_Disable(); |
138 | 138 | ||
139 | // show error | 139 | // show error |
140 | void SLOT_ShowError( const QString & ); | 140 | void SLOT_ShowError( const QString & ); |
141 | 141 | ||
142 | void SLOT_Enabled( int, bool ); | 142 | void SLOT_Enabled( int, bool ); |
143 | void SLOT_DriverDisappeared( OTDriver * ); | 143 | void SLOT_DriverDisappeared( OTDriver * ); |
144 | void SLOT_PeerDetected( OTPeer *, bool ); | 144 | void SLOT_PeerDetected( OTPeer *, bool ); |
145 | void SLOT_FinishedDetecting(); | 145 | void SLOT_FinishedDetecting(); |
146 | 146 | ||
147 | signals : | 147 | signals : |
148 | 148 | ||
149 | // any error | 149 | // any error |
150 | void error( const QString & ); | 150 | void error( const QString & ); |
151 | 151 | ||
152 | // signal state of bluetooth driver | 152 | // signal state of bluetooth driver |
153 | void stateChange( OTDriver * D, bool State ); | 153 | void stateChange( OTDriver * D, bool State ); |
154 | 154 | ||
155 | // sent when list of drivers changees | 155 | // sent when list of drivers changees |
156 | void driverListChanged(); | 156 | void driverListChanged(); |
157 | 157 | ||
158 | // sent when bluetooth on device is enabled | 158 | // sent when bluetooth on device is enabled |
159 | void deviceEnabled( bool ); | 159 | void deviceEnabled( bool ); |
160 | 160 | ||
161 | // sent when a (new if bool = TRUE) peer is detected | 161 | // sent when a (new if bool = TRUE) peer is detected |
162 | void detectedPeer( OTPeer *, bool ); | 162 | void detectedPeer( OTPeer *, bool ); |
163 | 163 | ||
164 | // end of detection process | 164 | // end of detection process |
165 | void finishedDetecting(); | 165 | void finishedDetecting(); |
166 | 166 | ||
167 | protected : | 167 | protected : |
168 | 168 | ||
169 | void connectNotify( const char * Signal ); | 169 | void connectNotify( const char * Signal ); |
170 | void disconnectNotify( const char * Signal ); | 170 | void disconnectNotify( const char * Signal ); |
171 | 171 | ||
172 | void timerEvent( QTimerEvent * ); | 172 | void timerEvent( QTimerEvent * ); |
173 | 173 | ||
174 | private : | 174 | private : |
175 | 175 | ||
176 | void loadActiveConnections( void ); | 176 | void loadActiveConnections( void ); |
177 | void loadKnownPeers( void ); | 177 | void loadKnownPeers( void ); |
178 | void saveKnownPeers( void ); | 178 | void saveKnownPeers( void ); |
179 | bool isConnectedTo( int devid, | 179 | bool isConnectedTo( int devid, |
180 | const OTDeviceAddress & Address ); | 180 | const OTDeviceAddress & Address ); |
181 | 181 | ||
182 | void readLinkKeys(); | 182 | void readLinkKeys(); |
183 | 183 | ||
184 | static OTGateway * SingleGateway; | 184 | static OTGateway * SingleGateway; |
185 | static int UseCount; | 185 | static int UseCount; |
186 | 186 | ||
187 | OTDriver * ScanWith; | 187 | OTDriver * ScanWith; |
188 | OTDriverList AllDrivers; | 188 | OTDriverList AllDrivers; |
189 | OTDevice * TheOTDevice; | 189 | OTDevice * TheOTDevice; |
190 | int HciCtl; | 190 | int HciCtl; |
191 | int ErrorConnectCount; | 191 | int ErrorConnectCount; |
192 | int RefreshTimer; | 192 | int RefreshTimer; |
193 | OTInquiry * Scanning; | 193 | OTInquiry * Scanning; |
194 | bool AllPeersModified; | 194 | bool AllPeersModified; |
195 | PeerVector AllPeers; | 195 | PeerVector AllPeers; |
196 | LinkKeyArray AllKeys; | 196 | LinkKeyArray AllKeys; |
197 | }; | 197 | }; |
198 | } | 198 | } |
199 | 199 | ||
200 | #endif | 200 | #endif |