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 @@ -109,334 +109,334 @@ OTDevice * OTGateway::getOTDevice( ) { TheOTDevice = new OTDevice( this ); connect( TheOTDevice, SIGNAL( isEnabled( int, bool ) ), this, SLOT( SLOT_Enabled( int, bool ) ) ); connect( TheOTDevice, SIGNAL( error( const QString & ) ), this, SLOT( SLOT_ShowError( const QString & ) ) ); } return TheOTDevice; } // start bluetooth (if stopped) // return TRUE if started void OTGateway::SLOT_SetEnabled( bool Mode ) { if( Mode ) { SLOT_Enable(); return; } SLOT_Disable(); } void OTGateway::SLOT_Enable() { getOTDevice()->attach(); } void OTGateway::SLOT_Disable() { getOTDevice()->detach(); } bool OTGateway::needsEnabling() { return getOTDevice()->needsAttach(); } bool OTGateway::isEnabled() { if( getOTDevice()->deviceNr() >= 0 && driver( getOTDevice()->deviceNr() )->isUp() ) return TRUE; // else check system return getOTDevice()->isAttached(); } void OTGateway::SLOT_ShowError( const QString & S ) { - owarn << S << oendl; + odebug << S << oendl; if( ErrorConnectCount > 0 ) { // pass error emit error( QString( "<p>" ) + S + "</p>" ); return; } QMessageBox::warning( 0, tr("OTGateway error"), S ); } void OTGateway::connectNotify( const char * S ) { if( S && strcmp( S, "error(const QString&)" ) == 0 ) { ErrorConnectCount ++; } } void OTGateway::disconnectNotify( const char * S ) { if( S && strcmp( S, "error(const QString&)" ) == 0 ) { ErrorConnectCount --; } } void OTGateway::timerEvent( QTimerEvent * ) { OTDriver * D; unsigned int oldc = AllDrivers.count(); bool old; AllDrivers.update(); if( oldc != AllDrivers.count() ) { updateDrivers(); } else { for( unsigned int i = 0; i < AllDrivers.count(); i ++ ) { D = AllDrivers[i]; old = D->isUp(); if( D->currentState() >= 0 ) { if( old != D->isUp() ) { emit stateChange( D, D->isUp() ); } } else { // if one driver is unable to provide info // we refresh all devices updateDrivers(); return; } } } } void OTGateway::SLOT_Enabled( int id, bool Up ) { - owarn << "device " << id << " state " << Up << oendl; + odebug << "device " << id << " state " << Up << oendl; if( Up ) { // device is up -> detect it updateDrivers(); if( (unsigned)id >= AllDrivers.count() ) { // to make sure that the driver really IS detected AllDrivers[id]->bringUp(); } } // if DOWN device already down emit deviceEnabled( Up ); } void OTGateway::updateDrivers( void ) { OTDriver * D; AllDrivers.update(); - owarn << "updated drivers. now " << AllDrivers.count() << oendl; + odebug << "updated drivers. now " << AllDrivers.count() << oendl; // connect signals for each driver for( unsigned int i = 0; i < AllDrivers.count(); i ++ ) { D = AllDrivers[i]; connect( D, SIGNAL( error( const QString & ) ), this, SLOT( SLOT_ShowError( const QString & ) ) ); connect( D, SIGNAL( stateChange( OTDriver *, bool ) ), this, SIGNAL( stateChange( OTDriver *, bool ) ) ); connect( D, SIGNAL( driverDisappeared( OTDriver * ) ), this, SLOT( SLOT_DriverDisappeared( OTDriver * ) ) ); } // verify main device too if( TheOTDevice ) TheOTDevice->checkAttach(); // set to default scanning hardware setScanWith( 0 ); emit driverListChanged(); } void OTGateway::SLOT_DriverDisappeared( OTDriver * D ) { - owarn << "Driver " << D->devname() << " when offline" << oendl; + odebug << "Driver " << D->devname() << " when offline" << oendl; updateDrivers(); } void OTGateway::scanNeighbourhood( OTDriver * D ) { if( Scanning ) { stopScanOfNeighbourhood(); } if( D ) { setScanWith( D ); } Scanning = new OTInquiry( scanWith() ); connect( Scanning, SIGNAL( peerFound( OTPeer *, bool )), this, SLOT( SLOT_PeerDetected( OTPeer *, bool ) ) ); connect( Scanning, SIGNAL( finished()), this, SLOT( SLOT_FinishedDetecting() ) ); // start scanning Scanning->inquire( 30.0 ); } OTPeer* OTGateway::findPeer( const OTDeviceAddress & Addr ) { for( unsigned int i = 0 ; i < AllPeers.count(); i ++ ) { if( AllPeers[i]->address() == Addr ) { return AllPeers[i]; } } return 0; } OTDriver* OTGateway::findDriver( const OTDeviceAddress & Addr ) { for( unsigned int i = 0 ; i < AllDrivers.count(); i ++ ) { if( AllDrivers[i]->address() == Addr ) { return AllDrivers[i]; } } return 0; } void OTGateway::SLOT_PeerDetected( OTPeer * P, bool IsNew ) { if( IsNew ) { // new peer - owarn << "New peer " << P->name() << oendl; + odebug << "New peer " << P->name() << oendl; addPeer( P ); } emit detectedPeer( P, IsNew ); } void OTGateway::addPeer( OTPeer * P ) { AllPeers.resize( AllPeers.size()+1); AllPeers.insert( AllPeers.size()-1, P ); AllPeersModified = 1; } void OTGateway::removePeer( OTPeer * P ) { int i = AllPeers.find( P ); if( i ) { AllPeers.remove( i ); AllPeersModified = 1; } } void OTGateway::stopScanOfNeighbourhood( void ) { if( Scanning ) { delete Scanning; Scanning = 0; } } void OTGateway::SLOT_FinishedDetecting() { stopScanOfNeighbourhood(); emit finishedDetecting(); } const char * OTGateway::deviceTypeToName( int cls ) { switch ( (cls & 0x001F00) >> 8) { case 0x00: return "misc"; case 0x01: return "computer"; case 0x02: return "phone"; case 0x03: return "lan"; case 0x04: return "av"; case 0x05: return "peripheral"; case 0x06: return "imaging"; case 0x07: default : break; } return "unknown"; } PANConnectionVector OTGateway::getPANConnections( void ) { PANConnectionVector V; struct bnep_connlist_req req; struct bnep_conninfo ci[48]; V.setAutoDelete(TRUE); int ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP); if (ctl < 0) { - owarn << "Failed to open control socket" << oendl; + odebug << "Failed to open control socket" << oendl; return V; } req.cnum = 48; req.ci = ci; if (ioctl(ctl, BNEPGETCONNLIST, &req)) { - owarn << "Failed to get connection list" << oendl; + odebug << "Failed to get connection list" << oendl; ::close( ctl ); return V; } for ( unsigned i=0; i < req.cnum; i++) { V.resize( V.size() + 1 ); if( ci[i].role == BNEP_SVC_PANU ) { // we are the client V.insert( V.size()-1, new OTPANConnection( ci[i].device, batostr((bdaddr_t *) ci[i].dst) ) ); } } ::close( ctl ); return V; } struct link_key { bdaddr_t sba; bdaddr_t dba; uint8_t key[16]; uint8_t type; time_t time; }; void OTGateway::readLinkKeys( void ) { struct link_key k; int rv; AllKeys.truncate(0); QFile F( "/etc/bluetooth/link_key" ); if( ! F.open( IO_ReadOnly ) ) { emit error( tr("Cannot open link_key file") ); return; } while( 1 ) { rv = F.readBlock( (char *)&k, sizeof( k ) ); if( rv == 0 ) // EOF break; if( rv < 0 ) { |