Diffstat (limited to 'noncore/settings/networksettings2/opietooth2/OTGateway.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/OTGateway.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp index 6531cf6..e8137dd 100644 --- a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp | |||
@@ -133,49 +133,49 @@ void OTGateway::SLOT_SetEnabled( bool Mode ) { | |||
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 | driver( getOTDevice()->deviceNr() )->isUp() ) | 148 | driver( getOTDevice()->deviceNr() )->isUp() ) |
149 | return TRUE; | 149 | return TRUE; |
150 | 150 | ||
151 | // else check system | 151 | // else check system |
152 | return getOTDevice()->isAttached(); | 152 | return getOTDevice()->isAttached(); |
153 | } | 153 | } |
154 | 154 | ||
155 | void OTGateway::SLOT_ShowError( const QString & S ) { | 155 | void OTGateway::SLOT_ShowError( const QString & S ) { |
156 | 156 | ||
157 | owarn << S << oendl; | 157 | odebug << S << oendl; |
158 | 158 | ||
159 | if( ErrorConnectCount > 0 ) { | 159 | if( ErrorConnectCount > 0 ) { |
160 | // pass error | 160 | // pass error |
161 | emit error( QString( "<p>" ) + S + "</p>" ); | 161 | emit error( QString( "<p>" ) + S + "</p>" ); |
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | 164 | ||
165 | QMessageBox::warning( 0, | 165 | QMessageBox::warning( 0, |
166 | tr("OTGateway error"), | 166 | tr("OTGateway error"), |
167 | S ); | 167 | S ); |
168 | } | 168 | } |
169 | 169 | ||
170 | void OTGateway::connectNotify( const char * S ) { | 170 | void OTGateway::connectNotify( const char * S ) { |
171 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { | 171 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { |
172 | ErrorConnectCount ++; | 172 | ErrorConnectCount ++; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | void OTGateway::disconnectNotify( const char * S ) { | 176 | void OTGateway::disconnectNotify( const char * S ) { |
177 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { | 177 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { |
178 | ErrorConnectCount --; | 178 | ErrorConnectCount --; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
@@ -189,104 +189,104 @@ void OTGateway::timerEvent( QTimerEvent * ) { | |||
189 | 189 | ||
190 | if( oldc != AllDrivers.count() ) { | 190 | if( oldc != AllDrivers.count() ) { |
191 | updateDrivers(); | 191 | updateDrivers(); |
192 | } else { | 192 | } else { |
193 | for( unsigned int i = 0; | 193 | for( unsigned int i = 0; |
194 | i < AllDrivers.count(); | 194 | i < AllDrivers.count(); |
195 | i ++ ) { | 195 | i ++ ) { |
196 | D = AllDrivers[i]; | 196 | D = AllDrivers[i]; |
197 | old = D->isUp(); | 197 | old = D->isUp(); |
198 | if( D->currentState() >= 0 ) { | 198 | if( D->currentState() >= 0 ) { |
199 | if( old != D->isUp() ) { | 199 | if( old != D->isUp() ) { |
200 | emit stateChange( D, D->isUp() ); | 200 | emit stateChange( D, D->isUp() ); |
201 | } | 201 | } |
202 | } else { | 202 | } else { |
203 | // if one driver is unable to provide info | 203 | // if one driver is unable to provide info |
204 | // we refresh all devices | 204 | // we refresh all devices |
205 | updateDrivers(); | 205 | updateDrivers(); |
206 | return; | 206 | return; |
207 | } | 207 | } |
208 | } | 208 | } |
209 | } | 209 | } |
210 | } | 210 | } |
211 | 211 | ||
212 | void OTGateway::SLOT_Enabled( int id, bool Up ) { | 212 | void OTGateway::SLOT_Enabled( int id, bool Up ) { |
213 | owarn << "device " << id << " state " << Up << oendl; | 213 | odebug << "device " << id << " state " << Up << oendl; |
214 | if( Up ) { | 214 | if( Up ) { |
215 | // device is up -> detect it | 215 | // device is up -> detect it |
216 | updateDrivers(); | 216 | updateDrivers(); |
217 | if( (unsigned)id >= AllDrivers.count() ) { | 217 | if( (unsigned)id >= AllDrivers.count() ) { |
218 | // to make sure that the driver really IS detected | 218 | // to make sure that the driver really IS detected |
219 | AllDrivers[id]->bringUp(); | 219 | AllDrivers[id]->bringUp(); |
220 | } | 220 | } |
221 | } // if DOWN device already down | 221 | } // if DOWN device already down |
222 | emit deviceEnabled( Up ); | 222 | emit deviceEnabled( Up ); |
223 | } | 223 | } |
224 | 224 | ||
225 | void OTGateway::updateDrivers( void ) { | 225 | void OTGateway::updateDrivers( void ) { |
226 | OTDriver * D; | 226 | OTDriver * D; |
227 | 227 | ||
228 | AllDrivers.update(); | 228 | AllDrivers.update(); |
229 | 229 | ||
230 | owarn << "updated drivers. now " << AllDrivers.count() << oendl; | 230 | odebug << "updated drivers. now " << AllDrivers.count() << oendl; |
231 | 231 | ||
232 | // connect signals for each driver | 232 | // connect signals for each driver |
233 | for( unsigned int i = 0; | 233 | for( unsigned int i = 0; |
234 | i < AllDrivers.count(); | 234 | i < AllDrivers.count(); |
235 | i ++ ) { | 235 | i ++ ) { |
236 | D = AllDrivers[i]; | 236 | D = AllDrivers[i]; |
237 | 237 | ||
238 | connect( D, | 238 | connect( D, |
239 | SIGNAL( error( const QString & ) ), | 239 | SIGNAL( error( const QString & ) ), |
240 | this, | 240 | this, |
241 | SLOT( SLOT_ShowError( const QString & ) ) | 241 | SLOT( SLOT_ShowError( const QString & ) ) |
242 | ); | 242 | ); |
243 | 243 | ||
244 | connect( D, | 244 | connect( D, |
245 | SIGNAL( stateChange( OTDriver *, bool ) ), | 245 | SIGNAL( stateChange( OTDriver *, bool ) ), |
246 | this, | 246 | this, |
247 | SIGNAL( stateChange( OTDriver *, bool ) ) | 247 | SIGNAL( stateChange( OTDriver *, bool ) ) |
248 | ); | 248 | ); |
249 | 249 | ||
250 | connect( D, | 250 | connect( D, |
251 | SIGNAL( driverDisappeared( OTDriver * ) ), | 251 | SIGNAL( driverDisappeared( OTDriver * ) ), |
252 | this, | 252 | this, |
253 | SLOT( SLOT_DriverDisappeared( OTDriver * ) ) | 253 | SLOT( SLOT_DriverDisappeared( OTDriver * ) ) |
254 | ); | 254 | ); |
255 | } | 255 | } |
256 | 256 | ||
257 | // verify main device too | 257 | // verify main device too |
258 | if( TheOTDevice ) | 258 | if( TheOTDevice ) |
259 | TheOTDevice->checkAttach(); | 259 | TheOTDevice->checkAttach(); |
260 | 260 | ||
261 | // set to default scanning hardware | 261 | // set to default scanning hardware |
262 | setScanWith( 0 ); | 262 | setScanWith( 0 ); |
263 | 263 | ||
264 | emit driverListChanged(); | 264 | emit driverListChanged(); |
265 | } | 265 | } |
266 | 266 | ||
267 | void OTGateway::SLOT_DriverDisappeared( OTDriver * D ) { | 267 | void OTGateway::SLOT_DriverDisappeared( OTDriver * D ) { |
268 | owarn << "Driver " << D->devname() << " when offline" << oendl; | 268 | odebug << "Driver " << D->devname() << " when offline" << oendl; |
269 | updateDrivers(); | 269 | updateDrivers(); |
270 | } | 270 | } |
271 | 271 | ||
272 | void OTGateway::scanNeighbourhood( OTDriver * D ) { | 272 | void OTGateway::scanNeighbourhood( OTDriver * D ) { |
273 | 273 | ||
274 | if( Scanning ) { | 274 | if( Scanning ) { |
275 | stopScanOfNeighbourhood(); | 275 | stopScanOfNeighbourhood(); |
276 | } | 276 | } |
277 | 277 | ||
278 | if( D ) { | 278 | if( D ) { |
279 | setScanWith( D ); | 279 | setScanWith( D ); |
280 | } | 280 | } |
281 | 281 | ||
282 | Scanning = new OTInquiry( scanWith() ); | 282 | Scanning = new OTInquiry( scanWith() ); |
283 | 283 | ||
284 | connect( Scanning, | 284 | connect( Scanning, |
285 | SIGNAL( peerFound( OTPeer *, bool )), | 285 | SIGNAL( peerFound( OTPeer *, bool )), |
286 | this, | 286 | this, |
287 | SLOT( SLOT_PeerDetected( OTPeer *, bool ) ) | 287 | SLOT( SLOT_PeerDetected( OTPeer *, bool ) ) |
288 | ); | 288 | ); |
289 | connect( Scanning, | 289 | connect( Scanning, |
290 | SIGNAL( finished()), | 290 | SIGNAL( finished()), |
291 | this, | 291 | this, |
292 | SLOT( SLOT_FinishedDetecting() ) | 292 | SLOT( SLOT_FinishedDetecting() ) |
@@ -297,49 +297,49 @@ void OTGateway::scanNeighbourhood( OTDriver * D ) { | |||
297 | } | 297 | } |
298 | 298 | ||
299 | OTPeer* OTGateway::findPeer( const OTDeviceAddress & Addr ) { | 299 | OTPeer* OTGateway::findPeer( const OTDeviceAddress & Addr ) { |
300 | for( unsigned int i = 0 ; i < AllPeers.count(); i ++ ) { | 300 | for( unsigned int i = 0 ; i < AllPeers.count(); i ++ ) { |
301 | if( AllPeers[i]->address() == Addr ) { | 301 | if( AllPeers[i]->address() == Addr ) { |
302 | return AllPeers[i]; | 302 | return AllPeers[i]; |
303 | } | 303 | } |
304 | } | 304 | } |
305 | return 0; | 305 | return 0; |
306 | } | 306 | } |
307 | 307 | ||
308 | OTDriver* OTGateway::findDriver( const OTDeviceAddress & Addr ) { | 308 | OTDriver* OTGateway::findDriver( const OTDeviceAddress & Addr ) { |
309 | for( unsigned int i = 0 ; i < AllDrivers.count(); i ++ ) { | 309 | for( unsigned int i = 0 ; i < AllDrivers.count(); i ++ ) { |
310 | if( AllDrivers[i]->address() == Addr ) { | 310 | if( AllDrivers[i]->address() == Addr ) { |
311 | return AllDrivers[i]; | 311 | return AllDrivers[i]; |
312 | } | 312 | } |
313 | } | 313 | } |
314 | return 0; | 314 | return 0; |
315 | } | 315 | } |
316 | 316 | ||
317 | void OTGateway::SLOT_PeerDetected( OTPeer * P, bool IsNew ) { | 317 | void OTGateway::SLOT_PeerDetected( OTPeer * P, bool IsNew ) { |
318 | 318 | ||
319 | if( IsNew ) { | 319 | if( IsNew ) { |
320 | // new peer | 320 | // new peer |
321 | owarn << "New peer " << P->name() << oendl; | 321 | odebug << "New peer " << P->name() << oendl; |
322 | addPeer( P ); | 322 | addPeer( P ); |
323 | } | 323 | } |
324 | 324 | ||
325 | emit detectedPeer( P, IsNew ); | 325 | emit detectedPeer( P, IsNew ); |
326 | } | 326 | } |
327 | 327 | ||
328 | void OTGateway::addPeer( OTPeer * P ) { | 328 | void OTGateway::addPeer( OTPeer * P ) { |
329 | AllPeers.resize( AllPeers.size()+1); | 329 | AllPeers.resize( AllPeers.size()+1); |
330 | AllPeers.insert( AllPeers.size()-1, P ); | 330 | AllPeers.insert( AllPeers.size()-1, P ); |
331 | AllPeersModified = 1; | 331 | AllPeersModified = 1; |
332 | } | 332 | } |
333 | 333 | ||
334 | void OTGateway::removePeer( OTPeer * P ) { | 334 | void OTGateway::removePeer( OTPeer * P ) { |
335 | int i = AllPeers.find( P ); | 335 | int i = AllPeers.find( P ); |
336 | if( i ) { | 336 | if( i ) { |
337 | AllPeers.remove( i ); | 337 | AllPeers.remove( i ); |
338 | AllPeersModified = 1; | 338 | AllPeersModified = 1; |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | void OTGateway::stopScanOfNeighbourhood( void ) { | 342 | void OTGateway::stopScanOfNeighbourhood( void ) { |
343 | if( Scanning ) { | 343 | if( Scanning ) { |
344 | delete Scanning; | 344 | delete Scanning; |
345 | Scanning = 0; | 345 | Scanning = 0; |
@@ -363,56 +363,56 @@ const char * OTGateway::deviceTypeToName( int cls ) { | |||
363 | return "lan"; | 363 | return "lan"; |
364 | case 0x04: | 364 | case 0x04: |
365 | return "av"; | 365 | return "av"; |
366 | case 0x05: | 366 | case 0x05: |
367 | return "peripheral"; | 367 | return "peripheral"; |
368 | case 0x06: | 368 | case 0x06: |
369 | return "imaging"; | 369 | return "imaging"; |
370 | case 0x07: | 370 | case 0x07: |
371 | default : | 371 | default : |
372 | break; | 372 | break; |
373 | } | 373 | } |
374 | return "unknown"; | 374 | return "unknown"; |
375 | } | 375 | } |
376 | 376 | ||
377 | PANConnectionVector OTGateway::getPANConnections( void ) { | 377 | PANConnectionVector OTGateway::getPANConnections( void ) { |
378 | PANConnectionVector V; | 378 | PANConnectionVector V; |
379 | 379 | ||
380 | struct bnep_connlist_req req; | 380 | struct bnep_connlist_req req; |
381 | struct bnep_conninfo ci[48]; | 381 | struct bnep_conninfo ci[48]; |
382 | 382 | ||
383 | V.setAutoDelete(TRUE); | 383 | V.setAutoDelete(TRUE); |
384 | 384 | ||
385 | int ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP); | 385 | int ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP); |
386 | if (ctl < 0) { | 386 | if (ctl < 0) { |
387 | owarn << "Failed to open control socket" << oendl; | 387 | odebug << "Failed to open control socket" << oendl; |
388 | return V; | 388 | return V; |
389 | } | 389 | } |
390 | 390 | ||
391 | req.cnum = 48; | 391 | req.cnum = 48; |
392 | req.ci = ci; | 392 | req.ci = ci; |
393 | if (ioctl(ctl, BNEPGETCONNLIST, &req)) { | 393 | if (ioctl(ctl, BNEPGETCONNLIST, &req)) { |
394 | owarn << "Failed to get connection list" << oendl; | 394 | odebug << "Failed to get connection list" << oendl; |
395 | ::close( ctl ); | 395 | ::close( ctl ); |
396 | return V; | 396 | return V; |
397 | } | 397 | } |
398 | 398 | ||
399 | for ( unsigned i=0; i < req.cnum; i++) { | 399 | for ( unsigned i=0; i < req.cnum; i++) { |
400 | V.resize( V.size() + 1 ); | 400 | V.resize( V.size() + 1 ); |
401 | if( ci[i].role == BNEP_SVC_PANU ) { | 401 | if( ci[i].role == BNEP_SVC_PANU ) { |
402 | // we are the client | 402 | // we are the client |
403 | V.insert( V.size()-1, new OTPANConnection( | 403 | V.insert( V.size()-1, new OTPANConnection( |
404 | ci[i].device, | 404 | ci[i].device, |
405 | batostr((bdaddr_t *) ci[i].dst) | 405 | batostr((bdaddr_t *) ci[i].dst) |
406 | ) ); | 406 | ) ); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | 409 | ||
410 | ::close( ctl ); | 410 | ::close( ctl ); |
411 | return V; | 411 | return V; |
412 | } | 412 | } |
413 | 413 | ||
414 | struct link_key { | 414 | struct link_key { |
415 | bdaddr_t sba; | 415 | bdaddr_t sba; |
416 | bdaddr_t dba; | 416 | bdaddr_t dba; |
417 | uint8_t key[16]; | 417 | uint8_t key[16]; |
418 | uint8_t type; | 418 | uint8_t type; |