summaryrefslogtreecommitdiff
authorwimpie <wimpie>2004-04-04 11:42:05 (UTC)
committer wimpie <wimpie>2004-04-04 11:42:05 (UTC)
commit8d2d2664e5f544b8292806e617deb7a0e4170dc0 (patch) (unidiff)
tree3e3764f82d52f8c32b0ed9d92c13ec483dc34114
parent321f82bb3d43cbab358434fef52fe76f17e7d1e3 (diff)
downloadopie-8d2d2664e5f544b8292806e617deb7a0e4170dc0.zip
opie-8d2d2664e5f544b8292806e617deb7a0e4170dc0.tar.gz
opie-8d2d2664e5f544b8292806e617deb7a0e4170dc0.tar.bz2
Error in generation of files
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h4
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h3
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp13
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth_NN.h8
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.cpp9
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.h4
-rw-r--r--noncore/settings/networksettings2/cable/cablerun.h3
-rw-r--r--noncore/settings/networksettings2/irda/irda_NN.cpp9
-rw-r--r--noncore/settings/networksettings2/irda/irda_NN.h4
-rw-r--r--noncore/settings/networksettings2/irda/irdarun.h3
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.cpp11
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.h4
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NNI.cpp14
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NNI.h2
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.cpp14
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.h6
-rw-r--r--noncore/settings/networksettings2/modem/modem_NN.cpp9
-rw-r--r--noncore/settings/networksettings2/modem/modem_NN.h4
-rw-r--r--noncore/settings/networksettings2/modem/modemrun.h3
-rw-r--r--noncore/settings/networksettings2/network/network_NN.cpp11
-rw-r--r--noncore/settings/networksettings2/network/network_NN.h4
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.cpp5
-rw-r--r--noncore/settings/networksettings2/network/networkedit.cpp6
-rw-r--r--noncore/settings/networksettings2/network/networkrun.cpp10
-rw-r--r--noncore/settings/networksettings2/network/networkrun.h3
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp86
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h23
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp5
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.cpp49
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.h6
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp206
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.cpp9
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.h4
-rw-r--r--noncore/settings/networksettings2/ppp/ppprun.cpp10
-rw-r--r--noncore/settings/networksettings2/ppp/ppprun.h8
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.cpp9
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.h4
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.cpp22
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.h3
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.cpp9
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.h4
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.cpp11
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.h1
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp29
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.h5
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.cpp9
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.h4
-rw-r--r--noncore/settings/networksettings2/vpn/vpnrun.h2
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.cpp15
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.h4
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NNI.cpp12
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NNI.h2
-rw-r--r--noncore/settings/networksettings2/wlan/wlanrun.h4
53 files changed, 564 insertions, 157 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
index e65b378..347da0c 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
@@ -4,24 +4,28 @@
4class BluetoothBNEPRun : public AsDevice { 4class BluetoothBNEPRun : public AsDevice {
5 5
6public : 6public :
7 7
8 BluetoothBNEPRun( ANetNodeInstance * NNI, 8 BluetoothBNEPRun( ANetNodeInstance * NNI,
9 BluetoothBNEPData & Data ) : AsDevice( NNI ) 9 BluetoothBNEPData & Data ) : AsDevice( NNI )
10 { } 10 { }
11 11
12 virtual long count( void ) 12 virtual long count( void )
13 { return 3; } 13 { return 3; }
14 virtual QString genNic( long nr ) 14 virtual QString genNic( long nr )
15 { QString S; return S.sprintf( "bnep%ld", nr ); } 15 { QString S; return S.sprintf( "bnep%ld", nr ); }
16
17 virtual AsDevice * asDevice( void )
18 { return (AsDevice *)this; }
19
16 virtual AsDevice * device( void ) 20 virtual AsDevice * device( void )
17 { return asDevice(); } 21 { return asDevice(); }
18 22
19protected : 23protected :
20 24
21 void detectState( NodeCollection * ) 25 void detectState( NodeCollection * )
22 { } 26 { }
23 27
24 bool setState( NodeCollection * , Action_t ) 28 bool setState( NodeCollection * , Action_t )
25 { return 0; } 29 { return 0; }
26 30
27 bool canSetState( State_t , Action_t ) 31 bool canSetState( State_t , Action_t )
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
index 87116e2..6a7902a 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
@@ -1,22 +1,25 @@
1#include <asline.h> 1#include <asline.h>
2#include "bluetoothRFCOMMdata.h" 2#include "bluetoothRFCOMMdata.h"
3 3
4class BluetoothRFCOMMRun : public AsLine { 4class BluetoothRFCOMMRun : public AsLine {
5 5
6public : 6public :
7 7
8 BluetoothRFCOMMRun( ANetNodeInstance * NNI, 8 BluetoothRFCOMMRun( ANetNodeInstance * NNI,
9 BluetoothRFCOMMData & Data ) : AsLine( NNI ) 9 BluetoothRFCOMMData & Data ) : AsLine( NNI )
10 { } 10 { }
11 11
12 virtual AsLine * asLine( void )
13 { return (AsLine *)this; }
14
12protected : 15protected :
13 16
14 void detectState( NodeCollection * ) 17 void detectState( NodeCollection * )
15 { } 18 { }
16 19
17 bool setState( NodeCollection * , Action_t ) 20 bool setState( NodeCollection * , Action_t )
18 { return 0; } 21 { return 0; }
19 22
20 bool canSetState( State_t , Action_t ) 23 bool canSetState( State_t , Action_t )
21 { return 0; } 24 { return 0; }
22}; 25};
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
index 91be153..47272c4 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
@@ -40,35 +40,42 @@ const char ** BluetoothBNEPNetNode::needs( void ) {
40 return BluetoothBNEPNeeds; 40 return BluetoothBNEPNeeds;
41} 41}
42 42
43const char * BluetoothBNEPNetNode::provides( void ) { 43const char * BluetoothBNEPNetNode::provides( void ) {
44 return "device"; 44 return "device";
45} 45}
46 46
47bool BluetoothBNEPNetNode::generateProperFilesFor( 47bool BluetoothBNEPNetNode::generateProperFilesFor(
48 ANetNodeInstance * ) { 48 ANetNodeInstance * ) {
49 return 1; 49 return 1;
50} 50}
51 51
52bool BluetoothBNEPNetNode::hasDataFor( const QString & ) { 52bool BluetoothBNEPNetNode::hasDataFor( const QString & S, bool DS ) {
53 return 0; 53 return DS && S == "interfaces";
54} 54}
55 55
56bool BluetoothBNEPNetNode::generateDataForCommonFile( 56bool BluetoothBNEPNetNode::generateDataForCommonFile(
57 SystemFile & , 57 SystemFile & ,
58 long , 58 long ,
59 ANetNodeInstance * ) { 59 ANetNodeInstance * ) {
60 return 1; 60 return 1;
61} 61}
62 62
63bool BluetoothBNEPNetNode::generateDeviceDataForCommonFile(
64 SystemFile & ,
65 long ,
66 ANetNodeInstance * ) {
67 return 1;
68}
69
63// 70//
64// 71//
65// BLUETOOTH PAN/NAP node 72// BLUETOOTH PAN/NAP node
66// 73//
67// 74//
68 75
69static const char * BluetoothRFCOMMNeeds[] = 76static const char * BluetoothRFCOMMNeeds[] =
70 { 0 77 { 0
71 }; 78 };
72 79
73BluetoothRFCOMMNetNode::BluetoothRFCOMMNetNode() : ANetNode() { 80BluetoothRFCOMMNetNode::BluetoothRFCOMMNetNode() : ANetNode() {
74} 81}
@@ -92,25 +99,25 @@ const char ** BluetoothRFCOMMNetNode::needs( void ) {
92 return BluetoothRFCOMMNeeds; 99 return BluetoothRFCOMMNeeds;
93} 100}
94 101
95const char * BluetoothRFCOMMNetNode::provides( void ) { 102const char * BluetoothRFCOMMNetNode::provides( void ) {
96 return "line"; 103 return "line";
97} 104}
98 105
99bool BluetoothRFCOMMNetNode::generateProperFilesFor( 106bool BluetoothRFCOMMNetNode::generateProperFilesFor(
100 ANetNodeInstance * ) { 107 ANetNodeInstance * ) {
101 return 0; 108 return 0;
102} 109}
103 110
104bool BluetoothRFCOMMNetNode::hasDataFor( const QString & ) { 111bool BluetoothRFCOMMNetNode::hasDataFor( const QString &, bool ) {
105 return 0; 112 return 0;
106} 113}
107 114
108bool BluetoothRFCOMMNetNode::generateDataForCommonFile( 115bool BluetoothRFCOMMNetNode::generateDataForCommonFile(
109 SystemFile & , 116 SystemFile & ,
110 long, 117 long,
111 ANetNodeInstance * ) { 118 ANetNodeInstance * ) {
112 return 0; 119 return 0;
113} 120}
114 121
115extern "C" { 122extern "C" {
116void create_plugin( QList<ANetNode> & PNN ) { 123void create_plugin( QList<ANetNode> & PNN ) {
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
index 705201c..d72b0d4 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
@@ -19,27 +19,29 @@ public:
19 19
20 virtual const QString nodeName() 20 virtual const QString nodeName()
21 { return tr("Bluetooth PAN/NAP"); } 21 { return tr("Bluetooth PAN/NAP"); }
22 22
23 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
24 24
25 virtual ANetNodeInstance * createInstance( void ); 25 virtual ANetNodeInstance * createInstance( void );
26 26
27 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
28 virtual const char * provides( void ); 28 virtual const char * provides( void );
29 29
30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
31 virtual bool hasDataFor( const QString & S ); 31 virtual bool hasDataFor( const QString & S, bool DS );
32 virtual bool generateDataForCommonFile( 32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); 33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 virtual bool generateDeviceDataForCommonFile(
35 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 36
35private: 37private:
36 38
37}; 39};
38 40
39class BluetoothRFCOMMNetNode : public ANetNode { 41class BluetoothRFCOMMNetNode : public ANetNode {
40 42
41 Q_OBJECT 43 Q_OBJECT
42 44
43public: 45public:
44 46
45 BluetoothRFCOMMNetNode(); 47 BluetoothRFCOMMNetNode();
@@ -50,26 +52,28 @@ public:
50 52
51 virtual const QString nodeName() 53 virtual const QString nodeName()
52 { return tr("Bluetooth serial link"); } 54 { return tr("Bluetooth serial link"); }
53 55
54 virtual const QString nodeDescription() ; 56 virtual const QString nodeDescription() ;
55 57
56 virtual ANetNodeInstance * createInstance( void ); 58 virtual ANetNodeInstance * createInstance( void );
57 59
58 virtual const char ** needs( void ); 60 virtual const char ** needs( void );
59 virtual const char * provides( void ); 61 virtual const char * provides( void );
60 62
61 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 63 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
62 virtual bool hasDataFor( const QString & S ); 64 virtual bool hasDataFor( const QString & S, bool );
63 virtual bool generateDataForCommonFile( 65 virtual bool generateDataForCommonFile(
64 SystemFile & SF, long, ANetNodeInstance * NNI ); 66 SystemFile & SF, long, ANetNodeInstance * NNI );
67 virtual bool generateDeviceDataForCommonFile(
68 SystemFile & SF, long, ANetNodeInstance * NNI );
65 69
66private: 70private:
67 71
68}; 72};
69 73
70extern "C" 74extern "C"
71{ 75{
72 void create_plugin( QList<ANetNode> & PNN ); 76 void create_plugin( QList<ANetNode> & PNN );
73}; 77};
74 78
75#endif 79#endif
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp
index 756903e..6f62772 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NN.cpp
@@ -32,28 +32,35 @@ const char ** CableNetNode::needs( void ) {
32 return CableNeeds; 32 return CableNeeds;
33} 33}
34 34
35const char * CableNetNode::provides( void ) { 35const char * CableNetNode::provides( void ) {
36 return "line"; 36 return "line";
37} 37}
38 38
39bool CableNetNode::generateProperFilesFor( 39bool CableNetNode::generateProperFilesFor(
40 ANetNodeInstance * ) { 40 ANetNodeInstance * ) {
41 return 1; 41 return 1;
42} 42}
43 43
44bool CableNetNode::hasDataFor( const QString & ) { 44bool CableNetNode::hasDataFor( const QString &, bool ) {
45 return 0; 45 return 0;
46} 46}
47 47
48bool CableNetNode::generateDataForCommonFile( 48bool CableNetNode::generateDataForCommonFile(
49 SystemFile & , 49 SystemFile & ,
50 long , 50 long ,
51 ANetNodeInstance * ) { 51 ANetNodeInstance * ) {
52 return 1; 52 return 1;
53} 53}
54 54
55bool CableNetNode::generateDeviceDataForCommonFile(
56 SystemFile & ,
57 long ,
58 ANetNodeInstance * ) {
59 return 1;
60}
61
55extern "C" { 62extern "C" {
56void create_plugin( QList<ANetNode> & PNN ) { 63void create_plugin( QList<ANetNode> & PNN ) {
57 PNN.append( new CableNetNode() ); 64 PNN.append( new CableNetNode() );
58} 65}
59} 66}
diff --git a/noncore/settings/networksettings2/cable/cable_NN.h b/noncore/settings/networksettings2/cable/cable_NN.h
index da99c1c..3875af6 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.h
+++ b/noncore/settings/networksettings2/cable/cable_NN.h
@@ -19,26 +19,28 @@ public:
19 19
20 virtual const QString nodeName() 20 virtual const QString nodeName()
21 { return tr("Cable Connection"); } 21 { return tr("Cable Connection"); }
22 22
23 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
24 24
25 virtual ANetNodeInstance * createInstance( void ); 25 virtual ANetNodeInstance * createInstance( void );
26 26
27 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
28 virtual const char * provides( void ); 28 virtual const char * provides( void );
29 29
30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
31 virtual bool hasDataFor( const QString & S ); 31 virtual bool hasDataFor( const QString & S, bool DS );
32 virtual bool generateDataForCommonFile( 32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); 33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 virtual bool generateDeviceDataForCommonFile(
35 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 36
35private: 37private:
36 38
37}; 39};
38 40
39extern "C" 41extern "C"
40{ 42{
41 void create_plugin( QList<ANetNode> & PNN ); 43 void create_plugin( QList<ANetNode> & PNN );
42}; 44};
43 45
44#endif 46#endif
diff --git a/noncore/settings/networksettings2/cable/cablerun.h b/noncore/settings/networksettings2/cable/cablerun.h
index 36ee640..7b341c4 100644
--- a/noncore/settings/networksettings2/cable/cablerun.h
+++ b/noncore/settings/networksettings2/cable/cablerun.h
@@ -1,21 +1,24 @@
1#include <asline.h> 1#include <asline.h>
2#include "cabledata.h" 2#include "cabledata.h"
3 3
4class CableRun : public AsLine { 4class CableRun : public AsLine {
5 5
6public : 6public :
7 7
8 CableRun( ANetNodeInstance * NNI, 8 CableRun( ANetNodeInstance * NNI,
9 CableData & Data ) : AsLine( NNI ) 9 CableData & Data ) : AsLine( NNI )
10 { D = &Data; } 10 { D = &Data; }
11 11
12 virtual AsLine * asLine( void )
13 { return (AsLine *)this; }
14
12protected : 15protected :
13 16
14 void detectState( NodeCollection * NC ); 17 void detectState( NodeCollection * NC );
15 bool setState( NodeCollection * NC, Action_t A ); 18 bool setState( NodeCollection * NC, Action_t A );
16 bool canSetState( State_t Curr, Action_t A ); 19 bool canSetState( State_t Curr, Action_t A );
17 20
18private : 21private :
19 22
20 CableData_t * D; 23 CableData_t * D;
21}; 24};
diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp
index 3b9c938..4347191 100644
--- a/noncore/settings/networksettings2/irda/irda_NN.cpp
+++ b/noncore/settings/networksettings2/irda/irda_NN.cpp
@@ -32,28 +32,35 @@ const char ** IRDANetNode::needs( void ) {
32 return IRDANeeds; 32 return IRDANeeds;
33} 33}
34 34
35const char * IRDANetNode::provides( void ) { 35const char * IRDANetNode::provides( void ) {
36 return "line"; 36 return "line";
37} 37}
38 38
39bool IRDANetNode::generateProperFilesFor( 39bool IRDANetNode::generateProperFilesFor(
40 ANetNodeInstance * ) { 40 ANetNodeInstance * ) {
41 return 1; 41 return 1;
42} 42}
43 43
44bool IRDANetNode::hasDataFor( const QString & ) { 44bool IRDANetNode::hasDataFor( const QString &, bool ) {
45 return 0; 45 return 0;
46} 46}
47 47
48bool IRDANetNode::generateDataForCommonFile( 48bool IRDANetNode::generateDataForCommonFile(
49 SystemFile & , 49 SystemFile & ,
50 long , 50 long ,
51 ANetNodeInstance * ) { 51 ANetNodeInstance * ) {
52 return 1; 52 return 1;
53} 53}
54 54
55bool IRDANetNode::generateDeviceDataForCommonFile(
56 SystemFile & ,
57 long ,
58 ANetNodeInstance * ) {
59 return 1;
60}
61
55extern "C" { 62extern "C" {
56void create_plugin( QList<ANetNode> & PNN ) { 63void create_plugin( QList<ANetNode> & PNN ) {
57 PNN.append( new IRDANetNode() ); 64 PNN.append( new IRDANetNode() );
58} 65}
59} 66}
diff --git a/noncore/settings/networksettings2/irda/irda_NN.h b/noncore/settings/networksettings2/irda/irda_NN.h
index 6574c17..a772f69 100644
--- a/noncore/settings/networksettings2/irda/irda_NN.h
+++ b/noncore/settings/networksettings2/irda/irda_NN.h
@@ -19,26 +19,28 @@ public:
19 19
20 virtual const QString nodeName() 20 virtual const QString nodeName()
21 { return tr("Infrared link"); } 21 { return tr("Infrared link"); }
22 22
23 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
24 24
25 virtual ANetNodeInstance * createInstance( void ); 25 virtual ANetNodeInstance * createInstance( void );
26 26
27 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
28 virtual const char * provides( void ); 28 virtual const char * provides( void );
29 29
30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
31 virtual bool hasDataFor( const QString & S ); 31 virtual bool hasDataFor( const QString & S, bool DS );
32 virtual bool generateDataForCommonFile( 32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); 33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 virtual bool generateDeviceDataForCommonFile(
35 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 36
35private: 37private:
36 38
37}; 39};
38 40
39extern "C" 41extern "C"
40{ 42{
41 void create_plugin( QList<ANetNode> & PNN ); 43 void create_plugin( QList<ANetNode> & PNN );
42}; 44};
43 45
44#endif 46#endif
diff --git a/noncore/settings/networksettings2/irda/irdarun.h b/noncore/settings/networksettings2/irda/irdarun.h
index adc9c24..d9fe5e8 100644
--- a/noncore/settings/networksettings2/irda/irdarun.h
+++ b/noncore/settings/networksettings2/irda/irdarun.h
@@ -1,22 +1,25 @@
1#include <asline.h> 1#include <asline.h>
2#include "irdadata.h" 2#include "irdadata.h"
3 3
4class IRDARun : public AsLine { 4class IRDARun : public AsLine {
5 5
6public : 6public :
7 7
8 IRDARun( ANetNodeInstance * NNI, 8 IRDARun( ANetNodeInstance * NNI,
9 IRDAData & Data ) : AsLine( NNI ) 9 IRDAData & Data ) : AsLine( NNI )
10 { } 10 { }
11 11
12 virtual AsLine * asLine( void )
13 { return (AsLine *)this; }
14
12protected : 15protected :
13 16
14 void detectState( NodeCollection * ) 17 void detectState( NodeCollection * )
15 { } 18 { }
16 19
17 bool setState( NodeCollection * , Action_t ) 20 bool setState( NodeCollection * , Action_t )
18 { return 0; } 21 { return 0; }
19 22
20 bool canSetState( State_t , Action_t ) 23 bool canSetState( State_t , Action_t )
21 { return 0; } 24 { return 0; }
22}; 25};
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
index a45496d..7d36918 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
@@ -33,28 +33,35 @@ const char ** LanCardNetNode::needs( void ) {
33 return LanCardNeeds; 33 return LanCardNeeds;
34} 34}
35 35
36const char * LanCardNetNode::provides( void ) { 36const char * LanCardNetNode::provides( void ) {
37 return "device"; 37 return "device";
38} 38}
39 39
40bool LanCardNetNode::generateProperFilesFor( 40bool LanCardNetNode::generateProperFilesFor(
41 ANetNodeInstance * ) { 41 ANetNodeInstance * ) {
42 return 1; 42 return 1;
43} 43}
44 44
45bool LanCardNetNode::hasDataFor( const QString & ) { 45bool LanCardNetNode::hasDataFor( const QString & S, bool DS ) {
46 return 0; 46 return DS && S == "interfaces";
47} 47}
48 48
49bool LanCardNetNode::generateDataForCommonFile( 49bool LanCardNetNode::generateDataForCommonFile(
50 SystemFile & , 50 SystemFile & ,
51 long , 51 long ,
52 ANetNodeInstance * ) { 52 ANetNodeInstance * ) {
53 return 1; 53 return 1;
54} 54}
55 55
56bool LanCardNetNode::generateDeviceDataForCommonFile(
57 SystemFile & S ,
58 long DevNr ,
59 ANetNodeInstance * NNI ) {
60 return ((ALanCard *)NNI)->generateDeviceDataForCommonFile(S, DevNr);
61}
62
56extern "C" { 63extern "C" {
57void create_plugin( QList<ANetNode> & PNN ) { 64void create_plugin( QList<ANetNode> & PNN ) {
58 PNN.append( new LanCardNetNode() ); 65 PNN.append( new LanCardNetNode() );
59} 66}
60} 67}
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h
index 71b49d0..9690c76 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.h
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.h
@@ -19,26 +19,28 @@ public:
19 19
20 virtual const QString nodeName() 20 virtual const QString nodeName()
21 { return tr("LAN card"); } 21 { return tr("LAN card"); }
22 22
23 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
24 24
25 virtual ANetNodeInstance * createInstance( void ); 25 virtual ANetNodeInstance * createInstance( void );
26 26
27 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
28 virtual const char * provides( void ); 28 virtual const char * provides( void );
29 29
30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
31 virtual bool hasDataFor( const QString & S ); 31 virtual bool hasDataFor( const QString & S, bool DS );
32 virtual bool generateDataForCommonFile( 32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); 33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 virtual bool generateDeviceDataForCommonFile(
35 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 36
35private: 37private:
36 38
37}; 39};
38 40
39extern "C" 41extern "C"
40{ 42{
41 void create_plugin( QList<ANetNode> & PNN ); 43 void create_plugin( QList<ANetNode> & PNN );
42}; 44};
43 45
44#endif 46#endif
diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
index 9595e2e..a6401db 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
@@ -33,12 +33,26 @@ QWidget * ALanCard::edit( QWidget * parent ) {
33 GUI->showData( Data ); 33 GUI->showData( Data );
34 return GUI; 34 return GUI;
35} 35}
36 36
37QString ALanCard::acceptable( void ) { 37QString ALanCard::acceptable( void ) {
38 return ( GUI ) ? GUI->acceptable( ) : QString(); 38 return ( GUI ) ? GUI->acceptable( ) : QString();
39} 39}
40 40
41void ALanCard::commit( void ) { 41void ALanCard::commit( void ) {
42 if( GUI && GUI->commit( Data ) ) 42 if( GUI && GUI->commit( Data ) )
43 setModified( 1 ); 43 setModified( 1 );
44} 44}
45
46bool ALanCard::generateDeviceDataForCommonFile( SystemFile & S, long DevNr ) {
47 AsDevice * Dev = runtime()->device();
48 QString NIC = Dev->genNic( DevNr );
49
50 if( S.name() == "interfaces" ) {
51 // generate mapping stanza for this interface
52 S << "# check if " << NIC << " can be brought UP" << endl;
53 S << "mapping " << NIC << endl;
54 S << " script networksettings2-request" << endl << endl;
55 }
56 return 0;
57}
58
diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.h b/noncore/settings/networksettings2/lancard/lancard_NNI.h
index 8fc8868..16f5f56 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NNI.h
+++ b/noncore/settings/networksettings2/lancard/lancard_NNI.h
@@ -18,24 +18,26 @@ public :
18 QString acceptable( void ); 18 QString acceptable( void );
19 void commit( void ); 19 void commit( void );
20 20
21 RuntimeInfo * runtime( void ) 21 RuntimeInfo * runtime( void )
22 { if( RT == 0 ) 22 { if( RT == 0 )
23 RT = new LanCardRun( this, Data ); 23 RT = new LanCardRun( this, Data );
24 return RT; 24 return RT;
25 } 25 }
26 26
27 virtual void * data( void ) 27 virtual void * data( void )
28 { return (void *)&Data; } 28 { return (void *)&Data; }
29 29
30 bool generateDeviceDataForCommonFile( SystemFile & S, long DevNr );
31
30protected : 32protected :
31 33
32 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 34 virtual void setSpecificAttribute( QString & Attr, QString & Value );
33 virtual void saveSpecificAttribute( QTextStream & TS ); 35 virtual void saveSpecificAttribute( QTextStream & TS );
34 36
35private : 37private :
36 38
37 LanCardEdit * GUI; 39 LanCardEdit * GUI;
38 LanCardData Data; 40 LanCardData Data;
39 LanCardRun * RT; 41 LanCardRun * RT;
40 42
41}; 43};
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.cpp b/noncore/settings/networksettings2/lancard/lancardrun.cpp
index b3b592b..951756d 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.cpp
+++ b/noncore/settings/networksettings2/lancard/lancardrun.cpp
@@ -27,25 +27,34 @@ void LanCardRun::detectState( NodeCollection * NC ) {
27 ++It ) { 27 ++It ) {
28 Run = It.current(); 28 Run = It.current();
29 if( X == Run->Name ) { 29 if( X == Run->Name ) {
30 Run->assignNode( netNode() ); 30 Run->assignNode( netNode() );
31 assignInterface( Run ); 31 assignInterface( Run );
32 NC->setCurrentState( IsUp ); 32 NC->setCurrentState( IsUp );
33 return; 33 return;
34 } 34 }
35 } 35 }
36 } 36 }
37 } 37 }
38 38
39 // we are certainly not UP 39 if( ( Run = assignedInterface() ) ) {
40 // we already have an interface assigned -> still present ?
41 if( ! Run->IsUp ) {
42 // usb is still free -> keep assignment
43 NC->setCurrentState( Available );
44 return;
45 } // else interface is up but NOT us -> some other profile
46 }
47
48 // nothing (valid) assigned to us
40 assignInterface( 0 ); 49 assignInterface( 0 );
41 50
42 // find possible interface 51 // find possible interface
43 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 52 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
44 It.current(); 53 It.current();
45 ++It ) { 54 ++It ) {
46 Run = It.current(); 55 Run = It.current();
47 if( handlesInterface( Run->Name ) && 56 if( handlesInterface( Run->Name ) &&
48 Run->CardType == ARPHRD_ETHER && 57 Run->CardType == ARPHRD_ETHER &&
49 ! Run->IsUp 58 ! Run->IsUp
50 ) { 59 ) {
51 // proper type, and Not UP -> free 60 // proper type, and Not UP -> free
@@ -78,26 +87,25 @@ bool LanCardRun::setState( NodeCollection * NC, Action_t A ) {
78 // we get back is NOT assigned 87 // we get back is NOT assigned
79 N->assignNode( netNode() ); 88 N->assignNode( netNode() );
80 assignInterface( N ); 89 assignInterface( N );
81 NC->setCurrentState( Available ); 90 NC->setCurrentState( Available );
82 return 1; 91 return 1;
83 } 92 }
84 case Deactivate : 93 case Deactivate :
85 if( NC->currentState() == IsUp ) { 94 if( NC->currentState() == IsUp ) {
86 // bring down first 95 // bring down first
87 if( ! connection()->setState( Down ) ) 96 if( ! connection()->setState( Down ) )
88 // could not ... 97 // could not ...
89 return 0; 98 return 0;
90 } 99 } else if( NC->currentState() != Available ) {
91 if( NC->currentState() != Available ) {
92 return 1; 100 return 1;
93 } 101 }
94 assignedInterface()->assignNode( 0 ); // release 102 assignedInterface()->assignNode( 0 ); // release
95 assignInterface( 0 ); 103 assignInterface( 0 );
96 NC->setCurrentState( Off ); 104 NC->setCurrentState( Off );
97 return 1; 105 return 1;
98 default : 106 default :
99 // FT 107 // FT
100 break; 108 break;
101 } 109 }
102 return 0; 110 return 0;
103} 111}
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.h b/noncore/settings/networksettings2/lancard/lancardrun.h
index 5f004e0..8dbd1b1 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.h
+++ b/noncore/settings/networksettings2/lancard/lancardrun.h
@@ -9,26 +9,30 @@ class LanCardRun : public AsDevice {
9 9
10public : 10public :
11 11
12 LanCardRun( ANetNodeInstance * NNI, 12 LanCardRun( ANetNodeInstance * NNI,
13 LanCardData & Data ) : AsDevice( NNI ), 13 LanCardData & Data ) : AsDevice( NNI ),
14 Pat( "eth[0-9]" ) 14 Pat( "eth[0-9]" )
15 { } 15 { }
16 16
17 virtual long count( void ) 17 virtual long count( void )
18 { return 2; } 18 { return 2; }
19 virtual QString genNic( long nr ) 19 virtual QString genNic( long nr )
20 { QString S; return S.sprintf( "eth%ld", nr ); } 20 { QString S; return S.sprintf( "eth%ld", nr ); }
21
21 virtual AsDevice * device( void ) 22 virtual AsDevice * device( void )
22 { return asDevice(); } 23 { return (AsDevice *)this; }
24
25 virtual AsDevice * asDevice( void )
26 { return (AsDevice *)this; }
23 27
24protected : 28protected :
25 29
26 void detectState( NodeCollection * NC ); 30 void detectState( NodeCollection * NC );
27 bool setState( NodeCollection * NC, Action_t A ); 31 bool setState( NodeCollection * NC, Action_t A );
28 bool canSetState( State_t Curr, Action_t A ); 32 bool canSetState( State_t Curr, Action_t A );
29 33
30 bool handlesInterface( const QString & I ); 34 bool handlesInterface( const QString & I );
31 35
32private : 36private :
33 37
34 InterfaceInfo * getInterface( void ); 38 InterfaceInfo * getInterface( void );
diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp
index 48e1ad8..2807963 100644
--- a/noncore/settings/networksettings2/modem/modem_NN.cpp
+++ b/noncore/settings/networksettings2/modem/modem_NN.cpp
@@ -33,28 +33,35 @@ const char ** ModemNetNode::needs( void ) {
33 return ModemNeeds; 33 return ModemNeeds;
34} 34}
35 35
36const char * ModemNetNode::provides( void ) { 36const char * ModemNetNode::provides( void ) {
37 return "line"; 37 return "line";
38} 38}
39 39
40bool ModemNetNode::generateProperFilesFor( 40bool ModemNetNode::generateProperFilesFor(
41 ANetNodeInstance * ) { 41 ANetNodeInstance * ) {
42 return 1; 42 return 1;
43} 43}
44 44
45bool ModemNetNode::hasDataFor( const QString & ) { 45bool ModemNetNode::hasDataFor( const QString &, bool ) {
46 return 0; 46 return 0;
47} 47}
48 48
49bool ModemNetNode::generateDataForCommonFile( 49bool ModemNetNode::generateDataForCommonFile(
50 SystemFile & , 50 SystemFile & ,
51 long , 51 long ,
52 ANetNodeInstance * ) { 52 ANetNodeInstance * ) {
53 return 1; 53 return 1;
54} 54}
55 55
56bool ModemNetNode::generateDeviceDataForCommonFile(
57 SystemFile & ,
58 long ,
59 ANetNodeInstance * ) {
60 return 1;
61}
62
56extern "C" { 63extern "C" {
57void create_plugin( QList<ANetNode> & PNN ) { 64void create_plugin( QList<ANetNode> & PNN ) {
58 PNN.append( new ModemNetNode() ); 65 PNN.append( new ModemNetNode() );
59} 66}
60} 67}
diff --git a/noncore/settings/networksettings2/modem/modem_NN.h b/noncore/settings/networksettings2/modem/modem_NN.h
index 5eceed2..bd921c6 100644
--- a/noncore/settings/networksettings2/modem/modem_NN.h
+++ b/noncore/settings/networksettings2/modem/modem_NN.h
@@ -19,26 +19,28 @@ public:
19 19
20 virtual const QString nodeName() 20 virtual const QString nodeName()
21 { return tr("Dialup modem"); } 21 { return tr("Dialup modem"); }
22 22
23 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
24 24
25 virtual ANetNodeInstance * createInstance( void ); 25 virtual ANetNodeInstance * createInstance( void );
26 26
27 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
28 virtual const char * provides( void ); 28 virtual const char * provides( void );
29 29
30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
31 virtual bool hasDataFor( const QString & S ); 31 virtual bool hasDataFor( const QString & S, bool DS );
32 virtual bool generateDataForCommonFile( 32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); 33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 virtual bool generateDeviceDataForCommonFile(
35 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 36
35private: 37private:
36 38
37}; 39};
38 40
39extern "C" 41extern "C"
40{ 42{
41 void create_plugin( QList<ANetNode> & PNN ); 43 void create_plugin( QList<ANetNode> & PNN );
42}; 44};
43 45
44#endif 46#endif
diff --git a/noncore/settings/networksettings2/modem/modemrun.h b/noncore/settings/networksettings2/modem/modemrun.h
index 719ab2f..6d1662b 100644
--- a/noncore/settings/networksettings2/modem/modemrun.h
+++ b/noncore/settings/networksettings2/modem/modemrun.h
@@ -1,22 +1,25 @@
1#include <asline.h> 1#include <asline.h>
2#include "modemdata.h" 2#include "modemdata.h"
3 3
4class ModemRun : public AsLine { 4class ModemRun : public AsLine {
5 5
6public : 6public :
7 7
8 ModemRun( ANetNodeInstance * NNI, 8 ModemRun( ANetNodeInstance * NNI,
9 ModemData & Data ) : AsLine ( NNI ) 9 ModemData & Data ) : AsLine ( NNI )
10 { } 10 { }
11 11
12 virtual AsLine * asLine( void )
13 { return (AsLine *)this; }
14
12protected : 15protected :
13 16
14 void detectState( NodeCollection * ) 17 void detectState( NodeCollection * )
15 { } 18 { }
16 19
17 bool setState( NodeCollection *, Action_t ) 20 bool setState( NodeCollection *, Action_t )
18 { return 0; } 21 { return 0; }
19 22
20 bool canSetState( State_t, Action_t ) 23 bool canSetState( State_t, Action_t )
21 { return 0; } 24 { return 0; }
22}; 25};
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp
index bb371ad..a6b15c6 100644
--- a/noncore/settings/networksettings2/network/network_NN.cpp
+++ b/noncore/settings/networksettings2/network/network_NN.cpp
@@ -34,31 +34,38 @@ const char ** NetworkNetNode::needs( void ) {
34 return NetworkNeeds; 34 return NetworkNeeds;
35} 35}
36 36
37const char * NetworkNetNode::provides( void ) { 37const char * NetworkNetNode::provides( void ) {
38 return "connection"; 38 return "connection";
39} 39}
40 40
41bool NetworkNetNode::generateProperFilesFor( 41bool NetworkNetNode::generateProperFilesFor(
42 ANetNodeInstance * ) { 42 ANetNodeInstance * ) {
43 return 1; 43 return 1;
44} 44}
45 45
46bool NetworkNetNode::hasDataFor( const QString & S ) { 46bool NetworkNetNode::hasDataFor( const QString & S, bool DS ) {
47 if( S == "interfaces" ) { 47 if( ! DS && S == "interfaces" ) {
48 return 1; 48 return 1;
49 } 49 }
50 return 0; 50 return 0;
51} 51}
52 52
53bool NetworkNetNode::generateDataForCommonFile( 53bool NetworkNetNode::generateDataForCommonFile(
54 SystemFile & S, 54 SystemFile & S,
55 long DevNr, 55 long DevNr,
56 ANetNodeInstance * NNI ) { 56 ANetNodeInstance * NNI ) {
57 return ((ANetwork *)NNI)->generateDataForCommonFile(S, DevNr); 57 return ((ANetwork *)NNI)->generateDataForCommonFile(S, DevNr);
58} 58}
59 59
60bool NetworkNetNode::generateDeviceDataForCommonFile(
61 SystemFile & ,
62 long ,
63 ANetNodeInstance * ) {
64 return 1;
65}
66
60extern "C" { 67extern "C" {
61void create_plugin( QList<ANetNode> & PNN ) { 68void create_plugin( QList<ANetNode> & PNN ) {
62 PNN.append( new NetworkNetNode() ); 69 PNN.append( new NetworkNetNode() );
63} 70}
64} 71}
diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h
index 220e00f..62a3f10 100644
--- a/noncore/settings/networksettings2/network/network_NN.h
+++ b/noncore/settings/networksettings2/network/network_NN.h
@@ -19,26 +19,28 @@ public:
19 19
20 virtual const QString nodeName() 20 virtual const QString nodeName()
21 { return tr("IP Configuration"); } 21 { return tr("IP Configuration"); }
22 22
23 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
24 24
25 virtual ANetNodeInstance * createInstance( void ); 25 virtual ANetNodeInstance * createInstance( void );
26 26
27 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
28 virtual const char * provides( void ); 28 virtual const char * provides( void );
29 29
30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
31 virtual bool hasDataFor( const QString & S ); 31 virtual bool hasDataFor( const QString & S, bool DS );
32 virtual bool generateDataForCommonFile( 32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); 33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 virtual bool generateDeviceDataForCommonFile(
35 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 36
35private: 37private:
36 38
37}; 39};
38 40
39extern "C" 41extern "C"
40{ 42{
41 void create_plugin( QList<ANetNode> & PNN ); 43 void create_plugin( QList<ANetNode> & PNN );
42}; 44};
43 45
44#endif 46#endif
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp
index 7130764..eac2d66 100644
--- a/noncore/settings/networksettings2/network/network_NNI.cpp
+++ b/noncore/settings/networksettings2/network/network_NNI.cpp
@@ -95,29 +95,24 @@ QString ANetwork::acceptable( void ) {
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::generateDataForCommonFile( SystemFile & S, long DevNr ) { 102bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) {
103 AsDevice * Dev = runtime()->device(); 103 AsDevice * Dev = runtime()->device();
104 QString NIC = Dev->genNic( DevNr ); 104 QString NIC = Dev->genNic( DevNr );
105 105
106 if( S.name() == "interfaces" ) { 106 if( S.name() == "interfaces" ) {
107 // generate mapping stanza for this interface
108 S << "# check if " << NIC << " can be brought UP" << endl;
109 S << "mapping " << NIC << endl;
110 S << " script networksettings2-request" << endl << endl;
111
112 // we can safely call from here since device item is deeper 107 // we can safely call from here since device item is deeper
113 if( Data.UseDHCP ) { 108 if( Data.UseDHCP ) {
114 S << "iface " << NIC << "-c" << connection()->number() << 109 S << "iface " << NIC << "-c" << connection()->number() <<
115 "-allowed inet dhcp" << endl; 110 "-allowed inet dhcp" << endl;
116 S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << 111 S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() <<
117 ".up" << Data.IPAddress << endl; 112 ".up" << Data.IPAddress << endl;
118 if( Data.SendHostname ) { 113 if( Data.SendHostname ) {
119 S << " hostname "<< Data.Hostname << endl; 114 S << " hostname "<< Data.Hostname << endl;
120 } 115 }
121 116
122 S << " down rm -f /tmp/profile-" << connection()->number() << 117 S << " down rm -f /tmp/profile-" << connection()->number() <<
123 ".up" << Data.IPAddress << endl; 118 ".up" << Data.IPAddress << endl;
diff --git a/noncore/settings/networksettings2/network/networkedit.cpp b/noncore/settings/networksettings2/network/networkedit.cpp
index b17d745..182213b 100644
--- a/noncore/settings/networksettings2/network/networkedit.cpp
+++ b/noncore/settings/networksettings2/network/networkedit.cpp
@@ -43,31 +43,31 @@ QString NetworkEdit::acceptable( void ) {
43 if( Broadcast_LE->text().isEmpty() ) 43 if( Broadcast_LE->text().isEmpty() )
44 return tr("Broadcast needed"); 44 return tr("Broadcast needed");
45 if( SubnetMask_LE->text().isEmpty() ) 45 if( SubnetMask_LE->text().isEmpty() )
46 return tr("Subnet mask needed"); 46 return tr("Subnet mask needed");
47 47
48 // valid IP ? 48 // valid IP ?
49 if( ! validIP( IPAddress_LE->text() ) ) 49 if( ! validIP( IPAddress_LE->text() ) )
50 return tr("IPAddress not valid"); 50 return tr("IPAddress not valid");
51 if( ! validIP( SubnetMask_LE->text() ) ) 51 if( ! validIP( SubnetMask_LE->text() ) )
52 return tr("Subnet mask not valid"); 52 return tr("Subnet mask not valid");
53 if( ! validIP( Broadcast_LE->text() ) ) 53 if( ! validIP( Broadcast_LE->text() ) )
54 return tr("Broadcast address not valid"); 54 return tr("Broadcast address not valid");
55 if( Gateway_LE->text().isEmpty() && 55 if( Gateway_LE->text().isEmpty() ||
56 ! validIP( Gateway_LE->text() ) ) 56 ! validIP( Gateway_LE->text() ) )
57 return tr("Gateway address not valid"); 57 return tr("Gateway address not valid");
58 if( DNS1_LE->text().isEmpty() && 58 if( ! DNS1_LE->text().isEmpty() &&
59 ! validIP( DNS1_LE->text() ) ) 59 ! validIP( DNS1_LE->text() ) )
60 return tr("DNS1 address not valid"); 60 return tr("DNS1 address not valid");
61 if( DNS2_LE->text().isEmpty() && 61 if( ! DNS2_LE->text().isEmpty() &&
62 ! validIP( DNS2_LE->text() ) ) 62 ! validIP( DNS2_LE->text() ) )
63 return tr("DNS2 address not valid"); 63 return tr("DNS2 address not valid");
64 return QString(); 64 return QString();
65} 65}
66 66
67bool NetworkEdit::commit( NetworkData_t & Data ) { 67bool NetworkEdit::commit( NetworkData_t & Data ) {
68 bool SM = 0; 68 bool SM = 0;
69 CBM( Data.UseDHCP, DHCP_CB, SM ); 69 CBM( Data.UseDHCP, DHCP_CB, SM );
70 TXTM( Data.IPAddress, IPAddress_LE, SM ); 70 TXTM( Data.IPAddress, IPAddress_LE, SM );
71 CBM( Data.SendHostname, SendHostname_CB, SM ); 71 CBM( Data.SendHostname, SendHostname_CB, SM );
72 TXTM( Data.Hostname, Hostname_LE, SM ); 72 TXTM( Data.Hostname, Hostname_LE, SM );
73 TXTM( Data.Gateway, Gateway_LE, SM ); 73 TXTM( Data.Gateway, Gateway_LE, SM );
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp
index 8deca14..f34fdbf 100644
--- a/noncore/settings/networksettings2/network/networkrun.cpp
+++ b/noncore/settings/networksettings2/network/networkrun.cpp
@@ -17,35 +17,37 @@ void NetworkRun::detectState( NodeCollection * NC ) {
17} 17}
18 18
19bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { 19bool NetworkRun::setState( NodeCollection * NC, Action_t A ) {
20 // we handle UP and DOWN 20 // we handle UP and DOWN
21 RuntimeInfo * RI = netNode()->nextNode()->runtime(); 21 RuntimeInfo * RI = netNode()->nextNode()->runtime();
22 AsDevice * Next = RI->asDevice(); 22 AsDevice * Next = RI->asDevice();
23 InterfaceInfo * II = Next->assignedInterface(); 23 InterfaceInfo * II = Next->assignedInterface();
24 24
25 if( A == Up ) { 25 if( A == Up ) {
26 // we can bring UP if lower level is available 26 // we can bring UP if lower level is available
27 if( NC->currentState() == Available ) { 27 if( NC->currentState() == Available ) {
28 QString S; 28 QString S;
29 S.sprintf( "ifup %s", II->Name.latin1() ); 29 S.sprintf( "ifup %s=%s-c%d-allowed",
30 II->Name.latin1(), II->Name.latin1(),
31 connection()->number() );
30 NSResources->system().execute( S ); 32 NSResources->system().execute( S );
31 NC->setCurrentState( IsUp );
32 } 33 }
33 return 1; 34 return 1;
34 } else if( A == Down ) { 35 } else if( A == Down ) {
35 if( NC->currentState() == IsUp ) { 36 if( NC->currentState() == IsUp ) {
36 QString S; 37 QString S;
37 S.sprintf( "ifdown %s", II->Name.latin1() ); 38 S.sprintf( "ifdown %s=%s-c%d-allowed",
39 II->Name.latin1(), II->Name.latin1(),
40 connection()->number() );
38 NSResources->system().execute( S ); 41 NSResources->system().execute( S );
39 NC->setCurrentState( Available );
40 } 42 }
41 return 1; 43 return 1;
42 } 44 }
43 // delegate 45 // delegate
44 return RI->setState( NC, A ); 46 return RI->setState( NC, A );
45} 47}
46 48
47bool NetworkRun::canSetState( State_t Curr, Action_t A ) { 49bool NetworkRun::canSetState( State_t Curr, Action_t A ) {
48 // we handle UP and DOWN 50 // we handle UP and DOWN
49 RuntimeInfo * RI = netNode()->nextNode()->runtime(); 51 RuntimeInfo * RI = netNode()->nextNode()->runtime();
50 52
51 if( A == Up ) { 53 if( A == Up ) {
diff --git a/noncore/settings/networksettings2/network/networkrun.h b/noncore/settings/networksettings2/network/networkrun.h
index f3d840e..fa16365 100644
--- a/noncore/settings/networksettings2/network/networkrun.h
+++ b/noncore/settings/networksettings2/network/networkrun.h
@@ -1,20 +1,23 @@
1#include <asconnection.h> 1#include <asconnection.h>
2#include "networkdata.h" 2#include "networkdata.h"
3 3
4class NetworkRun : public AsConnection { 4class NetworkRun : public AsConnection {
5 5
6public : 6public :
7 7
8 NetworkRun( ANetNodeInstance * NNI, 8 NetworkRun( ANetNodeInstance * NNI,
9 NetworkData & Data ) : AsConnection( NNI ) 9 NetworkData & Data ) : AsConnection( NNI )
10 { } 10 { }
11 11
12 virtual AsConnection * asConnection( void )
13 { return (AsConnection *)this; }
14
12protected : 15protected :
13 16
14 void detectState( NodeCollection * ); 17 void detectState( NodeCollection * );
15 bool setState( NodeCollection * ,Action_t A ); 18 bool setState( NodeCollection * ,Action_t A );
16 bool canSetState( State_t , Action_t A ); 19 bool canSetState( State_t , Action_t A );
17 20
18 bool handlesInterface( const QString & I ); 21 bool handlesInterface( const QString & I );
19 22
20}; 23};
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index e1110e2..c3e6572 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -159,54 +159,72 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
159 if( LBI ) { 159 if( LBI ) {
160 NodeCollection * NC = NSResources->findConnection( LBI->text() ); 160 NodeCollection * NC = NSResources->findConnection( LBI->text() );
161 if( ! NC ) { 161 if( ! NC ) {
162 return; 162 return;
163 } 163 }
164 OldName = NC->name(); 164 OldName = NC->name();
165 EC.setConnection( NC ); 165 EC.setConnection( NC );
166 } 166 }
167 167
168 EC.showMaximized(); 168 EC.showMaximized();
169 // disable refresh timer 169 // disable refresh timer
170 UpdateTimer->stop(); 170 UpdateTimer->stop();
171 if( EC.exec() == QDialog::Accepted ) { 171 // we need to retry
172 // toplevel item -> store 172 while( 1 ) {
173 NodeCollection * NC = EC.connection(); 173 if( EC.exec() == QDialog::Accepted ) {
174 if( NC->isModified() ) { 174 // toplevel item -> store
175 setModified( 1 ); 175 NodeCollection * NC = EC.connection();
176 if( NC->isModified() ) {
177 setModified( 1 );
178 if( LBI ) {
179 if( NC->name() != OldName ) {
180 // find if new name is free
181 NodeCollection * LCN = NSResources->findConnection(
182 NC->name() );
183 if( LCN ) {
184 QMessageBox::warning(
185 0,
186 tr( "Generating system configuration" ),
187 tr( "Name %1 already exists" ).arg(NC->name())
188 );
189 continue; // restart exec
190 } // else new name
191 // new name -> remove item
192 NSResources->removeConnection( OldName );
193 NSResources->addConnection( NC );
194 } // else not changed
195
196 // must add it here since change will trigger event
197 Profiles_LB->changeItem( NC->devicePixmap(),
198 NC->name(),
199 Profiles_LB->index( LBI )
200 );
201 } else {
202 // new item
203 int ci = Profiles_LB->count();
204 NSResources->addConnection( NC );
205 NC->setNumber( NC->maxConnectionNumber()+1 );
206 Profiles_LB->insertItem( NC->devicePixmap(), NC->name() );
207 Profiles_LB->setSelected( ci, TRUE );
208 }
209 updateProfileState( LBI );
210 }
211 } else {
212 // cancelled : reset connection
176 if( LBI ) { 213 if( LBI ) {
177 // new name -> remove item 214 NodeCollection * NC = NSResources->findConnection( LBI->text() );
178 NSResources->removeConnection( OldName ); 215 NC->reassign();
179 // must add it here since change will trigger event
180 NSResources->addConnection( NC );
181 Profiles_LB->changeItem( NC->devicePixmap(),
182 NC->name(),
183 Profiles_LB->index( LBI )
184 );
185 } else {
186 // new item
187 int ci = Profiles_LB->count();
188 NSResources->addConnection( NC );
189 NC->setNumber( NC->maxConnectionNumber()+1 );
190 Profiles_LB->insertItem( NC->devicePixmap(), NC->name() );
191 Profiles_LB->setSelected( ci, TRUE );
192 } 216 }
193 updateProfileState( LBI );
194 }
195 } else {
196 // cancelled : reset connection
197 if( LBI ) {
198 NodeCollection * NC = NSResources->findConnection( LBI->text() );
199 NC->reassign();
200 } 217 }
218 break;
201 } 219 }
202 // reenable 220 // reenable
203 UpdateTimer->start( 5000 ); 221 UpdateTimer->start( 5000 );
204} 222}
205 223
206void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { 224void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
207 if( LBI == 0 ) 225 if( LBI == 0 )
208 return; 226 return;
209 227
210 NodeCollection * NC = NSResources->findConnection( LBI->text() ); 228 NodeCollection * NC = NSResources->findConnection( LBI->text() );
211 229
212 // is button possible 230 // is button possible
@@ -324,83 +342,77 @@ void NetworkSettings::SLOT_On( void ) {
324 if ( ! LBI ) 342 if ( ! LBI )
325 return; 343 return;
326 344
327 NodeCollection * NC = 345 NodeCollection * NC =
328 NSResources->findConnection( LBI->text() ); 346 NSResources->findConnection( LBI->text() );
329 347
330 bool rv; 348 bool rv;
331 switch( NC->state() ) { 349 switch( NC->state() ) {
332 case Off : 350 case Off :
333 // activate interface 351 // activate interface
334 rv = NC->setState( Activate ); 352 rv = NC->setState( Activate );
335 break; 353 break;
336 case Available : 354 case Available : // deactivate
337 // deactivate 355 case IsUp : // deactivate (will also bring down if needed)
338 rv = NC->setState( Deactivate ); 356 rv = NC->setState( Deactivate );
339 break; 357 break;
340 case IsUp :
341 // bring down and deactivate
342 rv = ( NC->setState( Down ) &&
343 NC->setState( Deactivate ) );
344 break;
345 default : 358 default :
346 // others no change 359 // others no change
347 return; 360 return;
348 } 361 }
349 362
350 if( ! rv ) { 363 if( ! rv ) {
351 QMessageBox::warning( 364 QMessageBox::warning(
352 0, 365 0,
353 tr( "Activating profile" ), 366 tr( "Activating profile" ),
354 tr( "Cannot enable profile" ) ); 367 tr( "Cannot enable profile" ) );
355 return; 368 return;
356 } 369 }
357 updateProfileState( LBI ); 370 updateProfileState( LBI );
358} 371}
359 372
360void NetworkSettings::SLOT_Connect( void ) { 373void NetworkSettings::SLOT_Connect( void ) {
361 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 374 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
362 375
363 if ( ! LBI ) 376 if ( ! LBI )
364 return; 377 return;
365 378
366 NodeCollection * NC = 379 NodeCollection * NC =
367 NSResources->findConnection( LBI->text() ); 380 NSResources->findConnection( LBI->text() );
368 381
369 bool rv; 382 bool rv = 1 ;
370 switch( NC->state() ) { 383 switch( NC->state() ) {
371 case IsUp : 384 case IsUp :
372 // down interface 385 // down interface
373 rv = NC->setState( Down ); 386 rv = NC->setState( Down );
374 break; 387 break;
375 case Available : 388 case Available :
376 // up interface 389 // up interface
377 rv = NC->setState( Up ); 390 rv = NC->setState( Up );
378 break; 391 break;
379 case Off : 392 case Off :
380 // activate and bring up 393 // activate and bring up
381 rv = ( NC->setState( Activate ) && 394 rv = ( NC->setState( Activate ) &&
382 NC->setState( Up ) ); 395 NC->setState( Up ) );
383 break; 396 break;
384 default : 397 default :
385 // others no change 398 // others no change
386 return; 399 break;
387 } 400 }
388 401
389 if( ! rv ) { 402 if( ! rv ) {
390 QMessageBox::warning( 403 QMessageBox::warning(
391 0, 404 0,
392 tr( "Activating profile" ), 405 tr( "Activating profile" ),
393 tr( "Cannot enable profile" ) ); 406 tr( "Cannot enable profile" ) );
394 return;
395 } 407 }
396 408
397 // we do not update the GUI but wait for the REAL upping of the device 409 // we do not update the GUI but wait for the REAL upping of the device
398} 410}
399 411
400void NetworkSettings::SLOT_QCopMessage(const QCString &msg, const QByteArray &data) { 412void NetworkSettings::SLOT_QCopMessage(const QCString &msg, const QByteArray &data) {
401 QDataStream stream( data, IO_ReadOnly ); 413 QDataStream stream( data, IO_ReadOnly );
402 414
403 if( msg == "raise" ) { 415 if( msg == "raise" ) {
404 raise(); 416 raise();
405 return; 417 return;
406 } /* if ( msg == "someMessage(int,int,int)" ) { 418 } /* if ( msg == "someMessage(int,int,int)" ) {
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index 56333c5..f4a5e30 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -86,29 +86,33 @@ public:
86 86
87 // create a blank instance of a net node 87 // create a blank instance of a net node
88 virtual ANetNodeInstance * createInstance( void ) = 0; 88 virtual ANetNodeInstance * createInstance( void ) = 0;
89 89
90 // return feature this NetNode provides 90 // return feature this NetNode provides
91 virtual const char * provides( void ) = 0; 91 virtual const char * provides( void ) = 0;
92 virtual const char ** needs( void ) = 0; 92 virtual const char ** needs( void ) = 0;
93 93
94 // generate files specific for this node (if any) 94 // generate files specific for this node (if any)
95 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0; 95 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0;
96 // return TRUE if this node has data to be inserted in systemfile 96 // return TRUE if this node has data to be inserted in systemfile
97 // with name S 97 // with name S
98 virtual bool hasDataFor( const QString & S ) = 0; 98 virtual bool hasDataFor( const QString & S, bool DeviceSpecific ) = 0;
99 // generate data specific for the system file S 99 // generate data specific for a profile and for the system file S
100 // called only IF data was needed 100 // called only IF data was needed
101 virtual bool generateDataForCommonFile( 101 virtual bool generateDataForCommonFile(
102 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ) = 0; 102 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ) = 0;
103 // generate data specific for the device for the system file S
104 // called only IF data was needed
105 virtual bool generateDeviceDataForCommonFile(
106 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ) = 0;
103 107
104 // does this Node provide a Connection 108 // does this Node provide a Connection
105 bool isToplevel( void ) 109 bool isToplevel( void )
106 { return strcmp( provides(), "fullsetup") == 0 ; } 110 { return strcmp( provides(), "fullsetup") == 0 ; }
107 111
108 // compiled references to 'needed' NetNodes -> needs list 112 // compiled references to 'needed' NetNodes -> needs list
109 void setAlternatives( NetNodeList * Alt ) 113 void setAlternatives( NetNodeList * Alt )
110 { Alternatives = Alt; } 114 { Alternatives = Alt; }
111 NetNodeList & alternatives( void ) 115 NetNodeList & alternatives( void )
112 { return *Alternatives; } 116 { return *Alternatives; }
113 117
114protected : 118protected :
@@ -206,33 +210,33 @@ protected :
206 static long InstanceCounter; 210 static long InstanceCounter;
207}; 211};
208 212
209class RuntimeInfo : public QObject { 213class RuntimeInfo : public QObject {
210 214
211 Q_OBJECT 215 Q_OBJECT
212 216
213public : 217public :
214 218
215 RuntimeInfo( ANetNodeInstance * TheNNI ) 219 RuntimeInfo( ANetNodeInstance * TheNNI )
216 { NNI = TheNNI; } 220 { NNI = TheNNI; }
217 221
218 // downcast 222 // downcast implemented by specify runtime classes
219 AsDevice * asDevice( void ) 223 AsDevice * asDevice( void )
220 { return (AsDevice *)this; } 224 { return 0; }
221 AsConnection * asConnection( void ) 225 AsConnection * asConnection( void )
222 { return (AsConnection *)this; } 226 { return 0; }
223 AsLine * asLine( void ) 227 AsLine * asLine( void )
224 { return (AsLine *)this; } 228 { return 0; }
225 AsFullSetup * asFullSetup( void ) 229 AsFullSetup * asFullSetup( void )
226 { return (AsFullSetup *)this; } 230 { return 0; }
227 231
228 // does this node handles this interface e.g.eth0 232 // does this node handles this interface e.g.eth0
229 // recurse deeper if this node cannot answer that question 233 // recurse deeper if this node cannot answer that question
230 virtual bool handlesInterface( const QString & ) 234 virtual bool handlesInterface( const QString & )
231 { return 0; } 235 { return 0; }
232 virtual InterfaceInfo * assignedInterface( void ); 236 virtual InterfaceInfo * assignedInterface( void );
233 virtual AsDevice * device( void ); 237 virtual AsDevice * device( void );
234 238
235 ANetNodeInstance * netNode() 239 ANetNodeInstance * netNode()
236 { return NNI; } 240 { return NNI; }
237 NodeCollection * connection() 241 NodeCollection * connection()
238 { return NNI->connection(); } 242 { return NNI->connection(); }
@@ -375,29 +379,32 @@ public:
375 { return QString(""); } 379 { return QString(""); }
376 const QString nodeName() 380 const QString nodeName()
377 { return QString("Fake node" ); } 381 { return QString("Fake node" ); }
378 const QString nodeDescription() 382 const QString nodeDescription()
379 { return QString("Fake node" ); } 383 { return QString("Fake node" ); }
380 ANetNodeInstance * createInstance( void ); 384 ANetNodeInstance * createInstance( void );
381 const char * provides( void ) 385 const char * provides( void )
382 { return ""; } 386 { return ""; }
383 virtual const char ** needs( void ) 387 virtual const char ** needs( void )
384 { return 0; } 388 { return 0; }
385 virtual bool generateProperFilesFor( ANetNodeInstance * ) 389 virtual bool generateProperFilesFor( ANetNodeInstance * )
386 { return 0; } 390 { return 0; }
387 virtual bool hasDataFor( const QString & ) 391 virtual bool hasDataFor( const QString &, bool DS )
388 { return 0; } 392 { return 0; }
389 virtual bool generateDataForCommonFile( 393 virtual bool generateDataForCommonFile(
390 SystemFile & , long , ANetNodeInstance * ) 394 SystemFile & , long , ANetNodeInstance * )
391 {return 1; } 395 {return 1; }
396 virtual bool generateDeviceDataForCommonFile(
397 SystemFile & , long , ANetNodeInstance * )
398 {return 1; }
392 399
393private : 400private :
394 401
395}; 402};
396 403
397class FakeNetNodeInstance : public ANetNodeInstance { 404class FakeNetNodeInstance : public ANetNodeInstance {
398 405
399public: 406public:
400 407
401 FakeNetNodeInstance( ANetNode * NN ) : 408 FakeNetNodeInstance( ANetNode * NN ) :
402 ANetNodeInstance( NN ), ValAttrPairs() { } 409 ANetNodeInstance( NN ), ValAttrPairs() { }
403 virtual ~FakeNetNodeInstance( void ) { } 410 virtual ~FakeNetNodeInstance( void ) { }
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp
index 85dcd7d..a68f3c0 100644
--- a/noncore/settings/networksettings2/networksettings2/system.cpp
+++ b/noncore/settings/networksettings2/networksettings2/system.cpp
@@ -29,32 +29,33 @@ static char Dig2Hex[] = {
29 29
30System::System( void ) : ProbedInterfaces() { 30System::System( void ) : ProbedInterfaces() {
31 probeInterfaces(); 31 probeInterfaces();
32} 32}
33 33
34System::~System( void ) { 34System::~System( void ) {
35 if( ProcDevNet ) 35 if( ProcDevNet )
36 delete ProcDevNet; 36 delete ProcDevNet;
37} 37}
38 38
39int System::execute( const QString & S ) { 39int System::execute( const QString & S ) {
40 QString MyS = S; 40 QString MyS = S;
41 char * usr = getenv("USER");
41 int rv; 42 int rv;
42 43
43 if( S.isEmpty() ) { 44 if( S.isEmpty() ) {
44 // loophole to start shell 45 // loophole to start shell
45 return 8888; 46 return 8888;
46 } 47 }
47 if( getenv("USER") != "root" ) { 48 if( usr == 0 || strcmp( usr, "root" ) ) {
48 // use SUDO 49 // unknown or non-root user -> use SUDO
49 MyS.prepend( "sudo " ); 50 MyS.prepend( "sudo " );
50 } 51 }
51 52
52 fprintf( stderr, "Executing %s\n", MyS.latin1() ); 53 fprintf( stderr, "Executing %s\n", MyS.latin1() );
53 54
54 rv = system( MyS.latin1() ) ; 55 rv = system( MyS.latin1() ) ;
55 switch( rv ) { 56 switch( rv ) {
56 case -1 : 57 case -1 :
57 // cannot fork 58 // cannot fork
58 return 1; 59 return 1;
59 case 127 : 60 case 127 :
60 // cannot start shell 61 // cannot start shell
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
index 7249976..394ff52 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
@@ -21,42 +21,50 @@ SystemFile::SystemFile( const QString & N, const QString & P ){
21 21
22 // find location of templates 22 // find location of templates
23 TemplDir = QPEApplication::qpeDir() + "etc/" + TEMPLATEDIR; 23 TemplDir = QPEApplication::qpeDir() + "etc/" + TEMPLATEDIR;
24 FI.setFile( TemplDir ); 24 FI.setFile( TemplDir );
25 if( ! FI.isDir() ) { 25 if( ! FI.isDir() ) {
26 // try current dir 26 // try current dir
27 TemplDir = "./" TEMPLATEDIR; 27 TemplDir = "./" TEMPLATEDIR;
28 FI.setFile( TemplDir ); 28 FI.setFile( TemplDir );
29 if( ! FI.isDir() ) { 29 if( ! FI.isDir() ) {
30 hasPreSection = 30 hasPreSection =
31 hasPostSection = 31 hasPostSection =
32 hasPreNodeSection = 32 hasPreNodeSection =
33 hasPostNodeSection = 0; 33 hasPostNodeSection =
34 hasPreDeviceSection =
35 hasPostDeviceSection = 0;
34 return; 36 return;
35 } 37 }
36 } 38 }
37 39
38 // have found location 40 // have found location
39 S = TemplDir + Name + "/presection"; 41 S = TemplDir + Name + "/presection";
40 FI.setFile( S ); 42 FI.setFile( S );
41 hasPreSection = ( FI.exists() && FI.isReadable() ); 43 hasPreSection = ( FI.exists() && FI.isReadable() );
42 S = TemplDir + Name + "/postsection"; 44 S = TemplDir + Name + "/postsection";
43 FI.setFile( S ); 45 FI.setFile( S );
44 hasPostSection = ( FI.exists() && FI.isReadable() ); 46 hasPostSection = ( FI.exists() && FI.isReadable() );
45 S = TemplDir + Name + "/prenodesection"; 47 S = TemplDir + Name + "/prenodesection";
46 FI.setFile( S ); 48 FI.setFile( S );
47 hasPreNodeSection = ( FI.exists() && FI.isReadable() ); 49 hasPreNodeSection = ( FI.exists() && FI.isReadable() );
48 S = TemplDir + Name + "/postnodesection"; 50 S = TemplDir + Name + "/postnodesection";
49 FI.setFile( S ); 51 FI.setFile( S );
50 hasPostNodeSection = ( FI.exists() && FI.isReadable() ); 52 hasPostNodeSection = ( FI.exists() && FI.isReadable() );
53 S = TemplDir + Name + "/predevicesection";
54 FI.setFile( S );
55 hasPreDeviceSection = ( FI.exists() && FI.isReadable() );
56 S = TemplDir + Name + "/postdevicesection";
57 FI.setFile( S );
58 hasPostDeviceSection = ( FI.exists() && FI.isReadable() );
51 } 59 }
52} 60}
53 61
54SystemFile::~SystemFile( void ) { 62SystemFile::~SystemFile( void ) {
55 if( F ) 63 if( F )
56 delete F; 64 delete F;
57} 65}
58 66
59bool SystemFile::open( void ) { 67bool SystemFile::open( void ) {
60 if( F ) { 68 if( F ) {
61 F->close(); 69 F->close();
62 delete F; 70 delete F;
@@ -99,46 +107,81 @@ bool SystemFile::postSection( void ) {
99 if( hasPostSection ) { 107 if( hasPostSection ) {
100 QFile Fl( TemplDir + Name + "/postsection" ); 108 QFile Fl( TemplDir + Name + "/postsection" );
101 if( ! Fl.open( IO_ReadOnly ) ) 109 if( ! Fl.open( IO_ReadOnly ) )
102 return 1; // error 110 return 1; // error
103 // copy file to this file 111 // copy file to this file
104 F->writeBlock( Fl.readAll() ); 112 F->writeBlock( Fl.readAll() );
105 } 113 }
106 return 0; 114 return 0;
107} 115}
108 116
109bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) { 117bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) {
110 if( hasPreNodeSection ) { 118 if( hasPreNodeSection ) {
111 QFile Fl( TemplDir + Name + "/prenodesectoin" ); 119 QFile Fl( TemplDir + Name + "/prenodesection" );
112 if( ! Fl.open( IO_ReadOnly ) ) 120 if( ! Fl.open( IO_ReadOnly ) )
113 return 1; // error 121 return 1; // error
114 QTextStream TX( &Fl ); 122 QTextStream TX( &Fl );
115 QString Out; 123 QString Out;
116 QString S = TX.readLine(); 124 QString S = TX.readLine();
117 while( ! TX.eof() ) { 125 while( ! TX.eof() ) {
118 Out = S. 126 Out = S.
119 arg(NNI->netNode()->nodeName()); 127 arg(NNI->netNode()->nodeName());
120 (*this) << Out << endl; 128 (*this) << Out << endl;
121 S = TX.readLine(); 129 S = TX.readLine();
122 } 130 }
123 } 131 }
124 return 0; 132 return 0;
125} 133}
126 134
127bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long DevNr ) { 135bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long DevNr ) {
128 if( hasPostNodeSection ) { 136 if( hasPostNodeSection ) {
129 QFile Fl( TemplDir + Name + "/postnodesectoin" ); 137 QFile Fl( TemplDir + Name + "/postnodesection" );
130 if( ! Fl.open( IO_ReadOnly ) ) 138 if( ! Fl.open( IO_ReadOnly ) )
131 return 1; // error 139 return 1; // error
132 QTextStream TX( &Fl ); 140 QTextStream TX( &Fl );
133 QString Out; 141 QString Out;
134 QString S = TX.readLine(); 142 QString S = TX.readLine();
135 while( ! TX.eof() ) { 143 while( ! TX.eof() ) {
136 Out = S. 144 Out = S.
137 arg(NNI->nodeName()); 145 arg(NNI->nodeName());
138 (*this) << Out << endl; 146 (*this) << Out << endl;
139 S = TX.readLine(); 147 S = TX.readLine();
140 } 148 }
141 } 149 }
142 return 0; 150 return 0;
143} 151}
144 152
153bool SystemFile::preDeviceSection( ANetNodeInstance * NNI, long ) {
154 if( hasPreDeviceSection ) {
155 QFile Fl( TemplDir + Name + "/predevicesection" );
156 if( ! Fl.open( IO_ReadOnly ) )
157 return 1; // error
158 QTextStream TX( &Fl );
159 QString Out;
160 QString S = TX.readLine();
161 while( ! TX.eof() ) {
162 Out = S.
163 arg(NNI->netNode()->nodeName());
164 (*this) << Out << endl;
165 S = TX.readLine();
166 }
167 }
168 return 0;
169}
170
171bool SystemFile::postDeviceSection( ANetNodeInstance * NNI, long DevNr ) {
172 if( hasPostDeviceSection ) {
173 QFile Fl( TemplDir + Name + "/postdevicesection" );
174 if( ! Fl.open( IO_ReadOnly ) )
175 return 1; // error
176 QTextStream TX( &Fl );
177 QString Out;
178 QString S = TX.readLine();
179 while( ! TX.eof() ) {
180 Out = S.
181 arg(NNI->nodeName());
182 (*this) << Out << endl;
183 S = TX.readLine();
184 }
185 }
186 return 0;
187}
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.h b/noncore/settings/networksettings2/networksettings2/systemfile.h
index 8b6bcb9..35e0dfc 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.h
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.h
@@ -15,25 +15,29 @@ public :
15 ~SystemFile( void ); 15 ~SystemFile( void );
16 16
17 const QString & name( void ) 17 const QString & name( void )
18 { return Name; } 18 { return Name; }
19 19
20 bool open( void ); 20 bool open( void );
21 bool close( void ); 21 bool close( void );
22 22
23 bool preSection( void ); 23 bool preSection( void );
24 bool postSection( void ); 24 bool postSection( void );
25 bool preNodeSection( ANetNodeInstance * NNI, long DevNr ); 25 bool preNodeSection( ANetNodeInstance * NNI, long DevNr );
26 bool postNodeSection( ANetNodeInstance * NNI, long DevNr ); 26 bool postNodeSection( ANetNodeInstance * NNI, long DevNr );
27 bool preDeviceSection( ANetNodeInstance * NNI, long DevNr );
28 bool postDeviceSection( ANetNodeInstance * NNI, long DevNr );
27 29
28private : 30private :
29 31
30 QString Name; 32 QString Name;
31 QString Path; 33 QString Path;
32 QFile * F; 34 QFile * F;
33 bool hasPreSection; 35 bool hasPreSection;
34 bool hasPreNodeSection;
35 bool hasPostSection; 36 bool hasPostSection;
37 bool hasPreNodeSection;
36 bool hasPostNodeSection; 38 bool hasPostNodeSection;
39 bool hasPreDeviceSection;
40 bool hasPostDeviceSection;
37 41
38}; 42};
39#endif 43#endif
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index 3f5e958..6541596 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -179,24 +179,25 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
179 179
180 if( ! ForceIt && ! isModified() ) 180 if( ! ForceIt && ! isModified() )
181 return S; 181 return S;
182 182
183 // regenerate system files 183 // regenerate system files
184 printf( "Generating settings from %s\n", CfgFile.latin1() ); 184 printf( "Generating settings from %s\n", CfgFile.latin1() );
185 185
186 { Name2SystemFile_t & SFM = NSResources->systemFiles(); 186 { Name2SystemFile_t & SFM = NSResources->systemFiles();
187 Name2Connection_t & M = NSResources->connections(); 187 Name2Connection_t & M = NSResources->connections();
188 NodeCollection * NC; 188 NodeCollection * NC;
189 ANetNodeInstance * NNI; 189 ANetNodeInstance * NNI;
190 SystemFile * SF; 190 SystemFile * SF;
191 AsDevice * CurDev;
191 bool needToRegenerate = ForceIt; 192 bool needToRegenerate = ForceIt;
192 193
193 // 194 //
194 // check if we need to generate at least one of the system files 195 // check if we need to generate at least one of the system files
195 // 196 //
196 if( ! ForceIt ) { 197 if( ! ForceIt ) {
197 for( QDictIterator<SystemFile> sfit(SFM); 198 for( QDictIterator<SystemFile> sfit(SFM);
198 sfit.current(); 199 sfit.current();
199 ++sfit ) { 200 ++sfit ) {
200 SF = sfit.current(); 201 SF = sfit.current();
201 202
202 // check if there are nodes that are modified and require 203 // check if there are nodes that are modified and require
@@ -205,25 +206,27 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
205 // for all connections 206 // for all connections
206 for( QDictIterator<NodeCollection> ncit(M); 207 for( QDictIterator<NodeCollection> ncit(M);
207 ncit.current(); 208 ncit.current();
208 ++ncit ) { 209 ++ncit ) {
209 NC = ncit.current(); 210 NC = ncit.current();
210 211
211 if( NC->isModified() ) { 212 if( NC->isModified() ) {
212 // does this connection 'touch' this system file ? 213 // does this connection 'touch' this system file ?
213 for( QListIterator<ANetNodeInstance> cncit(*NC); 214 for( QListIterator<ANetNodeInstance> cncit(*NC);
214 cncit.current(); 215 cncit.current();
215 ++cncit ) { 216 ++cncit ) {
216 NNI = cncit.current(); 217 NNI = cncit.current();
217 if( NNI->netNode()->hasDataFor( SF->name() ) && 218 if( ( NNI->netNode()->hasDataFor( SF->name(), 1 ) ||
219 NNI->netNode()->hasDataFor( SF->name(), 0 )
220 ) &&
218 NNI->isModified() ) { 221 NNI->isModified() ) {
219 needToRegenerate = 1; 222 needToRegenerate = 1;
220 break; 223 break;
221 } 224 }
222 } 225 }
223 } 226 }
224 if( needToRegenerate ) 227 if( needToRegenerate )
225 break; 228 break;
226 } 229 }
227 if( needToRegenerate ) 230 if( needToRegenerate )
228 break; 231 break;
229 } 232 }
@@ -232,120 +235,269 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
232 // we cannot renumber with a FORCE request since 235 // we cannot renumber with a FORCE request since
233 // we probably are NOT going to save the config 236 // we probably are NOT going to save the config
234 // e.g. when using --regen option 237 // e.g. when using --regen option
235 if( ! ForceReq && needToRegenerate ) { 238 if( ! ForceReq && needToRegenerate ) {
236 NSResources->renumberConnections(); 239 NSResources->renumberConnections();
237 setModified(1); 240 setModified(1);
238 } 241 }
239 242
240 // 243 //
241 // generate files proper to each netnodeinstance 244 // generate files proper to each netnodeinstance
242 // 245 //
243 { Name2Instance_t & NNIs = NSResources->netNodeInstances(); 246 { Name2Instance_t & NNIs = NSResources->netNodeInstances();
244 ANetNodeInstance * NNI;
245 247
246 for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); 248 for( QDictIterator<ANetNodeInstance> NNIIt(NNIs);
247 NNIIt.current(); 249 NNIIt.current();
248 ++NNIIt 250 ++NNIIt
249 ){ 251 ){
250 // for all nodes find those that are modified 252 // for all nodes find those that are modified
251 NNI = NNIIt.current(); 253 NNI = NNIIt.current();
252 254
253 if( ForceIt || NNI->isModified() ) { 255 if( ForceIt || NNI->isModified() ) {
254 if( ! NNI->netNode()->generateProperFilesFor( NNI ) ) { 256 if( ! NNI->netNode()->generateProperFilesFor( NNI ) ) {
255 // problem generating 257 // problem generating
256 S = qApp->translate( "NetworkSettings", 258 S = qApp->translate( "NetworkSettings",
257 "<p>Cannot generate files proper to %1</p>" ). 259 "<p>Cannot generate files proper to %1</p>" ).
258 arg(NNI->netNode()->nodeName()) ; 260 arg(NNI->netNode()->nodeName()) ;
259 return S; 261 return S;
260 } 262 }
261 } 263 }
262 } 264 }
263 } 265 }
264 266
265 // 267 //
266 // generate system files 268 // generate all system files
267 // 269 //
268 for( QDictIterator<SystemFile> sfit(SFM); 270 for( QDictIterator<SystemFile> sfit(SFM);
269 sfit.current(); 271 sfit.current();
270 ++sfit ) { 272 ++sfit ) {
271 SF = sfit.current(); 273 SF = sfit.current();
272 274
273 //
274 // regenerate current file
275 //
276 printf( "Generating %s\n", SF->name().latin1() ); 275 printf( "Generating %s\n", SF->name().latin1() );
277 SF->open(); 276 SF->open();
278 277
279 do { // so we can break; 278 do { // so we can break;
280 279
280 // global presection for this system file
281 if( SF->preSection() ) { 281 if( SF->preSection() ) {
282 S = qApp->translate( "NetworkSettings", 282 S = qApp->translate( "NetworkSettings",
283 "<p>Error in preSection for file %1</p>" ). 283 "<p>Error in preSection for file %1</p>" ).
284 arg( SF->name() ); 284 arg( SF->name() );
285 return S; 285 return S;
286 } 286 }
287 287
288 for( QDictIterator<NodeCollection> ncit(M); 288 // find all netnodes and figure out if
289 ncit.current(); 289 // for that node there are instances
290 ++ncit ) { 290 for( QDictIterator<NetNode_t> nnit(
291 NC = ncit.current(); 291 NSResources->netNodes() );
292 292 nnit.current();
293 // get the netnode that serves as the device for this 293 ++nnit ) {
294 // connection 294 ANetNode * NN;
295 AsDevice * Dev = NC->device(); 295
296 NN = nnit.current()->NetNode;
297
298 // are there instances ?
299 NNI = 0;
300 for( QDictIterator<ANetNodeInstance> nniit(
301 NSResources->netNodeInstances() );
302 nniit.current();
303 ++nniit ) {
304 if( nniit.current()->netNode() == NN ) {
305 NNI = nniit.current();
306 break;
307 }
308 }
296 309
297 // generate 'entry' for every possible device this profile handles 310 if( ! NNI )
311 // no instances
312 continue;
313
314 // has this node data for this system file ?
315 if( (CurDev = NNI->runtime()->asDevice() ) ) {
316 // generate start for this nodetype for all possible devices of this type
317 for( int i = 0; i < CurDev->count(); i ++ ) {
318 if( SF->preDeviceSection( NNI, i ) ) {
319 S = qApp->translate( "NetworkSettings",
320 "<p>Error in preDeviceSection for file %1 and node %2</p>" ).
321 arg( SF->name() ).
322 arg( NN->nodeName() );
323 return S;
324 }
298 325
299 for( QListIterator<ANetNodeInstance> cncit(*NC); 326 if( ! NN->hasDataFor( SF->name(), 1 ) ) {
300 cncit.current(); 327 if( NN->generateDeviceDataForCommonFile( *SF, i, NNI ) ) {
301 ++cncit ) {
302 NNI = cncit.current();
303 for( int i = 0; i < Dev->count(); i ++ ) {
304 if( NNI->netNode()->hasDataFor( SF->name() ) ) {
305 if( SF->preNodeSection( NNI, i ) ) {
306 S = qApp->translate( "NetworkSettings", 328 S = qApp->translate( "NetworkSettings",
307 "<p>Error in preNodeSection for file %1 and node %2</p>" ). 329 "<p>Error in node part for file %1 and node %2</p>" ).
308 arg( SF->name() ). 330 arg( SF->name() ).
309 arg( NNI->netNode()->nodeName() ); 331 arg( NN->nodeName() );
310 return S; 332 return S;
311 } 333 }
334 }
335 }
336 } else {
337 // just request this once
338 if( SF->preDeviceSection( NNI, -1 ) ) {
339 S = qApp->translate( "NetworkSettings",
340 "<p>Error in preDeviceSection for file %1 and node %2</p>" ).
341 arg( SF->name() ).
342 arg( NN->nodeName() );
343 return S;
344 }
345
346 if( ! NN->hasDataFor( SF->name(), 1 ) ) {
347 if( NN->generateDeviceDataForCommonFile( *SF, -1, NNI ) ) {
348 S = qApp->translate( "NetworkSettings",
349 "<p>Error in node part for file %1 and node %2</p>" ).
350 arg( SF->name() ).
351 arg( NN->nodeName() );
352 return S;
353 }
354 }
355 }
356
357 // now generate profile specific data for all
358 // connections working on a device of the current
359 // netnode type
360 for( QDictIterator<NodeCollection> ncit(M);
361 ncit.current();
362 ++ncit ) {
363 NC = ncit.current();
312 364
313 if( NNI->netNode()->generateDataForCommonFile(*SF,i,NNI) ) { 365 NNI = NC->getToplevel();
366
367 // no output needed
368 if( ! NNI->netNode()->hasDataFor( SF->name(), 0 ) )
369 continue;
370
371 // get the netnode that serves as the device for this
372 // connection
373 AsDevice * Dev = NC->device();
374
375 if( CurDev ) {
376 if( CurDev != Dev ) {
377 // other device -> later
378 continue;
379 }
380
381 // generate 'entry' for every combination of device and profile
382 // each node delegates to deeper level
383 for( int i = 0; i < CurDev->count(); i ++ ) {
384 if( SF->preNodeSection( NNI, i ) ) {
314 S = qApp->translate( "NetworkSettings", 385 S = qApp->translate( "NetworkSettings",
315 "<p>Error in node part for file %1 and node %2</p>" ). 386 "<p>Error in preNodeSection for file %1 and node %2</p>" ).
316 arg( SF->name() ). 387 arg( SF->name() ).
317 arg( NNI->netNode()->nodeName() ); 388 arg( NNI->netNode()->nodeName() );
318 return S; 389 return S;
319 } 390 }
320 391
392 // ask all nodes in connection
393
394 for( QListIterator<ANetNodeInstance> cncit(*NC);
395 cncit.current();
396 ++cncit ) {
397 NNI = cncit.current();
398
399 if( NNI->netNode()->hasDataFor( SF->name(), 0 ) ) {
400 if( NNI->netNode()->generateDataForCommonFile(*SF,i,NNI) ) {
401 S = qApp->translate( "NetworkSettings",
402 "<p>Error in node part for file %1 and node %2</p>" ).
403 arg( SF->name() ).
404 arg( NNI->netNode()->nodeName() );
405 return S;
406 }
407 }
408 }
409
321 if( SF->postNodeSection( NNI, i ) ) { 410 if( SF->postNodeSection( NNI, i ) ) {
322 S = qApp->translate( "NetworkSettings", 411 S = qApp->translate( "NetworkSettings",
323 "<p>Error in postNodeSection for file %1 and node %2</p>" ). 412 "<p>Error in postNodeSection for file %1 and node %2</p>" ).
324 arg( SF->name() ). 413 arg( SF->name() ).
325 arg( NNI->netNode()->nodeName() ); 414 arg( NNI->netNode()->nodeName() );
326 return S; 415 return S;
327 } 416 }
328 } 417 }
418
419 } else {
420 if( Dev ) {
421 // other
422 continue;
423 }
424
425 // one entry to generate
426 if( SF->preNodeSection( NNI, -1 ) ) {
427 S = qApp->translate( "NetworkSettings",
428 "<p>Error in preNodeSection for file %1 and node %2</p>" ).
429 arg( SF->name() ).
430 arg( NNI->netNode()->nodeName() );
431 return S;
432 }
433
434 if( NNI->netNode()->generateDataForCommonFile(*SF,-1,NNI) ) {
435 S = qApp->translate( "NetworkSettings",
436 "<p>Error in node part for file %1 and node %2</p>" ).
437 arg( SF->name() ).
438 arg( NNI->netNode()->nodeName() );
439 return S;
440 }
441
442 if( SF->postNodeSection( NNI, -1 ) ) {
443 S = qApp->translate( "NetworkSettings",
444 "<p>Error in postNodeSection for file %1 and node %2</p>" ).
445 arg( SF->name() ).
446 arg( NNI->netNode()->nodeName() );
447 return S;
448 }
449 }
450
451 // generated some data
452 if( SF->postNodeSection( NNI, -1 ) ) {
453 S = qApp->translate( "NetworkSettings",
454 "<p>Error in postNodeSection for file %1 and node %2</p>" ).
455 arg( SF->name() ).
456 arg( NNI->netNode()->nodeName() );
457 return S;
458 }
459 *SF << endl;
460 }
461
462 if( CurDev ) {
463 // generate 'entry' for every combination of device and profile
464 // each node delegates to deeper level
465 for( int i = 0; i < CurDev->count(); i ++ ) {
466 if( SF->postDeviceSection( NNI, i ) ) {
467 S = qApp->translate( "NetworkSettings",
468 "<p>Error in postDeviceSection for file %1 and node %2</p>" ).
469 arg( SF->name() ).
470 arg( NNI->netNode()->nodeName() );
471 return S;
472 }
473 }
474 } else {
475 if( SF->postDeviceSection( NNI, -1 ) ) {
476 S = qApp->translate( "NetworkSettings",
477 "<p>Error in postDeviceSection for file %1 and node %2</p>" ).
478 arg( SF->name() ).
479 arg( NNI->netNode()->nodeName() );
480 return S;
329 } 481 }
330 } 482 }
331 *SF << endl;
332 } 483 }
333 484
334 if( SF->postSection() ) { 485 if( SF->postSection() ) {
335 S = qApp->translate( "NetworkSettings", 486 S = qApp->translate( "NetworkSettings",
336 "<p>Error in postSection for file %1</p>" ). 487 "<p>Error in postSection for file %1</p>" ).
337 arg( SF->name() ); 488 arg( SF->name() );
338 return S; 489 return S;
339 } 490 }
491
340 } while( 0 ); 492 } while( 0 );
341 SF->close(); 493 SF->close();
342 } 494 }
343 } 495 }
344 Force = 0; 496 Force = 0;
345 return S; 497 return S;
346} 498}
347 499
348QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) { 500QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) {
349 // collect connections that can work on top of this interface 501 // collect connections that can work on top of this interface
350 NodeCollection * NC; 502 NodeCollection * NC;
351 QList<NodeCollection> PossibleConnections; 503 QList<NodeCollection> PossibleConnections;
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
index 309c9a1..51d17ec 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
@@ -35,28 +35,35 @@ const char ** PPPNetNode::needs( void ) {
35 return PPPNeeds; 35 return PPPNeeds;
36} 36}
37 37
38const char * PPPNetNode::provides( void ) { 38const char * PPPNetNode::provides( void ) {
39 return "connection"; 39 return "connection";
40} 40}
41 41
42bool PPPNetNode::generateProperFilesFor( 42bool PPPNetNode::generateProperFilesFor(
43 ANetNodeInstance * ) { 43 ANetNodeInstance * ) {
44 return 1; 44 return 1;
45} 45}
46 46
47bool PPPNetNode::hasDataFor( const QString & ) { 47bool PPPNetNode::hasDataFor( const QString &, bool ) {
48 return 0; 48 return 0;
49} 49}
50 50
51bool PPPNetNode::generateDataForCommonFile( 51bool PPPNetNode::generateDataForCommonFile(
52 SystemFile & , 52 SystemFile & ,
53 long, 53 long,
54 ANetNodeInstance * ) { 54 ANetNodeInstance * ) {
55 return 1; 55 return 1;
56} 56}
57 57
58bool PPPNetNode::generateDeviceDataForCommonFile(
59 SystemFile & ,
60 long ,
61 ANetNodeInstance * ) {
62 return 1;
63}
64
58extern "C" { 65extern "C" {
59void create_plugin( QList<ANetNode> & PNN ) { 66void create_plugin( QList<ANetNode> & PNN ) {
60 PNN.append( new PPPNetNode() ); 67 PNN.append( new PPPNetNode() );
61} 68}
62} 69}
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.h b/noncore/settings/networksettings2/ppp/ppp_NN.h
index 3f9a338..8d56e7f 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.h
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.h
@@ -19,26 +19,28 @@ public:
19 19
20 virtual const QString nodeName() 20 virtual const QString nodeName()
21 { return tr("PPP Connection"); } 21 { return tr("PPP Connection"); }
22 22
23 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
24 24
25 virtual ANetNodeInstance * createInstance( void ); 25 virtual ANetNodeInstance * createInstance( void );
26 26
27 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
28 virtual const char * provides( void ); 28 virtual const char * provides( void );
29 29
30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
31 virtual bool hasDataFor( const QString & S ); 31 virtual bool hasDataFor( const QString & S, bool DS );
32 virtual bool generateDataForCommonFile( 32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); 33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 virtual bool generateDeviceDataForCommonFile(
35 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 36
35private: 37private:
36 38
37}; 39};
38 40
39extern "C" 41extern "C"
40{ 42{
41 void create_plugin( QList<ANetNode> & PNN ); 43 void create_plugin( QList<ANetNode> & PNN );
42}; 44};
43 45
44#endif 46#endif
diff --git a/noncore/settings/networksettings2/ppp/ppprun.cpp b/noncore/settings/networksettings2/ppp/ppprun.cpp
index 4ac0c5a..8c75df3 100644
--- a/noncore/settings/networksettings2/ppp/ppprun.cpp
+++ b/noncore/settings/networksettings2/ppp/ppprun.cpp
@@ -7,33 +7,25 @@ PPPRun::PPPRun( ANetNodeInstance * NNI, PPPData & Data ) :
7} 7}
8 8
9void PPPRun::detectState( NodeCollection * NC ) { 9void PPPRun::detectState( NodeCollection * NC ) {
10 if( isMyPPPDRunning( ) ) { 10 if( isMyPPPDRunning( ) ) {
11 if( isMyPPPUp() ) { 11 if( isMyPPPUp() ) {
12 NC->setCurrentState( IsUp ); 12 NC->setCurrentState( IsUp );
13 } else { 13 } else {
14 NC->setCurrentState( Available ); 14 NC->setCurrentState( Available );
15 } 15 }
16 } else { 16 } else {
17 NC->setCurrentState( Off ); // at least this 17 NC->setCurrentState( Off ); // at least this
18 // but could also be unavailable 18 // but could also be unavailable
19 ANetNodeInstance * NNI; 19 AsDevice::netNode()->nextNode()->runtime()->detectState( NC );
20 RuntimeInfo * RI;
21 NNI = AsDevice::netNode();
22 printf( "%p\n", NNI );
23 NNI = NNI->nextNode();
24 printf( "%p\n", NNI );
25 RI = NNI->runtime();
26 printf( "%p\n", RI );
27 RI->detectState( NC );
28 } 20 }
29} 21}
30 22
31bool PPPRun::setState( NodeCollection * NC, Action_t A ) { 23bool PPPRun::setState( NodeCollection * NC, Action_t A ) {
32 switch( A ) { 24 switch( A ) {
33 case Activate : 25 case Activate :
34 NC->setCurrentState( Available ); 26 NC->setCurrentState( Available );
35 // no 27 // no
36 break; 28 break;
37 case Deactivate : 29 case Deactivate :
38 if( NC->currentState() == IsUp ) { 30 if( NC->currentState() == IsUp ) {
39 NC->state( Down ); 31 NC->state( Down );
diff --git a/noncore/settings/networksettings2/ppp/ppprun.h b/noncore/settings/networksettings2/ppp/ppprun.h
index abb9176..765aff2 100644
--- a/noncore/settings/networksettings2/ppp/ppprun.h
+++ b/noncore/settings/networksettings2/ppp/ppprun.h
@@ -6,26 +6,32 @@
6#include <asdevice.h> 6#include <asdevice.h>
7#include "pppdata.h" 7#include "pppdata.h"
8 8
9class PPPRun : public AsConnection, public AsDevice { 9class PPPRun : public AsConnection, public AsDevice {
10 10
11public : 11public :
12 12
13 PPPRun( ANetNodeInstance * NNI, 13 PPPRun( ANetNodeInstance * NNI,
14 PPPData & Data ); 14 PPPData & Data );
15 virtual QString genNic( long NicNr ) 15 virtual QString genNic( long NicNr )
16 { QString S; return S.sprintf( "ppp%ld", NicNr ); } 16 { QString S; return S.sprintf( "ppp%ld", NicNr ); }
17 17
18 virtual AsDevice * asDevice( void )
19 { return (AsDevice *)this; }
20 virtual AsConnection * asConnection( void )
21 { return (AsConnection *)this; }
22
18 virtual AsDevice * device( void ) 23 virtual AsDevice * device( void )
19 { return AsDevice::asDevice(); } 24 { return (AsDevice *)this; }
25
20 virtual RuntimeInfo * runtimeInfo( void ) 26 virtual RuntimeInfo * runtimeInfo( void )
21 { return ( AsConnection *)this; } 27 { return ( AsConnection *)this; }
22 28
23 protected : 29 protected :
24 30
25 void detectState( NodeCollection * NC ); 31 void detectState( NodeCollection * NC );
26 bool setState( NodeCollection * NC, Action_t A ); 32 bool setState( NodeCollection * NC, Action_t A );
27 bool canSetState( State_t S, Action_t A ) 33 bool canSetState( State_t S, Action_t A )
28 { return AsDevice::connection()->findNext( 34 { return AsDevice::connection()->findNext(
29 AsDevice::netNode() )->runtime()->canSetState( S,A ); } 35 AsDevice::netNode() )->runtime()->canSetState( S,A ); }
30 36
31 bool handlesInterface( const QString & I ); 37 bool handlesInterface( const QString & I );
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp
index c39b86f..fcf1ca6 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NN.cpp
@@ -34,28 +34,35 @@ const char ** ProfileNetNode::needs( void ) {
34 return ProfileNeeds; 34 return ProfileNeeds;
35} 35}
36 36
37const char * ProfileNetNode::provides( void ) { 37const char * ProfileNetNode::provides( void ) {
38 return "fullsetup"; 38 return "fullsetup";
39} 39}
40 40
41bool ProfileNetNode::generateProperFilesFor( 41bool ProfileNetNode::generateProperFilesFor(
42 ANetNodeInstance * ) { 42 ANetNodeInstance * ) {
43 return 1; 43 return 1;
44} 44}
45 45
46bool ProfileNetNode::hasDataFor( const QString & ) { 46bool ProfileNetNode::hasDataFor( const QString &, bool ) {
47 return 0; 47 return 0;
48} 48}
49 49
50bool ProfileNetNode::generateDataForCommonFile( 50bool ProfileNetNode::generateDataForCommonFile(
51 SystemFile & , 51 SystemFile & ,
52 long, 52 long,
53 ANetNodeInstance * ) { 53 ANetNodeInstance * ) {
54 return 1; 54 return 1;
55} 55}
56 56
57bool ProfileNetNode::generateDeviceDataForCommonFile(
58 SystemFile & ,
59 long ,
60 ANetNodeInstance * ) {
61 return 1;
62}
63
57extern "C" { 64extern "C" {
58void create_plugin( QList<ANetNode> & PNN ) { 65void create_plugin( QList<ANetNode> & PNN ) {
59 PNN.append( new ProfileNetNode() ); 66 PNN.append( new ProfileNetNode() );
60} 67}
61} 68}
diff --git a/noncore/settings/networksettings2/profile/profile_NN.h b/noncore/settings/networksettings2/profile/profile_NN.h
index 3c06947..b64a6dd 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.h
+++ b/noncore/settings/networksettings2/profile/profile_NN.h
@@ -19,26 +19,28 @@ public:
19 19
20 virtual const QString nodeName() 20 virtual const QString nodeName()
21 { return tr("Regular profile"); } 21 { return tr("Regular profile"); }
22 22
23 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
24 24
25 virtual ANetNodeInstance * createInstance( void ); 25 virtual ANetNodeInstance * createInstance( void );
26 26
27 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
28 virtual const char * provides( void ); 28 virtual const char * provides( void );
29 29
30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
31 virtual bool hasDataFor( const QString & S ); 31 virtual bool hasDataFor( const QString & S, bool DS );
32 virtual bool generateDataForCommonFile( 32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); 33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 virtual bool generateDeviceDataForCommonFile(
35 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 36
35private: 37private:
36 38
37}; 39};
38 40
39extern "C" 41extern "C"
40{ 42{
41 void create_plugin( QList<ANetNode> & PNN ); 43 void create_plugin( QList<ANetNode> & PNN );
42}; 44};
43 45
44#endif 46#endif
diff --git a/noncore/settings/networksettings2/profile/profilerun.cpp b/noncore/settings/networksettings2/profile/profilerun.cpp
index 90c37ed..feebf86 100644
--- a/noncore/settings/networksettings2/profile/profilerun.cpp
+++ b/noncore/settings/networksettings2/profile/profilerun.cpp
@@ -10,43 +10,41 @@ void ProfileRun::detectState( NodeCollection * NC ) {
10 // convert to runtime and ask to detect the state 10 // convert to runtime and ask to detect the state
11 netNode()->nextNode()->runtime()->detectState( NC ); 11 netNode()->nextNode()->runtime()->detectState( NC );
12 } 12 }
13} 13}
14 14
15bool ProfileRun::setState( NodeCollection * NC, Action_t A ) { 15bool ProfileRun::setState( NodeCollection * NC, Action_t A ) {
16 ANetNodeInstance * NNNI; 16 ANetNodeInstance * NNNI;
17 17
18 NNNI = netNode()->nextNode(); 18 NNNI = netNode()->nextNode();
19 switch ( A ) { 19 switch ( A ) {
20 case Enable : 20 case Enable :
21 if( NC->currentState() == Disabled ) { 21 if( NC->currentState() == Disabled ) {
22 Data->Disabled = 0;
22 NC->setCurrentState( Off ); // at least 23 NC->setCurrentState( Off ); // at least
23 // ... but request deeper 24 // ... but request deeper
24 NNNI->runtime()->detectState(NC); 25 NNNI->runtime()->detectState(NC);
25 return 1;
26 } 26 }
27 return 1; 27 return 1;
28 case Disable : 28 case Disable :
29 if( NC->currentState() == IsUp ) { 29 switch( NC->currentState() ) {
30 // bring down -> make available 30 case IsUp :
31 NNNI->runtime()->setState(NC, Down); 31 case Available :
32 } 32 // bring Deactivate (will bring down)
33 if( NC->currentState() == Available ) { 33 if( ! NNNI->runtime()->setState(NC, Deactivate) )
34 // make unavailable 34 return 0;
35 NNNI->runtime()->setState(NC, Deactivate); 35 default :
36 } 36 break;
37 if( NC->currentState() > Available ) {
38 // could not disable
39 return 0;
40 } 37 }
38 Data->Disabled = 1;
41 NC->setCurrentState( Disabled ); 39 NC->setCurrentState( Disabled );
42 return 1; 40 return 1;
43 default : 41 default :
44 break; 42 break;
45 } 43 }
46 return NNNI->runtime()->setState(NC, A); 44 return NNNI->runtime()->setState(NC, A);
47} 45}
48 46
49bool ProfileRun::canSetState( State_t Curr, Action_t A ) { 47bool ProfileRun::canSetState( State_t Curr, Action_t A ) {
50 RuntimeInfo * RI; 48 RuntimeInfo * RI;
51 switch ( A ) { 49 switch ( A ) {
52 case Enable : 50 case Enable :
diff --git a/noncore/settings/networksettings2/profile/profilerun.h b/noncore/settings/networksettings2/profile/profilerun.h
index d3797b5..6e8385c 100644
--- a/noncore/settings/networksettings2/profile/profilerun.h
+++ b/noncore/settings/networksettings2/profile/profilerun.h
@@ -11,18 +11,21 @@ public :
11 ProfileRun( ANetNodeInstance * NNI, ProfileData & D ) : 11 ProfileRun( ANetNodeInstance * NNI, ProfileData & D ) :
12 AsFullSetup( NNI ) 12 AsFullSetup( NNI )
13 { Data = &D; } 13 { Data = &D; }
14 14
15 void detectState( NodeCollection * NC ); 15 void detectState( NodeCollection * NC );
16 bool setState( NodeCollection * NC, Action_t A ); 16 bool setState( NodeCollection * NC, Action_t A );
17 bool canSetState( State_t Curr, Action_t A ); 17 bool canSetState( State_t Curr, Action_t A );
18 18
19 bool handlesInterface( const QString & I ); 19 bool handlesInterface( const QString & I );
20 20
21 virtual const QString & description( void ) 21 virtual const QString & description( void )
22 { return Data->Description; } 22 { return Data->Description; }
23
24 virtual AsFullSetup * asFullSetup( void )
25 { return (AsFullSetup *)this; }
23private : 26private :
24 27
25 ProfileData * Data; 28 ProfileData * Data;
26 29
27}; 30};
28#endif 31#endif
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp
index c65771d..be4a2bc 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NN.cpp
@@ -33,28 +33,35 @@ const char ** USBNetNode::needs( void ) {
33 return USBNeeds; 33 return USBNeeds;
34} 34}
35 35
36const char * USBNetNode::provides( void ) { 36const char * USBNetNode::provides( void ) {
37 return "device"; 37 return "device";
38} 38}
39 39
40bool USBNetNode::generateProperFilesFor( 40bool USBNetNode::generateProperFilesFor(
41 ANetNodeInstance * ) { 41 ANetNodeInstance * ) {
42 return 1; 42 return 1;
43} 43}
44 44
45bool USBNetNode::hasDataFor( const QString & S ) { 45bool USBNetNode::hasDataFor( const QString & S, bool ) {
46 return (S== "interfaces"); 46 return (S== "interfaces");
47} 47}
48 48
49bool USBNetNode::generateDataForCommonFile( 49bool USBNetNode::generateDataForCommonFile(
50 SystemFile & S , 50 SystemFile & S ,
51 long DevNr, 51 long DevNr,
52 ANetNodeInstance * NNI) { 52 ANetNodeInstance * NNI) {
53 return ((AUSB *)NNI)->generateDataForCommonFile(S, DevNr); 53 return ((AUSB *)NNI)->generateDataForCommonFile(S, DevNr);
54} 54}
55 55
56bool USBNetNode::generateDeviceDataForCommonFile(
57 SystemFile & S ,
58 long DevNr,
59 ANetNodeInstance * NNI) {
60 return ((AUSB *)NNI)->generateDeviceDataForCommonFile(S, DevNr);
61}
62
56extern "C" { 63extern "C" {
57void create_plugin( QList<ANetNode> & PNN ) { 64void create_plugin( QList<ANetNode> & PNN ) {
58 PNN.append( new USBNetNode() ); 65 PNN.append( new USBNetNode() );
59} 66}
60} 67}
diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h
index 8b97452..8ff5289 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.h
+++ b/noncore/settings/networksettings2/usb/usb_NN.h
@@ -19,26 +19,28 @@ public:
19 19
20 virtual const QString nodeName() 20 virtual const QString nodeName()
21 { return tr("USB Cable Connect"); } 21 { return tr("USB Cable Connect"); }
22 22
23 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
24 24
25 virtual ANetNodeInstance * createInstance( void ); 25 virtual ANetNodeInstance * createInstance( void );
26 26
27 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
28 virtual const char * provides( void ); 28 virtual const char * provides( void );
29 29
30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
31 virtual bool hasDataFor( const QString & S ); 31 virtual bool hasDataFor( const QString & S, bool DeviceSpec );
32 virtual bool generateDataForCommonFile( 32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); 33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 virtual bool generateDeviceDataForCommonFile(
35 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 36
35private: 37private:
36 38
37}; 39};
38 40
39extern "C" 41extern "C"
40{ 42{
41 void create_plugin( QList<ANetNode> & PNN ); 43 void create_plugin( QList<ANetNode> & PNN );
42}; 44};
43 45
44#endif 46#endif
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.cpp b/noncore/settings/networksettings2/usb/usb_NNI.cpp
index 4729416..6fcd6d5 100644
--- a/noncore/settings/networksettings2/usb/usb_NNI.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NNI.cpp
@@ -34,13 +34,24 @@ void AUSB::commit( void ) {
34 34
35bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) { 35bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) {
36 AsDevice * Dev = runtime()->device(); 36 AsDevice * Dev = runtime()->device();
37 QString NIC = Dev->genNic( DevNr ); 37 QString NIC = Dev->genNic( DevNr );
38 38
39 if( S.name() == "interfaces" ) { 39 if( S.name() == "interfaces" ) {
40 // generate mapping stanza for this interface 40 // generate mapping stanza for this interface
41 S << " pre-up " << QPEApplication::qpeDir() << "bin/setmacaddress.sh " << NIC << " || true" << endl; 41 S << " pre-up " << QPEApplication::qpeDir() << "bin/setmacaddress.sh " << NIC << " || true" << endl;
42 } 42 }
43 return 0; 43 return 0;
44} 44}
45 45
46bool AUSB::generateDeviceDataForCommonFile( SystemFile & S, long DevNr ) {
47 AsDevice * Dev = runtime()->device();
48 QString NIC = Dev->genNic( DevNr );
46 49
50 if( S.name() == "interfaces" ) {
51 // generate mapping stanza for this interface
52 S << "# check if " << NIC << " can be brought UP" << endl;
53 S << "mapping " << NIC << endl;
54 S << " script networksettings2-request" << endl << endl;
55 }
56 return 0;
57}
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.h b/noncore/settings/networksettings2/usb/usb_NNI.h
index b09f17a..5dead36 100644
--- a/noncore/settings/networksettings2/usb/usb_NNI.h
+++ b/noncore/settings/networksettings2/usb/usb_NNI.h
@@ -19,24 +19,25 @@ public :
19 void commit( void ); 19 void commit( void );
20 20
21 RuntimeInfo * runtime( void ) 21 RuntimeInfo * runtime( void )
22 { if( RT == 0 ) 22 { if( RT == 0 )
23 RT = new USBRun( this, Data ); 23 RT = new USBRun( this, Data );
24 return RT; 24 return RT;
25 } 25 }
26 26
27 virtual void * data( void ) 27 virtual void * data( void )
28 { return (void *)&Data; } 28 { return (void *)&Data; }
29 29
30 bool generateDataForCommonFile( SystemFile & S, long DevNr ); 30 bool generateDataForCommonFile( SystemFile & S, long DevNr );
31 bool generateDeviceDataForCommonFile( SystemFile & S, long DevNr );
31 32
32protected : 33protected :
33 34
34 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 35 virtual void setSpecificAttribute( QString & Attr, QString & Value );
35 virtual void saveSpecificAttribute( QTextStream & TS ); 36 virtual void saveSpecificAttribute( QTextStream & TS );
36 37
37private : 38private :
38 39
39 USBEdit * GUI; 40 USBEdit * GUI;
40 USBData Data; 41 USBData Data;
41 USBRun * RT; 42 USBRun * RT;
42}; 43};
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp
index 49b5a77..3007e79 100644
--- a/noncore/settings/networksettings2/usb/usbrun.cpp
+++ b/noncore/settings/networksettings2/usb/usbrun.cpp
@@ -25,43 +25,54 @@ void USBRun::detectState( NodeCollection * NC ) {
25 ++It ) { 25 ++It ) {
26 Run = It.current(); 26 Run = It.current();
27 if( X == Run->Name ) { 27 if( X == Run->Name ) {
28 Run->assignNode( netNode() ); 28 Run->assignNode( netNode() );
29 assignInterface( Run ); 29 assignInterface( Run );
30 NC->setCurrentState( IsUp ); 30 NC->setCurrentState( IsUp );
31 return; 31 return;
32 } 32 }
33 } 33 }
34 } 34 }
35 } 35 }
36 36
37 fprintf( stderr, "NUP\n" ); 37 fprintf( stderr, "Assigned %p\n", assignedInterface() );
38 // definitively not up 38 if( ( Run = assignedInterface() ) ) {
39 // we already have an interface assigned -> still present ?
40 if( ! Run->IsUp ) {
41 // usb is still free -> keep assignment
42 NC->setCurrentState( Available );
43 return;
44 } // else interface is up but NOT us -> some other profile
45 }
46
47 // nothing (valid) assigned to us
39 assignInterface( 0 ); 48 assignInterface( 0 );
40 49
41 // find possible interface 50 // find possible interface
42 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 51 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
43 It.current(); 52 It.current();
44 ++It ) { 53 ++It ) {
45 Run = It.current(); 54 Run = It.current();
55
46 fprintf( stderr, "%s %d %d=%d %d\n", 56 fprintf( stderr, "%s %d %d=%d %d\n",
47 Run->Name.latin1(), 57 Run->Name.latin1(),
48 handlesInterface( Run->Name ), 58 handlesInterface( Run->Name ),
49 Run->CardType, ARPHRD_ETHER, 59 Run->CardType, ARPHRD_ETHER,
50 ! Run->IsUp ); 60 ! Run->IsUp );
61
51 if( handlesInterface( Run->Name ) && 62 if( handlesInterface( Run->Name ) &&
52 Run->CardType == ARPHRD_ETHER && 63 Run->CardType == ARPHRD_ETHER &&
53 ! Run->IsUp 64 ! Run->IsUp
54 ) { 65 ) {
55 fprintf( stderr, "OFF\n" ); 66 fprintf( stderr, "Released(OFF)\n" );
56 // proper type, and Not UP -> free 67 // proper type, and Not UP -> free
57 NC->setCurrentState( Off ); 68 NC->setCurrentState( Off );
58 return; 69 return;
59 } 70 }
60 } 71 }
61 // no free found 72 // no free found
62 fprintf( stderr, "UNA\n" ); 73 fprintf( stderr, "UNA\n" );
63 74
64 NC->setCurrentState( Unavailable ); 75 NC->setCurrentState( Unavailable );
65} 76}
66 77
67bool USBRun::setState( NodeCollection * NC, Action_t A ) { 78bool USBRun::setState( NodeCollection * NC, Action_t A ) {
@@ -74,35 +85,35 @@ bool USBRun::setState( NodeCollection * NC, Action_t A ) {
74 return 0; 85 return 0;
75 } 86 }
76 InterfaceInfo * N = getInterface(); 87 InterfaceInfo * N = getInterface();
77 if( ! N ) { 88 if( ! N ) {
78 // no interface available 89 // no interface available
79 NC->setCurrentState( Unavailable ); 90 NC->setCurrentState( Unavailable );
80 return 0; 91 return 0;
81 } 92 }
82 // because we were OFF the interface 93 // because we were OFF the interface
83 // we get back is NOT assigned 94 // we get back is NOT assigned
84 N->assignNode( netNode() ); 95 N->assignNode( netNode() );
85 assignInterface( N ); 96 assignInterface( N );
97 fprintf( stderr, "Assing %p\n", N );
86 NC->setCurrentState( Available ); 98 NC->setCurrentState( Available );
87 return 1; 99 return 1;
88 } 100 }
89 case Deactivate : 101 case Deactivate :
90 if( NC->currentState() == IsUp ) { 102 if( NC->currentState() == IsUp ) {
91 // bring down first 103 // bring down first
92 if( ! connection()->setState( Down ) ) 104 if( ! connection()->setState( Down ) )
93 // could not ... 105 // could not ...
94 return 0; 106 return 0;
95 } 107 } else if( NC->currentState() != Available ) {
96 if( NC->currentState() != Available ) {
97 return 1; 108 return 1;
98 } 109 }
99 assignedInterface()->assignNode( 0 ); // release 110 assignedInterface()->assignNode( 0 ); // release
100 assignInterface( 0 ); 111 assignInterface( 0 );
101 NC->setCurrentState( Off ); 112 NC->setCurrentState( Off );
102 return 1; 113 return 1;
103 default : 114 default :
104 // FT 115 // FT
105 break; 116 break;
106 } 117 }
107 return 0; 118 return 0;
108} 119}
diff --git a/noncore/settings/networksettings2/usb/usbrun.h b/noncore/settings/networksettings2/usb/usbrun.h
index c9c9121..60f9fe8 100644
--- a/noncore/settings/networksettings2/usb/usbrun.h
+++ b/noncore/settings/networksettings2/usb/usbrun.h
@@ -9,27 +9,30 @@ class USBRun : public AsDevice {
9 9
10public : 10public :
11 11
12 USBRun( ANetNodeInstance * NNI, 12 USBRun( ANetNodeInstance * NNI,
13 USBData & Data ) : 13 USBData & Data ) :
14 AsDevice( NNI ), 14 AsDevice( NNI ),
15 Pat( "usb[0-9abcdef]" ) 15 Pat( "usb[0-9abcdef]" )
16 { } 16 { }
17 17
18 virtual long count( void ) 18 virtual long count( void )
19 { return 1; } 19 { return 1; }
20 virtual QString genNic( long nr ); 20 virtual QString genNic( long nr );
21
21 virtual AsDevice * device( void ) 22 virtual AsDevice * device( void )
22 { return asDevice(); } 23 { return (AsDevice *)this; }
23 24
25 virtual AsDevice * asDevice( void )
26 { return (AsDevice *)this; }
24protected : 27protected :
25 28
26 void detectState( NodeCollection * ); 29 void detectState( NodeCollection * );
27 bool setState( NodeCollection * , Action_t A ); 30 bool setState( NodeCollection * , Action_t A );
28 bool canSetState( State_t , Action_t A ); 31 bool canSetState( State_t , Action_t A );
29 32
30 bool handlesInterface( const QString & I ); 33 bool handlesInterface( const QString & I );
31 34
32private : 35private :
33 36
34 InterfaceInfo * getInterface( void ); 37 InterfaceInfo * getInterface( void );
35 QRegExp Pat; 38 QRegExp Pat;
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
index c800929..f570fb2 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
@@ -34,28 +34,35 @@ const char ** VPNNetNode::needs( void ) {
34 return VPNNeeds; 34 return VPNNeeds;
35} 35}
36 36
37const char * VPNNetNode::provides( void ) { 37const char * VPNNetNode::provides( void ) {
38 return "connection"; 38 return "connection";
39} 39}
40 40
41bool VPNNetNode::generateProperFilesFor( 41bool VPNNetNode::generateProperFilesFor(
42 ANetNodeInstance * ) { 42 ANetNodeInstance * ) {
43 return 1; 43 return 1;
44} 44}
45 45
46bool VPNNetNode::hasDataFor( const QString & ) { 46bool VPNNetNode::hasDataFor( const QString &, bool ) {
47 return 0; 47 return 0;
48} 48}
49 49
50bool VPNNetNode::generateDataForCommonFile( 50bool VPNNetNode::generateDataForCommonFile(
51 SystemFile & , 51 SystemFile & ,
52 long, 52 long,
53 ANetNodeInstance * ) { 53 ANetNodeInstance * ) {
54 return 1; 54 return 1;
55} 55}
56 56
57bool VPNNetNode::generateDeviceDataForCommonFile(
58 SystemFile & ,
59 long ,
60 ANetNodeInstance * ) {
61 return 1;
62}
63
57extern "C" { 64extern "C" {
58void create_plugin( QList<ANetNode> & PNN ) { 65void create_plugin( QList<ANetNode> & PNN ) {
59 PNN.append( new VPNNetNode() ); 66 PNN.append( new VPNNetNode() );
60} 67}
61} 68}
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.h b/noncore/settings/networksettings2/vpn/vpn_NN.h
index a113ab9..cdb5117 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.h
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.h
@@ -19,26 +19,28 @@ public:
19 19
20 virtual const QString nodeName() 20 virtual const QString nodeName()
21 { return tr("VPN Connection"); } 21 { return tr("VPN Connection"); }
22 22
23 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
24 24
25 virtual ANetNodeInstance * createInstance( void ); 25 virtual ANetNodeInstance * createInstance( void );
26 26
27 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
28 virtual const char * provides( void ); 28 virtual const char * provides( void );
29 29
30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
31 virtual bool hasDataFor( const QString & S ); 31 virtual bool hasDataFor( const QString & S, bool DS );
32 virtual bool generateDataForCommonFile( 32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); 33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 virtual bool generateDeviceDataForCommonFile(
35 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 36
35private: 37private:
36 38
37}; 39};
38 40
39extern "C" 41extern "C"
40{ 42{
41 void create_plugin( QList<ANetNode> & PNN ); 43 void create_plugin( QList<ANetNode> & PNN );
42}; 44};
43 45
44#endif 46#endif
diff --git a/noncore/settings/networksettings2/vpn/vpnrun.h b/noncore/settings/networksettings2/vpn/vpnrun.h
index c221fd0..4d26298 100644
--- a/noncore/settings/networksettings2/vpn/vpnrun.h
+++ b/noncore/settings/networksettings2/vpn/vpnrun.h
@@ -3,24 +3,26 @@
3 3
4#include <asconnection.h> 4#include <asconnection.h>
5#include "vpndata.h" 5#include "vpndata.h"
6 6
7class VPNRun : public AsConnection { 7class VPNRun : public AsConnection {
8 8
9public : 9public :
10 10
11 VPNRun( ANetNodeInstance * NNI, VPNData & Data ) : 11 VPNRun( ANetNodeInstance * NNI, VPNData & Data ) :
12 AsConnection( NNI ) 12 AsConnection( NNI )
13 { } 13 { }
14 14
15 virtual AsConnection * asConnection( void )
16 { return (AsConnection *)this; }
15protected : 17protected :
16 18
17 void detectState( NodeCollection * ) 19 void detectState( NodeCollection * )
18 { } 20 { }
19 21
20 bool setState( NodeCollection *, Action_t ) 22 bool setState( NodeCollection *, Action_t )
21 { return 0; } 23 { return 0; }
22 24
23 bool canSetState( State_t, Action_t ) 25 bool canSetState( State_t, Action_t )
24 { return 0; } 26 { return 0; }
25 27
26 bool handlesInterface( const QString & I ); 28 bool handlesInterface( const QString & I );
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
index 5a26e41..e1e20c0 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp
+++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
@@ -33,28 +33,35 @@ const char ** WLanNetNode::needs( void ) {
33 return WLanNeeds; 33 return WLanNeeds;
34} 34}
35 35
36const char * WLanNetNode::provides( void ) { 36const char * WLanNetNode::provides( void ) {
37 return "device"; 37 return "device";
38} 38}
39 39
40bool WLanNetNode::generateProperFilesFor( 40bool WLanNetNode::generateProperFilesFor(
41 ANetNodeInstance * ) { 41 ANetNodeInstance * ) {
42 return 1; 42 return 1;
43} 43}
44 44
45bool WLanNetNode::hasDataFor( const QString & ) { 45bool WLanNetNode::hasDataFor( const QString & S, bool DS ) {
46 return 0; 46 return DS && S == "interfaces";
47} 47}
48 48
49bool WLanNetNode::generateDataForCommonFile( 49bool WLanNetNode::generateDataForCommonFile(
50 SystemFile & , 50 SystemFile &,
51 long, 51 long ,
52 ANetNodeInstance * ) { 52 ANetNodeInstance * ) {
53 return 1; 53 return 1;
54} 54}
55 55
56bool WLanNetNode::generateDeviceDataForCommonFile(
57 SystemFile & S,
58 long DevNr,
59 ANetNodeInstance * NNI ) {
60 return ((AWLan *)NNI)->generateDeviceDataForCommonFile(S, DevNr);
61}
62
56extern "C" { 63extern "C" {
57void create_plugin( QList<ANetNode> & PNN ) { 64void create_plugin( QList<ANetNode> & PNN ) {
58 PNN.append( new WLanNetNode() ); 65 PNN.append( new WLanNetNode() );
59} 66}
60} 67}
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.h b/noncore/settings/networksettings2/wlan/wlan_NN.h
index 0728a79..9111995 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NN.h
+++ b/noncore/settings/networksettings2/wlan/wlan_NN.h
@@ -19,26 +19,28 @@ public:
19 19
20 virtual const QString nodeName() 20 virtual const QString nodeName()
21 { return tr("WLan Device"); } 21 { return tr("WLan Device"); }
22 22
23 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
24 24
25 virtual ANetNodeInstance * createInstance( void ); 25 virtual ANetNodeInstance * createInstance( void );
26 26
27 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
28 virtual const char * provides( void ); 28 virtual const char * provides( void );
29 29
30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 30 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
31 virtual bool hasDataFor( const QString & S ); 31 virtual bool hasDataFor( const QString & S, bool DS );
32 virtual bool generateDataForCommonFile( 32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); 33 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 virtual bool generateDeviceDataForCommonFile(
35 SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
34 36
35private: 37private:
36 38
37}; 39};
38 40
39extern "C" 41extern "C"
40{ 42{
41 void create_plugin( QList<ANetNode> & PNN ); 43 void create_plugin( QList<ANetNode> & PNN );
42}; 44};
43 45
44#endif 46#endif
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
index 92f3457..8b948e0 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
+++ b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
@@ -19,12 +19,24 @@ QWidget * AWLan::edit( QWidget * parent ) {
19 return GUI; 19 return GUI;
20} 20}
21 21
22QString AWLan::acceptable( void ) { 22QString AWLan::acceptable( void ) {
23 return ( GUI ) ? GUI->acceptable( ) : QString(); 23 return ( GUI ) ? GUI->acceptable( ) : QString();
24} 24}
25 25
26void AWLan::commit( void ) { 26void AWLan::commit( void ) {
27 if( GUI && GUI->commit( Data ) ) 27 if( GUI && GUI->commit( Data ) )
28 setModified( 1 ); 28 setModified( 1 );
29} 29}
30 30
31bool AWLan::generateDeviceDataForCommonFile( SystemFile & S, long DevNr ) {
32 AsDevice * Dev = runtime()->device();
33 QString NIC = Dev->genNic( DevNr );
34
35 if( S.name() == "interfaces" ) {
36 // generate mapping stanza for this interface
37 S << "# check if " << NIC << " can be brought UP" << endl;
38 S << "mapping " << NIC << endl;
39 S << " script networksettings2-request" << endl << endl;
40 }
41 return 0;
42}
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.h b/noncore/settings/networksettings2/wlan/wlan_NNI.h
index 8b695b5..e464c84 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NNI.h
+++ b/noncore/settings/networksettings2/wlan/wlan_NNI.h
@@ -18,24 +18,26 @@ public :
18 QString acceptable( void ); 18 QString acceptable( void );
19 void commit( void ); 19 void commit( void );
20 20
21 RuntimeInfo * runtime( void ) 21 RuntimeInfo * runtime( void )
22 { if( RT == 0 ) 22 { if( RT == 0 )
23 RT = new WLanRun( this, Data ); 23 RT = new WLanRun( this, Data );
24 return RT; 24 return RT;
25 } 25 }
26 26
27 virtual void * data( void ) 27 virtual void * data( void )
28 { return (void *)&Data; } 28 { return (void *)&Data; }
29 29
30 bool generateDeviceDataForCommonFile( SystemFile & S, long DevNr );
31
30protected : 32protected :
31 33
32 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 34 virtual void setSpecificAttribute( QString & Attr, QString & Value );
33 virtual void saveSpecificAttribute( QTextStream & TS ); 35 virtual void saveSpecificAttribute( QTextStream & TS );
34 36
35private : 37private :
36 38
37 WLanEdit * GUI; 39 WLanEdit * GUI;
38 WLanData Data; 40 WLanData Data;
39 WLanRun * RT; 41 WLanRun * RT;
40 42
41}; 43};
diff --git a/noncore/settings/networksettings2/wlan/wlanrun.h b/noncore/settings/networksettings2/wlan/wlanrun.h
index 4cbb059..b853262 100644
--- a/noncore/settings/networksettings2/wlan/wlanrun.h
+++ b/noncore/settings/networksettings2/wlan/wlanrun.h
@@ -10,25 +10,27 @@ class WLanRun : public AsDevice {
10public : 10public :
11 11
12 WLanRun( ANetNodeInstance * NNI, WLanData & Data ) : 12 WLanRun( ANetNodeInstance * NNI, WLanData & Data ) :
13 AsDevice( NNI ), 13 AsDevice( NNI ),
14 Pat( "wlan[0-9]" ) 14 Pat( "wlan[0-9]" )
15 { } 15 { }
16 16
17 virtual long count( void ) 17 virtual long count( void )
18 { return 2; } 18 { return 2; }
19 virtual QString genNic( long nr ) 19 virtual QString genNic( long nr )
20 { QString S; return S.sprintf( "wlan%ld", nr ); } 20 { QString S; return S.sprintf( "wlan%ld", nr ); }
21 virtual AsDevice * device( void ) 21 virtual AsDevice * device( void )
22 { return asDevice(); } 22 { return (AsDevice *)this; }
23 virtual AsDevice * asDevice( void )
24 { return (AsDevice *)this; }
23 25
24protected : 26protected :
25 27
26 void detectState( NodeCollection * ) 28 void detectState( NodeCollection * )
27 { } 29 { }
28 30
29 bool setState( NodeCollection *, Action_t ) 31 bool setState( NodeCollection *, Action_t )
30 { return 0; } 32 { return 0; }
31 33
32 bool canSetState( State_t, Action_t ) 34 bool canSetState( State_t, Action_t )
33 { return 0; } 35 { return 0; }
34 36