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 | |||
@@ -1,31 +1,35 @@ | |||
1 | #include <asdevice.h> | 1 | #include <asdevice.h> |
2 | #include "bluetoothBNEPdata.h" | 2 | #include "bluetoothBNEPdata.h" |
3 | 3 | ||
4 | class BluetoothBNEPRun : public AsDevice { | 4 | class BluetoothBNEPRun : public AsDevice { |
5 | 5 | ||
6 | public : | 6 | public : |
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 | ||
19 | protected : | 23 | protected : |
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 ) |
28 | { return 0; } | 32 | { return 0; } |
29 | 33 | ||
30 | bool handlesInterface( const QString & ) | 34 | bool handlesInterface( const QString & ) |
31 | { return 0; } | 35 | { return 0; } |
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 | ||
4 | class BluetoothRFCOMMRun : public AsLine { | 4 | class BluetoothRFCOMMRun : public AsLine { |
5 | 5 | ||
6 | public : | 6 | public : |
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 | |||
12 | protected : | 15 | protected : |
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 | |||
@@ -36,43 +36,50 @@ ANetNodeInstance * BluetoothBNEPNetNode::createInstance( void ) { | |||
36 | return new ABluetoothBNEP( this ); | 36 | return new ABluetoothBNEP( this ); |
37 | } | 37 | } |
38 | 38 | ||
39 | const char ** BluetoothBNEPNetNode::needs( void ) { | 39 | const char ** BluetoothBNEPNetNode::needs( void ) { |
40 | return BluetoothBNEPNeeds; | 40 | return BluetoothBNEPNeeds; |
41 | } | 41 | } |
42 | 42 | ||
43 | const char * BluetoothBNEPNetNode::provides( void ) { | 43 | const char * BluetoothBNEPNetNode::provides( void ) { |
44 | return "device"; | 44 | return "device"; |
45 | } | 45 | } |
46 | 46 | ||
47 | bool BluetoothBNEPNetNode::generateProperFilesFor( | 47 | bool BluetoothBNEPNetNode::generateProperFilesFor( |
48 | ANetNodeInstance * ) { | 48 | ANetNodeInstance * ) { |
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( |
57 | SystemFile & , | 57 | SystemFile & , |
58 | long , | 58 | long , |
59 | ANetNodeInstance * ) { | 59 | ANetNodeInstance * ) { |
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 |
66 | // | 73 | // |
67 | // | 74 | // |
68 | 75 | ||
69 | static const char * BluetoothRFCOMMNeeds[] = | 76 | static const char * BluetoothRFCOMMNeeds[] = |
70 | { 0 | 77 | { 0 |
71 | }; | 78 | }; |
72 | 79 | ||
73 | BluetoothRFCOMMNetNode::BluetoothRFCOMMNetNode() : ANetNode() { | 80 | BluetoothRFCOMMNetNode::BluetoothRFCOMMNetNode() : ANetNode() { |
74 | } | 81 | } |
75 | 82 | ||
76 | BluetoothRFCOMMNetNode::~BluetoothRFCOMMNetNode(){ | 83 | BluetoothRFCOMMNetNode::~BluetoothRFCOMMNetNode(){ |
77 | } | 84 | } |
78 | 85 | ||
@@ -88,33 +95,33 @@ ANetNodeInstance * BluetoothRFCOMMNetNode::createInstance( void ) { | |||
88 | return new ABluetoothRFCOMM( this ); | 95 | return new ABluetoothRFCOMM( this ); |
89 | } | 96 | } |
90 | 97 | ||
91 | const char ** BluetoothRFCOMMNetNode::needs( void ) { | 98 | const char ** BluetoothRFCOMMNetNode::needs( void ) { |
92 | return BluetoothRFCOMMNeeds; | 99 | return BluetoothRFCOMMNeeds; |
93 | } | 100 | } |
94 | 101 | ||
95 | const char * BluetoothRFCOMMNetNode::provides( void ) { | 102 | const char * BluetoothRFCOMMNetNode::provides( void ) { |
96 | return "line"; | 103 | return "line"; |
97 | } | 104 | } |
98 | 105 | ||
99 | bool BluetoothRFCOMMNetNode::generateProperFilesFor( | 106 | bool BluetoothRFCOMMNetNode::generateProperFilesFor( |
100 | ANetNodeInstance * ) { | 107 | ANetNodeInstance * ) { |
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 | ||
108 | bool BluetoothRFCOMMNetNode::generateDataForCommonFile( | 115 | bool BluetoothRFCOMMNetNode::generateDataForCommonFile( |
109 | SystemFile & , | 116 | SystemFile & , |
110 | long, | 117 | long, |
111 | ANetNodeInstance * ) { | 118 | ANetNodeInstance * ) { |
112 | return 0; | 119 | return 0; |
113 | } | 120 | } |
114 | 121 | ||
115 | extern "C" { | 122 | extern "C" { |
116 | void create_plugin( QList<ANetNode> & PNN ) { | 123 | void create_plugin( QList<ANetNode> & PNN ) { |
117 | PNN.append( new BluetoothBNEPNetNode() ); | 124 | PNN.append( new BluetoothBNEPNetNode() ); |
118 | PNN.append( new BluetoothRFCOMMNetNode() ); | 125 | PNN.append( new BluetoothRFCOMMNetNode() ); |
119 | } | 126 | } |
120 | } | 127 | } |
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 | |||
@@ -15,61 +15,65 @@ public: | |||
15 | virtual ~BluetoothBNEPNetNode(); | 15 | virtual ~BluetoothBNEPNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/bluetooth"; } | 18 | { return "Devices/bluetooth"; } |
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | class BluetoothRFCOMMNetNode : public ANetNode { | 41 | class BluetoothRFCOMMNetNode : public ANetNode { |
40 | 42 | ||
41 | Q_OBJECT | 43 | Q_OBJECT |
42 | 44 | ||
43 | public: | 45 | public: |
44 | 46 | ||
45 | BluetoothRFCOMMNetNode(); | 47 | BluetoothRFCOMMNetNode(); |
46 | virtual ~BluetoothRFCOMMNetNode(); | 48 | virtual ~BluetoothRFCOMMNetNode(); |
47 | 49 | ||
48 | virtual const QString pixmapName() | 50 | virtual const QString pixmapName() |
49 | { return "Devices/bluetooth"; } | 51 | { return "Devices/bluetooth"; } |
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 | ||
66 | private: | 70 | private: |
67 | 71 | ||
68 | }; | 72 | }; |
69 | 73 | ||
70 | extern "C" | 74 | extern "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 | |||
@@ -28,32 +28,39 @@ ANetNodeInstance * CableNetNode::createInstance( void ) { | |||
28 | return new ACable( this ); | 28 | return new ACable( this ); |
29 | } | 29 | } |
30 | 30 | ||
31 | const char ** CableNetNode::needs( void ) { | 31 | const char ** CableNetNode::needs( void ) { |
32 | return CableNeeds; | 32 | return CableNeeds; |
33 | } | 33 | } |
34 | 34 | ||
35 | const char * CableNetNode::provides( void ) { | 35 | const char * CableNetNode::provides( void ) { |
36 | return "line"; | 36 | return "line"; |
37 | } | 37 | } |
38 | 38 | ||
39 | bool CableNetNode::generateProperFilesFor( | 39 | bool CableNetNode::generateProperFilesFor( |
40 | ANetNodeInstance * ) { | 40 | ANetNodeInstance * ) { |
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 | ||
48 | bool CableNetNode::generateDataForCommonFile( | 48 | bool CableNetNode::generateDataForCommonFile( |
49 | SystemFile & , | 49 | SystemFile & , |
50 | long , | 50 | long , |
51 | ANetNodeInstance * ) { | 51 | ANetNodeInstance * ) { |
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() ); |
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 | |||
@@ -15,30 +15,32 @@ public: | |||
15 | virtual ~CableNetNode(); | 15 | virtual ~CableNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/cable"; } | 18 | { return "Devices/cable"; } |
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | extern "C" | 41 | extern "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 | ||
4 | class CableRun : public AsLine { | 4 | class CableRun : public AsLine { |
5 | 5 | ||
6 | public : | 6 | public : |
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 | |||
12 | protected : | 15 | protected : |
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 | ||
18 | private : | 21 | private : |
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 | |||
@@ -28,32 +28,39 @@ ANetNodeInstance * IRDANetNode::createInstance( void ) { | |||
28 | return new AIRDA( this ); | 28 | return new AIRDA( this ); |
29 | } | 29 | } |
30 | 30 | ||
31 | const char ** IRDANetNode::needs( void ) { | 31 | const char ** IRDANetNode::needs( void ) { |
32 | return IRDANeeds; | 32 | return IRDANeeds; |
33 | } | 33 | } |
34 | 34 | ||
35 | const char * IRDANetNode::provides( void ) { | 35 | const char * IRDANetNode::provides( void ) { |
36 | return "line"; | 36 | return "line"; |
37 | } | 37 | } |
38 | 38 | ||
39 | bool IRDANetNode::generateProperFilesFor( | 39 | bool IRDANetNode::generateProperFilesFor( |
40 | ANetNodeInstance * ) { | 40 | ANetNodeInstance * ) { |
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 | ||
48 | bool IRDANetNode::generateDataForCommonFile( | 48 | bool IRDANetNode::generateDataForCommonFile( |
49 | SystemFile & , | 49 | SystemFile & , |
50 | long , | 50 | long , |
51 | ANetNodeInstance * ) { | 51 | ANetNodeInstance * ) { |
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() ); |
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 | |||
@@ -15,30 +15,32 @@ public: | |||
15 | virtual ~IRDANetNode(); | 15 | virtual ~IRDANetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/irda"; } | 18 | { return "Devices/irda"; } |
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | extern "C" | 41 | extern "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 | ||
4 | class IRDARun : public AsLine { | 4 | class IRDARun : public AsLine { |
5 | 5 | ||
6 | public : | 6 | public : |
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 | |||
12 | protected : | 15 | protected : |
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 | |||
@@ -29,32 +29,39 @@ ANetNodeInstance * LanCardNetNode::createInstance( void ) { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | 31 | ||
32 | const char ** LanCardNetNode::needs( void ) { | 32 | const char ** LanCardNetNode::needs( void ) { |
33 | return LanCardNeeds; | 33 | return LanCardNeeds; |
34 | } | 34 | } |
35 | 35 | ||
36 | const char * LanCardNetNode::provides( void ) { | 36 | const char * LanCardNetNode::provides( void ) { |
37 | return "device"; | 37 | return "device"; |
38 | } | 38 | } |
39 | 39 | ||
40 | bool LanCardNetNode::generateProperFilesFor( | 40 | bool LanCardNetNode::generateProperFilesFor( |
41 | ANetNodeInstance * ) { | 41 | ANetNodeInstance * ) { |
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( |
50 | SystemFile & , | 50 | SystemFile & , |
51 | long , | 51 | long , |
52 | ANetNodeInstance * ) { | 52 | ANetNodeInstance * ) { |
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() ); |
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 | |||
@@ -15,30 +15,32 @@ public: | |||
15 | virtual ~LanCardNetNode(); | 15 | virtual ~LanCardNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/card"; } | 18 | { return "Devices/card"; } |
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | extern "C" | 41 | extern "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 | |||
@@ -29,16 +29,30 @@ void ALanCard::saveSpecificAttribute( QTextStream & TS) { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | QWidget * ALanCard::edit( QWidget * parent ) { | 31 | QWidget * ALanCard::edit( QWidget * parent ) { |
32 | GUI = new LanCardEdit( parent ); | 32 | GUI = new LanCardEdit( parent ); |
33 | GUI->showData( Data ); | 33 | GUI->showData( Data ); |
34 | return GUI; | 34 | return GUI; |
35 | } | 35 | } |
36 | 36 | ||
37 | QString ALanCard::acceptable( void ) { | 37 | QString ALanCard::acceptable( void ) { |
38 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 38 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
39 | } | 39 | } |
40 | 40 | ||
41 | void ALanCard::commit( void ) { | 41 | 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 | |||
@@ -14,30 +14,32 @@ public : | |||
14 | 14 | ||
15 | ALanCard( LanCardNetNode * PNN ); | 15 | ALanCard( LanCardNetNode * PNN ); |
16 | 16 | ||
17 | QWidget * edit( QWidget * parent ); | 17 | QWidget * edit( QWidget * parent ); |
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 | |||
30 | protected : | 32 | protected : |
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 | ||
35 | private : | 37 | private : |
36 | 38 | ||
37 | LanCardEdit * GUI; | 39 | LanCardEdit * GUI; |
38 | LanCardData Data; | 40 | LanCardData Data; |
39 | LanCardRun * RT; | 41 | LanCardRun * RT; |
40 | 42 | ||
41 | }; | 43 | }; |
42 | 44 | ||
43 | #endif | 45 | #endif |
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 | |||
@@ -23,33 +23,42 @@ void LanCardRun::detectState( NodeCollection * NC ) { | |||
23 | // find interface | 23 | // find interface |
24 | if( handlesInterface( X ) ) { | 24 | if( handlesInterface( X ) ) { |
25 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); | 25 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); |
26 | It.current(); | 26 | It.current(); |
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 |
52 | NC->setCurrentState( Off ); | 61 | NC->setCurrentState( Off ); |
53 | return; | 62 | return; |
54 | } | 63 | } |
55 | } | 64 | } |
@@ -74,34 +83,33 @@ bool LanCardRun::setState( NodeCollection * NC, Action_t A ) { | |||
74 | NC->setCurrentState( Unavailable ); | 83 | NC->setCurrentState( Unavailable ); |
75 | return 0; | 84 | return 0; |
76 | } | 85 | } |
77 | // because we were OFF the interface | 86 | // because we were OFF the interface |
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 | } |
104 | 112 | ||
105 | bool LanCardRun::canSetState( State_t Curr, Action_t A ) { | 113 | bool LanCardRun::canSetState( State_t Curr, Action_t A ) { |
106 | // we only handle up down activate and deactivate | 114 | // we only handle up down activate and deactivate |
107 | switch( A ) { | 115 | switch( A ) { |
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 | |||
@@ -5,34 +5,38 @@ | |||
5 | #include <qregexp.h> | 5 | #include <qregexp.h> |
6 | #include "lancarddata.h" | 6 | #include "lancarddata.h" |
7 | 7 | ||
8 | class LanCardRun : public AsDevice { | 8 | class LanCardRun : public AsDevice { |
9 | 9 | ||
10 | public : | 10 | public : |
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 | ||
24 | protected : | 28 | protected : |
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 | ||
32 | private : | 36 | private : |
33 | 37 | ||
34 | InterfaceInfo * getInterface( void ); | 38 | InterfaceInfo * getInterface( void ); |
35 | QRegExp Pat; | 39 | QRegExp Pat; |
36 | 40 | ||
37 | }; | 41 | }; |
38 | #endif | 42 | #endif |
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 | |||
@@ -29,32 +29,39 @@ ANetNodeInstance * ModemNetNode::createInstance( void ) { | |||
29 | return new AModem( this ); | 29 | return new AModem( this ); |
30 | } | 30 | } |
31 | 31 | ||
32 | const char ** ModemNetNode::needs( void ) { | 32 | const char ** ModemNetNode::needs( void ) { |
33 | return ModemNeeds; | 33 | return ModemNeeds; |
34 | } | 34 | } |
35 | 35 | ||
36 | const char * ModemNetNode::provides( void ) { | 36 | const char * ModemNetNode::provides( void ) { |
37 | return "line"; | 37 | return "line"; |
38 | } | 38 | } |
39 | 39 | ||
40 | bool ModemNetNode::generateProperFilesFor( | 40 | bool ModemNetNode::generateProperFilesFor( |
41 | ANetNodeInstance * ) { | 41 | ANetNodeInstance * ) { |
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 | ||
49 | bool ModemNetNode::generateDataForCommonFile( | 49 | bool ModemNetNode::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 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() ); |
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 | |||
@@ -15,30 +15,32 @@ public: | |||
15 | virtual ~ModemNetNode(); | 15 | virtual ~ModemNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/modem"; } | 18 | { return "Devices/modem"; } |
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | extern "C" | 41 | extern "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 | ||
4 | class ModemRun : public AsLine { | 4 | class ModemRun : public AsLine { |
5 | 5 | ||
6 | public : | 6 | public : |
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 | |||
12 | protected : | 15 | protected : |
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 | |||
@@ -30,35 +30,42 @@ ANetNodeInstance * NetworkNetNode::createInstance( void ) { | |||
30 | return new ANetwork( this ); | 30 | return new ANetwork( this ); |
31 | } | 31 | } |
32 | 32 | ||
33 | const char ** NetworkNetNode::needs( void ) { | 33 | const char ** NetworkNetNode::needs( void ) { |
34 | return NetworkNeeds; | 34 | return NetworkNeeds; |
35 | } | 35 | } |
36 | 36 | ||
37 | const char * NetworkNetNode::provides( void ) { | 37 | const char * NetworkNetNode::provides( void ) { |
38 | return "connection"; | 38 | return "connection"; |
39 | } | 39 | } |
40 | 40 | ||
41 | bool NetworkNetNode::generateProperFilesFor( | 41 | bool NetworkNetNode::generateProperFilesFor( |
42 | ANetNodeInstance * ) { | 42 | ANetNodeInstance * ) { |
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; |
51 | } | 51 | } |
52 | 52 | ||
53 | bool NetworkNetNode::generateDataForCommonFile( | 53 | bool 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 | ||
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() ); |
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 | |||
@@ -15,30 +15,32 @@ public: | |||
15 | virtual ~NetworkNetNode(); | 15 | virtual ~NetworkNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/tcpip"; } | 18 | { return "Devices/tcpip"; } |
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | extern "C" | 41 | extern "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 | |||
@@ -91,37 +91,32 @@ QWidget * ANetwork::edit( QWidget * parent ) { | |||
91 | } | 91 | } |
92 | 92 | ||
93 | QString ANetwork::acceptable( void ) { | 93 | QString ANetwork::acceptable( void ) { |
94 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 94 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
95 | } | 95 | } |
96 | 96 | ||
97 | void ANetwork::commit( void ) { | 97 | void 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 | ||
102 | bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | 102 | bool 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; |
124 | } else { | 119 | } else { |
125 | S << "iface " << NIC << "-c" << connection()->number() << | 120 | S << "iface " << NIC << "-c" << connection()->number() << |
126 | "-allowed inet static" << endl; | 121 | "-allowed inet static" << endl; |
127 | S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << | 122 | S << " up echo \"" << NIC << "\" > /tmp/profile-" << 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 | |||
@@ -39,39 +39,39 @@ QString NetworkEdit::acceptable( void ) { | |||
39 | } | 39 | } |
40 | 40 | ||
41 | if( IPAddress_LE->text().isEmpty() ) | 41 | if( IPAddress_LE->text().isEmpty() ) |
42 | return tr("IPAddress needed"); | 42 | return tr("IPAddress needed"); |
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 | ||
67 | bool NetworkEdit::commit( NetworkData_t & Data ) { | 67 | bool 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 ); |
74 | TXTM( Data.Broadcast, Broadcast_LE, SM ); | 74 | TXTM( Data.Broadcast, Broadcast_LE, SM ); |
75 | TXTM( Data.NetMask, SubnetMask_LE, SM ); | 75 | TXTM( Data.NetMask, SubnetMask_LE, SM ); |
76 | TXTM( Data.DNS1, DNS1_LE, SM ); | 76 | TXTM( Data.DNS1, DNS1_LE, SM ); |
77 | TXTM( Data.DNS2, DNS2_LE, SM ); | 77 | TXTM( Data.DNS2, DNS2_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 | |||
@@ -13,43 +13,45 @@ void NetworkRun::detectState( NodeCollection * NC ) { | |||
13 | } | 13 | } |
14 | 14 | ||
15 | // has no interface -> delegate | 15 | // has no interface -> delegate |
16 | RI->detectState( NC ); | 16 | RI->detectState( NC ); |
17 | } | 17 | } |
18 | 18 | ||
19 | bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { | 19 | bool 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 | ||
47 | bool NetworkRun::canSetState( State_t Curr, Action_t A ) { | 49 | bool 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 ) { |
52 | return ( Curr == Available ); | 54 | return ( Curr == Available ); |
53 | } else if( A == Down ) { | 55 | } else if( A == Down ) { |
54 | return ( Curr == IsUp ); | 56 | return ( Curr == IsUp ); |
55 | } | 57 | } |
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 | ||
4 | class NetworkRun : public AsConnection { | 4 | class NetworkRun : public AsConnection { |
5 | 5 | ||
6 | public : | 6 | public : |
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 | |||
12 | protected : | 15 | protected : |
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 | |||
@@ -155,62 +155,80 @@ void NetworkSettings::SLOT_DeleteNode( void ) { | |||
155 | void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { | 155 | void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { |
156 | QString OldName = ""; | 156 | QString OldName = ""; |
157 | EditConnection EC( this ); | 157 | EditConnection EC( this ); |
158 | 158 | ||
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 | ||
206 | void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { | 224 | void 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 |
213 | bool EnabledPossible, OnPossible, ConnectPossible; | 231 | bool EnabledPossible, OnPossible, ConnectPossible; |
214 | // is button On or Off | 232 | // is button On or Off |
215 | bool DisabledOn, OnOn, ConnectOn; | 233 | bool DisabledOn, OnOn, ConnectOn; |
216 | 234 | ||
@@ -320,91 +338,85 @@ void NetworkSettings::SLOT_Enable( void ) { | |||
320 | 338 | ||
321 | void NetworkSettings::SLOT_On( void ) { | 339 | void NetworkSettings::SLOT_On( void ) { |
322 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); | 340 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
323 | 341 | ||
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 | ||
360 | void NetworkSettings::SLOT_Connect( void ) { | 373 | void 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 | ||
400 | void NetworkSettings::SLOT_QCopMessage(const QCString &msg, const QByteArray &data) { | 412 | void 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)" ) { |
407 | int a,b,c; | 419 | int a,b,c; |
408 | stream >> a >> b >> c; | 420 | stream >> a >> b >> c; |
409 | ... | 421 | ... |
410 | } */ | 422 | } */ |
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 | |||
@@ -82,37 +82,41 @@ public: | |||
82 | virtual const QString nodeName() = 0; | 82 | virtual const QString nodeName() = 0; |
83 | 83 | ||
84 | // description for this NetNode | 84 | // description for this NetNode |
85 | virtual const QString nodeDescription() = 0; | 85 | virtual const QString nodeDescription() = 0; |
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 | ||
114 | protected : | 118 | protected : |
115 | 119 | ||
116 | NetNodeList * Alternatives; | 120 | NetNodeList * Alternatives; |
117 | 121 | ||
118 | private : | 122 | private : |
@@ -202,41 +206,41 @@ protected : | |||
202 | QString Description; | 206 | QString Description; |
203 | bool IsModified; | 207 | bool IsModified; |
204 | bool IsNew; | 208 | bool IsNew; |
205 | 209 | ||
206 | static long InstanceCounter; | 210 | static long InstanceCounter; |
207 | }; | 211 | }; |
208 | 212 | ||
209 | class RuntimeInfo : public QObject { | 213 | class RuntimeInfo : public QObject { |
210 | 214 | ||
211 | Q_OBJECT | 215 | Q_OBJECT |
212 | 216 | ||
213 | public : | 217 | public : |
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(); } |
239 | 243 | ||
240 | virtual void detectState( NodeCollection * NC ) = 0; | 244 | virtual void detectState( NodeCollection * NC ) = 0; |
241 | virtual bool setState( NodeCollection * NC, Action_t A ) = 0; | 245 | virtual bool setState( NodeCollection * NC, Action_t A ) = 0; |
242 | virtual bool canSetState( State_t Curr, Action_t A ) = 0; | 246 | virtual bool canSetState( State_t Curr, Action_t A ) = 0; |
@@ -371,37 +375,40 @@ public: | |||
371 | FakeNetNode( ) { }; | 375 | FakeNetNode( ) { }; |
372 | virtual ~FakeNetNode(){}; | 376 | virtual ~FakeNetNode(){}; |
373 | 377 | ||
374 | const QString pixmapName() | 378 | const QString pixmapName() |
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 | ||
393 | private : | 400 | private : |
394 | 401 | ||
395 | }; | 402 | }; |
396 | 403 | ||
397 | class FakeNetNodeInstance : public ANetNodeInstance { | 404 | class FakeNetNodeInstance : public ANetNodeInstance { |
398 | 405 | ||
399 | public: | 406 | public: |
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 ) { } |
404 | 411 | ||
405 | virtual RuntimeInfo * runtime( void ) | 412 | virtual RuntimeInfo * runtime( void ) |
406 | { return 0; } | 413 | { return 0; } |
407 | 414 | ||
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 | |||
@@ -25,40 +25,41 @@ static char Dig2Hex[] = { | |||
25 | // get HIGH nibble of byte | 25 | // get HIGH nibble of byte |
26 | #define HN(x) Dig2Hex[(((x)&0xf0)>>4)] | 26 | #define HN(x) Dig2Hex[(((x)&0xf0)>>4)] |
27 | // get LOW nibble of byte | 27 | // get LOW nibble of byte |
28 | #define LN(x) Dig2Hex[((x)&0x0f)] | 28 | #define LN(x) Dig2Hex[((x)&0x0f)] |
29 | 29 | ||
30 | System::System( void ) : ProbedInterfaces() { | 30 | System::System( void ) : ProbedInterfaces() { |
31 | probeInterfaces(); | 31 | probeInterfaces(); |
32 | } | 32 | } |
33 | 33 | ||
34 | System::~System( void ) { | 34 | System::~System( void ) { |
35 | if( ProcDevNet ) | 35 | if( ProcDevNet ) |
36 | delete ProcDevNet; | 36 | delete ProcDevNet; |
37 | } | 37 | } |
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 | ||
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 |
61 | return 2; | 62 | return 2; |
62 | default : | 63 | default : |
63 | if( WEXITSTATUS(rv) != 0 ) { | 64 | if( WEXITSTATUS(rv) != 0 ) { |
64 | // error in command | 65 | // error in command |
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 | |||
@@ -17,50 +17,58 @@ SystemFile::SystemFile( const QString & N, const QString & P ){ | |||
17 | F = 0; | 17 | F = 0; |
18 | // get template info | 18 | // get template info |
19 | { QString S; | 19 | { QString S; |
20 | QFileInfo FI; | 20 | QFileInfo FI; |
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 | ||
54 | SystemFile::~SystemFile( void ) { | 62 | SystemFile::~SystemFile( void ) { |
55 | if( F ) | 63 | if( F ) |
56 | delete F; | 64 | delete F; |
57 | } | 65 | } |
58 | 66 | ||
59 | bool SystemFile::open( void ) { | 67 | bool SystemFile::open( void ) { |
60 | if( F ) { | 68 | if( F ) { |
61 | F->close(); | 69 | F->close(); |
62 | delete F; | 70 | delete F; |
63 | } | 71 | } |
64 | 72 | ||
65 | F = new QFile( Path + "bup" ); | 73 | F = new QFile( Path + "bup" ); |
66 | if( ! F->open( IO_WriteOnly ) ) { | 74 | if( ! F->open( IO_WriteOnly ) ) { |
@@ -95,50 +103,85 @@ bool SystemFile::preSection( void ) { | |||
95 | return 0; | 103 | return 0; |
96 | } | 104 | } |
97 | 105 | ||
98 | bool SystemFile::postSection( void ) { | 106 | 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 | ||
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 ); |
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 | ||
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 ); |
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 | ||
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 | |||
@@ -11,29 +11,33 @@ class SystemFile : public QTextStream { | |||
11 | 11 | ||
12 | public : | 12 | public : |
13 | 13 | ||
14 | SystemFile( const QString & Name, const QString & Path ); | 14 | SystemFile( const QString & Name, const QString & Path ); |
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 | ||
28 | private : | 30 | private : |
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 | |||
@@ -175,181 +175,333 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { | |||
175 | QString S = ""; | 175 | QString S = ""; |
176 | 176 | ||
177 | // include own force flag | 177 | // include own force flag |
178 | ForceIt = (Force) ? 1 : ForceReq; | 178 | ForceIt = (Force) ? 1 : 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 |
203 | // data for this system file | 204 | // data for this system file |
204 | 205 | ||
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 | } |
230 | } | 233 | } |
231 | 234 | ||
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 | ||
348 | QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) { | 500 | QList<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; |
352 | Name2Connection_t & M = NSResources->connections(); | 504 | Name2Connection_t & M = NSResources->connections(); |
353 | 505 | ||
354 | // for all connections | 506 | // for all connections |
355 | for( QDictIterator<NodeCollection> it(M); | 507 | for( QDictIterator<NodeCollection> it(M); |
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 | |||
@@ -31,32 +31,39 @@ ANetNodeInstance * PPPNetNode::createInstance( void ) { | |||
31 | return new APPP( this ); | 31 | return new APPP( this ); |
32 | } | 32 | } |
33 | 33 | ||
34 | const char ** PPPNetNode::needs( void ) { | 34 | const char ** PPPNetNode::needs( void ) { |
35 | return PPPNeeds; | 35 | return PPPNeeds; |
36 | } | 36 | } |
37 | 37 | ||
38 | const char * PPPNetNode::provides( void ) { | 38 | const char * PPPNetNode::provides( void ) { |
39 | return "connection"; | 39 | return "connection"; |
40 | } | 40 | } |
41 | 41 | ||
42 | bool PPPNetNode::generateProperFilesFor( | 42 | bool PPPNetNode::generateProperFilesFor( |
43 | ANetNodeInstance * ) { | 43 | ANetNodeInstance * ) { |
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 | ||
51 | bool PPPNetNode::generateDataForCommonFile( | 51 | bool PPPNetNode::generateDataForCommonFile( |
52 | SystemFile & , | 52 | SystemFile & , |
53 | long, | 53 | long, |
54 | ANetNodeInstance * ) { | 54 | ANetNodeInstance * ) { |
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() ); |
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 | |||
@@ -15,30 +15,32 @@ public: | |||
15 | virtual ~PPPNetNode(); | 15 | virtual ~PPPNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/ppp"; } | 18 | { return "Devices/ppp"; } |
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | extern "C" | 41 | extern "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 | |||
@@ -3,41 +3,33 @@ | |||
3 | 3 | ||
4 | PPPRun::PPPRun( ANetNodeInstance * NNI, PPPData & Data ) : | 4 | PPPRun::PPPRun( ANetNodeInstance * NNI, PPPData & Data ) : |
5 | AsConnection( NNI ), AsDevice( NNI ), Pat( "eth[0-9]" ) { | 5 | AsConnection( NNI ), AsDevice( NNI ), Pat( "eth[0-9]" ) { |
6 | D = &Data; | 6 | D = &Data; |
7 | } | 7 | } |
8 | 8 | ||
9 | void PPPRun::detectState( NodeCollection * NC ) { | 9 | void 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 | ||
31 | bool PPPRun::setState( NodeCollection * NC, Action_t A ) { | 23 | bool 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 ); |
40 | } | 32 | } |
41 | // cannot really disable | 33 | // cannot really disable |
42 | NC->setCurrentState( Available ); | 34 | NC->setCurrentState( Available ); |
43 | break; | 35 | break; |
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 | |||
@@ -2,34 +2,40 @@ | |||
2 | #define PPPRUN_H | 2 | #define PPPRUN_H |
3 | 3 | ||
4 | #include <qregexp.h> | 4 | #include <qregexp.h> |
5 | #include <asconnection.h> | 5 | #include <asconnection.h> |
6 | #include <asdevice.h> | 6 | #include <asdevice.h> |
7 | #include "pppdata.h" | 7 | #include "pppdata.h" |
8 | 8 | ||
9 | class PPPRun : public AsConnection, public AsDevice { | 9 | class PPPRun : public AsConnection, public AsDevice { |
10 | 10 | ||
11 | public : | 11 | public : |
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 ); |
32 | 38 | ||
33 | private : | 39 | private : |
34 | 40 | ||
35 | bool isMyPPPDRunning( void ); | 41 | bool isMyPPPDRunning( void ); |
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 | |||
@@ -30,32 +30,39 @@ ANetNodeInstance * ProfileNetNode::createInstance( void ) { | |||
30 | return new AProfile( this ); | 30 | return new AProfile( this ); |
31 | } | 31 | } |
32 | 32 | ||
33 | const char ** ProfileNetNode::needs( void ) { | 33 | const char ** ProfileNetNode::needs( void ) { |
34 | return ProfileNeeds; | 34 | return ProfileNeeds; |
35 | } | 35 | } |
36 | 36 | ||
37 | const char * ProfileNetNode::provides( void ) { | 37 | const char * ProfileNetNode::provides( void ) { |
38 | return "fullsetup"; | 38 | return "fullsetup"; |
39 | } | 39 | } |
40 | 40 | ||
41 | bool ProfileNetNode::generateProperFilesFor( | 41 | bool ProfileNetNode::generateProperFilesFor( |
42 | ANetNodeInstance * ) { | 42 | ANetNodeInstance * ) { |
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 | ||
50 | bool ProfileNetNode::generateDataForCommonFile( | 50 | bool ProfileNetNode::generateDataForCommonFile( |
51 | SystemFile & , | 51 | SystemFile & , |
52 | long, | 52 | long, |
53 | ANetNodeInstance * ) { | 53 | ANetNodeInstance * ) { |
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() ); |
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 | |||
@@ -15,30 +15,32 @@ public: | |||
15 | virtual ~ProfileNetNode(); | 15 | virtual ~ProfileNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/commprofile"; } | 18 | { return "Devices/commprofile"; } |
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | extern "C" | 41 | extern "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 | |||
@@ -6,51 +6,49 @@ void ProfileRun::detectState( NodeCollection * NC ) { | |||
6 | if( Data->Disabled ) { | 6 | if( Data->Disabled ) { |
7 | NC->setCurrentState( Disabled ); | 7 | NC->setCurrentState( Disabled ); |
8 | } else { | 8 | } else { |
9 | // find next item in connection | 9 | // find next item in connection |
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 | ||
15 | bool ProfileRun::setState( NodeCollection * NC, Action_t A ) { | 15 | bool 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 | ||
49 | bool ProfileRun::canSetState( State_t Curr, Action_t A ) { | 47 | bool 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 : |
53 | case Disable : | 51 | case Disable : |
54 | // always possible | 52 | // always possible |
55 | return 1; | 53 | return 1; |
56 | default : | 54 | 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 | |||
@@ -7,22 +7,25 @@ | |||
7 | class ProfileRun : public AsFullSetup { | 7 | class ProfileRun : public AsFullSetup { |
8 | 8 | ||
9 | public : | 9 | public : |
10 | 10 | ||
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; } | ||
23 | private : | 26 | private : |
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 | |||
@@ -29,32 +29,39 @@ ANetNodeInstance * USBNetNode::createInstance( void ) { | |||
29 | return new AUSB( this ); | 29 | return new AUSB( this ); |
30 | } | 30 | } |
31 | 31 | ||
32 | const char ** USBNetNode::needs( void ) { | 32 | const char ** USBNetNode::needs( void ) { |
33 | return USBNeeds; | 33 | return USBNeeds; |
34 | } | 34 | } |
35 | 35 | ||
36 | const char * USBNetNode::provides( void ) { | 36 | const char * USBNetNode::provides( void ) { |
37 | return "device"; | 37 | return "device"; |
38 | } | 38 | } |
39 | 39 | ||
40 | bool USBNetNode::generateProperFilesFor( | 40 | bool USBNetNode::generateProperFilesFor( |
41 | ANetNodeInstance * ) { | 41 | ANetNodeInstance * ) { |
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 | ||
49 | bool USBNetNode::generateDataForCommonFile( | 49 | bool 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 | ||
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() ); |
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 | |||
@@ -15,30 +15,32 @@ public: | |||
15 | virtual ~USBNetNode(); | 15 | virtual ~USBNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/usb"; } | 18 | { return "Devices/usb"; } |
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | extern "C" | 41 | extern "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 | |||
@@ -30,17 +30,28 @@ void AUSB::commit( void ) { | |||
30 | if( GUI && GUI->commit( Data ) ) { | 30 | if( GUI && GUI->commit( Data ) ) { |
31 | setModified( 1 ); | 31 | setModified( 1 ); |
32 | } | 32 | } |
33 | } | 33 | } |
34 | 34 | ||
35 | bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) { | 35 | bool 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 | ||
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 | |||
@@ -15,30 +15,31 @@ public : | |||
15 | AUSB( USBNetNode * PNN ); | 15 | AUSB( USBNetNode * PNN ); |
16 | 16 | ||
17 | QWidget * edit( QWidget * parent ); | 17 | QWidget * edit( QWidget * parent ); |
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 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 | ||
32 | protected : | 33 | protected : |
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 | ||
37 | private : | 38 | private : |
38 | 39 | ||
39 | USBEdit * GUI; | 40 | USBEdit * GUI; |
40 | USBData Data; | 41 | USBData Data; |
41 | USBRun * RT; | 42 | USBRun * RT; |
42 | }; | 43 | }; |
43 | 44 | ||
44 | #endif | 45 | #endif |
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 | |||
@@ -21,92 +21,103 @@ void USBRun::detectState( NodeCollection * NC ) { | |||
21 | // find interface | 21 | // find interface |
22 | if( handlesInterface( X ) ) { | 22 | if( handlesInterface( X ) ) { |
23 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); | 23 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); |
24 | It.current(); | 24 | It.current(); |
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 | ||
67 | bool USBRun::setState( NodeCollection * NC, Action_t A ) { | 78 | bool USBRun::setState( NodeCollection * NC, Action_t A ) { |
68 | 79 | ||
69 | // we only handle activate and deactivate | 80 | // we only handle activate and deactivate |
70 | switch( A ) { | 81 | switch( A ) { |
71 | case Activate : | 82 | case Activate : |
72 | { | 83 | { |
73 | if( NC->currentState() != Off ) { | 84 | if( NC->currentState() != Off ) { |
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 | } |
109 | 120 | ||
110 | bool USBRun::canSetState( State_t Curr, Action_t A ) { | 121 | bool USBRun::canSetState( State_t Curr, Action_t A ) { |
111 | // we only handle up down activate and deactivate | 122 | // we only handle up down activate and deactivate |
112 | switch( A ) { | 123 | switch( A ) { |
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 | |||
@@ -5,34 +5,37 @@ | |||
5 | #include <qregexp.h> | 5 | #include <qregexp.h> |
6 | #include "usbdata.h" | 6 | #include "usbdata.h" |
7 | 7 | ||
8 | class USBRun : public AsDevice { | 8 | class USBRun : public AsDevice { |
9 | 9 | ||
10 | public : | 10 | public : |
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; } | ||
24 | protected : | 27 | protected : |
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 | ||
32 | private : | 35 | private : |
33 | 36 | ||
34 | InterfaceInfo * getInterface( void ); | 37 | InterfaceInfo * getInterface( void ); |
35 | QRegExp Pat; | 38 | QRegExp Pat; |
36 | 39 | ||
37 | }; | 40 | }; |
38 | #endif | 41 | #endif |
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 | |||
@@ -30,32 +30,39 @@ ANetNodeInstance * VPNNetNode::createInstance( void ) { | |||
30 | return new AVPN( this ); | 30 | return new AVPN( this ); |
31 | } | 31 | } |
32 | 32 | ||
33 | const char ** VPNNetNode::needs( void ) { | 33 | const char ** VPNNetNode::needs( void ) { |
34 | return VPNNeeds; | 34 | return VPNNeeds; |
35 | } | 35 | } |
36 | 36 | ||
37 | const char * VPNNetNode::provides( void ) { | 37 | const char * VPNNetNode::provides( void ) { |
38 | return "connection"; | 38 | return "connection"; |
39 | } | 39 | } |
40 | 40 | ||
41 | bool VPNNetNode::generateProperFilesFor( | 41 | bool VPNNetNode::generateProperFilesFor( |
42 | ANetNodeInstance * ) { | 42 | ANetNodeInstance * ) { |
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 | ||
50 | bool VPNNetNode::generateDataForCommonFile( | 50 | bool VPNNetNode::generateDataForCommonFile( |
51 | SystemFile & , | 51 | SystemFile & , |
52 | long, | 52 | long, |
53 | ANetNodeInstance * ) { | 53 | ANetNodeInstance * ) { |
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() ); |
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 | |||
@@ -15,30 +15,32 @@ public: | |||
15 | virtual ~VPNNetNode(); | 15 | virtual ~VPNNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/vpn"; } | 18 | { return "Devices/vpn"; } |
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | extern "C" | 41 | extern "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 | |||
@@ -1,30 +1,32 @@ | |||
1 | #ifndef VPNRUN_H | 1 | #ifndef VPNRUN_H |
2 | #define VPNRUN_H | 2 | #define VPNRUN_H |
3 | 3 | ||
4 | #include <asconnection.h> | 4 | #include <asconnection.h> |
5 | #include "vpndata.h" | 5 | #include "vpndata.h" |
6 | 6 | ||
7 | class VPNRun : public AsConnection { | 7 | class VPNRun : public AsConnection { |
8 | 8 | ||
9 | public : | 9 | public : |
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; } | ||
15 | protected : | 17 | protected : |
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 ); |
27 | 29 | ||
28 | }; | 30 | }; |
29 | 31 | ||
30 | #endif | 32 | #endif |
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 | |||
@@ -29,32 +29,39 @@ ANetNodeInstance * WLanNetNode::createInstance( void ) { | |||
29 | return new AWLan( this ); | 29 | return new AWLan( this ); |
30 | } | 30 | } |
31 | 31 | ||
32 | const char ** WLanNetNode::needs( void ) { | 32 | const char ** WLanNetNode::needs( void ) { |
33 | return WLanNeeds; | 33 | return WLanNeeds; |
34 | } | 34 | } |
35 | 35 | ||
36 | const char * WLanNetNode::provides( void ) { | 36 | const char * WLanNetNode::provides( void ) { |
37 | return "device"; | 37 | return "device"; |
38 | } | 38 | } |
39 | 39 | ||
40 | bool WLanNetNode::generateProperFilesFor( | 40 | bool WLanNetNode::generateProperFilesFor( |
41 | ANetNodeInstance * ) { | 41 | ANetNodeInstance * ) { |
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() ); |
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 | |||
@@ -15,30 +15,32 @@ public: | |||
15 | virtual ~WLanNetNode(); | 15 | virtual ~WLanNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/wlan"; } | 18 | { return "Devices/wlan"; } |
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 | ||
35 | private: | 37 | private: |
36 | 38 | ||
37 | }; | 39 | }; |
38 | 40 | ||
39 | extern "C" | 41 | extern "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 | |||
@@ -15,16 +15,28 @@ void AWLan::saveSpecificAttribute( QTextStream & ) { | |||
15 | 15 | ||
16 | QWidget * AWLan::edit( QWidget * parent ) { | 16 | QWidget * AWLan::edit( QWidget * parent ) { |
17 | GUI = new WLanEdit( parent ); | 17 | GUI = new WLanEdit( parent ); |
18 | GUI->showData( Data ); | 18 | GUI->showData( Data ); |
19 | return GUI; | 19 | return GUI; |
20 | } | 20 | } |
21 | 21 | ||
22 | QString AWLan::acceptable( void ) { | 22 | QString AWLan::acceptable( void ) { |
23 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 23 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
24 | } | 24 | } |
25 | 25 | ||
26 | void AWLan::commit( void ) { | 26 | void 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 | ||
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 | |||
@@ -14,30 +14,32 @@ public : | |||
14 | 14 | ||
15 | AWLan( WLanNetNode * PNN ); | 15 | AWLan( WLanNetNode * PNN ); |
16 | 16 | ||
17 | QWidget * edit( QWidget * parent ); | 17 | QWidget * edit( QWidget * parent ); |
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 | |||
30 | protected : | 32 | protected : |
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 | ||
35 | private : | 37 | private : |
36 | 38 | ||
37 | WLanEdit * GUI; | 39 | WLanEdit * GUI; |
38 | WLanData Data; | 40 | WLanData Data; |
39 | WLanRun * RT; | 41 | WLanRun * RT; |
40 | 42 | ||
41 | }; | 43 | }; |
42 | 44 | ||
43 | #endif | 45 | #endif |
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 | |||
@@ -6,33 +6,35 @@ | |||
6 | #include "wlandata.h" | 6 | #include "wlandata.h" |
7 | 7 | ||
8 | class WLanRun : public AsDevice { | 8 | class WLanRun : public AsDevice { |
9 | 9 | ||
10 | public : | 10 | public : |
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 | ||
24 | protected : | 26 | protected : |
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 | ||
35 | bool handlesInterface( const QString & I ); | 37 | bool handlesInterface( const QString & I ); |
36 | 38 | ||
37 | private : | 39 | private : |
38 | 40 | ||