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,76 +1,76 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
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 | ||
7 | using Opietooth2::OTGateway; | 7 | using Opietooth2::OTGateway; |
8 | using Opietooth2::OTPANConnection; | 8 | using Opietooth2::OTPANNetworkSetup; |
9 | using Opietooth2::PANConnectionVector; | 9 | using Opietooth2::PANNetworkSetupVector; |
10 | 10 | ||
11 | BluetoothBNEPRun::BluetoothBNEPRun( ANetNodeInstance * NNI, | 11 | BluetoothBNEPRun::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]" ) { |
16 | OT = 0; | 16 | OT = 0; |
17 | } | 17 | } |
18 | 18 | ||
19 | BluetoothBNEPRun::~BluetoothBNEPRun( void ) { | 19 | BluetoothBNEPRun::~BluetoothBNEPRun( void ) { |
20 | if( OT ) { | 20 | if( OT ) { |
21 | OTGateway::releaseOTGateway(); | 21 | OTGateway::releaseOTGateway(); |
22 | } | 22 | } |
23 | } | 23 | } |
24 | 24 | ||
25 | State_t BluetoothBNEPRun::detectState( void ) { | 25 | State_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 | ||
61 | QString BluetoothBNEPRun::setMyState( NodeCollection * NC, Action_t A, bool ) { | 61 | QString 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" )); |
71 | NC->setCurrentState( Available ); | 71 | NC->setCurrentState( Available ); |
72 | 72 | ||
73 | return QString(); | 73 | return QString(); |
74 | } | 74 | } |
75 | 75 | ||
76 | if( A == Deactivate ) { | 76 | if( A == Deactivate ) { |
@@ -80,86 +80,86 @@ QString BluetoothBNEPRun::setMyState( NodeCollection * NC, Action_t A, bool ) { | |||
80 | } | 80 | } |
81 | return QString(); | 81 | return QString(); |
82 | } | 82 | } |
83 | 83 | ||
84 | bool BluetoothBNEPRun::handlesInterface( const QString & S ) { | 84 | bool BluetoothBNEPRun::handlesInterface( const QString & S ) { |
85 | return Pat.match( S ) >= 0; | 85 | return Pat.match( S ) >= 0; |
86 | } | 86 | } |
87 | 87 | ||
88 | bool BluetoothBNEPRun::handlesInterface( InterfaceInfo * I ) { | 88 | bool BluetoothBNEPRun::handlesInterface( InterfaceInfo * I ) { |
89 | return handlesInterface( I->Name ); | 89 | return handlesInterface( I->Name ); |
90 | } | 90 | } |
91 | 91 | ||
92 | bool BluetoothBNEPRun::hasFreePANConnection( bool Grab ) { | 92 | bool 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 | ||
129 | if( ! IsValid ) { | 129 | if( ! IsValid ) { |
130 | Log(("%s to %s not acceptable\n", | 130 | Log(("%s to %s not acceptable\n", |
131 | C->Device.latin1(), | 131 | C->Device.latin1(), |
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 | ||
149 | // we at least have a possible interface | 149 | // we at least have a possible interface |
150 | if( ! Candidate ) { | 150 | if( ! Candidate ) { |
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; |
164 | } | 164 | } |
165 | 165 | ||
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 | |||
@@ -13,22 +13,22 @@ public : | |||
13 | 13 | ||
14 | // i am a device | 14 | // i am a device |
15 | virtual RuntimeInfo * device( void ) | 15 | virtual RuntimeInfo * device( void ) |
16 | { return this; } | 16 | { return this; } |
17 | 17 | ||
18 | bool handlesInterface( const QString & ); | 18 | bool handlesInterface( const QString & ); |
19 | bool handlesInterface( InterfaceInfo * ); | 19 | bool handlesInterface( InterfaceInfo * ); |
20 | 20 | ||
21 | State_t detectState( void ); | 21 | State_t detectState( void ); |
22 | 22 | ||
23 | protected : | 23 | protected : |
24 | 24 | ||
25 | QString setMyState( NodeCollection * , Action_t, bool ); | 25 | QString setMyState( NetworkSetup * , Action_t, bool ); |
26 | 26 | ||
27 | private : | 27 | private : |
28 | 28 | ||
29 | bool hasFreePANConnection( bool Grab = 0 ); | 29 | bool hasFreePANNetworkSetup( bool Grab = 0 ); |
30 | 30 | ||
31 | BluetoothBNEPData & Data; | 31 | BluetoothBNEPData & Data; |
32 | Opietooth2::OTGateway * OT; | 32 | Opietooth2::OTGateway * OT; |
33 | QRegExp Pat; | 33 | QRegExp Pat; |
34 | }; | 34 | }; |
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 | |||
@@ -11,36 +11,36 @@ using Opietooth2::OTDeviceAddress; | |||
11 | BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) { | 11 | BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) { |
12 | if( OT ) { | 12 | if( OT ) { |
13 | OTGateway::releaseOTGateway(); | 13 | OTGateway::releaseOTGateway(); |
14 | } | 14 | } |
15 | } | 15 | } |
16 | 16 | ||
17 | State_t BluetoothRFCOMMRun::detectState( void ) { | 17 | State_t BluetoothRFCOMMRun::detectState( void ) { |
18 | 18 | ||
19 | if( ! OT ) { | 19 | if( ! OT ) { |
20 | OT = OTGateway::getOTGateway(); | 20 | OT = OTGateway::getOTGateway(); |
21 | } | 21 | } |
22 | 22 | ||
23 | if( deviceNrOfConnection() >= 0 ) { | 23 | if( deviceNrOfNetworkSetup() >= 0 ) { |
24 | return Available; | 24 | return Available; |
25 | } | 25 | } |
26 | 26 | ||
27 | odebug << "Bluetooth " | 27 | odebug << "Bluetooth " |
28 | << OT->isEnabled() | 28 | << OT->isEnabled() |
29 | << oendl; | 29 | << oendl; |
30 | 30 | ||
31 | return ( OT->isEnabled() ) ? Off : Unavailable; | 31 | return ( OT->isEnabled() ) ? Off : Unavailable; |
32 | } | 32 | } |
33 | 33 | ||
34 | QString BluetoothRFCOMMRun::setMyState( NodeCollection *, | 34 | QString BluetoothRFCOMMRun::setMyState( NetworkSetup *, |
35 | Action_t A, | 35 | Action_t A, |
36 | bool ) { | 36 | bool ) { |
37 | 37 | ||
38 | if( OT ) { | 38 | if( OT ) { |
39 | OTGateway::getOTGateway(); | 39 | OTGateway::getOTGateway(); |
40 | } | 40 | } |
41 | 41 | ||
42 | if( A == Activate ) { | 42 | if( A == Activate ) { |
43 | // from OFF to Available | 43 | // from OFF to Available |
44 | RFCOMMChannel * Ch = getChannel( ); | 44 | RFCOMMChannel * Ch = getChannel( ); |
45 | System & Sys = NSResources->system(); | 45 | System & Sys = NSResources->system(); |
46 | 46 | ||
@@ -61,25 +61,25 @@ QString BluetoothRFCOMMRun::setMyState( NodeCollection *, | |||
61 | 61 | ||
62 | // here rfcomm should be running -> we will detect state later | 62 | // here rfcomm should be running -> we will detect state later |
63 | return QString(); | 63 | return QString(); |
64 | } else { | 64 | } else { |
65 | Log(( "No channel selected -> cancel\n" )); | 65 | Log(( "No channel selected -> cancel\n" )); |
66 | return QString( "No channel selected. Operation cancelled" ); | 66 | return QString( "No channel selected. Operation cancelled" ); |
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | if( A == Deactivate ) { | 70 | if( A == Deactivate ) { |
71 | if( DeviceNr >= 0 ) { | 71 | if( DeviceNr >= 0 ) { |
72 | if( OT->releaseRFCommDevice( DeviceNr ) ) { | 72 | if( OT->releaseRFCommDevice( DeviceNr ) ) { |
73 | return QString( "Cannot release RFCOMM connection" ); | 73 | return QString( "Cannot release RFCOMM NetworkSetup" ); |
74 | } | 74 | } |
75 | DeviceNr = -1; | 75 | DeviceNr = -1; |
76 | } | 76 | } |
77 | } | 77 | } |
78 | return QString(); | 78 | return QString(); |
79 | } | 79 | } |
80 | 80 | ||
81 | #include <qlistbox.h> | 81 | #include <qlistbox.h> |
82 | #include <qframe.h> | 82 | #include <qframe.h> |
83 | #include <qlabel.h> | 83 | #include <qlabel.h> |
84 | #include <qlayout.h> | 84 | #include <qlayout.h> |
85 | #include <qdialog.h> | 85 | #include <qdialog.h> |
@@ -122,33 +122,33 @@ RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) { | |||
122 | odebug << "Selected " << Data->Devices[i]->Name << oendl; | 122 | odebug << "Selected " << Data->Devices[i]->Name << oendl; |
123 | Ch = Data->Devices[i]; | 123 | Ch = Data->Devices[i]; |
124 | break; | 124 | break; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | delete Dlg; | 129 | delete Dlg; |
130 | return Ch; | 130 | return Ch; |
131 | } | 131 | } |
132 | 132 | ||
133 | QString BluetoothRFCOMMRun::deviceFile( void ) { | 133 | QString BluetoothRFCOMMRun::deviceFile( void ) { |
134 | if( deviceNrOfConnection() >= 0 ) { | 134 | if( deviceNrOfNetworkSetup() >= 0 ) { |
135 | OTDevice * OTD = OT->getOTDevice(); | 135 | OTDevice * OTD = OT->getOTDevice(); |
136 | // there is a connection | 136 | // there is a NetworkSetup |
137 | return OTD->getRFCommDevicePattern().arg(DeviceNr); | 137 | return OTD->getRFCommDevicePattern().arg(DeviceNr); |
138 | } | 138 | } |
139 | return QString(); | 139 | return QString(); |
140 | } | 140 | } |
141 | 141 | ||
142 | int BluetoothRFCOMMRun::deviceNrOfConnection( void ) { | 142 | int BluetoothRFCOMMRun::deviceNrOfNetworkSetup( void ) { |
143 | 143 | ||
144 | if( ! OT ) { | 144 | if( ! OT ) { |
145 | OT = OTGateway::getOTGateway(); | 145 | OT = OTGateway::getOTGateway(); |
146 | } | 146 | } |
147 | 147 | ||
148 | DeviceNr = -1; | 148 | DeviceNr = -1; |
149 | for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) { | 149 | for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) { |
150 | odebug << "Check for rfcomm on " | 150 | odebug << "Check for rfcomm on " |
151 | << Data->Devices[i]->BDAddress | 151 | << Data->Devices[i]->BDAddress |
152 | << " " | 152 | << " " |
153 | << Data->Devices[i]->Channel | 153 | << Data->Devices[i]->Channel |
154 | << oendl; | 154 | << oendl; |
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 | |||
@@ -11,22 +11,22 @@ public : | |||
11 | BluetoothRFCOMMData & D ) : RuntimeInfo( NNI ) | 11 | BluetoothRFCOMMData & D ) : RuntimeInfo( NNI ) |
12 | { DeviceNr = -1; Data = &D; OT = 0; } | 12 | { DeviceNr = -1; Data = &D; OT = 0; } |
13 | virtual ~BluetoothRFCOMMRun( void ); | 13 | virtual ~BluetoothRFCOMMRun( void ); |
14 | 14 | ||
15 | virtual RuntimeInfo * line( void ) | 15 | virtual RuntimeInfo * line( void ) |
16 | { return this; } | 16 | { return this; } |
17 | virtual QString deviceFile( void ); | 17 | virtual QString deviceFile( void ); |
18 | 18 | ||
19 | State_t detectState( void ); | 19 | State_t detectState( void ); |
20 | 20 | ||
21 | protected : | 21 | protected : |
22 | 22 | ||
23 | QString setMyState( NodeCollection * , Action_t, bool ); | 23 | QString setMyState( NetworkSetup * , Action_t, bool ); |
24 | 24 | ||
25 | private : | 25 | private : |
26 | 26 | ||
27 | int deviceNrOfConnection( void ); | 27 | int deviceNrOfNetworkSetup( void ); |
28 | RFCOMMChannel * getChannel( void ); | 28 | RFCOMMChannel * getChannel( void ); |
29 | BluetoothRFCOMMData * Data; | 29 | BluetoothRFCOMMData * Data; |
30 | Opietooth2::OTGateway * OT; | 30 | Opietooth2::OTGateway * OT; |
31 | int DeviceNr; // cached from detection | 31 | int DeviceNr; // cached from detection |
32 | }; | 32 | }; |