From a9c188235c97e07b0eb96b13adbcdfd4bad64767 Mon Sep 17 00:00:00 2001 From: wimpie Date: Tue, 04 Jan 2005 01:35:26 +0000 Subject: CONTROL files : changed version string NS2 many changes and first release of OT2 --- (limited to 'noncore/settings/networksettings2/bluetooth') diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth.pro b/noncore/settings/networksettings2/bluetooth/bluetooth.pro index 8170d46..2e3b5bb 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth.pro +++ b/noncore/settings/networksettings2/bluetooth/bluetooth.pro @@ -1,20 +1,24 @@ TEMPLATE = lib CONFIG += qt warn_on release DESTDIR = $(OPIEDIR)/plugins/networksettings2 -HEADERS = bluetooth_NN.h \ +HEADERS = bluetoothBNEP_NN.h \ bluetoothBNEP_NNI.h \ + bluetoothRFCOMM_NN.h \ bluetoothRFCOMM_NNI.h \ bluetoothBNEPedit.h \ + bluetoothRFCOMMrun.h \ bluetoothRFCOMMedit.h -SOURCES = bluetooth_NN.cpp \ +SOURCES = bluetoothBNEP_NN.cpp \ bluetoothBNEP_NNI.cpp \ + bluetoothRFCOMM_NN.cpp \ bluetoothRFCOMM_NNI.cpp \ bluetoothBNEPedit.cpp \ bluetoothBNEPrun.cpp \ + bluetoothRFCOMMrun.cpp \ bluetoothRFCOMMedit.cpp -INCLUDEPATH += $(OPIEDIR)/include ../ ../networksettings2 -DEPENDPATH += $(OPIEDIR)/include ../ ../networksettings2 -LIBS += -lqpe +INCLUDEPATH += $(OPIEDIR)/include ../ ../networksettings2 ../opietooth2 +DEPENDPATH += $(OPIEDIR)/include ../ ../networksettings2 ../opietooth2 +LIBS += -lqpe -lopietooth2 INTERFACES = bluetoothBNEPGUI.ui bluetoothRFCOMMGUI.ui TARGET = bluetooth VERSION = 1.0.0 diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp index 398dcdc..42b2515 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp @@ -1,6 +1,6 @@ #include "bluetoothBNEPedit.h" #include "bluetoothBNEP_NNI.h" -#include "bluetooth_NN.h" +#include "bluetoothBNEP_NN.h" ABluetoothBNEP::ABluetoothBNEP( BluetoothBNEPNetNode * PNN ) : ANetNodeInstance( PNN ), Data() { diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h index 03c6903..f52a2c5 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h @@ -3,9 +3,12 @@ #include -typedef struct BluetoothBNEPData { +class BluetoothBNEPData { + +public : + bool AllowAll; QStringList BDAddress; -} BluetoothBNEPData_t; +}; #endif diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp index 24e4b7b..9d4ae97 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp @@ -4,246 +4,158 @@ #include #include "bluetoothBNEPrun.h" -QDict * BluetoothBNEPRun::PANConnections = 0; +BluetoothBNEPRun::BluetoothBNEPRun( ANetNodeInstance * NNI, + BluetoothBNEPData & D ) : + RuntimeInfo( NNI ), + Data( D), + Pat( "bnep[0-6]" ) { + OT = 0; +} -void BluetoothBNEPRun::detectState( NodeCollection * NC ) { - // unavailable : no card found - // available : card found and assigned to us or free - // up : card found and assigned to us and up - QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); - System & Sys = NSResources->system(); - InterfaceInfo * Run; - QFile F( S ); - - Log(("Detecting for %s\n", NC->name().latin1() )); - - if( F.open( IO_ReadOnly ) ) { - // could open file -> read interface and assign - QString X; - bool accepted = 0; - QTextStream TS(&F); - X = TS.readLine(); - Log(("%s exists : %s\n", S.latin1(), X.latin1() )); - // find interface - if( handlesInterface( X ) ) { - - Log(("Handles interface %s, PANC %p\n", X.latin1(), PANConnections )); - if( PANConnections == 0 ) { - // load connections that are active - // format : bnep0 00:60:57:02:71:A2 PANU - FILE * OutputOfCmd = popen( "pand --show", "r" ) ; - - PANConnections = new QDict; - - if( OutputOfCmd ) { - char ch; - // could fork - // read all data - QString Line = ""; - while( 1 ) { - if( fread( &ch, 1, 1, OutputOfCmd ) < 1 ) { - // eof - break; - } - if( ch == '\n' || ch == '\r' ) { - if( ! Line.isEmpty() ) { - if( Line.startsWith( "bnep" ) ) { - QStringList SL = QStringList::split( " ", Line ); - Log(("Detected PAN %s %s\n", - SL[0].latin1(), SL[1].latin1() )); - PANConnections->insert( SL[0], new QString(SL[1])); - } - Line=""; - } - } else { - Line += ch; - } - } - } +BluetoothBNEPRun::~BluetoothBNEPRun( void ) { + if( OT ) { + OTGateway::releaseOTGateway(); + } +} - pclose( OutputOfCmd ); - } +State_t BluetoothBNEPRun::detectState( void ) { - // check if this runtime allows connection to node - if( ! Data.AllowAll ) { - // has addresses - for ( QStringList::Iterator it = Data.BDAddress.begin(); - ! accepted && it != Data.BDAddress.end(); - ++ it ) { - for( QDictIterator it2( *(PANConnections) ); - it2.current(); - ++ it2 ) { - if( X == it2.currentKey() && - (*it) == *(it2.current()) - ) { - // found - Log(("%s accepts connections to %s\n", - NC->name().latin1(), - it2.current()->latin1() )); - accepted = 1; - break; - } - } - } - } else { - Log(("%s accepts any connection\n", NC->name().latin1() )); - // accept any - accepted = 1; - } + /* - if( accepted ) { - // matches and is allowed for this node - for( QDictIterator It(Sys.interfaces()); - It.current(); - ++It ) { - Run = It.current(); - if( X == Run->Name ) { - Log(("%s Assigned %p\n", NC->name().latin1(), Run )); - Run->assignNode( netNode() ); - assignInterface( Run ); - NC->setCurrentState( IsUp ); - return; - } - } - } - } - } - - Log(("Assigned %p\n", assignedInterface() )); - if( ( Run = assignedInterface() ) ) { - // we already have an interface assigned -> still present ? - if( ! Run->IsUp ) { - // usb is still free -> keep assignment - NC->setCurrentState( Available ); - return; - } // else interface is up but NOT us -> some other profile + need to detect + + 1. for any PAN connection 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) + + 2. if it not connected and we allow any connection we + are available or if that PAN connection 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 + + */ + + if( ! OT ) { + OT = OTGateway::getOTGateway(); } - // nothing (valid) assigned to us - assignInterface( 0 ); - - // find possible interface - for( QDictIterator It(Sys.interfaces()); - It.current(); - ++It ) { - Run = It.current(); - - Log(("%s %d %d=%d %d\n", - Run->Name.latin1(), - handlesInterface( Run->Name ), - Run->CardType, ARPHRD_ETHER, - ! Run->IsUp )); - - if( handlesInterface( Run->Name ) && - Run->CardType == ARPHRD_ETHER && - ! Run->IsUp - ) { - Log(("Released(OFF)\n" )); - // proper type, and Not UP -> free - NC->setCurrentState( Off ); - return; - } + if( ! OT->isEnabled() ) { + return Unavailable; } - // no free found - Log(("None available\n" )); - NC->setCurrentState( Unavailable ); + // if there is a PAN connection that is UP but not + // yet configured (no ifup) the we are available + return ( hasFreePANConnection() ) ? Available : Unknown; } -bool BluetoothBNEPRun::setState( NodeCollection * NC, Action_t A, bool ) { +QString BluetoothBNEPRun::setMyState( NodeCollection * NC, Action_t A, bool ) { - // we only handle activate and deactivate - switch( A ) { - case Activate : - { - if( NC->currentState() != Off ) { - return 0; - } - InterfaceInfo * N = getInterface(); - if( ! N ) { - // no interface available - NC->setCurrentState( Unavailable ); - return 0; - } - // because we were OFF the interface - // we get back is NOT assigned - N->assignNode( netNode() ); - assignInterface( N ); - Log(("Assing %p\n", N )); - NC->setCurrentState( Available ); - return 1; - } - case Deactivate : - if( NC->currentState() == IsUp ) { - // bring down first - if( ! connection()->setState( Down ) ) - // could not ... - return 0; - } else if( NC->currentState() != Available ) { - return 1; - } - assignedInterface()->assignNode( 0 ); // release - assignInterface( 0 ); - NC->setCurrentState( Off ); - return 1; - default : - // FT - break; + if( A == Activate ) { + if( hasFreePANConnection( 1 ) ) { + // we have now an assignedinterface + } else { + return QString("TODO : Start PAND"); + } + + Log(( "Assigned interface" )); + NC->setCurrentState( Available ); + + return QString(); } - return 0; + + if( A == Deactivate ) { + // nothing to do + NC->setCurrentState( Off ); + return QString(); + } + return QString(); } -bool BluetoothBNEPRun::canSetState( State_t Curr , Action_t A ) { - // we only handle up down activate and deactivate - switch( A ) { - case Activate : - { // at least available - if( Curr == Available ) { - return 1; - } - // or we can make one available - InterfaceInfo * N = getInterface(); - if( ! N || N->assignedNode() != 0 ) { - // non available or assigned - return 0; +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 ) { + + if( ! OT ) { + OT = OTGateway::getOTGateway(); + } + + // load PAN connections + OTPANConnection * C; + InterfaceInfo * Run; + InterfaceInfo * Candidate = 0; // reuse this interface + PANConnectionVector Conns = OT->getPANConnections(); + 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 + // 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 + IsValid = 1; + break; } - return 1; } - case Deactivate : - return ( Curr >= Available ); - default : - // FT - 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 ? + Run = Sys.findInterface( C->Device ); + + if( Run && Run->IsUp ) { + // this PAN connection 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; + } } - return 0; -} -// get interface that is free or assigned to us -InterfaceInfo * BluetoothBNEPRun::getInterface( void ) { - - System & S = NSResources->system(); - InterfaceInfo * best = 0, * Run; - - for( QDictIterator It(S.interfaces()); - It.current(); - ++It ) { - Run = It.current(); - if( handlesInterface( Run->Name ) && - Run->CardType == ARPHRD_ETHER - ) { - // this is a bluetooth card - if( Run->assignedNode() == netNode() ) { - // assigned to us - return Run; - } else if( Run->assignedNode() == 0 ) { - // free - best = Run; - } + if( Candidate ) { + if ( Grab ) { + netNode()->connection()->assignInterface( Candidate ); } + return 1; } - return best; // can be 0 -} -bool BluetoothBNEPRun::handlesInterface( const QString & S ) { - return Pat.match( S ) >= 0; + // no free PAN + return 0; } + diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h index ce03cbb..a05a7a2 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h @@ -1,34 +1,35 @@ -#include +#include #include "bluetoothBNEPdata.h" -class BluetoothBNEPRun : public AsDevice { +#include +using namespace Opietooth2; + +class BluetoothBNEPRun : public RuntimeInfo { public : BluetoothBNEPRun( ANetNodeInstance * NNI, - BluetoothBNEPData & D ) : - AsDevice( NNI ), - Data( D), - Pat( "bnep[0-6]" ) - { } + BluetoothBNEPData & D ); + virtual ~BluetoothBNEPRun( void ); + + // i am a device + virtual RuntimeInfo * device( void ) + { return this; } - virtual AsDevice * asDevice( void ) - { return (AsDevice *)this; } + bool handlesInterface( const QString & ); + bool handlesInterface( InterfaceInfo * ); - virtual AsDevice * device( void ) - { return asDevice(); } + State_t detectState( void ); protected : - void detectState( NodeCollection * ); - bool setState( NodeCollection * , Action_t, bool ); - bool canSetState( State_t , Action_t ); - bool handlesInterface( const QString & ); + QString setMyState( NodeCollection * , Action_t, bool ); private : - InterfaceInfo * getInterface( void ); + bool hasFreePANConnection( bool Grab = 0 ); + BluetoothBNEPData & Data; - static QDict * PANConnections; + OTGateway * OT; QRegExp Pat; }; diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui index 2754a70..7f6565a 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui @@ -11,8 +11,8 @@ 0 0 - 283 - 199 + 488 + 604 @@ -28,17 +28,38 @@ margin - 2 + 0 spacing - 2 + 3 + QLabel + + name + TextLabel5_2 + + + text + Selected devices with gprs capability + + + alignment + WordBreak|AlignVCenter|AlignLeft + + + wordwrap + + + QLayoutWidget name - Layout4 + Layout8 + + + layoutSpacing @@ -47,45 +68,120 @@ spacing - 6 + 3 QLabel name - TextLabel4 + TextLabel5 text - Name + Address QLineEdit name - Name_LE + Address_LE + + + + QToolButton + + name + FindDevice_TB + + + text + ... - QLabel + QLayoutWidget name - TextLabel3 + Layout7 - - text - Description - - - - QMultiLineEdit - - name - Description_LE + + layoutSpacing + + + margin + 0 + + + spacing + 3 + + + QLabel + + name + TextLabel2 + + + text + Channel + + + + QSpinBox + + name + Channel_SB + + + sizePolicy + + 0 + 0 + + + + minValue + 1 + + + + QLabel + + name + TextLabel2_2 + + + text + Name + + + + QLabel + + name + Name_LBL + + + sizePolicy + + 7 + 1 + + + + frameShape + Box + + + indent + 0 + + + QLayoutWidget @@ -93,6 +189,9 @@ name Layout5 + + layoutSpacing + margin @@ -100,32 +199,133 @@ spacing - 6 + 3 - QCheckBox + QLabel name - Automatic_CB + TextLabel7 + + + sizePolicy + + 7 + 1 + text - Start automatically + Addresses + + + alignment + AlignVCenter|AlignLeft + + + vAlign + + + + QToolButton + + name + Add_TB + + + text + ... - QCheckBox + QToolButton name - Confirm_CB + Remove_TB text - Confirm before start + ... + + QListView + + + text + Name + + + clickable + true + + + resizeable + true + + + + + text + Channel + + + clickable + true + + + resizeable + true + + + + + text + Address + + + clickable + true + + + resizeable + true + + + + name + Addresses_LV + + + allColumnsShowFocus + true + + + + + Add_TB + clicked() + BluetoothRFCOMM_FRM + SLOT_AddServer() + + + Remove_TB + clicked() + BluetoothRFCOMM_FRM + SLOT_RemoveServer() + + + FindDevice_TB + clicked() + BluetoothRFCOMM_FRM + SLOT_FindDevice() + + SLOT_AddServer() + SLOT_RemoveServer() + SLOT_FindDevice() + diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp index 7ec8288..d19386e 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp @@ -1,16 +1,35 @@ #include "bluetoothRFCOMMedit.h" #include "bluetoothRFCOMM_NNI.h" -#include "bluetooth_NN.h" +#include "bluetoothRFCOMM_NN.h" -ABluetoothRFCOMM::ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN ) : ANetNodeInstance( PNN ) { - GUI = 0; - RT = 0; +ABluetoothRFCOMM::ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN ) : + ANetNodeInstance( PNN ), Data() { + Data.Devices.setAutoDelete( TRUE ); + GUI = 0; + RT = 0; } -void ABluetoothRFCOMM::setSpecificAttribute( QString & , QString & ) { +void ABluetoothRFCOMM::setSpecificAttribute( QString & A, QString & V) { + + if( A == "bdaddress" ) { + Data.Devices.resize( Data.Devices.size() + 1 ); + Data.Devices.insert( Data.Devices.size() - 1, new RFCOMMChannel); + Data.Devices[ Data.Devices.size() - 1 ]->BDAddress = V; + } else if ( A == "channel" ) { + Data.Devices[ Data.Devices.size() - 1 ]->Channel = V.toLong(); + } else if ( A == "name" ) { + Data.Devices[ Data.Devices.size() - 1 ]->Name = V; + } } -void ABluetoothRFCOMM::saveSpecificAttribute( QTextStream & ) { +void ABluetoothRFCOMM::saveSpecificAttribute( QTextStream & TS ) { + for( unsigned int i = 0 ; + i < Data.Devices.count(); + i ++ ) { + TS << "bdaddress=" << Data.Devices[i]->BDAddress << endl; + TS << "name=" << quote( Data.Devices[i]->Name ) << endl; + TS << "channel=" << Data.Devices[i]->Channel << endl; + } } diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h index 18f0d38..14cfeb0 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h @@ -2,17 +2,21 @@ #define BLUETOOTHRFCOMM_DATA_H #include +#include -typedef struct BluetoothRFCOMMData { - QString Device; - QString LockFile; - long Speed; - short Parity; - short DataBits; - short StopBits; - bool HardwareControl; - bool SoftwareControl; +class RFCOMMChannel { -} BluetoothRFCOMMData_t; +public : + QString BDAddress; + QString Name; + int Channel; +}; + +class BluetoothRFCOMMData { + +public : + + QVector Devices; +}; #endif diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp index d3ddab4..7cac13f 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp @@ -1,18 +1,156 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include "bluetoothRFCOMMedit.h" +using namespace Opietooth2; + +class PeerLBI : public QListViewItem { + +public : + + PeerLBI( OTPeer * P, int Ch, QListView * LV ) : QListViewItem( LV ) { + Peer = P; + Channel = Ch; + + setText( 0, (P->name().isEmpty()) ? + P->address().toString() : + P->name() ); + QString S; + S.setNum( Ch ); + setText( 1, S ); + setText( 2, P->address().toString() ); + } + ~PeerLBI( ) { + } + + inline int channel( void ) const + { return Channel; } + inline OTPeer * peer( void ) const + { return Peer; } + + int Channel; + OTPeer * Peer; +}; + BluetoothRFCOMMEdit::BluetoothRFCOMMEdit( QWidget * Parent ) : BluetoothRFCOMMGUI( Parent ){ + Modified = 0; + OT = OTGateway::getOTGateway(); + + Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); + Remove_TB->setPixmap( NSResources->getPixmap( "remove" ) ); + FindDevice_TB->setPixmap( NSResources->getPixmap( "Devices/bluetooth" ) ); + Addresses_LV->setColumnAlignment( 1, Qt::AlignRight ); +} +BluetoothRFCOMMEdit::~BluetoothRFCOMMEdit( void ) { + OTGateway::releaseOTGateway(); } QString BluetoothRFCOMMEdit::acceptable( void ) { - return QString(); + return QString(); +} + +bool BluetoothRFCOMMEdit::commit( BluetoothRFCOMMData & Data ) { + int ct = 0; + PeerLBI * I; + + if( Modified ) { + QListViewItem * it = Addresses_LV->firstChild(); + + Data.Devices.resize( 0 ); + while( it ) { + + ct ++; + Data.Devices.resize( ct ); + I = (PeerLBI * )it; + + Data.Devices.insert( ct-1, new RFCOMMChannel ); + + Data.Devices[ct-1]->BDAddress = I->peer()->address().toString(); + Data.Devices[ct-1]->Name = I->peer()->name(); + Data.Devices[ct-1]->Channel = I->channel(); + + it = it->nextSibling(); + } + } + + return Modified; } void BluetoothRFCOMMEdit::showData( BluetoothRFCOMMData & Data ) { + + OTPeer * P; + + for( unsigned int i = 0; + i < Data.Devices.count(); + i ++ ) { + P = new OTPeer( OT ); + P->setAddress( OTDeviceAddress( Data.Devices[i]->BDAddress ) ); + P->setName( Data.Devices[i]->Name ); + + new PeerLBI( P, Data.Devices[i]->Channel, Addresses_LV ); + } + Modified = 0; } -bool BluetoothRFCOMMEdit::commit( BluetoothRFCOMMData & Data ) { - return 0; +void BluetoothRFCOMMEdit::SLOT_AddServer( void ) { + QListViewItem * it = Addresses_LV->firstChild(); + + while( it ) { + // check address + if( it->text(2) == Address_LE->text() ) { + // already in table + return; + } + it = it->nextSibling(); + } + + // new server + Modified = 1; + OTPeer * P = new OTPeer( OT ); + P->setAddress( OTDeviceAddress( Address_LE->text() ) ); + P->setName( Name_LBL->text() ); + new PeerLBI( P, Channel_SB->value(), Addresses_LV ); + + Address_LE->setText(""); + Name_LBL->setText(""); + Channel_SB->setValue(1); +} + +void BluetoothRFCOMMEdit::SLOT_RemoveServer( void ) { + + QListViewItem * it = Addresses_LV->firstChild(); + + while( it ) { + // check address + if( it->isSelected() ) { + delete it; + Modified = 1; + return; + } + it = it->nextSibling(); + } +} + +void BluetoothRFCOMMEdit::SLOT_FindDevice( void ) { + OTPeer * Peer; + int Channel; + + // find device in Opietooth + if( OTScan::getDevice( Peer, Channel, OT ) == QDialog::Accepted ) { + Address_LE->setText( Peer->address().toString() ); + Name_LBL->setText( Peer->name() ); + Channel_SB->setValue( Channel ); + } } diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h index 14a6d64..9ad8f2a 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h @@ -1,13 +1,27 @@ #include "bluetoothRFCOMMdata.h" #include "bluetoothRFCOMMGUI.h" +#include +using namespace Opietooth2; + class BluetoothRFCOMMEdit : public BluetoothRFCOMMGUI { public : BluetoothRFCOMMEdit( QWidget * parent ); + virtual ~BluetoothRFCOMMEdit( void ); QString acceptable( void ); void showData( BluetoothRFCOMMData & Data ); bool commit( BluetoothRFCOMMData & Data ); + + bool Modified; + OTGateway * OT; + +public slots : + + void SLOT_AddServer( void ); + void SLOT_RemoveServer( void ); + void SLOT_FindDevice( void ); + }; diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h index 65fd686..24e3dae 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h @@ -1,28 +1,33 @@ -#include +#include #include "bluetoothRFCOMMdata.h" -class BluetoothRFCOMMRun : public AsLine { +#include +using namespace Opietooth2; + +class BluetoothRFCOMMRun : public RuntimeInfo { public : BluetoothRFCOMMRun( ANetNodeInstance * NNI, - BluetoothRFCOMMData & Data ) : AsLine( NNI ) - { } + BluetoothRFCOMMData & D ) : RuntimeInfo( NNI ) + { DeviceNr = -1; Data = &D; OT = 0; } + virtual ~BluetoothRFCOMMRun( void ); - virtual AsLine * asLine( void ) - { return (AsLine *)this; } + virtual RuntimeInfo * line( void ) + { return this; } + virtual QString deviceFile( void ); - virtual QString deviceFile( void ) - { return QString( "/dev/rfcomm..." ); } + State_t detectState( void ); protected : - void detectState( NodeCollection * ) - { } + QString setMyState( NodeCollection * , Action_t, bool ); - bool setState( NodeCollection * , Action_t, bool ) - { return 0; } +private : - bool canSetState( State_t , Action_t ) - { return 0; } + int deviceNrOfConnection( void ); + RFCOMMChannel * getChannel( void ); + BluetoothRFCOMMData * Data; + Opietooth2::OTGateway * OT; + int DeviceNr; // cached from detection }; diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp index 443a627..9be6b16 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp @@ -12,6 +12,11 @@ static const char * BluetoothBNEPNeeds[] = { 0 }; +static const char * BluetoothBNEPProvides[] = + { "device", + 0 + }; + /** * Constructor, find all of the possible interfaces */ @@ -42,8 +47,8 @@ const char ** BluetoothBNEPNetNode::needs( void ) { return BluetoothBNEPNeeds; } -const char * BluetoothBNEPNetNode::provides( void ) { - return "device"; +const char ** BluetoothBNEPNetNode::provides( void ) { + return BluetoothBNEPProvides; } QString BluetoothBNEPNetNode::genNic( long nr ) { diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h index 4d6a3c1..b93342e 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h @@ -22,7 +22,7 @@ public: virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); virtual const char ** needs( void ); private: diff --git a/noncore/settings/networksettings2/bluetooth/config.in b/noncore/settings/networksettings2/bluetooth/config.in index 6968ac8..398cff1 100644 --- a/noncore/settings/networksettings2/bluetooth/config.in +++ b/noncore/settings/networksettings2/bluetooth/config.in @@ -1,4 +1,4 @@ config NS2BT boolean "opie-networksettings2plugin-bluetooth (set up BLUETOOTH)" default "n" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE && NS2OPIETOOTH diff --git a/noncore/settings/networksettings2/bluetooth/opie-networksettings2plugin-bluetooth.control b/noncore/settings/networksettings2/bluetooth/opie-networksettings2plugin-bluetooth.control index ea77bd7..c4d29f2 100644 --- a/noncore/settings/networksettings2/bluetooth/opie-networksettings2plugin-bluetooth.control +++ b/noncore/settings/networksettings2/bluetooth/opie-networksettings2plugin-bluetooth.control @@ -1,9 +1,9 @@ -Package: opie-networksettingsplugin2-bluetooth +Package: opie-networksettings2plugin-bluetooth Files: plugins/networksettings2/libbluetooth.so* Priority: optional Section: opie/settings Maintainer: Wim Delvaux Architecture: arm -Depends: opie-networksettings2, libopiecore2, libopienet2 +Depends: opie-networksettings2, libopietooth2, libopiecore2, libopienet2 Description: Network settings bluetooth plugin. Version: $QPE_VERSION$EXTRAVERSION -- cgit v0.9.0.2