summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/activateprofile.cpp2
-rw-r--r--noncore/settings/networksettings2/activateprofile.h2
-rw-r--r--noncore/settings/networksettings2/activatevpn.cpp10
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp40
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h4
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp12
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h4
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/cable/cablerun.cpp2
-rw-r--r--noncore/settings/networksettings2/cable/cablerun.h2
-rw-r--r--noncore/settings/networksettings2/editconnection.cpp54
-rw-r--r--noncore/settings/networksettings2/editconnection.h14
-rw-r--r--noncore/settings/networksettings2/editconnectionGUI.ui12
-rw-r--r--noncore/settings/networksettings2/gprs/GPRS_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/gprs/GPRS_NNI.cpp18
-rw-r--r--noncore/settings/networksettings2/gprs/GPRSrun.cpp4
-rw-r--r--noncore/settings/networksettings2/gprs/GPRSrun.h2
-rw-r--r--noncore/settings/networksettings2/irda/irdarun.h2
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.cpp8
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.h2
-rw-r--r--noncore/settings/networksettings2/modem/modemrun.h2
-rw-r--r--noncore/settings/networksettings2/network/network_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.cpp14
-rw-r--r--noncore/settings/networksettings2/network/networkrun.cpp9
-rw-r--r--noncore/settings/networksettings2/network/networkrun.h2
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp54
-rw-r--r--noncore/settings/networksettings2/networksettings2/asconnection.h6
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.cpp59
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h73
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp64
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.h28
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp4
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.h8
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp108
-rw-r--r--noncore/settings/networksettings2/nsdata.h4
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDriver.cpp4
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDriver.h4
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTGateway.cpp20
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTGateway.h12
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTInquiry.h2
-rw-r--r--noncore/settings/networksettings2/ppp/PPPDialingedit.cpp5
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.cpp4
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.cpp16
-rw-r--r--noncore/settings/networksettings2/ppp/ppprun.cpp4
-rw-r--r--noncore/settings/networksettings2/ppp/ppprun.h2
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.cpp8
-rw-r--r--noncore/settings/networksettings2/profile/profiledata.h2
-rw-r--r--noncore/settings/networksettings2/profile/profileedit.cpp8
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.cpp6
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.h2
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp8
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.h2
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.cpp6
-rw-r--r--noncore/settings/networksettings2/vpn/vpnrun.h2
-rw-r--r--noncore/settings/networksettings2/wlan/wlanedit.cpp2
-rw-r--r--noncore/settings/networksettings2/wlan/wlanrun.cpp8
-rw-r--r--noncore/settings/networksettings2/wlan/wlanrun.h2
58 files changed, 393 insertions, 373 deletions
diff --git a/noncore/settings/networksettings2/activateprofile.cpp b/noncore/settings/networksettings2/activateprofile.cpp
index e4064e3..fe98fc4 100644
--- a/noncore/settings/networksettings2/activateprofile.cpp
+++ b/noncore/settings/networksettings2/activateprofile.cpp
@@ -1,31 +1,31 @@
1#include <qlistbox.h> 1#include <qlistbox.h>
2#include <qlabel.h> 2#include <qlabel.h>
3#include "activateprofile.h" 3#include "activateprofile.h"
4 4
5ActivateProfile::ActivateProfile( const char * Interface ) : 5ActivateProfile::ActivateProfile( const char * Interface ) :
6 ActivateProfileGUI( 0, 0, TRUE ), NSD() { 6 ActivateProfileGUI( 0, 0, TRUE ), NSD() {
7 7
8 Possible = NSD.collectPossible( Interface ); 8 Possible = NSD.collectPossible( Interface );
9 9
10 DeviceName_LBL->setText( Interface ); 10 DeviceName_LBL->setText( Interface );
11 Profiles_LB->clear(); 11 Profiles_LB->clear();
12 for( NodeCollection * NC = Possible.first(); 12 for( NetworkSetup * NC = Possible.first();
13 NC; 13 NC;
14 NC = Possible.next() ) { 14 NC = Possible.next() ) {
15 Profiles_LB->insertItem( NC->devicePixmap(), 15 Profiles_LB->insertItem( NC->devicePixmap(),
16 NC->name() ); 16 NC->name() );
17 } 17 }
18} 18}
19 19
20ActivateProfile::~ActivateProfile( void ) { 20ActivateProfile::~ActivateProfile( void ) {
21} 21}
22 22
23long ActivateProfile::selectedProfile( void ) { 23long ActivateProfile::selectedProfile( void ) {
24 for( unsigned int i = 0 ; i < Profiles_LB->count(); i ++ ) { 24 for( unsigned int i = 0 ; i < Profiles_LB->count(); i ++ ) {
25 if( Profiles_LB->isSelected(i) ) { 25 if( Profiles_LB->isSelected(i) ) {
26 return Possible.at(i)->number(); 26 return Possible.at(i)->number();
27 27
28 } 28 }
29 } 29 }
30 return -1; 30 return -1;
31} 31}
diff --git a/noncore/settings/networksettings2/activateprofile.h b/noncore/settings/networksettings2/activateprofile.h
index dedeb51..385c665 100644
--- a/noncore/settings/networksettings2/activateprofile.h
+++ b/noncore/settings/networksettings2/activateprofile.h
@@ -1,19 +1,19 @@
1#include "activateprofileGUI.h" 1#include "activateprofileGUI.h"
2#include "nsdata.h" 2#include "nsdata.h"
3 3
4class ActivateProfile : public ActivateProfileGUI { 4class ActivateProfile : public ActivateProfileGUI {
5 5
6 Q_OBJECT 6 Q_OBJECT
7 7
8public : 8public :
9 9
10 ActivateProfile( const char * interface ); 10 ActivateProfile( const char * interface );
11 ~ActivateProfile( void ); 11 ~ActivateProfile( void );
12 12
13 long selectedProfile( void ); 13 long selectedProfile( void );
14 14
15private : 15private :
16 16
17 NetworkSettingsData NSD; 17 NetworkSettingsData NSD;
18 QList<NodeCollection> Possible; 18 QList<NetworkSetup> Possible;
19}; 19};
diff --git a/noncore/settings/networksettings2/activatevpn.cpp b/noncore/settings/networksettings2/activatevpn.cpp
index 768a031..35a881b 100644
--- a/noncore/settings/networksettings2/activatevpn.cpp
+++ b/noncore/settings/networksettings2/activatevpn.cpp
@@ -1,48 +1,48 @@
1#include <qlistview.h> 1#include <qlistview.h>
2#include <qheader.h> 2#include <qheader.h>
3#include <resources.h> 3#include <resources.h>
4#include "activatevpn.h" 4#include "activatevpn.h"
5 5
6class MyCheckListItem : public QCheckListItem { 6class MyCheckListItem : public QCheckListItem {
7 7
8public : 8public :
9 9
10 MyCheckListItem( NodeCollection * N, QListView * V ); 10 MyCheckListItem( NetworkSetup * N, QListView * V );
11 11
12 NodeCollection * NC; 12 NetworkSetup * NC;
13 13
14}; 14};
15 15
16MyCheckListItem::MyCheckListItem( NodeCollection * N, QListView * V ): 16MyCheckListItem::MyCheckListItem( NetworkSetup * N, QListView * V ):
17 QCheckListItem( V, N->name() ) { 17 QCheckListItem( V, N->name() ) {
18 NC = N; 18 NC = N;
19} 19}
20 20
21ActivateVPN::ActivateVPN( const QString & I ) : 21ActivateVPN::ActivateVPN( const QString & I ) :
22 ActivateVPNGUI( 0, 0, TRUE ), NSD() { 22 ActivateVPNGUI( 0, 0, TRUE ), NSD() {
23 23
24 QCheckListItem * CI; 24 QCheckListItem * CI;
25 VPN_LV->clear(); 25 VPN_LV->clear();
26 VPN_LV->header()->hide(); 26 VPN_LV->header()->hide();
27 27
28 // find all connections that want to be triggered by this interface 28 // find all NetworkSetups that want to be triggered by this interface
29 for( QDictIterator<NodeCollection> it(NSResources->connections()); 29 for( QDictIterator<NetworkSetup> it(NSResources->networkSetups());
30 it.current(); 30 it.current();
31 ++it ) { 31 ++it ) {
32 if( it.current()->triggeredBy( I ) ) { 32 if( it.current()->triggeredBy( I ) ) {
33 CI = new MyCheckListItem( it.current(), VPN_LV ); 33 CI = new MyCheckListItem( it.current(), VPN_LV );
34 } 34 }
35 } 35 }
36} 36}
37 37
38ActivateVPN::~ActivateVPN( void ) { 38ActivateVPN::~ActivateVPN( void ) {
39} 39}
40 40
41void ActivateVPN::SLOT_ChangedVPNSetting( QListViewItem * I ) { 41void ActivateVPN::SLOT_ChangedVPNSetting( QListViewItem * I ) {
42 42
43 MyCheckListItem * MI = (MyCheckListItem *)I; 43 MyCheckListItem * MI = (MyCheckListItem *)I;
44 44
45 printf( "%s : %d\n", 45 printf( "%s : %d\n",
46 MI->text(0).latin1(), 46 MI->text(0).latin1(),
47 MI->isOn() ); 47 MI->isOn() );
48} 48}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp
index 5c937a1..5c71a0a 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp
@@ -1,165 +1,165 @@
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
7using Opietooth2::OTGateway; 7using Opietooth2::OTGateway;
8using Opietooth2::OTPANConnection; 8using Opietooth2::OTPANNetworkSetup;
9using Opietooth2::PANConnectionVector; 9using Opietooth2::PANNetworkSetupVector;
10 10
11BluetoothBNEPRun::BluetoothBNEPRun( ANetNodeInstance * NNI, 11BluetoothBNEPRun::BluetoothBNEPRun( ANetNodeInstance * NNI,
12 BluetoothBNEPData & D ) : 12 BluetoothBNEPData & D ) :
13 RuntimeInfo( NNI ), 13 RuntimeInfo( NNI ),
14 Data( D), 14 Data( D),
15 Pat( "bnep[0-6]" ) { 15 Pat( "bnep[0-6]" ) {
16 OT = 0; 16 OT = 0;
17} 17}
18 18
19BluetoothBNEPRun::~BluetoothBNEPRun( void ) { 19BluetoothBNEPRun::~BluetoothBNEPRun( void ) {
20 if( OT ) { 20 if( OT ) {
21 OTGateway::releaseOTGateway(); 21 OTGateway::releaseOTGateway();
22 } 22 }
23} 23}
24 24
25State_t BluetoothBNEPRun::detectState( void ) { 25State_t BluetoothBNEPRun::detectState( void ) {
26 26
27 /* 27 /*
28 28
29 need to detect 29 need to detect
30 30
31 1. for any PAN connection that is found if that 31 1. for any PAN NetworkSetup that is found if that
32 PAN is connected. 32 PAN is connected.
33 33
34 if it is connected it is not available (since we do 34 if it is connected it is not available (since we do
35 not manage IP settings and we are called to detect 35 not manage IP settings and we are called to detect
36 the state we knwo that we do not have an UP connection) 36 the state we knwo that we do not have an UP NetworkSetup)
37 37
38 2. if it not connected and we allow any connection we 38 2. if it not connected and we allow any NetworkSetup we
39 are available or if that PAN connection is to a device 39 are available or if that PAN NetworkSetup is to a device
40 with a correct address 40 with a correct address
41 41
42 3. if it is not connected and the address do not match or 42 3. if it is not connected and the address do not match or
43 we do not accept any address, we are Unavailable but 43 we do not accept any address, we are Unavailable but
44 not DOWN. I.e a new connection could perhaps be created 44 not DOWN. I.e a new NetworkSetup could perhaps be created
45 45
46 */ 46 */
47 47
48 if( ! OT ) { 48 if( ! OT ) {
49 OT = OTGateway::getOTGateway(); 49 OT = OTGateway::getOTGateway();
50 } 50 }
51 51
52 if( ! OT->isEnabled() ) { 52 if( ! OT->isEnabled() ) {
53 return Unavailable; 53 return Unavailable;
54 } 54 }
55 55
56 // if there is a PAN connection that is UP but not 56 // if there is a PAN NetworkSetup that is UP but not
57 // yet configured (no ifup) the we are available 57 // yet configured (no ifup) the we are available
58 return ( hasFreePANConnection() ) ? Available : Unknown; 58 return ( hasFreePANNetworkSetup() ) ? Available : Unknown;
59} 59}
60 60
61QString BluetoothBNEPRun::setMyState( NodeCollection * NC, Action_t A, bool ) { 61QString BluetoothBNEPRun::setMyState( NetworkSetup * NC, Action_t A, bool ) {
62 62
63 if( A == Activate ) { 63 if( A == Activate ) {
64 if( hasFreePANConnection( 1 ) ) { 64 if( hasFreePANNetworkSetup( 1 ) ) {
65 // we have now an assignedinterface 65 // we have now an assignedinterface
66 } else { 66 } else {
67 return QString("TODO : Start PAND"); 67 return QString("TODO : Start PAND");
68 } 68 }
69 69
70 Log(( "Assigned interface" )); 70 Log(( "Assigned interface" ));
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 ) {
77 // nothing to do 77 // nothing to do
78 NC->setCurrentState( Off ); 78 NC->setCurrentState( Off );
79 return QString(); 79 return QString();
80 } 80 }
81 return QString(); 81 return QString();
82} 82}
83 83
84bool BluetoothBNEPRun::handlesInterface( const QString & S ) { 84bool BluetoothBNEPRun::handlesInterface( const QString & S ) {
85 return Pat.match( S ) >= 0; 85 return Pat.match( S ) >= 0;
86} 86}
87 87
88bool BluetoothBNEPRun::handlesInterface( InterfaceInfo * I ) { 88bool BluetoothBNEPRun::handlesInterface( InterfaceInfo * I ) {
89 return handlesInterface( I->Name ); 89 return handlesInterface( I->Name );
90} 90}
91 91
92bool BluetoothBNEPRun::hasFreePANConnection( bool Grab ) { 92bool BluetoothBNEPRun::hasFreePANNetworkSetup( bool Grab ) {
93 93
94 if( ! OT ) { 94 if( ! OT ) {
95 OT = OTGateway::getOTGateway(); 95 OT = OTGateway::getOTGateway();
96 } 96 }
97 97
98 // load PAN connections 98 // load PAN NetworkSetups
99 OTPANConnection * C; 99 OTPANNetworkSetup * C;
100 InterfaceInfo * Run; 100 InterfaceInfo * Run;
101 InterfaceInfo * Candidate = 0; // reuse this interface 101 InterfaceInfo * Candidate = 0; // reuse this interface
102 PANConnectionVector Conns = OT->getPANConnections(); 102 PANNetworkSetupVector Conns = OT->getPANNetworkSetups();
103 System & Sys = NSResources->system(); 103 System & Sys = NSResources->system();
104 bool IsValid; 104 bool IsValid;
105 105
106 for( unsigned int i = 0; 106 for( unsigned int i = 0;
107 i < Conns.count(); 107 i < Conns.count();
108 i ++ ) { 108 i ++ ) {
109 C = Conns[i]; 109 C = Conns[i];
110 110
111 if( Data.AllowAll ) { 111 if( Data.AllowAll ) {
112 // we allow all 112 // we allow all
113 IsValid = 1; 113 IsValid = 1;
114 } else { 114 } else {
115 // is this PAN connection connecting to a Peer 115 // is this PAN NetworkSetup connecting to a Peer
116 // we allow ? 116 // we allow ?
117 IsValid = 0; 117 IsValid = 0;
118 for ( QStringList::Iterator it = Data.BDAddress.begin(); 118 for ( QStringList::Iterator it = Data.BDAddress.begin();
119 it != Data.BDAddress.end(); 119 it != Data.BDAddress.end();
120 ++ it ) { 120 ++ it ) {
121 if( C->ConnectedTo == (*it) ) { 121 if( C->ConnectedTo == (*it) ) {
122 // this is a connection we could accept 122 // this is a NetworkSetup we could accept
123 IsValid = 1; 123 IsValid = 1;
124 break; 124 break;
125 } 125 }
126 } 126 }
127 } 127 }
128 128
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
@@ -1,34 +1,34 @@
1#include <netnode.h> 1#include <netnode.h>
2#include "bluetoothBNEPdata.h" 2#include "bluetoothBNEPdata.h"
3 3
4#include <OTGateway.h> 4#include <OTGateway.h>
5 5
6class BluetoothBNEPRun : public RuntimeInfo { 6class BluetoothBNEPRun : public RuntimeInfo {
7 7
8public : 8public :
9 9
10 BluetoothBNEPRun( ANetNodeInstance * NNI, 10 BluetoothBNEPRun( ANetNodeInstance * NNI,
11 BluetoothBNEPData & D ); 11 BluetoothBNEPData & D );
12 virtual ~BluetoothBNEPRun( void ); 12 virtual ~BluetoothBNEPRun( void );
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
23protected : 23protected :
24 24
25 QString setMyState( NodeCollection * , Action_t, bool ); 25 QString setMyState( NetworkSetup * , Action_t, bool );
26 26
27private : 27private :
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
@@ -1,164 +1,164 @@
1#include <qapplication.h> 1#include <qapplication.h>
2#include <resources.h> 2#include <resources.h>
3#include <OTDevice.h> 3#include <OTDevice.h>
4#include <OTGateway.h> 4#include <OTGateway.h>
5#include "bluetoothRFCOMMrun.h" 5#include "bluetoothRFCOMMrun.h"
6 6
7using Opietooth2::OTGateway; 7using Opietooth2::OTGateway;
8using Opietooth2::OTDevice; 8using Opietooth2::OTDevice;
9using Opietooth2::OTDeviceAddress; 9using Opietooth2::OTDeviceAddress;
10 10
11BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) { 11BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) {
12 if( OT ) { 12 if( OT ) {
13 OTGateway::releaseOTGateway(); 13 OTGateway::releaseOTGateway();
14 } 14 }
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( 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
34QString BluetoothRFCOMMRun::setMyState( NodeCollection *, 34QString 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
47 if( Ch ) { 47 if( Ch ) {
48 // connect to this peer 48 // connect to this peer
49 DeviceNr = OT->getFreeRFCommDevice(); 49 DeviceNr = OT->getFreeRFCommDevice();
50 QStringList S; 50 QStringList S;
51 51
52 S << "rfcomm" 52 S << "rfcomm"
53 << "bind" 53 << "bind"
54 << QString().setNum( DeviceNr ) 54 << QString().setNum( DeviceNr )
55 << Ch->BDAddress 55 << Ch->BDAddress
56 << QString().setNum( Ch->Channel ); 56 << QString().setNum( Ch->Channel );
57 57
58 if( Sys.runAsRoot( S ) ) { 58 if( Sys.runAsRoot( S ) ) {
59 return QString( "Error starting %1").arg(S.join(" ")); 59 return QString( "Error starting %1").arg(S.join(" "));
60 } 60 }
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>
86 86
87RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) { 87RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) {
88 88
89 if( Data->Devices.count() == 1 ) { 89 if( Data->Devices.count() == 1 ) {
90 // only one device -> return channel 90 // only one device -> return channel
91 return Data->Devices[0]; 91 return Data->Devices[0];
92 } 92 }
93 93
94 RFCOMMChannel * Ch = 0; 94 RFCOMMChannel * Ch = 0;
95 QDialog * Dlg = new QDialog( qApp->mainWidget(), 0, TRUE ); 95 QDialog * Dlg = new QDialog( qApp->mainWidget(), 0, TRUE );
96 QVBoxLayout * V = new QVBoxLayout( Dlg ); 96 QVBoxLayout * V = new QVBoxLayout( Dlg );
97 97
98 QLabel * L = new QLabel( 98 QLabel * L = new QLabel(
99 qApp->translate( "BluetoothRFCOMMRun", 99 qApp->translate( "BluetoothRFCOMMRun",
100 "Select device to connect to"), 100 "Select device to connect to"),
101 Dlg ); 101 Dlg );
102 QListBox * LB = new QListBox( Dlg ); 102 QListBox * LB = new QListBox( Dlg );
103 103
104 for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) { 104 for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) {
105 LB->insertItem( QString( "%1 (%2 Chnl %3)" ). 105 LB->insertItem( QString( "%1 (%2 Chnl %3)" ).
106 arg( Data->Devices[i]->Name ). 106 arg( Data->Devices[i]->Name ).
107 arg( Data->Devices[i]->BDAddress ). 107 arg( Data->Devices[i]->BDAddress ).
108 arg( Data->Devices[i]->Channel ) ); 108 arg( Data->Devices[i]->Channel ) );
109 } 109 }
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 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
133QString BluetoothRFCOMMRun::deviceFile( void ) { 133QString 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
142int BluetoothRFCOMMRun::deviceNrOfConnection( void ) { 142int 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;
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 odebug << "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/bluetoothRFCOMMrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
index 5a31a94..32986d3 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
@@ -1,32 +1,32 @@
1#include <netnode.h> 1#include <netnode.h>
2#include "bluetoothRFCOMMdata.h" 2#include "bluetoothRFCOMMdata.h"
3 3
4#include <OTGateway.h> 4#include <OTGateway.h>
5 5
6class BluetoothRFCOMMRun : public RuntimeInfo { 6class BluetoothRFCOMMRun : public RuntimeInfo {
7 7
8public : 8public :
9 9
10 BluetoothRFCOMMRun( ANetNodeInstance * NNI, 10 BluetoothRFCOMMRun( ANetNodeInstance * NNI,
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
21protected : 21protected :
22 22
23 QString setMyState( NodeCollection * , Action_t, bool ); 23 QString setMyState( NetworkSetup * , Action_t, bool );
24 24
25private : 25private :
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};
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp
index 58237a1..3f34bb2 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NN.cpp
@@ -1,52 +1,52 @@
1#include "cable_NN.h" 1#include "cable_NN.h"
2#include "cable_NNI.h" 2#include "cable_NNI.h"
3 3
4#include "netnodeinterface.h" 4#include "netnodeinterface.h"
5 5
6static const char * CableNeeds[] = 6static const char * CableNeeds[] =
7 { 0 7 { 0
8 }; 8 };
9 9
10static const char * CableProvides[] = 10static const char * CableProvides[] =
11 { "line", 11 { "line",
12 0 12 0
13 }; 13 };
14 14
15/** 15/**
16 * Constructor, find all of the possible interfaces 16 * Constructor, find all of the possible interfaces
17 */ 17 */
18CableNetNode::CableNetNode() : ANetNode(tr("Cable Connection")) { 18CableNetNode::CableNetNode() : ANetNode(tr("Cable NetworkSetup")) {
19} 19}
20 20
21/** 21/**
22 * Delete any interfaces that we own. 22 * Delete any interfaces that we own.
23 */ 23 */
24CableNetNode::~CableNetNode(){ 24CableNetNode::~CableNetNode(){
25} 25}
26 26
27const QString CableNetNode::nodeDescription(){ 27const QString CableNetNode::nodeDescription(){
28 return tr("\ 28 return tr("\
29<p>Sets up a wired serial or parallel.</p>\ 29<p>Sets up a wired serial or parallel.</p>\
30" 30"
31); 31);
32} 32}
33 33
34ANetNodeInstance * CableNetNode::createInstance( void ) { 34ANetNodeInstance * CableNetNode::createInstance( void ) {
35 return new ACable( this ); 35 return new ACable( this );
36} 36}
37 37
38const char ** CableNetNode::needs( void ) { 38const char ** CableNetNode::needs( void ) {
39 return CableNeeds; 39 return CableNeeds;
40} 40}
41 41
42const char ** CableNetNode::provides( void ) { 42const char ** CableNetNode::provides( void ) {
43 return CableProvides; 43 return CableProvides;
44} 44}
45 45
46void CableNetNode::setSpecificAttribute( QString & , QString & ) { 46void CableNetNode::setSpecificAttribute( QString & , QString & ) {
47} 47}
48 48
49void CableNetNode::saveSpecificAttribute( QTextStream & ) { 49void CableNetNode::saveSpecificAttribute( QTextStream & ) {
50} 50}
51 51
52OPIE_NS2_PLUGIN( NetNodeInterface_T<CableNetNode> ) 52OPIE_NS2_PLUGIN( NetNodeInterface_T<CableNetNode> )
diff --git a/noncore/settings/networksettings2/cable/cablerun.cpp b/noncore/settings/networksettings2/cable/cablerun.cpp
index 7a8deb9..edbeb89 100644
--- a/noncore/settings/networksettings2/cable/cablerun.cpp
+++ b/noncore/settings/networksettings2/cable/cablerun.cpp
@@ -1,22 +1,22 @@
1#include <fcntl.h> 1#include <fcntl.h>
2#include <unistd.h> 2#include <unistd.h>
3#include "cablerun.h" 3#include "cablerun.h"
4 4
5State_t CableRun::detectState( void ) { 5State_t CableRun::detectState( void ) {
6 6
7 int fd = open( Data->Device.latin1(), O_RDWR ); 7 int fd = open( Data->Device.latin1(), O_RDWR );
8 8
9 if( fd < 0 ) { 9 if( fd < 0 ) {
10 return Unavailable; 10 return Unavailable;
11 } 11 }
12 close( fd ); 12 close( fd );
13 return Available; 13 return Available;
14} 14}
15 15
16QString CableRun::setMyState( NodeCollection *, Action_t , bool ) { 16QString CableRun::setMyState( NetworkSetup *, Action_t , bool ) {
17 return QString(); 17 return QString();
18} 18}
19 19
20QString CableRun::deviceFile( void ) { 20QString CableRun::deviceFile( void ) {
21 return Data->Device; 21 return Data->Device;
22} 22}
diff --git a/noncore/settings/networksettings2/cable/cablerun.h b/noncore/settings/networksettings2/cable/cablerun.h
index 41aea01..6a457c4 100644
--- a/noncore/settings/networksettings2/cable/cablerun.h
+++ b/noncore/settings/networksettings2/cable/cablerun.h
@@ -1,26 +1,26 @@
1#include <netnode.h> 1#include <netnode.h>
2#include "cabledata.h" 2#include "cabledata.h"
3 3
4class CableRun : public RuntimeInfo { 4class CableRun : public RuntimeInfo {
5 5
6public : 6public :
7 7
8 CableRun( ANetNodeInstance * NNI, 8 CableRun( ANetNodeInstance * NNI,
9 CableData & D ) : RuntimeInfo( NNI ) 9 CableData & D ) : RuntimeInfo( NNI )
10 { Data = &D; } 10 { Data = &D; }
11 11
12 virtual RuntimeInfo * line( void ) 12 virtual RuntimeInfo * line( void )
13 { return this; } 13 { return this; }
14 14
15 virtual QString deviceFile( void ); 15 virtual QString deviceFile( void );
16 16
17 State_t detectState( void ); 17 State_t detectState( void );
18 18
19protected : 19protected :
20 20
21 QString setMyState( NodeCollection * , Action_t, bool ); 21 QString setMyState( NetworkSetup * , Action_t, bool );
22 22
23private : 23private :
24 24
25 CableData * Data; 25 CableData * Data;
26}; 26};
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp
index 717d9e9..6ab2dd6 100644
--- a/noncore/settings/networksettings2/editconnection.cpp
+++ b/noncore/settings/networksettings2/editconnection.cpp
@@ -1,629 +1,631 @@
1#include <opie2/odebug.h> 1#include <opie2/odebug.h>
2#include <qlistview.h> 2#include <qlistview.h>
3#include <qwidgetstack.h> 3#include <qwidgetstack.h>
4#include <qframe.h> 4#include <qframe.h>
5#include <qcombobox.h> 5#include <qcombobox.h>
6#include <qtabwidget.h> 6#include <qtabwidget.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qpushbutton.h> 8#include <qpushbutton.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qheader.h> 10#include <qheader.h>
11#include <qpainter.h> 11#include <qpainter.h>
12#include <qcheckbox.h> 12#include <qcheckbox.h>
13#include <qlabel.h> 13#include <qlabel.h>
14 14
15#include "editconnection.h" 15#include "editconnection.h"
16#include "resources.h" 16#include "resources.h"
17#include "netnode.h" 17#include "netnode.h"
18 18
19// 19//
20// 20//
21// THESE TO GIVE BETTER FEEDBACK ABOUT DISABLED ITEMS 21// THESE TO GIVE BETTER FEEDBACK ABOUT DISABLED ITEMS
22// 22//
23// 23//
24 24
25class MyQCheckListItem : public QCheckListItem 25class MyQCheckListItem : public QCheckListItem
26{ 26{
27public: 27public:
28 MyQCheckListItem( QListView *parent, const QString & S, Type T ) : 28 MyQCheckListItem( QListView *parent, const QString & S, Type T ) :
29 QCheckListItem( parent, S, T ) { } 29 QCheckListItem( parent, S, T ) { }
30 MyQCheckListItem( QCheckListItem *parent, const QString & S, Type T ) : 30 MyQCheckListItem( QCheckListItem *parent, const QString & S, Type T ) :
31 QCheckListItem( parent, S, T ) { } 31 QCheckListItem( parent, S, T ) { }
32 MyQCheckListItem( QListViewItem *parent, const QString & S, Type T ) : 32 MyQCheckListItem( QListViewItem *parent, const QString & S, Type T ) :
33 QCheckListItem( parent, S, T ) { } 33 QCheckListItem( parent, S, T ) { }
34 34
35 MyQCheckListItem( QListView *parent, const QString & S ) : 35 MyQCheckListItem( QListView *parent, const QString & S ) :
36 QCheckListItem( parent, S, QCheckListItem::Controller ) { } 36 QCheckListItem( parent, S, QCheckListItem::Controller ) { }
37 MyQCheckListItem( QCheckListItem *parent, const QString & S ) : 37 MyQCheckListItem( QCheckListItem *parent, const QString & S ) :
38 QCheckListItem( parent, S, QCheckListItem::Controller ) { } 38 QCheckListItem( parent, S, QCheckListItem::Controller ) { }
39 MyQCheckListItem( QListViewItem *parent, const QString & S ) : 39 MyQCheckListItem( QListViewItem *parent, const QString & S ) :
40 QCheckListItem( parent, S, QCheckListItem::Controller ) { } 40 QCheckListItem( parent, S, QCheckListItem::Controller ) { }
41 41
42 virtual void paintCell( QPainter *p, const QColorGroup &cg, 42 virtual void paintCell( QPainter *p, const QColorGroup &cg,
43 int column, int width, int alignment ); 43 int column, int width, int alignment );
44 44
45}; 45};
46 46
47void MyQCheckListItem::paintCell( QPainter *p, const QColorGroup &cg, 47void MyQCheckListItem::paintCell( QPainter *p, const QColorGroup &cg,
48 int column, int width, int alignment ) 48 int column, int width, int alignment )
49{ 49{
50 QColorGroup _cg( cg ); 50 QColorGroup _cg( cg );
51 QColor c = _cg.text(); 51 QColor c = _cg.text();
52 if ( ! isSelectable() ) 52 if ( ! isSelectable() )
53 _cg.setColor( QColorGroup::Text, Qt::lightGray ); 53 _cg.setColor( QColorGroup::Text, Qt::lightGray );
54 QCheckListItem::paintCell( p, _cg, column, width, alignment ); 54 QCheckListItem::paintCell( p, _cg, column, width, alignment );
55 _cg.setColor( QColorGroup::Text, c ); 55 _cg.setColor( QColorGroup::Text, c );
56} 56}
57 57
58class MyQListViewItem : public QListViewItem 58class MyQListViewItem : public QListViewItem
59{ 59{
60public: 60public:
61 MyQListViewItem( QListView *parent, const QString & S ) : 61 MyQListViewItem( QListView *parent, const QString & S ) :
62 QListViewItem( parent, S ) { } 62 QListViewItem( parent, S ) { }
63 MyQListViewItem( QListViewItem *parent, const QString & S ) : 63 MyQListViewItem( QListViewItem *parent, const QString & S ) :
64 QListViewItem( parent, S ) { } 64 QListViewItem( parent, S ) { }
65 65
66 virtual void paintCell( QPainter *p, const QColorGroup &cg, 66 virtual void paintCell( QPainter *p, const QColorGroup &cg,
67 int column, int width, int alignment ); 67 int column, int width, int alignment );
68 68
69}; 69};
70 70
71void MyQListViewItem::paintCell( QPainter *p, const QColorGroup &cg, 71void MyQListViewItem::paintCell( QPainter *p, const QColorGroup &cg,
72 int column, int width, int alignment ) 72 int column, int width, int alignment )
73{ 73{
74 QColorGroup _cg( cg ); 74 QColorGroup _cg( cg );
75 QColor c = _cg.text(); 75 QColor c = _cg.text();
76 if ( ! isSelectable() ) 76 if ( ! isSelectable() )
77 _cg.setColor( QColorGroup::Text, Qt::lightGray ); 77 _cg.setColor( QColorGroup::Text, Qt::lightGray );
78 QListViewItem::paintCell( p, _cg, column, width, alignment ); 78 QListViewItem::paintCell( p, _cg, column, width, alignment );
79 _cg.setColor( QColorGroup::Text, c ); 79 _cg.setColor( QColorGroup::Text, c );
80} 80}
81 81
82// 82//
83// 83//
84// REAL GUI 84// REAL GUI
85// 85//
86// 86//
87 87
88bool EditConnection::AutoCollapse = 1; 88bool EditNetworkSetup::AutoCollapse = 1;
89 89
90EditConnection::EditConnection( QWidget* parent ) : 90EditNetworkSetup::EditNetworkSetup( QWidget* parent ) :
91 EditConnectionGUI( parent, 0, TRUE ), TmpCollection() { 91 EditNetworkSetupGUI( parent, 0, TRUE ), TmpCollection() {
92 92
93 Tab_TB->setTabEnabled( Setup_FRM, FALSE ); 93 Tab_TB->setTabEnabled( Setup_FRM, FALSE );
94 Setup_FRM->setEnabled( FALSE ); 94 Setup_FRM->setEnabled( FALSE );
95 95
96 TmpIsValid = 0; 96 TmpIsValid = 0;
97 SelectedNodes = 0; 97 SelectedNodes = 0;
98 98
99 AutoCollapse_CB->setChecked( AutoCollapse ); 99 AutoCollapse_CB->setChecked( AutoCollapse );
100 100
101 Mapping = new QPtrDict<ANetNode>; 101 Mapping = new QPtrDict<ANetNode>;
102 Mapping->setAutoDelete( FALSE ); 102 Mapping->setAutoDelete( FALSE );
103 Nodes_LV->header()->hide(); 103 Nodes_LV->header()->hide();
104 // popluate tree with all NetNodes 104 // popluate tree with all NetNodes
105 buildFullTree(); 105 buildFullTree();
106} 106}
107 107
108NodeCollection * EditConnection::getTmpCollection( void ) { 108NetworkSetup * EditNetworkSetup::getTmpCollection( void ) {
109 109
110 if( TmpIsValid ) 110 if( TmpIsValid )
111 // content is stil OK 111 // content is stil OK
112 return &(TmpCollection); 112 return &(TmpCollection);
113 113
114 // reset collection -> delete all NEW NetNodes 114 // reset collection -> delete all NEW NetNodes
115 for( QListIterator<ANetNodeInstance> it(TmpCollection); 115 for( QListIterator<ANetNodeInstance> it(TmpCollection);
116 it.current(); 116 it.current();
117 ++it ) { 117 ++it ) {
118 if( it.current()->isNew() ) { 118 if( it.current()->isNew() ) {
119 delete it.current(); 119 delete it.current();
120 } 120 }
121 } 121 }
122
122 TmpCollection.clear(); 123 TmpCollection.clear();
124 TmpCollection.copyFrom( *SelectedNodes );
123 125
124 // update content 126 // update content
125 QListViewItem * it = Nodes_LV->firstChild(); 127 QListViewItem * it = Nodes_LV->firstChild();
126 ANetNode * NN; 128 ANetNode * NN;
127 129
128 // start iter (if there is a collection) 130 // start iter (if there is a collection)
129 /* 131 /*
130 132
131 a node collection is sorted from the toplevel 133 a node collection is sorted from the toplevel
132 node to the deepest node 134 node to the deepest node
133 135
134 */ 136 */
135 ANetNodeInstance * NNI = 137 ANetNodeInstance * NNI =
136 (SelectedNodes) ? SelectedNodes->first() : 0 ; 138 (SelectedNodes) ? SelectedNodes->first() : 0 ;
137 139
138 TmpCollection.setModified( 0 ); 140 TmpCollection.setModified( 0 );
139 141
140 // the listview always starts with the toplevel 142 // the listview always starts with the toplevel
141 // hierarchy. This is always a controller item 143 // hierarchy. This is always a controller item
142 while ( it ) { 144 while ( it ) {
143 NN = (*Mapping)[it]; 145 NN = (*Mapping)[it];
144 if( NN == 0 ) { 146 if( NN == 0 ) {
145 // this item is a controller -> 147 // this item is a controller ->
146 // has radio items as children -> 148 // has radio items as children ->
147 // find selected one 149 // find selected one
148 it = it->firstChild(); 150 it = it->firstChild();
149 while( it ) { 151 while( it ) {
150 if( ((QCheckListItem *)it)->isOn() ) { 152 if( ((QCheckListItem *)it)->isOn() ) {
151 // this radio is selected -> go deeper 153 // this radio is selected -> go deeper
152 break; 154 break;
153 } 155 }
154 it = it->nextSibling(); 156 it = it->nextSibling();
155 } 157 }
156 158
157 if( ! it ) { 159 if( ! it ) {
158 TmpIsValid = 0; 160 TmpIsValid = 0;
159 return 0; 161 return 0;
160 } 162 }
161 163
162 // it now contains selected radio 164 // it now contains selected radio
163 NN = (*Mapping)[it]; 165 NN = (*Mapping)[it];
164 } 166 }
165 167
166 // NN here contains the netnode of the 168 // NN here contains the netnode of the
167 // current item -> this node needs to 169 // current item -> this node needs to
168 // be stored in the collection 170 // be stored in the collection
169 if( NNI == 0 || 171 if( NNI == 0 ||
170 it->text(0) != NNI->nodeClass()->name() ) { 172 it->text(0) != NNI->nodeClass()->name() ) {
171 // new item not in previous collection 173 // new item not in previous collection
172 ANetNodeInstance * NNI = NN->createInstance(); 174 ANetNodeInstance * NNI = NN->createInstance();
173 NNI->initialize(); 175 NNI->initialize();
174 // this node type not in collection 176 // this node type not in collection
175 TmpCollection.append( NNI ); 177 TmpCollection.append( NNI );
176 // master collection changed because new item in it 178 // master collection changed because new item in it
177 TmpCollection.setModified( 1 ); 179 TmpCollection.setModified( 1 );
178 // no more valid items in old list 180 // no more valid items in old list
179 NNI = 0; 181 NNI = 0;
180 } else { 182 } else {
181 // already in list -> copy pointer 183 // already in list -> copy pointer
182 TmpCollection.append( NNI ); 184 TmpCollection.append( NNI );
183 NNI = SelectedNodes->next(); 185 NNI = SelectedNodes->next();
184 } 186 }
185 187
186 // go deeper to next level 188 // go deeper to next level
187 // this level is can be a new controller 189 // this level is can be a new controller
188 // or an item 190 // or an item
189 it = it->firstChild(); 191 it = it->firstChild();
190 } 192 }
191 193
192 TmpIsValid = 1; 194 TmpIsValid = 1;
193 return &(TmpCollection); 195 return &(TmpCollection);
194} 196}
195 197
196// pass a connection NodeCollection to be edited 198// pass a NetworkSetup NetworkSetup to be edited
197void EditConnection::setConnection( NodeCollection * NC ) { 199void EditNetworkSetup::setNetworkSetup( NetworkSetup * NC ) {
198 ANetNodeInstance * NNI; 200 ANetNodeInstance * NNI;
199 ANetNode * NN; 201 ANetNode * NN;
200 202
201 SelectedNodes = NC; 203 SelectedNodes = NC;
202 Name_LE->setText( NC->name() ); 204 Name_LE->setText( NC->name() );
203 NNI = NC->first(); 205 NNI = NC->first();
204 206
205 // show configure tabl 207 // show configure tabl
206 Tab_TB->setCurrentPage( 1 ); 208 Tab_TB->setCurrentPage( 1 );
207 209
208 // valid colledction 210 // valid colledction
209 Tab_TB->setTabEnabled( Setup_FRM, FALSE ); 211 Tab_TB->setTabEnabled( Setup_FRM, FALSE );
210 Setup_FRM->setEnabled( FALSE ); 212 Setup_FRM->setEnabled( FALSE );
211 213
212 // select items in collection 214 // select items in collection
213 QListViewItem * it = Nodes_LV->firstChild(); 215 QListViewItem * it = Nodes_LV->firstChild();
214 bool Found; 216 bool Found;
215 217
216 TmpIsValid = 0; 218 TmpIsValid = 0;
217 219
218 while ( it ) { 220 while ( it ) {
219 NN = (*Mapping)[it]; 221 NN = (*Mapping)[it];
220 if( NN == 0 ) { 222 if( NN == 0 ) {
221 // this item is a controller -> 223 // this item is a controller ->
222 // has radio items as children -> 224 // has radio items as children ->
223 // find selected one 225 // find selected one
224 it = it->firstChild(); 226 it = it->firstChild();
225 Found = 0; 227 Found = 0;
226 while( it ) { 228 while( it ) {
227 if( NNI && it->text(0) == NNI->nodeClass()->name() ) { 229 if( NNI && it->text(0) == NNI->nodeClass()->name() ) {
228 // this radio is part of the collection 230 // this radio is part of the collection
229 ((QCheckListItem *)it)->setOn( 1 ); 231 ((QCheckListItem *)it)->setOn( 1 );
230 updateGUI( it, NNI->nodeClass() ); 232 updateGUI( it, NNI->nodeClass() );
231 // check its children 233 // check its children
232 Found = 1; 234 Found = 1;
233 it = it->firstChild(); 235 it = it->firstChild();
234 NNI = SelectedNodes->next(); 236 NNI = SelectedNodes->next();
235 // do not bother to check other items 237 // do not bother to check other items
236 break; 238 break;
237 } 239 }
238 it = it->nextSibling(); 240 it = it->nextSibling();
239 } 241 }
240 242
241 if( ! Found ) { 243 if( ! Found ) {
242 // this means that this level is NOT present in collection 244 // this means that this level is NOT present in collection
243 // probably INCOMPATIBEL collection OR Missing plugin 245 // probably INCOMPATIBEL collection OR Missing plugin
244 QMessageBox::warning( 246 QMessageBox::warning(
245 0, 247 0,
246 tr( "Error presentig Connection" ), 248 tr( "Error presentig NetworkSetup" ),
247 tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). 249 tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ).
248 arg(NNI->nodeClass()->name()) ); 250 arg(NNI->nodeClass()->name()) );
249 return; 251 return;
250 } 252 }
251 253
252 // it now contains selected radio 254 // it now contains selected radio
253 NN = (*Mapping)[it]; 255 NN = (*Mapping)[it];
254 } else { 256 } else {
255 // automatic selection 257 // automatic selection
256 if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) { 258 if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) {
257 // should exist and be the same 259 // should exist and be the same
258 if( NNI ) { 260 if( NNI ) {
259 QMessageBox::warning( 261 QMessageBox::warning(
260 0, 262 0,
261 tr( "Error presentig Connection" ), 263 tr( "Error presentig NetworkSetup" ),
262 tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). 264 tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ).
263 arg(NNI->nodeClass()->name()) ); 265 arg(NNI->nodeClass()->name()) );
264 } else { 266 } else {
265 QMessageBox::warning( 267 QMessageBox::warning(
266 0, 268 0,
267 tr( "Error presentig Connection" ), 269 tr( "Error presentig NetworkSetup" ),
268 tr( "<p>Missing connection\"<i>%1</i>\"</p>" ). 270 tr( "<p>Missing NetworkSetup\"<i>%1</i>\"</p>" ).
269 arg(it->text(0)) ); 271 arg(it->text(0)) );
270 } 272 }
271 return; 273 return;
272 } 274 }
273 it = it->firstChild(); 275 it = it->firstChild();
274 } 276 }
275 } 277 }
276} 278}
277 279
278// get result of editing (either new OR updated collection 280// get result of editing (either new OR updated collection
279NodeCollection * EditConnection::connection( void ) { 281NetworkSetup * EditNetworkSetup::networkSetup( void ) {
280 282
281 if( SelectedNodes == 0 ) { 283 if( SelectedNodes == 0 ) {
282 // new collection 284 // new collection
283 SelectedNodes = new NodeCollection; 285 SelectedNodes = new NetworkSetup;
284 } 286 }
285 287
286 // clean out old entries 288 // clean out old entries
287 SelectedNodes->clear(); 289 SelectedNodes->clear();
288 290
289 // transfer 291 // transfer
290 for( QListIterator<ANetNodeInstance> it(TmpCollection); 292 for( QListIterator<ANetNodeInstance> it(TmpCollection);
291 it.current(); 293 it.current();
292 ++it ) { 294 ++it ) {
293 SelectedNodes->append( it.current() ); 295 SelectedNodes->append( it.current() );
294 } 296 }
295 297
296 if( TmpCollection.isModified() ) 298 if( TmpCollection.isModified() )
297 SelectedNodes->setModified( 1 ); 299 SelectedNodes->setModified( 1 );
298 300
299 if( SelectedNodes->name() != Name_LE->text() ) { 301 if( SelectedNodes->name() != Name_LE->text() ) {
300 SelectedNodes->setName( Name_LE->text() ); 302 SelectedNodes->setName( Name_LE->text() );
301 SelectedNodes->setModified( 1 ); 303 SelectedNodes->setModified( 1 );
302 } 304 }
303 305
304 return SelectedNodes; 306 return SelectedNodes;
305} 307}
306 308
307// Build device tree -> start 309// Build device tree -> start
308void EditConnection::buildFullTree( void ) { 310void EditNetworkSetup::buildFullTree( void ) {
309 ANetNode * NN; 311 ANetNode * NN;
310 312
311 // toplevel item 313 // toplevel item
312 MyQCheckListItem * TheTop = new MyQCheckListItem( 314 MyQCheckListItem * TheTop = new MyQCheckListItem(
313 Nodes_LV, 315 Nodes_LV,
314 NSResources->netNode2Name("fullsetup"), 316 NSResources->netNode2Name("fullsetup"),
315 QCheckListItem::Controller ); 317 QCheckListItem::Controller );
316 TheTop->setOpen( TRUE ); 318 TheTop->setOpen( TRUE );
317 Description_LBL->setText( 319 Description_LBL->setText(
318 NSResources->netNode2Description( "fullsetup" ) ); 320 NSResources->netNode2Description( "fullsetup" ) );
319 Nodes_LV->setSelected( TheTop, TRUE ); 321 Nodes_LV->setSelected( TheTop, TRUE );
320 322
321 // find all Nodes that are toplevel nodes -> ie provide 323 // find all Nodes that are toplevel nodes -> ie provide
322 // TCP/IP Connection 324 // TCP/IP NetworkSetup
323 for( QDictIterator<ANetNode> Iter(NSResources->netNodes()); 325 for( QDictIterator<ANetNode> Iter(NSResources->netNodes());
324 Iter.current(); 326 Iter.current();
325 ++Iter ) { 327 ++Iter ) {
326 NN = Iter.current(); 328 NN = Iter.current();
327 329
328 if( ! NN->isToplevel() ) { 330 if( ! NN->isToplevel() ) {
329 continue; 331 continue;
330 } 332 }
331 333
332 MyQCheckListItem * it = new MyQCheckListItem( TheTop, 334 MyQCheckListItem * it = new MyQCheckListItem( TheTop,
333 NN->name(), 335 NN->name(),
334 QCheckListItem::RadioButton ); 336 QCheckListItem::RadioButton );
335 it->setPixmap( 0, 337 it->setPixmap( 0,
336 NSResources->getPixmap( NN->pixmapName() ) 338 NSResources->getPixmap( NN->pixmapName() )
337 ); 339 );
338 // remember that this node maps to this listitem 340 // remember that this node maps to this listitem
339 Mapping->insert( it, NN ); 341 Mapping->insert( it, NN );
340 buildSubTree( it, NN ); 342 buildSubTree( it, NN );
341 } 343 }
342} 344}
343 345
344// Build device tree -> help function 346// Build device tree -> help function
345void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) { 347void EditNetworkSetup::buildSubTree( QListViewItem * it, ANetNode *NN ) {
346 ANetNode::NetNodeList & NNL = NN->alternatives(); 348 ANetNode::NetNodeList & NNL = NN->alternatives();
347 349
348 if( NNL.size() > 1 ) { 350 if( NNL.size() > 1 ) {
349 // this node has alternatives -> needs radio buttons 351 // this node has alternatives -> needs radio buttons
350 it = new MyQCheckListItem( 352 it = new MyQCheckListItem(
351 it, 353 it,
352 NSResources->netNode2Name(NN->needs()[0]), 354 NSResources->netNode2Name(NN->needs()[0]),
353 QCheckListItem::Controller ); 355 QCheckListItem::Controller );
354 it->setSelectable( FALSE ); 356 it->setSelectable( FALSE );
355 } 357 }
356 358
357 for ( unsigned int i=0; i < NNL.size(); i++ ) { 359 for ( unsigned int i=0; i < NNL.size(); i++ ) {
358 QListViewItem * CI; 360 QListViewItem * CI;
359 if( NNL.size() > 1 ) { 361 if( NNL.size() > 1 ) {
360 // generate radio buttons 362 // generate radio buttons
361 CI = new MyQCheckListItem( 363 CI = new MyQCheckListItem(
362 (QCheckListItem *)it, 364 (QCheckListItem *)it,
363 NNL[i]->name(), QCheckListItem::RadioButton ); 365 NNL[i]->name(), QCheckListItem::RadioButton );
364 // remember that this node maps to this listitem 366 // remember that this node maps to this listitem
365 CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); 367 CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) );
366 Mapping->insert( CI, NNL[i] ); 368 Mapping->insert( CI, NNL[i] );
367 CI->setSelectable( FALSE ); 369 CI->setSelectable( FALSE );
368 } else { 370 } else {
369 // Single item 371 // Single item
370 CI = new MyQListViewItem( it, NNL[i]->name() ); 372 CI = new MyQListViewItem( it, NNL[i]->name() );
371 // remember that this node maps to this listitem 373 // remember that this node maps to this listitem
372 Mapping->insert( CI, NNL[i] ); 374 Mapping->insert( CI, NNL[i] );
373 CI->setSelectable( FALSE ); 375 CI->setSelectable( FALSE );
374 CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); 376 CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) );
375 } 377 }
376 buildSubTree( CI, NNL[i] ); 378 buildSubTree( CI, NNL[i] );
377 } 379 }
378} 380}
379 381
380// Clicked ok OK button 382// Clicked ok OK button
381void EditConnection::accept( void ) { 383void EditNetworkSetup::accept( void ) {
382 if( ! haveCompleteConfig( 0 ) || Name_LE->text().isEmpty() ) { 384 if( ! haveCompleteConfig( 0 ) || Name_LE->text().isEmpty() ) {
383 QMessageBox::warning( 385 QMessageBox::warning(
384 0, 386 0,
385 tr( "Closing Connection Setup" ), 387 tr( "Closing NetworkSetup Setup" ),
386 tr( "Definition not complete or no name" ) ); 388 tr( "Definition not complete or no name" ) );
387 return; 389 return;
388 } 390 }
389 391
390 // check if all devices have acceptable input 392 // check if all devices have acceptable input
391 getTmpCollection(); 393 getTmpCollection();
392 { ANetNodeInstance * NNI; 394 { ANetNodeInstance * NNI;
393 QString S; 395 QString S;
394 396
395 for( QListIterator<ANetNodeInstance> it(TmpCollection); 397 for( QListIterator<ANetNodeInstance> it(TmpCollection);
396 it.current(); 398 it.current();
397 ++it ) { 399 ++it ) {
398 NNI = it.current(); 400 NNI = it.current();
399 // widget must show its own problems 401 // widget must show its own problems
400 S = NNI->acceptable(); 402 S = NNI->acceptable();
401 if( ! S.isEmpty() ) { 403 if( ! S.isEmpty() ) {
402 QMessageBox::warning( 404 QMessageBox::warning(
403 0, 405 0,
404 tr( "Cannot save" ), 406 tr( "Cannot save" ),
405 S ); 407 S );
406 return; 408 return;
407 } 409 }
408 NNI->commit(); 410 NNI->commit();
409 411
410 if( NNI->isModified() ) { 412 if( NNI->isModified() ) {
411 TmpCollection.setModified( 1 ); 413 TmpCollection.setModified( 1 );
412 // commit the data 414 // commit the data
413 } 415 }
414 } 416 }
415 } 417 }
416 418
417 QDialog::accept(); 419 QDialog::accept();
418} 420}
419 421
420// triggered by CB 422// triggered by CB
421void EditConnection::SLOT_AutoCollapse( bool b ) { 423void EditNetworkSetup::SLOT_AutoCollapse( bool b ) {
422 AutoCollapse = b; 424 AutoCollapse = b;
423} 425}
424 426
425// clicked on node in tree -> update GUI 427// clicked on node in tree -> update GUI
426void EditConnection::SLOT_SelectNode( QListViewItem * it ) { 428void EditNetworkSetup::SLOT_SelectNode( QListViewItem * it ) {
427 ANetNode * NN; 429 ANetNode * NN;
428 if( it == 0 || it->depth() == 0 ) { 430 if( it == 0 || it->depth() == 0 ) {
429 Description_LBL->setText( 431 Description_LBL->setText(
430 NSResources->netNode2Description( "fullsetup" ) ); 432 NSResources->netNode2Description( "fullsetup" ) );
431 // topevel or no selection 433 // topevel or no selection
432 return; 434 return;
433 } 435 }
434 436
435 // store conversion from lvitem to node 437 // store conversion from lvitem to node
436 NN = (*Mapping)[ it ]; 438 NN = (*Mapping)[ it ];
437 439
438 if( ! NN ) { 440 if( ! NN ) {
439 // intermediate node 441 // intermediate node
440 NN = (*Mapping)[ it->parent() ]; 442 NN = (*Mapping)[ it->parent() ];
441 if( NN ) { 443 if( NN ) {
442 // figure out type of this node -> produce mesage 444 // figure out type of this node -> produce mesage
443 Description_LBL->setText( NSResources->netNode2Description( 445 Description_LBL->setText( NSResources->netNode2Description(
444 NN->needs()[0]) ); 446 NN->needs()[0]) );
445 } else { 447 } else {
446 Description_LBL->setText( "" ); 448 Description_LBL->setText( "" );
447 } 449 }
448 return; 450 return;
449 } 451 }
450 452
451 Description_LBL->setText( NN->nodeDescription() ); 453 Description_LBL->setText( NN->nodeDescription() );
452 454
453 if( ! it->isSelectable() ) { 455 if( ! it->isSelectable() ) {
454 return; 456 return;
455 } 457 }
456 458
457 if( ! ((QCheckListItem *)it)->isOn() ) { 459 if( ! ((QCheckListItem *)it)->isOn() ) {
458 // clicked on line but NOT on Check or Radio item 460 // clicked on line but NOT on Check or Radio item
459 return; 461 return;
460 } 462 }
461 463
462 // item has really changed -> update 464 // item has really changed -> update
463 TmpIsValid = 0; 465 TmpIsValid = 0;
464 updateGUI( it, NN ); 466 updateGUI( it, NN );
465} 467}
466 468
467// cliecked on TAB to go to setup 469// cliecked on TAB to go to setup
468void EditConnection::SLOT_AlterTab( const QString & S ) { 470void EditNetworkSetup::SLOT_AlterTab( const QString & S ) {
469 if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) { 471 if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) {
470 // switched to setup -> update CB and populate ws with 472 // switched to setup -> update CB and populate ws with
471 // forms for devices 473 // forms for devices
472 474
473 if( ! TmpIsValid ) { 475 if( ! TmpIsValid ) {
474 getTmpCollection(); 476 getTmpCollection();
475 477
476 // clear CB and Ws 478 // clear CB and Ws
477 { QWidget * W; 479 { QWidget * W;
478 int i = 0; 480 int i = 0;
479 481
480 Devices_CB->clear(); 482 Devices_CB->clear();
481 while( ( W = Setup_WS->widget( i ) ) ) { 483 while( ( W = Setup_WS->widget( i ) ) ) {
482 Setup_WS->removeWidget( W ); 484 Setup_WS->removeWidget( W );
483 i ++; 485 i ++;
484 } 486 }
485 } 487 }
486 488
487 // update CB 489 // update CB
488 // and populate WidgetStack 490 // and populate WidgetStack
489 { ANetNodeInstance * NNI; 491 { ANetNodeInstance * NNI;
490 QListIterator<ANetNodeInstance> it(TmpCollection); 492 QListIterator<ANetNodeInstance> it(TmpCollection);
491 int i = 0; 493 int i = 0;
492 QWidget * W; 494 QWidget * W;
493 495
494 for ( ; it.current(); ++it ) { 496 for ( ; it.current(); ++it ) {
495 NNI = it.current(); 497 NNI = it.current();
496 Devices_CB->insertItem( 498 Devices_CB->insertItem(
497 NSResources->getPixmap( NNI->nodeClass()->pixmapName() ), 499 NSResources->getPixmap( NNI->nodeClass()->pixmapName() ),
498 NNI->nodeClass()->name() 500 NNI->nodeClass()->name()
499 ); 501 );
500 502
501 // add edit widget 503 // add edit widget
502 W = NNI->edit( Setup_WS ); 504 W = NNI->edit( Setup_WS );
503 if( ! W) { 505 if( ! W) {
504 W = new QLabel( Setup_WS, 506 W = new QLabel( Setup_WS,
505 tr("No configuration required")); 507 tr("No configuration required"));
506 } 508 }
507 Setup_WS->addWidget( W , i ); 509 Setup_WS->addWidget( W , i );
508 i ++; 510 i ++;
509 } 511 }
510 } 512 }
511 Setup_WS->raiseWidget( 0 ); 513 Setup_WS->raiseWidget( 0 );
512 } // still valid 514 } // still valid
513 } 515 }
514} 516}
515 517
516// update visual feedback of selection state 518// update visual feedback of selection state
517void EditConnection::updateGUI( QListViewItem * it, ANetNode * NN ) { 519void EditNetworkSetup::updateGUI( QListViewItem * it, ANetNode * NN ) {
518 520
519 bool HCC = haveCompleteConfig( it ); 521 bool HCC = haveCompleteConfig( it );
520 Tab_TB->setTabEnabled( Setup_FRM, HCC ); 522 Tab_TB->setTabEnabled( Setup_FRM, HCC );
521 Setup_FRM->setEnabled( HCC ); 523 Setup_FRM->setEnabled( HCC );
522 524
523 // disable children of all siblings at same level 525 // disable children of all siblings at same level
524 QListViewItem * Sbl = it->parent()->firstChild(); 526 QListViewItem * Sbl = it->parent()->firstChild();
525 while( Sbl ) { 527 while( Sbl ) {
526 if ( Sbl != it ) { 528 if ( Sbl != it ) {
527 disableTree( Sbl->firstChild(), FALSE ); 529 disableTree( Sbl->firstChild(), FALSE );
528 Sbl->setSelectable( TRUE ); 530 Sbl->setSelectable( TRUE );
529 if( AutoCollapse ) 531 if( AutoCollapse )
530 Sbl->setOpen( FALSE ); 532 Sbl->setOpen( FALSE );
531 } 533 }
532 Sbl = Sbl->nextSibling(); 534 Sbl = Sbl->nextSibling();
533 } 535 }
534 536
535 // enable selected path (as deep as it goes 537 // enable selected path (as deep as it goes
536 it->setOpen( TRUE ); 538 it->setOpen( TRUE );
537 enablePath( it->firstChild(), 539 enablePath( it->firstChild(),
538 (it->depth()==1) ? 540 (it->depth()==1) ?
539 1 : // toplevel always alternatives 541 1 : // toplevel always alternatives
540 (NN->alternatives().size() > 1) ); 542 (NN->alternatives().size() > 1) );
541} 543}
542 544
543void EditConnection::disableTree( QListViewItem * it, bool Mode ) { 545void EditNetworkSetup::disableTree( QListViewItem * it, bool Mode ) {
544 while( it ) { 546 while( it ) {
545 // disable sbl's chidren 547 // disable sbl's chidren
546 it->setSelectable( Mode ); 548 it->setSelectable( Mode );
547 if( AutoCollapse ) 549 if( AutoCollapse )
548 it->setOpen( Mode ); 550 it->setOpen( Mode );
549 disableTree( it->firstChild(), Mode ); 551 disableTree( it->firstChild(), Mode );
550 it = it->nextSibling(); 552 it = it->nextSibling();
551 } 553 }
552} 554}
553 555
554// pah : ParentHasAlternatives 556// pah : ParentHasAlternatives
555void EditConnection::enablePath( QListViewItem * it, bool pha ) { 557void EditNetworkSetup::enablePath( QListViewItem * it, bool pha ) {
556 while( it ) { 558 while( it ) {
557 ANetNode * NN; 559 ANetNode * NN;
558 NN = (*Mapping)[it]; 560 NN = (*Mapping)[it];
559 if( NN ) { 561 if( NN ) {
560 if( pha ) { 562 if( pha ) {
561 bool doOn = ((QCheckListItem *)it)->isOn(); 563 bool doOn = ((QCheckListItem *)it)->isOn();
562 // we are a checklistitem for sure 564 // we are a checklistitem for sure
563 it->setSelectable( TRUE ); 565 it->setSelectable( TRUE );
564 if( AutoCollapse && ! doOn ) 566 if( AutoCollapse && ! doOn )
565 it->setOpen( doOn ); 567 it->setOpen( doOn );
566 if( doOn ) { 568 if( doOn ) {
567 // selected alternative 569 // selected alternative
568 enablePath( it->firstChild(), 570 enablePath( it->firstChild(),
569 NN->alternatives().size() > 1); 571 NN->alternatives().size() > 1);
570 } else { 572 } else {
571 // non-selected alternative 573 // non-selected alternative
572 disableTree( it->firstChild(), FALSE); 574 disableTree( it->firstChild(), FALSE);
573 } 575 }
574 } else { 576 } else {
575 // we are single subitem 577 // we are single subitem
576 it->setSelectable( TRUE ); 578 it->setSelectable( TRUE );
577 it->setOpen( TRUE ); 579 it->setOpen( TRUE );
578 enablePath( it->firstChild(), 580 enablePath( it->firstChild(),
579 NN->alternatives().size() > 1); 581 NN->alternatives().size() > 1);
580 } 582 }
581 } else { 583 } else {
582 // controller node 584 // controller node
583 it->setSelectable( TRUE ); 585 it->setSelectable( TRUE );
584 it->setOpen( TRUE ); 586 it->setOpen( TRUE );
585 enablePath( it->firstChild(), pha ); 587 enablePath( it->firstChild(), pha );
586 } 588 }
587 it = it->nextSibling(); 589 it = it->nextSibling();
588 } 590 }
589} 591}
590 592
591// do we have a complete configuration (all needs are provided for ?) 593// do we have a complete configuration (all needs are provided for ?)
592bool EditConnection::haveCompleteConfig( QListViewItem * it ) { 594bool EditNetworkSetup::haveCompleteConfig( QListViewItem * it ) {
593 595
594 // check if all below this level is selected 596 // check if all below this level is selected
595 it = ( it ) ?it : Nodes_LV->firstChild(); 597 it = ( it ) ?it : Nodes_LV->firstChild();
596 ANetNode *NN; 598 ANetNode *NN;
597 bool Found; 599 bool Found;
598 600
599 while ( it ) { 601 while ( it ) {
600 NN = (*Mapping)[it]; 602 NN = (*Mapping)[it];
601 if( NN == 0 ) { 603 if( NN == 0 ) {
602 // this item is a controller -> 604 // this item is a controller ->
603 // has radio items as children -> 605 // has radio items as children ->
604 // find selected one 606 // find selected one
605 it = it->firstChild(); 607 it = it->firstChild();
606 Found = 0; 608 Found = 0;
607 while( it ) { 609 while( it ) {
608 if( ((QCheckListItem *)it)->isOn() ) { 610 if( ((QCheckListItem *)it)->isOn() ) {
609 Found = 1; 611 Found = 1;
610 // go deeper 612 // go deeper
611 it = it->firstChild(); 613 it = it->firstChild();
612 break; 614 break;
613 } 615 }
614 it = it->nextSibling(); 616 it = it->nextSibling();
615 } 617 }
616 618
617 if( ! Found ) { 619 if( ! Found ) {
618 return 0; // no not complete -> a radio should have been chkd 620 return 0; // no not complete -> a radio should have been chkd
619 } 621 }
620 622
621 // it now contains selected radio 623 // it now contains selected radio
622 NN = (*Mapping)[it]; 624 NN = (*Mapping)[it];
623 } else { 625 } else {
624 // automatic selection 626 // automatic selection
625 it = it->firstChild(); 627 it = it->firstChild();
626 } 628 }
627 } 629 }
628 return 1; 630 return 1;
629} 631}
diff --git a/noncore/settings/networksettings2/editconnection.h b/noncore/settings/networksettings2/editconnection.h
index e8d7a2c..c2fc643 100644
--- a/noncore/settings/networksettings2/editconnection.h
+++ b/noncore/settings/networksettings2/editconnection.h
@@ -1,49 +1,49 @@
1#include "editconnectionGUI.h" 1#include "editconnectionGUI.h"
2 2
3#include <qptrdict.h> 3#include <qptrdict.h>
4#include <qvector.h> 4#include <qvector.h>
5#include "netnode.h" 5#include "netnode.h"
6 6
7class ANetNodeInstance; 7class ANetNodeInstance;
8class ANetNode; 8class ANetNode;
9class QListViewItem; 9class QListViewItem;
10class NetNodeLVI; 10class NetNodeLVI;
11class QCloseEvent; 11class QCloseEvent;
12 12
13class EditConnection : public EditConnectionGUI { 13class EditNetworkSetup : public EditNetworkSetupGUI {
14 14
15 Q_OBJECT 15 Q_OBJECT
16 16
17public : 17public :
18 18
19 EditConnection( QWidget * P ); 19 EditNetworkSetup( QWidget * P );
20 20
21 ANetNodeInstance * netNodeInstance( void ); 21 ANetNodeInstance * netNodeInstance( void );
22 void setConnection( NodeCollection * NC ); 22 void setNetworkSetup( NetworkSetup * NC );
23 NodeCollection * connection( void ); 23 NetworkSetup * networkSetup( void );
24 24
25public slots : 25public slots :
26 26
27 void SLOT_AutoCollapse( bool ); 27 void SLOT_AutoCollapse( bool );
28 void SLOT_SelectNode( QListViewItem * it ); 28 void SLOT_SelectNode( QListViewItem * it );
29 void SLOT_AlterTab( const QString & S ); 29 void SLOT_AlterTab( const QString & S );
30 virtual void accept( void ); 30 virtual void accept( void );
31 31
32private : 32private :
33 33
34 NodeCollection * getTmpCollection( void ); 34 NetworkSetup * getTmpCollection( void );
35 void updateGUI( QListViewItem * it, ANetNode * NN ); 35 void updateGUI( QListViewItem * it, ANetNode * NN );
36 void buildFullTree( void ); 36 void buildFullTree( void );
37 void buildSubTree( QListViewItem * Parent, ANetNode * NN ); 37 void buildSubTree( QListViewItem * Parent, ANetNode * NN );
38 void disableTree( QListViewItem * it, bool Mode); 38 void disableTree( QListViewItem * it, bool Mode);
39 void enablePath( QListViewItem * it, bool pha); 39 void enablePath( QListViewItem * it, bool pha);
40 40
41 bool haveCompleteConfig( QListViewItem * it ); 41 bool haveCompleteConfig( QListViewItem * it );
42 QPtrDict<ANetNode> * Mapping; 42 QPtrDict<ANetNode> * Mapping;
43 NodeCollection * SelectedNodes; 43 NetworkSetup * SelectedNodes;
44 bool TmpIsValid; 44 bool TmpIsValid;
45 NodeCollection TmpCollection; 45 NetworkSetup TmpCollection;
46 46
47 static bool AutoCollapse; 47 static bool AutoCollapse;
48 48
49}; 49};
diff --git a/noncore/settings/networksettings2/editconnectionGUI.ui b/noncore/settings/networksettings2/editconnectionGUI.ui
index dfb2596..5e50490 100644
--- a/noncore/settings/networksettings2/editconnectionGUI.ui
+++ b/noncore/settings/networksettings2/editconnectionGUI.ui
@@ -1,216 +1,216 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>EditConnectionGUI</class> 2<class>EditNetworkSetupGUI</class>
3<widget> 3<widget>
4 <class>QDialog</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>EditConnectionGUI</cstring> 7 <cstring>EditNetworkSetupGUI</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>427</width> 14 <width>427</width>
15 <height>523</height> 15 <height>523</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>sizePolicy</name> 19 <name>sizePolicy</name>
20 <sizepolicy> 20 <sizepolicy>
21 <hsizetype>7</hsizetype> 21 <hsizetype>7</hsizetype>
22 <vsizetype>7</vsizetype> 22 <vsizetype>7</vsizetype>
23 </sizepolicy> 23 </sizepolicy>
24 </property> 24 </property>
25 <property stdset="1"> 25 <property stdset="1">
26 <name>minimumSize</name> 26 <name>minimumSize</name>
27 <size> 27 <size>
28 <width>0</width> 28 <width>0</width>
29 <height>70</height> 29 <height>70</height>
30 </size> 30 </size>
31 </property> 31 </property>
32 <property stdset="1"> 32 <property stdset="1">
33 <name>caption</name> 33 <name>caption</name>
34 <string>Edit profile</string> 34 <string>Edit profile</string>
35 </property> 35 </property>
36 <property> 36 <property>
37 <name>layoutMargin</name> 37 <name>layoutMargin</name>
38 </property> 38 </property>
39 <property> 39 <property>
40 <name>layoutSpacing</name> 40 <name>layoutSpacing</name>
41 </property> 41 </property>
42 <vbox> 42 <vbox>
43 <property stdset="1"> 43 <property stdset="1">
44 <name>margin</name> 44 <name>margin</name>
45 <number>2</number> 45 <number>2</number>
46 </property> 46 </property>
47 <property stdset="1"> 47 <property stdset="1">
48 <name>spacing</name> 48 <name>spacing</name>
49 <number>2</number> 49 <number>2</number>
50 </property> 50 </property>
51 <widget> 51 <widget>
52 <class>QTabWidget</class> 52 <class>QTabWidget</class>
53 <property stdset="1"> 53 <property stdset="1">
54 <name>name</name> 54 <name>name</name>
55 <cstring>Tab_TB</cstring> 55 <cstring>Tab_TB</cstring>
56 </property> 56 </property>
57 <property> 57 <property>
58 <name>layoutMargin</name> 58 <name>layoutMargin</name>
59 </property> 59 </property>
60 <property> 60 <property>
61 <name>layoutSpacing</name> 61 <name>layoutSpacing</name>
62 </property> 62 </property>
63 <widget> 63 <widget>
64 <class>QWidget</class> 64 <class>QWidget</class>
65 <property stdset="1"> 65 <property stdset="1">
66 <name>name</name> 66 <name>name</name>
67 <cstring>tab</cstring> 67 <cstring>tab</cstring>
68 </property> 68 </property>
69 <attribute> 69 <attribute>
70 <name>title</name> 70 <name>title</name>
71 <string>Device Tree</string> 71 <string>Device Tree</string>
72 </attribute> 72 </attribute>
73 <vbox> 73 <vbox>
74 <property stdset="1"> 74 <property stdset="1">
75 <name>margin</name> 75 <name>margin</name>
76 <number>0</number> 76 <number>0</number>
77 </property> 77 </property>
78 <property stdset="1"> 78 <property stdset="1">
79 <name>spacing</name> 79 <name>spacing</name>
80 <number>2</number> 80 <number>2</number>
81 </property> 81 </property>
82 <widget> 82 <widget>
83 <class>QLayoutWidget</class> 83 <class>QLayoutWidget</class>
84 <property stdset="1"> 84 <property stdset="1">
85 <name>name</name> 85 <name>name</name>
86 <cstring>Layout2</cstring> 86 <cstring>Layout2</cstring>
87 </property> 87 </property>
88 <hbox> 88 <hbox>
89 <property stdset="1"> 89 <property stdset="1">
90 <name>margin</name> 90 <name>margin</name>
91 <number>0</number> 91 <number>0</number>
92 </property> 92 </property>
93 <property stdset="1"> 93 <property stdset="1">
94 <name>spacing</name> 94 <name>spacing</name>
95 <number>6</number> 95 <number>6</number>
96 </property> 96 </property>
97 <widget> 97 <widget>
98 <class>QLabel</class> 98 <class>QLabel</class>
99 <property stdset="1"> 99 <property stdset="1">
100 <name>name</name> 100 <name>name</name>
101 <cstring>Header_LBL</cstring> 101 <cstring>Header_LBL</cstring>
102 </property> 102 </property>
103 <property stdset="1"> 103 <property stdset="1">
104 <name>sizePolicy</name> 104 <name>sizePolicy</name>
105 <sizepolicy> 105 <sizepolicy>
106 <hsizetype>1</hsizetype> 106 <hsizetype>1</hsizetype>
107 <vsizetype>1</vsizetype> 107 <vsizetype>1</vsizetype>
108 </sizepolicy> 108 </sizepolicy>
109 </property> 109 </property>
110 <property stdset="1"> 110 <property stdset="1">
111 <name>frameShape</name> 111 <name>frameShape</name>
112 <enum>MShape</enum> 112 <enum>MShape</enum>
113 </property> 113 </property>
114 <property stdset="1"> 114 <property stdset="1">
115 <name>frameShadow</name> 115 <name>frameShadow</name>
116 <enum>MShadow</enum> 116 <enum>MShadow</enum>
117 </property> 117 </property>
118 <property stdset="1"> 118 <property stdset="1">
119 <name>text</name> 119 <name>text</name>
120 <string>Connection profile</string> 120 <string>NetworkSetup profile</string>
121 </property> 121 </property>
122 <property stdset="1"> 122 <property stdset="1">
123 <name>alignment</name> 123 <name>alignment</name>
124 <set>AlignVCenter|AlignLeft</set> 124 <set>AlignVCenter|AlignLeft</set>
125 </property> 125 </property>
126 <property> 126 <property>
127 <name>vAlign</name> 127 <name>vAlign</name>
128 </property> 128 </property>
129 </widget> 129 </widget>
130 <widget> 130 <widget>
131 <class>QLineEdit</class> 131 <class>QLineEdit</class>
132 <property stdset="1"> 132 <property stdset="1">
133 <name>name</name> 133 <name>name</name>
134 <cstring>Name_LE</cstring> 134 <cstring>Name_LE</cstring>
135 </property> 135 </property>
136 </widget> 136 </widget>
137 </hbox> 137 </hbox>
138 </widget> 138 </widget>
139 <widget> 139 <widget>
140 <class>QListView</class> 140 <class>QListView</class>
141 <column> 141 <column>
142 <property> 142 <property>
143 <name>text</name> 143 <name>text</name>
144 <string>Column 1</string> 144 <string>Column 1</string>
145 </property> 145 </property>
146 <property> 146 <property>
147 <name>clickable</name> 147 <name>clickable</name>
148 <bool>true</bool> 148 <bool>true</bool>
149 </property> 149 </property>
150 <property> 150 <property>
151 <name>resizeable</name> 151 <name>resizeable</name>
152 <bool>true</bool> 152 <bool>true</bool>
153 </property> 153 </property>
154 </column> 154 </column>
155 <property stdset="1"> 155 <property stdset="1">
156 <name>name</name> 156 <name>name</name>
157 <cstring>Nodes_LV</cstring> 157 <cstring>Nodes_LV</cstring>
158 </property> 158 </property>
159 <property stdset="1"> 159 <property stdset="1">
160 <name>sizePolicy</name> 160 <name>sizePolicy</name>
161 <sizepolicy> 161 <sizepolicy>
162 <hsizetype>7</hsizetype> 162 <hsizetype>7</hsizetype>
163 <vsizetype>7</vsizetype> 163 <vsizetype>7</vsizetype>
164 </sizepolicy> 164 </sizepolicy>
165 </property> 165 </property>
166 <property stdset="1"> 166 <property stdset="1">
167 <name>minimumSize</name> 167 <name>minimumSize</name>
168 <size> 168 <size>
169 <width>0</width> 169 <width>0</width>
170 <height>0</height> 170 <height>0</height>
171 </size> 171 </size>
172 </property> 172 </property>
173 <property stdset="1"> 173 <property stdset="1">
174 <name>maximumSize</name> 174 <name>maximumSize</name>
175 <size> 175 <size>
176 <width>32767</width> 176 <width>32767</width>
177 <height>32767</height> 177 <height>32767</height>
178 </size> 178 </size>
179 </property> 179 </property>
180 <property stdset="1"> 180 <property stdset="1">
181 <name>rootIsDecorated</name> 181 <name>rootIsDecorated</name>
182 <bool>true</bool> 182 <bool>true</bool>
183 </property> 183 </property>
184 </widget> 184 </widget>
185 <widget> 185 <widget>
186 <class>QLayoutWidget</class> 186 <class>QLayoutWidget</class>
187 <property stdset="1"> 187 <property stdset="1">
188 <name>name</name> 188 <name>name</name>
189 <cstring>Layout4</cstring> 189 <cstring>Layout4</cstring>
190 </property> 190 </property>
191 <hbox> 191 <hbox>
192 <property stdset="1"> 192 <property stdset="1">
193 <name>margin</name> 193 <name>margin</name>
194 <number>0</number> 194 <number>0</number>
195 </property> 195 </property>
196 <property stdset="1"> 196 <property stdset="1">
197 <name>spacing</name> 197 <name>spacing</name>
198 <number>6</number> 198 <number>6</number>
199 </property> 199 </property>
200 <spacer> 200 <spacer>
201 <property> 201 <property>
202 <name>name</name> 202 <name>name</name>
203 <cstring>Spacer1</cstring> 203 <cstring>Spacer1</cstring>
204 </property> 204 </property>
205 <property stdset="1"> 205 <property stdset="1">
206 <name>orientation</name> 206 <name>orientation</name>
207 <enum>Horizontal</enum> 207 <enum>Horizontal</enum>
208 </property> 208 </property>
209 <property stdset="1"> 209 <property stdset="1">
210 <name>sizeType</name> 210 <name>sizeType</name>
211 <enum>Expanding</enum> 211 <enum>Expanding</enum>
212 </property> 212 </property>
213 <property> 213 <property>
214 <name>sizeHint</name> 214 <name>sizeHint</name>
215 <size> 215 <size>
216 <width>20</width> 216 <width>20</width>
@@ -285,122 +285,122 @@
285 <name>margin</name> 285 <name>margin</name>
286 <number>0</number> 286 <number>0</number>
287 </property> 287 </property>
288 <property stdset="1"> 288 <property stdset="1">
289 <name>spacing</name> 289 <name>spacing</name>
290 <number>0</number> 290 <number>0</number>
291 </property> 291 </property>
292 <widget> 292 <widget>
293 <class>QFrame</class> 293 <class>QFrame</class>
294 <property stdset="1"> 294 <property stdset="1">
295 <name>name</name> 295 <name>name</name>
296 <cstring>Setup_FRM</cstring> 296 <cstring>Setup_FRM</cstring>
297 </property> 297 </property>
298 <property stdset="1"> 298 <property stdset="1">
299 <name>frameShape</name> 299 <name>frameShape</name>
300 <enum>NoFrame</enum> 300 <enum>NoFrame</enum>
301 </property> 301 </property>
302 <property stdset="1"> 302 <property stdset="1">
303 <name>frameShadow</name> 303 <name>frameShadow</name>
304 <enum>Plain</enum> 304 <enum>Plain</enum>
305 </property> 305 </property>
306 <property stdset="1"> 306 <property stdset="1">
307 <name>lineWidth</name> 307 <name>lineWidth</name>
308 <number>0</number> 308 <number>0</number>
309 </property> 309 </property>
310 <property stdset="1"> 310 <property stdset="1">
311 <name>margin</name> 311 <name>margin</name>
312 <number>0</number> 312 <number>0</number>
313 </property> 313 </property>
314 <property stdset="1"> 314 <property stdset="1">
315 <name>midLineWidth</name> 315 <name>midLineWidth</name>
316 <number>0</number> 316 <number>0</number>
317 </property> 317 </property>
318 <property> 318 <property>
319 <name>layoutMargin</name> 319 <name>layoutMargin</name>
320 </property> 320 </property>
321 <property> 321 <property>
322 <name>layoutSpacing</name> 322 <name>layoutSpacing</name>
323 </property> 323 </property>
324 <vbox> 324 <vbox>
325 <property stdset="1"> 325 <property stdset="1">
326 <name>margin</name> 326 <name>margin</name>
327 <number>2</number> 327 <number>2</number>
328 </property> 328 </property>
329 <property stdset="1"> 329 <property stdset="1">
330 <name>spacing</name> 330 <name>spacing</name>
331 <number>4</number> 331 <number>4</number>
332 </property> 332 </property>
333 <widget> 333 <widget>
334 <class>QComboBox</class> 334 <class>QComboBox</class>
335 <property stdset="1"> 335 <property stdset="1">
336 <name>name</name> 336 <name>name</name>
337 <cstring>Devices_CB</cstring> 337 <cstring>Devices_CB</cstring>
338 </property> 338 </property>
339 </widget> 339 </widget>
340 <widget> 340 <widget>
341 <class>QWidgetStack</class> 341 <class>QWidgetStack</class>
342 <property stdset="1"> 342 <property stdset="1">
343 <name>name</name> 343 <name>name</name>
344 <cstring>Setup_WS</cstring> 344 <cstring>Setup_WS</cstring>
345 </property> 345 </property>
346 </widget> 346 </widget>
347 </vbox> 347 </vbox>
348 </widget> 348 </widget>
349 </vbox> 349 </vbox>
350 </widget> 350 </widget>
351 </widget> 351 </widget>
352 </vbox> 352 </vbox>
353</widget> 353</widget>
354<customwidgets> 354<customwidgets>
355 <customwidget> 355 <customwidget>
356 <class>QWidgetStack</class> 356 <class>QWidgetStack</class>
357 <header location="global">qwidgetstack.h</header> 357 <header location="global">qwidgetstack.h</header>
358 <sizehint> 358 <sizehint>
359 <width>-1</width> 359 <width>-1</width>
360 <height>-1</height> 360 <height>-1</height>
361 </sizehint> 361 </sizehint>
362 <container>0</container> 362 <container>0</container>
363 <sizepolicy> 363 <sizepolicy>
364 <hordata>7</hordata> 364 <hordata>7</hordata>
365 <verdata>7</verdata> 365 <verdata>7</verdata>
366 </sizepolicy> 366 </sizepolicy>
367 <pixmap>image0</pixmap> 367 <pixmap>image0</pixmap>
368 <slot access="public">raiseWidget( int )</slot> 368 <slot access="public">raiseWidget( int )</slot>
369 </customwidget> 369 </customwidget>
370</customwidgets> 370</customwidgets>
371<images> 371<images>
372 <image> 372 <image>
373 <name>image0</name> 373 <name>image0</name>
374 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> 374 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
375 </image> 375 </image>
376</images> 376</images>
377<connections> 377<connections>
378 <connection> 378 <connection>
379 <sender>Nodes_LV</sender> 379 <sender>Nodes_LV</sender>
380 <signal>clicked(QListViewItem*)</signal> 380 <signal>clicked(QListViewItem*)</signal>
381 <receiver>EditConnectionGUI</receiver> 381 <receiver>EditNetworkSetupGUI</receiver>
382 <slot>SLOT_SelectNode( QListViewItem *)</slot> 382 <slot>SLOT_SelectNode( QListViewItem *)</slot>
383 </connection> 383 </connection>
384 <connection> 384 <connection>
385 <sender>AutoCollapse_CB</sender> 385 <sender>AutoCollapse_CB</sender>
386 <signal>toggled(bool)</signal> 386 <signal>toggled(bool)</signal>
387 <receiver>EditConnectionGUI</receiver> 387 <receiver>EditNetworkSetupGUI</receiver>
388 <slot>SLOT_AutoCollapse( bool)</slot> 388 <slot>SLOT_AutoCollapse( bool)</slot>
389 </connection> 389 </connection>
390 <connection> 390 <connection>
391 <sender>Devices_CB</sender> 391 <sender>Devices_CB</sender>
392 <signal>activated(int)</signal> 392 <signal>activated(int)</signal>
393 <receiver>Setup_WS</receiver> 393 <receiver>Setup_WS</receiver>
394 <slot>raiseWidget( int )</slot> 394 <slot>raiseWidget( int )</slot>
395 </connection> 395 </connection>
396 <connection> 396 <connection>
397 <sender>Tab_TB</sender> 397 <sender>Tab_TB</sender>
398 <signal>selected(const QString&amp;)</signal> 398 <signal>selected(const QString&amp;)</signal>
399 <receiver>EditConnectionGUI</receiver> 399 <receiver>EditNetworkSetupGUI</receiver>
400 <slot>SLOT_AlterTab( const QString &amp; )</slot> 400 <slot>SLOT_AlterTab( const QString &amp; )</slot>
401 </connection> 401 </connection>
402 <slot access="public">SLOT_AlterTab( const QString &amp; )</slot> 402 <slot access="public">SLOT_AlterTab( const QString &amp; )</slot>
403 <slot access="public">SLOT_AutoCollapse( bool)</slot> 403 <slot access="public">SLOT_AutoCollapse( bool)</slot>
404 <slot access="public">SLOT_SelectNode( QListViewItem *)</slot> 404 <slot access="public">SLOT_SelectNode( QListViewItem *)</slot>
405</connections> 405</connections>
406</UI> 406</UI>
diff --git a/noncore/settings/networksettings2/gprs/GPRS_NN.cpp b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp
index e9553a6..374cf5a 100644
--- a/noncore/settings/networksettings2/gprs/GPRS_NN.cpp
+++ b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp
@@ -1,78 +1,78 @@
1#include <resources.h> 1#include <resources.h>
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <netnode.h> 3#include <netnode.h>
4#include "GPRS_NN.h" 4#include "GPRS_NN.h"
5#include "GPRS_NNI.h" 5#include "GPRS_NNI.h"
6 6
7#include "netnodeinterface.h" 7#include "netnodeinterface.h"
8 8
9static const char * GPRSNeeds[] = 9static const char * GPRSNeeds[] =
10 { "GPRS", 10 { "GPRS",
11 0 11 0
12 }; 12 };
13 13
14static const char * GPRSProvides[] = 14static const char * GPRSProvides[] =
15 { "connection", 15 { "NetworkSetup",
16 0 16 0
17 }; 17 };
18 18
19/** 19/**
20 * Constructor, find all of the possible interfaces 20 * Constructor, find all of the possible interfaces
21 */ 21 */
22GPRSNetNode::GPRSNetNode() : ANetNode(tr("GPRS capable device")) { 22GPRSNetNode::GPRSNetNode() : ANetNode(tr("GPRS capable device")) {
23 NSResources->addSystemFile( 23 NSResources->addSystemFile(
24 "pap-secrets", "/etc/ppp/pap-secrets", 0 ); 24 "pap-secrets", "/etc/ppp/pap-secrets", 0 );
25} 25}
26 26
27/** 27/**
28 * Delete any interfaces that we own. 28 * Delete any interfaces that we own.
29 */ 29 */
30GPRSNetNode::~GPRSNetNode(){ 30GPRSNetNode::~GPRSNetNode(){
31} 31}
32 32
33const QString GPRSNetNode::nodeDescription(){ 33const QString GPRSNetNode::nodeDescription(){
34 return tr("\ 34 return tr("\
35<p>provides access to a GPRS capable device.</p>\ 35<p>provides access to a GPRS capable device.</p>\
36" 36"
37); 37);
38} 38}
39 39
40ANetNodeInstance * GPRSNetNode::createInstance( void ) { 40ANetNodeInstance * GPRSNetNode::createInstance( void ) {
41 return new AGPRSDevice( this ); 41 return new AGPRSDevice( this );
42} 42}
43 43
44bool GPRSNetNode::hasDataForFile( SystemFile & S ) { 44bool GPRSNetNode::hasDataForFile( SystemFile & S ) {
45 return S.name() == "pap-secrets"; 45 return S.name() == "pap-secrets";
46} 46}
47 47
48short GPRSNetNode::generateFile( SystemFile & , 48short GPRSNetNode::generateFile( SystemFile & ,
49 ANetNodeInstance * , 49 ANetNodeInstance * ,
50 long ) { 50 long ) {
51 51
52 return 0; 52 return 0;
53} 53}
54 54
55const char ** GPRSNetNode::needs( void ) { 55const char ** GPRSNetNode::needs( void ) {
56 return GPRSNeeds; 56 return GPRSNeeds;
57} 57}
58 58
59const char ** GPRSNetNode::provides( void ) { 59const char ** GPRSNetNode::provides( void ) {
60 return GPRSProvides; 60 return GPRSProvides;
61} 61}
62 62
63void GPRSNetNode::setSpecificAttribute( QString & , QString & ) { 63void GPRSNetNode::setSpecificAttribute( QString & , QString & ) {
64} 64}
65 65
66void GPRSNetNode::saveSpecificAttribute( QTextStream & ) { 66void GPRSNetNode::saveSpecificAttribute( QTextStream & ) {
67} 67}
68 68
69QStringList GPRSNetNode::properFiles( void ) { 69QStringList GPRSNetNode::properFiles( void ) {
70 QStringList SL; 70 QStringList SL;
71 71
72 SL << "peers"; 72 SL << "peers";
73 SL << "chatscripts"; 73 SL << "chatscripts";
74 SL << "extra"; 74 SL << "extra";
75 return SL; 75 return SL;
76} 76}
77 77
78OPIE_NS2_PLUGIN( NetNodeInterface_T<GPRSNetNode> ) 78OPIE_NS2_PLUGIN( NetNodeInterface_T<GPRSNetNode> )
diff --git a/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp b/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp
index 2f61cba..bf8cc59 100644
--- a/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp
+++ b/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp
@@ -29,203 +29,203 @@ void AGPRSDevice::setSpecificAttribute( QString & A, QString & V ) {
29 Data.DNS1 = V; 29 Data.DNS1 = V;
30 } else if( A == "defaultgateway" ) { 30 } else if( A == "defaultgateway" ) {
31 Data.DefaultGateway = (V=="yes"); 31 Data.DefaultGateway = (V=="yes");
32 } else if( A == "setifset" ) { 32 } else if( A == "setifset" ) {
33 Data.SetIfSet = (V == "yes"); 33 Data.SetIfSet = (V == "yes");
34 } else if( A == "routes" ) { 34 } else if( A == "routes" ) {
35 Data.Routing.resize( V.toULong() ); 35 Data.Routing.resize( V.toULong() );
36 } else if( A.startsWith( "route" ) ) { 36 } else if( A.startsWith( "route" ) ) {
37 QStringList SL = QStringList::split( "/", V ); 37 QStringList SL = QStringList::split( "/", V );
38 GPRSRoutingEntry * E = new GPRSRoutingEntry; 38 GPRSRoutingEntry * E = new GPRSRoutingEntry;
39 39
40 E->Address = SL[0]; 40 E->Address = SL[0];
41 E->Mask = SL[1].toULong(); 41 E->Mask = SL[1].toULong();
42 42
43 Data.Routing.insert( A.mid(5).toULong(), E ); 43 Data.Routing.insert( A.mid(5).toULong(), E );
44 } else if( A == "debug" ) { 44 } else if( A == "debug" ) {
45 Data.Debug = V.toShort(); 45 Data.Debug = V.toShort();
46 } 46 }
47} 47}
48 48
49void AGPRSDevice::saveSpecificAttribute( QTextStream & TS ) { 49void AGPRSDevice::saveSpecificAttribute( QTextStream & TS ) {
50 TS << "apn=" << Data.APN << endl; 50 TS << "apn=" << Data.APN << endl;
51 TS << "user=" << Data.User << endl; 51 TS << "user=" << Data.User << endl;
52 TS << "password=" << Data.Password << endl; 52 TS << "password=" << Data.Password << endl;
53 TS << "dns1=" << Data.DNS1 << endl; 53 TS << "dns1=" << Data.DNS1 << endl;
54 TS << "dns2=" << Data.DNS2 << endl; 54 TS << "dns2=" << Data.DNS2 << endl;
55 TS << "defaultgateway=" << ( (Data.DefaultGateway) ? "yes" : "no" ) << endl; 55 TS << "defaultgateway=" << ( (Data.DefaultGateway) ? "yes" : "no" ) << endl;
56 TS << "setifset=" << ((Data.SetIfSet) ? "yes" : "no") << endl; 56 TS << "setifset=" << ((Data.SetIfSet) ? "yes" : "no") << endl;
57 TS << "debug=" << Data.Debug << endl; 57 TS << "debug=" << Data.Debug << endl;
58 58
59 TS << "routes=" << Data.Routing.count() << oendl; 59 TS << "routes=" << Data.Routing.count() << oendl;
60 for( unsigned int i = 0; i < Data.Routing.count(); i ++ ) { 60 for( unsigned int i = 0; i < Data.Routing.count(); i ++ ) {
61 TS << "route" << i << "=" 61 TS << "route" << i << "="
62 << Data.Routing[i]->Address 62 << Data.Routing[i]->Address
63 << "/" 63 << "/"
64 << Data.Routing[i]->Mask 64 << Data.Routing[i]->Mask
65 << oendl; 65 << oendl;
66 } 66 }
67} 67}
68 68
69QWidget * AGPRSDevice::edit( QWidget * parent ) { 69QWidget * AGPRSDevice::edit( QWidget * parent ) {
70 GUI = new GPRSEdit( parent ); 70 GUI = new GPRSEdit( parent );
71 GUI->showData( Data ); 71 GUI->showData( Data );
72 return GUI; 72 return GUI;
73} 73}
74 74
75QString AGPRSDevice::acceptable( void ) { 75QString AGPRSDevice::acceptable( void ) {
76 return ( GUI ) ? GUI->acceptable( ) : QString(); 76 return ( GUI ) ? GUI->acceptable( ) : QString();
77} 77}
78 78
79void AGPRSDevice::commit( void ) { 79void AGPRSDevice::commit( void ) {
80 if( GUI && GUI->commit( Data ) ) 80 if( GUI && GUI->commit( Data ) )
81 setModified( 1 ); 81 setModified( 1 );
82} 82}
83 83
84bool AGPRSDevice::hasDataForFile( SystemFile & S ) { 84bool AGPRSDevice::hasDataForFile( SystemFile & S ) {
85 return S.name() == "pap-secrets" || 85 return S.name() == "pap-secrets" ||
86 S.name() == "peers" || 86 S.name() == "peers" ||
87 S.name() == "extra" || 87 S.name() == "extra" ||
88 S.name() == "chatscripts" ; 88 S.name() == "chatscripts" ;
89} 89}
90 90
91short AGPRSDevice::generateFile( SystemFile & SF, 91short AGPRSDevice::generateFile( SystemFile & SF,
92 long 92 long
93 ) { 93 ) {
94 94
95 if( SF.name() == "pap-secrets" ) { 95 if( SF.name() == "pap-secrets" ) {
96 SF << Data.User 96 SF << Data.User
97 << " * " 97 << " * "
98 << Data.Password 98 << Data.Password
99 << " *" 99 << " *"
100 << endl; 100 << endl;
101 return 0; 101 return 0;
102 } else if( SF.name() == "chatscripts" ) { 102 } else if( SF.name() == "chatscripts" ) {
103 SF << "SAY \"Starting\\n\"" << oendl; 103 SF << "SAY \"Starting\\n\"" << oendl;
104 SF << "ECHO OFF" << oendl; 104 SF << "ECHO OFF" << oendl;
105 SF << "ABORT BUSY" << oendl; 105 SF << "ABORT BUSY" << oendl;
106 SF << "ABORT ERROR" << oendl; 106 SF << "ABORT ERROR" << oendl;
107 SF << "ABORT VOICE" << oendl; 107 SF << "ABORT VOICE" << oendl;
108 SF << "ABORT \"NO CARRIER\"" << oendl; 108 SF << "ABORT \"NO CARRIER\"" << oendl;
109 SF << "ABORT \"NO DIALTONE\"" << oendl; 109 SF << "ABORT \"NO DIALTONE\"" << oendl;
110 SF << "\"\" AT" << oendl; 110 SF << "\"\" AT" << oendl;
111 SF << "OK AT+CGATT=1" << oendl; 111 SF << "OK AT+CGATT=1" << oendl;
112 SF << "OK AT+CGDCONT=1,\"IP\",\"" 112 SF << "OK AT+CGDCONT=1,\"IP\",\""
113 << Data.APN 113 << Data.APN
114 << "\"" 114 << "\""
115 << oendl; 115 << oendl;
116 SF << "OK ATD*99***1#\\n" << oendl; 116 SF << "OK ATD*99***1#\\n" << oendl;
117 SF << "TIMEOUT 10" << oendl; 117 SF << "TIMEOUT 10" << oendl;
118 SF << "CONNECT \"\"" << oendl; 118 SF << "CONNECT \"\"" << oendl;
119 SF << "SAY \"READY\\n\"" << oendl; 119 SF << "SAY \"READY\\n\"" << oendl;
120 return 0; 120 return 0;
121 } else if( SF.name() == "peers" ) { 121 } else if( SF.name() == "peers" ) {
122 SF << "noauth" << oendl; 122 SF << "noauth" << oendl;
123 SF << "user " << Data.User << oendl; 123 SF << "user " << Data.User << oendl;
124 SF << "connect \"/usr/sbin/chat -s -v -f /etc/chatscripts/" 124 SF << "connect \"/usr/sbin/chat -s -v -f /etc/chatscripts/"
125 << removeSpaces( connection()->name() ) 125 << removeSpaces( networkSetup()->name() )
126 << "\"" 126 << "\""
127 << oendl; 127 << oendl;
128 SF << "ipcp-accept-local" << oendl; 128 SF << "ipcp-accept-local" << oendl;
129 SF << "ipcp-accept-remote" << oendl; 129 SF << "ipcp-accept-remote" << oendl;
130 if( Data.DefaultGateway ) { 130 if( Data.DefaultGateway ) {
131 SF << "defaultroute" << oendl; 131 SF << "defaultroute" << oendl;
132 if( Data.SetIfSet ) { 132 if( Data.SetIfSet ) {
133 SF << "replacedefaultroute" << oendl; 133 SF << "replacedefaultroute" << oendl;
134 } 134 }
135 } 135 }
136 if( Data.Debug ) { 136 if( Data.Debug ) {
137 SF << "logfile /tmp/" 137 SF << "logfile /tmp/"
138 << removeSpaces( connection()->name() ) 138 << removeSpaces( networkSetup()->name() )
139 << oendl; 139 << oendl;
140 for( int i = 0; i < Data.Debug; i ++ ) { 140 for( int i = 0; i < Data.Debug; i ++ ) {
141 SF << "debug" << oendl; 141 SF << "debug" << oendl;
142 } 142 }
143 } 143 }
144 SF << "nocrtscts" << oendl; 144 SF << "nocrtscts" << oendl;
145 SF << "local" << oendl; 145 SF << "local" << oendl;
146 SF << "lcp-echo-interval 0" << oendl; 146 SF << "lcp-echo-interval 0" << oendl;
147 SF << "lcp-echo-failure 0" << oendl; 147 SF << "lcp-echo-failure 0" << oendl;
148 SF << "usepeerdns" << oendl; 148 SF << "usepeerdns" << oendl;
149 SF << "linkname " << removeSpaces( connection()->name() ) << oendl; 149 SF << "linkname " << removeSpaces( networkSetup()->name() ) << oendl;
150 SF << "nopersist" << oendl; 150 SF << "nopersist" << oendl;
151 SF << "ipparam " << removeSpaces( connection()->name() ) <<oendl; 151 SF << "ipparam " << removeSpaces( networkSetup()->name() ) <<oendl;
152 SF << "maxfail 1" << oendl; 152 SF << "maxfail 1" << oendl;
153 return 0; 153 return 0;
154 } else if( SF.name() == "extra" ) { 154 } else if( SF.name() == "extra" ) {
155 unsigned long Bits; 155 unsigned long Bits;
156 // generate 'fixed' settings 156 // generate 'fixed' settings
157 for( unsigned int i = 0 ; 157 for( unsigned int i = 0 ;
158 i < Data.Routing.count(); 158 i < Data.Routing.count();
159 i ++ ) { 159 i ++ ) {
160 if( Data.Routing[i]->Mask == 32 ) { 160 if( Data.Routing[i]->Mask == 32 ) {
161 Bits = 0xffffffff; 161 Bits = 0xffffffff;
162 } else { 162 } else {
163 Bits = ~ ((1 << ((32-Data.Routing[i]->Mask))) - 1); 163 Bits = ~ ((1 << ((32-Data.Routing[i]->Mask))) - 1);
164 } 164 }
165 SF << "route add -net " 165 SF << "route add -net "
166 << Data.Routing[i]->Address 166 << Data.Routing[i]->Address
167 << " netmask " 167 << " netmask "
168 << ((Bits&0xff000000)>>24) 168 << ((Bits&0xff000000)>>24)
169 << "." 169 << "."
170 << ((Bits&0x00ff0000)>>16) 170 << ((Bits&0x00ff0000)>>16)
171 << "." 171 << "."
172 << ((Bits&0x0000ff00)>>8) 172 << ((Bits&0x0000ff00)>>8)
173 << "." 173 << "."
174 << ((Bits&0x000000ff)) 174 << ((Bits&0x000000ff))
175 << " gw $PPP_REMOTE" 175 << " gw $PPP_REMOTE"
176 << oendl; 176 << oendl;
177 SF << "route del -net " 177 SF << "route del -net "
178 << Data.Routing[i]->Address 178 << Data.Routing[i]->Address
179 << " netmask " 179 << " netmask "
180 << ((Bits&0xff000000)>>24) 180 << ((Bits&0xff000000)>>24)
181 << "." 181 << "."
182 << ((Bits&0x00ff0000)>>16) 182 << ((Bits&0x00ff0000)>>16)
183 << "." 183 << "."
184 << ((Bits&0x0000ff00)>>8) 184 << ((Bits&0x0000ff00)>>8)
185 << "." 185 << "."
186 << ((Bits&0x000000ff)) 186 << ((Bits&0x000000ff))
187 << " gw $PPP_REMOTE" 187 << " gw $PPP_REMOTE"
188 << oendl; 188 << oendl;
189 } 189 }
190 190
191 if( ! Data.DNS1.isEmpty() ) { 191 if( ! Data.DNS1.isEmpty() ) {
192 SF << "nameserver " 192 SF << "nameserver "
193 << Data.DNS1 193 << Data.DNS1
194 << " # profile " 194 << " # profile "
195 << removeSpaces( connection()->name() ) 195 << removeSpaces( networkSetup()->name() )
196 <<oendl; 196 <<oendl;
197 } 197 }
198 198
199 if( ! Data.DNS2.isEmpty() ) { 199 if( ! Data.DNS2.isEmpty() ) {
200 SF << "nameserver " 200 SF << "nameserver "
201 << Data.DNS2 201 << Data.DNS2
202 << " # profile " 202 << " # profile "
203 << removeSpaces( connection()->name() ) 203 << removeSpaces( networkSetup()->name() )
204 <<oendl; 204 <<oendl;
205 } 205 }
206 } 206 }
207 return 1; 207 return 1;
208} 208}
209 209
210bool AGPRSDevice::openFile( SystemFile & SF ) { 210bool AGPRSDevice::openFile( SystemFile & SF ) {
211 if( SF.name() == "peers" ) { 211 if( SF.name() == "peers" ) {
212 SF.setPath( 212 SF.setPath(
213 QString( "/etc/ppp/peers/" ) + 213 QString( "/etc/ppp/peers/" ) +
214 removeSpaces( connection()->name() ) 214 removeSpaces( networkSetup()->name() )
215 ); 215 );
216 return 1; 216 return 1;
217 } else if ( SF.name() == "chatscripts" ) { 217 } else if ( SF.name() == "chatscripts" ) {
218 SF.setPath( 218 SF.setPath(
219 QString( "/etc/chatscripts/" ) + 219 QString( "/etc/chatscripts/" ) +
220 removeSpaces( connection()->name() ) 220 removeSpaces( networkSetup()->name() )
221 ); 221 );
222 return 1; 222 return 1;
223 } else if ( SF.name() == "extra" ) { 223 } else if ( SF.name() == "extra" ) {
224 SF.setPath( 224 SF.setPath(
225 QString( "/etc/ppp/" ) + 225 QString( "/etc/ppp/" ) +
226 removeSpaces( connection()->name() ) + ".fixed" 226 removeSpaces( networkSetup()->name() ) + ".fixed"
227 ); 227 );
228 return 1; 228 return 1;
229 } 229 }
230 return 0; 230 return 0;
231} 231}
diff --git a/noncore/settings/networksettings2/gprs/GPRSrun.cpp b/noncore/settings/networksettings2/gprs/GPRSrun.cpp
index cccc71a..fd61f3a 100644
--- a/noncore/settings/networksettings2/gprs/GPRSrun.cpp
+++ b/noncore/settings/networksettings2/gprs/GPRSrun.cpp
@@ -1,105 +1,105 @@
1#include <sys/types.h> 1#include <sys/types.h>
2#include <signal.h> 2#include <signal.h>
3#include <errno.h> 3#include <errno.h>
4#include <qdir.h> 4#include <qdir.h>
5#include <system.h> 5#include <system.h>
6#include <resources.h> 6#include <resources.h>
7#include <netnode.h> 7#include <netnode.h>
8#include "GPRSrun.h" 8#include "GPRSrun.h"
9 9
10State_t GPRSRun::detectState( void ) { 10State_t GPRSRun::detectState( void ) {
11 11
12 // is pppd still running ? 12 // is pppd still running ?
13 // is rfcomm still active 13 // is rfcomm still active
14 NodeCollection * NC = nodeCollection(); 14 NetworkSetup * NC = networkSetup();
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 odebug << "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 odebug << "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 odebug << "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 }
59 } // else pppd is down 59 } // else pppd is down
60 } 60 }
61 NC->assignInterface( 0 ); 61 NC->assignInterface( 0 );
62 return Unknown; 62 return Unknown;
63} 63}
64 64
65QString GPRSRun::setMyState( NodeCollection * NC, Action_t A , bool ) { 65QString GPRSRun::setMyState( NetworkSetup * NC, Action_t A , bool ) {
66 66
67 if( A == Up ) { 67 if( A == Up ) {
68 // start ppp on deviceFile 68 // start ppp on deviceFile
69 QStringList SL; 69 QStringList SL;
70 SL << "pon" 70 SL << "pon"
71 << removeSpaces( NC->name() ) 71 << removeSpaces( NC->name() )
72 << NC->device()->deviceFile(); 72 << NC->device()->deviceFile();
73 73
74 if( ! NSResources->system().execAsUser( SL ) ) { 74 if( ! NSResources->system().execAsUser( SL ) ) {
75 return QString("Cannot start pppd for %1").arg(NC->name()); 75 return QString("Cannot start pppd for %1").arg(NC->name());
76 } 76 }
77 } else if ( A == Down ) { 77 } else if ( A == Down ) {
78 if( PPPPid == 0 ) { 78 if( PPPPid == 0 ) {
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 odebug << "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 ) {
104 return handlesInterface( I->Name ); 104 return handlesInterface( I->Name );
105} 105}
diff --git a/noncore/settings/networksettings2/gprs/GPRSrun.h b/noncore/settings/networksettings2/gprs/GPRSrun.h
index 817f8a9..c3c2015 100644
--- a/noncore/settings/networksettings2/gprs/GPRSrun.h
+++ b/noncore/settings/networksettings2/gprs/GPRSrun.h
@@ -1,34 +1,34 @@
1#include <netnode.h> 1#include <netnode.h>
2#include <qregexp.h> 2#include <qregexp.h>
3#include "GPRSdata.h" 3#include "GPRSdata.h"
4 4
5class GPRSRun : public RuntimeInfo { 5class GPRSRun : public RuntimeInfo {
6 6
7public : 7public :
8 8
9 GPRSRun( ANetNodeInstance * NNI, 9 GPRSRun( ANetNodeInstance * NNI,
10 GPRSData & D ) : RuntimeInfo( NNI ), 10 GPRSData & D ) : RuntimeInfo( NNI ),
11 Pat( "ppp[0-9]" ) { 11 Pat( "ppp[0-9]" ) {
12 PPPPid = 0; 12 PPPPid = 0;
13 } 13 }
14 14
15 bool handlesInterface( const QString & I ); 15 bool handlesInterface( const QString & I );
16 bool handlesInterface( InterfaceInfo * ); 16 bool handlesInterface( InterfaceInfo * );
17 17
18 virtual RuntimeInfo * device( void ) 18 virtual RuntimeInfo * device( void )
19 { return this; } 19 { return this; }
20 virtual RuntimeInfo * connection( void ) 20 virtual RuntimeInfo * connection( void )
21 { return this; } 21 { return this; }
22 22
23 State_t detectState( void ); 23 State_t detectState( void );
24 24
25protected : 25protected :
26 26
27 QString setMyState( NodeCollection * , Action_t, bool ); 27 QString setMyState( NetworkSetup * , Action_t, bool );
28 28
29private : 29private :
30 30
31 QRegExp Pat; 31 QRegExp Pat;
32 size_t PPPPid; 32 size_t PPPPid;
33 33
34}; 34};
diff --git a/noncore/settings/networksettings2/irda/irdarun.h b/noncore/settings/networksettings2/irda/irdarun.h
index d3b714b..e5ba79a 100644
--- a/noncore/settings/networksettings2/irda/irdarun.h
+++ b/noncore/settings/networksettings2/irda/irdarun.h
@@ -1,25 +1,25 @@
1#include <netnode.h> 1#include <netnode.h>
2#include "irdadata.h" 2#include "irdadata.h"
3 3
4class IRDARun : public RuntimeInfo { 4class IRDARun : public RuntimeInfo {
5 5
6public : 6public :
7 7
8 IRDARun( ANetNodeInstance * NNI, 8 IRDARun( ANetNodeInstance * NNI,
9 IRDAData & Data ) : RuntimeInfo( NNI ) 9 IRDAData & Data ) : RuntimeInfo( NNI )
10 { } 10 { }
11 11
12 virtual RuntimeInfo * line( void ) 12 virtual RuntimeInfo * line( void )
13 { return this; } 13 { return this; }
14 14
15 virtual QString deviceFile( void ) 15 virtual QString deviceFile( void )
16 { return QString( "/dev/irda" ); } 16 { return QString( "/dev/irda" ); }
17 17
18 State_t detectState( void ) 18 State_t detectState( void )
19 { return Unknown; } 19 { return Unknown; }
20 20
21protected : 21protected :
22 22
23 QString setMyState( NodeCollection * , Action_t, bool ) 23 QString setMyState( NetworkSetup * , Action_t, bool )
24 { return QString(); } 24 { return QString(); }
25}; 25};
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.cpp b/noncore/settings/networksettings2/lancard/lancardrun.cpp
index 8157dce..8a71aa9 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.cpp
+++ b/noncore/settings/networksettings2/lancard/lancardrun.cpp
@@ -1,148 +1,148 @@
1#include <qfile.h> 1#include <qfile.h>
2#include <qtextstream.h> 2#include <qtextstream.h>
3#include <qstringlist.h> 3#include <qstringlist.h>
4#include <resources.h> 4#include <resources.h>
5#include "lancardrun.h" 5#include "lancardrun.h"
6 6
7State_t LanCardRun::detectState( void ) { 7State_t LanCardRun::detectState( void ) {
8 8
9 // unavailable : no card found 9 // unavailable : no card found
10 // available : card found and assigned to us or free 10 // available : card found and assigned to us or free
11 // up : card found and assigned to us and up 11 // up : card found and assigned to us and up
12 12
13 NodeCollection * NC = nodeCollection(); 13 NetworkSetup * NC = networkSetup();
14 QString S = QString( "/tmp/profile-%1.up" ). 14 QString S = QString( "/tmp/profile-%1.up" ).
15 arg( NC->number()); 15 arg( NC->number());
16 System & Sys = NSResources->system(); 16 System & Sys = NSResources->system();
17 InterfaceInfo * Run; 17 InterfaceInfo * Run;
18 18
19 QFile F( S ); 19 QFile F( S );
20 20
21 if( F.open( IO_ReadOnly ) ) { 21 if( F.open( IO_ReadOnly ) ) {
22 // could open file -> read interface and assign 22 // could open file -> read interface and assign
23 QString X; 23 QString X;
24 QTextStream TS(&F); 24 QTextStream TS(&F);
25 X = TS.readLine(); 25 X = TS.readLine();
26 // find interface 26 // find interface
27 if( handlesInterface( X ) ) { 27 if( handlesInterface( X ) ) {
28 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 28 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
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 (Run->IsUp) ? IsUp : Available; 34 return (Run->IsUp) ? IsUp : Available;
35 } 35 }
36 } 36 }
37 } 37 }
38 } 38 }
39 39
40 if( ( Run = NC->assignedInterface() ) ) { 40 if( ( Run = NC->assignedInterface() ) ) {
41 // we already have an interface assigned -> still present ? 41 // we already have an interface assigned -> still present ?
42 if( ! Run->IsUp ) { 42 if( ! Run->IsUp ) {
43 // usb is still free -> keep assignment 43 // usb is still free -> keep assignment
44 return Available; 44 return Available;
45 } // else interface is up but NOT us -> some other profile 45 } // else interface is up but NOT us -> some other profile
46 } 46 }
47 47
48 // nothing (valid) assigned to us 48 // nothing (valid) assigned to us
49 NC->assignInterface( 0 ); 49 NC->assignInterface( 0 );
50 50
51 // find possible interface 51 // find possible interface
52 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 52 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
53 It.current(); 53 It.current();
54 ++It ) { 54 ++It ) {
55 Run = It.current(); 55 Run = It.current();
56 if( handlesInterface( *Run ) && 56 if( handlesInterface( *Run ) &&
57 ( Run->CardType == ARPHRD_ETHER 57 ( Run->CardType == ARPHRD_ETHER
58#ifdef ARPHRD_IEEE1394 58#ifdef ARPHRD_IEEE1394
59 || Run->CardType == ARPHRD_IEEE1394 59 || Run->CardType == ARPHRD_IEEE1394
60#endif 60#endif
61 ) && 61 ) &&
62 ! Run->IsUp 62 ! Run->IsUp
63 ) { 63 ) {
64 // proper type, and Not UP -> free 64 // proper type, and Not UP -> free
65 return Off; 65 return Off;
66 } 66 }
67 } 67 }
68 // no free found 68 // no free found
69 69
70 return Unavailable; 70 return Unavailable;
71} 71}
72 72
73QString LanCardRun::setMyState( NodeCollection * NC, Action_t A, bool ) { 73QString LanCardRun::setMyState( NetworkSetup * NC, Action_t A, bool ) {
74 74
75 if( A == Activate ) { 75 if( A == Activate ) {
76 InterfaceInfo * N = getInterface(); 76 InterfaceInfo * N = getInterface();
77 77
78 if( ! N ) { 78 if( ! N ) {
79 // no interface available 79 // no interface available
80 NC->setCurrentState( Unavailable ); 80 NC->setCurrentState( Unavailable );
81 return tr("No interface found"); 81 return tr("No interface found");
82 } 82 }
83 83
84 // because we were OFF the interface 84 // because we were OFF the interface
85 // we get back is NOT assigned 85 // we get back is NOT assigned
86 NC->assignInterface( N ); 86 NC->assignInterface( N );
87 NC->setCurrentState( Available ); 87 NC->setCurrentState( Available );
88 return QString(); 88 return QString();
89 } 89 }
90 90
91 if( A == Deactivate ) { 91 if( A == Deactivate ) {
92 NC->assignInterface( 0 ); 92 NC->assignInterface( 0 );
93 NC->setCurrentState( Off ); 93 NC->setCurrentState( Off );
94 } 94 }
95 95
96 return QString(); 96 return QString();
97} 97}
98 98
99// get interface that is free or assigned to us 99// get interface that is free or assigned to us
100InterfaceInfo * LanCardRun::getInterface( void ) { 100InterfaceInfo * LanCardRun::getInterface( void ) {
101 101
102 System & S = NSResources->system(); 102 System & S = NSResources->system();
103 InterfaceInfo * best = 0, * Run; 103 InterfaceInfo * best = 0, * Run;
104 104
105 for( QDictIterator<InterfaceInfo> It(S.interfaces()); 105 for( QDictIterator<InterfaceInfo> It(S.interfaces());
106 It.current(); 106 It.current();
107 ++It ) { 107 ++It ) {
108 Run = It.current(); 108 Run = It.current();
109 if( handlesInterface( *Run ) && 109 if( handlesInterface( *Run ) &&
110 ( Run->CardType == ARPHRD_ETHER 110 ( Run->CardType == ARPHRD_ETHER
111#ifdef ARPHRD_IEEE1394 111#ifdef ARPHRD_IEEE1394
112 || Run->CardType == ARPHRD_IEEE1394 112 || Run->CardType == ARPHRD_IEEE1394
113#endif 113#endif
114 ) 114 )
115 ) { 115 ) {
116 // this is a LAN card 116 // this is a LAN card
117 if( Run->assignedConnection() == netNode()->connection() ) { 117 if( Run->assignedToNetworkSetup() == netNode()->networkSetup() ) {
118 // assigned to us 118 // assigned to us
119 return Run; 119 return Run;
120 } else if( Run->assignedConnection() == 0 ) { 120 } else if( Run->assignedToNetworkSetup() == 0 ) {
121 // free 121 // free
122 best = Run; 122 best = Run;
123 } 123 }
124 } 124 }
125 } 125 }
126 return best; // can be 0 126 return best; // can be 0
127} 127}
128 128
129bool LanCardRun::handlesInterface( const QString & S ) { 129bool LanCardRun::handlesInterface( const QString & S ) {
130 InterfaceInfo * II; 130 InterfaceInfo * II;
131 II = NSResources->system().interface( S ); 131 II = NSResources->system().interface( S );
132 if( ( II = NSResources->system().interface( S ) ) ) { 132 if( ( II = NSResources->system().interface( S ) ) ) {
133 return handlesInterface( *II ); 133 return handlesInterface( *II );
134 } 134 }
135 return Pat.match( S ) >= 0; 135 return Pat.match( S ) >= 0;
136} 136}
137 137
138bool LanCardRun::handlesInterface( const InterfaceInfo & II ) { 138bool LanCardRun::handlesInterface( const InterfaceInfo & II ) {
139 if( Pat.match( II.Name ) < 0 ) 139 if( Pat.match( II.Name ) < 0 )
140 return 0; 140 return 0;
141 141
142 if( Data->AnyLanCard ) { 142 if( Data->AnyLanCard ) {
143 return 1; 143 return 1;
144 } 144 }
145 145
146 // must also match hardware address 146 // must also match hardware address
147 return ( Data->HWAddresses.findIndex( II.MACAddress ) >= 0 ); 147 return ( Data->HWAddresses.findIndex( II.MACAddress ) >= 0 );
148} 148}
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.h b/noncore/settings/networksettings2/lancard/lancardrun.h
index 57ef3fb..dfd3d62 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.h
+++ b/noncore/settings/networksettings2/lancard/lancardrun.h
@@ -1,37 +1,37 @@
1#ifndef LANCARDRUN_H 1#ifndef LANCARDRUN_H
2#define LANCARDRUN_H 2#define LANCARDRUN_H
3 3
4#include <netnode.h> 4#include <netnode.h>
5#include <qregexp.h> 5#include <qregexp.h>
6#include "lancarddata.h" 6#include "lancarddata.h"
7 7
8class LanCardRun : public RuntimeInfo { 8class LanCardRun : public RuntimeInfo {
9 9
10public : 10public :
11 11
12 LanCardRun( ANetNodeInstance * NNI, 12 LanCardRun( ANetNodeInstance * NNI,
13 LanCardData & D ) : RuntimeInfo( NNI ), 13 LanCardData & D ) : RuntimeInfo( NNI ),
14 Pat( "eth[0-9]" ) { 14 Pat( "eth[0-9]" ) {
15 Data = &D; 15 Data = &D;
16 } 16 }
17 17
18 virtual RuntimeInfo * device( void ) 18 virtual RuntimeInfo * device( void )
19 { return this; } 19 { return this; }
20 20
21 bool handlesInterface( const QString & I ); 21 bool handlesInterface( const QString & I );
22 bool handlesInterface( const InterfaceInfo & II ); 22 bool handlesInterface( const InterfaceInfo & II );
23 23
24 State_t detectState( void ); 24 State_t detectState( void );
25 25
26protected : 26protected :
27 27
28 QString setMyState( NodeCollection * , Action_t, bool ); 28 QString setMyState( NetworkSetup * , Action_t, bool );
29 29
30private : 30private :
31 31
32 InterfaceInfo * getInterface( void ); 32 InterfaceInfo * getInterface( void );
33 QRegExp Pat; 33 QRegExp Pat;
34 LanCardData * Data; 34 LanCardData * Data;
35 35
36}; 36};
37#endif 37#endif
diff --git a/noncore/settings/networksettings2/modem/modemrun.h b/noncore/settings/networksettings2/modem/modemrun.h
index eb3a193..df6b370 100644
--- a/noncore/settings/networksettings2/modem/modemrun.h
+++ b/noncore/settings/networksettings2/modem/modemrun.h
@@ -1,25 +1,25 @@
1#include <netnode.h> 1#include <netnode.h>
2#include "modemdata.h" 2#include "modemdata.h"
3 3
4class ModemRun : public RuntimeInfo { 4class ModemRun : public RuntimeInfo {
5 5
6public : 6public :
7 7
8 ModemRun( ANetNodeInstance * NNI, 8 ModemRun( ANetNodeInstance * NNI,
9 ModemData & Data ) : RuntimeInfo ( NNI ) 9 ModemData & Data ) : RuntimeInfo ( NNI )
10 { } 10 { }
11 11
12 virtual RuntimeInfo * line( void ) 12 virtual RuntimeInfo * line( void )
13 { return this; } 13 { return this; }
14 14
15 virtual QString deviceFile( void ) 15 virtual QString deviceFile( void )
16 { return QString("/dev/modem"); } 16 { return QString("/dev/modem"); }
17 17
18 State_t detectState( void ) 18 State_t detectState( void )
19 { return Unknown;} 19 { return Unknown;}
20 20
21protected : 21protected :
22 22
23 QString setMyState( NodeCollection * , Action_t, bool ) 23 QString setMyState( NetworkSetup * , Action_t, bool )
24 { return QString(); } 24 { return QString(); }
25}; 25};
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp
index 2fa31bd..80a7fac 100644
--- a/noncore/settings/networksettings2/network/network_NN.cpp
+++ b/noncore/settings/networksettings2/network/network_NN.cpp
@@ -1,95 +1,95 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <resources.h> 2#include <resources.h>
3#include <netnode.h> 3#include <netnode.h>
4#include "network_NN.h" 4#include "network_NN.h"
5#include "network_NNI.h" 5#include "network_NNI.h"
6 6
7#include "netnodeinterface.h" 7#include "netnodeinterface.h"
8 8
9static const char * NetworkNeeds[] = 9static const char * NetworkNeeds[] =
10 { "device", 10 { "device",
11 0 11 0
12 }; 12 };
13 13
14static const char * NetworkProvides[] = 14static const char * NetworkProvides[] =
15 { "connection", 15 { "NetworkSetup",
16 0 16 0
17 }; 17 };
18 18
19/** 19/**
20 * Constructor, find all of the possible interfaces 20 * Constructor, find all of the possible interfaces
21 */ 21 */
22NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) { 22NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) {
23 23
24 NSResources->addSystemFile( 24 NSResources->addSystemFile(
25 "interfaces", "/etc/network/interfaces", 1 ); 25 "interfaces", "/etc/network/interfaces", 1 );
26} 26}
27 27
28/** 28/**
29 * Delete any interfaces that we own. 29 * Delete any interfaces that we own.
30 */ 30 */
31NetworkNetNode::~NetworkNetNode(){ 31NetworkNetNode::~NetworkNetNode(){
32} 32}
33 33
34const QString NetworkNetNode::nodeDescription(){ 34const QString NetworkNetNode::nodeDescription(){
35 return tr("\ 35 return tr("\
36<p>Sets up TCP/IP options.</p>\ 36<p>Sets up TCP/IP options.</p>\
37<p>Use this to configure the TCP/IP protocol</p>\ 37<p>Use this to configure the TCP/IP protocol</p>\
38" 38"
39); 39);
40} 40}
41 41
42ANetNodeInstance * NetworkNetNode::createInstance( void ) { 42ANetNodeInstance * NetworkNetNode::createInstance( void ) {
43 return new ANetwork( this ); 43 return new ANetwork( this );
44} 44}
45 45
46bool NetworkNetNode::hasDataForFile( SystemFile & S ) { 46bool NetworkNetNode::hasDataForFile( SystemFile & S ) {
47 return S.name() == "interfaces"; 47 return S.name() == "interfaces";
48} 48}
49 49
50short NetworkNetNode::generateFile( SystemFile & SF, 50short NetworkNetNode::generateFile( SystemFile & SF,
51 ANetNodeInstance * NNI, 51 ANetNodeInstance * NNI,
52 long DevNr ) { 52 long DevNr ) {
53 53
54 if( DevNr < 0 ) { 54 if( DevNr < 0 ) {
55 // generate device specific but common part 55 // generate device specific but common part
56 return 1; 56 return 1;
57 } 57 }
58 58
59 QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); 59 QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
60 60
61 if( SF.name() == "interfaces" ) { 61 if( SF.name() == "interfaces" ) {
62 Log(("Generate entry for %s in %s\n", NIC.latin1(), SF.name().latin1() )); 62 Log(("Generate entry for %s in %s\n", NIC.latin1(), SF.name().latin1() ));
63 // generate mapping stanza for this interface 63 // generate mapping stanza for this interface
64 SF << "# check if " 64 SF << "# check if "
65 << NIC 65 << NIC
66 << " can be brought UP" 66 << " can be brought UP"
67 << endl; 67 << endl;
68 SF << "mapping " 68 SF << "mapping "
69 << NIC 69 << NIC
70 << endl; 70 << endl;
71 SF << " script " 71 SF << " script "
72 << QPEApplication::qpeDir() 72 << QPEApplication::qpeDir()
73 << "bin/networksettings2-request" 73 << "bin/networksettings2-request"
74 << endl 74 << endl
75 << endl; 75 << endl;
76 return 0; 76 return 0;
77 } 77 }
78 return 1; 78 return 1;
79} 79}
80 80
81const char ** NetworkNetNode::needs( void ) { 81const char ** NetworkNetNode::needs( void ) {
82 return NetworkNeeds; 82 return NetworkNeeds;
83} 83}
84 84
85const char ** NetworkNetNode::provides( void ) { 85const char ** NetworkNetNode::provides( void ) {
86 return NetworkProvides; 86 return NetworkProvides;
87} 87}
88 88
89void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { 89void NetworkNetNode::setSpecificAttribute( QString & , QString & ) {
90} 90}
91 91
92void NetworkNetNode::saveSpecificAttribute( QTextStream & ) { 92void NetworkNetNode::saveSpecificAttribute( QTextStream & ) {
93} 93}
94 94
95OPIE_NS2_PLUGIN( NetNodeInterface_T<NetworkNetNode> ) 95OPIE_NS2_PLUGIN( NetNodeInterface_T<NetworkNetNode> )
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp
index 34dac54..c183d5e 100644
--- a/noncore/settings/networksettings2/network/network_NNI.cpp
+++ b/noncore/settings/networksettings2/network/network_NNI.cpp
@@ -24,195 +24,195 @@ ANetwork::ANetwork( NetworkNetNode * PNN ) : ANetNodeInstance( PNN ) {
24 24
25void ANetwork::setSpecificAttribute( QString & A, QString & V ) { 25void ANetwork::setSpecificAttribute( QString & A, QString & V ) {
26 if( A == "usedhcp" ) { 26 if( A == "usedhcp" ) {
27 Data.UseDHCP = (V == "yes"); 27 Data.UseDHCP = (V == "yes");
28 } else if( A == "sendhostname" ) { 28 } else if( A == "sendhostname" ) {
29 Data.SendHostname = (V=="yes"); 29 Data.SendHostname = (V=="yes");
30 } else if( A == "hostname" ) { 30 } else if( A == "hostname" ) {
31 Data.Hostname = V; 31 Data.Hostname = V;
32 } else if( A == "ipaddress" ) { 32 } else if( A == "ipaddress" ) {
33 Data.IPAddress = V; 33 Data.IPAddress = V;
34 } else if( A == "netmask" ) { 34 } else if( A == "netmask" ) {
35 Data.NetMask = V; 35 Data.NetMask = V;
36 } else if( A == "broadcast" ) { 36 } else if( A == "broadcast" ) {
37 Data.Broadcast = V; 37 Data.Broadcast = V;
38 } else if( A == "gateway" ) { 38 } else if( A == "gateway" ) {
39 Data.Gateway = V; 39 Data.Gateway = V;
40 } else if( A == "dns1" ) { 40 } else if( A == "dns1" ) {
41 Data.DNS1 = V; 41 Data.DNS1 = V;
42 } else if( A == "dns2" ) { 42 } else if( A == "dns2" ) {
43 Data.DNS2 = V; 43 Data.DNS2 = V;
44 } else if( A == "preup" ) { 44 } else if( A == "preup" ) {
45 Data.PreUp_SL.append( V ); 45 Data.PreUp_SL.append( V );
46 } else if( A == "predown" ) { 46 } else if( A == "predown" ) {
47 Data.PreDown_SL.append( V ); 47 Data.PreDown_SL.append( V );
48 } else if( A == "postup" ) { 48 } else if( A == "postup" ) {
49 Data.PostUp_SL.append( V ); 49 Data.PostUp_SL.append( V );
50 } else if( A == "postdown" ) { 50 } else if( A == "postdown" ) {
51 Data.PostDown_SL.append( V ); 51 Data.PostDown_SL.append( V );
52 } 52 }
53} 53}
54 54
55void ANetwork::saveSpecificAttribute( QTextStream & TS ) { 55void ANetwork::saveSpecificAttribute( QTextStream & TS ) {
56 TS << "usedhcp=" << ((Data.UseDHCP) ? "yes" : "no") << endl; 56 TS << "usedhcp=" << ((Data.UseDHCP) ? "yes" : "no") << endl;
57 TS << "sendhostname=" << ((Data.SendHostname) ? "yes" : "no") << endl; 57 TS << "sendhostname=" << ((Data.SendHostname) ? "yes" : "no") << endl;
58 TS << "hostname=" << Data.Hostname << endl; 58 TS << "hostname=" << Data.Hostname << endl;
59 TS << "ipaddress=" << Data.IPAddress << endl; 59 TS << "ipaddress=" << Data.IPAddress << endl;
60 TS << "netmask=" << Data.NetMask << endl; 60 TS << "netmask=" << Data.NetMask << endl;
61 TS << "broadcast=" << Data.Broadcast << endl; 61 TS << "broadcast=" << Data.Broadcast << endl;
62 TS << "gateway=" << Data.Gateway << endl; 62 TS << "gateway=" << Data.Gateway << endl;
63 TS << "dns1=" << Data.DNS1 << endl; 63 TS << "dns1=" << Data.DNS1 << endl;
64 TS << "dns2=" << Data.DNS2 << endl; 64 TS << "dns2=" << Data.DNS2 << endl;
65 for ( QStringList::Iterator it = Data.PreUp_SL.begin(); 65 for ( QStringList::Iterator it = Data.PreUp_SL.begin();
66 it != Data.PreUp_SL.end(); 66 it != Data.PreUp_SL.end();
67 ++it ) { 67 ++it ) {
68 TS << "preup=" << quote(*it) << endl; 68 TS << "preup=" << quote(*it) << endl;
69 } 69 }
70 for ( QStringList::Iterator it = Data.PreDown_SL.begin(); 70 for ( QStringList::Iterator it = Data.PreDown_SL.begin();
71 it != Data.PreDown_SL.end(); 71 it != Data.PreDown_SL.end();
72 ++it ) { 72 ++it ) {
73 TS << "predown=" << quote(*it) << endl; 73 TS << "predown=" << quote(*it) << endl;
74 } 74 }
75 for ( QStringList::Iterator it = Data.PostUp_SL.begin(); 75 for ( QStringList::Iterator it = Data.PostUp_SL.begin();
76 it != Data.PostUp_SL.end(); 76 it != Data.PostUp_SL.end();
77 ++it ) { 77 ++it ) {
78 TS << "postup=" << quote(*it) << endl; 78 TS << "postup=" << quote(*it) << endl;
79 } 79 }
80 for ( QStringList::Iterator it = Data.PostDown_SL.begin(); 80 for ( QStringList::Iterator it = Data.PostDown_SL.begin();
81 it != Data.PostDown_SL.end(); 81 it != Data.PostDown_SL.end();
82 ++it ) { 82 ++it ) {
83 TS << "postdown=" << quote(*it) << endl; 83 TS << "postdown=" << quote(*it) << endl;
84 } 84 }
85} 85}
86 86
87QWidget * ANetwork::edit( QWidget * parent ) { 87QWidget * ANetwork::edit( QWidget * parent ) {
88 GUI = new NetworkEdit( parent ); 88 GUI = new NetworkEdit( parent );
89 GUI->showData( Data ); 89 GUI->showData( Data );
90 return GUI; 90 return GUI;
91} 91}
92 92
93QString ANetwork::acceptable( void ) { 93QString ANetwork::acceptable( void ) {
94 return ( GUI ) ? GUI->acceptable( ) : QString(); 94 return ( GUI ) ? GUI->acceptable( ) : QString();
95} 95}
96 96
97void ANetwork::commit( void ) { 97void ANetwork::commit( void ) {
98 if( GUI && GUI->commit( Data ) ) 98 if( GUI && GUI->commit( Data ) )
99 setModified( 1 ); 99 setModified( 1 );
100} 100}
101 101
102bool ANetwork::hasDataForFile( SystemFile & S ) { 102bool ANetwork::hasDataForFile( SystemFile & S ) {
103 return S.name() == "interfaces"; 103 return S.name() == "interfaces";
104} 104}
105 105
106short ANetwork::generateFile( SystemFile &SF, 106short ANetwork::generateFile( SystemFile &SF,
107 long DevNr 107 long DevNr
108 ) { 108 ) {
109 109
110 short rvl, rvd ; 110 short rvl, rvd ;
111 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); 111 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
112 112
113 rvl = 1; 113 rvl = 1;
114 if( SF.name() == "interfaces" ) { 114 if( SF.name() == "interfaces" ) {
115 Log(("Generate Network for %s\n", SF.name().latin1() )); 115 Log(("Generate Network for %s\n", SF.name().latin1() ));
116 // we can safely call from here since device item is deeper 116 // we can safely call from here since device item is deeper
117 if( Data.UseDHCP ) { 117 if( Data.UseDHCP ) {
118 SF << "iface " 118 SF << "iface "
119 << "A" 119 << "A"
120 << connection()->number() 120 << networkSetup()->number()
121 << NIC 121 << NIC
122 << " inet dhcp" 122 << " inet dhcp"
123 << endl; 123 << endl;
124 SF << " up echo \"" 124 SF << " up echo \""
125 << NIC 125 << NIC
126 << "\" > /tmp/profile-" 126 << "\" > /tmp/profile-"
127 << connection()->number() 127 << networkSetup()->number()
128 << ".up" 128 << ".up"
129 << endl; 129 << endl;
130 if( Data.SendHostname ) { 130 if( Data.SendHostname ) {
131 SF << " hostname " 131 SF << " hostname "
132 << Data.Hostname 132 << Data.Hostname
133 << endl; 133 << endl;
134 } 134 }
135 135
136 SF << " down rm -f /tmp/profile-" 136 SF << " down rm -f /tmp/profile-"
137 << connection()->number() 137 << networkSetup()->number()
138 << ".up" 138 << ".up"
139 << endl; 139 << endl;
140 } else { 140 } else {
141 SF << "iface " 141 SF << "iface "
142 << "A" 142 << "A"
143 << connection()->number() 143 << networkSetup()->number()
144 << NIC 144 << NIC
145 << " inet static" 145 << " inet static"
146 << endl; 146 << endl;
147 SF << " up echo \"" 147 SF << " up echo \""
148 << NIC 148 << NIC
149 << "\" > /tmp/profile-" 149 << "\" > /tmp/profile-"
150 << connection()->number() 150 << networkSetup()->number()
151 << ".up" 151 << ".up"
152 << endl; 152 << endl;
153 SF << " down rm -f /tmp/profile-" 153 SF << " down rm -f /tmp/profile-"
154 << connection()->number() 154 << networkSetup()->number()
155 << ".up" 155 << ".up"
156 << endl; 156 << endl;
157 SF << " address " 157 SF << " address "
158 << Data.IPAddress 158 << Data.IPAddress
159 << endl; 159 << endl;
160 SF << " broadcast " 160 SF << " broadcast "
161 << Data.Broadcast 161 << Data.Broadcast
162 << endl; 162 << endl;
163 SF << " netmask " 163 SF << " netmask "
164 << Data.NetMask 164 << Data.NetMask
165 << endl; 165 << endl;
166 166
167 // derive network address = IPAddress & netmask 167 // derive network address = IPAddress & netmask
168 { QString NW; 168 { QString NW;
169 QStringList ipal = QStringList::split( '.', Data.IPAddress ); 169 QStringList ipal = QStringList::split( '.', Data.IPAddress );
170 QStringList nmal = QStringList::split( '.', Data.NetMask ); 170 QStringList nmal = QStringList::split( '.', Data.NetMask );
171 171
172 NW = QString( "%1.%2.%3.%4" ). 172 NW = QString( "%1.%2.%3.%4" ).
173 arg( ipal[0].toShort() & nmal[0].toShort() ). 173 arg( ipal[0].toShort() & nmal[0].toShort() ).
174 arg( ipal[1].toShort() & nmal[1].toShort() ). 174 arg( ipal[1].toShort() & nmal[1].toShort() ).
175 arg( ipal[2].toShort() & nmal[2].toShort() ). 175 arg( ipal[2].toShort() & nmal[2].toShort() ).
176 arg( ipal[3].toShort() & nmal[3].toShort() ); 176 arg( ipal[3].toShort() & nmal[3].toShort() );
177 SF << " network " 177 SF << " network "
178 << NW 178 << NW
179 << endl; 179 << endl;
180 } 180 }
181 } 181 }
182 for ( QStringList::Iterator it = Data.PreUp_SL.begin(); 182 for ( QStringList::Iterator it = Data.PreUp_SL.begin();
183 it != Data.PreUp_SL.end(); 183 it != Data.PreUp_SL.end();
184 ++it ) { 184 ++it ) {
185 SF << " pre-up " 185 SF << " pre-up "
186 << (*it) 186 << (*it)
187 << endl; 187 << endl;
188 } 188 }
189 for ( QStringList::Iterator it = Data.PostUp_SL.begin(); 189 for ( QStringList::Iterator it = Data.PostUp_SL.begin();
190 it != Data.PostUp_SL.end(); 190 it != Data.PostUp_SL.end();
191 ++it ) { 191 ++it ) {
192 SF << " up " 192 SF << " up "
193 << (*it) 193 << (*it)
194 << endl; 194 << endl;
195 } 195 }
196 for ( QStringList::Iterator it = Data.PreDown_SL.begin(); 196 for ( QStringList::Iterator it = Data.PreDown_SL.begin();
197 it != Data.PreDown_SL.end(); 197 it != Data.PreDown_SL.end();
198 ++it ) { 198 ++it ) {
199 SF << " down " 199 SF << " down "
200 << (*it) 200 << (*it)
201 << endl; 201 << endl;
202 } 202 }
203 for ( QStringList::Iterator it = Data.PostDown_SL.begin(); 203 for ( QStringList::Iterator it = Data.PostDown_SL.begin();
204 it != Data.PostDown_SL.end(); 204 it != Data.PostDown_SL.end();
205 ++it ) { 205 ++it ) {
206 SF << " post-down " 206 SF << " post-down "
207 << (*it) 207 << (*it)
208 << endl; 208 << endl;
209 } 209 }
210 rvl = 0; 210 rvl = 0;
211 } 211 }
212 212
213 // embed other info in it 213 // embed other info in it
214 rvd = connection()->getToplevel()->generateFileEmbedded( SF, DevNr ); 214 rvd = networkSetup()->getToplevel()->generateFileEmbedded( SF, DevNr );
215 215
216 return (rvd == 2 || rvl == 2 ) ? 2 : 216 return (rvd == 2 || rvl == 2 ) ? 2 :
217 (rvd == 0 || rvl == 0 ) ? 0 : 1; 217 (rvd == 0 || rvl == 0 ) ? 0 : 1;
218} 218}
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp
index 74467ad..7039a36 100644
--- a/noncore/settings/networksettings2/network/networkrun.cpp
+++ b/noncore/settings/networksettings2/network/networkrun.cpp
@@ -1,51 +1,50 @@
1#include <system.h> 1#include <system.h>
2#include <netnode.h> 2#include <netnode.h>
3#include <resources.h> 3#include <resources.h>
4#include "networkrun.h" 4#include "networkrun.h"
5 5
6State_t NetworkRun::detectState( void ) { 6State_t NetworkRun::detectState( void ) {
7 InterfaceInfo * II = nodeCollection()->assignedInterface(); 7 InterfaceInfo * II = networkSetup()->assignedInterface();
8 8
9 Log(( "Interface %p %p : %d\n", II, nodeCollection(), (II) ? II->IsUp : 0 ));
10 if( II && II->IsUp ) { 9 if( II && II->IsUp ) {
11 // device has assigned interface 10 // device has assigned interface
12 return IsUp; 11 return IsUp;
13 } 12 }
14 13
15 // had no interface or interface is no longer up -> release 14 // had no interface or interface is no longer up -> release
16 nodeCollection()->assignInterface( 0 ); 15 networkSetup()->assignInterface( 0 );
17 16
18 return Unknown; 17 return Unknown;
19} 18}
20 19
21QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) { 20QString NetworkRun::setMyState( NetworkSetup * NC, Action_t A, bool ) {
22 // we handle UP and DOWN 21 // we handle UP and DOWN
23 InterfaceInfo * II = NC->assignedInterface(); 22 InterfaceInfo * II = NC->assignedInterface();
24 23
25 if( ! II ) { 24 if( ! II ) {
26 Log(( "no interface assigned." )); 25 Log(( "no interface assigned." ));
27 return QString(); 26 return QString();
28 } 27 }
29 28
30 QStringList SL; 29 QStringList SL;
31 30
32 if( A == Up ) { 31 if( A == Up ) {
33 // we can bring UP if lower level is available 32 // we can bring UP if lower level is available
34 SL << "ifup"; 33 SL << "ifup";
35 } else if( A == Down ) { 34 } else if( A == Down ) {
36 SL << "ifdown"; 35 SL << "ifdown";
37 } else { 36 } else {
38 return QString(); 37 return QString();
39 } 38 }
40 39
41 SL << QString().sprintf( "%s=A%ld%s", 40 SL << QString().sprintf( "%s=A%ld%s",
42 II->Name.latin1(), 41 II->Name.latin1(),
43 nodeCollection()->number(), 42 networkSetup()->number(),
44 II->Name.latin1() ); 43 II->Name.latin1() );
45 44
46 if( ! NSResources->system().runAsRoot( SL ) ) { 45 if( ! NSResources->system().runAsRoot( SL ) ) {
47 return QString("Cannot call %1").arg(SL.join(" ")); 46 return QString("Cannot call %1").arg(SL.join(" "));
48 } 47 }
49 48
50 return QString(); 49 return QString();
51} 50}
diff --git a/noncore/settings/networksettings2/network/networkrun.h b/noncore/settings/networksettings2/network/networkrun.h
index 78a1694..ac186e7 100644
--- a/noncore/settings/networksettings2/network/networkrun.h
+++ b/noncore/settings/networksettings2/network/networkrun.h
@@ -1,20 +1,20 @@
1#include <netnode.h> 1#include <netnode.h>
2#include "networkdata.h" 2#include "networkdata.h"
3 3
4class NetworkRun : public RuntimeInfo { 4class NetworkRun : public RuntimeInfo {
5 5
6public : 6public :
7 7
8 NetworkRun( ANetNodeInstance * NNI, 8 NetworkRun( ANetNodeInstance * NNI,
9 NetworkData & Data ) : RuntimeInfo( NNI ) 9 NetworkData & Data ) : RuntimeInfo( NNI )
10 { } 10 { }
11 11
12 virtual RuntimeInfo * connection( void ) 12 virtual RuntimeInfo * connection( void )
13 { return this; } 13 { return this; }
14 14
15 State_t detectState( void ); 15 State_t detectState( void );
16 16
17protected : 17protected :
18 18
19 QString setMyState( NodeCollection * , Action_t, bool ); 19 QString setMyState( NetworkSetup * , Action_t, bool );
20}; 20};
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index 78b6cce..80dcb3d 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -1,510 +1,510 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <unistd.h> 2#include <unistd.h>
3#include <errno.h> 3#include <errno.h>
4 4
5#include <opie2/odebug.h> 5#include <opie2/odebug.h>
6#include <opie2/oledbox.h> 6#include <opie2/oledbox.h>
7 7
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qlistbox.h> 9#include <qlistbox.h>
10#include <qlayout.h> 10#include <qlayout.h>
11#include <qgroupbox.h> 11#include <qgroupbox.h>
12#include <qtimer.h> 12#include <qtimer.h>
13#include <qlistbox.h> 13#include <qlistbox.h>
14#include <qmessagebox.h> 14#include <qmessagebox.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qiconview.h> 16#include <qiconview.h>
17#include <qtimer.h> 17#include <qtimer.h>
18#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
19#include <qtoolbutton.h> 19#include <qtoolbutton.h>
20#include <qevent.h> 20#include <qevent.h>
21 21
22#include "networksettings.h" 22#include "networksettings.h"
23#include "netnode.h" 23#include "netnode.h"
24#include "editconnection.h" 24#include "editconnection.h"
25 25
26NetworkSettings::NetworkSettings( QWidget *parent, 26NetworkSettings::NetworkSettings( QWidget *parent,
27 const char *name, 27 const char *name,
28 WFlags fl ) : NetworkSettingsGUI(parent,name,fl), 28 WFlags fl ) : NetworkSettingsGUI(parent,name,fl),
29 NSD() { 29 NSD() {
30 30
31 UpdateTimer = new QTimer( this ); 31 UpdateTimer = new QTimer( this );
32 32
33 // set pixmaps 33 // set pixmaps
34 Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); 34 Add_TB->setPixmap( NSResources->getPixmap( "add" ) );
35 Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) ); 35 Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) );
36 CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) ); 36 CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) );
37 GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) ); 37 GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) );
38 38
39 Disable_TB->setPixmap( NSResources->getPixmap( "disabled" ) ); 39 Disable_TB->setPixmap( NSResources->getPixmap( "disabled" ) );
40 Up_TB->setPixmap( NSResources->getPixmap( "more" ) ); 40 Up_TB->setPixmap( NSResources->getPixmap( "more" ) );
41 Down_TB->setPixmap( NSResources->getPixmap( "less" ) ); 41 Down_TB->setPixmap( NSResources->getPixmap( "less" ) );
42 42
43 QVBoxLayout* V = new QVBoxLayout( LED_Frm ); 43 QVBoxLayout* V = new QVBoxLayout( LED_Frm );
44 QHBoxLayout * H = new QHBoxLayout( 0 ); 44 QHBoxLayout * H = new QHBoxLayout( 0 );
45 V->addStretch(1); 45 V->addStretch(1);
46 V->addLayout( H ); 46 V->addLayout( H );
47 Leds[0] = new Opie::Ui::OLedBox( red, LED_Frm ); 47 Leds[0] = new Opie::Ui::OLedBox( red, LED_Frm );
48 H->addWidget( Leds[0], 0, Qt::AlignVCenter ); 48 H->addWidget( Leds[0], 0, Qt::AlignVCenter );
49 Leds[1] = new Opie::Ui::OLedBox( red, LED_Frm ); 49 Leds[1] = new Opie::Ui::OLedBox( red, LED_Frm );
50 H->addWidget( Leds[1], 0, Qt::AlignVCenter ); 50 H->addWidget( Leds[1], 0, Qt::AlignVCenter );
51 Leds[2] = new Opie::Ui::OLedBox( red, LED_Frm ); 51 Leds[2] = new Opie::Ui::OLedBox( red, LED_Frm );
52 H->addWidget( Leds[2], 0, Qt::AlignVCenter ); 52 H->addWidget( Leds[2], 0, Qt::AlignVCenter );
53 V->addStretch(1); 53 V->addStretch(1);
54 54
55 55
56 SLOT_ToProfile(); 56 SLOT_ToProfile();
57 57
58 // populate main Listbox 58 // populate main Listbox
59 Profiles_LB->clear(); 59 Profiles_LB->clear();
60 QPEApplication::setStylusOperation( 60 QPEApplication::setStylusOperation(
61 Profiles_LB->viewport(), QPEApplication::RightOnHold ); 61 Profiles_LB->viewport(), QPEApplication::RightOnHold );
62 62
63 connect( Profiles_LB, 63 connect( Profiles_LB,
64 SIGNAL(rightButtonPressed(QListBoxItem*,const QPoint&)), 64 SIGNAL(rightButtonPressed(QListBoxItem*,const QPoint&)),
65 this, SLOT(SLOT_EditNode(QListBoxItem*)) ); 65 this, SLOT(SLOT_EditNode(QListBoxItem*)) );
66 66
67 { Name2Connection_t & M = NSResources->connections(); 67 { Name2NetworkSetup_t & M = NSResources->networkSetups();
68 NodeCollection * NC; 68 NetworkSetup * NC;
69 // for all connections 69 // for all NetworkSetups
70 for( QDictIterator<NodeCollection> it(M); 70 for( QDictIterator<NetworkSetup> it(M);
71 it.current(); 71 it.current();
72 ++it ) { 72 ++it ) {
73 NC = it.current(); 73 NC = it.current();
74 Profiles_LB->insertItem( NC->devicePixmap(), 74 Profiles_LB->insertItem( NC->devicePixmap(),
75 NC->name() ); 75 NC->name() );
76 } 76 }
77 } 77 }
78 78
79 if( Profiles_LB->count() ) { 79 if( Profiles_LB->count() ) {
80 Profiles_LB->setSelected( 0, TRUE ); 80 Profiles_LB->setSelected( 0, TRUE );
81 } 81 }
82 82
83 // if no profiles -> auto popup editing 83 // if no profiles -> auto popup editing
84 if( NSResources->connections().count() == 0 ) { 84 if( NSResources->networkSetups().count() == 0 ) {
85 QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) ); 85 QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) );
86 } 86 }
87 87
88 connect( &(NSResources->system()), 88 connect( &(NSResources->system()),
89 SIGNAL( stdoutLine(const QString &) ), 89 SIGNAL( stdoutLine(const QString &) ),
90 this, SLOT( SLOT_CmdMessage(const QString &) ) ); 90 this, SLOT( SLOT_CmdMessage(const QString &) ) );
91 91
92 connect( &(NSResources->system()), 92 connect( &(NSResources->system()),
93 SIGNAL( stderrLine(const QString &) ), 93 SIGNAL( stderrLine(const QString &) ),
94 this, SLOT( SLOT_CmdMessage(const QString &) ) ); 94 this, SLOT( SLOT_CmdMessage(const QString &) ) );
95 95
96 connect( &(NSResources->system()), 96 connect( &(NSResources->system()),
97 SIGNAL( processEvent(const QString &) ), 97 SIGNAL( processEvent(const QString &) ),
98 this, SLOT( SLOT_CmdMessage(const QString &) ) ); 98 this, SLOT( SLOT_CmdMessage(const QString &) ) );
99 99
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 if( NSD.isModified() ) { 112 if( NSD.isModified() ) {
113 S = NSD.saveSettings(); 113 S = NSD.saveSettings();
114 if( ! S.isEmpty() ) { 114 if( ! S.isEmpty() ) {
115 S.insert( 0, "<p>" ); 115 S.insert( 0, "<p>" );
116 S.append( "</p>" ); 116 S.append( "</p>" );
117 // problem saving 117 // problem saving
118 QMessageBox::warning( 118 QMessageBox::warning(
119 0, 119 0,
120 tr( "Saving setup" ), S ); 120 tr( "Saving setup" ), S );
121 } 121 }
122 122
123 SLOT_GenerateConfig(); 123 SLOT_GenerateConfig();
124 NSD.setModified( 0 ); 124 NSD.setModified( 0 );
125 } 125 }
126 126
127} 127}
128 128
129void NetworkSettings::SLOT_CmdMessage( const QString & S ) { 129void NetworkSettings::SLOT_CmdMessage( const QString & S ) {
130 Messages_LB->insertItem( S ); 130 Messages_LB->insertItem( S );
131 Messages_LB->setCurrentItem( Messages_LB->count()-1 ); 131 Messages_LB->setCurrentItem( Messages_LB->count()-1 );
132 Messages_LB->ensureCurrentVisible(); 132 Messages_LB->ensureCurrentVisible();
133} 133}
134 134
135void NetworkSettings::SLOT_RefreshStates( void ) { 135void NetworkSettings::SLOT_RefreshStates( void ) {
136 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember 136 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember
137 137
138 if( LBI ) { 138 if( LBI ) {
139 NodeCollection * NC; 139 NetworkSetup * NC;
140 NSResources->system().probeInterfaces(); 140 NSResources->system().probeInterfaces();
141 // update current selection only 141 // update current selection only
142 NC = NSResources->findConnection( LBI->text() ); 142 NC = NSResources->findNetworkSetup( LBI->text() );
143 if( NC ) { 143 if( NC ) {
144 State_t OldS = NC->state(); 144 State_t OldS = NC->state();
145 State_t NewS = NC->state(1); 145 State_t NewS = NC->state(1);
146 if( OldS != NewS ) { 146 if( OldS != NewS ) {
147 updateProfileState( LBI ); 147 updateProfileState( LBI );
148 } 148 }
149 } 149 }
150 } 150 }
151 151
152 152
153 /* -> LATER !! 153 /* -> LATER !!
154 bool is; 154 bool is;
155 NodeCollection * NC; 155 NetworkSetup * NC;
156 156
157 for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) { 157 for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) {
158 NC = NSResources->findConnection( Profiles_LB->text(i) ); 158 NC = NSResources->findNetworkSetup( Profiles_LB->text(i) );
159 if( NC ) { 159 if( NC ) {
160 State_t OldS = NC->state(); 160 State_t OldS = NC->state();
161 State_t NewS = NC->state(1); 161 State_t NewS = NC->state(1);
162 if( OldS != NewS ) { 162 if( OldS != NewS ) {
163 is = Profiles_LB->isSelected(i); 163 is = Profiles_LB->isSelected(i);
164 Profiles_LB->changeItem( NC->statePixmap(NewS), 164 Profiles_LB->changeItem( NC->statePixmap(NewS),
165 NC->name(), 165 NC->name(),
166 i ); 166 i );
167 if( is ) { 167 if( is ) {
168 Profiles_LB->setSelected( i, TRUE ); 168 Profiles_LB->setSelected( i, TRUE );
169 } 169 }
170 } 170 }
171 } 171 }
172 } 172 }
173 if( ci >= 0 ) 173 if( ci >= 0 )
174 Profiles_LB->setCurrentItem( ci ); 174 Profiles_LB->setCurrentItem( ci );
175 */ 175 */
176} 176}
177 177
178void NetworkSettings::SLOT_AddNode( void ) { 178void NetworkSettings::SLOT_AddNode( void ) {
179 SLOT_EditNode( 0 ); 179 SLOT_EditNode( 0 );
180} 180}
181 181
182void NetworkSettings::SLOT_DeleteNode( void ) { 182void NetworkSettings::SLOT_DeleteNode( void ) {
183 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 183 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
184 184
185 if ( ! LBI ) 185 if ( ! LBI )
186 return; 186 return;
187 187
188 if( QMessageBox::warning( 188 if( QMessageBox::warning(
189 0, 189 0,
190 tr( "Removing profile" ), 190 tr( "Removing profile" ),
191 tr( "Remove selected profile ?" ), 191 tr( "Remove selected profile ?" ),
192 1, 0 ) == 1 ) { 192 1, 0 ) == 1 ) {
193 NSResources->removeConnection( LBI->text() ); 193 NSResources->removeNetworkSetup( LBI->text() );
194 delete LBI; 194 delete LBI;
195 NSD.setModified( 1 ); 195 NSD.setModified( 1 );
196 } 196 }
197} 197}
198 198
199void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { 199void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
200 QString OldName = ""; 200 QString OldName = "";
201 201
202 EditConnection EC( this ); 202 EditNetworkSetup EC( this );
203 203
204 if( LBI ) { 204 if( LBI ) {
205 NodeCollection * NC = NSResources->findConnection( LBI->text() ); 205 NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() );
206 if( ! NC ) { 206 if( ! NC ) {
207 return; 207 return;
208 } 208 }
209 OldName = NC->name(); 209 OldName = NC->name();
210 EC.setConnection( NC ); 210 EC.setNetworkSetup( NC );
211 } 211 }
212 212
213 EC.showMaximized(); 213 EC.showMaximized();
214 // disable refresh timer 214 // disable refresh timer
215 UpdateTimer->stop(); 215 UpdateTimer->stop();
216 216
217 // we need to retry 217 // we need to retry
218 while( 1 ) { 218 while( 1 ) {
219 if( EC.exec() == QDialog::Accepted ) { 219 if( EC.exec() == QDialog::Accepted ) {
220 // toplevel item -> store 220 // toplevel item -> store
221 NodeCollection * NC = EC.connection(); 221 NetworkSetup * NC = EC.networkSetup();
222 if( NC->isModified() ) { 222 if( NC->isModified() ) {
223 if( LBI ) { 223 if( LBI ) {
224 if( NC->name() != OldName ) { 224 if( NC->name() != OldName ) {
225 // find if new name is free 225 // find if new name is free
226 NodeCollection * LCN = NSResources->findConnection( 226 NetworkSetup * LCN = NSResources->findNetworkSetup(
227 NC->name() ); 227 NC->name() );
228 if( LCN ) { 228 if( LCN ) {
229 QMessageBox::warning( 229 QMessageBox::warning(
230 0, 230 0,
231 tr( "In System Config" ), 231 tr( "In System Config" ),
232 tr( "Name %1 already exists" ).arg(NC->name()) 232 tr( "Name %1 already exists" ).arg(NC->name())
233 ); 233 );
234 continue; // restart exec 234 continue; // restart exec
235 } // else new name 235 } // else new name
236 // new name -> remove item 236 // new name -> remove item
237 NSResources->removeConnection( OldName ); 237 NSResources->removeNetworkSetup( OldName );
238 NSResources->addConnection( NC, 0 ); 238 NSResources->addNetworkSetup( NC, 0 );
239 } // else not changed 239 } // else not changed
240 240
241 // must add it here since change will trigger event 241 // must add it here since change will trigger event
242 Profiles_LB->changeItem( NC->devicePixmap(), 242 Profiles_LB->changeItem( NC->devicePixmap(),
243 NC->name(), 243 NC->name(),
244 Profiles_LB->index( LBI ) 244 Profiles_LB->index( LBI )
245 ); 245 );
246 } else { 246 } else {
247 // new item 247 // new item
248 int ci = Profiles_LB->count(); 248 int ci = Profiles_LB->count();
249 NSResources->addConnection( NC, 0 ); 249 NSResources->addNetworkSetup( NC, 0 );
250 NC->setNumber( NSResources->assignConnectionNumber() ); 250 NC->setNumber( NSResources->assignNetworkSetupNumber() );
251 Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); 251 Profiles_LB->insertItem( NC->devicePixmap(), NC->name() );
252 Profiles_LB->setSelected( ci, TRUE ); 252 Profiles_LB->setSelected( ci, TRUE );
253 } 253 }
254 updateProfileState( LBI ); 254 updateProfileState( LBI );
255 } 255 }
256 } else { 256 } else {
257 // cancelled : reset connection 257 // cancelled : reset NetworkSetup
258 if( LBI ) { 258 if( LBI ) {
259 NodeCollection * NC = NSResources->findConnection( LBI->text() ); 259 NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() );
260 NC->reassign(); 260 NC->reassign();
261 } 261 }
262 } 262 }
263 break; 263 break;
264 } 264 }
265 // reenable 265 // reenable
266 UpdateTimer->start( 5000 ); 266 UpdateTimer->start( 5000 );
267} 267}
268 268
269void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { 269void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
270 if( LBI == 0 ) 270 if( LBI == 0 )
271 return; 271 return;
272 272
273 NodeCollection * NC = NSResources->findConnection( LBI->text() ); 273 NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() );
274 274
275 if( NC->description().isEmpty() ) { 275 if( NC->description().isEmpty() ) {
276 Description_LBL->setText( tr( "<<No description>>" ) ); 276 Description_LBL->setText( tr( "<<No description>>" ) );
277 } else { 277 } else {
278 Description_LBL->setText( NC->description() ); 278 Description_LBL->setText( NC->description() );
279 } 279 }
280 280
281 Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() ); 281 Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() );
282 282
283 bool FrmActive = 1; 283 bool FrmActive = 1;
284 bool IsEnabled = 1; 284 bool IsEnabled = 1;
285 int leds = 0; 285 int leds = 0;
286 286
287 switch( NC->state() ) { 287 switch( NC->state() ) {
288 case Disabled : // no further work 288 case Disabled : // no further work
289 IsEnabled = 0; 289 IsEnabled = 0;
290 FrmActive = 0; 290 FrmActive = 0;
291 break; 291 break;
292 case Unknown : 292 case Unknown :
293 case Unchecked : 293 case Unchecked :
294 case Unavailable : 294 case Unavailable :
295 FrmActive = 0; 295 FrmActive = 0;
296 break; 296 break;
297 case Off : 297 case Off :
298 leds = 1; 298 leds = 1;
299 break; 299 break;
300 case Available : 300 case Available :
301 leds = 2; 301 leds = 2;
302 break; 302 break;
303 case IsUp : 303 case IsUp :
304 leds = 3; 304 leds = 3;
305 break; 305 break;
306 } 306 }
307 307
308 Disable_TB->setOn( ! IsEnabled ); 308 Disable_TB->setOn( ! IsEnabled );
309 LED_Frm->setEnabled( FrmActive ); 309 LED_Frm->setEnabled( FrmActive );
310 310
311 for( int i = 0 ; i < leds; i ++ ) { 311 for( int i = 0 ; i < leds; i ++ ) {
312 Leds[i]->setColor( red ); 312 Leds[i]->setColor( red );
313 Leds[i]->setOn( true ); 313 Leds[i]->setOn( true );
314 } 314 }
315 for( int i = leds ; i < 3; i ++ ) { 315 for( int i = leds ; i < 3; i ++ ) {
316 Leds[i]->setColor( red ); 316 Leds[i]->setColor( red );
317 Leds[i]->setOn( false ); 317 Leds[i]->setOn( false );
318 } 318 }
319 319
320 Up_TB->setEnabled( leds < 3 && leds != 0 ); 320 Up_TB->setEnabled( leds < 3 && leds != 0 );
321 Down_TB->setEnabled( leds > 0 ); 321 Down_TB->setEnabled( leds > 0 );
322} 322}
323 323
324void NetworkSettings::SLOT_CheckState( void ) { 324void NetworkSettings::SLOT_CheckState( void ) {
325 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 325 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
326 if ( ! LBI ) 326 if ( ! LBI )
327 return; 327 return;
328 updateProfileState( LBI ); 328 updateProfileState( LBI );
329} 329}
330 330
331void NetworkSettings::updateProfileState( QListBoxItem * LBI ) { 331void NetworkSettings::updateProfileState( QListBoxItem * LBI ) {
332 if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) { 332 if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) {
333 SLOT_ShowNode( LBI ); 333 SLOT_ShowNode( LBI );
334 } 334 }
335} 335}
336 336
337void NetworkSettings::SLOT_GenerateConfig( void ) { 337void NetworkSettings::SLOT_GenerateConfig( void ) {
338 QString S = NSD.generateSettings(); 338 QString S = NSD.generateSettings();
339 if( ! S.isEmpty() ) { 339 if( ! S.isEmpty() ) {
340 S.insert( 0, "<p>" ); 340 S.insert( 0, "<p>" );
341 S.append( "</p>" ); 341 S.append( "</p>" );
342 QMessageBox::warning( 342 QMessageBox::warning(
343 0, 343 0,
344 tr( "Generate config" ), 344 tr( "Generate config" ),
345 S); 345 S);
346 } 346 }
347} 347}
348 348
349void NetworkSettings::SLOT_Disable( bool T ) { 349void NetworkSettings::SLOT_Disable( bool T ) {
350 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 350 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
351 QString Msg; 351 QString Msg;
352 352
353 if ( ! LBI ) 353 if ( ! LBI )
354 return; 354 return;
355 355
356 NodeCollection * NC = NSResources->findConnection( LBI->text() ); 356 NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() );
357 357
358 Log(( "Prepare to %sable\n", (T) ? "en" : "dis" )); 358 Log(( "Prepare to %sable\n", (T) ? "en" : "dis" ));
359 Msg = NC->setState( (T) ? Disable : Enable ); 359 Msg = NC->setState( (T) ? Disable : Enable );
360 if( ! Msg.isEmpty() ) { 360 if( ! Msg.isEmpty() ) {
361 Msg.insert( 0, "<p>" ); 361 Msg.insert( 0, "<p>" );
362 Msg.append( "</p>" ); 362 Msg.append( "</p>" );
363 QMessageBox::warning( 363 QMessageBox::warning(
364 0, 364 0,
365 tr( "Activating profile" ), 365 tr( "Activating profile" ),
366 Msg ); 366 Msg );
367 return; 367 return;
368 } 368 }
369 369
370 // reload new state 370 // reload new state
371 NC->state( true ); 371 NC->state( true );
372 updateProfileState( LBI ); 372 updateProfileState( LBI );
373} 373}
374 374
375void NetworkSettings::SLOT_Up( void ) { 375void NetworkSettings::SLOT_Up( void ) {
376 // bring more up 376 // bring more up
377 377
378 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 378 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
379 QString Msg; 379 QString Msg;
380 int led = -1; 380 int led = -1;
381 381
382 if ( ! LBI ) 382 if ( ! LBI )
383 return; 383 return;
384 384
385 NodeCollection * NC = 385 NetworkSetup * NC =
386 NSResources->findConnection( LBI->text() ); 386 NSResources->findNetworkSetup( LBI->text() );
387 387
388 switch( NC->state() ) { 388 switch( NC->state() ) {
389 case Disabled : // cannot modify this state 389 case Disabled : // cannot modify this state
390 case Unknown : // cannot modify this state 390 case Unknown : // cannot modify this state
391 case Unchecked : // cannot modify this state 391 case Unchecked : // cannot modify this state
392 case Unavailable : // cannot modify this state 392 case Unavailable : // cannot modify this state
393 case IsUp : // highest UP state 393 case IsUp : // highest UP state
394 return; 394 return;
395 case Off : // -> activate 395 case Off : // -> activate
396 led = 1; 396 led = 1;
397 Down_TB->setEnabled( true ); 397 Down_TB->setEnabled( true );
398 Log(( "Activate interface %s\n", NC->name().latin1() )); 398 Log(( "Activate interface %s\n", NC->name().latin1() ));
399 Msg = NC->setState( Activate ); 399 Msg = NC->setState( Activate );
400 break; 400 break;
401 case Available : // -> up 401 case Available : // -> up
402 led = 2; 402 led = 2;
403 Log(( "Bring up interface %s\n", NC->name().latin1() )); 403 Log(( "Bring up interface %s\n", NC->name().latin1() ));
404 Msg = NC->setState( Up ); 404 Msg = NC->setState( Up );
405 if( Msg.isEmpty() ) { 405 if( Msg.isEmpty() ) {
406 Up_TB->setEnabled( false ); 406 Up_TB->setEnabled( false );
407 } 407 }
408 break; 408 break;
409 } 409 }
410 410
411 if( ! Msg.isEmpty() ) { 411 if( ! Msg.isEmpty() ) {
412 Msg.insert( 0, "<p>" ); 412 Msg.insert( 0, "<p>" );
413 Msg.append( "</p>" ); 413 Msg.append( "</p>" );
414 QMessageBox::warning( 414 QMessageBox::warning(
415 0, 415 0,
416 tr( "Increase availability" ), 416 tr( "Increase availability" ),
417 Msg ); 417 Msg );
418 return; 418 return;
419 } 419 }
420 420
421 updateProfileState( LBI ); 421 updateProfileState( LBI );
422 422
423 // set color of led we should change 423 // set color of led we should change
424 if( led > 0 ) { 424 if( led > 0 ) {
425 Leds[led]->setColor( blue ); 425 Leds[led]->setColor( blue );
426 Leds[led]->setOn( true ); 426 Leds[led]->setOn( true );
427 } 427 }
428 428
429} 429}
430 430
431void NetworkSettings::SLOT_Down( void ) { 431void NetworkSettings::SLOT_Down( void ) {
432 // bring more down 432 // bring more down
433 433
434 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 434 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
435 int led = -1; 435 int led = -1;
436 QString Msg; 436 QString Msg;
437 437
438 if ( ! LBI ) 438 if ( ! LBI )
439 return; 439 return;
440 440
441 NodeCollection * NC = 441 NetworkSetup * NC =
442 NSResources->findConnection( LBI->text() ); 442 NSResources->findNetworkSetup( LBI->text() );
443 443
444 switch( NC->state() ) { 444 switch( NC->state() ) {
445 case Disabled : // cannot modify this state 445 case Disabled : // cannot modify this state
446 case Unknown : // cannot modify this state 446 case Unknown : // cannot modify this state
447 case Unchecked : // cannot modify this state 447 case Unchecked : // cannot modify this state
448 case Unavailable : // cannot modify this state 448 case Unavailable : // cannot modify this state
449 case Off : // highest DOWN state 449 case Off : // highest DOWN state
450 break; 450 break;
451 case Available : // -> down 451 case Available : // -> down
452 led = 0; 452 led = 0;
453 Log(( "Deactivate interface %s\n", NC->name().latin1() )); 453 Log(( "Deactivate interface %s\n", NC->name().latin1() ));
454 Msg = NC->setState( Deactivate ); 454 Msg = NC->setState( Deactivate );
455 Down_TB->setEnabled( false ); 455 Down_TB->setEnabled( false );
456 break; 456 break;
457 case IsUp : // highest UP state 457 case IsUp : // highest UP state
458 led = 1; 458 led = 1;
459 Up_TB->setEnabled( true ); 459 Up_TB->setEnabled( true );
460 Log(( "Bring down interface %s\n", NC->name().latin1() )); 460 Log(( "Bring down interface %s\n", NC->name().latin1() ));
461 Msg = NC->setState( Down, 1 ); 461 Msg = NC->setState( Down, 1 );
462 if( Msg.isEmpty() ) { 462 if( Msg.isEmpty() ) {
463 // remove 'up' file to make sure 463 // remove 'up' file to make sure
464 unlink ( QString().sprintf( "/tmp/Profile-%d.up", NC->number() ).latin1() );; 464 unlink ( QString().sprintf( "/tmp/Profile-%d.up", NC->number() ).latin1() );;
465 } 465 }
466 break; 466 break;
467 } 467 }
468 468
469 if( ! Msg.isEmpty() ) { 469 if( ! Msg.isEmpty() ) {
470 Msg.insert( 0, "<p>" ); 470 Msg.insert( 0, "<p>" );
471 Msg.append( "</p>" ); 471 Msg.append( "</p>" );
472 QMessageBox::warning( 472 QMessageBox::warning(
473 0, 473 0,
474 tr( "Decrease availability" ), 474 tr( "Decrease availability" ),
475 Msg ); 475 Msg );
476 return; 476 return;
477 } 477 }
478 478
479 updateProfileState( LBI ); 479 updateProfileState( LBI );
480 480
481 // set color of led we should change 481 // set color of led we should change
482 if( led >= 0 ) { 482 if( led >= 0 ) {
483 Leds[led]->setColor( blue ); 483 Leds[led]->setColor( blue );
484 } 484 }
485} 485}
486 486
487void NetworkSettings::SLOT_ToMessages( void ) { 487void NetworkSettings::SLOT_ToMessages( void ) {
488 Profiles_LB->hide(); 488 Profiles_LB->hide();
489 Profile_GB->hide(); 489 Profile_GB->hide();
490 Messages_GB->show(); 490 Messages_GB->show();
491} 491}
492 492
493void NetworkSettings::SLOT_ToProfile( void ) { 493void NetworkSettings::SLOT_ToProfile( void ) {
494 Profiles_LB->show(); 494 Profiles_LB->show();
495 Profile_GB->show(); 495 Profile_GB->show();
496 Messages_GB->hide(); 496 Messages_GB->hide();
497} 497}
498 498
499void NetworkSettings::SLOT_QCopMessage(const QCString &msg, const QByteArray &data) { 499void NetworkSettings::SLOT_QCopMessage(const QCString &msg, const QByteArray &data) {
500 QDataStream stream( data, IO_ReadOnly ); 500 QDataStream stream( data, IO_ReadOnly );
501 501
502 if( msg == "raise" ) { 502 if( msg == "raise" ) {
503 raise(); 503 raise();
504 return; 504 return;
505 } /* if ( msg == "someMessage(int,int,int)" ) { 505 } /* if ( msg == "someMessage(int,int,int)" ) {
506 int a,b,c; 506 int a,b,c;
507 stream >> a >> b >> c; 507 stream >> a >> b >> c;
508 ... 508 ...
509 } */ 509 } */
510} 510}
diff --git a/noncore/settings/networksettings2/networksettings2/asconnection.h b/noncore/settings/networksettings2/networksettings2/asconnection.h
index 1ed7e74..eeb0939 100644
--- a/noncore/settings/networksettings2/networksettings2/asconnection.h
+++ b/noncore/settings/networksettings2/networksettings2/asconnection.h
@@ -1,18 +1,18 @@
1#ifndef ASCONNECTION_H 1#ifndef ASCONNECTION_H
2#define ASCONNECTION_H 2#define ASCONNECTION_H
3 3
4#include <resources.h> 4#include <resources.h>
5 5
6// pure virtual (component oriented) interface of any 6// pure virtual (component oriented) interface of any
7// plugin that offers a connection 7// plugin that offers a networkSetup
8class AsConnection : public RuntimeInfo { 8class AsNetworkSetup : public RuntimeInfo {
9 9
10public : 10public :
11 11
12 AsConnection( ANetNodeInstance * NNI ) : 12 AsNetworkSetup( ANetNodeInstance * NNI ) :
13 RuntimeInfo( NNI ) { 13 RuntimeInfo( NNI ) {
14 } 14 }
15 15
16}; 16};
17 17
18#endif 18#endif
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp
index f00e0b3..0ab0e5b 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.cpp
+++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp
@@ -32,488 +32,497 @@ static char * StateName[] = {
32QString & deQuote( QString & X ) { 32QString & deQuote( QString & X ) {
33 if( X[0] == '"' ) { 33 if( X[0] == '"' ) {
34 // remove end and trailing "" and \x -> x 34 // remove end and trailing "" and \x -> x
35 QChar R; 35 QChar R;
36 long idx; 36 long idx;
37 idx = X.length()-1; 37 idx = X.length()-1;
38 X = X.mid( 1, idx ); 38 X = X.mid( 1, idx );
39 39
40 idx = 0; 40 idx = 0;
41 while( ( idx = X.find( '\\', idx ) ) >= 0 ) { 41 while( ( idx = X.find( '\\', idx ) ) >= 0 ) {
42 R = X.at( idx + 1 ); 42 R = X.at( idx + 1 );
43 X.replace( idx, 2, &R, 1 ); 43 X.replace( idx, 2, &R, 1 );
44 } 44 }
45 X = X.left( X.length()-1 ); 45 X = X.left( X.length()-1 );
46 } 46 }
47 return X; 47 return X;
48} 48}
49 49
50QString quote( QString X ) { 50QString quote( QString X ) {
51 if( X.find( QRegExp( "[ \n\"\\\t]" ) ) >= 0 ) { 51 if( X.find( QRegExp( "[ \n\"\\\t]" ) ) >= 0 ) {
52 // need to quote this 52 // need to quote this
53 QString OutString = "\""; 53 QString OutString = "\"";
54 54
55 X.replace( QRegExp("\""), "\\\"" ); 55 X.replace( QRegExp("\""), "\\\"" );
56 X.replace( QRegExp("\\"), "\\\\" ); 56 X.replace( QRegExp("\\"), "\\\\" );
57 X.replace( QRegExp(" "), "\\ " ); 57 X.replace( QRegExp(" "), "\\ " );
58 58
59 OutString += X; 59 OutString += X;
60 OutString += "\""; 60 OutString += "\"";
61 X = OutString; 61 X = OutString;
62 } 62 }
63 return X; 63 return X;
64} 64}
65 65
66 66
67// 67//
68// 68//
69// ANETNODE 69// ANETNODE
70// 70//
71// 71//
72 72
73void ANetNode::saveAttributes( QTextStream & TS ) { 73void ANetNode::saveAttributes( QTextStream & TS ) {
74 saveSpecificAttribute( TS ); 74 saveSpecificAttribute( TS );
75} 75}
76 76
77void ANetNode::setAttribute( QString & Attr, QString & Value ){ 77void ANetNode::setAttribute( QString & Attr, QString & Value ){
78 setSpecificAttribute( Attr, Value ); 78 setSpecificAttribute( Attr, Value );
79} 79}
80 80
81bool ANetNode::isToplevel( void ) { 81bool ANetNode::isToplevel( void ) {
82 const char ** P = provides(); 82 const char ** P = provides();
83 while( *P ) { 83 while( *P ) {
84 if( strcmp( *P, "fullsetup") == 0 ) 84 if( strcmp( *P, "fullsetup") == 0 )
85 return 1; 85 return 1;
86 P ++; 86 P ++;
87 } 87 }
88 return 0; 88 return 0;
89} 89}
90 90
91bool ANetNode::openFile( SystemFile & SF, 91bool ANetNode::openFile( SystemFile & SF,
92 ANetNodeInstance * NNI ) { 92 ANetNodeInstance * NNI ) {
93 return (NNI ) ? NNI->openFile( SF ) : 0 ; 93 return (NNI ) ? NNI->openFile( SF ) : 0 ;
94} 94}
95 95
96// 96//
97// 97//
98// ANETNODEINSTANCE 98// ANETNODEINSTANCE
99// 99//
100// 100//
101 101
102long ANetNodeInstance::InstanceCounter = -1; 102long ANetNodeInstance::InstanceCounter = -1;
103 103
104void ANetNodeInstance::initialize( void ) { 104void ANetNodeInstance::initialize( void ) {
105 if( InstanceCounter == -1 ) 105 if( InstanceCounter == -1 )
106 InstanceCounter = time(0); 106 InstanceCounter = time(0);
107 // set name 107 // set name
108 QString N; 108 QString N;
109 N.sprintf( "-%ld", InstanceCounter++ ); 109 N.sprintf( "-%ld", InstanceCounter++ );
110 N.prepend( NodeType->name() ); 110 N.prepend( NodeType->name() );
111 setName( N.latin1() ); 111 setName( N.latin1() );
112} 112}
113 113
114void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ 114void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){
115 if( Attr == "__name" ) { 115 if( Attr == "__name" ) {
116 setName( Value.latin1() ); 116 setName( Value.latin1() );
117 } else { 117 } else {
118 setSpecificAttribute( Attr, Value ); 118 setSpecificAttribute( Attr, Value );
119 } 119 }
120} 120}
121 121
122void ANetNodeInstance::saveAttributes( QTextStream & TS ) { 122void ANetNodeInstance::saveAttributes( QTextStream & TS ) {
123 TS << "__name=" << name() << endl; 123 TS << "__name=" << name() << endl;
124 saveSpecificAttribute( TS ); 124 saveSpecificAttribute( TS );
125} 125}
126 126
127ANetNodeInstance * ANetNodeInstance::nextNode( void ) { 127ANetNodeInstance * ANetNodeInstance::nextNode( void ) {
128 return connection()->findNext( this ); 128 return networkSetup()->findNext( this );
129} 129}
130 130
131// 131//
132// 132//
133// NODECOLLECTION 133// NODECOLLECTION
134// 134//
135// 135//
136 136
137NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { 137NetworkSetup::NetworkSetup( void ) : QList<ANetNodeInstance>() {
138 IsModified = 0; 138 IsModified = 0;
139 Index = -1; 139 Index = -1;
140 Name=""; 140 Name="";
141 IsNew = 1; 141 IsNew = 1;
142 CurrentState = Unchecked; 142 CurrentState = Unchecked;
143 AssignedInterface = 0; 143 AssignedInterface = 0;
144 Number = -1; 144 Number = -1;
145 Done = 0; 145 Done = 0;
146} 146}
147 147
148NodeCollection::NodeCollection( QTextStream & TS, bool & Dangling ) : 148NetworkSetup::NetworkSetup( QTextStream & TS, bool & Dangling ) :
149 QList<ANetNodeInstance>() { 149 QList<ANetNodeInstance>() {
150 long idx; 150 long idx;
151 QString S, A, N; 151 QString S, A, N;
152 152
153 Number = -1; 153 Number = -1;
154 Done = 0; 154 Done = 0;
155 IsModified = 0; 155 IsModified = 0;
156 Index = -1; 156 Index = -1;
157 Name=""; 157 Name="";
158 IsNew = 0; 158 IsNew = 0;
159 AssignedInterface = 0; 159 AssignedInterface = 0;
160 CurrentState = Unchecked; 160 CurrentState = Unchecked;
161 161
162 Dangling = 0; // by default node collection is ok 162 Dangling = 0; // by default node collection is ok
163 163
164 do { 164 do {
165 S = TS.readLine(); 165 S = TS.readLine();
166 if( S.isEmpty() ) { 166 if( S.isEmpty() ) {
167 // empty line 167 // empty line
168 break; 168 break;
169 } 169 }
170 170
171 idx = S.find('='); 171 idx = S.find('=');
172 S.stripWhiteSpace(); 172 S.stripWhiteSpace();
173 A = S.left( idx ); 173 A = S.left( idx );
174 A.lower(); 174 A.lower();
175 N = S.mid( idx+1, S.length() ); 175 N = S.mid( idx+1, S.length() );
176 N.stripWhiteSpace(); 176 N.stripWhiteSpace();
177 N = deQuote( N ); 177 N = deQuote( N );
178 178
179 if( A == "name" ) { 179 if( A == "name" ) {
180 Name = N; 180 Name = N;
181 } else if( A == "number" ) { 181 } else if( A == "number" ) {
182 setNumber( N.toLong() ); 182 setNumber( N.toLong() );
183 } else if( A == "node" ) { 183 } else if( A == "node" ) {
184 ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); 184 ANetNodeInstance * NNI = NSResources->findNodeInstance( N );
185 Log(( "Find node %s : %p\n", N.latin1(), NNI )); 185 Log(( "Find node %s : %p\n", N.latin1(), NNI ));
186 if( NNI ) { 186 if( NNI ) {
187 append( NNI ); 187 append( NNI );
188 } else { 188 } else {
189 // could not find a node type -> collection invalid 189 // could not find a node type -> collection invalid
190 Log(( "Node %s missing -> connection dangling\n", 190 Log(( "Node %s missing -> NetworkSetup dangling\n",
191 N.latin1() )); 191 N.latin1() ));
192 // create placeholder for this dangling NNI 192 // create placeholder for this dangling NNI
193 NNI = new ErrorNNI( N ); 193 NNI = new ErrorNNI( N );
194 Dangling = 1; 194 Dangling = 1;
195 } 195 }
196 } 196 }
197 } while( 1 ); 197 } while( 1 );
198 198
199 Log(( "Profile number %s : %d nodes\n", 199 Log(( "Profile number %s : %d nodes\n",
200 Name.latin1(), count() )); 200 Name.latin1(), count() ));
201} 201}
202 202
203NodeCollection::~NodeCollection( void ) { 203NetworkSetup::~NetworkSetup( void ) {
204} 204}
205 205
206const QString & NodeCollection::description( void ) { 206const QString & NetworkSetup::description( void ) {
207 ANetNodeInstance * NNI = getToplevel(); 207 ANetNodeInstance * NNI = getToplevel();
208 return (NNI) ? NNI->runtime()->description() : Name; 208 return (NNI) ? NNI->runtime()->description() : Name;
209} 209}
210 210
211void NodeCollection::append( ANetNodeInstance * NNI ) { 211void NetworkSetup::append( ANetNodeInstance * NNI ) {
212 NNI->setConnection( this ); 212 NNI->setNetworkSetup( this );
213 QList<ANetNodeInstance>::append( NNI ); 213 QList<ANetNodeInstance>::append( NNI );
214} 214}
215 215
216void NodeCollection::save( QTextStream & TS ) { 216void NetworkSetup::save( QTextStream & TS ) {
217 217
218 TS << "name=" << quote( Name ) << endl; 218 TS << "name=" << quote( Name ) << endl;
219 TS << "number=" << number() << endl; 219 TS << "number=" << number() << endl;
220 ANetNodeInstance * NNI; 220 ANetNodeInstance * NNI;
221 for( QListIterator<ANetNodeInstance> it(*this); 221 for( QListIterator<ANetNodeInstance> it(*this);
222 it.current(); 222 it.current();
223 ++it ) { 223 ++it ) {
224 NNI = it.current(); 224 NNI = it.current();
225 TS << "node=" << NNI->name() << endl; 225 TS << "node=" << NNI->name() << endl;
226 } 226 }
227 TS << endl; 227 TS << endl;
228 IsNew = 0; 228 IsNew = 0;
229} 229}
230 230
231ANetNodeInstance * NodeCollection::getToplevel( void ) { 231ANetNodeInstance * NetworkSetup::getToplevel( void ) {
232 ANetNodeInstance * NNI = 0; 232 ANetNodeInstance * NNI = 0;
233 for( QListIterator<ANetNodeInstance> it(*this); 233 for( QListIterator<ANetNodeInstance> it(*this);
234 it.current(); 234 it.current();
235 ++it ) { 235 ++it ) {
236 NNI = it.current(); 236 NNI = it.current();
237 if( NNI->nodeClass()->isToplevel() ) { 237 if( NNI->nodeClass()->isToplevel() ) {
238 return NNI; 238 return NNI;
239 } 239 }
240 } 240 }
241 return 0; 241 return 0;
242} 242}
243 243
244ANetNodeInstance * NodeCollection::findByName( const QString & S ) { 244ANetNodeInstance * NetworkSetup::findByName( const QString & S ) {
245 ANetNodeInstance * NNI = 0; 245 ANetNodeInstance * NNI = 0;
246 for( QListIterator<ANetNodeInstance> it(*this); 246 for( QListIterator<ANetNodeInstance> it(*this);
247 it.current(); 247 it.current();
248 ++it ) { 248 ++it ) {
249 NNI = it.current(); 249 NNI = it.current();
250 if( NNI->name() == S ) { 250 if( NNI->name() == S ) {
251 return NNI; 251 return NNI;
252 } 252 }
253 } 253 }
254 return 0; 254 return 0;
255} 255}
256 256
257ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { 257ANetNodeInstance * NetworkSetup::findNext( ANetNodeInstance * NNI ) {
258 ANetNodeInstance * NNNI; 258 ANetNodeInstance * NNNI;
259 259
260 if( ! NNI ) 260 if( ! NNI )
261 getToplevel(); 261 getToplevel();
262 262
263 for( QListIterator<ANetNodeInstance> it(*this); 263 for( QListIterator<ANetNodeInstance> it(*this);
264 it.current(); 264 it.current();
265 ++it ) { 265 ++it ) {
266 NNNI = it.current(); 266 NNNI = it.current();
267 if( NNNI == NNI ) { 267 if( NNNI == NNI ) {
268 ++it; 268 ++it;
269 return it.current(); 269 return it.current();
270 } 270 }
271 } 271 }
272 return 0; // no more next 272 return 0; // no more next
273} 273}
274 274
275int NodeCollection::compareItems( QCollection::Item I1, 275int NetworkSetup::compareItems( QCollection::Item I1,
276 QCollection::Item I2 ) { 276 QCollection::Item I2 ) {
277 ANetNodeInstance * NNI1, * NNI2; 277 ANetNodeInstance * NNI1, * NNI2;
278 NNI1 = (ANetNodeInstance *)I1; 278 NNI1 = (ANetNodeInstance *)I1;
279 NNI2 = (ANetNodeInstance *)I2; 279 NNI2 = (ANetNodeInstance *)I2;
280 return strcmp( NNI1->name(), NNI2->name() ); 280 return strcmp( NNI1->name(), NNI2->name() );
281} 281}
282 282
283static char * State2PixmapTbl[] = { 283static char * State2PixmapTbl[] = {
284 "NULL", // Unchecked : no pixmap 284 "NULL", // Unchecked : no pixmap
285 "check", // Unknown 285 "check", // Unknown
286 "delete", // unavailable 286 "delete", // unavailable
287 "disabled", // disabled 287 "disabled", // disabled
288 "off", // off 288 "off", // off
289 "disconnected", // available 289 "disconnected", // available
290 "connected" // up 290 "connected" // up
291}; 291};
292 292
293QPixmap NodeCollection::devicePixmap( void ) { 293QPixmap NetworkSetup::devicePixmap( void ) {
294 QPixmap pm = NSResources->getPixmap( 294 QPixmap pm = NSResources->getPixmap(
295 getToplevel()->nextNode()->pixmapName()+"-large"); 295 getToplevel()->nextNode()->pixmapName()+"-large");
296 296
297 QPixmap Mini = NSResources->getPixmap( 297 QPixmap Mini = NSResources->getPixmap(
298 device()->netNode()->pixmapName() ); 298 device()->netNode()->pixmapName() );
299 299
300 if( pm.isNull() || Mini.isNull() ) 300 if( pm.isNull() || Mini.isNull() )
301 return Resource::loadPixmap("Unknown"); 301 return Resource::loadPixmap("Unknown");
302 302
303 QPainter painter( &pm ); 303 QPainter painter( &pm );
304 painter.drawPixmap( pm.width()-Mini.width(), 304 painter.drawPixmap( pm.width()-Mini.width(),
305 pm.height()-Mini.height(), 305 pm.height()-Mini.height(),
306 Mini ); 306 Mini );
307 pm.setMask( pm.createHeuristicMask( TRUE ) ); 307 pm.setMask( pm.createHeuristicMask( TRUE ) );
308 return pm; 308 return pm;
309} 309}
310 310
311QPixmap NodeCollection::statePixmap( State_t S) { 311QPixmap NetworkSetup::statePixmap( State_t S) {
312 return NSResources->getPixmap( State2PixmapTbl[S] ); 312 return NSResources->getPixmap( State2PixmapTbl[S] );
313} 313}
314 314
315QString NodeCollection::stateName( State_t S) { 315QString NetworkSetup::stateName( State_t S) {
316 switch( S ) { 316 switch( S ) {
317 case Unknown : 317 case Unknown :
318 return qApp->translate( "networksettings2", "Unknown"); 318 return qApp->translate( "networksettings2", "Unknown");
319 case Unavailable : 319 case Unavailable :
320 return qApp->translate( "networksettings2", "Unavailable"); 320 return qApp->translate( "networksettings2", "Unavailable");
321 case Disabled : 321 case Disabled :
322 return qApp->translate( "networksettings2", "Disabled"); 322 return qApp->translate( "networksettings2", "Disabled");
323 case Off : 323 case Off :
324 return qApp->translate( "networksettings2", "Inactive"); 324 return qApp->translate( "networksettings2", "Inactive");
325 case Available : 325 case Available :
326 return qApp->translate( "networksettings2", "Available"); 326 return qApp->translate( "networksettings2", "Available");
327 case IsUp : 327 case IsUp :
328 return qApp->translate( "networksettings2", "Up"); 328 return qApp->translate( "networksettings2", "Up");
329 case Unchecked : /* FT */ 329 case Unchecked : /* FT */
330 default : 330 default :
331 break; 331 break;
332 } 332 }
333 return QString(""); 333 return QString("");
334} 334}
335 335
336void NodeCollection::reassign( void ) { 336void NetworkSetup::reassign( void ) {
337 for( QListIterator<ANetNodeInstance> it(*this); 337 for( QListIterator<ANetNodeInstance> it(*this);
338 it.current(); 338 it.current();
339 ++it ) { 339 ++it ) {
340 it.current()->setConnection( this ); 340 it.current()->setNetworkSetup( this );
341 } 341 }
342} 342}
343 343
344const QStringList & NodeCollection::triggers() { 344const QStringList & NetworkSetup::triggers() {
345 return getToplevel()->runtime()->triggers(); 345 return getToplevel()->runtime()->triggers();
346} 346}
347 347
348bool NodeCollection::hasDataForFile( SystemFile & S ) { 348bool NetworkSetup::hasDataForFile( SystemFile & S ) {
349 return ( firstWithDataForFile( S ) != 0 ); 349 return ( firstWithDataForFile( S ) != 0 );
350} 350}
351 351
352ANetNodeInstance * NodeCollection::firstWithDataForFile( SystemFile & S ) { 352ANetNodeInstance * NetworkSetup::firstWithDataForFile( SystemFile & S ) {
353 for( QListIterator<ANetNodeInstance> it(*this); 353 for( QListIterator<ANetNodeInstance> it(*this);
354 it.current(); 354 it.current();
355 ++it ) { 355 ++it ) {
356 if( it.current()->hasDataForFile( S ) ) { 356 if( it.current()->hasDataForFile( S ) ) {
357 return it.current(); 357 return it.current();
358 } 358 }
359 } 359 }
360 return 0; 360 return 0;
361} 361}
362 362
363State_t NodeCollection::state( bool Update ) { 363State_t NetworkSetup::state( bool Update ) {
364 State_t NodeState; 364 State_t NodeState;
365 365
366 if( CurrentState == Unchecked || Update ) { 366 if( CurrentState == Unchecked || Update ) {
367 // collect states of all nodes until with get the 'higest' 367 // collect states of all nodes until with get the 'higest'
368 // state possible 368 // state possible
369 369
370 Log(( "Connection %s state %s\n", 370 Log(( "NetworkSetup %s state %s\n",
371 Name.latin1(), StateName[CurrentState] )); 371 Name.latin1(), StateName[CurrentState] ));
372 372
373 CurrentState = Unknown; 373 CurrentState = Unknown;
374 for( QListIterator<ANetNodeInstance> it(*this); 374 for( QListIterator<ANetNodeInstance> it(*this);
375 it.current(); 375 it.current();
376 ++it ) { 376 ++it ) {
377 Log(( "-> Detect %s\n", it.current()->name() )); 377 Log(( "-> Detect %s\n", it.current()->name() ));
378 NodeState = it.current()->runtime()->detectState(); 378 NodeState = it.current()->runtime()->detectState();
379 Log(( " state %s\n", StateName[NodeState] )); 379 Log(( " state %s\n", StateName[NodeState] ));
380 380
381 if( NodeState == Disabled || 381 if( NodeState == Disabled ||
382 NodeState == IsUp ) { 382 NodeState == IsUp ) {
383 // max 383 // max
384 CurrentState = NodeState; 384 CurrentState = NodeState;
385 break; 385 break;
386 } 386 }
387 387
388 if( NodeState > CurrentState ) { 388 if( NodeState > CurrentState ) {
389 // higher 389 // higher
390 CurrentState = NodeState; 390 CurrentState = NodeState;
391 } 391 }
392 } 392 }
393 } 393 }
394 394
395 return CurrentState; 395 return CurrentState;
396} 396}
397 397
398QString NodeCollection::setState( Action_t A, bool Force ) { 398QString NetworkSetup::setState( Action_t A, bool Force ) {
399 399
400 QString msg; 400 QString msg;
401 Action_t Actions[10]; 401 Action_t Actions[10];
402 int NoOfActions = 0; 402 int NoOfActions = 0;
403 403
404 // get current state 404 // get current state
405 state( Force ); 405 state( Force );
406 406
407 switch( A ) { 407 switch( A ) {
408 case Disable : 408 case Disable :
409 if( CurrentState < Disabled ) { 409 if( CurrentState < Disabled ) {
410 // disabled 410 // disabled
411 CurrentState = Disabled; 411 CurrentState = Disabled;
412 return QString(); 412 return QString();
413 } 413 }
414 414
415 if( CurrentState == IsUp ) { 415 if( CurrentState == IsUp ) {
416 Actions[NoOfActions++] = Down; 416 Actions[NoOfActions++] = Down;
417 Actions[NoOfActions++] = Deactivate; 417 Actions[NoOfActions++] = Deactivate;
418 } else if( CurrentState == Available ) { 418 } else if( CurrentState == Available ) {
419 Actions[NoOfActions++] = Deactivate; 419 Actions[NoOfActions++] = Deactivate;
420 } 420 }
421 Actions[NoOfActions++] = Disable; 421 Actions[NoOfActions++] = Disable;
422 break; 422 break;
423 case Enable : 423 case Enable :
424 // always possible -> detected state is new state 424 // always possible -> detected state is new state
425 Actions[NoOfActions++] = Enable; 425 Actions[NoOfActions++] = Enable;
426 break; 426 break;
427 case Activate : 427 case Activate :
428 if( ! Force ) { 428 if( ! Force ) {
429 if( CurrentState >= Available ) { 429 if( CurrentState >= Available ) {
430 // already available 430 // already available
431 return QString(); 431 return QString();
432 } 432 }
433 433
434 if( CurrentState != Off ) { 434 if( CurrentState != Off ) {
435 return qApp->translate( "System", 435 return qApp->translate( "System",
436 "State should be off" ); 436 "State should be off" );
437 } 437 }
438 } 438 }
439 439
440 Actions[NoOfActions++] = Activate; 440 Actions[NoOfActions++] = Activate;
441 break; 441 break;
442 case Deactivate : 442 case Deactivate :
443 if( ! Force ) { 443 if( ! Force ) {
444 if( CurrentState < Off ) { 444 if( CurrentState < Off ) {
445 // already inactive 445 // already inactive
446 return QString(); 446 return QString();
447 } 447 }
448 } 448 }
449 449
450 if( CurrentState == IsUp ) { 450 if( CurrentState == IsUp ) {
451 Actions[NoOfActions++] = Down; 451 Actions[NoOfActions++] = Down;
452 } 452 }
453 Actions[NoOfActions++] = Deactivate; 453 Actions[NoOfActions++] = Deactivate;
454 break; 454 break;
455 case Up : 455 case Up :
456 if( ! Force ) { 456 if( ! Force ) {
457 if( CurrentState == IsUp ) { 457 if( CurrentState == IsUp ) {
458 return QString(); 458 return QString();
459 } 459 }
460 if( CurrentState < Off ) { 460 if( CurrentState < Off ) {
461 return qApp->translate( "System", 461 return qApp->translate( "System",
462 "State should at least be off" ); 462 "State should at least be off" );
463 } 463 }
464 } 464 }
465 if( CurrentState == Off ) { 465 if( CurrentState == Off ) {
466 Actions[NoOfActions++] = Activate; 466 Actions[NoOfActions++] = Activate;
467 } 467 }
468 Actions[NoOfActions++] = Up; 468 Actions[NoOfActions++] = Up;
469 break; 469 break;
470 case Down : 470 case Down :
471 if( ! Force ) { 471 if( ! Force ) {
472 if( CurrentState < Available ) { 472 if( CurrentState < Available ) {
473 // OK 473 // OK
474 return QString(); 474 return QString();
475 } 475 }
476 } 476 }
477 Actions[NoOfActions++] = Down; 477 Actions[NoOfActions++] = Down;
478 break; 478 break;
479 } 479 }
480 480
481 // send actions to all nodes 481 // send actions to all nodes
482 Log(( "Action %s requires %d steps\n", 482 Log(( "Action %s requires %d steps\n",
483 ActionName[A], NoOfActions )); 483 ActionName[A], NoOfActions ));
484 484
485 for( int i = 0 ; i < NoOfActions; i ++ ) { 485 for( int i = 0 ; i < NoOfActions; i ++ ) {
486 // setState recurses through the tree depth first 486 // setState recurses through the tree depth first
487 msg = getToplevel()->runtime()->setState( this, Actions[i], Force ); 487 msg = getToplevel()->runtime()->setState( this, Actions[i], Force );
488 if( ! msg.isEmpty() ) { 488 if( ! msg.isEmpty() ) {
489 return msg; 489 return msg;
490 } 490 }
491 } 491 }
492 return QString(); 492 return QString();
493} 493}
494 494
495void NetworkSetup::copyFrom( const NetworkSetup & N ) {
496 Number = N.Number;
497 CurrentState = N.CurrentState;
498 Name = N.Name;
499 IsNew = N.IsNew;
500 Index = N.Index;
501 AssignedInterface = N.AssignedInterface;
502}
503
495// 504//
496// 505//
497// RuntimeInfo 506// RuntimeInfo
498// 507//
499// 508//
500 509
501QString RuntimeInfo::setState( NodeCollection * NC, 510QString RuntimeInfo::setState( NetworkSetup * NC,
502 Action_t A, 511 Action_t A,
503 bool Force ) { 512 bool Force ) {
504 QString M; 513 QString M;
505 RuntimeInfo * Deeper = nextNode(); 514 RuntimeInfo * Deeper = nextNode();
506 515
507 if( Deeper ) { 516 if( Deeper ) {
508 // first go deeper 517 // first go deeper
509 M = Deeper->setState( NC, A, Force ); 518 M = Deeper->setState( NC, A, Force );
510 if( ! M.isEmpty() ) 519 if( ! M.isEmpty() )
511 return M; 520 return M;
512 } 521 }
513 522
514 // set my own state 523 // set my own state
515 Log (( "-> Act upon %s\n", netNode()->name() )); 524 Log (( "-> Act upon %s\n", netNode()->name() ));
516 M = setMyState( NC, A, Force ); 525 M = setMyState( NC, A, Force );
517 Log (( " result %s\n", M.latin1() )); 526 Log (( " result %s\n", M.latin1() ));
518 return M; 527 return M;
519} 528}
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index 151d546..8aebdc0 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -1,638 +1,641 @@
1#ifndef NETNODE_H 1#ifndef NETNODE_H
2#define NETNODE_H 2#define NETNODE_H
3 3
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qlist.h> 5#include <qlist.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qstringlist.h> 8#include <qstringlist.h>
9#include <qobject.h> 9#include <qobject.h>
10#include <time.h> 10#include <time.h>
11 11
12#include <Utils.h> 12#include <Utils.h>
13#include <system.h> 13#include <system.h>
14 14
15// difference feature interfaces 15// difference feature interfaces
16class AsDevice; 16class AsDevice;
17class AsLine; 17class AsLine;
18class AsConnection; 18class AsNetworkSetup;
19class AsFullSetup; 19class AsFullSetup;
20 20
21// needed for plugin creation function 21// needed for plugin creation function
22#include <qlist.h> 22#include <qlist.h>
23 23
24class ANetNode; 24class ANetNode;
25class ANetNodeInstance; 25class ANetNodeInstance;
26class NodeCollection; 26class NetworkSetup;
27class QTextStream; 27class QTextStream;
28class RuntimeInfo; 28class RuntimeInfo;
29class InterfaceInfo; 29class InterfaceInfo;
30class NSResources; 30class NSResources;
31 31
32extern QString & deQuote( QString & X ); 32extern QString & deQuote( QString & X );
33extern QString quote( QString X ); 33extern QString quote( QString X );
34 34
35#include "systemfile.h" 35#include "systemfile.h"
36 36
37typedef enum State { 37typedef enum State {
38 // if we have not yet detected the state of the device 38 // if we have not yet detected the state of the device
39 Unchecked = 0, 39 Unchecked = 0,
40 // if we cannot determine the state 40 // if we cannot determine the state
41 Unknown = 1, 41 Unknown = 1,
42 // if connection cannot be established e.g. because 42 // if networkSetup cannot be established e.g. because
43 // the hardware is not available 43 // the hardware is not available
44 Unavailable = 2, 44 Unavailable = 2,
45 // if the connection cannot be establishec but NOT 45 // if the networkSetup cannot be establishec but NOT
46 // because it is physically impossible but because 46 // because it is physically impossible but because
47 // it has been disabled for FUNCTIONAL reasons 47 // it has been disabled for FUNCTIONAL reasons
48 Disabled = 3, 48 Disabled = 3,
49 // if connection is available to is currently down 49 // if networkSetup is available to is currently down
50 // i.e. the corresponding hardware is not activated 50 // i.e. the corresponding hardware is not activated
51 Off = 4, 51 Off = 4,
52 // if connection is available to be used (i.e. the 52 // if networkSetup is available to be used (i.e. the
53 // devices if fully ready to be used 53 // devices if fully ready to be used
54 Available = 5, 54 Available = 5,
55 // if connection is being used 55 // if networkSetup is being used
56 IsUp = 6 56 IsUp = 6
57} State_t; 57} State_t;
58 58
59typedef enum Action { 59typedef enum Action {
60 // to make the device unavailable functionally -> to disabled 60 // to make the device unavailable functionally -> to disabled
61 Disable = 0, 61 Disable = 0,
62 // to make the device available functionally -> to off 62 // to make the device available functionally -> to off
63 Enable = 1, 63 Enable = 1,
64 // bring the hardware up -> to Available 64 // bring the hardware up -> to Available
65 Activate = 2, 65 Activate = 2,
66 // bring the hardware down -> to off 66 // bring the hardware down -> to off
67 Deactivate = 3, 67 Deactivate = 3,
68 // bring the connection up -> to IsUp 68 // bring the networkSetup up -> to IsUp
69 Up = 4, 69 Up = 4,
70 // bring the connection down -> to Available 70 // bring the networkSetup down -> to Available
71 Down = 5 71 Down = 5
72} Action_t; 72} Action_t;
73 73
74class ANetNode : public QObject { 74class ANetNode : public QObject {
75 75
76public: 76public:
77 77
78 typedef QArray<ANetNode *> NetNodeList; 78 typedef QArray<ANetNode *> NetNodeList;
79 79
80 ANetNode( const char * Name ) : QObject( 0, Name ) {} 80 ANetNode( const char * Name ) : QObject( 0, Name ) {}
81 virtual ~ANetNode(){}; 81 virtual ~ANetNode(){};
82 82
83 // 83 //
84 // 84 //
85 // standard methods with sensible default 85 // standard methods with sensible default
86 // 86 //
87 // 87 //
88 88
89 inline int done( void ) 89 inline int done( void )
90 { return Done; } 90 { return Done; }
91 inline void setDone( int D ) 91 inline void setDone( int D )
92 { Done = D; } 92 { Done = D; }
93 93
94 // does this Node provide a Connection 94 // does this Node provide a NetworkSetup
95 bool isToplevel( void ); 95 bool isToplevel( void );
96 96
97 // set the value of an attribute 97 // set the value of an attribute
98 void setAttribute( QString & Attr, QString & Value ) ; 98 void setAttribute( QString & Attr, QString & Value ) ;
99 void saveAttributes( QTextStream & TS ) ; 99 void saveAttributes( QTextStream & TS ) ;
100 100
101 // compiled references to 'needed' NetNodes -> needs list 101 // compiled references to 'needed' NetNodes -> needs list
102 inline void setAlternatives( NetNodeList * Alt ) 102 inline void setAlternatives( NetNodeList * Alt )
103 { Alternatives = Alt; } 103 { Alternatives = Alt; }
104 inline NetNodeList & alternatives( void ) 104 inline NetNodeList & alternatives( void )
105 { return *Alternatives; } 105 { return *Alternatives; }
106 106
107 // 107 //
108 // 108 //
109 // Virtual methods with sensible default 109 // Virtual methods with sensible default
110 // 110 //
111 // 111 //
112 112
113 // do instances of this noce class have data for this file 113 // do instances of this noce class have data for this file
114 virtual bool hasDataForFile( SystemFile & ) 114 virtual bool hasDataForFile( SystemFile & )
115 { return 0; } 115 { return 0; }
116 116
117 // open proper file SF identified by S 117 // open proper file SF identified by S
118 // this method is called by NS2. 118 // this method is called by NS2.
119 // 119 //
120 // overrule this ONLY if this proper file is a common file 120 // overrule this ONLY if this proper file is a common file
121 // for all NNI of this node class and the data generated 121 // for all NNI of this node class and the data generated
122 // by each of the NNI needs to be put in one file 122 // by each of the NNI needs to be put in one file
123 // 123 //
124 // if this is the case the file should be (re)opened in append 124 // if this is the case the file should be (re)opened in append
125 // return 0 if file cannot be opened 125 // return 0 if file cannot be opened
126 virtual bool openFile( SystemFile &SF, 126 virtual bool openFile( SystemFile &SF,
127 ANetNodeInstance * NNI ); 127 ANetNodeInstance * NNI );
128 128
129 // generate instance independent stuff 129 // generate instance independent stuff
130 // 0 : data output, 1 no data, 2 error 130 // 0 : data output, 1 no data, 2 error
131 virtual short generatePreamble( SystemFile & ) 131 virtual short generatePreamble( SystemFile & )
132 { return 1; } 132 { return 1; }
133 133
134 // generate instance independent stuff 134 // generate instance independent stuff
135 // 0 : data output, 1 no data, 2 error 135 // 0 : data output, 1 no data, 2 error
136 virtual short generatePostamble( SystemFile & ) 136 virtual short generatePostamble( SystemFile & )
137 { return 1; } 137 { return 1; }
138 138
139 // generate instance dependent but instance common stuff 139 // generate instance dependent but instance common stuff
140 // 0 : data output, 1 no data, 2 error 140 // 0 : data output, 1 no data, 2 error
141 virtual short generateFile( SystemFile &, 141 virtual short generateFile( SystemFile &,
142 ANetNodeInstance * , 142 ANetNodeInstance * ,
143 long ) 143 long )
144 { return 1; } 144 { return 1; }
145 145
146 // generate NIC name based on instance nr 146 // generate NIC name based on instance nr
147 // only relevant if node instances are devices 147 // only relevant if node instances are devices
148 virtual QString genNic( long ) 148 virtual QString genNic( long )
149 { return QString(""); } 149 { return QString(""); }
150 150
151 // max number of instances for this node type 151 // max number of instances for this node type
152 // only relevant if node instances are devices 152 // only relevant if node instances are devices
153 virtual long instanceCount( void ) 153 virtual long instanceCount( void )
154 { return 1; } 154 { return 1; }
155 155
156 // return ID list for each file generated specially for 156 // return ID list for each file generated specially for
157 // this node type 157 // this node type
158 virtual QStringList properFiles( void ) 158 virtual QStringList properFiles( void )
159 { return QStringList(); } 159 { return QStringList(); }
160 160
161 // 161 //
162 // 162 //
163 // pure virtual methods with sensible default 163 // pure virtual methods with sensible default
164 // 164 //
165 // 165 //
166 166
167 // pixmap needed for this NetNode 167 // pixmap needed for this NetNode
168 virtual const QString pixmapName() = 0; 168 virtual const QString pixmapName() = 0;
169 169
170 // description for this NetNode 170 // description for this NetNode
171 virtual const QString nodeDescription() = 0; 171 virtual const QString nodeDescription() = 0;
172 172
173 // create a blank instance of a net node 173 // create a blank instance of a net node
174 virtual ANetNodeInstance * createInstance( void ) = 0; 174 virtual ANetNodeInstance * createInstance( void ) = 0;
175 175
176 // return features this NetNode provides 176 // return features this NetNode provides
177 virtual const char ** provides( void ) = 0; 177 virtual const char ** provides( void ) = 0;
178 178
179 // return features this NetNode needs 179 // return features this NetNode needs
180 virtual const char ** needs( void ) = 0; 180 virtual const char ** needs( void ) = 0;
181 181
182protected : 182protected :
183 183
184 NetNodeList * Alternatives; 184 NetNodeList * Alternatives;
185 185
186private : 186private :
187 187
188 virtual void setSpecificAttribute( QString & , QString & ) = 0; 188 virtual void setSpecificAttribute( QString & , QString & ) = 0;
189 virtual void saveSpecificAttribute( QTextStream & ) = 0; 189 virtual void saveSpecificAttribute( QTextStream & ) = 0;
190 int Done; 190 int Done;
191 191
192}; 192};
193 193
194class ANetNodeInstance : public QObject { 194class ANetNodeInstance : public QObject {
195 195
196public: 196public:
197 197
198 ANetNodeInstance( ANetNode * NN ) : QObject() 198 ANetNodeInstance( ANetNode * NN ) : QObject()
199 { IsModified=0; NodeType = NN; IsNew = TRUE; } 199 { IsModified=0; NodeType = NN; IsNew = TRUE; }
200 virtual ~ANetNodeInstance( void ) { } 200 virtual ~ANetNodeInstance( void ) { }
201 201
202 inline int done( void ) 202 inline int done( void )
203 { return Done; } 203 { return Done; }
204 inline void setDone( int D ) 204 inline void setDone( int D )
205 { Done = D; } 205 { Done = D; }
206 206
207 // return data was modified 207 // return data was modified
208 inline void setModified( bool M ) 208 inline void setModified( bool M )
209 { IsModified = M; } 209 { IsModified = M; }
210 inline bool isModified( void ) 210 inline bool isModified( void )
211 { return IsModified; } 211 { return IsModified; }
212 212
213 // get next node 213 // get next node
214 ANetNodeInstance * nextNode(); 214 ANetNodeInstance * nextNode();
215 // return NetNode this is an instance of 215 // return NetNode this is an instance of
216 ANetNode * nodeClass( void ) 216 ANetNode * nodeClass( void )
217 { return NodeType; } 217 { return NodeType; }
218 218
219 // intialize am instance of a net node 219 // intialize am instance of a net node
220 void initialize( void ); 220 void initialize( void );
221 221
222 // set the value of an attribute 222 // set the value of an attribute
223 void setAttribute( QString & Attr, QString & Value ) ; 223 void setAttribute( QString & Attr, QString & Value ) ;
224 void saveAttributes( QTextStream & TS ) ; 224 void saveAttributes( QTextStream & TS ) ;
225 225
226 // return true if node isntance is NEW and not loaded 226 // return true if node isntance is NEW and not loaded
227 inline void setNew( bool IsN ) 227 inline void setNew( bool IsN )
228 { IsNew = IsN; } 228 { IsNew = IsN; }
229 inline bool isNew( void ) 229 inline bool isNew( void )
230 { return IsNew; } 230 { return IsNew; }
231 231
232 // return description for this instance 232 // return description for this instance
233 inline QString & description( void ) 233 inline QString & description( void )
234 { return Description; } 234 { return Description; }
235 inline void setDescription( const QString & S ) 235 inline void setDescription( const QString & S )
236 { Description = S; } 236 { Description = S; }
237 237
238 // pixmap for this instance -> from NetNode 238 // pixmap for this instance -> from NetNode
239 inline const QString pixmapName( void ) 239 inline const QString pixmapName( void )
240 { return NodeType->pixmapName(); } 240 { return NodeType->pixmapName(); }
241 241
242 inline const char ** provides( void ) 242 inline const char ** provides( void )
243 { return NodeType->provides(); } 243 { return NodeType->provides(); }
244 244
245 inline const char ** needs( void ) 245 inline const char ** needs( void )
246 { return NodeType->needs(); } 246 { return NodeType->needs(); }
247 247
248 inline void setConnection( NodeCollection * NC ) 248 inline void setNetworkSetup( NetworkSetup * NC )
249 { Connection = NC; } 249 { TheNetworkSetup = NC; }
250 inline NodeCollection * connection( void ) 250 inline NetworkSetup * networkSetup( void )
251 { return Connection; } 251 { return TheNetworkSetup; }
252 252
253 // 253 //
254 // 254 //
255 // Virtual methods with sensible defaults 255 // Virtual methods with sensible defaults
256 // 256 //
257 // 257 //
258 258
259 259
260 260
261 // open proper file identified by S 261 // open proper file identified by S
262 virtual bool openFile( SystemFile & ) 262 virtual bool openFile( SystemFile & )
263 { return 0; } 263 { return 0; }
264 264
265 // check if this node (or sub nodes) have data for this file 265 // check if this node (or sub nodes) have data for this file
266 virtual bool hasDataForFile( SystemFile & S ) 266 virtual bool hasDataForFile( SystemFile & S )
267 { return nodeClass()->hasDataForFile( S ); } 267 { return nodeClass()->hasDataForFile( S ); }
268 268
269 // generate code specific for this node but embedded 269 // generate code specific for this node but embedded
270 // in the section of the parent 270 // in the section of the parent
271 // this is called within the code of the parent 271 // this is called within the code of the parent
272 virtual short generateFileEmbedded( SystemFile & SF, 272 virtual short generateFileEmbedded( SystemFile & SF,
273 long DevNr ) 273 long DevNr )
274 { ANetNodeInstance * NNI = nextNode(); 274 { ANetNodeInstance * NNI = nextNode();
275 return (NNI) ? NNI->generateFileEmbedded( SF, DevNr ) : 1; 275 return (NNI) ? NNI->generateFileEmbedded( SF, DevNr ) : 1;
276 } 276 }
277 277
278 // generate code specific for this node 278 // generate code specific for this node
279 // (or find the first node that does) 279 // (or find the first node that does)
280 virtual short generateFile( SystemFile & SF, 280 virtual short generateFile( SystemFile & SF,
281 long DevNr ) 281 long DevNr )
282 { ANetNodeInstance * NNI = nextNode(); 282 { ANetNodeInstance * NNI = nextNode();
283 return (NNI) ? NNI->generateFile( SF, DevNr ) : 1; 283 return (NNI) ? NNI->generateFile( SF, DevNr ) : 1;
284 } 284 }
285 285
286 // return true if this node instance is triggered by this trigger 286 // return true if this node instance is triggered by this trigger
287 // could be delegated to deeper instances 287 // could be delegated to deeper instances
288 virtual bool triggeredBy( const QString & ) 288 virtual bool triggeredBy( const QString & )
289 { return 0; } 289 { return 0; }
290 290
291 // 291 //
292 // 292 //
293 // Pure virtual functions 293 // Pure virtual functions
294 // 294 //
295 // 295 //
296 296
297 // return runtime information for this node 297 // return runtime information for this node
298 virtual RuntimeInfo * runtime( void ) = 0; 298 virtual RuntimeInfo * runtime( void ) = 0;
299 299
300 // create edit widget under parent 300 // create edit widget under parent
301 virtual QWidget * edit( QWidget * parent ) = 0; 301 virtual QWidget * edit( QWidget * parent ) = 0;
302 302
303 // is given data acceptable 303 // is given data acceptable
304 virtual QString acceptable( void ) = 0; 304 virtual QString acceptable( void ) = 0;
305 305
306 // get data from GUI and store in node 306 // get data from GUI and store in node
307 virtual void commit( void ) = 0; 307 virtual void commit( void ) = 0;
308 308
309 // returns node specific data -> only useful for 'buddy' 309 // returns node specific data -> only useful for 'buddy'
310 virtual void * data( void ) = 0; 310 virtual void * data( void ) = 0;
311 311
312protected : 312protected :
313 313
314 virtual void setSpecificAttribute( QString & , QString & ) = 0; 314 virtual void setSpecificAttribute( QString & , QString & ) = 0;
315 virtual void saveSpecificAttribute( QTextStream & ) = 0; 315 virtual void saveSpecificAttribute( QTextStream & ) = 0;
316 316
317 ANetNode * NodeType; 317 ANetNode * NodeType;
318 // connection to which this node belongs to 318 // networkSetup to which this node belongs to
319 NodeCollection * Connection; 319 NetworkSetup * TheNetworkSetup;
320 QString Description; 320 QString Description;
321 bool IsModified; 321 bool IsModified;
322 // true if this nodeinstance was just created (and not 322 // true if this nodeinstance was just created (and not
323 // loaded from file 323 // loaded from file
324 bool IsNew; 324 bool IsNew;
325 int Done; 325 int Done;
326 326
327 static long InstanceCounter; 327 static long InstanceCounter;
328}; 328};
329 329
330class ErrorNNI: public ANetNodeInstance { 330class ErrorNNI: public ANetNodeInstance {
331 331
332public: 332public:
333 333
334 ErrorNNI( const QString & _Name ) : ANetNodeInstance( 0 ) { 334 ErrorNNI( const QString & _Name ) : ANetNodeInstance( 0 ) {
335 setName( _Name.latin1() ); 335 setName( _Name.latin1() );
336 } 336 }
337 337
338 RuntimeInfo * runtime( void ) { 338 RuntimeInfo * runtime( void ) {
339 return 0; 339 return 0;
340 } 340 }
341 341
342 // create edit widget under parent 342 // create edit widget under parent
343 QWidget * edit( QWidget * parent ) { 343 QWidget * edit( QWidget * parent ) {
344 return 0; 344 return 0;
345 } 345 }
346 346
347 // is given data acceptable 347 // is given data acceptable
348 QString acceptable( void ) { 348 QString acceptable( void ) {
349 return QString(); 349 return QString();
350 } 350 }
351 351
352 // get data from GUI and store in node 352 // get data from GUI and store in node
353 void commit( void ) { 353 void commit( void ) {
354 } 354 }
355 355
356 // returns node specific data -> only useful for 'buddy' 356 // returns node specific data -> only useful for 'buddy'
357 void * data( void ) { 357 void * data( void ) {
358 return 0; 358 return 0;
359 } 359 }
360 360
361protected : 361protected :
362 362
363 void setSpecificAttribute( QString & , QString & ) { 363 void setSpecificAttribute( QString & , QString & ) {
364 } 364 }
365 365
366 void saveSpecificAttribute( QTextStream & ) { 366 void saveSpecificAttribute( QTextStream & ) {
367 } 367 }
368}; 368};
369 369
370class RuntimeInfo : public QObject { 370class RuntimeInfo : public QObject {
371 371
372 Q_OBJECT 372 Q_OBJECT
373 373
374public : 374public :
375 375
376 RuntimeInfo( ANetNodeInstance * TheNNI ) 376 RuntimeInfo( ANetNodeInstance * TheNNI )
377 { NNI = TheNNI; } 377 { NNI = TheNNI; }
378 378
379 // 379 //
380 // 380 //
381 // methods to be overloaded by connection capable 381 // methods to be overloaded by networkSetup capable
382 // runtimes 382 // runtimes
383 // 383 //
384 // 384 //
385 385
386 386
387 // 387 //
388 // 388 //
389 // methods to be overloaded by device capable 389 // methods to be overloaded by device capable
390 // runtimes 390 // runtimes
391 // 391 //
392 // 392 //
393 393
394 // does this node handles this interface e.g.eth0 394 // does this node handles this interface e.g.eth0
395 // recurse deeper if this node cannot answer that question 395 // recurse deeper if this node cannot answer that question
396 virtual bool handlesInterface( const QString & S ) { 396 virtual bool handlesInterface( const QString & S ) {
397 RuntimeInfo * RI = device(); 397 RuntimeInfo * RI = device();
398 if( RI ) { 398 if( RI ) {
399 return RI->handlesInterface( S ); 399 return RI->handlesInterface( S );
400 } 400 }
401 return 0; 401 return 0;
402 } 402 }
403 bool handlesInterface( const InterfaceInfo & I ) { 403 bool handlesInterface( const InterfaceInfo & I ) {
404 RuntimeInfo * RI = device(); 404 RuntimeInfo * RI = device();
405 if( RI ) { 405 if( RI ) {
406 return RI->handlesInterface( I ); 406 return RI->handlesInterface( I );
407 } 407 }
408 return 0; 408 return 0;
409 } 409 }
410 410
411 // 411 //
412 // 412 //
413 // methods to be overloaded by full setup capable 413 // methods to be overloaded by full setup capable
414 // runtimes 414 // runtimes
415 // 415 //
416 // 416 //
417 417
418 // return description for this full setup 418 // return description for this full setup
419 virtual const QString & description( void ) { 419 virtual const QString & description( void ) {
420 return fullSetup()->description( ); 420 return fullSetup()->description( );
421 } 421 }
422 // return triggers that should fire when this 422 // return triggers that should fire when this
423 // setup is brought up 423 // setup is brought up
424 virtual const QStringList & triggers( void ) { 424 virtual const QStringList & triggers( void ) {
425 return fullSetup()->triggers( ); 425 return fullSetup()->triggers( );
426 } 426 }
427 427
428 // 428 //
429 // 429 //
430 // methods to be overloaded by line capable 430 // methods to be overloaded by line capable
431 // runtimes 431 // runtimes
432 // 432 //
433 // 433 //
434 434
435 // return the device file ('/dev/xxx') created 435 // return the device file ('/dev/xxx') created
436 // by this line capable runtime 436 // by this line capable runtime
437 virtual QString deviceFile( void ) { 437 virtual QString deviceFile( void ) {
438 RuntimeInfo * RI = line(); 438 RuntimeInfo * RI = line();
439 if( RI ) { 439 if( RI ) {
440 return RI->deviceFile(); 440 return RI->deviceFile();
441 } 441 }
442 return QString(); 442 return QString();
443 } 443 }
444 444
445 // 445 //
446 // 446 //
447 // runtime interface 447 // runtime interface
448 // 448 //
449 // 449 //
450 450
451 // return the node that offers device capability 451 // return the node that offers device capability
452 virtual RuntimeInfo * device( void ) 452 virtual RuntimeInfo * device( void )
453 { RuntimeInfo * RI = nextNode(); 453 { RuntimeInfo * RI = nextNode();
454 return (RI) ? RI->device() : 0; 454 return (RI) ? RI->device() : 0;
455 } 455 }
456 456
457 // return the node that offers connection capability 457 // return the node that offers connection capability
458 virtual RuntimeInfo * connection( void ) 458 virtual RuntimeInfo * connection( void )
459 { RuntimeInfo * RI = nextNode(); 459 { RuntimeInfo * RI = nextNode();
460 return (RI) ? RI->connection() : 0; 460 return (RI) ? RI->connection() : 0;
461 } 461 }
462 462
463 // return the node that offers line capability 463 // return the node that offers line capability
464 virtual RuntimeInfo * line( void ) 464 virtual RuntimeInfo * line( void )
465 { RuntimeInfo * RI = nextNode(); 465 { RuntimeInfo * RI = nextNode();
466 return (RI) ? RI->line() : 0; 466 return (RI) ? RI->line() : 0;
467 } 467 }
468 468
469 // return the node that offers full setup capability 469 // return the node that offers full setup capability
470 virtual RuntimeInfo * fullSetup( void ) 470 virtual RuntimeInfo * fullSetup( void )
471 { RuntimeInfo * RI = nextNode(); 471 { RuntimeInfo * RI = nextNode();
472 return (RI) ? RI->fullSetup() : 0; 472 return (RI) ? RI->fullSetup() : 0;
473 } 473 }
474 474
475 inline ANetNodeInstance * netNode() 475 inline ANetNodeInstance * netNode()
476 { return NNI; } 476 { return NNI; }
477 477
478 inline NodeCollection * nodeCollection() 478 inline NetworkSetup * networkSetup()
479 { return NNI->connection(); } 479 { return NNI->networkSetup(); }
480 480
481 virtual State_t detectState( void ) = 0; 481 virtual State_t detectState( void ) = 0;
482 // public API to set the state 482 // public API to set the state
483 virtual QString setState( NodeCollection * NC, 483 virtual QString setState( NetworkSetup * NC,
484 Action_t A, 484 Action_t A,
485 bool Force = 0 ); 485 bool Force = 0 );
486 486
487 inline RuntimeInfo * nextNode( void ) { 487 inline RuntimeInfo * nextNode( void ) {
488 ANetNodeInstance * NNI = netNode()->nextNode(); 488 ANetNodeInstance * NNI = netNode()->nextNode();
489 return (NNI) ? NNI->runtime() : 0; 489 return (NNI) ? NNI->runtime() : 0;
490 } 490 }
491 491
492signals : 492signals :
493 493
494 // sent by device if state changes 494 // sent by device if state changes
495 void stateChanged( State_t S, ANetNodeInstance * NNI ); 495 void stateChanged( State_t S, ANetNodeInstance * NNI );
496 496
497protected : 497protected :
498 498
499 // set state of this node (private API) 499 // set state of this node (private API)
500 virtual QString setMyState( NodeCollection * NC, 500 virtual QString setMyState( NetworkSetup * NC,
501 Action_t A, 501 Action_t A,
502 bool Force = 0 ) = 0; 502 bool Force = 0 ) = 0;
503 503
504 // connection this runtime info belongs to 504 // networkSetup this runtime info belongs to
505 ANetNodeInstance * NNI; 505 ANetNodeInstance * NNI;
506}; 506};
507 507
508class NodeCollection : public QList<ANetNodeInstance> { 508class NetworkSetup : public QList<ANetNodeInstance> {
509 509
510public : 510public :
511 511
512 NodeCollection( void ); 512 NetworkSetup( void );
513 NodeCollection( QTextStream & TS, bool & Dangling ); 513 NetworkSetup( QTextStream & TS, bool & Dangling );
514 ~NodeCollection( void ); 514 ~NetworkSetup( void );
515
516 // copy settings from NC to this
517 void copyFrom( const NetworkSetup & NC );
515 518
516 inline int done( void ) 519 inline int done( void )
517 { return Done; } 520 { return Done; }
518 inline void setDone( int D ) 521 inline void setDone( int D )
519 { Done = D; } 522 { Done = D; }
520 523
521 inline int number( void ) 524 inline int number( void )
522 { return Number; } 525 { return Number; }
523 inline void setNumber( int i ) 526 inline void setNumber( int i )
524 { Number = i; } 527 { Number = i; }
525 inline bool isNew( void ) 528 inline bool isNew( void )
526 { return IsNew; } 529 { return IsNew; }
527 inline void setNew( bool N ) 530 inline void setNew( bool N )
528 { IsNew = N ; } 531 { IsNew = N ; }
529 inline bool isModified( void ) 532 inline bool isModified( void )
530 { return IsModified; } 533 { return IsModified; }
531 inline void setModified( bool N ) 534 inline void setModified( bool N )
532 { IsModified = N ; } 535 { IsModified = N ; }
533 536
534 inline bool handlesInterface( const QString & S ) { 537 inline bool handlesInterface( const QString & S ) {
535 return getToplevel()->runtime()->handlesInterface( S ); 538 return getToplevel()->runtime()->handlesInterface( S );
536 } 539 }
537 540
538 // return the interface in the OS that is assigned to 541 // return the interface in the OS that is assigned to
539 // this device 542 // this device
540 inline InterfaceInfo * assignedInterface( void ) { 543 inline InterfaceInfo * assignedInterface( void ) {
541 return AssignedInterface; 544 return AssignedInterface;
542 } 545 }
543 546
544 // assign the interface to this device 547 // assign the interface to this device
545 inline void assignInterface( InterfaceInfo * NI ) { 548 inline void assignInterface( InterfaceInfo * NI ) {
546 if( NI == 0 ) { 549 // cleanup previous
547 if( AssignedInterface ) {
548 AssignedInterface->assignConnection( 0 );
549 }
550 }
551 AssignedInterface = NI;
552 if( AssignedInterface ) { 550 if( AssignedInterface ) {
553 AssignedInterface->assignConnection( this ); 551 AssignedInterface->assignToNetworkSetup( 0 );
554 } 552 }
553 if( NI ) {
554 // assign new
555 NI->assignToNetworkSetup( this );
556 }
557 AssignedInterface = NI;
555 } 558 }
556 559
557 inline RuntimeInfo * device() { 560 inline RuntimeInfo * device() {
558 return getToplevel()->runtime()->device(); 561 return getToplevel()->runtime()->device();
559 } 562 }
560 563
561 const QStringList & triggers(); 564 const QStringList & triggers();
562 565
563 State_t state( bool Update = 0 ); 566 State_t state( bool Update = 0 );
564 567
565 // get the ixmap for this device 568 // get the ixmap for this device
566 QPixmap devicePixmap( void ); 569 QPixmap devicePixmap( void );
567 QPixmap statePixmap( State_t S ); 570 QPixmap statePixmap( State_t S );
568 inline QPixmap statePixmap( bool Update = 0 ) 571 inline QPixmap statePixmap( bool Update = 0 )
569 { return statePixmap( state(Update) ); } 572 { return statePixmap( state(Update) ); }
570 QString stateName( State_t ); 573 QString stateName( State_t );
571 inline QString stateName( bool Update = 0 ) 574 inline QString stateName( bool Update = 0 )
572 { return stateName( state(Update) ); } 575 { return stateName( state(Update) ); }
573 576
574 QString setState( Action_t A, bool Force = 0 ); 577 QString setState( Action_t A, bool Force = 0 );
575 578
576 void save( QTextStream & TS ); 579 void save( QTextStream & TS );
577 580
578 void append( ANetNodeInstance * NNI ); 581 void append( ANetNodeInstance * NNI );
579 582
580 // makes sure that all items in the connection point to 583 // makes sure that all items in the networkSetup point to
581 // that connectoin 584 // that connectoin
582 void reassign( void ); 585 void reassign( void );
583 586
584 ANetNodeInstance * getToplevel( void ); 587 ANetNodeInstance * getToplevel( void );
585 ANetNodeInstance * findNext( ANetNodeInstance * NNI ); 588 ANetNodeInstance * findNext( ANetNodeInstance * NNI );
586 ANetNodeInstance * findByName( const QString & S ); 589 ANetNodeInstance * findByName( const QString & S );
587 590
588 inline const QString & name() 591 inline const QString & name()
589 { return Name; } 592 { return Name; }
590 593
591 const QString & description( void ); 594 const QString & description( void );
592 595
593 inline void setName( const QString & N) 596 inline void setName( const QString & N)
594 { Name = N; } 597 { Name = N; }
595 598
596 inline State_t currentState( void ) 599 inline State_t currentState( void )
597 { return CurrentState; } 600 { return CurrentState; }
598 inline void setCurrentState( State_t S ) 601 inline void setCurrentState( State_t S )
599 { CurrentState = S; } 602 { CurrentState = S; }
600 603
601 // return TRUE if this node can have data to be inserted in 604 // return TRUE if this node can have data to be inserted in
602 // file identified by S 605 // file identified by S
603 bool hasDataForFile( SystemFile & S ); 606 bool hasDataForFile( SystemFile & S );
604 ANetNodeInstance * firstWithDataForFile( SystemFile & ); 607 ANetNodeInstance * firstWithDataForFile( SystemFile & );
605 608
606 // generate items for this file -> toplevel call 609 // generate items for this file -> toplevel call
607 short generateFile( SystemFile & SF, 610 short generateFile( SystemFile & SF,
608 long DN // device number 611 long DN // device number
609 ) 612 )
610 { return getToplevel()->generateFile( SF, DN ); } 613 { return getToplevel()->generateFile( SF, DN ); }
611 614
612 bool triggeredBy( const QString & Trigger ) 615 bool triggeredBy( const QString & Trigger )
613 { return getToplevel()->triggeredBy( Trigger ); } 616 { return getToplevel()->triggeredBy( Trigger ); }
614 617
615private : 618private :
616 619
617 int compareItems ( QCollection::Item item1, 620 int compareItems ( QCollection::Item item1,
618 QCollection::Item item2 ); 621 QCollection::Item item2 );
619 622
620 long Number; 623 long Number;
621 624
622 // state of this connection 625 // state of this networkSetup
623 State_t CurrentState; 626 State_t CurrentState;
624 627
625 QString Name; 628 QString Name;
626 // true if this collection was just created (and not 629 // true if this collection was just created (and not
627 // loaded from file 630 // loaded from file
628 bool IsNew; 631 bool IsNew;
629 // index in listbox 632 // index in listbox
630 int Index; 633 int Index;
631 bool IsModified; 634 bool IsModified;
632 int Done; 635 int Done;
633 636
634 InterfaceInfo * AssignedInterface; 637 InterfaceInfo * AssignedInterface;
635 638
636}; 639};
637 640
638#endif 641#endif
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp
index b81dcaa..0e72c25 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.cpp
+++ b/noncore/settings/networksettings2/networksettings2/resources.cpp
@@ -1,410 +1,410 @@
1#include <unistd.h> 1#include <unistd.h>
2#include <errno.h> 2#include <errno.h>
3#include <fcntl.h> 3#include <fcntl.h>
4#include <pwd.h> 4#include <pwd.h>
5#include <qpixmap.h> 5#include <qpixmap.h>
6#include <qdir.h> 6#include <qdir.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8 8
9#include <qpe/qlibrary.h> 9#include <qpe/qlibrary.h>
10#include <qpe/qpeapplication.h> 10#include <qpe/qpeapplication.h>
11 11
12#include <opie2/odebug.h> 12#include <opie2/odebug.h>
13#include <opie2/opluginloader.h> 13#include <opie2/opluginloader.h>
14 14
15#include <qtopia/resource.h> 15#include <qtopia/resource.h>
16 16
17#include "netnode.h" 17#include "netnode.h"
18#include "resources.h" 18#include "resources.h"
19#include "netnodeinterface.h" 19#include "netnodeinterface.h"
20 20
21#define PLUGINDIR "plugins/networksettings2" 21#define PLUGINDIR "plugins/networksettings2"
22#define ICONDIR "/pics/networksettings2/" 22#define ICONDIR "/pics/networksettings2/"
23 23
24// single resources instance 24// single resources instance
25TheNSResources * _NSResources = 0; 25TheNSResources * _NSResources = 0;
26 26
27TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), 27TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
28 ConnectionsMap(), DanglingConnectionsMap() { 28 NetworkSetupsMap(), DanglingNetworkSetupsMap() {
29 29
30 _NSResources = this; 30 _NSResources = this;
31 31
32 detectCurrentUser(); 32 detectCurrentUser();
33 33
34 // load available netnodes 34 // load available netnodes
35 35
36 Plugins = 0; 36 Plugins = 0;
37 findAvailableNetNodes(); 37 findAvailableNetNodes();
38 38
39 // compile provides and needs lists 39 // compile provides and needs lists
40 { const char ** NeedsRun; 40 { const char ** NeedsRun;
41 QDictIterator<ANetNode> OuterIt( AllNodeTypes ); 41 QDictIterator<ANetNode> OuterIt( AllNodeTypes );
42 bool Done; 42 bool Done;
43 43
44 for ( ; OuterIt.current(); ++OuterIt ) { 44 for ( ; OuterIt.current(); ++OuterIt ) {
45 // find needs list 45 // find needs list
46 ANetNode::NetNodeList * NNLP = new ANetNode::NetNodeList; 46 ANetNode::NetNodeList * NNLP = new ANetNode::NetNodeList;
47 ANetNode::NetNodeList & NNL = *(NNLP); 47 ANetNode::NetNodeList & NNL = *(NNLP);
48 48
49 // must iterate this way to avoid duplication pointers 49 // must iterate this way to avoid duplication pointers
50 for ( QDictIterator<ANetNode> InnerIt( AllNodeTypes ); 50 for ( QDictIterator<ANetNode> InnerIt( AllNodeTypes );
51 InnerIt.current(); ++InnerIt ) { 51 InnerIt.current(); ++InnerIt ) {
52 52
53 if( InnerIt.current() == OuterIt.current() ) 53 if( InnerIt.current() == OuterIt.current() )
54 // avoid recursive 54 // avoid recursive
55 continue; 55 continue;
56 56
57 const char ** Provides = InnerIt.current()->provides(); 57 const char ** Provides = InnerIt.current()->provides();
58 NeedsRun = OuterIt.current()->needs(); 58 NeedsRun = OuterIt.current()->needs();
59 59
60 for( ; *NeedsRun; NeedsRun ++ ) { 60 for( ; *NeedsRun; NeedsRun ++ ) {
61 const char ** PRun; 61 const char ** PRun;
62 PRun = Provides; 62 PRun = Provides;
63 for( ; *PRun; PRun ++ ) { 63 for( ; *PRun; PRun ++ ) {
64 if( strcmp( *PRun, *NeedsRun ) == 0 ) { 64 if( strcmp( *PRun, *NeedsRun ) == 0 ) {
65 // inner provides what outer needs 65 // inner provides what outer needs
66 NNL.resize( NNL.size() + 1 ); 66 NNL.resize( NNL.size() + 1 );
67 NNL[NNL.size()-1] = InnerIt.current(); 67 NNL[NNL.size()-1] = InnerIt.current();
68 Done = 1; // break from 2 loops 68 Done = 1; // break from 2 loops
69 break; 69 break;
70 } 70 }
71 } 71 }
72 } 72 }
73 } 73 }
74 OuterIt.current()->setAlternatives( NNLP ); 74 OuterIt.current()->setAlternatives( NNLP );
75 } 75 }
76 } 76 }
77 77
78 // define built in Node types to Description map 78 // define built in Node types to Description map
79 addNodeType( "device", tr( "Network Device" ), 79 addNodeType( "device", tr( "Network Device" ),
80 tr( "<p>Devices that can handle IP packets</p>" ) ); 80 tr( "<p>Devices that can handle IP packets</p>" ) );
81 addNodeType( "line", tr( "Character device" ), 81 addNodeType( "line", tr( "Character device" ),
82 tr( "<p>Devices that can handle single bytes</p>" ) ); 82 tr( "<p>Devices that can handle single bytes</p>" ) );
83 addNodeType( "connection", tr( "IP Connection" ), 83 addNodeType( "NetworkSetup", tr( "IP NetworkSetup" ),
84 tr( "<p>Nodes that provide working IP connections</p>" ) ); 84 tr( "<p>Nodes that provide working IP NetworkSetups</p>" ) );
85 addNodeType( "fullsetup", tr( "Connection Profile" ), 85 addNodeType( "fullsetup", tr( "NetworkSetup Profile" ),
86 tr( "<p>Fully configured connection profile</p>" ) ); 86 tr( "<p>Fully configured NetworkSetup profile</p>" ) );
87 addNodeType( "GPRS", tr( "Connection to GPRS device" ), 87 addNodeType( "GPRS", tr( "NetworkSetup to GPRS device" ),
88 tr( "<p>Connection to a GPRS capable device</p>" ) ); 88 tr( "<p>NetworkSetup to a GPRS capable device</p>" ) );
89 89
90 // get access to the system 90 // get access to the system
91 TheSystem = new System(); 91 TheSystem = new System();
92 92
93} 93}
94 94
95TheNSResources::~TheNSResources( void ) { 95TheNSResources::~TheNSResources( void ) {
96 96
97 if( Plugins ) { 97 if( Plugins ) {
98 delete Plugins; 98 delete Plugins;
99 delete PluginManager; 99 delete PluginManager;
100 } 100 }
101 delete TheSystem; 101 delete TheSystem;
102 102
103} 103}
104 104
105void TheNSResources::addNodeType( const QString & ID, 105void TheNSResources::addNodeType( const QString & ID,
106 const QString & Name, 106 const QString & Name,
107 const QString & Descr ) { 107 const QString & Descr ) {
108 if( NodeTypeNameMap[ID].isEmpty() ) { 108 if( NodeTypeNameMap[ID].isEmpty() ) {
109 NodeTypeNameMap.insert( ID, Name ); 109 NodeTypeNameMap.insert( ID, Name );
110 NodeTypeDescriptionMap.insert( ID, Descr ); 110 NodeTypeDescriptionMap.insert( ID, Descr );
111 } 111 }
112} 112}
113 113
114void TheNSResources::addSystemFile( const QString & ID, 114void TheNSResources::addSystemFile( const QString & ID,
115 const QString & P, 115 const QString & P,
116 bool KDI ) { 116 bool KDI ) {
117 if( ! SystemFiles.find( ID ) ) { 117 if( ! SystemFiles.find( ID ) ) {
118 // new system file 118 // new system file
119 SystemFiles.insert( ID, new SystemFile( ID, P, KDI ) ); 119 SystemFiles.insert( ID, new SystemFile( ID, P, KDI ) );
120 } // else existed 120 } // else existed
121} 121}
122 122
123void TheNSResources::busy( bool ) { 123void TheNSResources::busy( bool ) {
124/* 124/*
125 if( B ) { 125 if( B ) {
126 ShowWait->show(); 126 ShowWait->show();
127 qApp->process 127 qApp->process
128 } else { 128 } else {
129 ShowWait->hide(); 129 ShowWait->hide();
130 } 130 }
131*/ 131*/
132} 132}
133 133
134void TheNSResources::findAvailableNetNodes( void ){ 134void TheNSResources::findAvailableNetNodes( void ){
135 135
136 Plugins = new OPluginLoader( "networksettings2" ); 136 Plugins = new OPluginLoader( "networksettings2" );
137 Plugins->setAutoDelete( true ); 137 Plugins->setAutoDelete( true );
138 138
139 PluginManager = new OPluginManager( Plugins ); 139 PluginManager = new OPluginManager( Plugins );
140 PluginManager->load(); 140 PluginManager->load();
141 141
142 if( Plugins->isInSafeMode() ) { 142 if( Plugins->isInSafeMode() ) {
143 QMessageBox::information( 143 QMessageBox::information(
144 0, 144 0,
145 tr( "Today Error"), 145 tr( "Today Error"),
146 tr( "<qt>The plugin '%1' caused Today to crash." 146 tr( "<qt>The plugin '%1' caused Today to crash."
147 " It could be that the plugin is not properly" 147 " It could be that the plugin is not properly"
148 " installed.<br>Today tries to continue loading" 148 " installed.<br>Today tries to continue loading"
149 " plugins.</qt>" ) 149 " plugins.</qt>" )
150 .arg( PluginManager->crashedPlugin().name())); 150 .arg( PluginManager->crashedPlugin().name()));
151 } 151 }
152 152
153 // Get All Plugins 153 // Get All Plugins
154 OPluginLoader::List allplugins = Plugins->filtered(); 154 OPluginLoader::List allplugins = Plugins->filtered();
155 QString lang = ::getenv("LANG"); 155 QString lang = ::getenv("LANG");
156 156
157 for( OPluginLoader::List::Iterator it = allplugins.begin(); 157 for( OPluginLoader::List::Iterator it = allplugins.begin();
158 it != allplugins.end(); 158 it != allplugins.end();
159 ++it ) { 159 ++it ) {
160 160
161 // check if this plugin supports the proper interface 161 // check if this plugin supports the proper interface
162 NetNodeInterface * interface = 162 NetNodeInterface * interface =
163 Plugins->load<NetNodeInterface>( *it, IID_NetworkSettings2 ); 163 Plugins->load<NetNodeInterface>( *it, IID_NetworkSettings2 );
164 164
165 if( ! interface ) { 165 if( ! interface ) {
166 Log(( "Plugin %s from %s does not support proper interface\n", 166 Log(( "Plugin %s from %s does not support proper interface\n",
167 (*it).name().latin1(), (*it).path().latin1() )); 167 (*it).name().latin1(), (*it).path().latin1() ));
168 continue; 168 continue;
169 } 169 }
170 170
171 // add the nodes in this plugin to the dictionary 171 // add the nodes in this plugin to the dictionary
172 { QList<ANetNode> PNN; 172 { QList<ANetNode> PNN;
173 173
174 interface->create_plugin( PNN ); 174 interface->create_plugin( PNN );
175 175
176 if( PNN.isEmpty() ) { 176 if( PNN.isEmpty() ) {
177 Log(( "Plugin %s from %s does offer any nodes\n", 177 Log(( "Plugin %s from %s does offer any nodes\n",
178 (*it).name().latin1(), (*it).path().latin1() )); 178 (*it).name().latin1(), (*it).path().latin1() ));
179 delete interface; 179 delete interface;
180 continue; 180 continue;
181 } 181 }
182 182
183 // merge this node with global node 183 // merge this node with global node
184 for( QListIterator<ANetNode> it(PNN); 184 for( QListIterator<ANetNode> it(PNN);
185 it.current(); 185 it.current();
186 ++it ) { 186 ++it ) {
187 AllNodeTypes.insert( it.current()->name(), it.current() ); 187 AllNodeTypes.insert( it.current()->name(), it.current() );
188 } 188 }
189 } 189 }
190 190
191 // load the translation 191 // load the translation
192 QTranslator *trans = new QTranslator(qApp); 192 QTranslator *trans = new QTranslator(qApp);
193 QString fn = QPEApplication::qpeDir()+ 193 QString fn = QPEApplication::qpeDir()+
194 "/i18n/"+lang+"/"+ (*it).name() + ".qm"; 194 "/i18n/"+lang+"/"+ (*it).name() + ".qm";
195 195
196 if( trans->load( fn ) ) 196 if( trans->load( fn ) )
197 qApp->installTranslator( trans ); 197 qApp->installTranslator( trans );
198 else 198 else
199 delete trans; 199 delete trans;
200 } 200 }
201 201
202} 202}
203 203
204// used to find unique connection number 204// used to find unique NetworkSetup number
205int TheNSResources::assignConnectionNumber( void ) { 205int TheNSResources::assignNetworkSetupNumber( void ) {
206 bool found = 1; 206 bool found = 1;
207 for( int trial = 0; ; trial ++ ) { 207 for( int trial = 0; ; trial ++ ) {
208 found = 1; 208 found = 1;
209 for( QDictIterator<NodeCollection> it(ConnectionsMap); 209 for( QDictIterator<NetworkSetup> it(NetworkSetupsMap);
210 it.current(); 210 it.current();
211 ++it ) { 211 ++it ) {
212 if( it.current()->number() == trial ) { 212 if( it.current()->number() == trial ) {
213 found = 0; 213 found = 0;
214 break; 214 break;
215 } 215 }
216 } 216 }
217 217
218 if( found ) { 218 if( found ) {
219 Log(("Assign profile number %d\n", trial )); 219 Log(("Assign profile number %d\n", trial ));
220 return trial; 220 return trial;
221 } 221 }
222 } 222 }
223} 223}
224 224
225QPixmap TheNSResources::getPixmap( const QString & QS ) { 225QPixmap TheNSResources::getPixmap( const QString & QS ) {
226 QPixmap P; 226 QPixmap P;
227 QString S("networksettings2/"); 227 QString S("networksettings2/");
228 S += QS; 228 S += QS;
229 P = Resource::loadPixmap( S ); 229 P = Resource::loadPixmap( S );
230 if( P.isNull() ) { 230 if( P.isNull() ) {
231 Log(( "Cannot load %s\n", S.latin1() )); 231 Log(( "Cannot load %s\n", S.latin1() ));
232 } 232 }
233 return ( P.isNull() ) ? QPixmap() : P; 233 return ( P.isNull() ) ? QPixmap() : P;
234} 234}
235 235
236QString TheNSResources::tr( const char * s ) { 236QString TheNSResources::tr( const char * s ) {
237 return qApp->translate( "resource", s ); 237 return qApp->translate( "resource", s );
238} 238}
239 239
240const QString & TheNSResources::netNode2Name( const char * s ) { 240const QString & TheNSResources::netNode2Name( const char * s ) {
241 return NodeTypeNameMap[s]; 241 return NodeTypeNameMap[s];
242} 242}
243 243
244const QString & TheNSResources::netNode2Description( const char * s ) { 244const QString & TheNSResources::netNode2Description( const char * s ) {
245 return NodeTypeDescriptionMap[s]; 245 return NodeTypeDescriptionMap[s];
246} 246}
247 247
248void TheNSResources::addConnection( NodeCollection * NC, bool Dangling ) { 248void TheNSResources::addNetworkSetup( NetworkSetup * NC, bool Dangling ) {
249 ANetNodeInstance * NNI; 249 ANetNodeInstance * NNI;
250 Log(( "Add Connection %s, Dangling %d\n", 250 Log(( "Add NetworkSetup %s, Dangling %d\n",
251 NC->name().latin1(), Dangling )); 251 NC->name().latin1(), Dangling ));
252 if( Dangling ) { 252 if( Dangling ) {
253 DanglingConnectionsMap.insert( NC->name(), NC ); 253 DanglingNetworkSetupsMap.insert( NC->name(), NC );
254 } else { 254 } else {
255 ConnectionsMap.insert( NC->name(), NC ); 255 NetworkSetupsMap.insert( NC->name(), NC );
256 } 256 }
257 257
258 // add (new) nodes to NodeList 258 // add (new) nodes to NodeList
259 for( QListIterator<ANetNodeInstance> it(*NC); 259 for( QListIterator<ANetNodeInstance> it(*NC);
260 it.current(); 260 it.current();
261 ++it ) { 261 ++it ) {
262 NNI = it.current(); 262 NNI = it.current();
263 if( findNodeInstance( NNI->name() ) == 0 ) { 263 if( findNodeInstance( NNI->name() ) == 0 ) {
264 // new item 264 // new item
265 addNodeInstance( NNI ); 265 addNodeInstance( NNI );
266 } 266 }
267 } 267 }
268} 268}
269 269
270void TheNSResources::removeConnection( const QString & N ) { 270void TheNSResources::removeNetworkSetup( const QString & N ) {
271 NodeCollection * NC = findConnection( N ); 271 NetworkSetup * NC = findNetworkSetup( N );
272 if( ! NC ) 272 if( ! NC )
273 return; 273 return;
274 274
275 // delete netnodes in this connection 275 // delete netnodes in this NetworkSetup
276 ANetNodeInstance * NNI; 276 ANetNodeInstance * NNI;
277 for( NNI = NC->first(); NNI != 0; NNI = NC->next() ) { 277 for( NNI = NC->first(); NNI != 0; NNI = NC->next() ) {
278 removeNodeInstance( NNI->name() ); 278 removeNodeInstance( NNI->name() );
279 } 279 }
280 if( ConnectionsMap.find( N ) ) { 280 if( NetworkSetupsMap.find( N ) ) {
281 ConnectionsMap.remove( N ); 281 NetworkSetupsMap.remove( N );
282 } else { 282 } else {
283 DanglingConnectionsMap.remove( N ); 283 DanglingNetworkSetupsMap.remove( N );
284 } 284 }
285 285
286} 286}
287 287
288// dangling connections are filtered out 288// dangling NetworkSetups are filtered out
289NodeCollection * TheNSResources::findConnection( const QString & S ) { 289NetworkSetup * TheNSResources::findNetworkSetup( const QString & S ) {
290 return ConnectionsMap[ S ]; 290 return NetworkSetupsMap[ S ];
291} 291}
292 292
293NodeCollection * TheNSResources::getConnection( int nr ) { 293NetworkSetup * TheNSResources::getNetworkSetup( int nr ) {
294 for( QDictIterator<NodeCollection> it(ConnectionsMap); 294 for( QDictIterator<NetworkSetup> it(NetworkSetupsMap);
295 it.current(); 295 it.current();
296 ++it ) { 296 ++it ) {
297 if( it.current()->number() == nr ) { 297 if( it.current()->number() == nr ) {
298 return it.current(); 298 return it.current();
299 } 299 }
300 } 300 }
301 return 0; 301 return 0;
302} 302}
303/* 303/*
304void TheNSResources::renumberConnections( void ) { 304void TheNSResources::renumberNetworkSetups( void ) {
305 Name2Connection_t & M = NSResources->connections(); 305 Name2NetworkSetup_t & M = NSResources->NetworkSetups();
306 NodeCollection * NC; 306 NetworkSetup * NC;
307 307
308 // for all connections 308 // for all NetworkSetups
309 NodeCollection::resetMaxNr(); 309 NetworkSetup::resetMaxNr();
310 for( QDictIterator<NodeCollection> it(M); 310 for( QDictIterator<NetworkSetup> it(M);
311 it.current(); 311 it.current();
312 ++it ) { 312 ++it ) {
313 NC = it.current(); 313 NC = it.current();
314 NC->setNumber( NC->maxConnectionNumber()+1 ); 314 NC->setNumber( NC->maxNetworkSetupNumber()+1 );
315 NC->setModified( 1 ); 315 NC->setModified( 1 );
316 } 316 }
317} 317}
318*/ 318*/
319 319
320typedef struct EnvVars { 320typedef struct EnvVars {
321 char * Name; 321 char * Name;
322 int Len; 322 int Len;
323} EnvVar_t; 323} EnvVar_t;
324 324
325#define AnEV(x) x, sizeof(x)-1 325#define AnEV(x) x, sizeof(x)-1
326 326
327static EnvVar_t EV[] = { 327static EnvVar_t EV[] = {
328 AnEV( "HOME" ), 328 AnEV( "HOME" ),
329 AnEV( "LOGNAME" ), 329 AnEV( "LOGNAME" ),
330 AnEV( "USER" ), 330 AnEV( "USER" ),
331 AnEV( "LD_LIBRARY_PATH" ), 331 AnEV( "LD_LIBRARY_PATH" ),
332 AnEV( "PATH" ), 332 AnEV( "PATH" ),
333 AnEV( "QTDIR" ), 333 AnEV( "QTDIR" ),
334 AnEV( "OPIEDIR" ), 334 AnEV( "OPIEDIR" ),
335 AnEV( "SHELL" ), 335 AnEV( "SHELL" ),
336 { NULL, 0 } 336 { NULL, 0 }
337}; 337};
338 338
339void TheNSResources::detectCurrentUser( void ) { 339void TheNSResources::detectCurrentUser( void ) {
340 // find current running qpe 340 // find current running qpe
341 QString QPEEnvFile = ""; 341 QString QPEEnvFile = "";
342 342
343 CurrentUser.UserName = ""; 343 CurrentUser.UserName = "";
344 CurrentUser.HomeDir = ""; 344 CurrentUser.HomeDir = "";
345 345
346 if( getenv( "OPIEDIR" ) == 0 ) { 346 if( getenv( "OPIEDIR" ) == 0 ) {
347 // nothing known 347 // nothing known
348 { // open proc dir and find all dirs in it 348 { // open proc dir and find all dirs in it
349 QRegExp R("[0-9]+"); 349 QRegExp R("[0-9]+");
350 QDir ProcDir( "/proc" ); 350 QDir ProcDir( "/proc" );
351 QFileInfo FI; 351 QFileInfo FI;
352 QStringList EL = ProcDir.entryList( QDir::Dirs ); 352 QStringList EL = ProcDir.entryList( QDir::Dirs );
353 353
354 // print it out 354 // print it out
355 for ( QStringList::Iterator it = EL.begin(); 355 for ( QStringList::Iterator it = EL.begin();
356 it != EL.end(); 356 it != EL.end();
357 ++it ) { 357 ++it ) {
358 if( R.match( (*it) ) >= 0 ) { 358 if( R.match( (*it) ) >= 0 ) {
359 QString S = ProcDir.path()+"/"+ (*it); 359 QString S = ProcDir.path()+"/"+ (*it);
360 S.append( "/exe" ); 360 S.append( "/exe" );
361 FI.setFile( S ); 361 FI.setFile( S );
362 // get the link 362 // get the link
363 S = FI.readLink(); 363 S = FI.readLink();
364 if( S.right( 8 ) == "/bin/qpe" ) { 364 if( S.right( 8 ) == "/bin/qpe" ) {
365 // found running qpe 365 // found running qpe
366 QPEEnvFile.sprintf( ProcDir.path()+ "/" + (*it) + "/environ" ); 366 QPEEnvFile.sprintf( ProcDir.path()+ "/" + (*it) + "/environ" );
367 break; 367 break;
368 } 368 }
369 } 369 }
370 } 370 }
371 } 371 }
372 372
373 if( QPEEnvFile.isEmpty() ) { 373 if( QPEEnvFile.isEmpty() ) {
374 // could not find qpe 374 // could not find qpe
375 Log(("Could not find qpe\n" )); 375 Log(("Could not find qpe\n" ));
376 return; 376 return;
377 } 377 }
378 378
379 // FI now contains path ProcDir to the cmd dir 379 // FI now contains path ProcDir to the cmd dir
380 { char * Buf = 0; 380 { char * Buf = 0;
381 char TB[1024]; 381 char TB[1024];
382 long BufSize = 0; 382 long BufSize = 0;
383 int fd; 383 int fd;
384 int rd; 384 int rd;
385 385
386 fd = open( QPEEnvFile.latin1(), O_RDONLY ); 386 fd = open( QPEEnvFile.latin1(), O_RDONLY );
387 if( fd < 0 ) { 387 if( fd < 0 ) {
388 Log(("Could not open %s : %d\n", 388 Log(("Could not open %s : %d\n",
389 QPEEnvFile.latin1(), errno )); 389 QPEEnvFile.latin1(), errno ));
390 return; 390 return;
391 } 391 }
392 392
393 while( (rd = read( fd, TB, sizeof(TB) ) ) > 0 ) { 393 while( (rd = read( fd, TB, sizeof(TB) ) ) > 0 ) {
394 Buf = (char *)realloc( Buf, BufSize+rd ); 394 Buf = (char *)realloc( Buf, BufSize+rd );
395 memcpy( Buf+BufSize, TB, rd ); 395 memcpy( Buf+BufSize, TB, rd );
396 BufSize += rd; 396 BufSize += rd;
397 } 397 }
398 398
399 char * Data = Buf; 399 char * Data = Buf;
400 char * DataEnd = Data+BufSize-1; 400 char * DataEnd = Data+BufSize-1;
401 401
402 // get env items out of list 402 // get env items out of list
403 while( Data < DataEnd ) { 403 while( Data < DataEnd ) {
404 404
405 EnvVar_t * Run = EV; 405 EnvVar_t * Run = EV;
406 while( Run->Name ) { 406 while( Run->Name ) {
407 if( strncmp( Data, Run->Name, Run->Len ) == 0 && 407 if( strncmp( Data, Run->Name, Run->Len ) == 0 &&
408 Data[Run->Len] == '=' 408 Data[Run->Len] == '='
409 ) { 409 ) {
410 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); 410 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h
index 51c4250..f7393d3 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.h
+++ b/noncore/settings/networksettings2/networksettings2/resources.h
@@ -1,153 +1,153 @@
1#ifndef __RESOURCES__H 1#ifndef __RESOURCES__H
2#define __RESOURCES__H 2#define __RESOURCES__H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qdict.h> 5#include <qdict.h>
6#include <qmap.h> 6#include <qmap.h>
7#include <qlist.h> 7#include <qlist.h>
8#include "netnode.h" 8#include "netnode.h"
9#include "systemfile.h" 9#include "systemfile.h"
10#include "system.h" 10#include "system.h"
11 11
12class QLibrary; 12class QLibrary;
13class QPixmap; 13class QPixmap;
14class ANetNode; 14class ANetNode;
15class ANetNodeInstance; 15class ANetNodeInstance;
16 16
17namespace Opie { 17namespace Opie {
18 namespace Core { 18 namespace Core {
19 class OPluginLoader; 19 class OPluginLoader;
20 class OPluginManager; 20 class OPluginManager;
21 } 21 }
22} 22}
23 23
24typedef void (*GetNetNodeListFt_t)(QList<ANetNode>& PNN ); 24typedef void (*GetNetNodeListFt_t)(QList<ANetNode>& PNN );
25 25
26class CurrentQPEUser { 26class CurrentQPEUser {
27 27
28public : 28public :
29 CurrentQPEUser() : UserName(), HomeDir(), EnvList() {} 29 CurrentQPEUser() : UserName(), HomeDir(), EnvList() {}
30 30
31 inline bool known( void ) 31 inline bool known( void )
32 { return ! HomeDir.isEmpty() && ! UserName.isEmpty(); } 32 { return ! HomeDir.isEmpty() && ! UserName.isEmpty(); }
33 33
34 QString UserName; 34 QString UserName;
35 QString HomeDir; 35 QString HomeDir;
36 int Uid; 36 int Uid;
37 int Gid; 37 int Gid;
38 QArray<char *> EnvList; 38 QArray<char *> EnvList;
39}; 39};
40 40
41typedef QDict<ANetNode> Name2NetNode_t; 41typedef QDict<ANetNode> Name2NetNode_t;
42typedef QDict<ANetNodeInstance > Name2Instance_t; 42typedef QDict<ANetNodeInstance > Name2Instance_t;
43typedef QDict<NodeCollection> Name2Connection_t; 43typedef QDict<NetworkSetup> Name2NetworkSetup_t;
44typedef QDict<SystemFile> Name2SystemFile_t; 44typedef QDict<SystemFile> Name2SystemFile_t;
45 45
46class TheNSResources { 46class TheNSResources {
47 47
48public : 48public :
49 49
50 TheNSResources( void ); 50 TheNSResources( void );
51 ~TheNSResources( ); 51 ~TheNSResources( );
52 52
53 // give busy feedback 53 // give busy feedback
54 void busy( bool B ); 54 void busy( bool B );
55 55
56 System & system() 56 System & system()
57 { return *TheSystem; } 57 { return *TheSystem; }
58 58
59 int assignConnectionNumber(void); 59 int assignNetworkSetupNumber(void);
60 QPixmap getPixmap( const QString & Name ); 60 QPixmap getPixmap( const QString & Name );
61 61
62 Name2NetNode_t & netNodes( void ) 62 Name2NetNode_t & netNodes( void )
63 { return AllNodeTypes; } 63 { return AllNodeTypes; }
64 bool netNodeExists( const QString & X ) 64 bool netNodeExists( const QString & X )
65 { return AllNodeTypes.find(X)!=0; } 65 { return AllNodeTypes.find(X)!=0; }
66 ANetNode * findNetNode( const QString & N ) 66 ANetNode * findNetNode( const QString & N )
67 { return AllNodeTypes.find(N); 67 { return AllNodeTypes.find(N);
68 } 68 }
69 // define new plugin (=node) 69 // define new plugin (=node)
70 void addNodeType( const QString & ID, 70 void addNodeType( const QString & ID,
71 const QString & LongName, 71 const QString & LongName,
72 const QString & Description ); 72 const QString & Description );
73 73
74 Name2SystemFile_t & systemFiles( void ) 74 Name2SystemFile_t & systemFiles( void )
75 { return SystemFiles; } 75 { return SystemFiles; }
76 void addSystemFile( const QString & ID, 76 void addSystemFile( const QString & ID,
77 const QString & P, 77 const QString & P,
78 bool KDI ); 78 bool KDI );
79 79
80 ANetNodeInstance * createNodeInstance( const QString & S ) 80 ANetNodeInstance * createNodeInstance( const QString & S )
81 { ANetNode * NN = findNetNode( S ); 81 { ANetNode * NN = findNetNode( S );
82 82
83 Log(( "Find node type %s : %p\n", S.latin1(), NN )); 83 Log(( "Find node type %s : %p\n", S.latin1(), NN ));
84 84
85 if( NN == 0 ) 85 if( NN == 0 )
86 // type of this instance not found 86 // type of this instance not found
87 return 0; 87 return 0;
88 88
89 ANetNodeInstance * NNI = NN->createInstance(); 89 ANetNodeInstance * NNI = NN->createInstance();
90 NNI->initialize(); 90 NNI->initialize();
91 return NNI; 91 return NNI;
92 } 92 }
93 93
94 Name2Instance_t & netNodeInstances( void ) 94 Name2Instance_t & netNodeInstances( void )
95 { return AllNodes; } 95 { return AllNodes; }
96 void addNodeInstance( ANetNodeInstance * I ) 96 void addNodeInstance( ANetNodeInstance * I )
97 { AllNodes.insert( I->name(), I ); } 97 { AllNodes.insert( I->name(), I ); }
98 void removeNodeInstance( const QString & N ) 98 void removeNodeInstance( const QString & N )
99 { AllNodes.remove( N );} 99 { AllNodes.remove( N );}
100 ANetNodeInstance * findNodeInstance( const QString & S ) 100 ANetNodeInstance * findNodeInstance( const QString & S )
101 { return AllNodes[S]; } 101 { return AllNodes[S]; }
102 102
103 const QString & netNode2Name( const char * Type ); 103 const QString & netNode2Name( const char * Type );
104 const QString & netNode2Description( const char * Type ); 104 const QString & netNode2Description( const char * Type );
105 105
106 void addConnection( NodeCollection * NC, bool Dangling ); 106 void addNetworkSetup( NetworkSetup * NC, bool Dangling );
107 void removeConnection( const QString & N ); 107 void removeNetworkSetup( const QString & N );
108 NodeCollection * findConnection( const QString & N ); 108 NetworkSetup * findNetworkSetup( const QString & N );
109 NodeCollection * getConnection( int nr ); 109 NetworkSetup * getNetworkSetup( int nr );
110 Name2Connection_t & connections( void ) 110 Name2NetworkSetup_t & networkSetups( void )
111 { return ConnectionsMap; } 111 { return NetworkSetupsMap; }
112 Name2Connection_t & danglingConnections( void ) 112 Name2NetworkSetup_t & danglingNetworkSetups( void )
113 { return DanglingConnectionsMap; } 113 { return DanglingNetworkSetupsMap; }
114 114
115 inline bool userKnown( void ) 115 inline bool userKnown( void )
116 { return CurrentUser.known(); } 116 { return CurrentUser.known(); }
117 CurrentQPEUser & currentUser( void ) 117 CurrentQPEUser & currentUser( void )
118 { return CurrentUser; } 118 { return CurrentUser; }
119 119
120private : 120private :
121 121
122 void detectCurrentUser( void ); 122 void detectCurrentUser( void );
123 QString tr( const char * path ); 123 QString tr( const char * path );
124 124
125 void findAvailableNetNodes( void ); 125 void findAvailableNetNodes( void );
126 126
127 QMap< QString, QString> NodeTypeNameMap; 127 QMap< QString, QString> NodeTypeNameMap;
128 QMap< QString, QString> NodeTypeDescriptionMap; 128 QMap< QString, QString> NodeTypeDescriptionMap;
129 // list of connections that are valid 129 // list of networkSetups that are valid
130 Name2Connection_t ConnectionsMap; 130 Name2NetworkSetup_t NetworkSetupsMap;
131 // list of connection configurations that are not valid 131 // list of networkSetup configurations that are not valid
132 // e.g. because plugins are missing 132 // e.g. because plugins are missing
133 Name2Connection_t DanglingConnectionsMap; 133 Name2NetworkSetup_t DanglingNetworkSetupsMap;
134 System * TheSystem; 134 System * TheSystem;
135 Name2SystemFile_t SystemFiles; 135 Name2SystemFile_t SystemFiles;
136 136
137 // all node type classes 137 // all node type classes
138 Name2NetNode_t AllNodeTypes; 138 Name2NetNode_t AllNodeTypes;
139 139
140 // all nodes 140 // all nodes
141 Name2Instance_t AllNodes; 141 Name2Instance_t AllNodes;
142 142
143 CurrentQPEUser CurrentUser; 143 CurrentQPEUser CurrentUser;
144 144
145 Opie::Core::OPluginLoader * Plugins; 145 Opie::Core::OPluginLoader * Plugins;
146 Opie::Core::OPluginManager * PluginManager; 146 Opie::Core::OPluginManager * PluginManager;
147 147
148}; 148};
149 149
150extern TheNSResources * _NSResources; 150extern TheNSResources * _NSResources;
151#define NSResources _NSResources 151#define NSResources _NSResources
152 152
153#endif 153#endif
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp
index a290f08..33cc5bd 100644
--- a/noncore/settings/networksettings2/networksettings2/system.cpp
+++ b/noncore/settings/networksettings2/networksettings2/system.cpp
@@ -360,199 +360,199 @@ void System::probeInterfaces( void ) {
360 HN( ifrs.ifr_hwaddr.sa_data[0] ), 360 HN( ifrs.ifr_hwaddr.sa_data[0] ),
361 LN( ifrs.ifr_hwaddr.sa_data[0] ), 361 LN( ifrs.ifr_hwaddr.sa_data[0] ),
362 HN( ifrs.ifr_hwaddr.sa_data[1] ), 362 HN( ifrs.ifr_hwaddr.sa_data[1] ),
363 LN( ifrs.ifr_hwaddr.sa_data[1] ), 363 LN( ifrs.ifr_hwaddr.sa_data[1] ),
364 HN( ifrs.ifr_hwaddr.sa_data[2] ), 364 HN( ifrs.ifr_hwaddr.sa_data[2] ),
365 LN( ifrs.ifr_hwaddr.sa_data[2] ), 365 LN( ifrs.ifr_hwaddr.sa_data[2] ),
366 HN( ifrs.ifr_hwaddr.sa_data[3] ), 366 HN( ifrs.ifr_hwaddr.sa_data[3] ),
367 LN( ifrs.ifr_hwaddr.sa_data[3] ), 367 LN( ifrs.ifr_hwaddr.sa_data[3] ),
368 HN( ifrs.ifr_hwaddr.sa_data[4] ), 368 HN( ifrs.ifr_hwaddr.sa_data[4] ),
369 LN( ifrs.ifr_hwaddr.sa_data[4] ), 369 LN( ifrs.ifr_hwaddr.sa_data[4] ),
370 HN( ifrs.ifr_hwaddr.sa_data[5] ), 370 HN( ifrs.ifr_hwaddr.sa_data[5] ),
371 LN( ifrs.ifr_hwaddr.sa_data[5] ) 371 LN( ifrs.ifr_hwaddr.sa_data[5] )
372 ); 372 );
373 break; 373 break;
374#ifdef ARPHRD_IEEE1394 374#ifdef ARPHRD_IEEE1394
375 case ARPHRD_IEEE1394 : // Firewire Eth address 375 case ARPHRD_IEEE1394 : // Firewire Eth address
376 IFI->MACAddress.sprintf( 376 IFI->MACAddress.sprintf(
377 "%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-00-00", 377 "%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-00-00",
378 HN( ifrs.ifr_hwaddr.sa_data[0] ), 378 HN( ifrs.ifr_hwaddr.sa_data[0] ),
379 LN( ifrs.ifr_hwaddr.sa_data[0] ), 379 LN( ifrs.ifr_hwaddr.sa_data[0] ),
380 HN( ifrs.ifr_hwaddr.sa_data[1] ), 380 HN( ifrs.ifr_hwaddr.sa_data[1] ),
381 LN( ifrs.ifr_hwaddr.sa_data[1] ), 381 LN( ifrs.ifr_hwaddr.sa_data[1] ),
382 HN( ifrs.ifr_hwaddr.sa_data[2] ), 382 HN( ifrs.ifr_hwaddr.sa_data[2] ),
383 LN( ifrs.ifr_hwaddr.sa_data[2] ), 383 LN( ifrs.ifr_hwaddr.sa_data[2] ),
384 HN( ifrs.ifr_hwaddr.sa_data[3] ), 384 HN( ifrs.ifr_hwaddr.sa_data[3] ),
385 LN( ifrs.ifr_hwaddr.sa_data[3] ), 385 LN( ifrs.ifr_hwaddr.sa_data[3] ),
386 HN( ifrs.ifr_hwaddr.sa_data[4] ), 386 HN( ifrs.ifr_hwaddr.sa_data[4] ),
387 LN( ifrs.ifr_hwaddr.sa_data[4] ), 387 LN( ifrs.ifr_hwaddr.sa_data[4] ),
388 HN( ifrs.ifr_hwaddr.sa_data[5] ), 388 HN( ifrs.ifr_hwaddr.sa_data[5] ),
389 LN( ifrs.ifr_hwaddr.sa_data[5] ), 389 LN( ifrs.ifr_hwaddr.sa_data[5] ),
390 HN( ifrs.ifr_hwaddr.sa_data[6] ), 390 HN( ifrs.ifr_hwaddr.sa_data[6] ),
391 LN( ifrs.ifr_hwaddr.sa_data[6] ), 391 LN( ifrs.ifr_hwaddr.sa_data[6] ),
392 HN( ifrs.ifr_hwaddr.sa_data[7] ), 392 HN( ifrs.ifr_hwaddr.sa_data[7] ),
393 LN( ifrs.ifr_hwaddr.sa_data[7] ), 393 LN( ifrs.ifr_hwaddr.sa_data[7] ),
394 HN( ifrs.ifr_hwaddr.sa_data[8] ), 394 HN( ifrs.ifr_hwaddr.sa_data[8] ),
395 LN( ifrs.ifr_hwaddr.sa_data[8] ), 395 LN( ifrs.ifr_hwaddr.sa_data[8] ),
396 HN( ifrs.ifr_hwaddr.sa_data[9] ), 396 HN( ifrs.ifr_hwaddr.sa_data[9] ),
397 LN( ifrs.ifr_hwaddr.sa_data[9] ), 397 LN( ifrs.ifr_hwaddr.sa_data[9] ),
398 HN( ifrs.ifr_hwaddr.sa_data[10] ), 398 HN( ifrs.ifr_hwaddr.sa_data[10] ),
399 LN( ifrs.ifr_hwaddr.sa_data[10] ), 399 LN( ifrs.ifr_hwaddr.sa_data[10] ),
400 HN( ifrs.ifr_hwaddr.sa_data[11] ), 400 HN( ifrs.ifr_hwaddr.sa_data[11] ),
401 LN( ifrs.ifr_hwaddr.sa_data[11] ), 401 LN( ifrs.ifr_hwaddr.sa_data[11] ),
402 HN( ifrs.ifr_hwaddr.sa_data[12] ), 402 HN( ifrs.ifr_hwaddr.sa_data[12] ),
403 LN( ifrs.ifr_hwaddr.sa_data[12] ), 403 LN( ifrs.ifr_hwaddr.sa_data[12] ),
404 HN( ifrs.ifr_hwaddr.sa_data[13] ), 404 HN( ifrs.ifr_hwaddr.sa_data[13] ),
405 LN( ifrs.ifr_hwaddr.sa_data[13] ) 405 LN( ifrs.ifr_hwaddr.sa_data[13] )
406 ); 406 );
407 break; 407 break;
408#endif 408#endif
409 case ARPHRD_PPP : // PPP 409 case ARPHRD_PPP : // PPP
410 break; 410 break;
411 case ARPHRD_IEEE80211 : // WLAN 411 case ARPHRD_IEEE80211 : // WLAN
412 break; 412 break;
413 case ARPHRD_IRDA : // IRDA 413 case ARPHRD_IRDA : // IRDA
414 break; 414 break;
415 } 415 }
416 } 416 }
417 } else // else already probed before -> just update 417 } else // else already probed before -> just update
418 Log(("Redetected NIC %s\n", NicName.latin1())); 418 Log(("Redetected NIC %s\n", NicName.latin1()));
419 419
420 // get dynamic info 420 // get dynamic info
421 if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) { 421 if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) {
422 IFI->IsUp = ((ifrs.ifr_flags & IFF_UP) == IFF_UP); 422 IFI->IsUp = ((ifrs.ifr_flags & IFF_UP) == IFF_UP);
423 IFI->HasMulticast = ((ifrs.ifr_flags & IFF_MULTICAST) == IFF_MULTICAST); 423 IFI->HasMulticast = ((ifrs.ifr_flags & IFF_MULTICAST) == IFF_MULTICAST);
424 } else { 424 } else {
425 IFI->IsUp = 0; 425 IFI->IsUp = 0;
426 IFI->HasMulticast = 0; 426 IFI->HasMulticast = 0;
427 } 427 }
428 428
429 if( ioctl(sockfd, SIOCGIFADDR, &ifrs) >= 0 ) { 429 if( ioctl(sockfd, SIOCGIFADDR, &ifrs) >= 0 ) {
430 IFI->Address = 430 IFI->Address =
431 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_addr)->sin_addr); 431 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_addr)->sin_addr);
432 } else { 432 } else {
433 IFI->Address = ""; 433 IFI->Address = "";
434 IFI->IsUp = 0; 434 IFI->IsUp = 0;
435 } 435 }
436 if( ioctl(sockfd, SIOCGIFBRDADDR, &ifrs) >= 0 ) { 436 if( ioctl(sockfd, SIOCGIFBRDADDR, &ifrs) >= 0 ) {
437 IFI->BCastAddress = 437 IFI->BCastAddress =
438 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_broadaddr)->sin_addr); 438 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_broadaddr)->sin_addr);
439 } else { 439 } else {
440 IFI->BCastAddress = ""; 440 IFI->BCastAddress = "";
441 } 441 }
442 if( ioctl(sockfd, SIOCGIFNETMASK, &ifrs) >= 0 ) { 442 if( ioctl(sockfd, SIOCGIFNETMASK, &ifrs) >= 0 ) {
443 IFI->Netmask = 443 IFI->Netmask =
444 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_netmask)->sin_addr); 444 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_netmask)->sin_addr);
445 } else { 445 } else {
446 IFI->Netmask = ""; 446 IFI->Netmask = "";
447 } 447 }
448 Log(("NIC %s UP ? %d\n", NicName.latin1(), IFI->IsUp )); 448 Log(("NIC %s UP ? %d\n", NicName.latin1(), IFI->IsUp ));
449 } 449 }
450 450
451 ::close( sockfd ); 451 ::close( sockfd );
452} 452}
453 453
454InterfaceInfo * System::findInterface( const QString & N ) { 454InterfaceInfo * System::findInterface( const QString & N ) {
455 InterfaceInfo * Run; 455 InterfaceInfo * Run;
456 // has PAN connection UP interface ? 456 // has PAN NetworkSetup UP interface ?
457 for( QDictIterator<InterfaceInfo> It(ProbedInterfaces); 457 for( QDictIterator<InterfaceInfo> It(ProbedInterfaces);
458 It.current(); 458 It.current();
459 ++It ) { 459 ++It ) {
460 Run = It.current(); 460 Run = It.current();
461 if( N == Run->Name ) { 461 if( N == Run->Name ) {
462 // this PAN connection is up 462 // this PAN NetworkSetup is up
463 return Run; 463 return Run;
464 } 464 }
465 } 465 }
466 return 0; 466 return 0;
467} 467}
468 468
469#include <stdarg.h> 469#include <stdarg.h>
470static FILE * logf = 0; 470static FILE * logf = 0;
471 471
472void VLog( char * Format, ... ) { 472void VLog( char * Format, ... ) {
473 va_list l; 473 va_list l;
474 474
475 va_start(l, Format ); 475 va_start(l, Format );
476 476
477 if( logf == (FILE *)0 ) { 477 if( logf == (FILE *)0 ) {
478 QString S = getenv("NS2LOG"); 478 QString S = getenv("NS2LOG");
479 if( S == "stderr" ) { 479 if( S == "stderr" ) {
480 logf = stderr; 480 logf = stderr;
481 } else if( S.isEmpty() ) { 481 } else if( S.isEmpty() ) {
482 logf = fopen( "/tmp/ns2log", "a" ); 482 logf = fopen( "/tmp/ns2log", "a" );
483 } else { 483 } else {
484 logf = fopen( S, "a" ); 484 logf = fopen( S, "a" );
485 } 485 }
486 486
487 if( ! logf ) { 487 if( ! logf ) {
488 fprintf( stderr, "Cannot open logfile %s : %d\n", 488 fprintf( stderr, "Cannot open logfile %s : %d\n",
489 S.latin1(), errno ); 489 S.latin1(), errno );
490 logf = (FILE *)1; 490 logf = (FILE *)1;
491 } else { 491 } else {
492 fprintf( logf, "____ OPEN LOGFILE ____\n"); 492 fprintf( logf, "____ OPEN LOGFILE ____\n");
493 } 493 }
494 } 494 }
495 495
496 if( (unsigned long)logf > 1 ) { 496 if( (unsigned long)logf > 1 ) {
497 vfprintf( logf, Format, l ); 497 vfprintf( logf, Format, l );
498 } 498 }
499 va_end( l ); 499 va_end( l );
500 fflush( logf ); 500 fflush( logf );
501 501
502} 502}
503 503
504void LogClose( void ) { 504void LogClose( void ) {
505 if( (long)logf > 1 ) { 505 if( (long)logf > 1 ) {
506 fprintf( logf, "____ CLOSE LOGFILE ____\n"); 506 fprintf( logf, "____ CLOSE LOGFILE ____\n");
507 if( logf != stderr ) { 507 if( logf != stderr ) {
508 fclose( logf ); 508 fclose( logf );
509 } 509 }
510 logf = 0; 510 logf = 0;
511 } 511 }
512} 512}
513 513
514QString removeSpaces( const QString & X ) { 514QString removeSpaces( const QString & X ) {
515 QString Y; 515 QString Y;
516 Y = X.simplifyWhiteSpace(); 516 Y = X.simplifyWhiteSpace();
517 Y.replace( QRegExp(" "), "_" ); 517 Y.replace( QRegExp(" "), "_" );
518 odebug << X << " **" << Y << "**" << oendl; 518 odebug << X << " **" << Y << "**" << oendl;
519 return Y; 519 return Y;
520} 520}
521 521
522// 522//
523// 523//
524// 524//
525// 525//
526// 526//
527 527
528MyProcess::MyProcess() : QObject(), StdoutBuffer(), StderrBuffer() { 528MyProcess::MyProcess() : QObject(), StdoutBuffer(), StderrBuffer() {
529 P = new OProcess(); 529 P = new OProcess();
530 connect( P, 530 connect( P,
531 SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int ) ), 531 SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int ) ),
532 this, 532 this,
533 SLOT( SLOT_Stdout(Opie::Core::OProcess*,char*,int) ) ); 533 SLOT( SLOT_Stdout(Opie::Core::OProcess*,char*,int) ) );
534 534
535 connect( P, 535 connect( P,
536 SIGNAL( receivedStderr(Opie::Core::OProcess*, char*, int ) ), 536 SIGNAL( receivedStderr(Opie::Core::OProcess*, char*, int ) ),
537 this, 537 this,
538 SLOT( SLOT_Stderr(Opie::Core::OProcess*,char*,int) ) ); 538 SLOT( SLOT_Stderr(Opie::Core::OProcess*,char*,int) ) );
539 connect( P, 539 connect( P,
540 SIGNAL( processExited(Opie::Core::OProcess*) ), 540 SIGNAL( processExited(Opie::Core::OProcess*) ),
541 this, 541 this,
542 SLOT( SLOT_ProcessExited(Opie::Core::OProcess*) ) ); 542 SLOT( SLOT_ProcessExited(Opie::Core::OProcess*) ) );
543} 543}
544 544
545MyProcess::~MyProcess() { 545MyProcess::~MyProcess() {
546 delete P; 546 delete P;
547} 547}
548 548
549void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) { 549void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) {
550 if( EchoMode ) { 550 if( EchoMode ) {
551 write( 1, Buf, len ); 551 write( 1, Buf, len );
552 return; 552 return;
553 } 553 }
554 554
555 char * LB = (char *)alloca( len + 1 ); 555 char * LB = (char *)alloca( len + 1 );
556 memcpy( LB, Buf, len ); 556 memcpy( LB, Buf, len );
557 LB[len] = '\0'; 557 LB[len] = '\0';
558 558
diff --git a/noncore/settings/networksettings2/networksettings2/system.h b/noncore/settings/networksettings2/networksettings2/system.h
index ebee0d5..794b868 100644
--- a/noncore/settings/networksettings2/networksettings2/system.h
+++ b/noncore/settings/networksettings2/networksettings2/system.h
@@ -1,140 +1,140 @@
1#ifndef __SYSTEM__H 1#ifndef __SYSTEM__H
2#define __SYSTEM__H 2#define __SYSTEM__H
3 3
4#include <qstring.h> 4#include <qstring.h>
5 5
6#include <opie2/oprocess.h> 6#include <opie2/oprocess.h>
7 7
8using namespace Opie::Core; 8using namespace Opie::Core;
9 9
10// for hardware types 10// for hardware types
11#include <net/if_arp.h> 11#include <net/if_arp.h>
12#include <qdict.h> 12#include <qdict.h>
13#include <qobject.h> 13#include <qobject.h>
14#include <stdio.h> 14#include <stdio.h>
15 15
16class NodeCollection; 16class NetworkSetup;
17class ANetNodeInstance; 17class ANetNodeInstance;
18class QFile; 18class QFile;
19 19
20class MyProcess : public QObject { 20class MyProcess : public QObject {
21 21
22 Q_OBJECT 22 Q_OBJECT
23 23
24public : 24public :
25 25
26 MyProcess(); 26 MyProcess();
27 ~MyProcess(); 27 ~MyProcess();
28 28
29 inline OProcess & process() 29 inline OProcess & process()
30 { return *P; } 30 { return *P; }
31 31
32 inline void setEchoMode( bool M ) { 32 inline void setEchoMode( bool M ) {
33 EchoMode = M; 33 EchoMode = M;
34 } 34 }
35 35
36public slots : 36public slots :
37 37
38 void SLOT_Stdout( Opie::Core::OProcess * P, char *, int ); 38 void SLOT_Stdout( Opie::Core::OProcess * P, char *, int );
39 void SLOT_Stderr( Opie::Core::OProcess * P, char *, int ); 39 void SLOT_Stderr( Opie::Core::OProcess * P, char *, int );
40 void SLOT_ProcessExited( Opie::Core::OProcess * P); 40 void SLOT_ProcessExited( Opie::Core::OProcess * P);
41 41
42signals : 42signals :
43 43
44 void stdoutLine( const QString & ); 44 void stdoutLine( const QString & );
45 void stderrLine( const QString & ); 45 void stderrLine( const QString & );
46 void processExited( MyProcess * ); 46 void processExited( MyProcess * );
47 47
48private : 48private :
49 49
50 QString StdoutBuffer; 50 QString StdoutBuffer;
51 QString StderrBuffer; 51 QString StderrBuffer;
52 OProcess * P; 52 OProcess * P;
53 // output all output to my output 53 // output all output to my output
54 bool EchoMode; 54 bool EchoMode;
55}; 55};
56 56
57class InterfaceInfo { 57class InterfaceInfo {
58 58
59public : 59public :
60 60
61 InterfaceInfo() : 61 InterfaceInfo() :
62 Name(), 62 Name(),
63 MACAddress(), 63 MACAddress(),
64 BCastAddress(), 64 BCastAddress(),
65 Netmask(), 65 Netmask(),
66 DstAddress() { 66 DstAddress() {
67 } 67 }
68 68
69 NodeCollection * assignedConnection() 69 NetworkSetup * assignedToNetworkSetup()
70 { return Collection; } 70 { return Collection; }
71 71
72 void assignConnection( NodeCollection * NNI ) 72 void assignToNetworkSetup( NetworkSetup * NNI )
73 { Collection = NNI; } 73 { Collection = NNI; }
74 74
75 NodeCollection * Collection; // connection taking care of me 75 NetworkSetup * Collection; // networkSetup taking care of me
76 QString Name; // name of interface 76 QString Name; // name of interface
77 int CardType; // type of card 77 int CardType; // type of card
78 QString MACAddress; // MAC address 78 QString MACAddress; // MAC address
79 QString Address; // IP Address 79 QString Address; // IP Address
80 QString BCastAddress; // Broadcast Address 80 QString BCastAddress; // Broadcast Address
81 QString Netmask; // Netmask 81 QString Netmask; // Netmask
82 QString DstAddress; // Peer address (if P-t-P) 82 QString DstAddress; // Peer address (if P-t-P)
83 bool IsUp; // interface is UP 83 bool IsUp; // interface is UP
84 bool HasMulticast; // Supports Multicast 84 bool HasMulticast; // Supports Multicast
85 bool IsPointToPoint; // IsPointToPoint card 85 bool IsPointToPoint; // IsPointToPoint card
86 86
87 QString RcvBytes; 87 QString RcvBytes;
88 QString SndBytes; 88 QString SndBytes;
89 QString RcvErrors; 89 QString RcvErrors;
90 QString SndErrors; 90 QString SndErrors;
91 QString RcvDropped; 91 QString RcvDropped;
92 QString SndDropped; 92 QString SndDropped;
93 QString Collisions; 93 QString Collisions;
94}; 94};
95 95
96class System : public QObject { 96class System : public QObject {
97 97
98 Q_OBJECT 98 Q_OBJECT
99 99
100public : 100public :
101 101
102 System( void ); 102 System( void );
103 ~System( void ); 103 ~System( void );
104 104
105 QDict<InterfaceInfo> & interfaces( void ); 105 QDict<InterfaceInfo> & interfaces( void );
106 InterfaceInfo * interface( const QString& N ) 106 InterfaceInfo * interface( const QString& N )
107 { return interfaces()[N]; } 107 { return interfaces()[N]; }
108 108
109 // exec command as root 109 // exec command as root
110 int runAsRoot( QStringList & S, MyProcess * Prc = 0 ); 110 int runAsRoot( QStringList & S, MyProcess * Prc = 0 );
111 111
112 // exec command as user 112 // exec command as user
113 int execAsUser( QStringList & Cmd, bool Synchronous = 0 ); 113 int execAsUser( QStringList & Cmd, bool Synchronous = 0 );
114 114
115 // refresh stats for this interface 115 // refresh stats for this interface
116 void refreshStatistics( InterfaceInfo & ); 116 void refreshStatistics( InterfaceInfo & );
117 117
118 // reloads interfaces 118 // reloads interfaces
119 void probeInterfaces( void ); 119 void probeInterfaces( void );
120 120
121 InterfaceInfo * findInterface( const QString & DevName ); 121 InterfaceInfo * findInterface( const QString & DevName );
122 122
123private slots : 123private slots :
124 124
125 void SLOT_ProcessExited( MyProcess * ); 125 void SLOT_ProcessExited( MyProcess * );
126 126
127signals : 127signals :
128 128
129 void stdoutLine( const QString & ); 129 void stdoutLine( const QString & );
130 void stderrLine( const QString & ); 130 void stderrLine( const QString & );
131 void processEvent( const QString & ); 131 void processEvent( const QString & );
132 132
133private : 133private :
134 134
135 QDict<InterfaceInfo> ProbedInterfaces; 135 QDict<InterfaceInfo> ProbedInterfaces;
136 FILE * OutputOfCmd; 136 FILE * OutputOfCmd;
137 QFile * ProcDevNet; 137 QFile * ProcDevNet;
138}; 138};
139 139
140#endif 140#endif
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index 39031ed..b4622fc 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -1,787 +1,787 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <opie2/odebug.h> 2#include <opie2/odebug.h>
3#include <qpe/qpeapplication.h> 3#include <qpe/qpeapplication.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qdir.h> 5#include <qdir.h>
6#include <qfile.h> 6#include <qfile.h>
7#include <qfileinfo.h> 7#include <qfileinfo.h>
8 8
9#include "nsdata.h" 9#include "nsdata.h"
10#include <netnode.h> 10#include <netnode.h>
11#include <resources.h> 11#include <resources.h>
12 12
13static QString CfgFile; 13static QString CfgFile;
14 14
15NetworkSettingsData::NetworkSettingsData( void ) { 15NetworkSettingsData::NetworkSettingsData( void ) {
16 // init global resources structure 16 // init global resources structure
17 new TheNSResources(); 17 new TheNSResources();
18 18
19 if( ! NSResources->userKnown() ) { 19 if( ! NSResources->userKnown() ) {
20 Log(( "Cannot detect qpe user HOME=\"%s\" USER=\"%s\"\n", 20 Log(( "Cannot detect qpe user HOME=\"%s\" USER=\"%s\"\n",
21 NSResources->currentUser().HomeDir.latin1(), 21 NSResources->currentUser().HomeDir.latin1(),
22 NSResources->currentUser().UserName.latin1() )); 22 NSResources->currentUser().UserName.latin1() ));
23 return; 23 return;
24 } 24 }
25 25
26 CfgFile.sprintf( "%s/Settings/NS2.conf", 26 CfgFile.sprintf( "%s/Settings/NS2.conf",
27 NSResources->currentUser().HomeDir.latin1() ); 27 NSResources->currentUser().HomeDir.latin1() );
28 Log(( "Cfg from %s\n", CfgFile.latin1() )); 28 Log(( "Cfg from %s\n", CfgFile.latin1() ));
29 29
30 // load settings 30 // load settings
31 loadSettings(); 31 loadSettings();
32 32
33 // assign interfaces by scanning /tmp/profile-%s.Up files 33 // assign interfaces by scanning /tmp/profile-%s.Up files
34 { QDir D( "/tmp" ); 34 { QDir D( "/tmp" );
35 QFile * F = new QFile; 35 QFile * F = new QFile;
36 int profilenr; 36 int profilenr;
37 QString interfacename; 37 QString interfacename;
38 QTextStream TS ( F ); 38 QTextStream TS ( F );
39 39
40 QStringList SL = D.entryList( "profile-*.up"); 40 QStringList SL = D.entryList( "profile-*.up");
41 41
42 Log(( "System reports %d interfaces. Found %d up\n", 42 Log(( "System reports %d interfaces. Found %d up\n",
43 NSResources->system().interfaces().count(), 43 NSResources->system().interfaces().count(),
44 SL.count() )); 44 SL.count() ));
45 45
46 for ( QStringList::Iterator it = SL.begin(); 46 for ( QStringList::Iterator it = SL.begin();
47 it != SL.end(); 47 it != SL.end();
48 ++it ) { 48 ++it ) {
49 profilenr = atol( (*it).mid( 8 ).latin1() ); 49 profilenr = atol( (*it).mid( 8 ).latin1() );
50 // read the interface store int 'up' 50 // read the interface store int 'up'
51 F->setName( D.path() + "/" + (*it) ); 51 F->setName( D.path() + "/" + (*it) );
52 if( F->open( IO_ReadOnly ) ) { 52 if( F->open( IO_ReadOnly ) ) {
53 NodeCollection * NC; 53 NetworkSetup * NC;
54 interfacename = TS.readLine(); 54 interfacename = TS.readLine();
55 F->close(); 55 F->close();
56 56
57 Log(( "Assign interface %s to Profile nr %d\n", 57 Log(( "Assign interface %s to Profile nr %d\n",
58 interfacename.latin1(), profilenr )); 58 interfacename.latin1(), profilenr ));
59 59
60 NC = NSResources->getConnection( profilenr ); 60 NC = NSResources->getNetworkSetup( profilenr );
61 if( NC ) { 61 if( NC ) {
62 NC->assignInterface( 62 NC->assignInterface(
63 NSResources->system().findInterface( interfacename ) ); 63 NSResources->system().findInterface( interfacename ) );
64 Log(( "Assign interface %p\n", 64 Log(( "Assign interface %p\n",
65 NC->assignedInterface() )); 65 NC->assignedInterface() ));
66 } else { 66 } else {
67 Log(( "Profile nr %d no longer defined\n", 67 Log(( "Profile nr %d no longer defined\n",
68 profilenr )); 68 profilenr ));
69 } 69 }
70 } 70 }
71 } 71 }
72 } 72 }
73} 73}
74 74
75// saving is done by caller 75// saving is done by caller
76NetworkSettingsData::~NetworkSettingsData( void ) { 76NetworkSettingsData::~NetworkSettingsData( void ) {
77 delete NSResources; 77 delete NSResources;
78} 78}
79 79
80void NetworkSettingsData::loadSettings( void ) { 80void NetworkSettingsData::loadSettings( void ) {
81 QString Line, S; 81 QString Line, S;
82 QString Attr, Value; 82 QString Attr, Value;
83 long idx; 83 long idx;
84 84
85 QFile F( CfgFile ); 85 QFile F( CfgFile );
86 QTextStream TS( &F ); 86 QTextStream TS( &F );
87 87
88 ForceModified = 0; 88 ForceModified = 0;
89 89
90 do { 90 do {
91 91
92 if( ! F.open(IO_ReadOnly) ) 92 if( ! F.open(IO_ReadOnly) )
93 break; 93 break;
94 94
95 /* load the file -> 95 /* load the file ->
96 96
97 FORMAT : 97 FORMAT :
98 98
99 [NETNODETYPE] 99 [NETNODETYPE]
100 Entries ... 100 Entries ...
101 <EMPTYLINE> 101 <EMPTYLINE>
102 [connection] 102 [NetworkSetup]
103 Name=Name 103 Name=Name
104 Node=Name 104 Node=Name
105 <EMPTYLINE> 105 <EMPTYLINE>
106 */ 106 */
107 while( ! TS.atEnd() ) { 107 while( ! TS.atEnd() ) {
108 S = Line = TS.readLine(); 108 S = Line = TS.readLine();
109 109
110 if ( S.isEmpty() || S[0] != '[' ) 110 if ( S.isEmpty() || S[0] != '[' )
111 continue; 111 continue;
112 112
113 S = S.mid( 1, S.length()-2 ); 113 S = S.mid( 1, S.length()-2 );
114 114
115 if( ! NSResources ) { 115 if( ! NSResources ) {
116 continue; 116 continue;
117 } 117 }
118 118
119 if( S == "connection" ) { 119 if( S == "NetworkSetup" ) {
120 // load connections -> collections of nodes 120 // load NetworkSetups -> collections of nodes
121 bool Dangling; 121 bool Dangling;
122 NodeCollection * NC = new NodeCollection( TS, Dangling ); 122 NetworkSetup * NC = new NetworkSetup( TS, Dangling );
123 NSResources->addConnection( NC, Dangling ); 123 NSResources->addNetworkSetup( NC, Dangling );
124 } else { 124 } else {
125 ANetNode * NN = 0; 125 ANetNode * NN = 0;
126 ANetNodeInstance* NNI = 0; 126 ANetNodeInstance* NNI = 0;
127 if( S.startsWith( "nodetype " ) ) { 127 if( S.startsWith( "nodetype " ) ) {
128 S = S.mid( 9, S.length()-9 ); 128 S = S.mid( 9, S.length()-9 );
129 S = deQuote(S); 129 S = deQuote(S);
130 // try to find netnode 130 // try to find netnode
131 NN = NSResources->findNetNode( S ); 131 NN = NSResources->findNetNode( S );
132 } else { 132 } else {
133 // try to find instance 133 // try to find instance
134 NNI = NSResources->createNodeInstance( S ); 134 NNI = NSResources->createNodeInstance( S );
135 } 135 }
136 136
137 if( NN == 0 && NNI == 0 ) { 137 if( NN == 0 && NNI == 0 ) {
138 LeftOvers.append( Line ); 138 LeftOvers.append( Line );
139 do { 139 do {
140 Line = TS.readLine(); 140 Line = TS.readLine();
141 // store even delimiter 141 // store even delimiter
142 LeftOvers.append( Line ); 142 LeftOvers.append( Line );
143 } while ( ! Line.isEmpty() ); 143 } while ( ! Line.isEmpty() );
144 144
145 //next section 145 //next section
146 continue; 146 continue;
147 } 147 }
148 148
149 // read entries of this section 149 // read entries of this section
150 do { 150 do {
151 S = Line = TS.readLine(); 151 S = Line = TS.readLine();
152 152
153 if( S.isEmpty() ) { 153 if( S.isEmpty() ) {
154 // empty line 154 // empty line
155 break; 155 break;
156 } 156 }
157 idx = S.find( '=' ); 157 idx = S.find( '=' );
158 if( idx > 0 ) { 158 if( idx > 0 ) {
159 Attr = S.left( idx ); 159 Attr = S.left( idx );
160 Value = S.mid( idx+1, S.length() ); 160 Value = S.mid( idx+1, S.length() );
161 } else { 161 } else {
162 Value=""; 162 Value="";
163 Attr = S; 163 Attr = S;
164 } 164 }
165 165
166 Value.stripWhiteSpace(); 166 Value.stripWhiteSpace();
167 Attr.stripWhiteSpace(); 167 Attr.stripWhiteSpace();
168 Attr.lower(); 168 Attr.lower();
169 // dequote Attr 169 // dequote Attr
170 Value = deQuote(Value); 170 Value = deQuote(Value);
171 171
172 if( NN ) { 172 if( NN ) {
173 // set the attribute 173 // set the attribute
174 NN->setAttribute( Attr, Value ); 174 NN->setAttribute( Attr, Value );
175 } else { 175 } else {
176 // set the attribute 176 // set the attribute
177 NNI->setAttribute( Attr, Value ); 177 NNI->setAttribute( Attr, Value );
178 } 178 }
179 } while( 1 ); 179 } while( 1 );
180 180
181 if( NNI ) { 181 if( NNI ) {
182 // loading from file -> exists 182 // loading from file -> exists
183 Log( ( "NodeInstance %s : %p\n", NNI->name(), NNI )); 183 Log( ( "NodeInstance %s : %p\n", NNI->name(), NNI ));
184 NNI->setNew( FALSE ); 184 NNI->setNew( FALSE );
185 NSResources->addNodeInstance( NNI ); 185 NSResources->addNodeInstance( NNI );
186 } 186 }
187 187
188 if( NN ) { 188 if( NN ) {
189 Log( ( "Node %s : %p\n", NN->name(), NN ) ); 189 Log( ( "Node %s : %p\n", NN->name(), NN ) );
190 } 190 }
191 } 191 }
192 } 192 }
193 193
194 } while( 0 ); 194 } while( 0 );
195 195
196} 196}
197 197
198QString NetworkSettingsData::saveSettings( void ) { 198QString NetworkSettingsData::saveSettings( void ) {
199 QString ErrS = ""; 199 QString ErrS = "";
200 200
201 if( ! isModified() ) 201 if( ! isModified() )
202 return ErrS; 202 return ErrS;
203 203
204 QString S; 204 QString S;
205 QFile F( CfgFile + ".bup" ); 205 QFile F( CfgFile + ".bup" );
206 206
207 Log( ( "Saving settings to %s\n", CfgFile.latin1() )); 207 Log( ( "Saving settings to %s\n", CfgFile.latin1() ));
208 if( ! F.open( IO_WriteOnly | IO_Truncate ) ) { 208 if( ! F.open( IO_WriteOnly | IO_Truncate ) ) {
209 ErrS = qApp->translate( "NetworkSettings", 209 ErrS = qApp->translate( "NetworkSettings",
210 "<p>Could not save setup to \"%1\" !</p>" ). 210 "<p>Could not save setup to \"%1\" !</p>" ).
211 arg(CfgFile); 211 arg(CfgFile);
212 // problem 212 // problem
213 return ErrS; 213 return ErrS;
214 } 214 }
215 215
216 QTextStream TS( &F ); 216 QTextStream TS( &F );
217 217
218 // save global configs 218 // save global configs
219 for( QDictIterator<ANetNode> it( NSResources->netNodes() ); 219 for( QDictIterator<ANetNode> it( NSResources->netNodes() );
220 it.current(); 220 it.current();
221 ++it ) { 221 ++it ) {
222 TS << "[nodetype " 222 TS << "[nodetype "
223 << quote( QString( it.current()->name() ) ) 223 << quote( QString( it.current()->name() ) )
224 << "]" 224 << "]"
225 << endl; 225 << endl;
226 226
227 it.current()->saveAttributes( TS ); 227 it.current()->saveAttributes( TS );
228 TS << endl; 228 TS << endl;
229 } 229 }
230 230
231 // save leftovers 231 // save leftovers
232 for ( QStringList::Iterator it = LeftOvers.begin(); 232 for ( QStringList::Iterator it = LeftOvers.begin();
233 it != LeftOvers.end(); ++it ) { 233 it != LeftOvers.end(); ++it ) {
234 TS << (*it) << endl; 234 TS << (*it) << endl;
235 } 235 }
236 236
237 // save all netnode instances 237 // save all netnode instances
238 { ANetNodeInstance * NNI; 238 { ANetNodeInstance * NNI;
239 for( QDictIterator<ANetNodeInstance> nit( 239 for( QDictIterator<ANetNodeInstance> nit(
240 NSResources->netNodeInstances()); 240 NSResources->netNodeInstances());
241 nit.current(); 241 nit.current();
242 ++nit ) { 242 ++nit ) {
243 // header 243 // header
244 NNI = nit.current(); 244 NNI = nit.current();
245 TS << '[' 245 TS << '['
246 << QString(NNI->nodeClass()->name()) 246 << QString(NNI->nodeClass()->name())
247 << ']' 247 << ']'
248 << endl; 248 << endl;
249 NNI->saveAttributes( TS ); 249 NNI->saveAttributes( TS );
250 TS << endl; 250 TS << endl;
251 } 251 }
252 } 252 }
253 253
254 // good connections 254 // good NetworkSetups
255 { Name2Connection_t & M = NSResources->connections(); 255 { Name2NetworkSetup_t & M = NSResources->networkSetups();
256 256
257 // for all connections 257 // for all NetworkSetups
258 for( QDictIterator<NodeCollection> it(M); 258 for( QDictIterator<NetworkSetup> it(M);
259 it.current(); 259 it.current();
260 ++it ) { 260 ++it ) {
261 TS << "[connection]" << endl; 261 TS << "[NetworkSetup]" << endl;
262 it.current()->save(TS); 262 it.current()->save(TS);
263 } 263 }
264 } 264 }
265 265
266 // save dangling connections 266 // save dangling NetworkSetups
267 { Name2Connection_t & M = NSResources->danglingConnections(); 267 { Name2NetworkSetup_t & M = NSResources->danglingNetworkSetups();
268 268
269 // for all connections 269 // for all NetworkSetups
270 for( QDictIterator<NodeCollection> it(M); 270 for( QDictIterator<NetworkSetup> it(M);
271 it.current(); 271 it.current();
272 ++it ) { 272 ++it ) {
273 TS << "[connection]" << endl; 273 TS << "[NetworkSetup]" << endl;
274 it.current()->save(TS); 274 it.current()->save(TS);
275 } 275 }
276 } 276 }
277 277
278 QDir D("."); 278 QDir D(".");
279 D.rename( CfgFile + ".bup", CfgFile ); 279 D.rename( CfgFile + ".bup", CfgFile );
280 280
281 // 281 //
282 // proper files AND system files regenerated 282 // proper files AND system files regenerated
283 // 283 //
284 284
285 285
286 for( QDictIterator<NodeCollection> it(NSResources->connections()); 286 for( QDictIterator<NetworkSetup> it(NSResources->networkSetups());
287 it.current(); 287 it.current();
288 ++it ) { 288 ++it ) {
289 it.current()->setModified( 0 ); 289 it.current()->setModified( 0 );
290 } 290 }
291 291
292 return ErrS; 292 return ErrS;
293} 293}
294 294
295QString NetworkSettingsData::generateSettings( void ) { 295QString NetworkSettingsData::generateSettings( void ) {
296 QString S = ""; 296 QString S = "";
297 Name2SystemFile_t & SFM = NSResources->systemFiles(); 297 Name2SystemFile_t & SFM = NSResources->systemFiles();
298 Name2Connection_t & M = NSResources->connections(); 298 Name2NetworkSetup_t & M = NSResources->networkSetups();
299 NodeCollection * NC; 299 NetworkSetup * NC;
300 ANetNodeInstance * NNI; 300 ANetNodeInstance * NNI;
301 ANetNodeInstance * FirstWithData; 301 ANetNodeInstance * FirstWithData;
302 RuntimeInfo * CurDev; 302 RuntimeInfo * CurDev;
303 ANetNode * NN, * CurDevNN = 0; 303 ANetNode * NN, * CurDevNN = 0;
304 long NoOfDevs; 304 long NoOfDevs;
305 long DevCtStart; 305 long DevCtStart;
306 bool needToGenerate; 306 bool needToGenerate;
307 307
308 // regenerate system files 308 // regenerate system files
309 Log( ( "Generating settings from %s\n", CfgFile.latin1() )); 309 Log( ( "Generating settings from %s\n", CfgFile.latin1() ));
310 310
311 for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); 311 for( QDictIterator<ANetNode> nnit( NSResources->netNodes() );
312 nnit.current(); 312 nnit.current();
313 ++nnit ) { 313 ++nnit ) {
314 bool FirstItem = 1; 314 bool FirstItem = 1;
315 bool Generated = 0; 315 bool Generated = 0;
316 316
317 CurDevNN = nnit.current(); 317 CurDevNN = nnit.current();
318 318
319 { QStringList SL; 319 { QStringList SL;
320 SL = CurDevNN->properFiles(); 320 SL = CurDevNN->properFiles();
321 321
322 for ( QStringList::Iterator it = SL.begin(); 322 for ( QStringList::Iterator it = SL.begin();
323 it != SL.end(); 323 it != SL.end();
324 ++it ) { 324 ++it ) {
325 325
326 Generated = 0; 326 Generated = 0;
327 FirstItem = 1; 327 FirstItem = 1;
328 // iterate over NNI's of this class 328 // iterate over NNI's of this class
329 for( QDictIterator<ANetNodeInstance> nniit( 329 for( QDictIterator<ANetNodeInstance> nniit(
330 NSResources->netNodeInstances() ); 330 NSResources->netNodeInstances() );
331 nniit.current(); 331 nniit.current();
332 ++nniit ) { 332 ++nniit ) {
333 if( nniit.current()->nodeClass() != CurDevNN ) 333 if( nniit.current()->nodeClass() != CurDevNN )
334 // different class 334 // different class
335 continue; 335 continue;
336 336
337 // open proper file 337 // open proper file
338 { SystemFile SF( (*it) ); 338 { SystemFile SF( (*it) );
339 339
340 if( ! CurDevNN->openFile( SF, nniit.current()) ) { 340 if( ! CurDevNN->openFile( SF, nniit.current()) ) {
341 // cannot open 341 // cannot open
342 S = qApp->translate( "NetworkSettings", 342 S = qApp->translate( "NetworkSettings",
343 "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). 343 "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
344 arg( (*it) ).arg( CurDevNN->name() ); 344 arg( (*it) ).arg( CurDevNN->name() );
345 return S; 345 return S;
346 } 346 }
347 347
348 if( ! SF.open() ) { 348 if( ! SF.open() ) {
349 S = qApp->translate( "NetworkSettings", 349 S = qApp->translate( "NetworkSettings",
350 "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). 350 "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
351 arg( (*it) ).arg( CurDevNN->name() ); 351 arg( (*it) ).arg( CurDevNN->name() );
352 return S; 352 return S;
353 } 353 }
354 354
355 // preamble on first 355 // preamble on first
356 if( FirstItem ) { 356 if( FirstItem ) {
357 if( CurDevNN->generatePreamble( SF ) == 2 ) { 357 if( CurDevNN->generatePreamble( SF ) == 2 ) {
358 S = qApp->translate( "NetworkSettings", 358 S = qApp->translate( "NetworkSettings",
359 "<p>Error in section \"preamble\" for proper file \"%1\" and node \"%2\"</p>" ). 359 "<p>Error in section \"preamble\" for proper file \"%1\" and node \"%2\"</p>" ).
360 arg( (*it) ). 360 arg( (*it) ).
361 arg( CurDevNN->name() ); 361 arg( CurDevNN->name() );
362 return S; 362 return S;
363 } 363 }
364 } 364 }
365 FirstItem = 0; 365 FirstItem = 0;
366 Generated = 1; 366 Generated = 1;
367 367
368 // item specific 368 // item specific
369 if( nniit.current()->generateFile( SF, -1 ) == 2 ) { 369 if( nniit.current()->generateFile( SF, -1 ) == 2 ) {
370 S = qApp->translate( "NetworkSettings", 370 S = qApp->translate( "NetworkSettings",
371 "<p>Error in section for node \"%1\" for proper file \"%2\" and node class \"%3\"</p>" ). 371 "<p>Error in section for node \"%1\" for proper file \"%2\" and node class \"%3\"</p>" ).
372 arg( nniit.current()->name() ). 372 arg( nniit.current()->name() ).
373 arg( (*it) ). 373 arg( (*it) ).
374 arg( CurDevNN->name() ); 374 arg( CurDevNN->name() );
375 return S; 375 return S;
376 } 376 }
377 } 377 }
378 } 378 }
379 379
380 if( Generated ) { 380 if( Generated ) {
381 SystemFile SF( (*it) ); 381 SystemFile SF( (*it) );
382 382
383 if( CurDevNN->openFile( SF, 0 ) && 383 if( CurDevNN->openFile( SF, 0 ) &&
384 ! SF.path().isEmpty() 384 ! SF.path().isEmpty()
385 ) { 385 ) {
386 386
387 if( ! SF.open() ) { 387 if( ! SF.open() ) {
388 S = qApp->translate( "NetworkSettings", 388 S = qApp->translate( "NetworkSettings",
389 "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). 389 "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
390 arg( (*it) ).arg( CurDevNN->name() ); 390 arg( (*it) ).arg( CurDevNN->name() );
391 return S; 391 return S;
392 } 392 }
393 393
394 if( CurDevNN->generatePostamble( SF ) == 2 ) { 394 if( CurDevNN->generatePostamble( SF ) == 2 ) {
395 S = qApp->translate( "NetworkSettings", 395 S = qApp->translate( "NetworkSettings",
396 "<p>Error in section \"postamble\" for proper file \"%1\" and node \"%2\"</p>" ). 396 "<p>Error in section \"postamble\" for proper file \"%1\" and node \"%2\"</p>" ).
397 arg( (*it) ). 397 arg( (*it) ).
398 arg( CurDevNN->name() ); 398 arg( CurDevNN->name() );
399 return S; 399 return S;
400 } 400 }
401 } // no postamble 401 } // no postamble
402 } 402 }
403 } 403 }
404 } 404 }
405 } 405 }
406 406
407 // 407 //
408 // generate all registered files 408 // generate all registered files
409 // 409 //
410 for( QDictIterator<SystemFile> sfit(SFM); 410 for( QDictIterator<SystemFile> sfit(SFM);
411 sfit.current(); 411 sfit.current();
412 ++sfit ) { 412 ++sfit ) {
413 SystemFile * SF; 413 SystemFile * SF;
414 414
415 SF = sfit.current(); 415 SF = sfit.current();
416 416
417 // reset all 417 // reset all
418 for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); 418 for( QDictIterator<ANetNode> nnit( NSResources->netNodes() );
419 nnit.current(); 419 nnit.current();
420 ++nnit ) { 420 ++nnit ) {
421 nnit.current()->setDone(0); 421 nnit.current()->setDone(0);
422 } 422 }
423 423
424 for( QDictIterator<ANetNodeInstance> nniit( 424 for( QDictIterator<ANetNodeInstance> nniit(
425 NSResources->netNodeInstances() ); 425 NSResources->netNodeInstances() );
426 nniit.current(); 426 nniit.current();
427 ++nniit ) { 427 ++nniit ) {
428 nniit.current()->setDone(0); 428 nniit.current()->setDone(0);
429 } 429 }
430 430
431 for( QDictIterator<NodeCollection> ncit(M); 431 for( QDictIterator<NetworkSetup> ncit(M);
432 ncit.current(); 432 ncit.current();
433 ++ncit ) { 433 ++ncit ) {
434 ncit.current()->setDone(0); 434 ncit.current()->setDone(0);
435 } 435 }
436 436
437 Log( ( "Generating system file %s\n", SF->name().latin1() )); 437 Log( ( "Generating system file %s\n", SF->name().latin1() ));
438 438
439 needToGenerate = 0; 439 needToGenerate = 0;
440 440
441 // are there netnodes that have instances and need 441 // are there netnodes that have instances and need
442 // to write data in this system file ? 442 // to write data in this system file ?
443 for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); 443 for( QDictIterator<ANetNode> nnit( NSResources->netNodes() );
444 ! needToGenerate && nnit.current(); 444 ! needToGenerate && nnit.current();
445 ++nnit ) { 445 ++nnit ) {
446 446
447 NN = nnit.current(); 447 NN = nnit.current();
448 448
449 if( NN->hasDataForFile( *SF ) ) { 449 if( NN->hasDataForFile( *SF ) ) {
450 // netnode can have data 450 // netnode can have data
451 451
452 // are there instances of this node ? 452 // are there instances of this node ?
453 for( QDictIterator<ANetNodeInstance> nniit( 453 for( QDictIterator<ANetNodeInstance> nniit(
454 NSResources->netNodeInstances() ); 454 NSResources->netNodeInstances() );
455 ! needToGenerate && nniit.current(); 455 ! needToGenerate && nniit.current();
456 ++nniit ) { 456 ++nniit ) {
457 if( nniit.current()->nodeClass() == NN ) { 457 if( nniit.current()->nodeClass() == NN ) {
458 // yes 458 // yes
459 Log(("Node %s has data\n", 459 Log(("Node %s has data\n",
460 nniit.current()->name() )); 460 nniit.current()->name() ));
461 needToGenerate = 1; 461 needToGenerate = 1;
462 break; 462 break;
463 } 463 }
464 } 464 }
465 } 465 }
466 } 466 }
467 467
468 if( ! needToGenerate ) { 468 if( ! needToGenerate ) {
469 // no instances found that might need to write data 469 // no instances found that might need to write data
470 // in this systemfile 470 // in this systemfile
471 Log(("No nodes for systemfile %s\n", SF->name().latin1() )); 471 Log(("No nodes for systemfile %s\n", SF->name().latin1() ));
472 continue; 472 continue;
473 } 473 }
474 474
475 // ok generate this system file 475 // ok generate this system file
476 if( ! SF->open() ) { 476 if( ! SF->open() ) {
477 S = qApp->translate( "NetworkSettings", 477 S = qApp->translate( "NetworkSettings",
478 "<p>Cannot open system file \"%1\"</p>" ). 478 "<p>Cannot open system file \"%1\"</p>" ).
479 arg( SF->name() ); 479 arg( SF->name() );
480 return S; 480 return S;
481 } 481 }
482 482
483 // global presection for this system file 483 // global presection for this system file
484 if( ! SF->preSection() ) { 484 if( ! SF->preSection() ) {
485 S = qApp->translate( "NetworkSettings", 485 S = qApp->translate( "NetworkSettings",
486 "<p>Error in section \"Preamble\" for file \"%1\"</p>" ). 486 "<p>Error in section \"Preamble\" for file \"%1\"</p>" ).
487 arg( SF->name() ); 487 arg( SF->name() );
488 return S; 488 return S;
489 } 489 }
490 490
491 // find connections that want to write to this file 491 // find NetworkSetups that want to write to this file
492 for( QDictIterator<NodeCollection> ncit(M); 492 for( QDictIterator<NetworkSetup> ncit(M);
493 ncit.current(); 493 ncit.current();
494 ++ncit ) { 494 ++ncit ) {
495 495
496 NC = ncit.current(); 496 NC = ncit.current();
497 497
498 if( NC->done() ) { 498 if( NC->done() ) {
499 // already done 499 // already done
500 continue; 500 continue;
501 } 501 }
502 502
503 if( ! NC->hasDataForFile( *SF ) ) { 503 if( ! NC->hasDataForFile( *SF ) ) {
504 // no data 504 // no data
505 continue; 505 continue;
506 } 506 }
507 507
508 Log(("Generating %s for connection %s\n", 508 Log(("Generating %s for NetworkSetup %s\n",
509 SF->name().latin1(), NC->name().latin1() )); 509 SF->name().latin1(), NC->name().latin1() ));
510 // find highest item that wants to write data to this file 510 // find highest item that wants to write data to this file
511 FirstWithData = NC->firstWithDataForFile( *SF ); 511 FirstWithData = NC->firstWithDataForFile( *SF );
512 512
513 // find device on which this connection works 513 // find device on which this NetworkSetup works
514 CurDev = NC->device(); 514 CurDev = NC->device();
515 // class of that node 515 // class of that node
516 CurDevNN = CurDev->netNode()->nodeClass(); 516 CurDevNN = CurDev->netNode()->nodeClass();
517 517
518 if( ! FirstWithData->nodeClass()->done() ) { 518 if( ! FirstWithData->nodeClass()->done() ) {
519 // generate fixed part 519 // generate fixed part
520 if( ! SF->preDeviceSection( CurDevNN ) ) { 520 if( ! SF->preDeviceSection( CurDevNN ) ) {
521 S = qApp->translate( "NetworkSettings", 521 S = qApp->translate( "NetworkSettings",
522 "<p>Error in section \"Pre-Device\" for file \"%1\"</p>" ). 522 "<p>Error in section \"Pre-Device\" for file \"%1\"</p>" ).
523 arg( SF->name() ); 523 arg( SF->name() );
524 return S; 524 return S;
525 } 525 }
526 526
527 if( FirstWithData->nodeClass()->generateFile( 527 if( FirstWithData->nodeClass()->generateFile(
528 *SF, 528 *SF,
529 FirstWithData, 529 FirstWithData,
530 -2 ) == 2 ) { 530 -2 ) == 2 ) {
531 S = qApp->translate( "NetworkSettings", 531 S = qApp->translate( "NetworkSettings",
532 "<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ). 532 "<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ).
533 arg( SF->name() ). 533 arg( SF->name() ).
534 arg( CurDevNN->name() ); 534 arg( CurDevNN->name() );
535 return S; 535 return S;
536 } 536 }
537 FirstWithData->nodeClass()->setDone( 1 ); 537 FirstWithData->nodeClass()->setDone( 1 );
538 Log(( "Systemfile %s for node instance %s is done\n", 538 Log(( "Systemfile %s for node instance %s is done\n",
539 SF->name().latin1(), 539 SF->name().latin1(),
540 FirstWithData->name() )); 540 FirstWithData->name() ));
541 } 541 }
542 542
543 NoOfDevs = 0; 543 NoOfDevs = 0;
544 DevCtStart = -1; 544 DevCtStart = -1;
545 545
546 if( SF->knowsDeviceInstances() ) { 546 if( SF->knowsDeviceInstances() ) {
547 DevCtStart = 0; 547 DevCtStart = 0;
548 NoOfDevs = CurDevNN->instanceCount(); 548 NoOfDevs = CurDevNN->instanceCount();
549 } 549 }
550 550
551 if( ! CurDev->netNode()->nodeClass()->done() ) { 551 if( ! CurDev->netNode()->nodeClass()->done() ) {
552 // first time this device is handled 552 // first time this device is handled
553 // generate common device specific part 553 // generate common device specific part
554 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { 554 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) {
555 555
556 if( FirstWithData->nodeClass()->generateFile( 556 if( FirstWithData->nodeClass()->generateFile(
557 *SF, CurDev->netNode(), i ) == 2 ) { 557 *SF, CurDev->netNode(), i ) == 2 ) {
558 S = qApp->translate( "NetworkSettings", 558 S = qApp->translate( "NetworkSettings",
559 "<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ). 559 "<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ).
560 arg( SF->name() ). 560 arg( SF->name() ).
561 arg( CurDevNN->name() ); 561 arg( CurDevNN->name() );
562 return S; 562 return S;
563 } 563 }
564 } 564 }
565 CurDev->netNode()->nodeClass()->setDone( 1 ); 565 CurDev->netNode()->nodeClass()->setDone( 1 );
566 566
567 Log(( "Systemfile %s for Nodeclass %s is done\n", 567 Log(( "Systemfile %s for Nodeclass %s is done\n",
568 SF->name().latin1(), 568 SF->name().latin1(),
569 CurDev->netNode()->nodeClass()->name() 569 CurDev->netNode()->nodeClass()->name()
570 )); 570 ));
571 } 571 }
572 572
573 // generate profile specific info 573 // generate profile specific info
574 // for all nodeconnections that work on the same device 574 // for all nodeNetworkSetups that work on the same device
575 for( QDictIterator<NodeCollection> ncit2(M); 575 for( QDictIterator<NetworkSetup> ncit2(M);
576 ncit2.current(); 576 ncit2.current();
577 ++ncit2 ) { 577 ++ncit2 ) {
578 578
579 if( ncit2.current()->device() != CurDev ) { 579 if( ncit2.current()->device() != CurDev ) {
580 // different device 580 // different device
581 continue; 581 continue;
582 } 582 }
583 583
584 Log(("Connection %s of family %s\n", 584 Log(("NetworkSetup %s of family %s\n",
585 ncit2.current()->name().latin1(), 585 ncit2.current()->name().latin1(),
586 CurDev->name() )); 586 CurDev->name() ));
587 // generate 587 // generate
588 NNI = ncit2.current()->firstWithDataForFile( *SF ); 588 NNI = ncit2.current()->firstWithDataForFile( *SF );
589 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { 589 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) {
590 if( ! SF->preNodeSection( NNI, i ) ) { 590 if( ! SF->preNodeSection( NNI, i ) ) {
591 S = qApp->translate( "NetworkSettings", 591 S = qApp->translate( "NetworkSettings",
592 "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ). 592 "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
593 arg( SF->name() ). 593 arg( SF->name() ).
594 arg( CurDevNN->name() ); 594 arg( CurDevNN->name() );
595 return S; 595 return S;
596 } 596 }
597 597
598 switch( NNI->generateFile( *SF, i ) ) { 598 switch( NNI->generateFile( *SF, i ) ) {
599 case 0 : 599 case 0 :
600 (*SF) << endl; 600 (*SF) << endl;
601 break; 601 break;
602 case 1 : 602 case 1 :
603 break; 603 break;
604 case 2 : 604 case 2 :
605 S = qApp->translate( "NetworkSettings", 605 S = qApp->translate( "NetworkSettings",
606 "<p>Error in section \"Node\" for file \"%1\" and node \"%2\"</p>" ). 606 "<p>Error in section \"Node\" for file \"%1\" and node \"%2\"</p>" ).
607 arg( SF->name() ). 607 arg( SF->name() ).
608 arg( CurDevNN->name() ); 608 arg( CurDevNN->name() );
609 return S; 609 return S;
610 } 610 }
611 611
612 if( ! SF->postNodeSection( NNI, i ) ) { 612 if( ! SF->postNodeSection( NNI, i ) ) {
613 S = qApp->translate( "NetworkSettings", 613 S = qApp->translate( "NetworkSettings",
614 "<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ). 614 "<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
615 arg( SF->name() ). 615 arg( SF->name() ).
616 arg( CurDevNN->name() ); 616 arg( CurDevNN->name() );
617 return S; 617 return S;
618 } 618 }
619 } 619 }
620 620
621 ncit2.current()->setDone( 1 ); 621 ncit2.current()->setDone( 1 );
622 622
623 } 623 }
624 } 624 }
625 625
626 if( ! SF->postDeviceSection( CurDevNN ) ) { 626 if( ! SF->postDeviceSection( CurDevNN ) ) {
627 S = qApp->translate( "NetworkSettings", 627 S = qApp->translate( "NetworkSettings",
628 "<p>Error in section \"Post-Device\" for file \"%1\" and node \"%2\"</p>" ). 628 "<p>Error in section \"Post-Device\" for file \"%1\" and node \"%2\"</p>" ).
629 arg( SF->name() ). 629 arg( SF->name() ).
630 arg( CurDevNN->name() ); 630 arg( CurDevNN->name() );
631 return S; 631 return S;
632 } 632 }
633 633
634 634
635 if( ! SF->postSection() ) { 635 if( ! SF->postSection() ) {
636 S = qApp->translate( "NetworkSettings", 636 S = qApp->translate( "NetworkSettings",
637 "<p>Error in section \"Closure\" for file \"%1\"</p>" ). 637 "<p>Error in section \"Closure\" for file \"%1\"</p>" ).
638 arg( SF->name() ); 638 arg( SF->name() );
639 return S; 639 return S;
640 } 640 }
641 641
642 // end of file 642 // end of file
643 SF->close(); 643 SF->close();
644 } 644 }
645 return S; 645 return S;
646} 646}
647 647
648QList<NodeCollection> NetworkSettingsData::collectPossible( 648QList<NetworkSetup> NetworkSettingsData::collectPossible(
649 const QString & Interface ) { 649 const QString & Interface ) {
650 // collect connections that can work on top of this interface 650 // collect NetworkSetups that can work on top of this interface
651 NodeCollection * NC; 651 NetworkSetup * NC;
652 QList<NodeCollection> PossibleConnections; 652 QList<NetworkSetup> PossibleNetworkSetups;
653 Name2Connection_t & M = NSResources->connections(); 653 Name2NetworkSetup_t & M = NSResources->networkSetups();
654 654
655 // for all connections 655 // for all NetworkSetups
656 for( QDictIterator<NodeCollection> it(M); 656 for( QDictIterator<NetworkSetup> it(M);
657 it.current(); 657 it.current();
658 ++it ) { 658 ++it ) {
659 NC = it.current(); 659 NC = it.current();
660 // check if this profile handles the requested interface 660 // check if this profile handles the requested interface
661 if( NC->handlesInterface( Interface ) && // if different Intf. 661 if( NC->handlesInterface( Interface ) && // if different Intf.
662 NC->state() != Disabled && // if enabled 662 NC->state() != Disabled && // if enabled
663 NC->state() != IsUp // if already used 663 NC->state() != IsUp // if already used
664 ) { 664 ) {
665 Log( ( "Append %s for %s\n", 665 Log( ( "Append %s for %s\n",
666 NC->name().latin1(), Interface.latin1() )); 666 NC->name().latin1(), Interface.latin1() ));
667 PossibleConnections.append( NC ); 667 PossibleNetworkSetups.append( NC );
668 } 668 }
669 } 669 }
670 return PossibleConnections; 670 return PossibleNetworkSetups;
671} 671}
672 672
673 673
674/* 674/*
675 Called by the system to see if interface can be brought UP 675 Called by the system to see if interface can be brought UP
676 676
677 if allowed, echo Interface-allowed else Interface-disallowed 677 if allowed, echo Interface-allowed else Interface-disallowed
678*/ 678*/
679 679
680bool NetworkSettingsData::canStart( const QString & Interface ) { 680bool NetworkSettingsData::canStart( const QString & Interface ) {
681 // load situation 681 // load situation
682 NodeCollection * NC = 0; 682 NetworkSetup * NC = 0;
683 QList<NodeCollection> PossibleConnections; 683 QList<NetworkSetup> PossibleNetworkSetups;
684 684
685 PossibleConnections = collectPossible( Interface ); 685 PossibleNetworkSetups = collectPossible( Interface );
686 686
687 Log( ( "for %s : Possiblilies %d\n", 687 Log( ( "for %s : Possiblilies %d\n",
688 Interface.latin1(), PossibleConnections.count() )); 688 Interface.latin1(), PossibleNetworkSetups.count() ));
689 switch( PossibleConnections.count() ) { 689 switch( PossibleNetworkSetups.count() ) {
690 case 0 : // no connections 690 case 0 : // no NetworkSetups
691 break; 691 break;
692 case 1 : // one connection 692 case 1 : // one NetworkSetup
693 NC = PossibleConnections.first(); 693 NC = PossibleNetworkSetups.first();
694 break; 694 break;
695 default : // need to ask user ? 695 default : // need to ask user ?
696 return 1; 696 return 1;
697 } 697 }
698 698
699 if( NC ) { 699 if( NC ) {
700 switch( NC->state() ) { 700 switch( NC->state() ) {
701 case Unchecked : 701 case Unchecked :
702 case Unknown : 702 case Unknown :
703 case Unavailable : 703 case Unavailable :
704 case Disabled : 704 case Disabled :
705 // this profile does not allow interface to be UP 705 // this profile does not allow interface to be UP
706 // -> try others 706 // -> try others
707 break; 707 break;
708 case Off : 708 case Off :
709 // try to UP the device 709 // try to UP the device
710 { QString S= NC->setState( Activate ); 710 { QString S= NC->setState( Activate );
711 if( ! S.isEmpty() ) { 711 if( ! S.isEmpty() ) {
712 // could not bring device Online -> try other alters 712 // could not bring device Online -> try other alters
713 Log(( "disallow %ld for %s : %s\n", 713 Log(( "disallow %ld for %s : %s\n",
714 NC->number(), Interface.latin1(), S.latin1() )); 714 NC->number(), Interface.latin1(), S.latin1() ));
715 break; 715 break;
716 } 716 }
717 // interface assigned 717 // interface assigned
718 } 718 }
719 // FT 719 // FT
720 case Available : 720 case Available :
721 case IsUp : // also called for 'ifdown' 721 case IsUp : // also called for 'ifdown'
722 // device is ready -> done 722 // device is ready -> done
723 Log(( "allow %ld for %s\n", NC->number(), Interface.latin1())); 723 Log(( "allow %ld for %s\n", NC->number(), Interface.latin1()));
724 printf( "A%ld%s\n", NC->number(), Interface.latin1() ); 724 printf( "A%ld%s\n", NC->number(), Interface.latin1() );
725 return 0; 725 return 0;
726 } 726 }
727 } 727 }
728 728
729 // if we come here no alternatives are possible 729 // if we come here no alternatives are possible
730 Log(( "disallow %s\n", Interface.latin1())); 730 Log(( "disallow %s\n", Interface.latin1()));
731 printf( "D-%s\n", Interface.latin1() ); 731 printf( "D-%s\n", Interface.latin1() );
732 return 0; 732 return 0;
733} 733}
734 734
735bool NetworkSettingsData::isModified( void ) { 735bool NetworkSettingsData::isModified( void ) {
736 if( ForceModified ) 736 if( ForceModified )
737 return 1; 737 return 1;
738 738
739 for( QDictIterator<NodeCollection> it(NSResources->connections()); 739 for( QDictIterator<NetworkSetup> it(NSResources->networkSetups());
740 it.current(); 740 it.current();
741 ++it ) { 741 ++it ) {
742 if( it.current()->isModified() ) { 742 if( it.current()->isModified() ) {
743 return 1; 743 return 1;
744 } 744 }
745 } 745 }
746 return 0; 746 return 0;
747} 747}
748 748
749bool NetworkSettingsData::couldBeTriggered( const QString & Interface ) { 749bool NetworkSettingsData::couldBeTriggered( const QString & Interface ) {
750 // load situation 750 // load situation
751 QList<NodeCollection> PossibleTriggered; 751 QList<NetworkSetup> PossibleTriggered;
752 752
753 PossibleTriggered = collectTriggered( Interface ); 753 PossibleTriggered = collectTriggered( Interface );
754 754
755 Log( ( "for %s : Possiblilies %d\n", 755 Log( ( "for %s : Possiblilies %d\n",
756 Interface.latin1(), PossibleTriggered.count() )); 756 Interface.latin1(), PossibleTriggered.count() ));
757 757
758 return ( PossibleTriggered.count() ) ? 1 : 0; 758 return ( PossibleTriggered.count() ) ? 1 : 0;
759} 759}
760 760
761QList<NodeCollection> NetworkSettingsData::collectTriggered( 761QList<NetworkSetup> NetworkSettingsData::collectTriggered(
762 const QString & Interface ) { 762 const QString & Interface ) {
763 763
764 // collect connections that could be triggered by this interface 764 // collect NetworkSetups that could be triggered by this interface
765 NodeCollection * NC; 765 NetworkSetup * NC;
766 QList<NodeCollection> PossibleTriggered; 766 QList<NetworkSetup> PossibleTriggered;
767 767
768 // for all connections 768 // for all NetworkSetups
769 Name2Connection_t & M = NSResources->connections(); 769 Name2NetworkSetup_t & M = NSResources->networkSetups();
770 770
771 for( QDictIterator<NodeCollection> it(M); 771 for( QDictIterator<NetworkSetup> it(M);
772 it.current(); 772 it.current();
773 ++it ) { 773 ++it ) {
774 NC = it.current(); 774 NC = it.current();
775 // check if this profile handles the requested interface 775 // check if this profile handles the requested interface
776 if( NC->triggeredBy( Interface ) && // if different Intf. 776 if( NC->triggeredBy( Interface ) && // if different Intf.
777 NC->state() != Disabled && // if enabled 777 NC->state() != Disabled && // if enabled
778 NC->state() != IsUp // if already used 778 NC->state() != IsUp // if already used
779 ) { 779 ) {
780 Log( ( "Append %s for %s\n", 780 Log( ( "Append %s for %s\n",
781 NC->name().latin1(), Interface.latin1() )); 781 NC->name().latin1(), Interface.latin1() ));
782 PossibleTriggered.append( NC ); 782 PossibleTriggered.append( NC );
783 } 783 }
784 } 784 }
785 return PossibleTriggered; 785 return PossibleTriggered;
786} 786}
787 787
diff --git a/noncore/settings/networksettings2/nsdata.h b/noncore/settings/networksettings2/nsdata.h
index 5791c1e..b9c216d 100644
--- a/noncore/settings/networksettings2/nsdata.h
+++ b/noncore/settings/networksettings2/nsdata.h
@@ -1,38 +1,38 @@
1#ifndef __NSDATA_H 1#ifndef __NSDATA_H
2#define __NSDATA_H 2#define __NSDATA_H
3 3
4#include <netnode.h> 4#include <netnode.h>
5 5
6class NetworkSettingsData { 6class NetworkSettingsData {
7 7
8public : 8public :
9 9
10 NetworkSettingsData( void ); 10 NetworkSettingsData( void );
11 ~NetworkSettingsData( void ); 11 ~NetworkSettingsData( void );
12 12
13 void loadSettings( void ); 13 void loadSettings( void );
14 QString saveSettings( void ); 14 QString saveSettings( void );
15 15
16 QString generateSettings( void ); 16 QString generateSettings( void );
17 17
18 bool isModified( void ); 18 bool isModified( void );
19 inline void setModified( bool M ) 19 inline void setModified( bool M )
20 { ForceModified = M; } 20 { ForceModified = M; }
21 21
22 QList<NodeCollection> collectPossible( const QString & Interface ); 22 QList<NetworkSetup> collectPossible( const QString & Interface );
23 // return TRUE if we need gui to decide 23 // return TRUE if we need gui to decide
24 bool canStart( const QString & Interface ); 24 bool canStart( const QString & Interface );
25 // return TRUE if there are vpns that could be triggered 25 // return TRUE if there are vpns that could be triggered
26 // by this interface 26 // by this interface
27 bool couldBeTriggered( const QString & Interface ); 27 bool couldBeTriggered( const QString & Interface );
28 28
29private : 29private :
30 30
31 QList<NodeCollection> collectTriggered( const QString &Interface ); 31 QList<NetworkSetup> collectTriggered( const QString &Interface );
32 bool ForceModified; 32 bool ForceModified;
33 33
34 // collect strings in config file nobody wants 34 // collect strings in config file nobody wants
35 QStringList LeftOvers; 35 QStringList LeftOvers;
36}; 36};
37 37
38#endif 38#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTDriver.cpp b/noncore/settings/networksettings2/opietooth2/OTDriver.cpp
index a7ee662..cfd0491 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDriver.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTDriver.cpp
@@ -620,125 +620,125 @@ void OTDriver::getClass( QString & service,
620 break; 620 break;
621 case 6: 621 case 6:
622 device = "83-99% utilized"; 622 device = "83-99% utilized";
623 break; 623 break;
624 case 7: 624 case 7:
625 device = "No service available"; 625 device = "No service available";
626 break; 626 break;
627 } 627 }
628 } 628 }
629 } else if( major == 6 ) { /* imaging */ 629 } else if( major == 6 ) { /* imaging */
630 if (minor & 4) 630 if (minor & 4)
631 device = "Display"; 631 device = "Display";
632 if (minor & 8) 632 if (minor & 8)
633 device = "Camera"; 633 device = "Camera";
634 if (minor & 16) 634 if (minor & 16)
635 device = "Scanner"; 635 device = "Scanner";
636 if (minor & 32) 636 if (minor & 32)
637 device = "Printer"; 637 device = "Printer";
638 } 638 }
639 } 639 }
640 break; 640 break;
641 } 641 }
642 MCM ++; 642 MCM ++;
643 } 643 }
644 644
645 if( MCM->Major == -1 ) { 645 if( MCM->Major == -1 ) {
646 device = "Unknown (reserved) minor device class"; 646 device = "Unknown (reserved) minor device class";
647 } 647 }
648} 648}
649 649
650QString OTDriver::strType() { 650QString OTDriver::strType() {
651 return QString( hci_dtypetostr(Type) ); 651 return QString( hci_dtypetostr(Type) );
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 odebug << "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 odebug << "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 }
685 685
686 if( hci_read_remote_name( fd(), 686 if( hci_read_remote_name( fd(),
687 &(PAddr.getBDAddr()), 687 &(PAddr.getBDAddr()),
688 sizeof(name), 688 sizeof(name),
689 name, 689 name,
690 100000 ) < 0 ) { 690 100000 ) < 0 ) {
691 return QString( "N/A" ); 691 return QString( "N/A" );
692 } 692 }
693 693
694 return QString( name ); 694 return QString( name );
695} 695}
696 696
697long OTDriver::getLinkQuality( const OTDeviceAddress & Addr ) { 697long OTDriver::getLinkQuality( const OTDeviceAddress & Addr ) {
698 struct hci_conn_info_req *cr; 698 struct hci_conn_info_req *cr;
699 struct hci_request rq; 699 struct hci_request rq;
700 read_rssi_rp rp; 700 read_rssi_rp rp;
701 uint16_t handle; 701 uint16_t handle;
702 702
703 if( ! open() ) { 703 if( ! open() ) {
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 odebug << "Get connection info failed" << oendl; 716 odebug << "Get NetworkSetup 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 odebug << "Get connection info failed" << oendl; 734 odebug << "Get NetworkSetup info failed" << oendl;
735 return 0; 735 return 0;
736 } 736 }
737 737
738 if( rp.status ) { 738 if( rp.status ) {
739 odebug << 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/OTDriver.h b/noncore/settings/networksettings2/opietooth2/OTDriver.h
index b54ffdf..899fab4 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDriver.h
+++ b/noncore/settings/networksettings2/opietooth2/OTDriver.h
@@ -1,217 +1,217 @@
1/*************************************************************************** 1/***************************************************************************
2 * Copyright (C) 2003 by Mattia Merzi * 2 * Copyright (C) 2003 by Mattia Merzi *
3 * ottobit@ferrara.linux.it * 3 * ottobit@ferrara.linux.it *
4 * * 4 * *
5 * This program is free software; you can redistribute it and/or modify * 5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by * 6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or * 7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. * 8 * (at your option) any later version. *
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11#ifndef OTDRIVER_H 11#ifndef OTDRIVER_H
12#define OTDRIVER_H 12#define OTDRIVER_H
13 13
14/* 14/*
15 * This class handles the connection with the BlueZ libraries, implements 15 * This class handles the networkSetup with the BlueZ libraries, implements
16 * most of the bluetooth-related functions and owns the KBTDevice class 16 * most of the bluetooth-related functions and owns the KBTDevice class
17 * that is a single local bluetooth device representation. 17 * that is a single local bluetooth device representation.
18 * It is used as a Singleton pattern thru the getDefaultConnector() method. 18 * It is used as a Singleton pattern thru the getDefaultConnector() method.
19 * 19 *
20 */ 20 */
21#include <qobject.h> 21#include <qobject.h>
22#include <opie2/odebug.h> 22#include <opie2/odebug.h>
23#include <bluezlib.h> 23#include <bluezlib.h>
24 24
25#include <OTDeviceAddress.h> 25#include <OTDeviceAddress.h>
26 26
27namespace Opietooth2 { 27namespace Opietooth2 {
28 28
29class OTGateway; 29class OTGateway;
30class OTHCISocket; 30class OTHCISocket;
31class OTDeviceAddress; 31class OTDeviceAddress;
32class OTPeer; 32class OTPeer;
33 33
34/* 34/*
35 * This is the representation of a 35 * This is the representation of a
36 * Bluetooth device for the local 36 * Bluetooth device for the local
37 * machine. 37 * machine.
38 */ 38 */
39class OTDriver : public QObject { 39class OTDriver : public QObject {
40 40
41 Q_OBJECT 41 Q_OBJECT
42 42
43public: 43public:
44 44
45 OTDriver( OTGateway * Ot, struct hci_dev_info* di); 45 OTDriver( OTGateway * Ot, struct hci_dev_info* di);
46 ~OTDriver(); 46 ~OTDriver();
47 47
48 inline OTGateway * gateway() const 48 inline OTGateway * gateway() const
49 { return OT; } 49 { return OT; }
50 50
51 /* 51 /*
52 * Initializes the device using the passed hci_dev_info 52 * Initializes the device using the passed hci_dev_info
53 * struct, contining the basic information in order to 53 * struct, contining the basic information in order to
54 * talk with the pyisical device. 54 * talk with the pyisical device.
55 */ 55 */
56 void init(struct hci_dev_info* di); 56 void init(struct hci_dev_info* di);
57 57
58 /* 58 /*
59 * Open the device and obtains a file descriptor to id 59 * Open the device and obtains a file descriptor to id
60 * return if open 60 * return if open
61 */ 61 */
62 bool open(); 62 bool open();
63 63
64 OTHCISocket * openSocket(); 64 OTHCISocket * openSocket();
65 65
66 void closeSocket(); 66 void closeSocket();
67 67
68 /* 68 /*
69 * Return true if the device is opened. 69 * Return true if the device is opened.
70 */ 70 */
71 int isOpen() 71 int isOpen()
72 { return Fd != -1; }; 72 { return Fd != -1; };
73 73
74 /* 74 /*
75 * Calls the ioctl(HCIDEVRESET) in order to 75 * Calls the ioctl(HCIDEVRESET) in order to
76 * reset the device. 76 * reset the device.
77 */ 77 */
78 int reset(); 78 int reset();
79 79
80 // set Up if true and not yet up 80 // set Up if true and not yet up
81 void setUp( bool Mode ); 81 void setUp( bool Mode );
82 82
83 /* 83 /*
84 * Turn the device up and the reinitializes the device. 84 * Turn the device up and the reinitializes the device.
85 * If the device is already up, nothing is done. 85 * If the device is already up, nothing is done.
86 */ 86 */
87 void bringUp(); 87 void bringUp();
88 88
89 /* 89 /*
90 * Turn the device down and the reinitializes the device. 90 * Turn the device down and the reinitializes the device.
91 * If the device is already down, nothing is done. 91 * If the device is already down, nothing is done.
92 */ 92 */
93 void bringDown(); 93 void bringDown();
94 94
95 // is the device UP now 95 // is the device UP now
96 bool isUp() const 96 bool isUp() const
97 { return IsUp; } 97 { return IsUp; }
98 98
99 // get current state 99 // get current state
100 // return 1 if UP, 0 if DOWN, -1 if ERROR 100 // return 1 if UP, 0 if DOWN, -1 if ERROR
101 int currentState(); 101 int currentState();
102 102
103 /* 103 /*
104 * Returns the name of the device. If the device is 104 * Returns the name of the device. If the device is
105 * down, the device id is returned. 105 * down, the device id is returned.
106 */ 106 */
107 QString name(); 107 QString name();
108 108
109 int devId() const 109 int devId() const
110 { return Dev_id; }; 110 { return Dev_id; };
111 111
112 /* 112 /*
113 * Returns the string representation of the device id, 113 * Returns the string representation of the device id,
114 * with the same format of the hciconfig tool. 114 * with the same format of the hciconfig tool.
115 */ 115 */
116 QString devname() 116 QString devname()
117 { return Dev; }; 117 { return Dev; };
118 118
119 /* 119 /*
120 * Returns the file descriptor for the local 120 * Returns the file descriptor for the local
121 * connection to this device 121 * networkSetup to this device
122 */ 122 */
123 int fd() const 123 int fd() const
124 { return Fd; }; 124 { return Fd; };
125 void setfd(int _fd) 125 void setfd(int _fd)
126 { Fd = _fd; }; 126 { Fd = _fd; };
127 127
128 void setType(int _type) 128 void setType(int _type)
129 { Type = _type; }; 129 { Type = _type; };
130 int type() const 130 int type() const
131 { return Type; }; 131 { return Type; };
132 QString strType(); 132 QString strType();
133 133
134 int iscan() const 134 int iscan() const
135 { return Iscan; } 135 { return Iscan; }
136 void setIScan(int _iscan) 136 void setIScan(int _iscan)
137 { Iscan = _iscan; } 137 { Iscan = _iscan; }
138 138
139 int pscan() const 139 int pscan() const
140 { return Pscan; } 140 { return Pscan; }
141 void setPScan(int _pscan) 141 void setPScan(int _pscan)
142 { Pscan = _pscan; } 142 { Pscan = _pscan; }
143 143
144 int authentication() const 144 int authentication() const
145 { return Auth; } 145 { return Auth; }
146 void setAuthentication(int _auth) 146 void setAuthentication(int _auth)
147 { Auth = _auth; } 147 { Auth = _auth; }
148 148
149 int encryption() const 149 int encryption() const
150 { return Encrypt; } 150 { return Encrypt; }
151 void setEncryption(int _encrypt) 151 void setEncryption(int _encrypt)
152 { Encrypt = _encrypt; } 152 { Encrypt = _encrypt; }
153 153
154 void setDevId(int _dev_id) 154 void setDevId(int _dev_id)
155 { Dev_id = _dev_id; }; 155 { Dev_id = _dev_id; };
156 void setDev(char* _dev) 156 void setDev(char* _dev)
157 { Dev = _dev; }; 157 { Dev = _dev; };
158 158
159 void setFlags( unsigned long flags); 159 void setFlags( unsigned long flags);
160 160
161 const OTDeviceAddress & address() 161 const OTDeviceAddress & address()
162 { return Address; } 162 { return Address; }
163 163
164 void setFeatures( unsigned char * _f); 164 void setFeatures( unsigned char * _f);
165 QString features() 165 QString features()
166 { return Features; } 166 { return Features; }
167 167
168 void setManufacturer(int compid); 168 void setManufacturer(int compid);
169 QString manufacturer() 169 QString manufacturer()
170 { return Manufacturer; } 170 { return Manufacturer; }
171 171
172 QString revision(); 172 QString revision();
173 173
174 void setScanMode(bool iscan, bool pscan); 174 void setScanMode(bool iscan, bool pscan);
175 void setClass(unsigned long cls); 175 void setClass(unsigned long cls);
176 176
177 void changeDevName(const char* name); 177 void changeDevName(const char* name);
178 void changeEncryption(bool _encryption); 178 void changeEncryption(bool _encryption);
179 void changeAuthentication(bool _auth); 179 void changeAuthentication(bool _auth);
180 180
181 void getClass( QString & service, 181 void getClass( QString & service,
182 QString & device ); 182 QString & device );
183 void changeClass( unsigned char service, 183 void changeClass( unsigned char service,
184 unsigned char major, 184 unsigned char major,
185 unsigned char minor); 185 unsigned char minor);
186 186
187 QString getPeerName( const OTDeviceAddress & PAddr ); 187 QString getPeerName( const OTDeviceAddress & PAddr );
188 188
189 // address must be connected to this driver 189 // address must be connected to this driver
190 long getLinkQuality( const OTDeviceAddress & Address ); 190 long getLinkQuality( const OTDeviceAddress & Address );
191 191
192signals : 192signals :
193 193
194 void error( const QString & ); 194 void error( const QString & );
195 void stateChange( OTDriver * , bool ); 195 void stateChange( OTDriver * , bool );
196 void driverDisappeared( OTDriver * ); 196 void driverDisappeared( OTDriver * );
197 197
198private slots : 198private slots :
199 199
200 /* 200 /*
201 * Reinitializes the device, obtaining a fresh 201 * Reinitializes the device, obtaining a fresh
202 * hci_dev_info structure. 202 * hci_dev_info structure.
203 */ 203 */
204 void reinit(); 204 void reinit();
205 void SLOT_CloseFd(); 205 void SLOT_CloseFd();
206 206
207private: 207private:
208 208
209 QString getRevEricsson(); 209 QString getRevEricsson();
210 QString getRevCsr(unsigned short rev); 210 QString getRevCsr(unsigned short rev);
211 211
212 QString Name; 212 QString Name;
213 QString Dev; 213 QString Dev;
214 QString Revision; 214 QString Revision;
215 QString Manufacturer; 215 QString Manufacturer;
216 OTDeviceAddress Address; 216 OTDeviceAddress Address;
217 QString Features; 217 QString Features;
diff --git a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp
index 1b61a2e..7fc8719 100644
--- a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp
@@ -1,163 +1,163 @@
1#include <qmessagebox.h> 1#include <qmessagebox.h>
2#include <qfile.h> 2#include <qfile.h>
3#include <qdir.h> 3#include <qdir.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qpixmap.h> 5#include <qpixmap.h>
6#include <qvector.h> 6#include <qvector.h>
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8 8
9#include <opie2/odebug.h> 9#include <opie2/odebug.h>
10 10
11#include <bluezlib.h> 11#include <bluezlib.h>
12 12
13#include <OTDevice.h> 13#include <OTDevice.h>
14#include <OTDriver.h> 14#include <OTDriver.h>
15#include <OTInquiry.h> 15#include <OTInquiry.h>
16#include <OTDriverList.h> 16#include <OTDriverList.h>
17#include <OTDeviceAddress.h> 17#include <OTDeviceAddress.h>
18#include <OTGateway.h> 18#include <OTGateway.h>
19 19
20using namespace Opietooth2; 20using namespace Opietooth2;
21 21
22// single instance 22// single instance
23OTGateway * OTGateway::SingleGateway = 0; 23OTGateway * OTGateway::SingleGateway = 0;
24int OTGateway::UseCount = 0; 24int OTGateway::UseCount = 0;
25 25
26OTGateway * OTGateway::getOTGateway( void ) { 26OTGateway * OTGateway::getOTGateway( void ) {
27 if(SingleGateway == 0 ) { 27 if(SingleGateway == 0 ) {
28 SingleGateway = new OTGateway(); 28 SingleGateway = new OTGateway();
29 } 29 }
30 30
31 UseCount ++; 31 UseCount ++;
32 return SingleGateway; 32 return SingleGateway;
33} 33}
34 34
35void OTGateway::releaseOTGateway( void ) { 35void OTGateway::releaseOTGateway( void ) {
36 UseCount --; 36 UseCount --;
37 if( UseCount == 0 ) { 37 if( UseCount == 0 ) {
38 delete SingleGateway; 38 delete SingleGateway;
39 SingleGateway = 0; 39 SingleGateway = 0;
40 } 40 }
41} 41}
42 42
43// open bluetooth system 43// open bluetooth system
44OTGateway::OTGateway( void ) : QObject( 0, "OTGateway" ), 44OTGateway::OTGateway( void ) : QObject( 0, "OTGateway" ),
45 AllDrivers( this ), 45 AllDrivers( this ),
46 AllPeers() { 46 AllPeers() {
47 47
48 ErrorConnectCount = 0; 48 ErrorConnectCount = 0;
49 TheOTDevice = 0; 49 TheOTDevice = 0;
50 Scanning = 0; 50 Scanning = 0;
51 AllPeersModified = 0; 51 AllPeersModified = 0;
52 AllPeers.setAutoDelete( TRUE ); 52 AllPeers.setAutoDelete( TRUE );
53 53
54 if ( ( HciCtl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) { 54 if ( ( HciCtl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) {
55 SLOT_ShowError( tr( "error opening hci socket" ) ); 55 SLOT_ShowError( tr( "error opening hci socket" ) );
56 return; 56 return;
57 } 57 }
58 58
59 // load all known devices 59 // load all known devices
60 updateDrivers(); 60 updateDrivers();
61 61
62 // load all peers we have ever seen 62 // load all peers we have ever seen
63 loadKnownPeers(); 63 loadKnownPeers();
64 64
65 // iterate over drivers and find active connections 65 // iterate over drivers and find active NetworkSetups
66 // adding/updating peers 66 // adding/updating peers
67 loadActiveConnections(); 67 loadActiveNetworkSetups();
68 68
69 // check every 4 seconds the state of BT 69 // check every 4 seconds the state of BT
70 timerEvent(0); 70 timerEvent(0);
71 RefreshTimer = -1; 71 RefreshTimer = -1;
72 setRefreshTimer( 4000 ); 72 setRefreshTimer( 4000 );
73 73
74 // load known link keys 74 // load known link keys
75 readLinkKeys(); 75 readLinkKeys();
76} 76}
77 77
78// close bluetooth system 78// close bluetooth system
79OTGateway::~OTGateway( void ) { 79OTGateway::~OTGateway( void ) {
80 80
81 if( AllPeersModified ) { 81 if( AllPeersModified ) {
82 saveKnownPeers(); 82 saveKnownPeers();
83 } 83 }
84 84
85 if( Scanning ) 85 if( Scanning )
86 delete Scanning; 86 delete Scanning;
87 87
88 if( TheOTDevice ) 88 if( TheOTDevice )
89 delete TheOTDevice; 89 delete TheOTDevice;
90 90
91 if( HciCtl >= 0 ) { 91 if( HciCtl >= 0 ) {
92 ::close( HciCtl ); 92 ::close( HciCtl );
93 } 93 }
94} 94}
95 95
96void OTGateway::setRefreshTimer( int T ) { 96void OTGateway::setRefreshTimer( int T ) {
97 if( RefreshTimer != -1 ) { 97 if( RefreshTimer != -1 ) {
98 killTimer( RefreshTimer ); 98 killTimer( RefreshTimer );
99 } 99 }
100 100
101 if( T == 0 ) 101 if( T == 0 )
102 T = 4000; 102 T = 4000;
103 RefreshTimer = startTimer( T ); 103 RefreshTimer = startTimer( T );
104} 104}
105 105
106OTDevice * OTGateway::getOTDevice( ) { 106OTDevice * OTGateway::getOTDevice( ) {
107 if( TheOTDevice == 0 ) { 107 if( TheOTDevice == 0 ) {
108 // load bluetooth device and check state 108 // load bluetooth device and check state
109 TheOTDevice = new OTDevice( this ); 109 TheOTDevice = new OTDevice( this );
110 connect( TheOTDevice, 110 connect( TheOTDevice,
111 SIGNAL( isEnabled( int, bool ) ), 111 SIGNAL( isEnabled( int, bool ) ),
112 this, 112 this,
113 SLOT( SLOT_Enabled( int, bool ) ) ); 113 SLOT( SLOT_Enabled( int, bool ) ) );
114 114
115 connect( TheOTDevice, 115 connect( TheOTDevice,
116 SIGNAL( error( const QString & ) ), 116 SIGNAL( error( const QString & ) ),
117 this, 117 this,
118 SLOT( SLOT_ShowError( const QString & ) ) ); 118 SLOT( SLOT_ShowError( const QString & ) ) );
119 } 119 }
120 120
121 return TheOTDevice; 121 return TheOTDevice;
122} 122}
123 123
124// start bluetooth (if stopped) 124// start bluetooth (if stopped)
125// return TRUE if started 125// return TRUE if started
126void OTGateway::SLOT_SetEnabled( bool Mode ) { 126void OTGateway::SLOT_SetEnabled( bool Mode ) {
127 if( Mode ) { 127 if( Mode ) {
128 SLOT_Enable(); 128 SLOT_Enable();
129 return; 129 return;
130 } 130 }
131 SLOT_Disable(); 131 SLOT_Disable();
132} 132}
133 133
134void OTGateway::SLOT_Enable() { 134void OTGateway::SLOT_Enable() {
135 getOTDevice()->attach(); 135 getOTDevice()->attach();
136} 136}
137 137
138void OTGateway::SLOT_Disable() { 138void OTGateway::SLOT_Disable() {
139 getOTDevice()->detach(); 139 getOTDevice()->detach();
140} 140}
141 141
142bool OTGateway::needsEnabling() { 142bool OTGateway::needsEnabling() {
143 return getOTDevice()->needsAttach(); 143 return getOTDevice()->needsAttach();
144} 144}
145 145
146bool OTGateway::isEnabled() { 146bool OTGateway::isEnabled() {
147 if( getOTDevice()->deviceNr() >= 0 && 147 if( getOTDevice()->deviceNr() >= 0 &&
148 AllDrivers.count() != 0 && 148 AllDrivers.count() != 0 &&
149 driver( getOTDevice()->deviceNr() )->isUp() ) 149 driver( getOTDevice()->deviceNr() )->isUp() )
150 return TRUE; 150 return TRUE;
151 151
152 // else check system 152 // else check system
153 return getOTDevice()->isAttached(); 153 return getOTDevice()->isAttached();
154} 154}
155 155
156void OTGateway::SLOT_ShowError( const QString & S ) { 156void OTGateway::SLOT_ShowError( const QString & S ) {
157 157
158 odebug << S << oendl; 158 odebug << S << oendl;
159 159
160 if( ErrorConnectCount > 0 ) { 160 if( ErrorConnectCount > 0 ) {
161 // pass error 161 // pass error
162 emit error( QString( "<p>" ) + S + "</p>" ); 162 emit error( QString( "<p>" ) + S + "</p>" );
163 return; 163 return;
@@ -282,356 +282,356 @@ void OTGateway::scanNeighbourhood( OTDriver * D ) {
282 282
283 Scanning = new OTInquiry( scanWith() ); 283 Scanning = new OTInquiry( scanWith() );
284 284
285 connect( Scanning, 285 connect( Scanning,
286 SIGNAL( peerFound( OTPeer *, bool )), 286 SIGNAL( peerFound( OTPeer *, bool )),
287 this, 287 this,
288 SLOT( SLOT_PeerDetected( OTPeer *, bool ) ) 288 SLOT( SLOT_PeerDetected( OTPeer *, bool ) )
289 ); 289 );
290 connect( Scanning, 290 connect( Scanning,
291 SIGNAL( finished()), 291 SIGNAL( finished()),
292 this, 292 this,
293 SLOT( SLOT_FinishedDetecting() ) 293 SLOT( SLOT_FinishedDetecting() )
294 ); 294 );
295 295
296 // start scanning 296 // start scanning
297 Scanning->inquire( 30.0 ); 297 Scanning->inquire( 30.0 );
298} 298}
299 299
300OTPeer* OTGateway::findPeer( const OTDeviceAddress & Addr ) { 300OTPeer* OTGateway::findPeer( const OTDeviceAddress & Addr ) {
301 for( unsigned int i = 0 ; i < AllPeers.count(); i ++ ) { 301 for( unsigned int i = 0 ; i < AllPeers.count(); i ++ ) {
302 if( AllPeers[i]->address() == Addr ) { 302 if( AllPeers[i]->address() == Addr ) {
303 return AllPeers[i]; 303 return AllPeers[i];
304 } 304 }
305 } 305 }
306 return 0; 306 return 0;
307} 307}
308 308
309OTDriver* OTGateway::findDriver( const OTDeviceAddress & Addr ) { 309OTDriver* OTGateway::findDriver( const OTDeviceAddress & Addr ) {
310 for( unsigned int i = 0 ; i < AllDrivers.count(); i ++ ) { 310 for( unsigned int i = 0 ; i < AllDrivers.count(); i ++ ) {
311 if( AllDrivers[i]->address() == Addr ) { 311 if( AllDrivers[i]->address() == Addr ) {
312 return AllDrivers[i]; 312 return AllDrivers[i];
313 } 313 }
314 } 314 }
315 return 0; 315 return 0;
316} 316}
317 317
318void OTGateway::SLOT_PeerDetected( OTPeer * P, bool IsNew ) { 318void OTGateway::SLOT_PeerDetected( OTPeer * P, bool IsNew ) {
319 319
320 if( IsNew ) { 320 if( IsNew ) {
321 // new peer 321 // new peer
322 odebug << "New peer " << P->name() << oendl; 322 odebug << "New peer " << P->name() << oendl;
323 addPeer( P ); 323 addPeer( P );
324 } 324 }
325 325
326 emit detectedPeer( P, IsNew ); 326 emit detectedPeer( P, IsNew );
327} 327}
328 328
329void OTGateway::addPeer( OTPeer * P ) { 329void OTGateway::addPeer( OTPeer * P ) {
330 AllPeers.resize( AllPeers.size()+1); 330 AllPeers.resize( AllPeers.size()+1);
331 AllPeers.insert( AllPeers.size()-1, P ); 331 AllPeers.insert( AllPeers.size()-1, P );
332 AllPeersModified = 1; 332 AllPeersModified = 1;
333} 333}
334 334
335void OTGateway::removePeer( OTPeer * P ) { 335void OTGateway::removePeer( OTPeer * P ) {
336 int i = AllPeers.find( P ); 336 int i = AllPeers.find( P );
337 if( i ) { 337 if( i ) {
338 AllPeers.remove( i ); 338 AllPeers.remove( i );
339 AllPeersModified = 1; 339 AllPeersModified = 1;
340 } 340 }
341} 341}
342 342
343void OTGateway::stopScanOfNeighbourhood( void ) { 343void OTGateway::stopScanOfNeighbourhood( void ) {
344 if( Scanning ) { 344 if( Scanning ) {
345 delete Scanning; 345 delete Scanning;
346 Scanning = 0; 346 Scanning = 0;
347 } 347 }
348} 348}
349 349
350void OTGateway::SLOT_FinishedDetecting() { 350void OTGateway::SLOT_FinishedDetecting() {
351 stopScanOfNeighbourhood(); 351 stopScanOfNeighbourhood();
352 emit finishedDetecting(); 352 emit finishedDetecting();
353} 353}
354 354
355const char * OTGateway::deviceTypeToName( int cls ) { 355const char * OTGateway::deviceTypeToName( int cls ) {
356 switch ( (cls & 0x001F00) >> 8) { 356 switch ( (cls & 0x001F00) >> 8) {
357 case 0x00: 357 case 0x00:
358 return "misc"; 358 return "misc";
359 case 0x01: 359 case 0x01:
360 return "computer"; 360 return "computer";
361 case 0x02: 361 case 0x02:
362 return "phone"; 362 return "phone";
363 case 0x03: 363 case 0x03:
364 return "lan"; 364 return "lan";
365 case 0x04: 365 case 0x04:
366 return "av"; 366 return "av";
367 case 0x05: 367 case 0x05:
368 return "peripheral"; 368 return "peripheral";
369 case 0x06: 369 case 0x06:
370 return "imaging"; 370 return "imaging";
371 case 0x07: 371 case 0x07:
372 default : 372 default :
373 break; 373 break;
374 } 374 }
375 return "unknown"; 375 return "unknown";
376} 376}
377 377
378PANConnectionVector OTGateway::getPANConnections( void ) { 378PANNetworkSetupVector OTGateway::getPANNetworkSetups( void ) {
379 PANConnectionVector V; 379 PANNetworkSetupVector V;
380 380
381 struct bnep_connlist_req req; 381 struct bnep_connlist_req req;
382 struct bnep_conninfo ci[48]; 382 struct bnep_conninfo ci[48];
383 383
384 V.setAutoDelete(TRUE); 384 V.setAutoDelete(TRUE);
385 385
386 int ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP); 386 int ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP);
387 if (ctl < 0) { 387 if (ctl < 0) {
388 odebug << "Failed to open control socket" << oendl; 388 odebug << "Failed to open control socket" << oendl;
389 return V; 389 return V;
390 } 390 }
391 391
392 req.cnum = 48; 392 req.cnum = 48;
393 req.ci = ci; 393 req.ci = ci;
394 if (ioctl(ctl, BNEPGETCONNLIST, &req)) { 394 if (ioctl(ctl, BNEPGETCONNLIST, &req)) {
395 odebug << "Failed to get connection list" << oendl; 395 odebug << "Failed to get NetworkSetup list" << oendl;
396 ::close( ctl ); 396 ::close( ctl );
397 return V; 397 return V;
398 } 398 }
399 399
400 for ( unsigned i=0; i < req.cnum; i++) { 400 for ( unsigned i=0; i < req.cnum; i++) {
401 V.resize( V.size() + 1 ); 401 V.resize( V.size() + 1 );
402 if( ci[i].role == BNEP_SVC_PANU ) { 402 if( ci[i].role == BNEP_SVC_PANU ) {
403 // we are the client 403 // we are the client
404 V.insert( V.size()-1, new OTPANConnection( 404 V.insert( V.size()-1, new OTPANNetworkSetup(
405 ci[i].device, 405 ci[i].device,
406 batostr((bdaddr_t *) ci[i].dst) 406 batostr((bdaddr_t *) ci[i].dst)
407 ) ); 407 ) );
408 } 408 }
409 } 409 }
410 410
411 ::close( ctl ); 411 ::close( ctl );
412 return V; 412 return V;
413} 413}
414 414
415struct link_key { 415struct link_key {
416 bdaddr_t sba; 416 bdaddr_t sba;
417 bdaddr_t dba; 417 bdaddr_t dba;
418 uint8_t key[16]; 418 uint8_t key[16];
419 uint8_t type; 419 uint8_t type;
420 time_t time; 420 time_t time;
421}; 421};
422 422
423void OTGateway::readLinkKeys( void ) { 423void OTGateway::readLinkKeys( void ) {
424 424
425 struct link_key k; 425 struct link_key k;
426 int rv; 426 int rv;
427 427
428 AllKeys.truncate(0); 428 AllKeys.truncate(0);
429 429
430 QFile F( "/etc/bluetooth/link_key" ); 430 QFile F( "/etc/bluetooth/link_key" );
431 431
432 if( ! F.open( IO_ReadOnly ) ) { 432 if( ! F.open( IO_ReadOnly ) ) {
433 emit error( tr("Cannot open link_key file") ); 433 emit error( tr("Cannot open link_key file") );
434 return; 434 return;
435 } 435 }
436 436
437 while( 1 ) { 437 while( 1 ) {
438 rv = F.readBlock( (char *)&k, sizeof( k ) ); 438 rv = F.readBlock( (char *)&k, sizeof( k ) );
439 if( rv == 0 ) 439 if( rv == 0 )
440 // EOF 440 // EOF
441 break; 441 break;
442 442
443 if( rv < 0 ) { 443 if( rv < 0 ) {
444 emit error( tr("Read error in link key file") ); 444 emit error( tr("Read error in link key file") );
445 } 445 }
446 446
447 AllKeys.resize( AllKeys.size()+1 ); 447 AllKeys.resize( AllKeys.size()+1 );
448 AllKeys[ AllKeys.size()-1 ].From.setBDAddr( k.sba ); 448 AllKeys[ AllKeys.size()-1 ].From.setBDAddr( k.sba );
449 AllKeys[ AllKeys.size()-1 ].To.setBDAddr( k.dba ); 449 AllKeys[ AllKeys.size()-1 ].To.setBDAddr( k.dba );
450 } 450 }
451} 451}
452 452
453bool OTGateway::removeLinkKey( unsigned int Index ) { 453bool OTGateway::removeLinkKey( unsigned int Index ) {
454 OTLinkKey & LK = AllKeys[Index]; 454 OTLinkKey & LK = AllKeys[Index];
455 455
456 struct link_key k; 456 struct link_key k;
457 int rv; 457 int rv;
458 458
459 QFile F( "/etc/bluetooth/link_key" ); 459 QFile F( "/etc/bluetooth/link_key" );
460 QFile OutF( "/etc/bluetooth/newlink_key" ); 460 QFile OutF( "/etc/bluetooth/newlink_key" );
461 461
462 if( ! F.open( IO_ReadOnly ) ) { 462 if( ! F.open( IO_ReadOnly ) ) {
463 emit error( tr("Cannot open link_key file") ); 463 emit error( tr("Cannot open link_key file") );
464 return 0; 464 return 0;
465 } 465 }
466 466
467 if( ! OutF.open( IO_WriteOnly | IO_Truncate ) ) { 467 if( ! OutF.open( IO_WriteOnly | IO_Truncate ) ) {
468 emit error( tr("Cannot open temporary link_key file") ); 468 emit error( tr("Cannot open temporary link_key file") );
469 return 0; 469 return 0;
470 } 470 }
471 471
472 while( 1 ) { 472 while( 1 ) {
473 rv = F.readBlock( (char *)&k, sizeof( k ) ); 473 rv = F.readBlock( (char *)&k, sizeof( k ) );
474 if( rv == 0 ) 474 if( rv == 0 )
475 // EOF 475 // EOF
476 break; 476 break;
477 477
478 if( rv < 0 ) { 478 if( rv < 0 ) {
479 emit error( tr("Read error in link key file") ); 479 emit error( tr("Read error in link key file") );
480 return 0; 480 return 0;
481 } 481 }
482 482
483 if( LK.from() != OTDeviceAddress( k.sba ) || 483 if( LK.from() != OTDeviceAddress( k.sba ) ||
484 LK.to() != OTDeviceAddress( k.dba ) ) { 484 LK.to() != OTDeviceAddress( k.dba ) ) {
485 // copy 485 // copy
486 OutF.writeBlock( (char *)&k, sizeof( k ) ); 486 OutF.writeBlock( (char *)&k, sizeof( k ) );
487 } // else remove this key 487 } // else remove this key
488 } 488 }
489 489
490 // rename files 490 // rename files
491 QDir D( "/etc/bluetooth" ); 491 QDir D( "/etc/bluetooth" );
492 492
493 D.remove( "link_key" ); 493 D.remove( "link_key" );
494 D.rename( "newlink_key", "link_key" ); 494 D.rename( "newlink_key", "link_key" );
495 495
496 // restart hcid 496 // restart hcid
497 system( "/etc/init.d/hcid stop" ); 497 system( "/etc/init.d/hcid stop" );
498 system( "/etc/init.d/hcid start" ); 498 system( "/etc/init.d/hcid start" );
499 499
500 // remove from table 500 // remove from table
501 if( Index < (AllKeys.size()-1) ) { 501 if( Index < (AllKeys.size()-1) ) {
502 // collapse array 502 // collapse array
503 AllKeys[Index] = AllKeys[AllKeys.size()-1]; 503 AllKeys[Index] = AllKeys[AllKeys.size()-1];
504 } 504 }
505 505
506 // remove last element 506 // remove last element
507 AllKeys.resize( AllKeys.size()-1 ); 507 AllKeys.resize( AllKeys.size()-1 );
508 508
509 return 1; 509 return 1;
510} 510}
511 511
512#define MAXCONNECTIONS 10 512#define MAXCONNECTIONS 10
513void OTGateway::loadActiveConnections( void ) { 513void OTGateway::loadActiveNetworkSetups( void ) {
514 514
515 struct hci_conn_list_req *cl; 515 struct hci_conn_list_req *cl;
516 struct hci_conn_info *ci; 516 struct hci_conn_info *ci;
517 OTDeviceAddress Addr; 517 OTDeviceAddress Addr;
518 OTPeer * P; 518 OTPeer * P;
519 519
520 if (!(cl = (struct hci_conn_list_req *)malloc( 520 if (!(cl = (struct hci_conn_list_req *)malloc(
521 MAXCONNECTIONS * sizeof(*ci) + sizeof(*cl)))) { 521 MAXCONNECTIONS * sizeof(*ci) + sizeof(*cl)))) {
522 emit error( tr("Can't allocate memory") ); 522 emit error( tr("Can't allocate memory") );
523 return; 523 return;
524 } 524 }
525 memset( cl, 0, MAXCONNECTIONS * sizeof(*ci) + sizeof(*cl) ); 525 memset( cl, 0, MAXCONNECTIONS * sizeof(*ci) + sizeof(*cl) );
526 526
527 for( unsigned int i = 0; 527 for( unsigned int i = 0;
528 i < AllDrivers.count(); 528 i < AllDrivers.count();
529 i ++ ) { 529 i ++ ) {
530 530
531 if( ! AllDrivers[i]->isUp() ) { 531 if( ! AllDrivers[i]->isUp() ) {
532 continue; 532 continue;
533 } 533 }
534 534
535 // driver is up -> check connections 535 // driver is up -> check NetworkSetups
536 cl->dev_id = AllDrivers[i]->devId(); 536 cl->dev_id = AllDrivers[i]->devId();
537 cl->conn_num = MAXCONNECTIONS; 537 cl->conn_num = MAXCONNECTIONS;
538 ci = cl->conn_info; 538 ci = cl->conn_info;
539 539
540 if (ioctl( getSocket(), HCIGETCONNLIST, (void *) cl)) { 540 if (ioctl( getSocket(), HCIGETCONNLIST, (void *) cl)) {
541 emit error( tr("Can't get connection list") ); 541 emit error( tr("Can't get NetworkSetup list") );
542 break; 542 break;
543 } 543 }
544 544
545 for ( int k = 0; k < cl->conn_num; k++, ci++) { 545 for ( int k = 0; k < cl->conn_num; k++, ci++) {
546 546
547 if( ci->state != BT_CONNECTED ) { 547 if( ci->state != BT_CONNECTED ) {
548 // not yet connected 548 // not yet connected
549 continue; 549 continue;
550 } 550 }
551 551
552 Addr.setBDAddr( ci->bdaddr ); 552 Addr.setBDAddr( ci->bdaddr );
553 P = findPeer( Addr ); 553 P = findPeer( Addr );
554 if( ! P ) { 554 if( ! P ) {
555 // peer not yet known -> add 555 // peer not yet known -> add
556 P = new OTPeer( this ); 556 P = new OTPeer( this );
557 addPeer( P ); 557 addPeer( P );
558 P->setAddress( Addr ); 558 P->setAddress( Addr );
559 // infoQueue.push_back(info); 559 // infoQueue.push_back(info);
560 P->setName( AllDrivers[i]->getPeerName( Addr ) ); 560 P->setName( AllDrivers[i]->getPeerName( Addr ) );
561 } 561 }
562 P->setState( OTPeer::Peer_Up ); 562 P->setState( OTPeer::Peer_Up );
563 P->setConnectedTo( AllDrivers[i] ); 563 P->setConnectedTo( AllDrivers[i] );
564 } 564 }
565 } 565 }
566 566
567 free( cl ); 567 free( cl );
568} 568}
569 569
570void OTGateway::loadKnownPeers( void ) { 570void OTGateway::loadKnownPeers( void ) {
571 QDir SaveDir = QDir::home(); 571 QDir SaveDir = QDir::home();
572 572
573 if( ! SaveDir.exists( "Settings" ) ) { 573 if( ! SaveDir.exists( "Settings" ) ) {
574 return; 574 return;
575 } 575 }
576 SaveDir.cd( "Settings" ); 576 SaveDir.cd( "Settings" );
577 577
578 if( ! SaveDir.exists( "opietooth" ) ) { 578 if( ! SaveDir.exists( "opietooth" ) ) {
579 return; 579 return;
580 } 580 }
581 SaveDir.cd( "opietooth" ); 581 SaveDir.cd( "opietooth" );
582 582
583 QFile F( SaveDir.path() + "/SeenDevices.conf" ); 583 QFile F( SaveDir.path() + "/SeenDevices.conf" );
584 584
585 if( F.open( IO_ReadOnly ) ) { 585 if( F.open( IO_ReadOnly ) ) {
586 QTextStream TS(&F); 586 QTextStream TS(&F);
587 long count; 587 long count;
588 588
589 count = TS.readLine().toLong(); 589 count = TS.readLine().toLong();
590 590
591 while( count > 0 ) { 591 while( count > 0 ) {
592 addPeer( new OTPeer( TS, this ) ); 592 addPeer( new OTPeer( TS, this ) );
593 count --; 593 count --;
594 } 594 }
595 } 595 }
596 596
597 AllPeersModified = 0; 597 AllPeersModified = 0;
598} 598}
599 599
600void OTGateway::saveKnownPeers( void ) { 600void OTGateway::saveKnownPeers( void ) {
601 QDir SaveDir = QDir::home(); 601 QDir SaveDir = QDir::home();
602 602
603 if( ! SaveDir.exists( "Settings" ) ) { 603 if( ! SaveDir.exists( "Settings" ) ) {
604 SaveDir.mkdir( "Settings" ); 604 SaveDir.mkdir( "Settings" );
605 } 605 }
606 SaveDir.cd( "Settings" ); 606 SaveDir.cd( "Settings" );
607 607
608 if( ! SaveDir.exists( "opietooth" ) ) { 608 if( ! SaveDir.exists( "opietooth" ) ) {
609 SaveDir.mkdir( "opietooth" ); 609 SaveDir.mkdir( "opietooth" );
610 } 610 }
611 SaveDir.cd( "opietooth" ); 611 SaveDir.cd( "opietooth" );
612 612
613 QFile F( SaveDir.path() + "/SeenDevices.conf" ); 613 QFile F( SaveDir.path() + "/SeenDevices.conf" );
614 614
615 if( F.open( IO_WriteOnly | IO_Truncate ) ) { 615 if( F.open( IO_WriteOnly | IO_Truncate ) ) {
616 QTextStream TS(&F); 616 QTextStream TS(&F);
617 QString S; 617 QString S;
618 618
619 TS << AllPeers.count() << endl; 619 TS << AllPeers.count() << endl;
620 620
621 for( unsigned int i = 0; 621 for( unsigned int i = 0;
622 i < AllPeers.count(); 622 i < AllPeers.count();
623 i ++ ) { 623 i ++ ) {
624 AllPeers[i]->save( TS ); 624 AllPeers[i]->save( TS );
625 } 625 }
626 AllPeersModified = 0; 626 AllPeersModified = 0;
627 } 627 }
628 AllPeersModified = 0; 628 AllPeersModified = 0;
629} 629}
630 630
631int OTGateway::connectedToRFCommChannel( const OTDeviceAddress & Addr, 631int OTGateway::connectedToRFCommChannel( const OTDeviceAddress & Addr,
632 int channel ) { 632 int channel ) {
633 633
634 int s; 634 int s;
635 635
636 if( (s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_RFCOMM)) < 0 ) { 636 if( (s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_RFCOMM)) < 0 ) {
637 emit error( tr("Can't open RFCOMM control socket") ); 637 emit error( tr("Can't open RFCOMM control socket") );
@@ -660,115 +660,115 @@ int OTGateway::connectedToRFCommChannel( const OTDeviceAddress & Addr,
660 // connected to Peer 660 // connected to Peer
661 if( Addr == OTDeviceAddress( dr->dst ) && 661 if( Addr == OTDeviceAddress( dr->dst ) &&
662 channel == dr->channel && 662 channel == dr->channel &&
663 ( dr->state != 0 ) 663 ( dr->state != 0 )
664 ) { 664 ) {
665 // return device ID 665 // return device ID
666 return dr->id; 666 return dr->id;
667 } 667 }
668 } 668 }
669 } 669 }
670 670
671 // no device 671 // no device
672 return -1; 672 return -1;
673} 673}
674 674
675static int byID( struct rfcomm_dev_info * d1, 675static int byID( struct rfcomm_dev_info * d1,
676 struct rfcomm_dev_info * d2 ) { 676 struct rfcomm_dev_info * d2 ) {
677 return d1->id - d2->id; 677 return d1->id - d2->id;
678} 678}
679 679
680int OTGateway::getFreeRFCommDevice( void ) { 680int OTGateway::getFreeRFCommDevice( void ) {
681 681
682 int s; 682 int s;
683 683
684 if( (s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_RFCOMM)) < 0 ) { 684 if( (s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_RFCOMM)) < 0 ) {
685 emit error( tr("Can't open RFCOMM control socket") ); 685 emit error( tr("Can't open RFCOMM control socket") );
686 return 0; 686 return 0;
687 } 687 }
688 688
689 // get all rfcomm devices 689 // get all rfcomm devices
690 { struct rfcomm_dev_list_req *dl; 690 { struct rfcomm_dev_list_req *dl;
691 struct rfcomm_dev_info *di, *dr; 691 struct rfcomm_dev_info *di, *dr;
692 int i; 692 int i;
693 693
694 dl = (struct rfcomm_dev_list_req *)alloca( 694 dl = (struct rfcomm_dev_list_req *)alloca(
695 sizeof(*dl) + RFCOMM_MAX_DEV * sizeof(*di)); 695 sizeof(*dl) + RFCOMM_MAX_DEV * sizeof(*di));
696 696
697 dl->dev_num = RFCOMM_MAX_DEV; 697 dl->dev_num = RFCOMM_MAX_DEV;
698 di = dl->dev_info; 698 di = dl->dev_info;
699 699
700 if( ::ioctl(s, RFCOMMGETDEVLIST, (void *) dl) < 0) { 700 if( ::ioctl(s, RFCOMMGETDEVLIST, (void *) dl) < 0) {
701 emit error( tr("Can't get device list") ); 701 emit error( tr("Can't get device list") );
702 ::close( s ); 702 ::close( s );
703 return 0; 703 return 0;
704 } 704 }
705 705
706 // s 706 // s
707 if( dl->dev_num ) { 707 if( dl->dev_num ) {
708 qsort( di, sizeof(struct rfcomm_dev_info), 708 qsort( di, sizeof(struct rfcomm_dev_info),
709 dl->dev_num, (int(*)(const void*,const void*))byID ); 709 dl->dev_num, (int(*)(const void*,const void*))byID );
710 int id = 0; 710 int id = 0;
711 711
712 dr = di; 712 dr = di;
713 // find lowest free device number 713 // find lowest free device number
714 for (i = 0; i < dl->dev_num; i++, dr++) { 714 for (i = 0; i < dl->dev_num; i++, dr++) {
715 if( id != dr->id ) { 715 if( id != dr->id ) {
716 return id; 716 return id;
717 } 717 }
718 id ++; 718 id ++;
719 } 719 }
720 return id; 720 return id;
721 } else { 721 } else {
722 return 0; 722 return 0;
723 } 723 }
724 } 724 }
725} 725}
726 726
727int OTGateway::releaseRFCommDevice( int devnr ) { 727int OTGateway::releaseRFCommDevice( int devnr ) {
728 728
729 int s; 729 int s;
730 730
731 if( (s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_RFCOMM)) < 0 ) { 731 if( (s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_RFCOMM)) < 0 ) {
732 emit error( tr("Can't open RFCOMM control socket") ); 732 emit error( tr("Can't open RFCOMM control socket") );
733 return 0; 733 return 0;
734 } 734 }
735 735
736 // get all rfcomm devices 736 // get all rfcomm devices
737 { struct rfcomm_dev_list_req *dl; 737 { struct rfcomm_dev_list_req *dl;
738 struct rfcomm_dev_info *di, *dr; 738 struct rfcomm_dev_info *di, *dr;
739 int i; 739 int i;
740 740
741 dl = (struct rfcomm_dev_list_req *)alloca( 741 dl = (struct rfcomm_dev_list_req *)alloca(
742 sizeof(*dl) + RFCOMM_MAX_DEV * sizeof(*di)); 742 sizeof(*dl) + RFCOMM_MAX_DEV * sizeof(*di));
743 memset( dl, 0, sizeof(*dl) + RFCOMM_MAX_DEV * sizeof(*di) ); 743 memset( dl, 0, sizeof(*dl) + RFCOMM_MAX_DEV * sizeof(*di) );
744 dl->dev_num = RFCOMM_MAX_DEV; 744 dl->dev_num = RFCOMM_MAX_DEV;
745 di = dl->dev_info; 745 di = dl->dev_info;
746 746
747 if( ::ioctl(s, RFCOMMGETDEVLIST, (void *) dl) < 0) { 747 if( ::ioctl(s, RFCOMMGETDEVLIST, (void *) dl) < 0) {
748 emit error( tr("Can't get device list") ); 748 emit error( tr("Can't get device list") );
749 ::close( s ); 749 ::close( s );
750 return 0; 750 return 0;
751 } 751 }
752 752
753 dr = di; 753 dr = di;
754 for (i = 0; i < dl->dev_num; i++, dr++) { 754 for (i = 0; i < dl->dev_num; i++, dr++) {
755 if( dr->id == devnr ) { 755 if( dr->id == devnr ) {
756 // still in connection list 756 // still in NetworkSetup list
757 struct rfcomm_dev_req req; 757 struct rfcomm_dev_req req;
758 int err; 758 int err;
759 759
760 memset(&req, 0, sizeof(req)); 760 memset(&req, 0, sizeof(req));
761 req.dev_id = devnr; 761 req.dev_id = devnr;
762 762
763 if ((err = ioctl(s, RFCOMMRELEASEDEV, &req)) < 0 ) { 763 if ((err = ioctl(s, RFCOMMRELEASEDEV, &req)) < 0 ) {
764 return err; 764 return err;
765 } 765 }
766 return 0; 766 return 0;
767 } 767 }
768 } 768 }
769 } 769 }
770 770
771 // no device -> nothing to release eiterh 771 // no device -> nothing to release eiterh
772 return 0; 772 return 0;
773} 773}
774 774
diff --git a/noncore/settings/networksettings2/opietooth2/OTGateway.h b/noncore/settings/networksettings2/opietooth2/OTGateway.h
index 11c6b30..d0e42db 100644
--- a/noncore/settings/networksettings2/opietooth2/OTGateway.h
+++ b/noncore/settings/networksettings2/opietooth2/OTGateway.h
@@ -1,200 +1,200 @@
1#ifndef OTGATEWAY_H 1#ifndef OTGATEWAY_H
2#define OTGATEWAY_H 2#define OTGATEWAY_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include <qvector.h> 5#include <qvector.h>
6#include <qmap.h> 6#include <qmap.h>
7 7
8#include <OTDriverList.h> 8#include <OTDriverList.h>
9#include <OTInquiry.h> 9#include <OTInquiry.h>
10 10
11class QPixmap; 11class QPixmap;
12 12
13namespace Opietooth2 { 13namespace Opietooth2 {
14 14
15class OTDriverList; 15class OTDriverList;
16class OTDriver; 16class OTDriver;
17class OTDevice; 17class OTDevice;
18class OTPeer; 18class OTPeer;
19class OTInquiry; 19class OTInquiry;
20class OTPANConnection; 20class OTPANNetworkSetup;
21class OTLinkKey; 21class OTLinkKey;
22 22
23typedef QVector<OTPeer> PeerVector; 23typedef QVector<OTPeer> PeerVector;
24typedef QVector<OTPANConnection> PANConnectionVector; 24typedef QVector<OTPANNetworkSetup> PANNetworkSetupVector;
25typedef QArray<OTLinkKey> LinkKeyArray; 25typedef QArray<OTLinkKey> LinkKeyArray;
26 26
27class OTLinkKey { 27class OTLinkKey {
28 28
29public : 29public :
30 30
31 OTLinkKey( const OTDeviceAddress & F, 31 OTLinkKey( const OTDeviceAddress & F,
32 const OTDeviceAddress & T ) { 32 const OTDeviceAddress & T ) {
33 From = F; 33 From = F;
34 To = T; 34 To = T;
35 } 35 }
36 36
37 const OTDeviceAddress & to() 37 const OTDeviceAddress & to()
38 { return To; } 38 { return To; }
39 const OTDeviceAddress & from() 39 const OTDeviceAddress & from()
40 { return From; } 40 { return From; }
41 41
42 OTDeviceAddress From; 42 OTDeviceAddress From;
43 OTDeviceAddress To; 43 OTDeviceAddress To;
44}; 44};
45 45
46class OTPANConnection { 46class OTPANNetworkSetup {
47 47
48public : 48public :
49 49
50 OTPANConnection( const QString & Dev, const QString & CT ) { 50 OTPANNetworkSetup( const QString & Dev, const QString & CT ) {
51 Device = Dev; 51 Device = Dev;
52 ConnectedTo = CT; 52 ConnectedTo = CT;
53 } 53 }
54 54
55 QString Device; 55 QString Device;
56 QString ConnectedTo; 56 QString ConnectedTo;
57}; 57};
58 58
59 59
60class OTGateway : public QObject { 60class OTGateway : public QObject {
61 61
62 Q_OBJECT 62 Q_OBJECT
63 63
64public : 64public :
65 65
66 // single instance 66 // single instance
67 static OTGateway * getOTGateway( void ); 67 static OTGateway * getOTGateway( void );
68 static void releaseOTGateway( void ); 68 static void releaseOTGateway( void );
69 // convert device type as class to name for that class 69 // convert device type as class to name for that class
70 static const char * deviceTypeToName( int Cls ); 70 static const char * deviceTypeToName( int Cls );
71 71
72 // open bluetooth system 72 // open bluetooth system
73 OTGateway( void ); 73 OTGateway( void );
74 // close bluetooth system 74 // close bluetooth system
75 ~OTGateway( void ); 75 ~OTGateway( void );
76 76
77 // get access to system device 77 // get access to system device
78 OTDevice * getOTDevice(); 78 OTDevice * getOTDevice();
79 79
80 // return true if this device needs enabling of bluetooth 80 // return true if this device needs enabling of bluetooth
81 bool needsEnabling(); 81 bool needsEnabling();
82 // return true if system is running 82 // return true if system is running
83 bool isEnabled(); 83 bool isEnabled();
84 void setRefreshTimer( int MilleSecs ); 84 void setRefreshTimer( int MilleSecs );
85 // return socket to HCI raw layer 85 // return socket to HCI raw layer
86 inline int getSocket() 86 inline int getSocket()
87 { return HciCtl; } 87 { return HciCtl; }
88 88
89 OTDriverList & getDriverList() 89 OTDriverList & getDriverList()
90 { return AllDrivers; } 90 { return AllDrivers; }
91 OTDriver * driver( int nr ) 91 OTDriver * driver( int nr )
92 { return AllDrivers.count() == 0 ? 0 : AllDrivers[nr]; } 92 { return AllDrivers.count() == 0 ? 0 : AllDrivers[nr]; }
93 void updateDrivers(); 93 void updateDrivers();
94 94
95 PANConnectionVector getPANConnections(); 95 PANNetworkSetupVector getPANNetworkSetups();
96 96
97 // scan neighbourhood using device 97 // scan neighbourhood using device
98 void scanNeighbourhood( OTDriver * D = 0 ); 98 void scanNeighbourhood( OTDriver * D = 0 );
99 void stopScanOfNeighbourhood(void ); 99 void stopScanOfNeighbourhood(void );
100 void setScanWith( OTDriver * D = 0 ) 100 void setScanWith( OTDriver * D = 0 )
101 { ScanWith = (D) ? D : 101 { ScanWith = (D) ? D :
102 (AllDrivers.count() ) ? AllDrivers[0] : 0; } 102 (AllDrivers.count() ) ? AllDrivers[0] : 0; }
103 OTDriver * scanWith( void ) 103 OTDriver * scanWith( void )
104 { return ScanWith; } 104 { return ScanWith; }
105 105
106 // get list of all detected peers 106 // get list of all detected peers
107 inline const PeerVector & peers( void ) 107 inline const PeerVector & peers( void )
108 { return AllPeers; } 108 { return AllPeers; }
109 // ping peer to see if it is up 109 // ping peer to see if it is up
110 bool isPeerUp( const OTDeviceAddress & PAddr, 110 bool isPeerUp( const OTDeviceAddress & PAddr,
111 int timeoutInSec = 1, 111 int timeoutInSec = 1,
112 int timeoutInUSec = 0, 112 int timeoutInUSec = 0,
113 int retry = 1 ); 113 int retry = 1 );
114 OTPeer * findPeer( const OTDeviceAddress & Addr ); 114 OTPeer * findPeer( const OTDeviceAddress & Addr );
115 void removePeer( OTPeer * P ); 115 void removePeer( OTPeer * P );
116 void addPeer( OTPeer * P ); 116 void addPeer( OTPeer * P );
117 117
118 OTDriver * findDriver( const OTDeviceAddress & Addr ); 118 OTDriver * findDriver( const OTDeviceAddress & Addr );
119 119
120 inline const LinkKeyArray & getLinkKeys() const 120 inline const LinkKeyArray & getLinkKeys() const
121 { return AllKeys; } 121 { return AllKeys; }
122 bool removeLinkKey( unsigned int index ); 122 bool removeLinkKey( unsigned int index );
123 123
124 // return device number if we are connected over any device 124 // return device number if we are connected over any device
125 // to the channel 125 // to the channel
126 // else returns -1 126 // else returns -1
127 int connectedToRFCommChannel( const OTDeviceAddress & Addr, int channel ); 127 int connectedToRFCommChannel( const OTDeviceAddress & Addr, int channel );
128 int getFreeRFCommDevice( void ); 128 int getFreeRFCommDevice( void );
129 // return 0 if properly released 129 // return 0 if properly released
130 int releaseRFCommDevice( int DevNr ); 130 int releaseRFCommDevice( int DevNr );
131 131
132public slots : 132public slots :
133 133
134 // start bluetooth system 134 // start bluetooth system
135 void SLOT_SetEnabled( bool ); 135 void SLOT_SetEnabled( bool );
136 void SLOT_Enable(); 136 void SLOT_Enable();
137 void SLOT_Disable(); 137 void SLOT_Disable();
138 138
139 // show error 139 // show error
140 void SLOT_ShowError( const QString & ); 140 void SLOT_ShowError( const QString & );
141 141
142 void SLOT_Enabled( int, bool ); 142 void SLOT_Enabled( int, bool );
143 void SLOT_DriverDisappeared( OTDriver * ); 143 void SLOT_DriverDisappeared( OTDriver * );
144 void SLOT_PeerDetected( OTPeer *, bool ); 144 void SLOT_PeerDetected( OTPeer *, bool );
145 void SLOT_FinishedDetecting(); 145 void SLOT_FinishedDetecting();
146 146
147signals : 147signals :
148 148
149 // any error 149 // any error
150 void error( const QString & ); 150 void error( const QString & );
151 151
152 // signal state of bluetooth driver 152 // signal state of bluetooth driver
153 void stateChange( OTDriver * D, bool State ); 153 void stateChange( OTDriver * D, bool State );
154 154
155 // sent when list of drivers changees 155 // sent when list of drivers changees
156 void driverListChanged(); 156 void driverListChanged();
157 157
158 // sent when bluetooth on device is enabled 158 // sent when bluetooth on device is enabled
159 void deviceEnabled( bool ); 159 void deviceEnabled( bool );
160 160
161 // sent when a (new if bool = TRUE) peer is detected 161 // sent when a (new if bool = TRUE) peer is detected
162 void detectedPeer( OTPeer *, bool ); 162 void detectedPeer( OTPeer *, bool );
163 163
164 // end of detection process 164 // end of detection process
165 void finishedDetecting(); 165 void finishedDetecting();
166 166
167protected : 167protected :
168 168
169 void connectNotify( const char * Signal ); 169 void connectNotify( const char * Signal );
170 void disconnectNotify( const char * Signal ); 170 void disconnectNotify( const char * Signal );
171 171
172 void timerEvent( QTimerEvent * ); 172 void timerEvent( QTimerEvent * );
173 173
174private : 174private :
175 175
176 void loadActiveConnections( void ); 176 void loadActiveNetworkSetups( void );
177 void loadKnownPeers( void ); 177 void loadKnownPeers( void );
178 void saveKnownPeers( void ); 178 void saveKnownPeers( void );
179 bool isConnectedTo( int devid, 179 bool isConnectedTo( int devid,
180 const OTDeviceAddress & Address ); 180 const OTDeviceAddress & Address );
181 181
182 void readLinkKeys(); 182 void readLinkKeys();
183 183
184 static OTGateway * SingleGateway; 184 static OTGateway * SingleGateway;
185 static int UseCount; 185 static int UseCount;
186 186
187 OTDriver * ScanWith; 187 OTDriver * ScanWith;
188 OTDriverList AllDrivers; 188 OTDriverList AllDrivers;
189 OTDevice * TheOTDevice; 189 OTDevice * TheOTDevice;
190 int HciCtl; 190 int HciCtl;
191 int ErrorConnectCount; 191 int ErrorConnectCount;
192 int RefreshTimer; 192 int RefreshTimer;
193 OTInquiry * Scanning; 193 OTInquiry * Scanning;
194 bool AllPeersModified; 194 bool AllPeersModified;
195 PeerVector AllPeers; 195 PeerVector AllPeers;
196 LinkKeyArray AllKeys; 196 LinkKeyArray AllKeys;
197}; 197};
198} 198}
199 199
200#endif 200#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTInquiry.h b/noncore/settings/networksettings2/opietooth2/OTInquiry.h
index f7bdeec..559af7a 100644
--- a/noncore/settings/networksettings2/opietooth2/OTInquiry.h
+++ b/noncore/settings/networksettings2/opietooth2/OTInquiry.h
@@ -1,137 +1,137 @@
1//-*-c++-*- 1//-*-c++-*-
2/*************************************************************************** 2/***************************************************************************
3 * Copyright (C) 2003 by Fred Schaettgen * 3 * Copyright (C) 2003 by Fred Schaettgen *
4 * kdebluetooth@schaettgen.de * 4 * kdebluetooth@schaettgen.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by * 7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or * 8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. * 9 * (at your option) any later version. *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12#ifndef OTINQUIRY_H 12#ifndef OTINQUIRY_H
13#define OTINQUIRY_H 13#define OTINQUIRY_H
14 14
15#include <qstring.h> 15#include <qstring.h>
16#include <qobject.h> 16#include <qobject.h>
17 17
18#include <qguardedptr.h> 18#include <qguardedptr.h>
19#include <qtimer.h> 19#include <qtimer.h>
20 20
21#include <OTPeer.h> 21#include <OTPeer.h>
22 22
23// #include <set> 23// #include <set>
24// #include <deque> 24// #include <deque>
25 25
26namespace Opietooth2 { 26namespace Opietooth2 {
27 27
28class QSocket; 28class QSocket;
29class QDateTime; 29class QDateTime;
30 30
31class OTDriver; 31class OTDriver;
32class OTHCISocket; 32class OTHCISocket;
33 33
34/** Scans for nearby bluetooth devices. 34/** Scans for nearby bluetooth devices.
35 * This class provides an asynchronous interface to the 35 * This class provides an asynchronous interface to the
36 * inquriy HCI command. To scan for other devices, connect 36 * inquriy HCI command. To scan for other devices, connect
37 * to the signals neighbourFound() and finished() and call 37 * to the signals neighbourFound() and finished() and call
38 * inquiry(). Inquiry results are signalled as soon as they arrive, 38 * inquiry(). Inquiry results are signalled as soon as they arrive,
39 * so the information can be displayed before the whole inquiry 39 * so the information can be displayed before the whole inquiry
40 * process is finished. 40 * process is finished.
41 * Still no connections should be set up before 41 * Still no networkSetups should be set up before
42 * the finished() signal was sent (hmm, is this always true..?) 42 * the finished() signal was sent (hmm, is this always true..?)
43 */ 43 */
44 44
45class OTInquiry : public QObject { 45class OTInquiry : public QObject {
46 46
47 Q_OBJECT 47 Q_OBJECT
48 48
49public: 49public:
50 50
51 /** Constructor. 51 /** Constructor.
52 @param owner The owning parent object 52 @param owner The owning parent object
53 */ 53 */
54 OTInquiry( OTDriver* Drv ); 54 OTInquiry( OTDriver* Drv );
55 55
56 /** Destructor. */ 56 /** Destructor. */
57 virtual ~OTInquiry(); 57 virtual ~OTInquiry();
58 58
59 // General/Unlimited Inquiry Access Code 59 // General/Unlimited Inquiry Access Code
60 static const int GIAC = 0x9E8B33; 60 static const int GIAC = 0x9E8B33;
61 61
62 // Limited Dedicated Inquiry Access Code 62 // Limited Dedicated Inquiry Access Code
63 static const int LIAC = 0x9E8B00; 63 static const int LIAC = 0x9E8B00;
64 64
65 /** Starts the inquiry. 65 /** Starts the inquiry.
66 if you start inquiry several times without calling clear(), 66 if you start inquiry several times without calling clear(),
67 you will receive each result only once. 67 you will receive each result only once.
68 @param timeout duration of the inquiry in seconds. 68 @param timeout duration of the inquiry in seconds.
69 It will be rounded to the next multiple of 1.28 sec, 69 It will be rounded to the next multiple of 1.28 sec,
70 with a maximum of 61.44 sec. 70 with a maximum of 61.44 sec.
71 @param lap 71 @param lap
72 */ 72 */
73 bool inquire( double timeout = 8.0, 73 bool inquire( double timeout = 8.0,
74 int numResponses = 0, 74 int numResponses = 0,
75 int lap = GIAC); 75 int lap = GIAC);
76 76
77 void stopInquiring( ); 77 void stopInquiring( );
78 78
79 /** Enters periodic inquiry mode. 79 /** Enters periodic inquiry mode.
80 An inquiry will be started at a random time in the intervall 80 An inquiry will be started at a random time in the intervall
81 between minduration and maxduration. 81 between minduration and maxduration.
82 @param minduration minimum time between two inquiries. Rounded to 82 @param minduration minimum time between two inquiries. Rounded to
83 a multiple of 1.28, (3.84 <= d <= 83884.8) 83 a multiple of 1.28, (3.84 <= d <= 83884.8)
84 @param maxduration maximum time between two inquiries. Rounded to 84 @param maxduration maximum time between two inquiries. Rounded to
85 a multiple of 1.28, (3.84 <= d <= 83884.8) 85 a multiple of 1.28, (3.84 <= d <= 83884.8)
86 @param timeout duration of the inquiry in seconds. 86 @param timeout duration of the inquiry in seconds.
87 It will be rounded to the next multiple of 1.28 sec, 87 It will be rounded to the next multiple of 1.28 sec,
88 with a maximum of 61.44 sec. 88 with a maximum of 61.44 sec.
89 @param numResponses Number of responses after which the inquiry 89 @param numResponses Number of responses after which the inquiry
90 will be stopped. 0 means no limit. 90 will be stopped. 0 means no limit.
91 @param lap 91 @param lap
92 */ 92 */
93 /* 93 /*
94 void inquirePeriodically( double minduration, 94 void inquirePeriodically( double minduration,
95 double maxduration, 95 double maxduration,
96 double timeout = 8.0, 96 double timeout = 8.0,
97 int numResponses = 0, 97 int numResponses = 0,
98 int lap = LIAC 98 int lap = LIAC
99 ); 99 );
100*/ 100*/
101 /** checks if there the inquiry is running currently 101 /** checks if there the inquiry is running currently
102 @return true if there is an inquiry running 102 @return true if there is an inquiry running
103 which was started by this object. 103 which was started by this object.
104 @todo possibility to check for "foreign" inquiries. Deal with 104 @todo possibility to check for "foreign" inquiries. Deal with
105 the fact that we can receive foreign inquiry results. 105 the fact that we can receive foreign inquiry results.
106 */ 106 */
107 bool isInquiring(); 107 bool isInquiring();
108 108
109 /** This function returns true after after an inquiry was 109 /** This function returns true after after an inquiry was
110 started, results were received and the inquiry ended successfully. 110 started, results were received and the inquiry ended successfully.
111 This can be the case without calling inquiry() at all, because 111 This can be the case without calling inquiry() at all, because
112 results of inquiries started by other programs are also processed. 112 results of inquiries started by other programs are also processed.
113 */ 113 */
114 bool isFinished(); 114 bool isFinished();
115 115
116 /** Resets the list of received results and sets 116 /** Resets the list of received results and sets
117 isInquiryComplete() to false. 117 isInquiryComplete() to false.
118 */ 118 */
119 void reset(); 119 void reset();
120 120
121 inline OTDriver * driver() const 121 inline OTDriver * driver() const
122 { return Driver; } 122 { return Driver; }
123 123
124protected: 124protected:
125 125
126 /** Called when a new neighbour was found. The default 126 /** Called when a new neighbour was found. The default
127 implementation emits the neighbourFound signal. 127 implementation emits the neighbourFound signal.
128 @param bdaddr the address found. 128 @param bdaddr the address found.
129 */ 129 */
130 virtual void onPeerFound( OTPeer * Peer, bool ); 130 virtual void onPeerFound( OTPeer * Peer, bool );
131 131
132 enum ErrorCode { 132 enum ErrorCode {
133 InquiryFinishedTimeout = 0x0100 133 InquiryFinishedTimeout = 0x0100
134 }; 134 };
135 135
136signals : 136signals :
137 137
diff --git a/noncore/settings/networksettings2/ppp/PPPDialingedit.cpp b/noncore/settings/networksettings2/ppp/PPPDialingedit.cpp
index 9264ceb..2b03c73 100644
--- a/noncore/settings/networksettings2/ppp/PPPDialingedit.cpp
+++ b/noncore/settings/networksettings2/ppp/PPPDialingedit.cpp
@@ -1,25 +1,24 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <qcombobox.h> 2#include <qcombobox.h>
3#include <qmessagebox.h> 3#include <qmessagebox.h>
4#include <qradiobutton.h> 4#include <qradiobutton.h>
5#include <qlineedit.h> 5#include <qlineedit.h>
6#include <GUIUtils.h> 6#include <GUIUtils.h>
7#include "PPPDialingedit.h" 7#include "PPPDialingedit.h"
8 8
9PPPDialingEdit::PPPDialingEdit( QWidget * Parent ) : 9PPPDialingEdit::PPPDialingEdit( QWidget * Parent ) :
10 PPPDialingGUI( Parent ){ 10 PPPDialingGUI( Parent ){
11 11
12 // populate widget stack 12 // populate widget stack
13} 13}
14 14
15QString PPPDialingEdit::acceptable( void ) { 15QString PPPDialingEdit::acceptable( void ) {
16 return QString(); 16 return QString();
17} 17}
18 18
19bool PPPDialingEdit::commit( PPPData & D ) { 19bool PPPDialingEdit::commit( PPPData & ) {
20 bool SM; 20 return true;
21 return SM;
22} 21}
23 22
24void PPPDialingEdit::showData( PPPData & D ) { 23void PPPDialingEdit::showData( PPPData & D ) {
25} 24}
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
index 8c15e9c..884168c 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
@@ -1,83 +1,83 @@
1#include <qfile.h> 1#include <qfile.h>
2#include <resources.h> 2#include <resources.h>
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include "ppp_NN.h" 4#include "ppp_NN.h"
5#include "ppp_NNI.h" 5#include "ppp_NNI.h"
6 6
7#include "netnodeinterface.h" 7#include "netnodeinterface.h"
8 8
9QStringList * PPPNetNode::ProperFiles = 0; 9QStringList * PPPNetNode::ProperFiles = 0;
10 10
11static const char * PPPNeeds[] = 11static const char * PPPNeeds[] =
12 { "modem", 12 { "modem",
13 0 13 0
14 }; 14 };
15 15
16static const char * PPPProvides[] = 16static const char * PPPProvides[] =
17 { "connection", 17 { "NetworkSetup",
18 0 18 0
19 }; 19 };
20 20
21/** 21/**
22 * Constructor, find all of the possible interfaces 22 * Constructor, find all of the possible interfaces
23 */ 23 */
24PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) { 24PPPNetNode::PPPNetNode() : ANetNode(tr("PPP NetworkSetup")) {
25 25
26 NSResources->addSystemFile( 26 NSResources->addSystemFile(
27 "pap-secrets", "/etc/ppp/pap-secrets", 0 ); 27 "pap-secrets", "/etc/ppp/pap-secrets", 0 );
28 NSResources->addSystemFile( 28 NSResources->addSystemFile(
29 "chap-secrets", "/etc/ppp/chap-secrets", 0 ); 29 "chap-secrets", "/etc/ppp/chap-secrets", 0 );
30} 30}
31 31
32/** 32/**
33 * Delete any interfaces that we own. 33 * Delete any interfaces that we own.
34 */ 34 */
35PPPNetNode::~PPPNetNode(){ 35PPPNetNode::~PPPNetNode(){
36} 36}
37 37
38const QString PPPNetNode::nodeDescription(){ 38const QString PPPNetNode::nodeDescription(){
39 return tr("\ 39 return tr("\
40<p>Sets up IP using PPP.</p>\ 40<p>Sets up IP using PPP.</p>\
41<p>Use this for dialup devices or serial setups</p>\ 41<p>Use this for dialup devices or serial setups</p>\
42" 42"
43); 43);
44} 44}
45 45
46ANetNodeInstance * PPPNetNode::createInstance( void ) { 46ANetNodeInstance * PPPNetNode::createInstance( void ) {
47 return new APPP( this ); 47 return new APPP( this );
48} 48}
49 49
50const char ** PPPNetNode::needs( void ) { 50const char ** PPPNetNode::needs( void ) {
51 return PPPNeeds; 51 return PPPNeeds;
52} 52}
53 53
54const char ** PPPNetNode::provides( void ) { 54const char ** PPPNetNode::provides( void ) {
55 return PPPProvides; 55 return PPPProvides;
56} 56}
57 57
58QStringList PPPNetNode::properFiles( void ) { 58QStringList PPPNetNode::properFiles( void ) {
59 QStringList SL; 59 QStringList SL;
60 SL << "peers" << "chatscripts"; 60 SL << "peers" << "chatscripts";
61 return SL; 61 return SL;
62} 62}
63 63
64// need to generate : 64// need to generate :
65// /etc/ppp/pap-secrets 65// /etc/ppp/pap-secrets
66// /etc/ppp/pap-secrets 66// /etc/ppp/pap-secrets
67bool PPPNetNode::hasDataForFile( SystemFile & S ) { 67bool PPPNetNode::hasDataForFile( SystemFile & S ) {
68 return S.name() == "pap-secrets" || 68 return S.name() == "pap-secrets" ||
69 S.name() == "chap-secrets" ; 69 S.name() == "chap-secrets" ;
70} 70}
71 71
72QString PPPNetNode::genNic( long NicNr ) { 72QString PPPNetNode::genNic( long NicNr ) {
73 QString S; 73 QString S;
74 return S.sprintf( "ppp%ld", NicNr ); 74 return S.sprintf( "ppp%ld", NicNr );
75} 75}
76 76
77void PPPNetNode::setSpecificAttribute( QString & , QString & ) { 77void PPPNetNode::setSpecificAttribute( QString & , QString & ) {
78} 78}
79 79
80void PPPNetNode::saveSpecificAttribute( QTextStream & ) { 80void PPPNetNode::saveSpecificAttribute( QTextStream & ) {
81} 81}
82 82
83OPIE_NS2_PLUGIN( NetNodeInterface_T<PPPNetNode> ) 83OPIE_NS2_PLUGIN( NetNodeInterface_T<PPPNetNode> )
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
index 9e3bb64..7286d96 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
@@ -56,180 +56,180 @@ void APPP::setSpecificAttribute( QString & A, QString & V ) {
56 Data.Auth.Login.Send = V; 56 Data.Auth.Login.Send = V;
57 } else if( A == "authpasswordexpect" ) { 57 } else if( A == "authpasswordexpect" ) {
58 Data.Auth.Password.Expect = V; 58 Data.Auth.Password.Expect = V;
59 } else if( A == "authpasswordsend" ) { 59 } else if( A == "authpasswordsend" ) {
60 Data.Auth.Password.Send = V; 60 Data.Auth.Password.Send = V;
61 } else if( A == "authpcemode" ) { 61 } else if( A == "authpcemode" ) {
62 Data.Auth.PCEMode = V.toShort(); 62 Data.Auth.PCEMode = V.toShort();
63 } else if( A == "authclient" ) { 63 } else if( A == "authclient" ) {
64 Data.Auth.Client = V; 64 Data.Auth.Client = V;
65 } else if( A == "authserver" ) { 65 } else if( A == "authserver" ) {
66 Data.Auth.Server = V; 66 Data.Auth.Server = V;
67 } else if( A == "authsecret" ) { 67 } else if( A == "authsecret" ) {
68 Data.Auth.Secret = V; 68 Data.Auth.Secret = V;
69 } 69 }
70 } else if( A.startsWith( "ip" ) ) { 70 } else if( A.startsWith( "ip" ) ) {
71 if( A == "iplocaloverrule" ) { 71 if( A == "iplocaloverrule" ) {
72 Data.IP.LocalOverrule = (V == "yes"); 72 Data.IP.LocalOverrule = (V == "yes");
73 } else if( A == "ipremoteoverrule" ) { 73 } else if( A == "ipremoteoverrule" ) {
74 Data.IP.RemoteOverrule = (V == "yes"); 74 Data.IP.RemoteOverrule = (V == "yes");
75 } else if( A == "ipgwautomatic" ) { 75 } else if( A == "ipgwautomatic" ) {
76 Data.IP.GWAutomatic = (V == "yes"); 76 Data.IP.GWAutomatic = (V == "yes");
77 } else if( A == "ipgwisdefault" ) { 77 } else if( A == "ipgwisdefault" ) {
78 Data.IP.GWIsDefault = (V == "yes"); 78 Data.IP.GWIsDefault = (V == "yes");
79 } else if( A == "ipgwifnotset" ) { 79 } else if( A == "ipgwifnotset" ) {
80 Data.IP.GWIfNotSet = (V == "yes"); 80 Data.IP.GWIfNotSet = (V == "yes");
81 } else if( A == "iplocaladdress" ) { 81 } else if( A == "iplocaladdress" ) {
82 Data.IP.LocalAddress = V; 82 Data.IP.LocalAddress = V;
83 } else if( A == "ipremoteaddress" ) { 83 } else if( A == "ipremoteaddress" ) {
84 Data.IP.RemoteAddress = V; 84 Data.IP.RemoteAddress = V;
85 } else if( A == "ipgwaddress" ) { 85 } else if( A == "ipgwaddress" ) {
86 Data.IP.GWAddress = V; 86 Data.IP.GWAddress = V;
87 } 87 }
88 } else if( A.startsWith( "run" ) ) { 88 } else if( A.startsWith( "run" ) ) {
89 if( A == "runpreconnect" ) { 89 if( A == "runpreconnect" ) {
90 Data.Run.PreConnect = V; 90 Data.Run.PreConnect = V;
91 } else if( A == "runpostconnect" ) { 91 } else if( A == "runpostconnect" ) {
92 Data.Run.PostConnect = V; 92 Data.Run.PostConnect = V;
93 } else if( A == "runpredisconnect" ) { 93 } else if( A == "runpredisconnect" ) {
94 Data.Run.PreDisconnect = V; 94 Data.Run.PreDisconnect = V;
95 } else if( A == "runpostdisconnect" ) { 95 } else if( A == "runpostdisconnect" ) {
96 Data.Run.PostDisconnect = V; 96 Data.Run.PostDisconnect = V;
97 } 97 }
98 } 98 }
99} 99}
100 100
101void APPP::saveSpecificAttribute( QTextStream & TS ) { 101void APPP::saveSpecificAttribute( QTextStream & TS ) {
102 TS << "dnsserverassigned=" << 102 TS << "dnsserverassigned=" <<
103 ( ( Data.DNS.ServerAssigned ) ? "yes" : "no" ) << endl; 103 ( ( Data.DNS.ServerAssigned ) ? "yes" : "no" ) << endl;
104 TS << "dnsdomainname=" << Data.DNS.DomainName << endl; 104 TS << "dnsdomainname=" << Data.DNS.DomainName << endl;
105 for( unsigned int i = 0; i < Data.DNS.Servers.size(); i ++ ) { 105 for( unsigned int i = 0; i < Data.DNS.Servers.size(); i ++ ) {
106 TS << "dnsserver=" << *(Data.DNS.Servers[i]) << endl; 106 TS << "dnsserver=" << *(Data.DNS.Servers[i]) << endl;
107 } 107 }
108 TS << "authmode=" << Data.Auth.Mode << endl; 108 TS << "authmode=" << Data.Auth.Mode << endl;
109 TS << "authloginexpect=" << quote( Data.Auth.Login.Expect ) << endl; 109 TS << "authloginexpect=" << quote( Data.Auth.Login.Expect ) << endl;
110 TS << "authloginsend=" << quote( Data.Auth.Login.Send ) << endl; 110 TS << "authloginsend=" << quote( Data.Auth.Login.Send ) << endl;
111 TS << "authpasswordexpect=" << quote( Data.Auth.Password.Expect ) << endl; 111 TS << "authpasswordexpect=" << quote( Data.Auth.Password.Expect ) << endl;
112 TS << "authpasswordsend=" << quote( Data.Auth.Password.Send ) << endl; 112 TS << "authpasswordsend=" << quote( Data.Auth.Password.Send ) << endl;
113 TS << "authpcemode=" << Data.Auth.PCEMode << endl; 113 TS << "authpcemode=" << Data.Auth.PCEMode << endl;
114 TS << "authclient=" << Data.Auth.Client << endl; 114 TS << "authclient=" << Data.Auth.Client << endl;
115 TS << "authserver=" << Data.Auth.Server << endl; 115 TS << "authserver=" << Data.Auth.Server << endl;
116 TS << "authsecret=" << quote( Data.Auth.Secret ) << endl; 116 TS << "authsecret=" << quote( Data.Auth.Secret ) << endl;
117 TS << "ipgwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl; 117 TS << "ipgwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl;
118 TS << "ipgwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl; 118 TS << "ipgwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl;
119 TS << "ipgwifnotset=" << ( ( Data.IP.GWIfNotSet ) ? "yes" : "no" ) << endl; 119 TS << "ipgwifnotset=" << ( ( Data.IP.GWIfNotSet ) ? "yes" : "no" ) << endl;
120 TS << "iplocaloverrule=" << ( ( Data.IP.LocalOverrule ) ? "yes" : "no" ) << endl; 120 TS << "iplocaloverrule=" << ( ( Data.IP.LocalOverrule ) ? "yes" : "no" ) << endl;
121 TS << "ipremoteoverrule=" << ( ( Data.IP.RemoteOverrule ) ? "yes" : "no" ) << endl; 121 TS << "ipremoteoverrule=" << ( ( Data.IP.RemoteOverrule ) ? "yes" : "no" ) << endl;
122 TS << "iplocaladdress=" << Data.IP.LocalAddress << endl; 122 TS << "iplocaladdress=" << Data.IP.LocalAddress << endl;
123 TS << "ipremoteaddress=" << Data.IP.RemoteAddress << endl; 123 TS << "ipremoteaddress=" << Data.IP.RemoteAddress << endl;
124 TS << "ipgwaddress=" << Data.IP.GWAddress << endl; 124 TS << "ipgwaddress=" << Data.IP.GWAddress << endl;
125 125
126 TS << "runpreconnect=" << Data.Run.PreConnect << endl; 126 TS << "runpreconnect=" << Data.Run.PreConnect << endl;
127 TS << "runpostconnect=" << Data.Run.PostConnect << endl; 127 TS << "runpostconnect=" << Data.Run.PostConnect << endl;
128 TS << "runpredisconnect=" << Data.Run.PreDisconnect << endl; 128 TS << "runpredisconnect=" << Data.Run.PreDisconnect << endl;
129 TS << "runpostdisconnect=" << Data.Run.PostDisconnect << endl; 129 TS << "runpostdisconnect=" << Data.Run.PostDisconnect << endl;
130 130
131} 131}
132 132
133QWidget * APPP::edit( QWidget * parent ) { 133QWidget * APPP::edit( QWidget * parent ) {
134 GUI = new PPPEdit( parent ); 134 GUI = new PPPEdit( parent );
135 GUI->showData( Data ); 135 GUI->showData( Data );
136 return GUI; 136 return GUI;
137} 137}
138 138
139QString APPP::acceptable( void ) { 139QString APPP::acceptable( void ) {
140 return ( GUI ) ? GUI->acceptable( ) : QString(); 140 return ( GUI ) ? GUI->acceptable( ) : QString();
141} 141}
142 142
143void APPP::commit( void ) { 143void APPP::commit( void ) {
144 if( GUI && GUI->commit( Data ) ) { 144 if( GUI && GUI->commit( Data ) ) {
145 setModified( 1 ); 145 setModified( 1 );
146 } 146 }
147} 147}
148 148
149bool APPP::openFile( SystemFile & SF ) { 149bool APPP::openFile( SystemFile & SF ) {
150 if( SF.name() == "peers" ) { 150 if( SF.name() == "peers" ) {
151 SF.setPath( removeSpaces( 151 SF.setPath( removeSpaces(
152 QString( "/tmp/ppp/peers/" ) + connection()->name() ) ); 152 QString( "/tmp/ppp/peers/" ) + networkSetup()->name() ) );
153 return 1; 153 return 1;
154 } else if ( SF.name() == "chatscripts" ) { 154 } else if ( SF.name() == "chatscripts" ) {
155 SF.setPath( removeSpaces( 155 SF.setPath( removeSpaces(
156 QString( "/tmp/chatscripts/" ) + connection()->name() ) ); 156 QString( "/tmp/chatscripts/" ) + networkSetup()->name() ) );
157 return 1; 157 return 1;
158 } 158 }
159 return 0; 159 return 0;
160} 160}
161 161
162short APPP::generateFile( SystemFile & SF, long DevNr ) { 162short APPP::generateFile( SystemFile & SF, long DevNr ) {
163 short rvl, rvd; 163 short rvl, rvd;
164 164
165 rvl = 1; 165 rvl = 1;
166 rvd = 1; 166 rvd = 1;
167 167
168 if( SF.name() == "pap-secrets" ) { 168 if( SF.name() == "pap-secrets" ) {
169 Log(("Generate PPP for %s\n", SF.name().latin1() )); 169 Log(("Generate PPP for %s\n", SF.name().latin1() ));
170 170
171 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) { 171 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) {
172 SF << "# secrets for " 172 SF << "# secrets for "
173 << connection()->name().latin1() 173 << networkSetup()->name().latin1()
174 << endl; 174 << endl;
175 SF << Data.Auth.Client 175 SF << Data.Auth.Client
176 << " " 176 << " "
177 << Data.Auth.Server 177 << Data.Auth.Server
178 << " " 178 << " "
179 << Data.Auth.Secret 179 << Data.Auth.Secret
180 << endl; 180 << endl;
181 rvl = 0; 181 rvl = 0;
182 rvd = connection()->getToplevel()->generateFileEmbedded( 182 rvd = networkSetup()->getToplevel()->generateFileEmbedded(
183 SF, DevNr ); 183 SF, DevNr );
184 } 184 }
185 } else if( SF.name() == "chap-secrets" ) { 185 } else if( SF.name() == "chap-secrets" ) {
186 Log(("Generate PPP for %s\n", SF.name().latin1() )); 186 Log(("Generate PPP for %s\n", SF.name().latin1() ));
187 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) { 187 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) {
188 // used for both EAP and Chap 188 // used for both EAP and Chap
189 SF << "# secrets for " 189 SF << "# secrets for "
190 << connection()->name().latin1() 190 << networkSetup()->name().latin1()
191 << endl; 191 << endl;
192 SF << Data.Auth.Client 192 SF << Data.Auth.Client
193 << " " 193 << " "
194 << Data.Auth.Server 194 << Data.Auth.Server
195 << " " 195 << " "
196 << Data.Auth.Secret 196 << Data.Auth.Secret
197 << endl; 197 << endl;
198 198
199 rvl = 0; 199 rvl = 0;
200 rvd = connection()->getToplevel()->generateFileEmbedded( 200 rvd = networkSetup()->getToplevel()->generateFileEmbedded(
201 SF, DevNr ); 201 SF, DevNr );
202 } 202 }
203 } else if ( SF.name() == "peers" ) { 203 } else if ( SF.name() == "peers" ) {
204 204
205 QFileInfo FI(SF.path()); 205 QFileInfo FI(SF.path());
206 Log(("Generate PPP for %s\n", SF.name().latin1() )); 206 Log(("Generate PPP for %s\n", SF.name().latin1() ));
207 207
208 SF << "connect \"/usr/sbin/chat -v -f /etc/chatscripts/" 208 SF << "connect \"/usr/sbin/chat -v -f /etc/chatscripts/"
209 << FI.baseName() 209 << FI.baseName()
210 << "\"" 210 << "\""
211 << endl; 211 << endl;
212 212
213 if( Data.IP.GWIsDefault ) { 213 if( Data.IP.GWIsDefault ) {
214 SF << "defaultroute" 214 SF << "defaultroute"
215 << endl; 215 << endl;
216 } 216 }
217 217
218 SF << "linkname " 218 SF << "linkname "
219 << removeSpaces( SF.name().latin1() ) 219 << removeSpaces( SF.name().latin1() )
220 << endl; 220 << endl;
221 221
222 // insert other data here 222 // insert other data here
223 rvl = 0; 223 rvl = 0;
224 rvd = connection()->getToplevel()->generateFileEmbedded( 224 rvd = networkSetup()->getToplevel()->generateFileEmbedded(
225 SF, DevNr ); 225 SF, DevNr );
226 } else if ( SF.name() == "chatscripts" ) { 226 } else if ( SF.name() == "chatscripts" ) {
227 Log(("Generate PPP for %s\n", SF.name().latin1() )); 227 Log(("Generate PPP for %s\n", SF.name().latin1() ));
228 rvl = 0; 228 rvl = 0;
229 rvd = connection()->getToplevel()->generateFileEmbedded( 229 rvd = networkSetup()->getToplevel()->generateFileEmbedded(
230 SF, DevNr ); 230 SF, DevNr );
231 } 231 }
232 232
233 return (rvd == 2 || rvl == 2 ) ? 2 : 233 return (rvd == 2 || rvl == 2 ) ? 2 :
234 (rvd == 0 || rvl == 0 ) ? 0 : 1; 234 (rvd == 0 || rvl == 0 ) ? 0 : 1;
235} 235}
diff --git a/noncore/settings/networksettings2/ppp/ppprun.cpp b/noncore/settings/networksettings2/ppp/ppprun.cpp
index 8403e6d..f548483 100644
--- a/noncore/settings/networksettings2/ppp/ppprun.cpp
+++ b/noncore/settings/networksettings2/ppp/ppprun.cpp
@@ -1,52 +1,52 @@
1#include <resources.h> 1#include <resources.h>
2#include "ppprun.h" 2#include "ppprun.h"
3 3
4PPPRun::PPPRun( ANetNodeInstance * NNI, PPPData & Data ) : 4PPPRun::PPPRun( ANetNodeInstance * NNI, PPPData & Data ) :
5 RuntimeInfo( NNI ), Pat( "eth[0-9]" ) { 5 RuntimeInfo( NNI ), Pat( "eth[0-9]" ) {
6 D = &Data; 6 D = &Data;
7} 7}
8 8
9State_t PPPRun::detectState( void ) { 9State_t PPPRun::detectState( void ) {
10 if( isMyPPPDRunning( ) ) { 10 if( isMyPPPDRunning( ) ) {
11 return ( isMyPPPUp() ) ? IsUp : Available; 11 return ( isMyPPPUp() ) ? IsUp : Available;
12 } 12 }
13 return Off; 13 return Off;
14} 14}
15 15
16QString PPPRun::setMyState( NodeCollection * NC, Action_t A, bool ) { 16QString PPPRun::setMyState( NetworkSetup * , Action_t , bool ) {
17 return QString(); 17 return QString();
18} 18}
19 19
20bool PPPRun::isMyPPPDRunning( void ) { 20bool PPPRun::isMyPPPDRunning( void ) {
21 return 0; 21 return 0;
22} 22}
23 23
24bool PPPRun::isMyPPPUp( void ) { 24bool PPPRun::isMyPPPUp( void ) {
25 System & S = NSResources->system(); 25 System & S = NSResources->system();
26 InterfaceInfo * Run; 26 InterfaceInfo * Run;
27 QRegExp R( "ppp[0-9]" ); 27 QRegExp R( "ppp[0-9]" );
28 28
29 for( QDictIterator<InterfaceInfo> It(S.interfaces()); 29 for( QDictIterator<InterfaceInfo> It(S.interfaces());
30 It.current(); 30 It.current();
31 ++It ) { 31 ++It ) {
32 Run = It.current(); 32 Run = It.current();
33 if( R.match( Run->Name ) >= 0 && 33 if( R.match( Run->Name ) >= 0 &&
34 Run->IsPointToPoint 34 Run->IsPointToPoint
35 ) { 35 ) {
36 // this is a LAN card 36 // this is a LAN card
37 if( Run->assignedConnection() == netNode()->connection() ) { 37 if( Run->assignedToNetworkSetup() == netNode()->networkSetup() ) {
38 // assigned to us 38 // assigned to us
39 return 1; 39 return 1;
40 } 40 }
41 } 41 }
42 } 42 }
43 return 0; 43 return 0;
44} 44}
45 45
46bool PPPRun::handlesInterface( const QString & S ) { 46bool PPPRun::handlesInterface( const QString & S ) {
47 return Pat.match( S ) >= 0; 47 return Pat.match( S ) >= 0;
48} 48}
49 49
50bool PPPRun::handlesInterface( InterfaceInfo * I ) { 50bool PPPRun::handlesInterface( InterfaceInfo * I ) {
51 return handlesInterface( I->Name ); 51 return handlesInterface( I->Name );
52} 52}
diff --git a/noncore/settings/networksettings2/ppp/ppprun.h b/noncore/settings/networksettings2/ppp/ppprun.h
index 2990a96..9535382 100644
--- a/noncore/settings/networksettings2/ppp/ppprun.h
+++ b/noncore/settings/networksettings2/ppp/ppprun.h
@@ -1,37 +1,37 @@
1#ifndef PPPRUN_H 1#ifndef PPPRUN_H
2#define PPPRUN_H 2#define PPPRUN_H
3 3
4#include <qregexp.h> 4#include <qregexp.h>
5#include <netnode.h> 5#include <netnode.h>
6#include "pppdata.h" 6#include "pppdata.h"
7 7
8class PPPRun : public RuntimeInfo { 8class PPPRun : public RuntimeInfo {
9 9
10public : 10public :
11 11
12 PPPRun( ANetNodeInstance * NNI, 12 PPPRun( ANetNodeInstance * NNI,
13 PPPData & Data ); 13 PPPData & Data );
14 14
15 bool handlesInterface( const QString & I ); 15 bool handlesInterface( const QString & I );
16 bool handlesInterface( InterfaceInfo * ); 16 bool handlesInterface( InterfaceInfo * );
17 17
18 State_t detectState( void ); 18 State_t detectState( void );
19 virtual RuntimeInfo * device( void ) 19 virtual RuntimeInfo * device( void )
20 { return this; } 20 { return this; }
21 virtual RuntimeInfo * connection( void ) 21 virtual RuntimeInfo * connection( void )
22 { return this; } 22 { return this; }
23 23
24protected : 24protected :
25 25
26 QString setMyState( NodeCollection * , Action_t, bool ); 26 QString setMyState( NetworkSetup * , Action_t, bool );
27 27
28private : 28private :
29 29
30 bool isMyPPPDRunning( void ); 30 bool isMyPPPDRunning( void );
31 bool isMyPPPUp( void ); 31 bool isMyPPPUp( void );
32 32
33 PPPData * D; 33 PPPData * D;
34 QRegExp Pat; 34 QRegExp Pat;
35}; 35};
36 36
37#endif 37#endif
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp
index 1e6912e..007f4a5 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NN.cpp
@@ -1,58 +1,58 @@
1#include <resources.h> 1#include <resources.h>
2#include "profile_NN.h" 2#include "profile_NN.h"
3#include "profile_NNI.h" 3#include "profile_NNI.h"
4 4
5#include "netnodeinterface.h" 5#include "netnodeinterface.h"
6 6
7static const char * ProfileNeeds[] = 7static const char * ProfileNeeds[] =
8 { "connection", 8 { "NetworkSetup",
9 0 9 0
10 }; 10 };
11static const char * ProfileProvides[] = 11static const char * ProfileProvides[] =
12 { "fullsetup", 12 { "fullsetup",
13 0 13 0
14 }; 14 };
15 15
16/** 16/**
17 * Constructor, find all of the possible interfaces 17 * Constructor, find all of the possible interfaces
18 */ 18 */
19ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) { 19ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular NetworkSetup profile")) {
20 20
21 NSResources->addSystemFile( 21 NSResources->addSystemFile(
22 "interfaces", "/etc/network/interfaces", 1 ); 22 "interfaces", "/etc/network/interfaces", 1 );
23 23
24} 24}
25 25
26/** 26/**
27 * Delete any interfaces that we own. 27 * Delete any interfaces that we own.
28 */ 28 */
29ProfileNetNode::~ProfileNetNode(){ 29ProfileNetNode::~ProfileNetNode(){
30} 30}
31 31
32const QString ProfileNetNode::nodeDescription(){ 32const QString ProfileNetNode::nodeDescription(){
33 return tr("\ 33 return tr("\
34<p>Define use of an IP connection.</p>\ 34<p>Define use of an IP NetworkSetup.</p>\
35<p>Configure if and when this connection needs to be established</p>\ 35<p>Configure if and when this NetworkSetup needs to be established</p>\
36" 36"
37); 37);
38} 38}
39 39
40ANetNodeInstance * ProfileNetNode::createInstance( void ) { 40ANetNodeInstance * ProfileNetNode::createInstance( void ) {
41 return new AProfile( this ); 41 return new AProfile( this );
42} 42}
43 43
44const char ** ProfileNetNode::needs( void ) { 44const char ** ProfileNetNode::needs( void ) {
45 return ProfileNeeds; 45 return ProfileNeeds;
46} 46}
47 47
48const char ** ProfileNetNode::provides( void ) { 48const char ** ProfileNetNode::provides( void ) {
49 return ProfileProvides; 49 return ProfileProvides;
50} 50}
51 51
52void ProfileNetNode::setSpecificAttribute( QString & , QString & ) { 52void ProfileNetNode::setSpecificAttribute( QString & , QString & ) {
53} 53}
54 54
55void ProfileNetNode::saveSpecificAttribute( QTextStream & ) { 55void ProfileNetNode::saveSpecificAttribute( QTextStream & ) {
56} 56}
57 57
58OPIE_NS2_PLUGIN( NetNodeInterface_T<ProfileNetNode> ) 58OPIE_NS2_PLUGIN( NetNodeInterface_T<ProfileNetNode> )
diff --git a/noncore/settings/networksettings2/profile/profiledata.h b/noncore/settings/networksettings2/profile/profiledata.h
index c9577e5..2f7060d 100644
--- a/noncore/settings/networksettings2/profile/profiledata.h
+++ b/noncore/settings/networksettings2/profile/profiledata.h
@@ -1,17 +1,17 @@
1#ifndef PROFILE_DATA_H 1#ifndef PROFILE_DATA_H
2#define PROFILE_DATA_H 2#define PROFILE_DATA_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5class ProfileData { 5class ProfileData {
6public : 6public :
7 QString Description; 7 QString Description;
8 // start up automatically 8 // start up automatically
9 bool Automatic; 9 bool Automatic;
10 // if started up automatically, ask user for confirmation 10 // if started up automatically, ask user for confirmation
11 bool Confirm; 11 bool Confirm;
12 // Do not bring this connection up 12 // Do not bring this networkSetup up
13 bool Disabled; 13 bool Disabled;
14 bool TriggerVPN; 14 bool TriggerVPN;
15} ; 15} ;
16 16
17#endif 17#endif
diff --git a/noncore/settings/networksettings2/profile/profileedit.cpp b/noncore/settings/networksettings2/profile/profileedit.cpp
index 88aab15..ad943fe 100644
--- a/noncore/settings/networksettings2/profile/profileedit.cpp
+++ b/noncore/settings/networksettings2/profile/profileedit.cpp
@@ -1,98 +1,102 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qframe.h> 2#include <qframe.h>
3#include <qcheckbox.h> 3#include <qcheckbox.h>
4#include <qmultilineedit.h> 4#include <qmultilineedit.h>
5#include <qcheckbox.h> 5#include <qcheckbox.h>
6 6
7#include <GUIUtils.h> 7#include <GUIUtils.h>
8#include <netnode.h> 8#include <netnode.h>
9#include <resources.h> 9#include <resources.h>
10 10
11#include "profileedit.h" 11#include "profileedit.h"
12 12
13ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : 13ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) :
14 ProfileGUI( Parent ), RefreshTimer(this) { 14 ProfileGUI( Parent ), RefreshTimer(this) {
15 InterfaceInfo * II; 15 InterfaceInfo * II;
16 16
17 II = TNNI->networkSetup()->assignedInterface();
18 Log(( "Interface %p %p %p: %d\n", II,
19 TNNI, TNNI->networkSetup(), (II) ? II->IsUp : 0 ));
20
17 NNI = TNNI; 21 NNI = TNNI;
18 Dev = NNI->runtime()->device(); 22 Dev = NNI->runtime()->device();
19 if( ( II = NNI->connection()->assignedInterface() ) ) { 23 if( ( II = NNI->networkSetup()->assignedInterface() ) ) {
20 24
21 Refresh_CB->setEnabled( TRUE ); 25 Refresh_CB->setEnabled( TRUE );
22 Snd_GB->setEnabled( TRUE ); 26 Snd_GB->setEnabled( TRUE );
23 Rcv_GB->setEnabled( TRUE ); 27 Rcv_GB->setEnabled( TRUE );
24 Collisions_FRM->setEnabled( TRUE ); 28 Collisions_FRM->setEnabled( TRUE );
25 29
26 // show current content 30 // show current content
27 SLOT_Refresh(); 31 SLOT_Refresh();
28 32
29 // fill in static data 33 // fill in static data
30 InterfaceName_LBL->setText( II->Name ); 34 InterfaceName_LBL->setText( II->Name );
31 IPAddress_LBL->setText( II->Address ); 35 IPAddress_LBL->setText( II->Address );
32 SubnetMask_LBL->setText( II->Netmask ); 36 SubnetMask_LBL->setText( II->Netmask );
33 Broadcast_LBL->setText( II->BCastAddress ); 37 Broadcast_LBL->setText( II->BCastAddress );
34 MACAddress_LBL->setText( II->MACAddress ); 38 MACAddress_LBL->setText( II->MACAddress );
35 if( II->IsPointToPoint ) { 39 if( II->IsPointToPoint ) {
36 PointToPoint_LBL->setText( II->DstAddress ); 40 PointToPoint_LBL->setText( II->DstAddress );
37 } 41 }
38 QString S; 42 QString S;
39 InterfaceName_LBL->setText( II->Name ); 43 InterfaceName_LBL->setText( II->Name );
40 if( II->HasMulticast ) { 44 if( II->HasMulticast ) {
41 S += "Multicast"; 45 S += "Multicast";
42 } 46 }
43 if( ! S.isEmpty() ) { 47 if( ! S.isEmpty() ) {
44 S.prepend( " : " ); 48 S.prepend( " : " );
45 } 49 }
46 InterfaceOptions_LBL->setText( S ); 50 InterfaceOptions_LBL->setText( S );
47 51
48 connect( &RefreshTimer, SIGNAL( timeout() ), 52 connect( &RefreshTimer, SIGNAL( timeout() ),
49 this, SLOT( SLOT_Refresh() ) ); 53 this, SLOT( SLOT_Refresh() ) );
50 } 54 }
51 55
52} 56}
53 57
54QString ProfileEdit::acceptable( void ) { 58QString ProfileEdit::acceptable( void ) {
55 return QString(); 59 return QString();
56} 60}
57 61
58void ProfileEdit::showData( ProfileData & Data ) { 62void ProfileEdit::showData( ProfileData & Data ) {
59 Description_LE->setText( Data.Description ); 63 Description_LE->setText( Data.Description );
60 Automatic_CB->setChecked( Data.Automatic ); 64 Automatic_CB->setChecked( Data.Automatic );
61 TriggersVPN_CB->setChecked( Data.TriggerVPN ); 65 TriggersVPN_CB->setChecked( Data.TriggerVPN );
62 Confirm_CB->setChecked( Data.Confirm ); 66 Confirm_CB->setChecked( Data.Confirm );
63 Disabled_CB->setChecked( Data.Disabled ); 67 Disabled_CB->setChecked( Data.Disabled );
64} 68}
65 69
66 70
67bool ProfileEdit::commit( ProfileData & Data ) { 71bool ProfileEdit::commit( ProfileData & Data ) {
68 bool SM = 0; 72 bool SM = 0;
69 TXTM( Data.Description, Description_LE, SM ); 73 TXTM( Data.Description, Description_LE, SM );
70 74
71 CBM( Data.Automatic, Automatic_CB, SM ); 75 CBM( Data.Automatic, Automatic_CB, SM );
72 CBM( Data.TriggerVPN, TriggersVPN_CB, SM ); 76 CBM( Data.TriggerVPN, TriggersVPN_CB, SM );
73 CBM( Data.Disabled, Disabled_CB, SM ); 77 CBM( Data.Disabled, Disabled_CB, SM );
74 CBM( Data.Confirm, Confirm_CB, SM ); 78 CBM( Data.Confirm, Confirm_CB, SM );
75 79
76 return SM; 80 return SM;
77} 81}
78 82
79void ProfileEdit::SLOT_Refresh( void ) { 83void ProfileEdit::SLOT_Refresh( void ) {
80 InterfaceInfo * II = NNI->connection()->assignedInterface(); 84 InterfaceInfo * II = NNI->networkSetup()->assignedInterface();
81 NSResources->system().refreshStatistics( *II ); 85 NSResources->system().refreshStatistics( *II );
82 RcvBytes_LBL->setText( II->RcvBytes ); 86 RcvBytes_LBL->setText( II->RcvBytes );
83 SndBytes_LBL->setText( II->SndBytes ); 87 SndBytes_LBL->setText( II->SndBytes );
84 RcvErrors_LBL->setText( II->RcvErrors ); 88 RcvErrors_LBL->setText( II->RcvErrors );
85 SndErrors_LBL->setText( II->SndErrors ); 89 SndErrors_LBL->setText( II->SndErrors );
86 RcvDropped_LBL->setText( II->RcvDropped ); 90 RcvDropped_LBL->setText( II->RcvDropped );
87 SndDropped_LBL->setText( II->SndDropped ); 91 SndDropped_LBL->setText( II->SndDropped );
88 Collisions_LBL->setText( II->Collisions ); 92 Collisions_LBL->setText( II->Collisions );
89} 93}
90 94
91void ProfileEdit::SLOT_AutoRefresh( bool ar ) { 95void ProfileEdit::SLOT_AutoRefresh( bool ar ) {
92 if( ar ) { 96 if( ar ) {
93 RefreshTimer.start( 1000 ); 97 RefreshTimer.start( 1000 );
94 SLOT_Refresh(); 98 SLOT_Refresh();
95 } else { 99 } else {
96 RefreshTimer.stop(); 100 RefreshTimer.stop();
97 } 101 }
98} 102}
diff --git a/noncore/settings/networksettings2/profile/profilerun.cpp b/noncore/settings/networksettings2/profile/profilerun.cpp
index acb67bd..48011ea 100644
--- a/noncore/settings/networksettings2/profile/profilerun.cpp
+++ b/noncore/settings/networksettings2/profile/profilerun.cpp
@@ -1,27 +1,31 @@
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 InterfaceInfo * II = networkSetup()->assignedInterface();
7
8 Log(( "Interface %p %p %p: %d\n", II,
9 netNode(), netNode()->networkSetup(), (II) ? II->IsUp : 0 ));
6 if( Data->Disabled ) { 10 if( Data->Disabled ) {
7 return Disabled; 11 return Disabled;
8 } 12 }
9 return Unknown; 13 return Unknown;
10} 14}
11 15
12QString ProfileRun::setMyState( NodeCollection * NC, Action_t A, bool ) { 16QString ProfileRun::setMyState( NetworkSetup * NC, Action_t A, bool ) {
13 odebug << "Profile " << Data->Disabled << oendl; 17 odebug << "Profile " << Data->Disabled << oendl;
14 if( A == Disable ) { 18 if( A == Disable ) {
15 if( ! Data->Disabled ) { 19 if( ! Data->Disabled ) {
16 Data->Disabled = 1; 20 Data->Disabled = 1;
17 NC->setModified( 1 ); 21 NC->setModified( 1 );
18 } 22 }
19 } else if( A == Enable ) { 23 } else if( A == Enable ) {
20 if( Data->Disabled ) { 24 if( Data->Disabled ) {
21 Data->Disabled = 0; 25 Data->Disabled = 0;
22 NC->setModified( 1 ); 26 NC->setModified( 1 );
23 } 27 }
24 } 28 }
25 29
26 return QString(); 30 return QString();
27} 31}
diff --git a/noncore/settings/networksettings2/profile/profilerun.h b/noncore/settings/networksettings2/profile/profilerun.h
index 2d48b15..9470c0f 100644
--- a/noncore/settings/networksettings2/profile/profilerun.h
+++ b/noncore/settings/networksettings2/profile/profilerun.h
@@ -1,33 +1,33 @@
1#ifndef PROFILERUN_H 1#ifndef PROFILERUN_H
2#define PROFILERUN_H 2#define PROFILERUN_H
3 3
4#include <netnode.h> 4#include <netnode.h>
5#include "profiledata.h" 5#include "profiledata.h"
6 6
7class ProfileRun : public RuntimeInfo { 7class ProfileRun : public RuntimeInfo {
8 8
9public : 9public :
10 10
11 ProfileRun( ANetNodeInstance * NNI, ProfileData & D ) : 11 ProfileRun( ANetNodeInstance * NNI, ProfileData & D ) :
12 RuntimeInfo( NNI ) 12 RuntimeInfo( NNI )
13 { Data = &D; } 13 { Data = &D; }
14 14
15 virtual RuntimeInfo * fullSetup( void ) 15 virtual RuntimeInfo * fullSetup( void )
16 { return this; } 16 { return this; }
17 virtual const QString & description( void ) 17 virtual const QString & description( void )
18 { return Data->Description; } 18 { return Data->Description; }
19 virtual bool triggersVPN( void ) 19 virtual bool triggersVPN( void )
20 { return Data->TriggerVPN; } 20 { return Data->TriggerVPN; }
21 21
22 State_t detectState( void ); 22 State_t detectState( void );
23 23
24protected : 24protected :
25 25
26 QString setMyState( NodeCollection * , Action_t, bool ); 26 QString setMyState( NetworkSetup * , Action_t, bool );
27 27
28private : 28private :
29 29
30 ProfileData * Data; 30 ProfileData * Data;
31 31
32}; 32};
33#endif 33#endif
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp
index 6d90ae0..6e2597c 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NN.cpp
@@ -1,60 +1,60 @@
1#include <resources.h> 1#include <resources.h>
2#include "usb_NN.h" 2#include "usb_NN.h"
3#include "usb_NNI.h" 3#include "usb_NNI.h"
4 4
5#include "netnodeinterface.h" 5#include "netnodeinterface.h"
6 6
7static const char * USBNeeds[] = 7static const char * USBNeeds[] =
8 { 0 8 { 0
9 }; 9 };
10 10
11static const char * USBProvides[] = 11static const char * USBProvides[] =
12 { "device", 12 { "device",
13 0 13 0
14 }; 14 };
15 15
16/** 16/**
17 * Constructor, find all of the possible interfaces 17 * Constructor, find all of the possible interfaces
18 */ 18 */
19USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) { 19USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) {
20 NSResources->addSystemFile( 20 NSResources->addSystemFile(
21 "interfaces", "/etc/network/interfaces", 1 ); 21 "interfaces", "/etc/network/interfaces", 1 );
22} 22}
23 23
24/** 24/**
25 * Delete any interfaces that we own. 25 * Delete any interfaces that we own.
26 */ 26 */
27USBNetNode::~USBNetNode(){ 27USBNetNode::~USBNetNode(){
28} 28}
29 29
30const QString USBNetNode::nodeDescription(){ 30const QString USBNetNode::nodeDescription(){
31 return tr("\ 31 return tr("\
32<p>Configure Ethernet over USB.</p>\ 32<p>Configure Ethernet over USB.</p>\
33<p>Use this for a computer to computer USB cable connection</p>\ 33<p>Use this for a computer to computer USB cable NetworkSetup</p>\
34" 34"
35); 35);
36} 36}
37 37
38ANetNodeInstance * USBNetNode::createInstance( void ) { 38ANetNodeInstance * USBNetNode::createInstance( void ) {
39 return new AUSB( this ); 39 return new AUSB( this );
40} 40}
41 41
42const char ** USBNetNode::needs( void ) { 42const char ** USBNetNode::needs( void ) {
43 return USBNeeds; 43 return USBNeeds;
44} 44}
45 45
46const char ** USBNetNode::provides( void ) { 46const char ** USBNetNode::provides( void ) {
47 return USBProvides; 47 return USBProvides;
48} 48}
49 49
50QString USBNetNode::genNic( long ) { 50QString USBNetNode::genNic( long ) {
51 return QString( "usbf" ); 51 return QString( "usbf" );
52} 52}
53 53
54void USBNetNode::setSpecificAttribute( QString & , QString & ) { 54void USBNetNode::setSpecificAttribute( QString & , QString & ) {
55} 55}
56 56
57void USBNetNode::saveSpecificAttribute( QTextStream & ) { 57void USBNetNode::saveSpecificAttribute( QTextStream & ) {
58} 58}
59 59
60OPIE_NS2_PLUGIN( NetNodeInterface_T<USBNetNode> ) 60OPIE_NS2_PLUGIN( NetNodeInterface_T<USBNetNode> )
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp
index 763644e..4082f7f 100644
--- a/noncore/settings/networksettings2/usb/usbrun.cpp
+++ b/noncore/settings/networksettings2/usb/usbrun.cpp
@@ -1,120 +1,120 @@
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 "usbrun.h" 5#include "usbrun.h"
6 6
7State_t USBRun::detectState( void ) { 7State_t USBRun::detectState( void ) {
8 8
9 // unavailable : no card found 9 // unavailable : no card found
10 // available : card found and assigned to us or free 10 // available : card found and assigned to us or free
11 // up : card found and assigned to us and up 11 // up : card found and assigned to us and up
12 12
13 NodeCollection * NC = nodeCollection(); 13 NetworkSetup * NC = networkSetup();
14 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); 14 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
15 System & Sys = NSResources->system(); 15 System & Sys = NSResources->system();
16 InterfaceInfo * Run; 16 InterfaceInfo * Run;
17 QFile F( S ); 17 QFile F( S );
18 Log(("Detecting for %s\n", NC->name().latin1() )); 18 Log(("Detecting for %s\n", NC->name().latin1() ));
19 19
20 if( F.open( IO_ReadOnly ) ) { 20 if( F.open( IO_ReadOnly ) ) {
21 // could open file -> read interface and assign 21 // could open file -> read interface and assign
22 QString X; 22 QString X;
23 QTextStream TS(&F); 23 QTextStream TS(&F);
24 X = TS.readLine(); 24 X = TS.readLine();
25 Log(("%s exists\n", S.latin1() )); 25 Log(("%s exists\n", S.latin1() ));
26 // find interface 26 // find interface
27 if( handlesInterface( X ) ) { 27 if( handlesInterface( X ) ) {
28 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 28 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
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 (Run->IsUp) ? IsUp : Available; 34 return (Run->IsUp) ? IsUp : Available;
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
42 if( ( Run = NC->assignedInterface() ) ) { 42 if( ( Run = NC->assignedInterface() ) ) {
43 // we already have an interface assigned -> still present ? 43 // we already have an interface assigned -> still present ?
44 if( ! Run->IsUp ) { 44 if( ! Run->IsUp ) {
45 // usb is still free -> keep assignment 45 // usb is still free -> keep assignment
46 return Available; 46 return Available;
47 } // else interface is up but NOT us -> some other profile 47 } // else interface is up but NOT us -> some other profile
48 } 48 }
49 49
50 // nothing (valid) assigned to us 50 // nothing (valid) assigned to us
51 NC->assignInterface( 0 ); 51 NC->assignInterface( 0 );
52 52
53 // find possible interface 53 // find possible interface
54 if( getInterface() ) { 54 if( getInterface() ) {
55 // proper type, and Not UP -> free 55 // proper type, and Not UP -> free
56 // usb cables are currently always available when requested 56 // usb cables are currently always available when requested
57 // until we can detect if we are plugged in 57 // until we can detect if we are plugged in
58 return Available; 58 return Available;
59 } 59 }
60 60
61 return Unavailable; 61 return Unavailable;
62} 62}
63 63
64QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) { 64QString USBRun::setMyState( NetworkSetup * NC, Action_t, bool ) {
65 65
66 InterfaceInfo * I = getInterface(); 66 InterfaceInfo * I = getInterface();
67 67
68 if( ! I ) { 68 if( ! I ) {
69 return QString("No usb device available"); 69 return QString("No usb device available");
70 } 70 }
71 71
72 Log(( "Grabbed USB interface %s\n", I->Name.latin1() )); 72 Log(( "Grabbed USB interface %s\n", I->Name.latin1() ));
73 // grab this interface 73 // grab this interface
74 NC->assignInterface( I ); 74 NC->assignInterface( I );
75 75
76 return QString(); 76 return QString();
77} 77}
78 78
79// get interface that is free or assigned to us 79// get interface that is free or assigned to us
80InterfaceInfo * USBRun::getInterface( void ) { 80InterfaceInfo * USBRun::getInterface( void ) {
81 81
82 System & S = NSResources->system(); 82 System & S = NSResources->system();
83 InterfaceInfo * best = 0, * Run; 83 InterfaceInfo * best = 0, * Run;
84 84
85 for( QDictIterator<InterfaceInfo> It(S.interfaces()); 85 for( QDictIterator<InterfaceInfo> It(S.interfaces());
86 It.current(); 86 It.current();
87 ++It ) { 87 ++It ) {
88 Run = It.current(); 88 Run = It.current();
89 89
90 Log(("%s %d %d=%d %d\n", 90 Log(("%s %d %d=%d %d\n",
91 Run->Name.latin1(), 91 Run->Name.latin1(),
92 handlesInterface( Run->Name ), 92 handlesInterface( Run->Name ),
93 Run->CardType, ARPHRD_ETHER, 93 Run->CardType, ARPHRD_ETHER,
94 ! Run->IsUp )); 94 ! Run->IsUp ));
95 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->assignedToNetworkSetup() == netNode()->networkSetup() ) {
101 // assigned to us 101 // assigned to us
102 return Run; 102 return Run;
103 } else if( ! Run->IsUp && 103 } else if( ! Run->IsUp &&
104 Run->assignedConnection() == 0 ) { 104 Run->assignedToNetworkSetup() == 0 ) {
105 // free 105 // free
106 best = Run; 106 best = Run;
107 } // UP or not assigned to us 107 } // UP or not assigned to us
108 } 108 }
109 } 109 }
110 return best; // can be 0 110 return best; // can be 0
111} 111}
112 112
113bool USBRun::handlesInterface( const QString & S ) { 113bool USBRun::handlesInterface( const QString & S ) {
114 return Pat.match( S ) >= 0; 114 return Pat.match( S ) >= 0;
115} 115}
116 116
117bool USBRun::handlesInterface( InterfaceInfo * I ) { 117bool USBRun::handlesInterface( InterfaceInfo * I ) {
118 return handlesInterface( I->Name ); 118 return handlesInterface( I->Name );
119} 119}
120 120
diff --git a/noncore/settings/networksettings2/usb/usbrun.h b/noncore/settings/networksettings2/usb/usbrun.h
index 6ce4fa2..0872f3d 100644
--- a/noncore/settings/networksettings2/usb/usbrun.h
+++ b/noncore/settings/networksettings2/usb/usbrun.h
@@ -1,36 +1,36 @@
1#ifndef USBRUN_H 1#ifndef USBRUN_H
2#define USBRUN_H 2#define USBRUN_H
3 3
4#include <netnode.h> 4#include <netnode.h>
5#include <qregexp.h> 5#include <qregexp.h>
6#include "usbdata.h" 6#include "usbdata.h"
7 7
8class USBRun : public RuntimeInfo { 8class USBRun : public RuntimeInfo {
9 9
10public : 10public :
11 11
12 USBRun( ANetNodeInstance * NNI, 12 USBRun( ANetNodeInstance * NNI,
13 USBData & Data ) : 13 USBData & Data ) :
14 RuntimeInfo( NNI ), 14 RuntimeInfo( NNI ),
15 Pat( "usb[0-9abcdef]" ) { 15 Pat( "usb[0-9abcdef]" ) {
16 } 16 }
17 17
18 virtual RuntimeInfo * device( void ) 18 virtual RuntimeInfo * device( void )
19 { return this; } 19 { return this; }
20 20
21 bool handlesInterface( const QString & I ); 21 bool handlesInterface( const QString & I );
22 bool handlesInterface( InterfaceInfo * ); 22 bool handlesInterface( InterfaceInfo * );
23 23
24 State_t detectState( void ); 24 State_t detectState( void );
25 25
26protected : 26protected :
27 27
28 QString setMyState( NodeCollection * , Action_t, bool ); 28 QString setMyState( NetworkSetup * , Action_t, bool );
29 29
30private : 30private :
31 31
32 InterfaceInfo * getInterface( void ); 32 InterfaceInfo * getInterface( void );
33 QRegExp Pat; 33 QRegExp Pat;
34 34
35}; 35};
36#endif 36#endif
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
index 96e9df2..7c2e77b 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
@@ -1,52 +1,52 @@
1#include "vpn_NN.h" 1#include "vpn_NN.h"
2#include "vpn_NNI.h" 2#include "vpn_NNI.h"
3 3
4#include "netnodeinterface.h" 4#include "netnodeinterface.h"
5 5
6static const char * VPNNeeds[] = 6static const char * VPNNeeds[] =
7 { 0 7 { 0
8 }; 8 };
9 9
10static const char * VPNProvides[] = 10static const char * VPNProvides[] =
11 { "connection", 11 { "NetworkSetup",
12 0 12 0
13 }; 13 };
14/** 14/**
15 * Constructor, find all of the possible interfaces 15 * Constructor, find all of the possible interfaces
16 */ 16 */
17VPNNetNode::VPNNetNode() : ANetNode(tr("VPN Connection")) { 17VPNNetNode::VPNNetNode() : ANetNode(tr("VPN NetworkSetup")) {
18} 18}
19 19
20/** 20/**
21 * Delete any interfaces that we own. 21 * Delete any interfaces that we own.
22 */ 22 */
23VPNNetNode::~VPNNetNode(){ 23VPNNetNode::~VPNNetNode(){
24} 24}
25 25
26const QString VPNNetNode::nodeDescription(){ 26const QString VPNNetNode::nodeDescription(){
27 return tr("\ 27 return tr("\
28<p>Configure private IP connection.</p>\ 28<p>Configure private IP NetworkSetup.</p>\
29<p>Defines Secure tunnels over non secure IP sessions</p>\ 29<p>Defines Secure tunnels over non secure IP sessions</p>\
30" 30"
31); 31);
32} 32}
33 33
34ANetNodeInstance * VPNNetNode::createInstance( void ) { 34ANetNodeInstance * VPNNetNode::createInstance( void ) {
35 return new AVPN( this ); 35 return new AVPN( this );
36} 36}
37 37
38const char ** VPNNetNode::needs( void ) { 38const char ** VPNNetNode::needs( void ) {
39 return VPNNeeds; 39 return VPNNeeds;
40} 40}
41 41
42const char ** VPNNetNode::provides( void ) { 42const char ** VPNNetNode::provides( void ) {
43 return VPNProvides; 43 return VPNProvides;
44} 44}
45 45
46void VPNNetNode::setSpecificAttribute( QString & , QString & ) { 46void VPNNetNode::setSpecificAttribute( QString & , QString & ) {
47} 47}
48 48
49void VPNNetNode::saveSpecificAttribute( QTextStream & ) { 49void VPNNetNode::saveSpecificAttribute( QTextStream & ) {
50} 50}
51 51
52OPIE_NS2_PLUGIN( NetNodeInterface_T<VPNNetNode> ) 52OPIE_NS2_PLUGIN( NetNodeInterface_T<VPNNetNode> )
diff --git a/noncore/settings/networksettings2/vpn/vpnrun.h b/noncore/settings/networksettings2/vpn/vpnrun.h
index 9a55625..e40aa87 100644
--- a/noncore/settings/networksettings2/vpn/vpnrun.h
+++ b/noncore/settings/networksettings2/vpn/vpnrun.h
@@ -1,27 +1,27 @@
1#ifndef VPNRUN_H 1#ifndef VPNRUN_H
2#define VPNRUN_H 2#define VPNRUN_H
3 3
4#include <netnode.h> 4#include <netnode.h>
5#include "vpndata.h" 5#include "vpndata.h"
6 6
7class VPNRun : public RuntimeInfo { 7class VPNRun : public RuntimeInfo {
8 8
9public : 9public :
10 10
11 VPNRun( ANetNodeInstance * NNI, VPNData & Data ) : 11 VPNRun( ANetNodeInstance * NNI, VPNData & Data ) :
12 RuntimeInfo( NNI ) 12 RuntimeInfo( NNI )
13 { } 13 { }
14 14
15 virtual RuntimeInfo * connection( void ) 15 virtual RuntimeInfo * connection( void )
16 { return this; } 16 { return this; }
17 17
18 State_t detectState( void ) 18 State_t detectState( void )
19 { return Unknown; } 19 { return Unknown; }
20 20
21protected : 21protected :
22 22
23 QString setMyState( NodeCollection * , Action_t, bool ) 23 QString setMyState( NetworkSetup * , Action_t, bool )
24 { return QString(); } 24 { return QString(); }
25}; 25};
26 26
27#endif 27#endif
diff --git a/noncore/settings/networksettings2/wlan/wlanedit.cpp b/noncore/settings/networksettings2/wlan/wlanedit.cpp
index 74174bf..73c0c7c 100644
--- a/noncore/settings/networksettings2/wlan/wlanedit.cpp
+++ b/noncore/settings/networksettings2/wlan/wlanedit.cpp
@@ -1,115 +1,115 @@
1#include <qlineedit.h> 1#include <qlineedit.h>
2#include <qprogressbar.h> 2#include <qprogressbar.h>
3#include <qcombobox.h> 3#include <qcombobox.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qregexp.h> 5#include <qregexp.h>
6#include <qcheckbox.h> 6#include <qcheckbox.h>
7#include <GUIUtils.h> 7#include <GUIUtils.h>
8#include <resources.h> 8#include <resources.h>
9#include <wextensions.h> 9#include <wextensions.h>
10 10
11#include "wlanedit.h" 11#include "wlanedit.h"
12#include "wlan_NN.h" 12#include "wlan_NN.h"
13#include "wlan_NNI.h" 13#include "wlan_NNI.h"
14 14
15WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : 15WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * TNNI ) :
16 WLanGUI( Parent ), RefreshTimer(this){ 16 WLanGUI( Parent ), RefreshTimer(this){
17 17
18 InterfaceInfo * II; 18 InterfaceInfo * II;
19 19
20 NNI = TNNI; 20 NNI = TNNI;
21 Dev = NNI->runtime()->device(); 21 Dev = NNI->runtime()->device();
22 WE = 0; 22 WE = 0;
23 if( ( II = NNI->connection()->assignedInterface() ) ) { 23 if( ( II = NNI->networkSetup()->assignedInterface() ) ) {
24 // show data 24 // show data
25 WE = new WExtensions( II->Name ); 25 WE = new WExtensions( II->Name );
26 26
27 if( WE->doesHaveWirelessExtensions() ) { 27 if( WE->doesHaveWirelessExtensions() ) {
28 QString S; 28 QString S;
29 Station_LBL->setText( WE->station() ); 29 Station_LBL->setText( WE->station() );
30 ESSID_LBL->setText( WE->essid() ); 30 ESSID_LBL->setText( WE->essid() );
31 Mode_LBL->setText( WE->mode() ); 31 Mode_LBL->setText( WE->mode() );
32 S.setNum( WE->frequency() ); 32 S.setNum( WE->frequency() );
33 Frequency_LBL->setText( S ); 33 Frequency_LBL->setText( S );
34 S.setNum( WE->channel() ); 34 S.setNum( WE->channel() );
35 Channel_LBL->setText( S ); 35 Channel_LBL->setText( S );
36 S.setNum( WE->rate() ); 36 S.setNum( WE->rate() );
37 Rate_LBL->setText( S ); 37 Rate_LBL->setText( S );
38 AP_LBL->setText( WE->ap() ); 38 AP_LBL->setText( WE->ap() );
39 39
40 SLOT_Refresh(); 40 SLOT_Refresh();
41 41
42 connect( &RefreshTimer, SIGNAL( timeout() ), 42 connect( &RefreshTimer, SIGNAL( timeout() ),
43 this, SLOT( SLOT_Refresh() ) ); 43 this, SLOT( SLOT_Refresh() ) );
44 } 44 }
45 } 45 }
46} 46}
47 47
48WLanEdit::~WLanEdit( void ) { 48WLanEdit::~WLanEdit( void ) {
49 if( WE ) 49 if( WE )
50 delete WE; 50 delete WE;
51} 51}
52 52
53QString WLanEdit::acceptable( void ) { 53QString WLanEdit::acceptable( void ) {
54 if( ESSID_LE->text().isEmpty() ) { 54 if( ESSID_LE->text().isEmpty() ) {
55 return QString("ESSID is mandatory"); 55 return QString("ESSID is mandatory");
56 } 56 }
57 if( SpecifyAP_CB->isChecked() && 57 if( SpecifyAP_CB->isChecked() &&
58 APMac_LE->text().isEmpty() ) { 58 APMac_LE->text().isEmpty() ) {
59 return QString("APMac must have value"); 59 return QString("APMac must have value");
60 } 60 }
61 return QString(); 61 return QString();
62} 62}
63 63
64void WLanEdit::showData( WLanData & Data ) { 64void WLanEdit::showData( WLanData & Data ) {
65 Mode_CB->setCurrentItem( Data.Mode ); 65 Mode_CB->setCurrentItem( Data.Mode );
66 ESSID_LE->setText( Data.ESSID ); 66 ESSID_LE->setText( Data.ESSID );
67 NodeName_LE->setText( Data.NodeName ); 67 NodeName_LE->setText( Data.NodeName );
68 SpecifyAP_CB->setChecked( Data.SpecificAP ); 68 SpecifyAP_CB->setChecked( Data.SpecificAP );
69 APMac_LE->setText( Data.APMac ); 69 APMac_LE->setText( Data.APMac );
70 70
71 EnableWEP_CB->setChecked( Data.Encrypted ); 71 EnableWEP_CB->setChecked( Data.Encrypted );
72 AcceptNonEncrypted_CB->setChecked( Data.AcceptNonEncrypted ); 72 AcceptNonEncrypted_CB->setChecked( Data.AcceptNonEncrypted );
73 Key1_LE->setText( Data.Key[0] ); 73 Key1_LE->setText( Data.Key[0] );
74 Key2_LE->setText( Data.Key[1] ); 74 Key2_LE->setText( Data.Key[1] );
75 Key3_LE->setText( Data.Key[2] ); 75 Key3_LE->setText( Data.Key[2] );
76 Key4_LE->setText( Data.Key[3] ); 76 Key4_LE->setText( Data.Key[3] );
77} 77}
78 78
79bool WLanEdit::commit( WLanData & Data ) { 79bool WLanEdit::commit( WLanData & Data ) {
80 bool SM = 0; 80 bool SM = 0;
81 81
82 TXTM( Data.ESSID, ESSID_LE, SM ); 82 TXTM( Data.ESSID, ESSID_LE, SM );
83 TXTM( Data.NodeName, NodeName_LE, SM ); 83 TXTM( Data.NodeName, NodeName_LE, SM );
84 TXTM( Data.APMac, APMac_LE, SM ); 84 TXTM( Data.APMac, APMac_LE, SM );
85 TXTM( Data.Key[0], Key1_LE, SM ); 85 TXTM( Data.Key[0], Key1_LE, SM );
86 TXTM( Data.Key[1], Key2_LE, SM ); 86 TXTM( Data.Key[1], Key2_LE, SM );
87 TXTM( Data.Key[2], Key3_LE, SM ); 87 TXTM( Data.Key[2], Key3_LE, SM );
88 TXTM( Data.Key[3], Key4_LE, SM ); 88 TXTM( Data.Key[3], Key4_LE, SM );
89 CBM( Data.SpecificAP, SpecifyAP_CB, SM ); 89 CBM( Data.SpecificAP, SpecifyAP_CB, SM );
90 CBM( Data.Encrypted, EnableWEP_CB, SM ); 90 CBM( Data.Encrypted, EnableWEP_CB, SM );
91 CBM( Data.AcceptNonEncrypted, AcceptNonEncrypted_CB, SM ); 91 CBM( Data.AcceptNonEncrypted, AcceptNonEncrypted_CB, SM );
92 CIM( Data.Mode, Mode_CB, SM ); 92 CIM( Data.Mode, Mode_CB, SM );
93 return 0; 93 return 0;
94} 94}
95 95
96void WLanEdit::SLOT_Refresh( void ) { 96void WLanEdit::SLOT_Refresh( void ) {
97 if( WE ) { 97 if( WE ) {
98 int signal, noise, quality; 98 int signal, noise, quality;
99 WE->stats( signal, noise, quality); 99 WE->stats( signal, noise, quality);
100 100
101 Signal_PB->setProgress( signal ); 101 Signal_PB->setProgress( signal );
102 Noise_PB->setProgress( noise ); 102 Noise_PB->setProgress( noise );
103 Quality_PB->setProgress( quality ); 103 Quality_PB->setProgress( quality );
104 } 104 }
105} 105}
106 106
107void WLanEdit::SLOT_AutoRefresh( bool ar ) { 107void WLanEdit::SLOT_AutoRefresh( bool ar ) {
108 if( ar ) { 108 if( ar ) {
109 RefreshTimer.start( 1000 ); 109 RefreshTimer.start( 1000 );
110 SLOT_Refresh(); 110 SLOT_Refresh();
111 } else { 111 } else {
112 RefreshTimer.stop(); 112 RefreshTimer.stop();
113 } 113 }
114} 114}
115 115
diff --git a/noncore/settings/networksettings2/wlan/wlanrun.cpp b/noncore/settings/networksettings2/wlan/wlanrun.cpp
index b15a560..a0c5884 100644
--- a/noncore/settings/networksettings2/wlan/wlanrun.cpp
+++ b/noncore/settings/networksettings2/wlan/wlanrun.cpp
@@ -1,120 +1,120 @@
1 1
2#include <qfile.h> 2#include <qfile.h>
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include <qstringlist.h> 4#include <qstringlist.h>
5#include <resources.h> 5#include <resources.h>
6#include "wlanrun.h" 6#include "wlanrun.h"
7 7
8State_t WLanRun::detectState( void ) { 8State_t WLanRun::detectState( void ) {
9 9
10 // unavailable : no card found 10 // unavailable : no card found
11 // available : card found and assigned to us or free 11 // available : card found and assigned to us or free
12 // up : card found and assigned to us and up 12 // up : card found and assigned to us and up
13 13
14 NodeCollection * NC = nodeCollection(); 14 NetworkSetup * NC = networkSetup();
15 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); 15 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
16 System & Sys = NSResources->system(); 16 System & Sys = NSResources->system();
17 InterfaceInfo * Run; 17 InterfaceInfo * Run;
18 18
19 QFile F( S ); 19 QFile F( S );
20 20
21 if( F.open( IO_ReadOnly ) ) { 21 if( F.open( IO_ReadOnly ) ) {
22 // could open file -> read interface and assign 22 // could open file -> read interface and assign
23 QString X; 23 QString X;
24 QTextStream TS(&F); 24 QTextStream TS(&F);
25 X = TS.readLine(); 25 X = TS.readLine();
26 // find interface 26 // find interface
27 if( handlesInterface( X ) ) { 27 if( handlesInterface( X ) ) {
28 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 28 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
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 (Run->IsUp) ? IsUp : Available; 34 return (Run->IsUp) ? IsUp : Available;
35 } 35 }
36 } 36 }
37 } 37 }
38 } 38 }
39 39
40 if( ( Run = NC->assignedInterface() ) ) { 40 if( ( Run = NC->assignedInterface() ) ) {
41 // we already have an interface assigned -> still present ? 41 // we already have an interface assigned -> still present ?
42 if( ! Run->IsUp ) { 42 if( ! Run->IsUp ) {
43 // usb is still free -> keep assignment 43 // usb is still free -> keep assignment
44 return Available; 44 return Available;
45 } // else interface is up but NOT us -> some other profile 45 } // else interface is up but NOT us -> some other profile
46 } 46 }
47 47
48 // nothing (valid) assigned to us 48 // nothing (valid) assigned to us
49 NC->assignInterface( 0 ); 49 NC->assignInterface( 0 );
50 50
51 // find possible interface 51 // find possible interface
52 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 52 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
53 It.current(); 53 It.current();
54 ++It ) { 54 ++It ) {
55 Run = It.current(); 55 Run = It.current();
56 if( handlesInterface( *Run ) && 56 if( handlesInterface( *Run ) &&
57 ( Run->CardType == ARPHRD_ETHER 57 ( Run->CardType == ARPHRD_ETHER
58#ifdef ARPHRD_IEEE1394 58#ifdef ARPHRD_IEEE1394
59 || Run->CardType == ARPHRD_IEEE1394 59 || Run->CardType == ARPHRD_IEEE1394
60#endif 60#endif
61 ) && 61 ) &&
62 ! Run->IsUp 62 ! Run->IsUp
63 ) { 63 ) {
64 // proper type, and Not UP -> free 64 // proper type, and Not UP -> free
65 return Off; 65 return Off;
66 } 66 }
67 } 67 }
68 68
69 return Unavailable; 69 return Unavailable;
70 70
71} 71}
72 72
73QString WLanRun::setMyState( NodeCollection * , Action_t , bool ) { 73QString WLanRun::setMyState( NetworkSetup * , Action_t , bool ) {
74 74
75 // we only handle activate and deactivate 75 // we only handle activate and deactivate
76 return QString(); 76 return QString();
77} 77}
78 78
79// get interface that is free or assigned to us 79// get interface that is free or assigned to us
80InterfaceInfo * WLanRun::getInterface( void ) { 80InterfaceInfo * WLanRun::getInterface( void ) {
81 81
82 System & S = NSResources->system(); 82 System & S = NSResources->system();
83 InterfaceInfo * best = 0, * Run; 83 InterfaceInfo * best = 0, * Run;
84 84
85 for( QDictIterator<InterfaceInfo> It(S.interfaces()); 85 for( QDictIterator<InterfaceInfo> It(S.interfaces());
86 It.current(); 86 It.current();
87 ++It ) { 87 ++It ) {
88 Run = It.current(); 88 Run = It.current();
89 if( handlesInterface( *Run ) && 89 if( handlesInterface( *Run ) &&
90 ( Run->CardType == ARPHRD_ETHER 90 ( Run->CardType == ARPHRD_ETHER
91#ifdef ARPHRD_IEEE1394 91#ifdef ARPHRD_IEEE1394
92 || Run->CardType == ARPHRD_IEEE1394 92 || Run->CardType == ARPHRD_IEEE1394
93#endif 93#endif
94 ) 94 )
95 ) { 95 ) {
96 // this is a LAN card 96 // this is a LAN card
97 if( Run->assignedConnection() == netNode()->connection() ) { 97 if( Run->assignedToNetworkSetup() == netNode()->networkSetup() ) {
98 // assigned to us 98 // assigned to us
99 return Run; 99 return Run;
100 } else if( Run->assignedConnection() == 0 ) { 100 } else if( Run->assignedToNetworkSetup() == 0 ) {
101 // free 101 // free
102 best = Run; 102 best = Run;
103 } 103 }
104 } 104 }
105 } 105 }
106 return best; // can be 0 106 return best; // can be 0
107} 107}
108 108
109bool WLanRun::handlesInterface( const QString & S ) { 109bool WLanRun::handlesInterface( const QString & S ) {
110 InterfaceInfo * II; 110 InterfaceInfo * II;
111 II = NSResources->system().interface( S ); 111 II = NSResources->system().interface( S );
112 if( ( II = NSResources->system().interface( S ) ) ) { 112 if( ( II = NSResources->system().interface( S ) ) ) {
113 return handlesInterface( *II ); 113 return handlesInterface( *II );
114 } 114 }
115 return Pat.match( S ) >= 0; 115 return Pat.match( S ) >= 0;
116} 116}
117 117
118bool WLanRun::handlesInterface( const InterfaceInfo & II ) { 118bool WLanRun::handlesInterface( const InterfaceInfo & II ) {
119 return ( Pat.match( II.Name ) < 0 ); 119 return ( Pat.match( II.Name ) < 0 );
120} 120}
diff --git a/noncore/settings/networksettings2/wlan/wlanrun.h b/noncore/settings/networksettings2/wlan/wlanrun.h
index fd325d4..e3e7735 100644
--- a/noncore/settings/networksettings2/wlan/wlanrun.h
+++ b/noncore/settings/networksettings2/wlan/wlanrun.h
@@ -1,36 +1,36 @@
1#ifndef WLANRUN_H 1#ifndef WLANRUN_H
2#define WLANRUN_H 2#define WLANRUN_H
3 3
4#include <qregexp.h> 4#include <qregexp.h>
5#include <netnode.h> 5#include <netnode.h>
6#include "wlandata.h" 6#include "wlandata.h"
7 7
8class WLanRun : public RuntimeInfo { 8class WLanRun : public RuntimeInfo {
9 9
10public : 10public :
11 11
12 WLanRun( ANetNodeInstance * NNI, WLanData & Data ) : 12 WLanRun( ANetNodeInstance * NNI, WLanData & Data ) :
13 RuntimeInfo( NNI ), 13 RuntimeInfo( NNI ),
14 Pat( "wlan[0-9]" ) { 14 Pat( "wlan[0-9]" ) {
15 } 15 }
16 16
17 virtual RuntimeInfo * device( void ) 17 virtual RuntimeInfo * device( void )
18 { return this; } 18 { return this; }
19 19
20 bool handlesInterface( const QString & I ); 20 bool handlesInterface( const QString & I );
21 bool handlesInterface( const InterfaceInfo & II ); 21 bool handlesInterface( const InterfaceInfo & II );
22 22
23 State_t detectState( void ); 23 State_t detectState( void );
24 24
25protected : 25protected :
26 26
27 QString setMyState( NodeCollection * , Action_t, bool ); 27 QString setMyState( NetworkSetup * , Action_t, bool );
28 28
29private : 29private :
30 30
31 InterfaceInfo * getInterface( void ); 31 InterfaceInfo * getInterface( void );
32 QRegExp Pat; 32 QRegExp Pat;
33 WLanData * Data; 33 WLanData * Data;
34}; 34};
35 35
36#endif 36#endif