Diffstat (limited to 'noncore/settings/networksettings2/bluetooth') (more/less context) (ignore whitespace changes)
4 files changed, 30 insertions, 30 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp index 5c937a1..5c71a0a 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp @@ -1,165 +1,165 @@ #include <qfile.h> #include <qfileinfo.h> #include <qtextstream.h> #include <resources.h> #include "bluetoothBNEPrun.h" using Opietooth2::OTGateway; -using Opietooth2::OTPANConnection; -using Opietooth2::PANConnectionVector; +using Opietooth2::OTPANNetworkSetup; +using Opietooth2::PANNetworkSetupVector; BluetoothBNEPRun::BluetoothBNEPRun( ANetNodeInstance * NNI, BluetoothBNEPData & D ) : RuntimeInfo( NNI ), Data( D), Pat( "bnep[0-6]" ) { OT = 0; } BluetoothBNEPRun::~BluetoothBNEPRun( void ) { if( OT ) { OTGateway::releaseOTGateway(); } } State_t BluetoothBNEPRun::detectState( void ) { /* need to detect - 1. for any PAN connection that is found if that + 1. for any PAN NetworkSetup that is found if that PAN is connected. if it is connected it is not available (since we do not manage IP settings and we are called to detect - the state we knwo that we do not have an UP connection) + the state we knwo that we do not have an UP NetworkSetup) - 2. if it not connected and we allow any connection we - are available or if that PAN connection is to a device + 2. if it not connected and we allow any NetworkSetup we + are available or if that PAN NetworkSetup is to a device with a correct address 3. if it is not connected and the address do not match or we do not accept any address, we are Unavailable but - not DOWN. I.e a new connection could perhaps be created + not DOWN. I.e a new NetworkSetup could perhaps be created */ if( ! OT ) { OT = OTGateway::getOTGateway(); } if( ! OT->isEnabled() ) { return Unavailable; } - // if there is a PAN connection that is UP but not + // if there is a PAN NetworkSetup that is UP but not // yet configured (no ifup) the we are available - return ( hasFreePANConnection() ) ? Available : Unknown; + return ( hasFreePANNetworkSetup() ) ? Available : Unknown; } -QString BluetoothBNEPRun::setMyState( NodeCollection * NC, Action_t A, bool ) { +QString BluetoothBNEPRun::setMyState( NetworkSetup * NC, Action_t A, bool ) { if( A == Activate ) { - if( hasFreePANConnection( 1 ) ) { + if( hasFreePANNetworkSetup( 1 ) ) { // we have now an assignedinterface } else { return QString("TODO : Start PAND"); } Log(( "Assigned interface" )); NC->setCurrentState( Available ); return QString(); } if( A == Deactivate ) { // nothing to do NC->setCurrentState( Off ); return QString(); } return QString(); } bool BluetoothBNEPRun::handlesInterface( const QString & S ) { return Pat.match( S ) >= 0; } bool BluetoothBNEPRun::handlesInterface( InterfaceInfo * I ) { return handlesInterface( I->Name ); } -bool BluetoothBNEPRun::hasFreePANConnection( bool Grab ) { +bool BluetoothBNEPRun::hasFreePANNetworkSetup( bool Grab ) { if( ! OT ) { OT = OTGateway::getOTGateway(); } - // load PAN connections - OTPANConnection * C; + // load PAN NetworkSetups + OTPANNetworkSetup * C; InterfaceInfo * Run; InterfaceInfo * Candidate = 0; // reuse this interface - PANConnectionVector Conns = OT->getPANConnections(); + PANNetworkSetupVector Conns = OT->getPANNetworkSetups(); System & Sys = NSResources->system(); bool IsValid; for( unsigned int i = 0; i < Conns.count(); i ++ ) { C = Conns[i]; if( Data.AllowAll ) { // we allow all IsValid = 1; } else { - // is this PAN connection connecting to a Peer + // is this PAN NetworkSetup connecting to a Peer // we allow ? IsValid = 0; for ( QStringList::Iterator it = Data.BDAddress.begin(); it != Data.BDAddress.end(); ++ it ) { if( C->ConnectedTo == (*it) ) { - // this is a connection we could accept + // this is a NetworkSetup we could accept IsValid = 1; break; } } } if( ! IsValid ) { Log(("%s to %s not acceptable\n", C->Device.latin1(), C->ConnectedTo.latin1() )); // don't bother checking this address // it is not acceptable continue; } - // is this PAN connection available to us ? + // is this PAN NetworkSetup available to us ? Run = Sys.findInterface( C->Device ); if( Run && Run->IsUp ) { - // this PAN connection is up + // this PAN NetworkSetup is up Log(("%s acceptable but unavailable\n", C->Device.latin1() )); // find others continue; } // we at least have a possible interface if( ! Candidate ) { Candidate = Run; } } if( Candidate ) { if ( Grab ) { - netNode()->connection()->assignInterface( Candidate ); + netNode()->networkSetup()->assignInterface( Candidate ); } return 1; } // no free PAN return 0; } diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h index 8551a2e..7346a8d 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h @@ -1,34 +1,34 @@ #include <netnode.h> #include "bluetoothBNEPdata.h" #include <OTGateway.h> class BluetoothBNEPRun : public RuntimeInfo { public : BluetoothBNEPRun( ANetNodeInstance * NNI, BluetoothBNEPData & D ); virtual ~BluetoothBNEPRun( void ); // i am a device virtual RuntimeInfo * device( void ) { return this; } bool handlesInterface( const QString & ); bool handlesInterface( InterfaceInfo * ); State_t detectState( void ); protected : - QString setMyState( NodeCollection * , Action_t, bool ); + QString setMyState( NetworkSetup * , Action_t, bool ); private : - bool hasFreePANConnection( bool Grab = 0 ); + bool hasFreePANNetworkSetup( bool Grab = 0 ); BluetoothBNEPData & Data; Opietooth2::OTGateway * OT; QRegExp Pat; }; diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp index 3df7f5c..cd7bb4a 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp @@ -1,164 +1,164 @@ #include <qapplication.h> #include <resources.h> #include <OTDevice.h> #include <OTGateway.h> #include "bluetoothRFCOMMrun.h" using Opietooth2::OTGateway; using Opietooth2::OTDevice; using Opietooth2::OTDeviceAddress; BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) { if( OT ) { OTGateway::releaseOTGateway(); } } State_t BluetoothRFCOMMRun::detectState( void ) { if( ! OT ) { OT = OTGateway::getOTGateway(); } - if( deviceNrOfConnection() >= 0 ) { + if( deviceNrOfNetworkSetup() >= 0 ) { return Available; } odebug << "Bluetooth " << OT->isEnabled() << oendl; return ( OT->isEnabled() ) ? Off : Unavailable; } -QString BluetoothRFCOMMRun::setMyState( NodeCollection *, +QString BluetoothRFCOMMRun::setMyState( NetworkSetup *, Action_t A, bool ) { if( OT ) { OTGateway::getOTGateway(); } if( A == Activate ) { // from OFF to Available RFCOMMChannel * Ch = getChannel( ); System & Sys = NSResources->system(); if( Ch ) { // connect to this peer DeviceNr = OT->getFreeRFCommDevice(); QStringList S; S << "rfcomm" << "bind" << QString().setNum( DeviceNr ) << Ch->BDAddress << QString().setNum( Ch->Channel ); if( Sys.runAsRoot( S ) ) { return QString( "Error starting %1").arg(S.join(" ")); } // here rfcomm should be running -> we will detect state later return QString(); } else { Log(( "No channel selected -> cancel\n" )); return QString( "No channel selected. Operation cancelled" ); } } if( A == Deactivate ) { if( DeviceNr >= 0 ) { if( OT->releaseRFCommDevice( DeviceNr ) ) { - return QString( "Cannot release RFCOMM connection" ); + return QString( "Cannot release RFCOMM NetworkSetup" ); } DeviceNr = -1; } } return QString(); } #include <qlistbox.h> #include <qframe.h> #include <qlabel.h> #include <qlayout.h> #include <qdialog.h> RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) { if( Data->Devices.count() == 1 ) { // only one device -> return channel return Data->Devices[0]; } RFCOMMChannel * Ch = 0; QDialog * Dlg = new QDialog( qApp->mainWidget(), 0, TRUE ); QVBoxLayout * V = new QVBoxLayout( Dlg ); QLabel * L = new QLabel( qApp->translate( "BluetoothRFCOMMRun", "Select device to connect to"), Dlg ); QListBox * LB = new QListBox( Dlg ); for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) { LB->insertItem( QString( "%1 (%2 Chnl %3)" ). arg( Data->Devices[i]->Name ). arg( Data->Devices[i]->BDAddress ). arg( Data->Devices[i]->Channel ) ); } V->addWidget( L ); V->addWidget( LB ); Dlg->resize( 100, 100 ); Dlg->move( 20, (qApp->desktop()->height()-100)/2 ); if( Dlg->exec() == QDialog::Accepted ) { unsigned int i = 0; for( i = 0; i < Data->Devices.count(); i ++ ) { if( LB->isSelected(i) ) { odebug << "Selected " << Data->Devices[i]->Name << oendl; Ch = Data->Devices[i]; break; } } } delete Dlg; return Ch; } QString BluetoothRFCOMMRun::deviceFile( void ) { - if( deviceNrOfConnection() >= 0 ) { + if( deviceNrOfNetworkSetup() >= 0 ) { OTDevice * OTD = OT->getOTDevice(); - // there is a connection + // there is a NetworkSetup return OTD->getRFCommDevicePattern().arg(DeviceNr); } return QString(); } -int BluetoothRFCOMMRun::deviceNrOfConnection( void ) { +int BluetoothRFCOMMRun::deviceNrOfNetworkSetup( void ) { if( ! OT ) { OT = OTGateway::getOTGateway(); } DeviceNr = -1; for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) { odebug << "Check for rfcomm on " << Data->Devices[i]->BDAddress << " " << Data->Devices[i]->Channel << oendl; if( ( DeviceNr = OT->connectedToRFCommChannel( OTDeviceAddress( Data->Devices[i]->BDAddress ), Data->Devices[i]->Channel ) ) >= 0 ) { odebug << "Up " << oendl; break; } } return DeviceNr; } diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h index 5a31a94..32986d3 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h @@ -1,32 +1,32 @@ #include <netnode.h> #include "bluetoothRFCOMMdata.h" #include <OTGateway.h> class BluetoothRFCOMMRun : public RuntimeInfo { public : BluetoothRFCOMMRun( ANetNodeInstance * NNI, BluetoothRFCOMMData & D ) : RuntimeInfo( NNI ) { DeviceNr = -1; Data = &D; OT = 0; } virtual ~BluetoothRFCOMMRun( void ); virtual RuntimeInfo * line( void ) { return this; } virtual QString deviceFile( void ); State_t detectState( void ); protected : - QString setMyState( NodeCollection * , Action_t, bool ); + QString setMyState( NetworkSetup * , Action_t, bool ); private : - int deviceNrOfConnection( void ); + int deviceNrOfNetworkSetup( void ); RFCOMMChannel * getChannel( void ); BluetoothRFCOMMData * Data; Opietooth2::OTGateway * OT; int DeviceNr; // cached from detection }; |