summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp40
1 files changed, 20 insertions, 20 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
@@ -2,14 +2,14 @@
2#include <qfileinfo.h> 2#include <qfileinfo.h>
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include <resources.h> 4#include <resources.h>
5#include "bluetoothBNEPrun.h" 5#include "bluetoothBNEPrun.h"
6 6
7using Opietooth2::OTGateway; 7using Opietooth2::OTGateway;
8using Opietooth2::OTPANConnection; 8using Opietooth2::OTPANNetworkSetup;
9using Opietooth2::PANConnectionVector; 9using Opietooth2::PANNetworkSetupVector;
10 10
11BluetoothBNEPRun::BluetoothBNEPRun( ANetNodeInstance * NNI, 11BluetoothBNEPRun::BluetoothBNEPRun( ANetNodeInstance * NNI,
12 BluetoothBNEPData & D ) : 12 BluetoothBNEPData & D ) :
13 RuntimeInfo( NNI ), 13 RuntimeInfo( NNI ),
14 Data( D), 14 Data( D),
15 Pat( "bnep[0-6]" ) { 15 Pat( "bnep[0-6]" ) {
@@ -25,46 +25,46 @@ BluetoothBNEPRun::~BluetoothBNEPRun( void ) {
25State_t BluetoothBNEPRun::detectState( void ) { 25State_t BluetoothBNEPRun::detectState( void ) {
26 26
27 /* 27 /*
28 28
29 need to detect 29 need to detect
30 30
31 1. for any PAN connection that is found if that 31 1. for any PAN NetworkSetup that is found if that
32 PAN is connected. 32 PAN is connected.
33 33
34 if it is connected it is not available (since we do 34 if it is connected it is not available (since we do
35 not manage IP settings and we are called to detect 35 not manage IP settings and we are called to detect
36 the state we knwo that we do not have an UP connection) 36 the state we knwo that we do not have an UP NetworkSetup)
37 37
38 2. if it not connected and we allow any connection we 38 2. if it not connected and we allow any NetworkSetup we
39 are available or if that PAN connection is to a device 39 are available or if that PAN NetworkSetup is to a device
40 with a correct address 40 with a correct address
41 41
42 3. if it is not connected and the address do not match or 42 3. if it is not connected and the address do not match or
43 we do not accept any address, we are Unavailable but 43 we do not accept any address, we are Unavailable but
44 not DOWN. I.e a new connection could perhaps be created 44 not DOWN. I.e a new NetworkSetup could perhaps be created
45 45
46 */ 46 */
47 47
48 if( ! OT ) { 48 if( ! OT ) {
49 OT = OTGateway::getOTGateway(); 49 OT = OTGateway::getOTGateway();
50 } 50 }
51 51
52 if( ! OT->isEnabled() ) { 52 if( ! OT->isEnabled() ) {
53 return Unavailable; 53 return Unavailable;
54 } 54 }
55 55
56 // if there is a PAN connection that is UP but not 56 // if there is a PAN NetworkSetup that is UP but not
57 // yet configured (no ifup) the we are available 57 // yet configured (no ifup) the we are available
58 return ( hasFreePANConnection() ) ? Available : Unknown; 58 return ( hasFreePANNetworkSetup() ) ? Available : Unknown;
59} 59}
60 60
61QString BluetoothBNEPRun::setMyState( NodeCollection * NC, Action_t A, bool ) { 61QString BluetoothBNEPRun::setMyState( NetworkSetup * NC, Action_t A, bool ) {
62 62
63 if( A == Activate ) { 63 if( A == Activate ) {
64 if( hasFreePANConnection( 1 ) ) { 64 if( hasFreePANNetworkSetup( 1 ) ) {
65 // we have now an assignedinterface 65 // we have now an assignedinterface
66 } else { 66 } else {
67 return QString("TODO : Start PAND"); 67 return QString("TODO : Start PAND");
68 } 68 }
69 69
70 Log(( "Assigned interface" )); 70 Log(( "Assigned interface" ));
@@ -86,43 +86,43 @@ bool BluetoothBNEPRun::handlesInterface( const QString & S ) {
86} 86}
87 87
88bool BluetoothBNEPRun::handlesInterface( InterfaceInfo * I ) { 88bool BluetoothBNEPRun::handlesInterface( InterfaceInfo * I ) {
89 return handlesInterface( I->Name ); 89 return handlesInterface( I->Name );
90} 90}
91 91
92bool BluetoothBNEPRun::hasFreePANConnection( bool Grab ) { 92bool BluetoothBNEPRun::hasFreePANNetworkSetup( bool Grab ) {
93 93
94 if( ! OT ) { 94 if( ! OT ) {
95 OT = OTGateway::getOTGateway(); 95 OT = OTGateway::getOTGateway();
96 } 96 }
97 97
98 // load PAN connections 98 // load PAN NetworkSetups
99 OTPANConnection * C; 99 OTPANNetworkSetup * C;
100 InterfaceInfo * Run; 100 InterfaceInfo * Run;
101 InterfaceInfo * Candidate = 0; // reuse this interface 101 InterfaceInfo * Candidate = 0; // reuse this interface
102 PANConnectionVector Conns = OT->getPANConnections(); 102 PANNetworkSetupVector Conns = OT->getPANNetworkSetups();
103 System & Sys = NSResources->system(); 103 System & Sys = NSResources->system();
104 bool IsValid; 104 bool IsValid;
105 105
106 for( unsigned int i = 0; 106 for( unsigned int i = 0;
107 i < Conns.count(); 107 i < Conns.count();
108 i ++ ) { 108 i ++ ) {
109 C = Conns[i]; 109 C = Conns[i];
110 110
111 if( Data.AllowAll ) { 111 if( Data.AllowAll ) {
112 // we allow all 112 // we allow all
113 IsValid = 1; 113 IsValid = 1;
114 } else { 114 } else {
115 // is this PAN connection connecting to a Peer 115 // is this PAN NetworkSetup connecting to a Peer
116 // we allow ? 116 // we allow ?
117 IsValid = 0; 117 IsValid = 0;
118 for ( QStringList::Iterator it = Data.BDAddress.begin(); 118 for ( QStringList::Iterator it = Data.BDAddress.begin();
119 it != Data.BDAddress.end(); 119 it != Data.BDAddress.end();
120 ++ it ) { 120 ++ it ) {
121 if( C->ConnectedTo == (*it) ) { 121 if( C->ConnectedTo == (*it) ) {
122 // this is a connection we could accept 122 // this is a NetworkSetup we could accept
123 IsValid = 1; 123 IsValid = 1;
124 break; 124 break;
125 } 125 }
126 } 126 }
127 } 127 }
128 128
@@ -132,17 +132,17 @@ bool BluetoothBNEPRun::hasFreePANConnection( bool Grab ) {
132 C->ConnectedTo.latin1() )); 132 C->ConnectedTo.latin1() ));
133 // don't bother checking this address 133 // don't bother checking this address
134 // it is not acceptable 134 // it is not acceptable
135 continue; 135 continue;
136 } 136 }
137 137
138 // is this PAN connection available to us ? 138 // is this PAN NetworkSetup available to us ?
139 Run = Sys.findInterface( C->Device ); 139 Run = Sys.findInterface( C->Device );
140 140
141 if( Run && Run->IsUp ) { 141 if( Run && Run->IsUp ) {
142 // this PAN connection is up 142 // this PAN NetworkSetup is up
143 Log(("%s acceptable but unavailable\n", 143 Log(("%s acceptable but unavailable\n",
144 C->Device.latin1() )); 144 C->Device.latin1() ));
145 // find others 145 // find others
146 continue; 146 continue;
147 } 147 }
148 148
@@ -151,13 +151,13 @@ bool BluetoothBNEPRun::hasFreePANConnection( bool Grab ) {
151 Candidate = Run; 151 Candidate = Run;
152 } 152 }
153 } 153 }
154 154
155 if( Candidate ) { 155 if( Candidate ) {
156 if ( Grab ) { 156 if ( Grab ) {
157 netNode()->connection()->assignInterface( Candidate ); 157 netNode()->networkSetup()->assignInterface( Candidate );
158 } 158 }
159 return 1; 159 return 1;
160 } 160 }
161 161
162 // no free PAN 162 // no free PAN
163 return 0; 163 return 0;