summaryrefslogtreecommitdiff
authorwimpie <wimpie>2005-01-09 00:32:10 (UTC)
committer wimpie <wimpie>2005-01-09 00:32:10 (UTC)
commite54346d28b19d3ac671802a25e8c03f346693291 (patch) (unidiff)
tree0f8d6561e24a7ba36fd8a6ab1869aa470e1fdb36
parent60a617583d0ccc793d9ea4465998d90ec208db58 (diff)
downloadopie-e54346d28b19d3ac671802a25e8c03f346693291.zip
opie-e54346d28b19d3ac671802a25e8c03f346693291.tar.gz
opie-e54346d28b19d3ac671802a25e8c03f346693291.tar.bz2
Updated dependencies
NS2->app requires OT2Lib and NS2Lib OT2Lib requires NS2Lib Most plugins only require NS2Lib Except BTPlugin which requires als OT2Lib Also renamed owarn -> odebug
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp8
-rw-r--r--noncore/settings/networksettings2/bluetooth/config.in2
-rw-r--r--noncore/settings/networksettings2/config.in2
-rw-r--r--noncore/settings/networksettings2/editconnection.cpp1
-rw-r--r--noncore/settings/networksettings2/gprs/GPRSrun.cpp8
-rw-r--r--noncore/settings/networksettings2/network/networkrun.cpp41
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp6
-rw-r--r--noncore/settings/networksettings2/networksettings2/config.in2
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp16
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.cpp18
-rwxr-xr-xnoncore/settings/networksettings2/opie-networksettings2.postinst2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDevice.cpp6
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDriver.cpp16
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDriverList.cpp4
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTGateway.cpp14
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp14
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTInquiry.cpp18
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTPeer.cpp20
-rw-r--r--noncore/settings/networksettings2/opietooth2/Opietooth.cpp12
-rw-r--r--noncore/settings/networksettings2/opietooth2/config.in4
-rwxr-xr-xnoncore/settings/networksettings2/opietooth2/libopietooth2.postinst2
-rw-r--r--noncore/settings/networksettings2/opietooth2/opietooth2.pro7
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.cpp2
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp51
24 files changed, 139 insertions, 137 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp
index ef6878a..3df7f5c 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp
@@ -15,25 +15,25 @@ BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) {
15} 15}
16 16
17State_t BluetoothRFCOMMRun::detectState( void ) { 17State_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( deviceNrOfConnection() >= 0 ) {
24 return Available; 24 return Available;
25 } 25 }
26 26
27 owarn << "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
34QString BluetoothRFCOMMRun::setMyState( NodeCollection *, 34QString BluetoothRFCOMMRun::setMyState( NodeCollection *,
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();
@@ -110,25 +110,25 @@ RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) {
110 110
111 V->addWidget( L ); 111 V->addWidget( L );
112 V->addWidget( LB ); 112 V->addWidget( LB );
113 113
114 Dlg->resize( 100, 100 ); 114 Dlg->resize( 100, 100 );
115 Dlg->move( 20, 115 Dlg->move( 20,
116 (qApp->desktop()->height()-100)/2 ); 116 (qApp->desktop()->height()-100)/2 );
117 117
118 if( Dlg->exec() == QDialog::Accepted ) { 118 if( Dlg->exec() == QDialog::Accepted ) {
119 unsigned int i = 0; 119 unsigned int i = 0;
120 for( i = 0; i < Data->Devices.count(); i ++ ) { 120 for( i = 0; i < Data->Devices.count(); i ++ ) {
121 if( LB->isSelected(i) ) { 121 if( LB->isSelected(i) ) {
122 owarn << "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
133QString BluetoothRFCOMMRun::deviceFile( void ) { 133QString BluetoothRFCOMMRun::deviceFile( void ) {
134 if( deviceNrOfConnection() >= 0 ) { 134 if( deviceNrOfConnection() >= 0 ) {
@@ -138,27 +138,27 @@ QString BluetoothRFCOMMRun::deviceFile( void ) {
138 } 138 }
139 return QString(); 139 return QString();
140} 140}
141 141
142int BluetoothRFCOMMRun::deviceNrOfConnection( void ) { 142int BluetoothRFCOMMRun::deviceNrOfConnection( 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 owarn << "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;
155 if( ( DeviceNr = OT->connectedToRFCommChannel( 155 if( ( DeviceNr = OT->connectedToRFCommChannel(
156 OTDeviceAddress( Data->Devices[i]->BDAddress ), 156 OTDeviceAddress( Data->Devices[i]->BDAddress ),
157 Data->Devices[i]->Channel ) ) >= 0 ) { 157 Data->Devices[i]->Channel ) ) >= 0 ) {
158 owarn << "Up " 158 odebug << "Up "
159 << oendl; 159 << oendl;
160 break; 160 break;
161 } 161 }
162 } 162 }
163 return DeviceNr; 163 return DeviceNr;
164} 164}
diff --git a/noncore/settings/networksettings2/bluetooth/config.in b/noncore/settings/networksettings2/bluetooth/config.in
index 398cff1..1a76f96 100644
--- a/noncore/settings/networksettings2/bluetooth/config.in
+++ b/noncore/settings/networksettings2/bluetooth/config.in
@@ -1,4 +1,4 @@
1 config NS2BT 1 config NS2BT
2 boolean "opie-networksettings2plugin-bluetooth (set up BLUETOOTH)" 2 boolean "opie-networksettings2plugin-bluetooth (set up BLUETOOTH)"
3 default "n" if NS2 3 default "n" if NS2
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE && NS2OPIETOOTH 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE && NS2OPIETOOTH && LIBBLUEZ_DEP
diff --git a/noncore/settings/networksettings2/config.in b/noncore/settings/networksettings2/config.in
index d2b5f26..0236bab 100644
--- a/noncore/settings/networksettings2/config.in
+++ b/noncore/settings/networksettings2/config.in
@@ -1,18 +1,18 @@
1 source noncore/settings/networksettings2/networksettings2/config.in 1 source noncore/settings/networksettings2/networksettings2/config.in
2 source noncore/settings/networksettings2/opietooth2/config.in 2 source noncore/settings/networksettings2/opietooth2/config.in
3 source noncore/settings/networksettings2/opietooth2_applet/config.in 3 source noncore/settings/networksettings2/opietooth2_applet/config.in
4 4
5config NS2 5config NS2
6 boolean 6 boolean "opie-networksettings2 application"
7 default "y" 7 default "y"
8 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE && NS2OPIETOOTH 8 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE && NS2OPIETOOTH
9 9
10 source noncore/settings/networksettings2/profile/config.in 10 source noncore/settings/networksettings2/profile/config.in
11 source noncore/settings/networksettings2/network/config.in 11 source noncore/settings/networksettings2/network/config.in
12 source noncore/settings/networksettings2/lancard/config.in 12 source noncore/settings/networksettings2/lancard/config.in
13 source noncore/settings/networksettings2/ppp/config.in 13 source noncore/settings/networksettings2/ppp/config.in
14 source noncore/settings/networksettings2/wlan/config.in 14 source noncore/settings/networksettings2/wlan/config.in
15 source noncore/settings/networksettings2/usb/config.in 15 source noncore/settings/networksettings2/usb/config.in
16 source noncore/settings/networksettings2/irda/config.in 16 source noncore/settings/networksettings2/irda/config.in
17 source noncore/settings/networksettings2/vpn/config.in 17 source noncore/settings/networksettings2/vpn/config.in
18 source noncore/settings/networksettings2/bluetooth/config.in 18 source noncore/settings/networksettings2/bluetooth/config.in
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp
index 0c3ead6..717d9e9 100644
--- a/noncore/settings/networksettings2/editconnection.cpp
+++ b/noncore/settings/networksettings2/editconnection.cpp
@@ -146,25 +146,24 @@ NodeCollection * EditConnection::getTmpCollection( void ) {
146 // has radio items as children -> 146 // has radio items as children ->
147 // find selected one 147 // find selected one
148 it = it->firstChild(); 148 it = it->firstChild();
149 while( it ) { 149 while( it ) {
150 if( ((QCheckListItem *)it)->isOn() ) { 150 if( ((QCheckListItem *)it)->isOn() ) {
151 // this radio is selected -> go deeper 151 // this radio is selected -> go deeper
152 break; 152 break;
153 } 153 }
154 it = it->nextSibling(); 154 it = it->nextSibling();
155 } 155 }
156 156
157 if( ! it ) { 157 if( ! it ) {
158 owarn << "Radio not selected" << oendl;
159 TmpIsValid = 0; 158 TmpIsValid = 0;
160 return 0; 159 return 0;
161 } 160 }
162 161
163 // it now contains selected radio 162 // it now contains selected radio
164 NN = (*Mapping)[it]; 163 NN = (*Mapping)[it];
165 } 164 }
166 165
167 // NN here contains the netnode of the 166 // NN here contains the netnode of the
168 // current item -> this node needs to 167 // current item -> this node needs to
169 // be stored in the collection 168 // be stored in the collection
170 if( NNI == 0 || 169 if( NNI == 0 ||
diff --git a/noncore/settings/networksettings2/gprs/GPRSrun.cpp b/noncore/settings/networksettings2/gprs/GPRSrun.cpp
index e842b99..cccc71a 100644
--- a/noncore/settings/networksettings2/gprs/GPRSrun.cpp
+++ b/noncore/settings/networksettings2/gprs/GPRSrun.cpp
@@ -14,45 +14,45 @@ State_t GPRSRun::detectState( void ) {
14 NodeCollection * NC = nodeCollection(); 14 NodeCollection * NC = nodeCollection();
15 InterfaceInfo * I = NC->assignedInterface(); 15 InterfaceInfo * I = NC->assignedInterface();
16 16
17 QDir D("/var/run"); 17 QDir D("/var/run");
18 18
19 if( I ) { 19 if( I ) {
20 // has some pppx attached 20 // has some pppx attached
21 return ( I->IsUp ) ? IsUp : Available; 21 return ( I->IsUp ) ? IsUp : Available;
22 } 22 }
23 23
24 // check ppp itself and figure out interface 24 // check ppp itself and figure out interface
25 25
26 owarn << "Check for ppp " << NC->name() << oendl; 26 odebug << "Check for ppp " << NC->name() << oendl;
27 if( D.exists( QString("ppp-")+removeSpaces(NC->name())+".pid") ) { 27 if( D.exists( QString("ppp-")+removeSpaces(NC->name())+".pid") ) {
28 // get pid and check if pppd is still running 28 // get pid and check if pppd is still running
29 QFile F( D.path()+"/ppp-"+removeSpaces(NC->name())+".pid"); 29 QFile F( D.path()+"/ppp-"+removeSpaces(NC->name())+".pid");
30 30
31 owarn << "PPP PID " << F.name() << oendl; 31 odebug << "PPP PID " << F.name() << oendl;
32 if( F.open( IO_ReadOnly ) ) { 32 if( F.open( IO_ReadOnly ) ) {
33 QTextStream TS(&F); 33 QTextStream TS(&F);
34 QString X = TS.readLine(); 34 QString X = TS.readLine();
35 PPPPid = X.toULong(); 35 PPPPid = X.toULong();
36 int rv; 36 int rv;
37 37
38 rv = ::kill( PPPPid, 0 ); 38 rv = ::kill( PPPPid, 0 );
39 if( rv == 0 || 39 if( rv == 0 ||
40 ( rv < 0 && errno == EPERM ) 40 ( rv < 0 && errno == EPERM )
41 ) { 41 ) {
42 // pppd is still up 42 // pppd is still up
43 X = TS.readLine(); 43 X = TS.readLine();
44 I = NSResources->system().findInterface(X); 44 I = NSResources->system().findInterface(X);
45 45
46 owarn << "ppp running : IFace " << X << " = " << (long)I << oendl; 46 odebug << "ppp running : IFace " << X << " = " << (long)I << oendl;
47 47
48 if( I ) { 48 if( I ) {
49 NC->assignInterface( I ); 49 NC->assignInterface( I );
50 return (I->IsUp) ? IsUp : Available; 50 return (I->IsUp) ? IsUp : Available;
51 } 51 }
52 52
53 return Available; 53 return Available;
54 54
55 } else { 55 } else {
56 // pppd is down 56 // pppd is down
57 PPPPid = 0; 57 PPPPid = 0;
58 } 58 }
@@ -79,25 +79,25 @@ QString GPRSRun::setMyState( NodeCollection * NC, Action_t A , bool ) {
79 detectState(); 79 detectState();
80 } 80 }
81 if( PPPPid ) { 81 if( PPPPid ) {
82 QStringList SL; 82 QStringList SL;
83 83
84 SL << "poff" 84 SL << "poff"
85 << removeSpaces( NC->name() ); 85 << removeSpaces( NC->name() );
86 86
87 if( ! NSResources->system().execAsUser( SL ) ) { 87 if( ! NSResources->system().execAsUser( SL ) ) {
88 return QString("Cannot terminate pppd for %1").arg(NC->name()); 88 return QString("Cannot terminate pppd for %1").arg(NC->name());
89 } 89 }
90 NC->assignInterface( 0 ); 90 NC->assignInterface( 0 );
91 owarn << "ppp stopped " << oendl; 91 odebug << "ppp stopped " << oendl;
92 PPPPid = 0; 92 PPPPid = 0;
93 } 93 }
94 } 94 }
95 95
96 return QString(); 96 return QString();
97} 97}
98 98
99bool GPRSRun::handlesInterface( const QString & S ) { 99bool GPRSRun::handlesInterface( const QString & S ) {
100 return Pat.match( S ) >= 0; 100 return Pat.match( S ) >= 0;
101} 101}
102 102
103bool GPRSRun::handlesInterface( InterfaceInfo * I ) { 103bool GPRSRun::handlesInterface( InterfaceInfo * I ) {
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp
index c17aa7f..2c93d9d 100644
--- a/noncore/settings/networksettings2/network/networkrun.cpp
+++ b/noncore/settings/networksettings2/network/networkrun.cpp
@@ -13,39 +13,38 @@ State_t NetworkRun::detectState( void ) {
13 } 13 }
14 14
15 // had no interface or interface is no longer up -> release 15 // had no interface or interface is no longer up -> release
16 nodeCollection()->assignInterface( 0 ); 16 nodeCollection()->assignInterface( 0 );
17 17
18 return Unknown; 18 return Unknown;
19} 19}
20 20
21QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) { 21QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
22 // we handle UP and DOWN 22 // we handle UP and DOWN
23 InterfaceInfo * II = NC->assignedInterface(); 23 InterfaceInfo * II = NC->assignedInterface();
24 24
25 if( ! II ) {
26 Log(( "no interface assigned." ));
27 return QString();
28 }
29
30 QStringList SL;
31
25 if( A == Up ) { 32 if( A == Up ) {
26 // we can bring UP if lower level is available 33 // we can bring UP if lower level is available
27 QStringList SL; 34 SL << "ifup";
28 SL << "ifup" 35 } else if( A == Down ) {
29 << QString().sprintf( "%s=%s-c%d-allowed", 36 SL << "ifdown";
37 } else {
38 return QString();
39 }
40
41 SL << QString().sprintf( "%s=%s-c%d-allowed",
30 II->Name.latin1(), II->Name.latin1(), 42 II->Name.latin1(), II->Name.latin1(),
31 nodeCollection()->number() ); 43 nodeCollection()->number() );
32 if( ! NSResources->system().runAsRoot( SL ) ) { 44
33 return QString("Cannot call %1").arg(SL.join(" ")); 45 if( ! NSResources->system().runAsRoot( SL ) ) {
34 } 46 return QString("Cannot call %1").arg(SL.join(" "));
35 return QString(); 47 }
36 } 48
37
38 if( A == Down ) {
39 QStringList SL;
40 if( II ) {
41 SL << "ifdown"
42 << II->Name.latin1();
43 if( ! NSResources->system().runAsRoot( SL ) ) {
44 return QString( "Cannot call %1" ).arg( SL.join( " " ));
45 }
46 } else {
47 Log(( "no interface assigned." ));
48 }
49 }
50 return QString(); 49 return QString();
51} 50}
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index 9680a96..78b6cce 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -100,27 +100,25 @@ NetworkSettings::NetworkSettings( QWidget *parent,
100 UpdateTimer->start( 5000 ); 100 UpdateTimer->start( 5000 );
101 connect( UpdateTimer, SIGNAL( timeout() ), 101 connect( UpdateTimer, SIGNAL( timeout() ),
102 this, SLOT( SLOT_RefreshStates() ) ); 102 this, SLOT( SLOT_RefreshStates() ) );
103 103
104 /* Add QCopChannel */ 104 /* Add QCopChannel */
105 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), 105 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
106 this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) ); 106 this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) );
107} 107}
108 108
109NetworkSettings::~NetworkSettings() { 109NetworkSettings::~NetworkSettings() {
110 QString S; 110 QString S;
111 111
112 owarn << "Dispose NS" << oendl;
113 if( NSD.isModified() ) { 112 if( NSD.isModified() ) {
114 owarn << "Modified" << oendl;
115 S = NSD.saveSettings(); 113 S = NSD.saveSettings();
116 if( ! S.isEmpty() ) { 114 if( ! S.isEmpty() ) {
117 S.insert( 0, "<p>" ); 115 S.insert( 0, "<p>" );
118 S.append( "</p>" ); 116 S.append( "</p>" );
119 // problem saving 117 // problem saving
120 QMessageBox::warning( 118 QMessageBox::warning(
121 0, 119 0,
122 tr( "Saving setup" ), S ); 120 tr( "Saving setup" ), S );
123 } 121 }
124 122
125 SLOT_GenerateConfig(); 123 SLOT_GenerateConfig();
126 NSD.setModified( 0 ); 124 NSD.setModified( 0 );
@@ -277,30 +275,28 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
277 if( NC->description().isEmpty() ) { 275 if( NC->description().isEmpty() ) {
278 Description_LBL->setText( tr( "<<No description>>" ) ); 276 Description_LBL->setText( tr( "<<No description>>" ) );
279 } else { 277 } else {
280 Description_LBL->setText( NC->description() ); 278 Description_LBL->setText( NC->description() );
281 } 279 }
282 280
283 Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() ); 281 Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() );
284 282
285 bool FrmActive = 1; 283 bool FrmActive = 1;
286 bool IsEnabled = 1; 284 bool IsEnabled = 1;
287 int leds = 0; 285 int leds = 0;
288 286
289 owarn << "State " << NC->state() << oendl;
290 switch( NC->state() ) { 287 switch( NC->state() ) {
291 case Disabled : // no further work 288 case Disabled : // no further work
292 IsEnabled = 0; 289 IsEnabled = 0;
293 FrmActive = 0; 290 FrmActive = 0;
294 owarn << "LEds " << leds << oendl;
295 break; 291 break;
296 case Unknown : 292 case Unknown :
297 case Unchecked : 293 case Unchecked :
298 case Unavailable : 294 case Unavailable :
299 FrmActive = 0; 295 FrmActive = 0;
300 break; 296 break;
301 case Off : 297 case Off :
302 leds = 1; 298 leds = 1;
303 break; 299 break;
304 case Available : 300 case Available :
305 leds = 2; 301 leds = 2;
306 break; 302 break;
@@ -350,25 +346,25 @@ void NetworkSettings::SLOT_GenerateConfig( void ) {
350 } 346 }
351} 347}
352 348
353void NetworkSettings::SLOT_Disable( bool T ) { 349void NetworkSettings::SLOT_Disable( bool T ) {
354 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 350 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
355 QString Msg; 351 QString Msg;
356 352
357 if ( ! LBI ) 353 if ( ! LBI )
358 return; 354 return;
359 355
360 NodeCollection * NC = NSResources->findConnection( LBI->text() ); 356 NodeCollection * NC = NSResources->findConnection( LBI->text() );
361 357
362 owarn << "Prepare to disable" << oendl; 358 Log(( "Prepare to %sable\n", (T) ? "en" : "dis" ));
363 Msg = NC->setState( (T) ? Disable : Enable ); 359 Msg = NC->setState( (T) ? Disable : Enable );
364 if( ! Msg.isEmpty() ) { 360 if( ! Msg.isEmpty() ) {
365 Msg.insert( 0, "<p>" ); 361 Msg.insert( 0, "<p>" );
366 Msg.append( "</p>" ); 362 Msg.append( "</p>" );
367 QMessageBox::warning( 363 QMessageBox::warning(
368 0, 364 0,
369 tr( "Activating profile" ), 365 tr( "Activating profile" ),
370 Msg ); 366 Msg );
371 return; 367 return;
372 } 368 }
373 369
374 // reload new state 370 // reload new state
diff --git a/noncore/settings/networksettings2/networksettings2/config.in b/noncore/settings/networksettings2/networksettings2/config.in
index b384e18..56e971e 100644
--- a/noncore/settings/networksettings2/networksettings2/config.in
+++ b/noncore/settings/networksettings2/networksettings2/config.in
@@ -1,5 +1,5 @@
1config NS2CORE 1config NS2CORE
2 boolean "opie-networksettings2 (TCP/IP network settings)" 2 boolean "opie-networksettings2 library"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI
5 5
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp
index e642c08..f027d35 100644
--- a/noncore/settings/networksettings2/networksettings2/system.cpp
+++ b/noncore/settings/networksettings2/networksettings2/system.cpp
@@ -63,25 +63,25 @@ int System::runAsRoot( QStringList & S, MyProcess * Prc ) {
63 char * usr = getenv("USER"); 63 char * usr = getenv("USER");
64 64
65 if( S.count() == 0 ) { 65 if( S.count() == 0 ) {
66 // loophole to start shell 66 // loophole to start shell
67 return 8888; 67 return 8888;
68 } 68 }
69 if( usr == 0 || strcmp( usr, "root" ) ) { 69 if( usr == 0 || strcmp( usr, "root" ) ) {
70 // unknown or non-root user -> use SUDO 70 // unknown or non-root user -> use SUDO
71 S.prepend( "sudo" ); 71 S.prepend( "sudo" );
72 } 72 }
73 73
74 if( getenv( "NS2TESTMODE" ) ) { 74 if( getenv( "NS2TESTMODE" ) ) {
75 owarn << "TESTMODE !!! execute " 75 odebug << "TESTMODE !!! execute "
76 << S.join( " ") 76 << S.join( " ")
77 << oendl; 77 << oendl;
78 } else { 78 } else {
79 MyProcess * P; 79 MyProcess * P;
80 80
81 if( Prc ) { 81 if( Prc ) {
82 P = Prc; 82 P = Prc;
83 } else { 83 } else {
84 P = new MyProcess(); 84 P = new MyProcess();
85 emit processEvent( tr("Command : ") + S.join( " " ) ); 85 emit processEvent( tr("Command : ") + S.join( " " ) );
86 86
87 connect( P, 87 connect( P,
@@ -97,31 +97,31 @@ int System::runAsRoot( QStringList & S, MyProcess * Prc ) {
97 connect( P, 97 connect( P,
98 SIGNAL(processExited(MyProcess*) ), 98 SIGNAL(processExited(MyProcess*) ),
99 this, SLOT 99 this, SLOT
100 (SLOT_ProcessExited(MyProcess*) ) ); 100 (SLOT_ProcessExited(MyProcess*) ) );
101 } 101 }
102 102
103 P->process() << S; 103 P->process() << S;
104 104
105 Log(("Executing %s\n", S.join( " " ).latin1() )); 105 Log(("Executing %s\n", S.join( " " ).latin1() ));
106 106
107 if( ! P->process().start( OProcess::DontCare, 107 if( ! P->process().start( OProcess::DontCare,
108 OProcess::AllOutput ) ) { 108 OProcess::AllOutput ) ) {
109 owarn << "Error starting " << S << oendl; 109 odebug << "Error starting " << S << oendl;
110 if( ! Prc ) 110 if( ! Prc )
111 delete P; 111 delete P;
112 // error starting app 112 // error starting app
113 return 0; 113 return 0;
114 } 114 }
115 owarn << "Started " << S << oendl; 115 odebug << "Started " << S << oendl;
116 } 116 }
117 117
118 // all is fine 118 // all is fine
119 return 1; 119 return 1;
120} 120}
121 121
122int System::execAsUser( QStringList & SL ) { 122int System::execAsUser( QStringList & SL ) {
123 MyProcess * P = new MyProcess(); 123 MyProcess * P = new MyProcess();
124 CurrentQPEUser CU = NSResources->currentUser(); 124 CurrentQPEUser CU = NSResources->currentUser();
125 char * usr = getenv("USER"); 125 char * usr = getenv("USER");
126 126
127 if( strcmp( usr, "root" ) == 0 ) { 127 if( strcmp( usr, "root" ) == 0 ) {
@@ -261,37 +261,37 @@ void System::probeInterfaces( void ) {
261 struct ifreq ifrs; 261 struct ifreq ifrs;
262 InterfaceInfo * IFI; 262 InterfaceInfo * IFI;
263 263
264 // flag all as 'down' 264 // flag all as 'down'
265 for( QDictIterator<InterfaceInfo> it( ProbedInterfaces ); 265 for( QDictIterator<InterfaceInfo> it( ProbedInterfaces );
266 it.current(); 266 it.current();
267 ++it ) { 267 ++it ) {
268 it.current()->IsUp = 0; 268 it.current()->IsUp = 0;
269 } 269 }
270 270
271 sockfd = socket(PF_INET, SOCK_DGRAM, 0); 271 sockfd = socket(PF_INET, SOCK_DGRAM, 0);
272 if(sockfd == -1) { 272 if(sockfd == -1) {
273 owarn << "Cannot open INET socket " 273 odebug << "Cannot open INET socket "
274 << errno 274 << errno
275 << " " 275 << " "
276 << strerror( errno ) 276 << strerror( errno )
277 << oendl; 277 << oendl;
278 return; 278 return;
279 } 279 }
280 280
281 // read interfaces from /proc/dev/net 281 // read interfaces from /proc/dev/net
282 // SIOCGIFCONF does not return ALL interfaces ???!? 282 // SIOCGIFCONF does not return ALL interfaces ???!?
283 ProcDevNet = new QFile(PROCNETDEV); 283 ProcDevNet = new QFile(PROCNETDEV);
284 if( ! ProcDevNet->open(IO_ReadOnly) ) { 284 if( ! ProcDevNet->open(IO_ReadOnly) ) {
285 owarn << "Cannot open " 285 odebug << "Cannot open "
286 << PROCNETDEV 286 << PROCNETDEV
287 << " " 287 << " "
288 << errno 288 << errno
289 << " " 289 << " "
290 << strerror( errno ) 290 << strerror( errno )
291 << oendl; 291 << oendl;
292 delete ProcDevNet; 292 delete ProcDevNet;
293 ProcDevNet =0; 293 ProcDevNet =0;
294 ::close( sockfd ); 294 ::close( sockfd );
295 return; 295 return;
296 } 296 }
297 297
@@ -500,25 +500,25 @@ void LogClose( void ) {
500 fprintf( logf, "____ CLOSE LOGFILE ____\n"); 500 fprintf( logf, "____ CLOSE LOGFILE ____\n");
501 if( logf != stderr ) { 501 if( logf != stderr ) {
502 fclose( logf ); 502 fclose( logf );
503 } 503 }
504 logf = 0; 504 logf = 0;
505 } 505 }
506} 506}
507 507
508QString removeSpaces( const QString & X ) { 508QString removeSpaces( const QString & X ) {
509 QString Y; 509 QString Y;
510 Y = X.simplifyWhiteSpace(); 510 Y = X.simplifyWhiteSpace();
511 Y.replace( QRegExp(" "), "_" ); 511 Y.replace( QRegExp(" "), "_" );
512 owarn << X << " **" << Y << "**" << oendl; 512 odebug << X << " **" << Y << "**" << oendl;
513 return Y; 513 return Y;
514} 514}
515 515
516// 516//
517// 517//
518// 518//
519// 519//
520// 520//
521 521
522MyProcess::MyProcess() : QObject(), StdoutBuffer(), StderrBuffer() { 522MyProcess::MyProcess() : QObject(), StdoutBuffer(), StderrBuffer() {
523 P = new OProcess(); 523 P = new OProcess();
524 connect( P, 524 connect( P,
@@ -539,46 +539,46 @@ MyProcess::MyProcess() : QObject(), StdoutBuffer(), StderrBuffer() {
539MyProcess::~MyProcess() { 539MyProcess::~MyProcess() {
540 delete P; 540 delete P;
541} 541}
542 542
543void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) { 543void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) {
544 char * LB = (char *)alloca( len + 1 ); 544 char * LB = (char *)alloca( len + 1 );
545 memcpy( LB, Buf, len ); 545 memcpy( LB, Buf, len );
546 LB[len] = '\0'; 546 LB[len] = '\0';
547 547
548 // now input is zero terminated 548 // now input is zero terminated
549 StdoutBuffer += LB; 549 StdoutBuffer += LB;
550 550
551 owarn << "Received " << len << " bytes on stdout" << oendl; 551 odebug << "Received " << len << " bytes on stdout" << oendl;
552 // see if we have some lines (allow empty lines) 552 // see if we have some lines (allow empty lines)
553 QStringList SL = QStringList::split( "\n", StdoutBuffer, TRUE ); 553 QStringList SL = QStringList::split( "\n", StdoutBuffer, TRUE );
554 554
555 for( unsigned int i = 0; i < SL.count()-1; i ++ ) { 555 for( unsigned int i = 0; i < SL.count()-1; i ++ ) {
556 Log(( "Stdout : \"%s\"\n", SL[i].latin1() ) ); 556 Log(( "Stdout : \"%s\"\n", SL[i].latin1() ) );
557 emit stdoutLine( SL[i] ); 557 emit stdoutLine( SL[i] );
558 } 558 }
559 559
560 // last line is rest 560 // last line is rest
561 StdoutBuffer = SL[ SL.count()-1 ]; 561 StdoutBuffer = SL[ SL.count()-1 ];
562} 562}
563 563
564void MyProcess::SLOT_Stderr( Opie::Core::OProcess * , char * Buf, int len ) { 564void MyProcess::SLOT_Stderr( Opie::Core::OProcess * , char * Buf, int len ) {
565 char * LB = (char *)alloca( len + 1 ); 565 char * LB = (char *)alloca( len + 1 );
566 memcpy( LB, Buf, len ); 566 memcpy( LB, Buf, len );
567 LB[len] = '\0'; 567 LB[len] = '\0';
568 568
569 // now input is zero terminated 569 // now input is zero terminated
570 StderrBuffer += LB; 570 StderrBuffer += LB;
571 571
572 owarn << "Received " << len << " bytes on stderr" << oendl; 572 odebug << "Received " << len << " bytes on stderr" << oendl;
573 // see if we have some lines (allow empty lines) 573 // see if we have some lines (allow empty lines)
574 QStringList SL = QStringList::split( "\n", StderrBuffer, TRUE ); 574 QStringList SL = QStringList::split( "\n", StderrBuffer, TRUE );
575 575
576 for( unsigned int i = 0; i < SL.count()-1; i ++ ) { 576 for( unsigned int i = 0; i < SL.count()-1; i ++ ) {
577 Log(( "Stderr : \"%s\"\n", SL[i].latin1() ) ); 577 Log(( "Stderr : \"%s\"\n", SL[i].latin1() ) );
578 emit stderrLine( SL[i] ); 578 emit stderrLine( SL[i] );
579 } 579 }
580 580
581 // last line is rest 581 // last line is rest
582 StderrBuffer = SL[ SL.count()-1 ]; 582 StderrBuffer = SL[ SL.count()-1 ];
583} 583}
584 584
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
index 8deef94..1b1988e 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
@@ -90,34 +90,34 @@ bool SystemFile::open( void ) {
90 if( F ) { 90 if( F ) {
91 F->close(); 91 F->close();
92 delete F; 92 delete F;
93 } 93 }
94 94
95 F = new QFile( Prefix + Path + ((InAppend)?"":"bup") ); 95 F = new QFile( Prefix + Path + ((InAppend)?"":"bup") );
96 Log(( "Open systemfile %s\n", F->name().latin1() )); 96 Log(( "Open systemfile %s\n", F->name().latin1() ));
97 if( ! F->open( ((InAppend)?IO_Append : 0 ) | IO_WriteOnly ) ) { 97 if( ! F->open( ((InAppend)?IO_Append : 0 ) | IO_WriteOnly ) ) {
98 return 0; 98 return 0;
99 } 99 }
100 } else { 100 } else {
101 if( ! F ) { 101 if( ! F ) {
102 owarn << "!!!!!!!!!!!!!!!!!! " << oendl; 102 odebug << "!!!!!!!!!!!!!!!!!! " << oendl;
103 owarn << "!!!! TESTMODE !!!!" << oendl; 103 odebug << "!!!! TESTMODE !!!!" << oendl;
104 owarn << "!!!!!!!!!!!!!!!!!! " << oendl; 104 odebug << "!!!!!!!!!!!!!!!!!! " << oendl;
105 owarn << "!!!!" << oendl; 105 odebug << "!!!!" << oendl;
106 owarn << "!!!! GENERATE " << Path << oendl; 106 odebug << "!!!! GENERATE " << Path << oendl;
107 if( InAppend ) { 107 if( InAppend ) {
108 owarn << "!!!! In APPEND mode" << oendl; 108 odebug << "!!!! In APPEND mode" << oendl;
109 } 109 }
110 owarn << "!!!!" << oendl; 110 odebug << "!!!!" << oendl;
111 owarn << "!!!!!!!!!!!!!!!!!!" << oendl; 111 odebug << "!!!!!!!!!!!!!!!!!!" << oendl;
112 112
113 F = new QFile(); 113 F = new QFile();
114 F->open( IO_WriteOnly, stderr ); 114 F->open( IO_WriteOnly, stderr );
115 } 115 }
116 } 116 }
117 setDevice( F ); 117 setDevice( F );
118 return 1; 118 return 1;
119} 119}
120 120
121bool SystemFile::close( void ) { 121bool SystemFile::close( void ) {
122 if( ! F || ! F->isOpen() ) { 122 if( ! F || ! F->isOpen() ) {
123 return 1 ; 123 return 1 ;
@@ -127,25 +127,25 @@ bool SystemFile::close( void ) {
127 127
128 if( Prefix == "stderr" ) { 128 if( Prefix == "stderr" ) {
129 return 1; 129 return 1;
130 } 130 }
131 131
132 QString OldP = Prefix + Path + "bup"; 132 QString OldP = Prefix + Path + "bup";
133 133
134 F->close(); 134 F->close();
135 delete F; 135 delete F;
136 F = 0; 136 F = 0;
137 137
138 if( ! InAppend ) { 138 if( ! InAppend ) {
139 owarn << "Rename " << OldP << " to " << Path << oendl; 139 odebug << "Rename " << OldP << " to " << Path << oendl;
140 return ( rename( OldP.latin1(), Path.latin1() ) >= 0 ); 140 return ( rename( OldP.latin1(), Path.latin1() ) >= 0 );
141 } 141 }
142 return 1; 142 return 1;
143} 143}
144 144
145bool SystemFile::preSection( void ) { 145bool SystemFile::preSection( void ) {
146 if( hasPreSection ) { 146 if( hasPreSection ) {
147 QFile Fl( TemplDir + Name + "/presection" ); 147 QFile Fl( TemplDir + Name + "/presection" );
148 if( ! Fl.open( IO_ReadOnly ) ) 148 if( ! Fl.open( IO_ReadOnly ) )
149 return 0; // error 149 return 0; // error
150 // copy file to this file 150 // copy file to this file
151 F->writeBlock( Fl.readAll() ); 151 F->writeBlock( Fl.readAll() );
diff --git a/noncore/settings/networksettings2/opie-networksettings2.postinst b/noncore/settings/networksettings2/opie-networksettings2.postinst
index ce43274..d1d98ac 100755
--- a/noncore/settings/networksettings2/opie-networksettings2.postinst
+++ b/noncore/settings/networksettings2/opie-networksettings2.postinst
@@ -1,9 +1,9 @@
1#!/bin/sh 1#!/bin/sh
2 2
3QTPB=/opt/QtPalmtop/bin 3QTPB=/opt/QtPalmtop/bin
4 4
5[ ! -L ${QTPB}/networksettings2-request ] && ln -sf ${QTPB}/networksettings2 ${QTPB}/networksettings2-request 5[ ! -L ${QTPB}/networksettings2-request ] && ln -sf ${QTPB}/networksettings2 ${QTPB}/networksettings2-request
6 6
7qcop QPE/TaskBar "reloadApps()" 7${QTPB}/qcop QPE/TaskBar "reloadApps()"
8 8
9exit 0 9exit 0
diff --git a/noncore/settings/networksettings2/opietooth2/OTDevice.cpp b/noncore/settings/networksettings2/opietooth2/OTDevice.cpp
index 62f17a0..c6f7d5e 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDevice.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTDevice.cpp
@@ -94,25 +94,25 @@ bool OTDevice::attach(){
94 return TRUE; 94 return TRUE;
95} 95}
96 96
97bool OTDevice::detach(){ 97bool OTDevice::detach(){
98 98
99 if( needsAttach() && m_hciattachPid ) { 99 if( needsAttach() && m_hciattachPid ) {
100 if( m_hciattach ) { 100 if( m_hciattach ) {
101 delete m_hciattach; 101 delete m_hciattach;
102 m_hciattach = 0; 102 m_hciattach = 0;
103 } 103 }
104 104
105 if( kill( m_hciattachPid, 9) < 0 ) { 105 if( kill( m_hciattachPid, 9) < 0 ) {
106 owarn << "could not stop " << errno << oendl; 106 odebug << "could not stop " << errno << oendl;
107 emit error( tr( "Could not stop process" ) ); 107 emit error( tr( "Could not stop process" ) );
108 return FALSE; 108 return FALSE;
109 } 109 }
110 m_hciattachPid = 0; 110 m_hciattachPid = 0;
111 emit isEnabled( m_deviceNr, 0 ); 111 emit isEnabled( m_deviceNr, 0 );
112 m_deviceNr = -1; 112 m_deviceNr = -1;
113 } 113 }
114 114
115 return TRUE; 115 return TRUE;
116} 116}
117 117
118bool OTDevice::isAttached()const{ 118bool OTDevice::isAttached()const{
@@ -159,25 +159,25 @@ void OTDevice::slotStdOut(OProcess* proc, char* , int ) {
159 emit isEnabled( m_deviceNr, 1 ); 159 emit isEnabled( m_deviceNr, 1 );
160 } 160 }
161 } 161 }
162} 162}
163 163
164void OTDevice::slotStdErr(OProcess* proc, char* chars, int len) { 164void OTDevice::slotStdErr(OProcess* proc, char* chars, int len) {
165 165
166 if(proc == m_hciattach && len >= 1 ){ 166 if(proc == m_hciattach && len >= 1 ){
167 // collect output 167 // collect output
168 QCString string( chars, len+1 ); // \0 == +1 168 QCString string( chars, len+1 ); // \0 == +1
169 QString m_output; 169 QString m_output;
170 m_output.append( string.data() ); 170 m_output.append( string.data() );
171 owarn << m_output << oendl; 171 odebug << m_output << oendl;
172 } 172 }
173} 173}
174 174
175pid_t OTDevice::getPidOfHCIAttach( void ) { 175pid_t OTDevice::getPidOfHCIAttach( void ) {
176 176
177 if( needsAttach() ) { 177 if( needsAttach() ) {
178 // not yet attached -> perhaps now ? 178 // not yet attached -> perhaps now ?
179 // load /proc dir and check if command name contains hciattach 179 // load /proc dir and check if command name contains hciattach
180 QRegExp R("[0-9]+"); 180 QRegExp R("[0-9]+");
181 QDir ProcDir( "/proc" ); 181 QDir ProcDir( "/proc" );
182 QFileInfo FI; 182 QFileInfo FI;
183 QStringList EL = ProcDir.entryList( QDir::Dirs ); 183 QStringList EL = ProcDir.entryList( QDir::Dirs );
@@ -202,25 +202,25 @@ pid_t OTDevice::getPidOfHCIAttach( void ) {
202 } 202 }
203 } 203 }
204 } 204 }
205 205
206 return 0; 206 return 0;
207} 207}
208 208
209void OTDevice::detectDeviceType( QString & Device, 209void OTDevice::detectDeviceType( QString & Device,
210 QString & Mode, 210 QString & Mode,
211 unsigned long & Speed ) { 211 unsigned long & Speed ) {
212 212
213 // detect device type and determine parms 213 // detect device type and determine parms
214 owarn << "Detecting device" << oendl; 214 odebug << "Detecting device" << oendl;
215 switch ( ODevice::inst()->model() ) { 215 switch ( ODevice::inst()->model() ) {
216 case Model_iPAQ_H39xx: 216 case Model_iPAQ_H39xx:
217 Device = "/dev/tts/1"; 217 Device = "/dev/tts/1";
218 Mode = "bcsp"; 218 Mode = "bcsp";
219 Speed = 921600; 219 Speed = 921600;
220 NeedsAttach = 1; 220 NeedsAttach = 1;
221 break; 221 break;
222 222
223 case Model_iPAQ_H5xxx: 223 case Model_iPAQ_H5xxx:
224 Device = "/dev/tts/1"; 224 Device = "/dev/tts/1";
225 Mode = "any"; 225 Mode = "any";
226 Speed = 921600; 226 Speed = 921600;
diff --git a/noncore/settings/networksettings2/opietooth2/OTDriver.cpp b/noncore/settings/networksettings2/opietooth2/OTDriver.cpp
index 8bd7919..a7ee662 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDriver.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTDriver.cpp
@@ -141,25 +141,25 @@ static MainClassMap_t MainClasses[] = {
141 { 5, MapPeripheralClass }, 141 { 5, MapPeripheralClass },
142 { 6, 0 }, // special case 142 { 6, 0 }, // special case
143 { 63, MapUnclassifiedClass }, 143 { 63, MapUnclassifiedClass },
144 { -1, 0 } 144 { -1, 0 }
145}; 145};
146 146
147OTDriver::OTDriver( OTGateway * _OT, struct hci_dev_info* di) : QObject( _OT ), Address() { 147OTDriver::OTDriver( OTGateway * _OT, struct hci_dev_info* di) : QObject( _OT ), Address() {
148 OT = _OT; 148 OT = _OT;
149 IsUp = 0; 149 IsUp = 0;
150 Socket = 0; 150 Socket = 0;
151 151
152 init(di); 152 init(di);
153 owarn << "Driver " << devname() << oendl; 153 odebug << "Driver " << devname() << oendl;
154 154
155 AutoClose = new QTimer( this ); 155 AutoClose = new QTimer( this );
156 connect( AutoClose, 156 connect( AutoClose,
157 SIGNAL( timeout() ), 157 SIGNAL( timeout() ),
158 this, 158 this,
159 SLOT( SLOT_CloseFd() ) 159 SLOT( SLOT_CloseFd() )
160 ); 160 );
161} 161}
162 162
163OTDriver::~OTDriver() { 163OTDriver::~OTDriver() {
164 closeSocket(); 164 closeSocket();
165 SLOT_CloseFd(); 165 SLOT_CloseFd();
@@ -376,48 +376,48 @@ int OTDriver::reset() {
376} 376}
377 377
378void OTDriver::setUp( bool M ) { 378void OTDriver::setUp( bool M ) {
379 if( M && ! isUp() ) { 379 if( M && ! isUp() ) {
380 bringUp(); 380 bringUp();
381 } else if( ! M && isUp() ) { 381 } else if( ! M && isUp() ) {
382 bringDown(); 382 bringDown();
383 } 383 }
384} 384}
385 385
386void OTDriver::bringUp() { 386void OTDriver::bringUp() {
387 387
388 owarn << "bringUp : " << Dev << oendl; 388 odebug << "bringUp : " << Dev << oendl;
389 389
390 if( ! open() ) { 390 if( ! open() ) {
391 return; 391 return;
392 } 392 }
393 393
394 if (! isUp()) { 394 if (! isUp()) {
395 if( ioctl(fd(), HCIDEVUP, devId()) < 0 ) { 395 if( ioctl(fd(), HCIDEVUP, devId()) < 0 ) {
396 if( errno != EALREADY ) { 396 if( errno != EALREADY ) {
397 emit error( tr( "Cannot bring interface %1 up. %2 : %3" ). 397 emit error( tr( "Cannot bring interface %1 up. %2 : %3" ).
398 arg( devname() ). 398 arg( devname() ).
399 arg( errno ). 399 arg( errno ).
400 arg( strerror(errno) ) ); 400 arg( strerror(errno) ) );
401 } 401 }
402 return; 402 return;
403 } 403 }
404 // have to wait a bit for the 'up' to become active 404 // have to wait a bit for the 'up' to become active
405 QTimer::singleShot( 3000, this, SLOT( reinit() ) ); 405 QTimer::singleShot( 3000, this, SLOT( reinit() ) );
406 } 406 }
407} 407}
408 408
409void OTDriver::bringDown() { 409void OTDriver::bringDown() {
410 410
411 owarn << "bringDown : " << Dev << oendl; 411 odebug << "bringDown : " << Dev << oendl;
412 412
413 if( ! open() ) { 413 if( ! open() ) {
414 return; 414 return;
415 } 415 }
416 416
417 if ( isUp() ) { 417 if ( isUp() ) {
418 if( ioctl(fd(), HCIDEVDOWN, devId()) < 0 ) { 418 if( ioctl(fd(), HCIDEVDOWN, devId()) < 0 ) {
419 if( errno != EALREADY ) { 419 if( errno != EALREADY ) {
420 emit error( tr( "Cannot bring interface %1 down. %2 : %3" ). 420 emit error( tr( "Cannot bring interface %1 down. %2 : %3" ).
421 arg( devname() ). 421 arg( devname() ).
422 arg( errno ). 422 arg( errno ).
423 arg( strerror(errno) ) ); 423 arg( strerror(errno) ) );
@@ -652,33 +652,33 @@ QString OTDriver::strType() {
652} 652}
653 653
654void OTDriver::setFeatures( unsigned char * _f) { 654void OTDriver::setFeatures( unsigned char * _f) {
655 Features = lmp_featurestostr(_f, NULL, 255); 655 Features = lmp_featurestostr(_f, NULL, 255);
656} 656}
657 657
658void OTDriver::setManufacturer(int compid) { 658void OTDriver::setManufacturer(int compid) {
659 Manufacturer = bt_compidtostr(compid); 659 Manufacturer = bt_compidtostr(compid);
660} 660}
661 661
662OTHCISocket * OTDriver::openSocket( void ) { 662OTHCISocket * OTDriver::openSocket( void ) {
663 if( ! Socket ) { 663 if( ! Socket ) {
664 owarn << "Open HCI socket to " << devname() << oendl; 664 odebug << "Open HCI socket to " << devname() << oendl;
665 Socket = new OTHCISocket( this ); 665 Socket = new OTHCISocket( this );
666 } 666 }
667 return Socket; 667 return Socket;
668} 668}
669 669
670void OTDriver::closeSocket( void ) { 670void OTDriver::closeSocket( void ) {
671 if( Socket ) { 671 if( Socket ) {
672 owarn << "Close HCI socket to " << devname() << oendl; 672 odebug << "Close HCI socket to " << devname() << oendl;
673 delete Socket; 673 delete Socket;
674 Socket = 0; 674 Socket = 0;
675 } 675 }
676} 676}
677 677
678QString OTDriver::getPeerName( const OTDeviceAddress & PAddr ) { 678QString OTDriver::getPeerName( const OTDeviceAddress & PAddr ) {
679 QString S; 679 QString S;
680 char name[100 ]; 680 char name[100 ];
681 681
682 if( ! open() ) { 682 if( ! open() ) {
683 return QString("N/A"); 683 return QString("N/A");
684 } 684 }
@@ -704,41 +704,41 @@ long OTDriver::getLinkQuality( const OTDeviceAddress & Addr ) {
704 return 0; 704 return 0;
705 } 705 }
706 706
707 cr = (struct hci_conn_info_req *)malloc( 707 cr = (struct hci_conn_info_req *)malloc(
708 sizeof(*cr) + sizeof(struct hci_conn_info)); 708 sizeof(*cr) + sizeof(struct hci_conn_info));
709 if (!cr) 709 if (!cr)
710 return 0; 710 return 0;
711 711
712 bacpy( &(cr->bdaddr), &(Addr.getBDAddr()) ); 712 bacpy( &(cr->bdaddr), &(Addr.getBDAddr()) );
713 cr->type = ACL_LINK; 713 cr->type = ACL_LINK;
714 714
715 if (ioctl( fd(), HCIGETCONNINFO, (unsigned long) cr) < 0) { 715 if (ioctl( fd(), HCIGETCONNINFO, (unsigned long) cr) < 0) {
716 owarn << "Get connection info failed" << oendl; 716 odebug << "Get connection info failed" << oendl;
717 free(cr); 717 free(cr);
718 return 0; 718 return 0;
719 } 719 }
720 720
721 handle = htobs(cr->conn_info->handle); 721 handle = htobs(cr->conn_info->handle);
722 722
723 free(cr); 723 free(cr);
724 724
725 memset(&rq, 0, sizeof(rq)); 725 memset(&rq, 0, sizeof(rq));
726 rq.ogf = OGF_STATUS_PARAM; 726 rq.ogf = OGF_STATUS_PARAM;
727 rq.ocf = OCF_READ_RSSI; 727 rq.ocf = OCF_READ_RSSI;
728 rq.cparam = &handle; 728 rq.cparam = &handle;
729 rq.clen = 2; 729 rq.clen = 2;
730 rq.rparam = &rp; 730 rq.rparam = &rp;
731 rq.rlen = GET_LINK_QUALITY_RP_SIZE; 731 rq.rlen = GET_LINK_QUALITY_RP_SIZE;
732 732
733 if (hci_send_req( fd(), &rq, 100) < 0) { 733 if (hci_send_req( fd(), &rq, 100) < 0) {
734 owarn << "Get connection info failed" << oendl; 734 odebug << "Get connection info failed" << oendl;
735 return 0; 735 return 0;
736 } 736 }
737 737
738 if( rp.status ) { 738 if( rp.status ) {
739 owarn << QString().sprintf("HCI get_link_quality cmd failed (0x%2.2X)", rp.status) << oendl; 739 odebug << QString().sprintf("HCI get_link_quality cmd failed (0x%2.2X)", rp.status) << oendl;
740 return 0; 740 return 0;
741 } 741 }
742 742
743 return rp.rssi+50; 743 return rp.rssi+50;
744} 744}
diff --git a/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp b/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp
index f703834..e5af742 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp
@@ -44,25 +44,25 @@ void OTDriverList::update() {
44 ::realloc( dl, sizeof( struct hci_dev_list_req ) + 44 ::realloc( dl, sizeof( struct hci_dev_list_req ) +
45 ( cur * sizeof(struct hci_dev_req) ) 45 ( cur * sizeof(struct hci_dev_req) )
46 ); 46 );
47 47
48 if( dl == 0 ) { 48 if( dl == 0 ) {
49 // memory problem 49 // memory problem
50 exit(1); 50 exit(1);
51 } 51 }
52 52
53 dl->dev_num = cur; 53 dl->dev_num = cur;
54 54
55 if( ioctl( OT->getSocket(), HCIGETDEVLIST, (void*)dl) ) { 55 if( ioctl( OT->getSocket(), HCIGETDEVLIST, (void*)dl) ) {
56 owarn << "WARNING : cannot read device list. " 56 odebug << "WARNING : cannot read device list. "
57 << errno 57 << errno
58 << strerror( errno ) << oendl; 58 << strerror( errno ) << oendl;
59 return; 59 return;
60 } 60 }
61 61
62 // if num == cur perhaps we did not get all devices yet 62 // if num == cur perhaps we did not get all devices yet
63 } while( dl->dev_num == cur ); 63 } while( dl->dev_num == cur );
64 64
65 if( dl->dev_num != count() ) { 65 if( dl->dev_num != count() ) {
66 // new or missing devices 66 // new or missing devices
67 clear(); 67 clear();
68 68
@@ -70,17 +70,17 @@ void OTDriverList::update() {
70 resize( dl->dev_num ); 70 resize( dl->dev_num );
71 71
72 for( cur=0; cur < dl->dev_num; cur ++) { 72 for( cur=0; cur < dl->dev_num; cur ++) {
73 memset( &di, 0, sizeof( di ) ); 73 memset( &di, 0, sizeof( di ) );
74 di.dev_id = (dr+cur)->dev_id; 74 di.dev_id = (dr+cur)->dev_id;
75 75
76 // get device info 76 // get device info
77 if( ioctl( OT->getSocket(), HCIGETDEVINFO, (void*)&di) != 0 ) 77 if( ioctl( OT->getSocket(), HCIGETDEVINFO, (void*)&di) != 0 )
78 continue; // uh ? 78 continue; // uh ?
79 insert( cur, new OTDriver( OT, &di ) ); 79 insert( cur, new OTDriver( OT, &di ) );
80 } 80 }
81 81
82 owarn << "Found " << count() << " devices" << oendl; 82 odebug << "Found " << count() << " devices" << oendl;
83 83
84 ::free( dl ); 84 ::free( dl );
85 } 85 }
86} 86}
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
@@ -145,25 +145,25 @@ bool OTGateway::needsEnabling() {
145 145
146bool OTGateway::isEnabled() { 146bool OTGateway::isEnabled() {
147 if( getOTDevice()->deviceNr() >= 0 && 147 if( getOTDevice()->deviceNr() >= 0 &&
148 driver( getOTDevice()->deviceNr() )->isUp() ) 148 driver( getOTDevice()->deviceNr() )->isUp() )
149 return TRUE; 149 return TRUE;
150 150
151 // else check system 151 // else check system
152 return getOTDevice()->isAttached(); 152 return getOTDevice()->isAttached();
153} 153}
154 154
155void OTGateway::SLOT_ShowError( const QString & S ) { 155void OTGateway::SLOT_ShowError( const QString & S ) {
156 156
157 owarn << S << oendl; 157 odebug << S << oendl;
158 158
159 if( ErrorConnectCount > 0 ) { 159 if( ErrorConnectCount > 0 ) {
160 // pass error 160 // pass error
161 emit error( QString( "<p>" ) + S + "</p>" ); 161 emit error( QString( "<p>" ) + S + "</p>" );
162 return; 162 return;
163 } 163 }
164 164
165 QMessageBox::warning( 0, 165 QMessageBox::warning( 0,
166 tr("OTGateway error"), 166 tr("OTGateway error"),
167 S ); 167 S );
168} 168}
169 169
@@ -201,42 +201,42 @@ void OTGateway::timerEvent( QTimerEvent * ) {
201 } 201 }
202 } else { 202 } else {
203 // if one driver is unable to provide info 203 // if one driver is unable to provide info
204 // we refresh all devices 204 // we refresh all devices
205 updateDrivers(); 205 updateDrivers();
206 return; 206 return;
207 } 207 }
208 } 208 }
209 } 209 }
210} 210}
211 211
212void OTGateway::SLOT_Enabled( int id, bool Up ) { 212void OTGateway::SLOT_Enabled( int id, bool Up ) {
213 owarn << "device " << id << " state " << Up << oendl; 213 odebug << "device " << id << " state " << Up << oendl;
214 if( Up ) { 214 if( Up ) {
215 // device is up -> detect it 215 // device is up -> detect it
216 updateDrivers(); 216 updateDrivers();
217 if( (unsigned)id >= AllDrivers.count() ) { 217 if( (unsigned)id >= AllDrivers.count() ) {
218 // to make sure that the driver really IS detected 218 // to make sure that the driver really IS detected
219 AllDrivers[id]->bringUp(); 219 AllDrivers[id]->bringUp();
220 } 220 }
221 } // if DOWN device already down 221 } // if DOWN device already down
222 emit deviceEnabled( Up ); 222 emit deviceEnabled( Up );
223} 223}
224 224
225void OTGateway::updateDrivers( void ) { 225void OTGateway::updateDrivers( void ) {
226 OTDriver * D; 226 OTDriver * D;
227 227
228 AllDrivers.update(); 228 AllDrivers.update();
229 229
230 owarn << "updated drivers. now " << AllDrivers.count() << oendl; 230 odebug << "updated drivers. now " << AllDrivers.count() << oendl;
231 231
232 // connect signals for each driver 232 // connect signals for each driver
233 for( unsigned int i = 0; 233 for( unsigned int i = 0;
234 i < AllDrivers.count(); 234 i < AllDrivers.count();
235 i ++ ) { 235 i ++ ) {
236 D = AllDrivers[i]; 236 D = AllDrivers[i];
237 237
238 connect( D, 238 connect( D,
239 SIGNAL( error( const QString & ) ), 239 SIGNAL( error( const QString & ) ),
240 this, 240 this,
241 SLOT( SLOT_ShowError( const QString & ) ) 241 SLOT( SLOT_ShowError( const QString & ) )
242 ); 242 );
@@ -256,25 +256,25 @@ void OTGateway::updateDrivers( void ) {
256 256
257 // verify main device too 257 // verify main device too
258 if( TheOTDevice ) 258 if( TheOTDevice )
259 TheOTDevice->checkAttach(); 259 TheOTDevice->checkAttach();
260 260
261 // set to default scanning hardware 261 // set to default scanning hardware
262 setScanWith( 0 ); 262 setScanWith( 0 );
263 263
264 emit driverListChanged(); 264 emit driverListChanged();
265} 265}
266 266
267void OTGateway::SLOT_DriverDisappeared( OTDriver * D ) { 267void OTGateway::SLOT_DriverDisappeared( OTDriver * D ) {
268 owarn << "Driver " << D->devname() << " when offline" << oendl; 268 odebug << "Driver " << D->devname() << " when offline" << oendl;
269 updateDrivers(); 269 updateDrivers();
270} 270}
271 271
272void OTGateway::scanNeighbourhood( OTDriver * D ) { 272void OTGateway::scanNeighbourhood( OTDriver * D ) {
273 273
274 if( Scanning ) { 274 if( Scanning ) {
275 stopScanOfNeighbourhood(); 275 stopScanOfNeighbourhood();
276 } 276 }
277 277
278 if( D ) { 278 if( D ) {
279 setScanWith( D ); 279 setScanWith( D );
280 } 280 }
@@ -309,25 +309,25 @@ OTDriver* OTGateway::findDriver( const OTDeviceAddress & Addr ) {
309 for( unsigned int i = 0 ; i < AllDrivers.count(); i ++ ) { 309 for( unsigned int i = 0 ; i < AllDrivers.count(); i ++ ) {
310 if( AllDrivers[i]->address() == Addr ) { 310 if( AllDrivers[i]->address() == Addr ) {
311 return AllDrivers[i]; 311 return AllDrivers[i];
312 } 312 }
313 } 313 }
314 return 0; 314 return 0;
315} 315}
316 316
317void OTGateway::SLOT_PeerDetected( OTPeer * P, bool IsNew ) { 317void OTGateway::SLOT_PeerDetected( OTPeer * P, bool IsNew ) {
318 318
319 if( IsNew ) { 319 if( IsNew ) {
320 // new peer 320 // new peer
321 owarn << "New peer " << P->name() << oendl; 321 odebug << "New peer " << P->name() << oendl;
322 addPeer( P ); 322 addPeer( P );
323 } 323 }
324 324
325 emit detectedPeer( P, IsNew ); 325 emit detectedPeer( P, IsNew );
326} 326}
327 327
328void OTGateway::addPeer( OTPeer * P ) { 328void OTGateway::addPeer( OTPeer * P ) {
329 AllPeers.resize( AllPeers.size()+1); 329 AllPeers.resize( AllPeers.size()+1);
330 AllPeers.insert( AllPeers.size()-1, P ); 330 AllPeers.insert( AllPeers.size()-1, P );
331 AllPeersModified = 1; 331 AllPeersModified = 1;
332} 332}
333 333
@@ -375,32 +375,32 @@ const char * OTGateway::deviceTypeToName( int cls ) {
375} 375}
376 376
377PANConnectionVector OTGateway::getPANConnections( void ) { 377PANConnectionVector OTGateway::getPANConnections( void ) {
378 PANConnectionVector V; 378 PANConnectionVector V;
379 379
380 struct bnep_connlist_req req; 380 struct bnep_connlist_req req;
381 struct bnep_conninfo ci[48]; 381 struct bnep_conninfo ci[48];
382 382
383 V.setAutoDelete(TRUE); 383 V.setAutoDelete(TRUE);
384 384
385 int ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP); 385 int ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP);
386 if (ctl < 0) { 386 if (ctl < 0) {
387 owarn << "Failed to open control socket" << oendl; 387 odebug << "Failed to open control socket" << oendl;
388 return V; 388 return V;
389 } 389 }
390 390
391 req.cnum = 48; 391 req.cnum = 48;
392 req.ci = ci; 392 req.ci = ci;
393 if (ioctl(ctl, BNEPGETCONNLIST, &req)) { 393 if (ioctl(ctl, BNEPGETCONNLIST, &req)) {
394 owarn << "Failed to get connection list" << oendl; 394 odebug << "Failed to get connection list" << oendl;
395 ::close( ctl ); 395 ::close( ctl );
396 return V; 396 return V;
397 } 397 }
398 398
399 for ( unsigned i=0; i < req.cnum; i++) { 399 for ( unsigned i=0; i < req.cnum; i++) {
400 V.resize( V.size() + 1 ); 400 V.resize( V.size() + 1 );
401 if( ci[i].role == BNEP_SVC_PANU ) { 401 if( ci[i].role == BNEP_SVC_PANU ) {
402 // we are the client 402 // we are the client
403 V.insert( V.size()-1, new OTPANConnection( 403 V.insert( V.size()-1, new OTPANConnection(
404 ci[i].device, 404 ci[i].device,
405 batostr((bdaddr_t *) ci[i].dst) 405 batostr((bdaddr_t *) ci[i].dst)
406 ) ); 406 ) );
diff --git a/noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp b/noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp
index 471c3bf..1997b44 100644
--- a/noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp
@@ -25,37 +25,37 @@ using namespace Opietooth2;
25OTHCISocket::OTHCISocket( OTDriver * D ) : 25OTHCISocket::OTHCISocket( OTDriver * D ) :
26 QObject( D, D->devname() ) { 26 QObject( D, D->devname() ) {
27 BStatusSet = false; 27 BStatusSet = false;
28 Driver = D; 28 Driver = D;
29 HCIReadNotifier = 0; 29 HCIReadNotifier = 0;
30} 30}
31 31
32OTHCISocket::~OTHCISocket() { 32OTHCISocket::~OTHCISocket() {
33 close(); 33 close();
34} 34}
35 35
36void OTHCISocket::close() { 36void OTHCISocket::close() {
37 owarn << "OTHCISocket::close()" << oendl; 37 odebug << "OTHCISocket::close()" << oendl;
38 if( HCIReadNotifier ) { 38 if( HCIReadNotifier ) {
39 delete HCIReadNotifier; 39 delete HCIReadNotifier;
40 } 40 }
41 41
42 if( HCISocket.isValid() ) { 42 if( HCISocket.isValid() ) {
43 HCISocket.close(); 43 HCISocket.close();
44 } 44 }
45} 45}
46 46
47bool OTHCISocket::open() { 47bool OTHCISocket::open() {
48 48
49 owarn << "OTHCISocket::open()" << oendl; 49 odebug << "OTHCISocket::open()" << oendl;
50 int s; 50 int s;
51 51
52 s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); 52 s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
53 53
54 if (s < 0) { 54 if (s < 0) {
55 emit error( tr( "Error creating socket on %1 : %2 %3"). 55 emit error( tr( "Error creating socket on %1 : %2 %3").
56 arg( Driver->devname() ). 56 arg( Driver->devname() ).
57 arg( errno ). 57 arg( errno ).
58 arg( strerror(errno) ) 58 arg( strerror(errno) )
59 ); 59 );
60 return false; 60 return false;
61 } 61 }
@@ -142,25 +142,25 @@ void OTHCISocket::slotSocketActivated() {
142 unsigned char eventCode = buf[1]; 142 unsigned char eventCode = buf[1];
143 unsigned char len = buf[2]; 143 unsigned char len = buf[2];
144 144
145 if (psize-3 == len) { 145 if (psize-3 == len) {
146 146
147 QByteArray databuf; 147 QByteArray databuf;
148 databuf.duplicate((char*)(buf+3), len); 148 databuf.duplicate((char*)(buf+3), len);
149 emit event(eventCode, databuf); 149 emit event(eventCode, databuf);
150 if (eventCode == EVT_CMD_STATUS) { 150 if (eventCode == EVT_CMD_STATUS) {
151 updateStatus( databuf ); 151 updateStatus( databuf );
152 } 152 }
153 } else { 153 } else {
154 owarn << "Error reading hci packet: packetSize(" 154 odebug << "Error reading hci packet: packetSize("
155 << psize 155 << psize
156 << ")-3 != dataSize(" 156 << ")-3 != dataSize("
157 << len 157 << len
158 << ")" 158 << ")"
159 << oendl; 159 << oendl;
160 } 160 }
161 } else if (err == QSocketDevice::NoError) { 161 } else if (err == QSocketDevice::NoError) {
162 slotConnectionClosed(); 162 slotConnectionClosed();
163 } else { 163 } else {
164 HCISocket.close(); 164 HCISocket.close();
165 slotSocketError(err); 165 slotSocketError(err);
166 } 166 }
@@ -174,25 +174,25 @@ void OTHCISocket::updateStatus(const QByteArray& data) {
174 Q_UINT16 opcode; 174 Q_UINT16 opcode;
175 175
176 BStatusSet = true; 176 BStatusSet = true;
177 177
178 stream >> status >> dummy >> opcode; 178 stream >> status >> dummy >> opcode;
179 //kdDebug() << "updatestatus opcode=" << uint32_t(opcode) << endl; 179 //kdDebug() << "updatestatus opcode=" << uint32_t(opcode) << endl;
180 LastStatus = status; 180 LastStatus = status;
181 LastStatusOgf = cmd_opcode_ogf(opcode); 181 LastStatusOgf = cmd_opcode_ogf(opcode);
182 LastStatusOcf = cmd_opcode_ocf(opcode); 182 LastStatusOcf = cmd_opcode_ocf(opcode);
183} 183}
184 184
185void OTHCISocket::slotConnectionClosed() { 185void OTHCISocket::slotConnectionClosed() {
186 owarn << "HCI connection closed." << oendl; 186 odebug << "HCI connection closed." << oendl;
187 emit connectionClosed(); 187 emit connectionClosed();
188} 188}
189 189
190void OTHCISocket::readEvent() { 190void OTHCISocket::readEvent() {
191 191
192 if (HCIReadNotifier) { 192 if (HCIReadNotifier) {
193 slotSocketActivated(); 193 slotSocketActivated();
194 } 194 }
195} 195}
196 196
197bool OTHCISocket::sendCommand( unsigned char ogf, 197bool OTHCISocket::sendCommand( unsigned char ogf,
198 unsigned short ocf, 198 unsigned short ocf,
@@ -221,53 +221,53 @@ bool OTHCISocket::sendCommand( unsigned char ogf,
221 221
222bool OTHCISocket::readStatus( unsigned char ogf, 222bool OTHCISocket::readStatus( unsigned char ogf,
223 unsigned short ocf, 223 unsigned short ocf,
224 int *status, 224 int *status,
225 int timeout_ms) { 225 int timeout_ms) {
226 QTimer timer; 226 QTimer timer;
227 227
228 timer.start(timeout_ms, true); 228 timer.start(timeout_ms, true);
229 BStatusSet = false; 229 BStatusSet = false;
230 230
231 while (timer.isActive() && HCISocket.isValid()) { 231 while (timer.isActive() && HCISocket.isValid()) {
232 232
233 owarn << "OTHCISocket::readStatus()" << oendl; 233 odebug << "OTHCISocket::readStatus()" << oendl;
234 bool timeout = false; 234 bool timeout = false;
235 235
236 if( HCISocket.bytesAvailable() == 0) { 236 if( HCISocket.bytesAvailable() == 0) {
237 int rv = HCISocket.waitForMore(timeout_ms); 237 int rv = HCISocket.waitForMore(timeout_ms);
238 timeout = (rv == 0); 238 timeout = (rv == 0);
239 } 239 }
240 240
241 if (!timeout) { 241 if (!timeout) {
242 slotSocketActivated(); 242 slotSocketActivated();
243 } 243 }
244 244
245 if( BStatusSet == true && 245 if( BStatusSet == true &&
246 ogf == LastStatusOgf && 246 ogf == LastStatusOgf &&
247 ocf == LastStatusOcf) { 247 ocf == LastStatusOcf) {
248 *status = LastStatus; 248 *status = LastStatus;
249 owarn << "OTHCISocket::readStatus(ogf=" 249 odebug << "OTHCISocket::readStatus(ogf="
250 << ogf 250 << ogf
251 << ",ocf=" 251 << ",ocf="
252 << ocf 252 << ocf
253 << ",timeout=" 253 << ",timeout="
254 << LastStatus 254 << LastStatus
255 << ")" 255 << ")"
256 << oendl; 256 << oendl;
257 return true; 257 return true;
258 } 258 }
259 } 259 }
260 260
261 owarn << "OTHCISocket::readStatus(ogf=" 261 odebug << "OTHCISocket::readStatus(ogf="
262 << ogf 262 << ogf
263 << ",ocf=" 263 << ",ocf="
264 << ocf 264 << ocf
265 << ",timeout=" 265 << ",timeout="
266 << LastStatus 266 << LastStatus
267 << ") : timeout " 267 << ") : timeout "
268 << oendl; 268 << oendl;
269 return false; 269 return false;
270} 270}
271 271
272int OTHCISocket::socket() { 272int OTHCISocket::socket() {
273 return HCISocket.socket(); 273 return HCISocket.socket();
diff --git a/noncore/settings/networksettings2/opietooth2/OTInquiry.cpp b/noncore/settings/networksettings2/opietooth2/OTInquiry.cpp
index 8e94bbc..2bc63c7 100644
--- a/noncore/settings/networksettings2/opietooth2/OTInquiry.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTInquiry.cpp
@@ -50,60 +50,60 @@ OTInquiry::OTInquiry( OTDriver * Drv ) : QObject( Drv ) {
50 connect( Socket, 50 connect( Socket,
51 SIGNAL( event(unsigned char, QByteArray)), 51 SIGNAL( event(unsigned char, QByteArray)),
52 this, 52 this,
53 SLOT(slotHCIEvent(unsigned char, QByteArray))); 53 SLOT(slotHCIEvent(unsigned char, QByteArray)));
54} 54}
55 55
56OTInquiry::~OTInquiry() { 56OTInquiry::~OTInquiry() {
57 stopInquiring(); 57 stopInquiring();
58} 58}
59 59
60void OTInquiry::stopInquiring( void ) { 60void OTInquiry::stopInquiring( void ) {
61 if( Socket ) { 61 if( Socket ) {
62 owarn << "Stop inquiry" << oendl; 62 odebug << "Stop inquiry" << oendl;
63 Driver->closeSocket(); 63 Driver->closeSocket();
64 Socket = 0; 64 Socket = 0;
65 } 65 }
66} 66}
67 67
68bool OTInquiry::inquire( double timeout, int numResponses, int lap) { 68bool OTInquiry::inquire( double timeout, int numResponses, int lap) {
69 69
70 QByteArray cmdBuf(5); 70 QByteArray cmdBuf(5);
71 71
72 cmdBuf[0] = lap & 0xFF; 72 cmdBuf[0] = lap & 0xFF;
73 cmdBuf[1] = (lap >> 8) & 0xFF; 73 cmdBuf[1] = (lap >> 8) & 0xFF;
74 cmdBuf[2] = (lap >> 16) & 0xFF; 74 cmdBuf[2] = (lap >> 16) & 0xFF;
75 cmdBuf[3] = max(0x01, min(0x30, int(timeout/1.28))); 75 cmdBuf[3] = max(0x01, min(0x30, int(timeout/1.28)));
76 cmdBuf[4] = (unsigned char)numResponses; 76 cmdBuf[4] = (unsigned char)numResponses;
77 77
78 owarn << "Send HCI inquiry command. wait for " << cmdBuf[3] << oendl; 78 odebug << "Send HCI inquiry command. wait for " << cmdBuf[3] << oendl;
79 79
80 Socket->sendCommand(0x01, 0x0001, cmdBuf); 80 Socket->sendCommand(0x01, 0x0001, cmdBuf);
81 81
82 int status; 82 int status;
83 83
84 if( Socket->readStatus(0x01, 0x0001, &status)) { 84 if( Socket->readStatus(0x01, 0x0001, &status)) {
85 if (status == 0) { 85 if (status == 0) {
86 SuccessfullyStarted = true; 86 SuccessfullyStarted = true;
87 InquiryTimeoutTimer->start( int(1000*(timeout+1.0)), true); 87 InquiryTimeoutTimer->start( int(1000*(timeout+1.0)), true);
88 return true; 88 return true;
89 } 89 }
90 else { 90 else {
91 QString S =QString().sprintf( "%x", status ); 91 QString S =QString().sprintf( "%x", status );
92 owarn << "OTInquiry::inquiry() failed: 0x" << S << oendl; 92 odebug << "OTInquiry::inquiry() failed: 0x" << S << oendl;
93 emit finished(); 93 emit finished();
94 return false; 94 return false;
95 } 95 }
96 } else { 96 } else {
97 owarn << "OTInquiry::inquiry(): Timeout." << oendl; 97 odebug << "OTInquiry::inquiry(): Timeout." << oendl;
98 return false; 98 return false;
99 } 99 }
100} 100}
101 101
102bool OTInquiry::isInquiring() { 102bool OTInquiry::isInquiring() {
103 return InquiryTimeoutTimer->isActive(); 103 return InquiryTimeoutTimer->isActive();
104} 104}
105 105
106bool OTInquiry::isFinished() { 106bool OTInquiry::isFinished() {
107 return SuccessfullyStarted && SuccessfullyEnded; 107 return SuccessfullyStarted && SuccessfullyEnded;
108} 108}
109 109
@@ -117,62 +117,62 @@ void OTInquiry::reset() {
117 117
118 118
119void OTInquiry::onPeerFound( OTPeer * Peer, bool IsNew ) { 119void OTInquiry::onPeerFound( OTPeer * Peer, bool IsNew ) {
120 emit peerFound( Peer, IsNew ); 120 emit peerFound( Peer, IsNew );
121} 121}
122 122
123void OTInquiry::slotInquiryTimeout() { 123void OTInquiry::slotInquiryTimeout() {
124 emit error( tr( "Timeout while waiting for end of inquiry.") ); 124 emit error( tr( "Timeout while waiting for end of inquiry.") );
125} 125}
126 126
127void OTInquiry::slotHCIEvent(unsigned char eventCode, QByteArray buf) { 127void OTInquiry::slotHCIEvent(unsigned char eventCode, QByteArray buf) {
128 128
129 owarn << "OTInquiry: hci packet received: eventCode=" 129 odebug << "OTInquiry: hci packet received: eventCode="
130 << (unsigned int)eventCode 130 << (unsigned int)eventCode
131 << " packetLength=" 131 << " packetLength="
132 << (unsigned int)buf.size() 132 << (unsigned int)buf.size()
133 << oendl; 133 << oendl;
134 134
135 unsigned char *data = (unsigned char*)buf.data(); 135 unsigned char *data = (unsigned char*)buf.data();
136 switch (eventCode) { 136 switch (eventCode) {
137 case EVT_INQUIRY_COMPLETE: 137 case EVT_INQUIRY_COMPLETE:
138 { unsigned char status = data[0]; 138 { unsigned char status = data[0];
139 owarn << "EVT_INQUIRY_COMPLETE status=" << status << oendl; 139 odebug << "EVT_INQUIRY_COMPLETE status=" << status << oendl;
140 InquiryTimeoutTimer->stop(); 140 InquiryTimeoutTimer->stop();
141 if (status == 0) { 141 if (status == 0) {
142 if( SuccessfullyStarted == true) { 142 if( SuccessfullyStarted == true) {
143 owarn << "OTInquiry ended successfully" << oendl; 143 odebug << "OTInquiry ended successfully" << oendl;
144 SuccessfullyEnded = true; 144 SuccessfullyEnded = true;
145 } 145 }
146 emit finished(); 146 emit finished();
147 } 147 }
148 else { 148 else {
149 emit error( tr( "OTInquiry completed with error (code %1)" ). 149 emit error( tr( "OTInquiry completed with error (code %1)" ).
150 arg(status)); 150 arg(status));
151 } 151 }
152 } 152 }
153 break; 153 break;
154 case EVT_INQUIRY_RESULT: 154 case EVT_INQUIRY_RESULT:
155 { int numResults = data[0]; 155 { int numResults = data[0];
156 OTPeer * P = 0; 156 OTPeer * P = 0;
157 bool IsNew; 157 bool IsNew;
158 OTDeviceAddress Addr; 158 OTDeviceAddress Addr;
159 QString N; 159 QString N;
160 160
161 inquiry_info *results = (inquiry_info*)(data+1); 161 inquiry_info *results = (inquiry_info*)(data+1);
162 162
163 for (int n=0; n<numResults; n++) { 163 for (int n=0; n<numResults; n++) {
164 Addr.setBDAddr( results[n].bdaddr ); 164 Addr.setBDAddr( results[n].bdaddr );
165 165
166 owarn << "INQUIRY_RESULT: " 166 odebug << "INQUIRY_RESULT: "
167 << Addr.toString() 167 << Addr.toString()
168 << oendl; 168 << oendl;
169 169
170 P = Driver->gateway()->findPeer( Addr ); 170 P = Driver->gateway()->findPeer( Addr );
171 171
172 if( P ) { 172 if( P ) {
173 // peer known 173 // peer known
174 if( P->state() != OTPeer::Peer_Up ) { 174 if( P->state() != OTPeer::Peer_Up ) {
175 P->setState( OTPeer::Peer_Up ); 175 P->setState( OTPeer::Peer_Up );
176 } 176 }
177 IsNew = 0; 177 IsNew = 0;
178 } else { 178 } else {
@@ -194,25 +194,25 @@ void OTInquiry::slotHCIEvent(unsigned char eventCode, QByteArray buf) {
194 194
195 // call the handler. Emits a signal if not overwritten 195 // call the handler. Emits a signal if not overwritten
196 onPeerFound( P, IsNew ); 196 onPeerFound( P, IsNew );
197 197
198 // } 198 // }
199 } 199 }
200 } 200 }
201 break; 201 break;
202 case EVT_CMD_STATUS : 202 case EVT_CMD_STATUS :
203 { int status = data[0]; 203 { int status = data[0];
204 int numHciCmdPkts = data[1]; 204 int numHciCmdPkts = data[1];
205 int cmdOpcode = *((uint16_t*)(data+2)); 205 int cmdOpcode = *((uint16_t*)(data+2));
206 owarn << "EVT_CMD_STATUS status=" 206 odebug << "EVT_CMD_STATUS status="
207 << status 207 << status
208 << " numPkts=" 208 << " numPkts="
209 << numHciCmdPkts 209 << numHciCmdPkts
210 << " cmdOpcode=" 210 << " cmdOpcode="
211 << cmdOpcode 211 << cmdOpcode
212 << oendl; 212 << oendl;
213 if (cmdOpcode == OCF_INQUIRY) { 213 if (cmdOpcode == OCF_INQUIRY) {
214 214
215 } 215 }
216 } 216 }
217 break; 217 break;
218 } 218 }
diff --git a/noncore/settings/networksettings2/opietooth2/OTPeer.cpp b/noncore/settings/networksettings2/opietooth2/OTPeer.cpp
index 0d7e943..2272f04 100644
--- a/noncore/settings/networksettings2/opietooth2/OTPeer.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTPeer.cpp
@@ -42,54 +42,54 @@ OTPeer::OTPeer( QTextStream & TS, OTGateway * _OT ) {
42 load( TS ); 42 load( TS );
43} 43}
44 44
45OTPeer::~OTPeer( ) { 45OTPeer::~OTPeer( ) {
46 46
47} 47}
48 48
49void OTPeer::updateServices( void ) { 49void OTPeer::updateServices( void ) {
50 sdp_session_t *session; 50 sdp_session_t *session;
51 51
52 serviceList.clear(); 52 serviceList.clear();
53 53
54 owarn << "Get services from " << Addr.toString() << oendl; 54 odebug << "Get services from " << Addr.toString() << oendl;
55 55
56 session = sdp_connect( &(OTDeviceAddress::any.getBDAddr()), 56 session = sdp_connect( &(OTDeviceAddress::any.getBDAddr()),
57 &(Addr.getBDAddr()), 57 &(Addr.getBDAddr()),
58 0); 58 0);
59 59
60 if (!session) { 60 if (!session) {
61 owarn << "sdp_connect(" 61 odebug << "sdp_connect("
62 << Addr.toString() 62 << Addr.toString()
63 << ") failed" 63 << ") failed"
64 << oendl; 64 << oendl;
65 return; // error 65 return; // error
66 } 66 }
67 67
68 uint32_t range = 0x0000ffff; 68 uint32_t range = 0x0000ffff;
69 sdp_list_t* attrId = sdp_list_append(0, &range); 69 sdp_list_t* attrId = sdp_list_append(0, &range);
70 70
71 // search all public features 71 // search all public features
72 uuid_t grp; 72 uuid_t grp;
73 sdp_uuid16_create( &grp, PUBLIC_BROWSE_GROUP ); 73 sdp_uuid16_create( &grp, PUBLIC_BROWSE_GROUP );
74 sdp_list_t * search = sdp_list_append(0, &grp ); 74 sdp_list_t * search = sdp_list_append(0, &grp );
75 75
76 // get data from peer 76 // get data from peer
77 sdp_list_t* seq; 77 sdp_list_t* seq;
78 if (sdp_service_search_attr_req( session, 78 if (sdp_service_search_attr_req( session,
79 search, 79 search,
80 SDP_ATTR_REQ_RANGE, 80 SDP_ATTR_REQ_RANGE,
81 attrId, 81 attrId,
82 &seq ) ) { 82 &seq ) ) {
83 owarn << "Service Search failed" << oendl; 83 odebug << "Service Search failed" << oendl;
84 sdp_close(session); 84 sdp_close(session);
85 return; 85 return;
86 } 86 }
87 87
88 sdp_list_free(attrId, 0); 88 sdp_list_free(attrId, 0);
89 sdp_list_free(search, 0); 89 sdp_list_free(search, 0);
90 90
91 // process result 91 // process result
92 sdp_list_t* next = NULL; 92 sdp_list_t* next = NULL;
93 93
94 for (; seq; seq = next) { 94 for (; seq; seq = next) {
95 sdp_record_t *rec = (sdp_record_t *) seq->data; 95 sdp_record_t *rec = (sdp_record_t *) seq->data;
@@ -168,25 +168,25 @@ void OTPeer::load( QTextStream & TS ) {
168#define POLLDELAY 1000 168#define POLLDELAY 1000
169#define PREMAGICNR (MAGICNR+POLLDELAY) 169#define PREMAGICNR (MAGICNR+POLLDELAY)
170 170
171void OTPeer::findOutState( int timeoutInSec, bool Force ) { 171void OTPeer::findOutState( int timeoutInSec, bool Force ) {
172 ProbeFD = -1; 172 ProbeFD = -1;
173 if( Force && ConnectedTo == 0 ) { 173 if( Force && ConnectedTo == 0 ) {
174 State = OTPeer::Peer_Unknown; 174 State = OTPeer::Peer_Unknown;
175 } // else keep state or is connected to us 175 } // else keep state or is connected to us
176 176
177 if( State == OTPeer::Peer_Unknown ) { 177 if( State == OTPeer::Peer_Unknown ) {
178 ProbePhase = 0; 178 ProbePhase = 0;
179 ProbeTimeout = timeoutInSec*1000; 179 ProbeTimeout = timeoutInSec*1000;
180 owarn << "Ping " << address().toString() << oendl; 180 odebug << "Ping " << address().toString() << oendl;
181 startTimer( POLLDELAY ); 181 startTimer( POLLDELAY );
182 } else { 182 } else {
183 ProbeTimeout = 0; 183 ProbeTimeout = 0;
184 startTimer( 0 ); 184 startTimer( 0 );
185 } 185 }
186} 186}
187 187
188#define PINGSIZE 20 188#define PINGSIZE 20
189void OTPeer::timerEvent( QTimerEvent * ev ) { 189void OTPeer::timerEvent( QTimerEvent * ev ) {
190 190
191 ProbeTimeout -= POLLDELAY; 191 ProbeTimeout -= POLLDELAY;
192 192
@@ -226,25 +226,25 @@ void OTPeer::timerEvent( QTimerEvent * ev ) {
226 } 226 }
227 } 227 }
228 ProbePhase = 1; // wait for connect 228 ProbePhase = 1; // wait for connect
229 break; 229 break;
230 case 1 : 230 case 1 :
231 { struct pollfd pf[1]; 231 { struct pollfd pf[1];
232 char buf[L2CAP_CMD_HDR_SIZE + PINGSIZE + 20]; 232 char buf[L2CAP_CMD_HDR_SIZE + PINGSIZE + 20];
233 int n; 233 int n;
234 234
235 pf[0].fd = ProbeFD; 235 pf[0].fd = ProbeFD;
236 pf[0].events = POLLOUT; 236 pf[0].events = POLLOUT;
237 if( (n = ::poll(pf, 1, 0)) < 0 ) { 237 if( (n = ::poll(pf, 1, 0)) < 0 ) {
238 owarn << address().toString() 238 odebug << address().toString()
239 << " : errno " 239 << " : errno "
240 << errno 240 << errno
241 << " " 241 << " "
242 << strerror(errno)<<oendl; 242 << strerror(errno)<<oendl;
243 ProbeTimeout = 0; 243 ProbeTimeout = 0;
244 break; 244 break;
245 } 245 }
246 246
247 if( ! n ) { 247 if( ! n ) {
248 // not ready -> try again 248 // not ready -> try again
249 break; 249 break;
250 } 250 }
@@ -257,89 +257,89 @@ void OTPeer::timerEvent( QTimerEvent * ev ) {
257 257
258 /* Build command header */ 258 /* Build command header */
259 cmd->code = L2CAP_ECHO_REQ; 259 cmd->code = L2CAP_ECHO_REQ;
260 cmd->ident = *(char *)this; // get some byte 260 cmd->ident = *(char *)this; // get some byte
261 cmd->len = PINGSIZE; 261 cmd->len = PINGSIZE;
262 262
263 /* Send Echo Request */ 263 /* Send Echo Request */
264 if( ::send(ProbeFD, buf, PINGSIZE + L2CAP_CMD_HDR_SIZE, 0) <= 0) { 264 if( ::send(ProbeFD, buf, PINGSIZE + L2CAP_CMD_HDR_SIZE, 0) <= 0) {
265 if( errno == EACCES ) { 265 if( errno == EACCES ) {
266 // permission denied means that we could not 266 // permission denied means that we could not
267 // connect because the device does not allow us 267 // connect because the device does not allow us
268 // but it is UP 268 // but it is UP
269 owarn << address().toString() 269 odebug << address().toString()
270 << " good send error " 270 << " good send error "
271 << errno 271 << errno
272 << " " 272 << " "
273 << strerror( errno) 273 << strerror( errno)
274 << oendl; 274 << oendl;
275 State = OTPeer::Peer_Up; 275 State = OTPeer::Peer_Up;
276 ProbeTimeout = 0; 276 ProbeTimeout = 0;
277 break; 277 break;
278 } else if( errno != EBUSY ) { 278 } else if( errno != EBUSY ) {
279 owarn << address().toString() 279 odebug << address().toString()
280 << " : errno " 280 << " : errno "
281 << errno 281 << errno
282 << " " 282 << " "
283 << strerror(errno) 283 << strerror(errno)
284 << oendl; 284 << oendl;
285 ProbeTimeout = 0; 285 ProbeTimeout = 0;
286 break; 286 break;
287 } // else want some more 287 } // else want some more
288 } 288 }
289 289
290 ProbePhase = 2; // wait for ping reply 290 ProbePhase = 2; // wait for ping reply
291 } 291 }
292 break; 292 break;
293 case 2 : // wait for reply 293 case 2 : // wait for reply
294 { struct pollfd pf[1]; 294 { struct pollfd pf[1];
295 char buf[L2CAP_CMD_HDR_SIZE + PINGSIZE + 20]; 295 char buf[L2CAP_CMD_HDR_SIZE + PINGSIZE + 20];
296 l2cap_cmd_hdr *cmd = (l2cap_cmd_hdr *) buf; 296 l2cap_cmd_hdr *cmd = (l2cap_cmd_hdr *) buf;
297 int n; 297 int n;
298 298
299 pf[0].fd = ProbeFD; 299 pf[0].fd = ProbeFD;
300 pf[0].events = POLLIN; 300 pf[0].events = POLLIN;
301 if( (n = ::poll(pf, 1, 0)) < 0 ) { 301 if( (n = ::poll(pf, 1, 0)) < 0 ) {
302 owarn << address().toString() 302 odebug << address().toString()
303 << " : errno " 303 << " : errno "
304 << errno 304 << errno
305 << " " 305 << " "
306 << strerror(errno) 306 << strerror(errno)
307 <<oendl; 307 <<oendl;
308 ProbeTimeout = 0; 308 ProbeTimeout = 0;
309 break; 309 break;
310 } 310 }
311 311
312 if( ! n ) { 312 if( ! n ) {
313 // not ready -> try again 313 // not ready -> try again
314 break; 314 break;
315 } 315 }
316 316
317 if( (n = ::recv( ProbeFD, buf, sizeof(buf), 0)) < 0) { 317 if( (n = ::recv( ProbeFD, buf, sizeof(buf), 0)) < 0) {
318 owarn << address().toString() 318 odebug << address().toString()
319 << "errno " 319 << "errno "
320 << errno 320 << errno
321 << " " 321 << " "
322 << strerror(errno) 322 << strerror(errno)
323 << oendl; 323 << oendl;
324 ProbeTimeout = 0; 324 ProbeTimeout = 0;
325 break; 325 break;
326 } 326 }
327 327
328 /* Check for our id */ 328 /* Check for our id */
329 if( cmd->ident != *(char *)this ) 329 if( cmd->ident != *(char *)this )
330 // not our reply 330 // not our reply
331 break; 331 break;
332 332
333 owarn << "reply from " 333 odebug << "reply from "
334 << address().toString() 334 << address().toString()
335 << oendl; 335 << oendl;
336 // whatever reply we get is a valid reply 336 // whatever reply we get is a valid reply
337 State = OTPeer::Peer_Up; 337 State = OTPeer::Peer_Up;
338 ProbeTimeout = 0; 338 ProbeTimeout = 0;
339 } 339 }
340 break; 340 break;
341 } 341 }
342 342
343 if( State != OTPeer::Peer_Unknown ) { 343 if( State != OTPeer::Peer_Unknown ) {
344 ProbeTimeout = 0; 344 ProbeTimeout = 0;
345 } 345 }
diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp
index b14cc2f..8323549 100644
--- a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp
+++ b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp
@@ -528,25 +528,25 @@ void OTScan::SLOT_Selected( QListViewItem * it ) {
528 // store result 528 // store result
529 SelectedPeer = ((PeerLVI *)it->parent())->peer(); 529 SelectedPeer = ((PeerLVI *)it->parent())->peer();
530 SelectedChannel = ((ChannelLVI *)it)->channel(); 530 SelectedChannel = ((ChannelLVI *)it)->channel();
531 } else { 531 } else {
532 // click on device 532 // click on device
533 if( it->depth() != 0 ) { 533 if( it->depth() != 0 ) {
534 return; 534 return;
535 } 535 }
536 536
537 SelectedPeer = ((PeerLVI *)it)->peer(); 537 SelectedPeer = ((PeerLVI *)it)->peer();
538 SelectedChannel = 0; 538 SelectedChannel = 0;
539 } 539 }
540 owarn << "Selected " << SelectedPeer->address().toString() << 540 odebug << "Selected " << SelectedPeer->address().toString() <<
541 " Channel " << SelectedChannel << oendl; 541 " Channel " << SelectedChannel << oendl;
542 emit selected(); 542 emit selected();
543} 543}
544 544
545void OTScan::SLOT_FinishedDetecting( ) { 545void OTScan::SLOT_FinishedDetecting( ) {
546 scanMode( false ); 546 scanMode( false );
547} 547}
548 548
549void OTScan::SLOT_CleanupOld( ) { 549void OTScan::SLOT_CleanupOld( ) {
550 550
551 // iterate over all peers and find those that 551 // iterate over all peers and find those that
552 // are down and have no pairing info 552 // are down and have no pairing info
@@ -556,66 +556,66 @@ void OTScan::SLOT_CleanupOld( ) {
556 QListViewItem * Lit = DetectedPeers_LV->firstChild(); 556 QListViewItem * Lit = DetectedPeers_LV->firstChild();
557 while( Lit ) { 557 while( Lit ) {
558 TheP = ((PeerLVI *)Lit)->peer(); 558 TheP = ((PeerLVI *)Lit)->peer();
559 if( TheP->state() == OTPeer::Peer_Down ) { 559 if( TheP->state() == OTPeer::Peer_Down ) {
560 unsigned int k; 560 unsigned int k;
561 561
562 // what about linkkeys ? 562 // what about linkkeys ?
563 for( k = 0; k < Keys.count(); k ++ ) { 563 for( k = 0; k < Keys.count(); k ++ ) {
564 if( TheP->address() == Keys[k].to() || 564 if( TheP->address() == Keys[k].to() ||
565 TheP->address() == Keys[k].from() 565 TheP->address() == Keys[k].from()
566 ) { 566 ) {
567 // part of linkkey 567 // part of linkkey
568 owarn << "LINKKEY " << TheP->address().toString() << oendl; 568 odebug << "LINKKEY " << TheP->address().toString() << oendl;
569 break; 569 break;
570 } 570 }
571 } 571 }
572 572
573 if( k == Keys.count() ) { 573 if( k == Keys.count() ) {
574 owarn << "RM LINKKEY " << TheP->address().toString() << oendl; 574 odebug << "RM LINKKEY " << TheP->address().toString() << oendl;
575 // not found -> remember to remove this peer 575 // not found -> remember to remove this peer
576 QListViewItem * Nit; 576 QListViewItem * Nit;
577 OT->removePeer( TheP ); 577 OT->removePeer( TheP );
578 Nit = Lit->nextSibling(); 578 Nit = Lit->nextSibling();
579 delete Lit; 579 delete Lit;
580 Lit = Nit; 580 Lit = Nit;
581 continue; 581 continue;
582 } 582 }
583 } else { 583 } else {
584 owarn << "NODOWN " << TheP->address().toString() << oendl; 584 odebug << "NODOWN " << TheP->address().toString() << oendl;
585 } 585 }
586 586
587 Lit = Lit->nextSibling(); 587 Lit = Lit->nextSibling();
588 } 588 }
589} 589}
590 590
591void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){ 591void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){
592 PeerLVI * it = 0; 592 PeerLVI * it = 0;
593 593
594 if( IsNew ) { 594 if( IsNew ) {
595 it = new PeerLVI( P, DetectedPeers_LV ); 595 it = new PeerLVI( P, DetectedPeers_LV );
596 } else { 596 } else {
597 // find peer in table 597 // find peer in table
598 QListViewItem * Lit = DetectedPeers_LV->firstChild(); 598 QListViewItem * Lit = DetectedPeers_LV->firstChild();
599 while( Lit ) { 599 while( Lit ) {
600 if( ((PeerLVI *)Lit)->peer() == P ) { 600 if( ((PeerLVI *)Lit)->peer() == P ) {
601 // this item 601 // this item
602 it = (PeerLVI *)Lit; 602 it = (PeerLVI *)Lit;
603 break; 603 break;
604 } 604 }
605 Lit = Lit->nextSibling(); 605 Lit = Lit->nextSibling();
606 } 606 }
607 607
608 if( ! it ) { 608 if( ! it ) {
609 owarn << "Should not occur" << oendl; 609 odebug << "Should not occur" << oendl;
610 return; 610 return;
611 } 611 }
612 } 612 }
613 613
614 // update/show info 614 // update/show info
615 it->setText( 0, P->name() ); 615 it->setText( 0, P->name() );
616 it->setPixmap(0, Icons->deviceIcon( 616 it->setPixmap(0, Icons->deviceIcon(
617 OT->deviceTypeToName( P->deviceClass() ) ) ); 617 OT->deviceTypeToName( P->deviceClass() ) ) );
618 618
619 // tell peer to report its state async 619 // tell peer to report its state async
620 connect( P, 620 connect( P,
621 SIGNAL( peerStateReport( OTPeer *)), 621 SIGNAL( peerStateReport( OTPeer *)),
@@ -920,25 +920,25 @@ void OTManage::SLOT_ShowDriver( QListViewItem * It ) {
920 // not toplevel 920 // not toplevel
921 return; 921 return;
922 922
923 DriverLVI * it = (DriverLVI *) It; 923 DriverLVI * it = (DriverLVI *) It;
924 DriverIsUp_CB->setChecked( it->driver()->isUp() ); 924 DriverIsUp_CB->setChecked( it->driver()->isUp() );
925} 925}
926 926
927void OTManage::SLOT_UpDriver( bool Up ) { 927void OTManage::SLOT_UpDriver( bool Up ) {
928 QListViewItem * it = AllDrivers_LV->firstChild(); 928 QListViewItem * it = AllDrivers_LV->firstChild();
929 while( it ) { 929 while( it ) {
930 if( it->isSelected() ) { 930 if( it->isSelected() ) {
931 OTDriver * D = ((DriverLVI *)it)->driver(); 931 OTDriver * D = ((DriverLVI *)it)->driver();
932 owarn << "UP driver " << D->devname() << oendl; 932 odebug << "UP driver " << D->devname() << oendl;
933 // this 933 // this
934 D->setUp( Up ); 934 D->setUp( Up );
935 return; 935 return;
936 } 936 }
937 it = it->nextSibling(); 937 it = it->nextSibling();
938 } 938 }
939} 939}
940 940
941void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) { 941void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) {
942 QListViewItem * it = AllDrivers_LV->firstChild(); 942 QListViewItem * it = AllDrivers_LV->firstChild();
943 while( it ) { 943 while( it ) {
944 if( ((DriverLVI *)it)->driver() == D ) { 944 if( ((DriverLVI *)it)->driver() == D ) {
diff --git a/noncore/settings/networksettings2/opietooth2/config.in b/noncore/settings/networksettings2/opietooth2/config.in
index 720f49a..084e8c0 100644
--- a/noncore/settings/networksettings2/opietooth2/config.in
+++ b/noncore/settings/networksettings2/opietooth2/config.in
@@ -1,5 +1,5 @@
1config NS2OPIETOOTH 1config NS2OPIETOOTH
2 boolean "opie-networksettings2 bluetooth library" 2 boolean "Opietooth2 bluetooth library"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBBLUEZ_DEP && NS2CORE
5 5
diff --git a/noncore/settings/networksettings2/opietooth2/libopietooth2.postinst b/noncore/settings/networksettings2/opietooth2/libopietooth2.postinst
index cd605c2..2713c61 100755
--- a/noncore/settings/networksettings2/opietooth2/libopietooth2.postinst
+++ b/noncore/settings/networksettings2/opietooth2/libopietooth2.postinst
@@ -1,10 +1,10 @@
1#!/bin/sh 1#!/bin/sh
2 2
3QTPB=/opt/QtPalmtop/bin 3QTPB=/opt/QtPalmtop/bin
4 4
5[ ! -L ${QTPB}/networksettings2-opietooth ] && ln -sf ${QTPB}/networksettings2 ${QTPB}/networksettings2-opietooth 5[ ! -L ${QTPB}/networksettings2-opietooth ] && ln -sf ${QTPB}/networksettings2 ${QTPB}/networksettings2-opietooth
6 6
7# qcop QPE/Taskbar "linkChanged(opietooth)" 7# qcop QPE/Taskbar "linkChanged(opietooth)"
8qcop QPE/Taskbar "reloadApps()" 8${QTPB}/qcop QPE/Taskbar "reloadApps()"
9 9
10exit 0 10exit 0
diff --git a/noncore/settings/networksettings2/opietooth2/opietooth2.pro b/noncore/settings/networksettings2/opietooth2/opietooth2.pro
index e0057a9..16277cf 100644
--- a/noncore/settings/networksettings2/opietooth2/opietooth2.pro
+++ b/noncore/settings/networksettings2/opietooth2/opietooth2.pro
@@ -26,12 +26,19 @@ SOURCES = OTDevice.cpp \
26 OTIcons.cpp \ 26 OTIcons.cpp \
27 OTPeer.cpp \ 27 OTPeer.cpp \
28 OTGateway.cpp \ 28 OTGateway.cpp \
29 Opietooth.cpp 29 Opietooth.cpp
30 INCLUDEPATH+= $(OPIEDIR)/include ../networksettings2 30 INCLUDEPATH+= $(OPIEDIR)/include ../networksettings2
31 DEPENDPATH+= $(OPIEDIR)/include 31 DEPENDPATH+= $(OPIEDIR)/include
32LIBS += -lqpe -lopiecore2 -lbluetooth -lnetworksettings2 32LIBS += -lqpe -lopiecore2 -lbluetooth -lnetworksettings2
33 INTERFACES= OTMainGUI.ui OTSniffGUI.ui OTScanGUI.ui OTManageGUI.ui OTPairingGUI.ui 33 INTERFACES= OTMainGUI.ui OTSniffGUI.ui OTScanGUI.ui OTManageGUI.ui OTPairingGUI.ui
34 TARGET = opietooth2 34 TARGET = opietooth2
35 VERSION = 1.0.0 35 VERSION = 1.0.0
36 36
37include ( $(OPIEDIR)/include.pro ) 37include ( $(OPIEDIR)/include.pro )
38
39!isEmpty( LIBBLUEZ_INC_DIR ) {
40 INCLUDEPATH += $$LIBBLUEZ_INC_DIR
41}
42!isEmpty( LIBBLUEZ_LIB_DIR ) {
43 LIBS += -L$$LIBBLUEZ_LIB_DIR
44}
diff --git a/noncore/settings/networksettings2/profile/profilerun.cpp b/noncore/settings/networksettings2/profile/profilerun.cpp
index ab57a00..acb67bd 100644
--- a/noncore/settings/networksettings2/profile/profilerun.cpp
+++ b/noncore/settings/networksettings2/profile/profilerun.cpp
@@ -1,25 +1,25 @@
1#include <resources.h> 1#include <resources.h>
2 2
3#include "profilerun.h" 3#include "profilerun.h"
4 4
5State_t ProfileRun::detectState( void ) { 5State_t ProfileRun::detectState( void ) {
6 if( Data->Disabled ) { 6 if( Data->Disabled ) {
7 return Disabled; 7 return Disabled;
8 } 8 }
9 return Unknown; 9 return Unknown;
10} 10}
11 11
12QString ProfileRun::setMyState( NodeCollection * NC, Action_t A, bool ) { 12QString ProfileRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
13 owarn << "Profile " << Data->Disabled << oendl; 13 odebug << "Profile " << Data->Disabled << oendl;
14 if( A == Disable ) { 14 if( A == Disable ) {
15 if( ! Data->Disabled ) { 15 if( ! Data->Disabled ) {
16 Data->Disabled = 1; 16 Data->Disabled = 1;
17 NC->setModified( 1 ); 17 NC->setModified( 1 );
18 } 18 }
19 } else if( A == Enable ) { 19 } else if( A == Enable ) {
20 if( Data->Disabled ) { 20 if( Data->Disabled ) {
21 Data->Disabled = 0; 21 Data->Disabled = 0;
22 NC->setModified( 1 ); 22 NC->setModified( 1 );
23 } 23 }
24 } 24 }
25 25
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp
index eb439c1..de8c8a2 100644
--- a/noncore/settings/networksettings2/usb/usbrun.cpp
+++ b/noncore/settings/networksettings2/usb/usbrun.cpp
@@ -29,90 +29,91 @@ State_t USBRun::detectState( void ) {
29 It.current(); 29 It.current();
30 ++It ) { 30 ++It ) {
31 Run = It.current(); 31 Run = It.current();
32 if( X == Run->Name ) { 32 if( X == Run->Name ) {
33 NC->assignInterface( Run ); 33 NC->assignInterface( Run );
34 return IsUp; 34 return IsUp;
35 } 35 }
36 } 36 }
37 } 37 }
38 } 38 }
39 39
40 Log(("Assigned %p\n", NC->assignedInterface() )); 40 Log(("Assigned %p\n", NC->assignedInterface() ));
41
41 if( ( Run = NC->assignedInterface() ) ) { 42 if( ( Run = NC->assignedInterface() ) ) {
42 // we already have an interface assigned -> still present ? 43 // we already have an interface assigned -> still present ?
43 if( ! Run->IsUp ) { 44 if( ! Run->IsUp ) {
44 // usb is still free -> keep assignment 45 // usb is still free -> keep assignment
45 return Available; 46 return Available;
46 } // else interface is up but NOT us -> some other profile 47 } // else interface is up but NOT us -> some other profile
47 } 48 }
48 49
49 // nothing (valid) assigned to us 50 // nothing (valid) assigned to us
50 NC->assignInterface( 0 ); 51 NC->assignInterface( 0 );
51 52
52 // find possible interface 53 // find possible interface
53 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 54 if( getInterface() ) {
54 It.current(); 55 // proper type, and Not UP -> free
55 ++It ) { 56 // usb cables are currently always available when requested
56 Run = It.current(); 57 // until we can detect if we are plugged in
57 58 return Available;
58 Log(("%s %d %d=%d %d\n",
59 Run->Name.latin1(),
60 handlesInterface( Run->Name ),
61 Run->CardType, ARPHRD_ETHER,
62 ! Run->IsUp ));
63
64 if( handlesInterface( Run->Name ) &&
65 Run->CardType == ARPHRD_ETHER &&
66 ! Run->IsUp
67 ) {
68 // proper type, and Not UP -> free
69 // usb cables are currently always available when requested
70 // until we can detect if we are plugged in
71 return Available;
72 }
73 } 59 }
74 60
75 return Unavailable; 61 return Unavailable;
76} 62}
77 63
78QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) { 64QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
79 65
80 // nothing needs to be done to 'activate' or 'deactivate' 66 InterfaceInfo * I = getInterface();
81 // a cable 67
68 if( ! I ) {
69 return QString("No usb device available");
70 }
71
72 Log(( "Grabbed USB interface %s\n", I->Name.latin1() ));
73 // grab this interface
74 NC->assignInterface( I );
75
82 return QString(); 76 return QString();
83} 77}
84 78
85// get interface that is free or assigned to us 79// get interface that is free or assigned to us
86InterfaceInfo * USBRun::getInterface( void ) { 80InterfaceInfo * USBRun::getInterface( void ) {
87 81
88 System & S = NSResources->system(); 82 System & S = NSResources->system();
89 InterfaceInfo * best = 0, * Run; 83 InterfaceInfo * best = 0, * Run;
90 QRegExp R( "usb[0-9abcdef]" );
91 84
92 for( QDictIterator<InterfaceInfo> It(S.interfaces()); 85 for( QDictIterator<InterfaceInfo> It(S.interfaces());
93 It.current(); 86 It.current();
94 ++It ) { 87 ++It ) {
95 Run = It.current(); 88 Run = It.current();
89
90 Log(("%s %d %d=%d %d\n",
91 Run->Name.latin1(),
92 handlesInterface( Run->Name ),
93 Run->CardType, ARPHRD_ETHER,
94 ! Run->IsUp ));
95
96 if( handlesInterface( Run->Name ) && 96 if( handlesInterface( Run->Name ) &&
97 Run->CardType == ARPHRD_ETHER 97 Run->CardType == ARPHRD_ETHER
98 ) { 98 ) {
99 // this is a USB card 99 // this is a USB card
100 if( Run->assignedConnection() == netNode()->connection() ) { 100 if( Run->assignedConnection() == netNode()->connection() ) {
101 // assigned to us 101 // assigned to us
102 return Run; 102 return Run;
103 } else if( Run->assignedConnection() == 0 ) { 103 } else if( ! Run->IsUp &&
104 Run->assignedConnection() == 0 ) {
104 // free 105 // free
105 best = Run; 106 best = Run;
106 } 107 } // UP or not assigned to us
107 } 108 }
108 } 109 }
109 return best; // can be 0 110 return best; // can be 0
110} 111}
111 112
112bool USBRun::handlesInterface( const QString & S ) { 113bool USBRun::handlesInterface( const QString & S ) {
113 return Pat.match( S ) >= 0; 114 return Pat.match( S ) >= 0;
114} 115}
115 116
116bool USBRun::handlesInterface( InterfaceInfo * I ) { 117bool USBRun::handlesInterface( InterfaceInfo * I ) {
117 return handlesInterface( I->Name ); 118 return handlesInterface( I->Name );
118} 119}