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 | |||
@@ -13,6 +13,10 @@ public : | |||
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 | ||
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 | |||
@@ -9,6 +9,9 @@ public : | |||
9 | BluetoothRFCOMMData & Data ) : AsLine( NNI ) | 9 | BluetoothRFCOMMData & Data ) : AsLine( NNI ) |
10 | { } | 10 | { } |
11 | 11 | ||
12 | virtual AsLine * asLine( void ) | ||
13 | { return (AsLine *)this; } | ||
14 | |||
12 | protected : | 15 | protected : |
13 | 16 | ||
14 | void detectState( NodeCollection * ) | 17 | void detectState( NodeCollection * ) |
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 | |||
@@ -49,8 +49,8 @@ bool BluetoothBNEPNetNode::generateProperFilesFor( | |||
49 | return 1; | 49 | return 1; |
50 | } | 50 | } |
51 | 51 | ||
52 | bool BluetoothBNEPNetNode::hasDataFor( const QString & ) { | 52 | bool BluetoothBNEPNetNode::hasDataFor( const QString & S, bool DS ) { |
53 | return 0; | 53 | return DS && S == "interfaces"; |
54 | } | 54 | } |
55 | 55 | ||
56 | bool BluetoothBNEPNetNode::generateDataForCommonFile( | 56 | bool BluetoothBNEPNetNode::generateDataForCommonFile( |
@@ -60,6 +60,13 @@ bool BluetoothBNEPNetNode::generateDataForCommonFile( | |||
60 | return 1; | 60 | return 1; |
61 | } | 61 | } |
62 | 62 | ||
63 | bool 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 |
@@ -101,7 +108,7 @@ bool BluetoothRFCOMMNetNode::generateProperFilesFor( | |||
101 | return 0; | 108 | return 0; |
102 | } | 109 | } |
103 | 110 | ||
104 | bool BluetoothRFCOMMNetNode::hasDataFor( const QString & ) { | 111 | bool BluetoothRFCOMMNetNode::hasDataFor( const QString &, bool ) { |
105 | return 0; | 112 | return 0; |
106 | } | 113 | } |
107 | 114 | ||
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 | |||
@@ -28,9 +28,11 @@ public: | |||
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
@@ -59,9 +61,11 @@ public: | |||
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 | ||
66 | private: | 70 | private: |
67 | 71 | ||
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 | |||
@@ -41,7 +41,7 @@ bool CableNetNode::generateProperFilesFor( | |||
41 | return 1; | 41 | return 1; |
42 | } | 42 | } |
43 | 43 | ||
44 | bool CableNetNode::hasDataFor( const QString & ) { | 44 | bool CableNetNode::hasDataFor( const QString &, bool ) { |
45 | return 0; | 45 | return 0; |
46 | } | 46 | } |
47 | 47 | ||
@@ -52,6 +52,13 @@ bool CableNetNode::generateDataForCommonFile( | |||
52 | return 1; | 52 | return 1; |
53 | } | 53 | } |
54 | 54 | ||
55 | bool CableNetNode::generateDeviceDataForCommonFile( | ||
56 | SystemFile & , | ||
57 | long , | ||
58 | ANetNodeInstance * ) { | ||
59 | return 1; | ||
60 | } | ||
61 | |||
55 | extern "C" { | 62 | extern "C" { |
56 | void create_plugin( QList<ANetNode> & PNN ) { | 63 | void create_plugin( QList<ANetNode> & PNN ) { |
57 | PNN.append( new CableNetNode() ); | 64 | PNN.append( new CableNetNode() ); |
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 | |||
@@ -28,9 +28,11 @@ public: | |||
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
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 | |||
@@ -9,6 +9,9 @@ public : | |||
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 | |||
12 | protected : | 15 | protected : |
13 | 16 | ||
14 | void detectState( NodeCollection * NC ); | 17 | void detectState( NodeCollection * NC ); |
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 | |||
@@ -41,7 +41,7 @@ bool IRDANetNode::generateProperFilesFor( | |||
41 | return 1; | 41 | return 1; |
42 | } | 42 | } |
43 | 43 | ||
44 | bool IRDANetNode::hasDataFor( const QString & ) { | 44 | bool IRDANetNode::hasDataFor( const QString &, bool ) { |
45 | return 0; | 45 | return 0; |
46 | } | 46 | } |
47 | 47 | ||
@@ -52,6 +52,13 @@ bool IRDANetNode::generateDataForCommonFile( | |||
52 | return 1; | 52 | return 1; |
53 | } | 53 | } |
54 | 54 | ||
55 | bool IRDANetNode::generateDeviceDataForCommonFile( | ||
56 | SystemFile & , | ||
57 | long , | ||
58 | ANetNodeInstance * ) { | ||
59 | return 1; | ||
60 | } | ||
61 | |||
55 | extern "C" { | 62 | extern "C" { |
56 | void create_plugin( QList<ANetNode> & PNN ) { | 63 | void create_plugin( QList<ANetNode> & PNN ) { |
57 | PNN.append( new IRDANetNode() ); | 64 | PNN.append( new IRDANetNode() ); |
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 | |||
@@ -28,9 +28,11 @@ public: | |||
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
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 | |||
@@ -9,6 +9,9 @@ public : | |||
9 | IRDAData & Data ) : AsLine( NNI ) | 9 | IRDAData & Data ) : AsLine( NNI ) |
10 | { } | 10 | { } |
11 | 11 | ||
12 | virtual AsLine * asLine( void ) | ||
13 | { return (AsLine *)this; } | ||
14 | |||
12 | protected : | 15 | protected : |
13 | 16 | ||
14 | void detectState( NodeCollection * ) | 17 | void detectState( NodeCollection * ) |
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 | |||
@@ -42,8 +42,8 @@ bool LanCardNetNode::generateProperFilesFor( | |||
42 | return 1; | 42 | return 1; |
43 | } | 43 | } |
44 | 44 | ||
45 | bool LanCardNetNode::hasDataFor( const QString & ) { | 45 | bool LanCardNetNode::hasDataFor( const QString & S, bool DS ) { |
46 | return 0; | 46 | return DS && S == "interfaces"; |
47 | } | 47 | } |
48 | 48 | ||
49 | bool LanCardNetNode::generateDataForCommonFile( | 49 | bool LanCardNetNode::generateDataForCommonFile( |
@@ -53,6 +53,13 @@ bool LanCardNetNode::generateDataForCommonFile( | |||
53 | return 1; | 53 | return 1; |
54 | } | 54 | } |
55 | 55 | ||
56 | bool LanCardNetNode::generateDeviceDataForCommonFile( | ||
57 | SystemFile & S , | ||
58 | long DevNr , | ||
59 | ANetNodeInstance * NNI ) { | ||
60 | return ((ALanCard *)NNI)->generateDeviceDataForCommonFile(S, DevNr); | ||
61 | } | ||
62 | |||
56 | extern "C" { | 63 | extern "C" { |
57 | void create_plugin( QList<ANetNode> & PNN ) { | 64 | void create_plugin( QList<ANetNode> & PNN ) { |
58 | PNN.append( new LanCardNetNode() ); | 65 | PNN.append( new LanCardNetNode() ); |
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 | |||
@@ -28,9 +28,11 @@ public: | |||
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
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 | |||
@@ -42,3 +42,17 @@ void ALanCard::commit( void ) { | |||
42 | if( GUI && GUI->commit( Data ) ) | 42 | if( GUI && GUI->commit( Data ) ) |
43 | setModified( 1 ); | 43 | setModified( 1 ); |
44 | } | 44 | } |
45 | |||
46 | bool 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 | |||
@@ -27,6 +27,8 @@ public : | |||
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 | |||
30 | protected : | 32 | protected : |
31 | 33 | ||
32 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 34 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
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 | |||
@@ -36,7 +36,16 @@ void LanCardRun::detectState( NodeCollection * NC ) { | |||
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 |
@@ -87,8 +96,7 @@ bool LanCardRun::setState( NodeCollection * NC, Action_t A ) { | |||
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 |
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 | |||
@@ -18,8 +18,12 @@ public : | |||
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 | ||
24 | protected : | 28 | protected : |
25 | 29 | ||
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 | |||
@@ -42,7 +42,7 @@ bool ModemNetNode::generateProperFilesFor( | |||
42 | return 1; | 42 | return 1; |
43 | } | 43 | } |
44 | 44 | ||
45 | bool ModemNetNode::hasDataFor( const QString & ) { | 45 | bool ModemNetNode::hasDataFor( const QString &, bool ) { |
46 | return 0; | 46 | return 0; |
47 | } | 47 | } |
48 | 48 | ||
@@ -53,6 +53,13 @@ bool ModemNetNode::generateDataForCommonFile( | |||
53 | return 1; | 53 | return 1; |
54 | } | 54 | } |
55 | 55 | ||
56 | bool ModemNetNode::generateDeviceDataForCommonFile( | ||
57 | SystemFile & , | ||
58 | long , | ||
59 | ANetNodeInstance * ) { | ||
60 | return 1; | ||
61 | } | ||
62 | |||
56 | extern "C" { | 63 | extern "C" { |
57 | void create_plugin( QList<ANetNode> & PNN ) { | 64 | void create_plugin( QList<ANetNode> & PNN ) { |
58 | PNN.append( new ModemNetNode() ); | 65 | PNN.append( new ModemNetNode() ); |
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 | |||
@@ -28,9 +28,11 @@ public: | |||
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
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 | |||
@@ -9,6 +9,9 @@ public : | |||
9 | ModemData & Data ) : AsLine ( NNI ) | 9 | ModemData & Data ) : AsLine ( NNI ) |
10 | { } | 10 | { } |
11 | 11 | ||
12 | virtual AsLine * asLine( void ) | ||
13 | { return (AsLine *)this; } | ||
14 | |||
12 | protected : | 15 | protected : |
13 | 16 | ||
14 | void detectState( NodeCollection * ) | 17 | void detectState( NodeCollection * ) |
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 | |||
@@ -43,8 +43,8 @@ bool NetworkNetNode::generateProperFilesFor( | |||
43 | return 1; | 43 | return 1; |
44 | } | 44 | } |
45 | 45 | ||
46 | bool NetworkNetNode::hasDataFor( const QString & S ) { | 46 | bool 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; |
@@ -57,6 +57,13 @@ bool NetworkNetNode::generateDataForCommonFile( | |||
57 | return ((ANetwork *)NNI)->generateDataForCommonFile(S, DevNr); | 57 | return ((ANetwork *)NNI)->generateDataForCommonFile(S, DevNr); |
58 | } | 58 | } |
59 | 59 | ||
60 | bool NetworkNetNode::generateDeviceDataForCommonFile( | ||
61 | SystemFile & , | ||
62 | long , | ||
63 | ANetNodeInstance * ) { | ||
64 | return 1; | ||
65 | } | ||
66 | |||
60 | extern "C" { | 67 | extern "C" { |
61 | void create_plugin( QList<ANetNode> & PNN ) { | 68 | void create_plugin( QList<ANetNode> & PNN ) { |
62 | PNN.append( new NetworkNetNode() ); | 69 | PNN.append( new NetworkNetNode() ); |
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 | |||
@@ -28,9 +28,11 @@ public: | |||
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
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 | |||
@@ -104,11 +104,6 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
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() << |
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 | |||
@@ -52,13 +52,13 @@ QString NetworkEdit::acceptable( void ) { | |||
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(); |
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 | |||
@@ -26,17 +26,19 @@ bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { | |||
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 | } |
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 | |||
@@ -9,6 +9,9 @@ public : | |||
9 | NetworkData & Data ) : AsConnection( NNI ) | 9 | NetworkData & Data ) : AsConnection( NNI ) |
10 | { } | 10 | { } |
11 | 11 | ||
12 | virtual AsConnection * asConnection( void ) | ||
13 | { return (AsConnection *)this; } | ||
14 | |||
12 | protected : | 15 | protected : |
13 | 16 | ||
14 | void detectState( NodeCollection * ); | 17 | void detectState( NodeCollection * ); |
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 | |||
@@ -168,36 +168,54 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { | |||
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 ); |
@@ -333,15 +351,10 @@ void NetworkSettings::SLOT_On( void ) { | |||
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; |
@@ -366,7 +379,7 @@ void NetworkSettings::SLOT_Connect( void ) { | |||
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 |
@@ -383,7 +396,7 @@ void NetworkSettings::SLOT_Connect( void ) { | |||
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 ) { |
@@ -391,7 +404,6 @@ void NetworkSettings::SLOT_Connect( void ) { | |||
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 |
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 | |||
@@ -95,11 +95,15 @@ public: | |||
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 ) |
@@ -215,15 +219,15 @@ public : | |||
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 |
@@ -384,11 +388,14 @@ public: | |||
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 | ||
393 | private : | 400 | private : |
394 | 401 | ||
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 | |||
@@ -38,14 +38,15 @@ System::~System( void ) { | |||
38 | 38 | ||
39 | int System::execute( const QString & S ) { | 39 | int 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 | ||
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 | |||
@@ -30,7 +30,9 @@ SystemFile::SystemFile( const QString & N, const QString & P ){ | |||
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 | } |
@@ -48,6 +50,12 @@ SystemFile::SystemFile( const QString & N, const QString & P ){ | |||
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 | ||
@@ -108,7 +116,7 @@ bool SystemFile::postSection( void ) { | |||
108 | 116 | ||
109 | bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) { | 117 | bool 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 ); |
@@ -126,7 +134,7 @@ bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) { | |||
126 | 134 | ||
127 | bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long DevNr ) { | 135 | bool 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 ); |
@@ -142,3 +150,38 @@ bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long DevNr ) { | |||
142 | return 0; | 150 | return 0; |
143 | } | 151 | } |
144 | 152 | ||
153 | bool 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 | |||
171 | bool 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 | |||
@@ -24,6 +24,8 @@ public : | |||
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 | ||
28 | private : | 30 | private : |
29 | 31 | ||
@@ -31,9 +33,11 @@ private : | |||
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 | |||
@@ -188,6 +188,7 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { | |||
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 | // |
@@ -214,7 +215,9 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { | |||
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; |
@@ -241,7 +244,6 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { | |||
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(); |
@@ -263,21 +265,19 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { | |||
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>" ). |
@@ -285,39 +285,128 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { | |||
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>" ). |
@@ -326,9 +415,71 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { | |||
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() ) { |
@@ -337,6 +488,7 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { | |||
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 | } |
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 | |||
@@ -44,7 +44,7 @@ bool PPPNetNode::generateProperFilesFor( | |||
44 | return 1; | 44 | return 1; |
45 | } | 45 | } |
46 | 46 | ||
47 | bool PPPNetNode::hasDataFor( const QString & ) { | 47 | bool PPPNetNode::hasDataFor( const QString &, bool ) { |
48 | return 0; | 48 | return 0; |
49 | } | 49 | } |
50 | 50 | ||
@@ -55,6 +55,13 @@ bool PPPNetNode::generateDataForCommonFile( | |||
55 | return 1; | 55 | return 1; |
56 | } | 56 | } |
57 | 57 | ||
58 | bool PPPNetNode::generateDeviceDataForCommonFile( | ||
59 | SystemFile & , | ||
60 | long , | ||
61 | ANetNodeInstance * ) { | ||
62 | return 1; | ||
63 | } | ||
64 | |||
58 | extern "C" { | 65 | extern "C" { |
59 | void create_plugin( QList<ANetNode> & PNN ) { | 66 | void create_plugin( QList<ANetNode> & PNN ) { |
60 | PNN.append( new PPPNetNode() ); | 67 | PNN.append( new PPPNetNode() ); |
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 | |||
@@ -28,9 +28,11 @@ public: | |||
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
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 | |||
@@ -16,15 +16,7 @@ void PPPRun::detectState( NodeCollection * NC ) { | |||
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 | ||
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 | |||
@@ -15,8 +15,14 @@ public : | |||
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 | ||
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 | |||
@@ -43,7 +43,7 @@ bool ProfileNetNode::generateProperFilesFor( | |||
43 | return 1; | 43 | return 1; |
44 | } | 44 | } |
45 | 45 | ||
46 | bool ProfileNetNode::hasDataFor( const QString & ) { | 46 | bool ProfileNetNode::hasDataFor( const QString &, bool ) { |
47 | return 0; | 47 | return 0; |
48 | } | 48 | } |
49 | 49 | ||
@@ -54,6 +54,13 @@ bool ProfileNetNode::generateDataForCommonFile( | |||
54 | return 1; | 54 | return 1; |
55 | } | 55 | } |
56 | 56 | ||
57 | bool ProfileNetNode::generateDeviceDataForCommonFile( | ||
58 | SystemFile & , | ||
59 | long , | ||
60 | ANetNodeInstance * ) { | ||
61 | return 1; | ||
62 | } | ||
63 | |||
57 | extern "C" { | 64 | extern "C" { |
58 | void create_plugin( QList<ANetNode> & PNN ) { | 65 | void create_plugin( QList<ANetNode> & PNN ) { |
59 | PNN.append( new ProfileNetNode() ); | 66 | PNN.append( new ProfileNetNode() ); |
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 | |||
@@ -28,9 +28,11 @@ public: | |||
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
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 | |||
@@ -19,25 +19,23 @@ bool ProfileRun::setState( NodeCollection * NC, Action_t A ) { | |||
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 : |
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 | |||
@@ -20,6 +20,9 @@ public : | |||
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; } | ||
23 | private : | 26 | private : |
24 | 27 | ||
25 | ProfileData * Data; | 28 | ProfileData * Data; |
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 | |||
@@ -42,7 +42,7 @@ bool USBNetNode::generateProperFilesFor( | |||
42 | return 1; | 42 | return 1; |
43 | } | 43 | } |
44 | 44 | ||
45 | bool USBNetNode::hasDataFor( const QString & S ) { | 45 | bool USBNetNode::hasDataFor( const QString & S, bool ) { |
46 | return (S== "interfaces"); | 46 | return (S== "interfaces"); |
47 | } | 47 | } |
48 | 48 | ||
@@ -53,6 +53,13 @@ bool USBNetNode::generateDataForCommonFile( | |||
53 | return ((AUSB *)NNI)->generateDataForCommonFile(S, DevNr); | 53 | return ((AUSB *)NNI)->generateDataForCommonFile(S, DevNr); |
54 | } | 54 | } |
55 | 55 | ||
56 | bool USBNetNode::generateDeviceDataForCommonFile( | ||
57 | SystemFile & S , | ||
58 | long DevNr, | ||
59 | ANetNodeInstance * NNI) { | ||
60 | return ((AUSB *)NNI)->generateDeviceDataForCommonFile(S, DevNr); | ||
61 | } | ||
62 | |||
56 | extern "C" { | 63 | extern "C" { |
57 | void create_plugin( QList<ANetNode> & PNN ) { | 64 | void create_plugin( QList<ANetNode> & PNN ) { |
58 | PNN.append( new USBNetNode() ); | 65 | PNN.append( new USBNetNode() ); |
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 | |||
@@ -28,9 +28,11 @@ public: | |||
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
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 | |||
@@ -43,4 +43,15 @@ bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
43 | return 0; | 43 | return 0; |
44 | } | 44 | } |
45 | 45 | ||
46 | bool 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 | |||
@@ -28,6 +28,7 @@ public : | |||
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 | ||
32 | protected : | 33 | protected : |
33 | 34 | ||
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 | |||
@@ -34,8 +34,17 @@ void USBRun::detectState( NodeCollection * NC ) { | |||
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 |
@@ -43,16 +52,18 @@ void USBRun::detectState( NodeCollection * NC ) { | |||
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; |
@@ -83,6 +94,7 @@ bool USBRun::setState( NodeCollection * NC, Action_t A ) { | |||
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 | } |
@@ -92,8 +104,7 @@ bool USBRun::setState( NodeCollection * NC, Action_t A ) { | |||
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 |
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 | |||
@@ -18,9 +18,12 @@ public : | |||
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; } | ||
24 | protected : | 27 | protected : |
25 | 28 | ||
26 | void detectState( NodeCollection * ); | 29 | void detectState( NodeCollection * ); |
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 | |||
@@ -43,7 +43,7 @@ bool VPNNetNode::generateProperFilesFor( | |||
43 | return 1; | 43 | return 1; |
44 | } | 44 | } |
45 | 45 | ||
46 | bool VPNNetNode::hasDataFor( const QString & ) { | 46 | bool VPNNetNode::hasDataFor( const QString &, bool ) { |
47 | return 0; | 47 | return 0; |
48 | } | 48 | } |
49 | 49 | ||
@@ -54,6 +54,13 @@ bool VPNNetNode::generateDataForCommonFile( | |||
54 | return 1; | 54 | return 1; |
55 | } | 55 | } |
56 | 56 | ||
57 | bool VPNNetNode::generateDeviceDataForCommonFile( | ||
58 | SystemFile & , | ||
59 | long , | ||
60 | ANetNodeInstance * ) { | ||
61 | return 1; | ||
62 | } | ||
63 | |||
57 | extern "C" { | 64 | extern "C" { |
58 | void create_plugin( QList<ANetNode> & PNN ) { | 65 | void create_plugin( QList<ANetNode> & PNN ) { |
59 | PNN.append( new VPNNetNode() ); | 66 | PNN.append( new VPNNetNode() ); |
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 | |||
@@ -28,9 +28,11 @@ public: | |||
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
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 | |||
@@ -12,6 +12,8 @@ public : | |||
12 | AsConnection( NNI ) | 12 | AsConnection( NNI ) |
13 | { } | 13 | { } |
14 | 14 | ||
15 | virtual AsConnection * asConnection( void ) | ||
16 | { return (AsConnection *)this; } | ||
15 | protected : | 17 | protected : |
16 | 18 | ||
17 | void detectState( NodeCollection * ) | 19 | void detectState( NodeCollection * ) |
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 | |||
@@ -42,17 +42,24 @@ bool WLanNetNode::generateProperFilesFor( | |||
42 | return 1; | 42 | return 1; |
43 | } | 43 | } |
44 | 44 | ||
45 | bool WLanNetNode::hasDataFor( const QString & ) { | 45 | bool WLanNetNode::hasDataFor( const QString & S, bool DS ) { |
46 | return 0; | 46 | return DS && S == "interfaces"; |
47 | } | 47 | } |
48 | 48 | ||
49 | bool WLanNetNode::generateDataForCommonFile( | 49 | bool WLanNetNode::generateDataForCommonFile( |
50 | SystemFile & , | 50 | SystemFile &, |
51 | long, | 51 | long , |
52 | ANetNodeInstance * ) { | 52 | ANetNodeInstance * ) { |
53 | return 1; | 53 | return 1; |
54 | } | 54 | } |
55 | 55 | ||
56 | bool WLanNetNode::generateDeviceDataForCommonFile( | ||
57 | SystemFile & S, | ||
58 | long DevNr, | ||
59 | ANetNodeInstance * NNI ) { | ||
60 | return ((AWLan *)NNI)->generateDeviceDataForCommonFile(S, DevNr); | ||
61 | } | ||
62 | |||
56 | extern "C" { | 63 | extern "C" { |
57 | void create_plugin( QList<ANetNode> & PNN ) { | 64 | void create_plugin( QList<ANetNode> & PNN ) { |
58 | PNN.append( new WLanNetNode() ); | 65 | PNN.append( new WLanNetNode() ); |
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 | |||
@@ -28,9 +28,11 @@ public: | |||
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
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 | |||
@@ -28,3 +28,15 @@ void AWLan::commit( void ) { | |||
28 | setModified( 1 ); | 28 | setModified( 1 ); |
29 | } | 29 | } |
30 | 30 | ||
31 | bool 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 | |||
@@ -27,6 +27,8 @@ public : | |||
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 | |||
30 | protected : | 32 | protected : |
31 | 33 | ||
32 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 34 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
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 | |||
@@ -19,7 +19,9 @@ public : | |||
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 | ||
24 | protected : | 26 | protected : |
25 | 27 | ||