author | wimpie <wimpie> | 2004-04-04 11:42:05 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-04-04 11:42:05 (UTC) |
commit | 8d2d2664e5f544b8292806e617deb7a0e4170dc0 (patch) (unidiff) | |
tree | 3e3764f82d52f8c32b0ed9d92c13ec483dc34114 | |
parent | 321f82bb3d43cbab358434fef52fe76f17e7d1e3 (diff) | |
download | opie-8d2d2664e5f544b8292806e617deb7a0e4170dc0.zip opie-8d2d2664e5f544b8292806e617deb7a0e4170dc0.tar.gz opie-8d2d2664e5f544b8292806e617deb7a0e4170dc0.tar.bz2 |
Error in generation of files
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,32 +1,36 @@ | |||
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; } |
32 | }; | 36 | }; |
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 | |||
@@ -1,120 +1,127 @@ | |||
1 | #include "bluetooth_NN.h" | 1 | #include "bluetooth_NN.h" |
2 | #include "bluetoothBNEP_NNI.h" | 2 | #include "bluetoothBNEP_NNI.h" |
3 | #include "bluetoothRFCOMM_NNI.h" | 3 | #include "bluetoothRFCOMM_NNI.h" |
4 | 4 | ||
5 | // | 5 | // |
6 | // | 6 | // |
7 | // BLUETOOTH PAN/NAP node | 7 | // BLUETOOTH PAN/NAP node |
8 | // | 8 | // |
9 | // | 9 | // |
10 | 10 | ||
11 | static const char * BluetoothBNEPNeeds[] = | 11 | static const char * BluetoothBNEPNeeds[] = |
12 | { 0 | 12 | { 0 |
13 | }; | 13 | }; |
14 | 14 | ||
15 | /** | 15 | /** |
16 | * Constructor, find all of the possible interfaces | 16 | * Constructor, find all of the possible interfaces |
17 | */ | 17 | */ |
18 | BluetoothBNEPNetNode::BluetoothBNEPNetNode() : ANetNode() { | 18 | BluetoothBNEPNetNode::BluetoothBNEPNetNode() : ANetNode() { |
19 | } | 19 | } |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * Delete any interfaces that we own. | 22 | * Delete any interfaces that we own. |
23 | */ | 23 | */ |
24 | BluetoothBNEPNetNode::~BluetoothBNEPNetNode(){ | 24 | BluetoothBNEPNetNode::~BluetoothBNEPNetNode(){ |
25 | } | 25 | } |
26 | 26 | ||
27 | const QString BluetoothBNEPNetNode::nodeDescription(){ | 27 | const QString BluetoothBNEPNetNode::nodeDescription(){ |
28 | return tr("\ | 28 | return tr("\ |
29 | <p>Sets up a bluetooth link using the bluetooth Network profile.</p>\ | 29 | <p>Sets up a bluetooth link using the bluetooth Network profile.</p>\ |
30 | <p>Use this to connect two computing devices.</p>\ | 30 | <p>Use this to connect two computing devices.</p>\ |
31 | " | 31 | " |
32 | ); | 32 | ); |
33 | } | 33 | } |
34 | 34 | ||
35 | ANetNodeInstance * BluetoothBNEPNetNode::createInstance( void ) { | 35 | 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 | ||
79 | const QString BluetoothRFCOMMNetNode::nodeDescription(){ | 86 | const QString BluetoothRFCOMMNetNode::nodeDescription(){ |
80 | return tr("\ | 87 | return tr("\ |
81 | <p>Sets up a bluetooth link using the bluetooth serial profile.</p>\ | 88 | <p>Sets up a bluetooth link using the bluetooth serial profile.</p>\ |
82 | <p>Use this to connect to a GSM.</p>\ | 89 | <p>Use this to connect to a GSM.</p>\ |
83 | " | 90 | " |
84 | ); | 91 | ); |
85 | } | 92 | } |
86 | 93 | ||
87 | ANetNodeInstance * BluetoothRFCOMMNetNode::createInstance( void ) { | 94 | 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 | |||
@@ -1,75 +1,79 @@ | |||
1 | #ifndef BLUETOOTH_NETNODE_H | 1 | #ifndef BLUETOOTH_NETNODE_H |
2 | #define BLUETOOTH_NETNODE_H | 2 | #define BLUETOOTH_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class ABluetoothBNEP; | 6 | class ABluetoothBNEP; |
7 | 7 | ||
8 | class BluetoothBNEPNetNode : public ANetNode { | 8 | class BluetoothBNEPNetNode : public ANetNode { |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | BluetoothBNEPNetNode(); | 14 | BluetoothBNEPNetNode(); |
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 | |||
@@ -1,59 +1,66 @@ | |||
1 | #include "cable_NN.h" | 1 | #include "cable_NN.h" |
2 | #include "cable_NNI.h" | 2 | #include "cable_NNI.h" |
3 | 3 | ||
4 | static const char * CableNeeds[] = | 4 | static const char * CableNeeds[] = |
5 | { 0 | 5 | { 0 |
6 | }; | 6 | }; |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * Constructor, find all of the possible interfaces | 9 | * Constructor, find all of the possible interfaces |
10 | */ | 10 | */ |
11 | CableNetNode::CableNetNode() : ANetNode() { | 11 | CableNetNode::CableNetNode() : ANetNode() { |
12 | } | 12 | } |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * Delete any interfaces that we own. | 15 | * Delete any interfaces that we own. |
16 | */ | 16 | */ |
17 | CableNetNode::~CableNetNode(){ | 17 | CableNetNode::~CableNetNode(){ |
18 | } | 18 | } |
19 | 19 | ||
20 | const QString CableNetNode::nodeDescription(){ | 20 | const QString CableNetNode::nodeDescription(){ |
21 | return tr("\ | 21 | return tr("\ |
22 | <p>Sets up a wired serial or parallel.</p>\ | 22 | <p>Sets up a wired serial or parallel.</p>\ |
23 | " | 23 | " |
24 | ); | 24 | ); |
25 | } | 25 | } |
26 | 26 | ||
27 | ANetNodeInstance * CableNetNode::createInstance( void ) { | 27 | 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 | |||
@@ -1,44 +1,46 @@ | |||
1 | #ifndef CABLE_NETNODE_H | 1 | #ifndef CABLE_NETNODE_H |
2 | #define CABLE_NETNODE_H | 2 | #define CABLE_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class ACable; | 6 | class ACable; |
7 | 7 | ||
8 | class CableNetNode : public ANetNode { | 8 | class CableNetNode : public ANetNode { |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | CableNetNode(); | 14 | CableNetNode(); |
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 | |||
@@ -1,59 +1,66 @@ | |||
1 | #include "irda_NN.h" | 1 | #include "irda_NN.h" |
2 | #include "irda_NNI.h" | 2 | #include "irda_NNI.h" |
3 | 3 | ||
4 | static const char * IRDANeeds[] = | 4 | static const char * IRDANeeds[] = |
5 | { 0 | 5 | { 0 |
6 | }; | 6 | }; |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * Constructor, find all of the possible interfaces | 9 | * Constructor, find all of the possible interfaces |
10 | */ | 10 | */ |
11 | IRDANetNode::IRDANetNode() : ANetNode() { | 11 | IRDANetNode::IRDANetNode() : ANetNode() { |
12 | } | 12 | } |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * Delete any interfaces that we own. | 15 | * Delete any interfaces that we own. |
16 | */ | 16 | */ |
17 | IRDANetNode::~IRDANetNode(){ | 17 | IRDANetNode::~IRDANetNode(){ |
18 | } | 18 | } |
19 | 19 | ||
20 | const QString IRDANetNode::nodeDescription(){ | 20 | const QString IRDANetNode::nodeDescription(){ |
21 | return tr("\ | 21 | return tr("\ |
22 | <p>Sets up a infra red serial link.</p>\ | 22 | <p>Sets up a infra red serial link.</p>\ |
23 | " | 23 | " |
24 | ); | 24 | ); |
25 | } | 25 | } |
26 | 26 | ||
27 | ANetNodeInstance * IRDANetNode::createInstance( void ) { | 27 | 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 | |||
@@ -1,44 +1,46 @@ | |||
1 | #ifndef IRDA_NETNODE_H | 1 | #ifndef IRDA_NETNODE_H |
2 | #define IRDA_NETNODE_H | 2 | #define IRDA_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class AIRDA; | 6 | class AIRDA; |
7 | 7 | ||
8 | class IRDANetNode : public ANetNode { | 8 | class IRDANetNode : public ANetNode { |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | IRDANetNode(); | 14 | IRDANetNode(); |
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 | |||
@@ -1,60 +1,67 @@ | |||
1 | #include "lancard_NN.h" | 1 | #include "lancard_NN.h" |
2 | #include "lancard_NNI.h" | 2 | #include "lancard_NNI.h" |
3 | 3 | ||
4 | static const char * LanCardNeeds[] = | 4 | static const char * LanCardNeeds[] = |
5 | { 0 }; | 5 | { 0 }; |
6 | 6 | ||
7 | /** | 7 | /** |
8 | * Constructor, find all of the possible interfaces | 8 | * Constructor, find all of the possible interfaces |
9 | */ | 9 | */ |
10 | LanCardNetNode::LanCardNetNode() : ANetNode() { | 10 | LanCardNetNode::LanCardNetNode() : ANetNode() { |
11 | } | 11 | } |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * Delete any interfaces that we own. | 14 | * Delete any interfaces that we own. |
15 | */ | 15 | */ |
16 | LanCardNetNode::~LanCardNetNode(){ | 16 | LanCardNetNode::~LanCardNetNode(){ |
17 | } | 17 | } |
18 | 18 | ||
19 | const QString LanCardNetNode::nodeDescription(){ | 19 | const QString LanCardNetNode::nodeDescription(){ |
20 | return tr("\ | 20 | return tr("\ |
21 | <p>Sets up a wired regular LAN card.</p>\ | 21 | <p>Sets up a wired regular LAN card.</p>\ |
22 | <p>Use this to set up 10/100/1000 MBit LAN cards.</p>\ | 22 | <p>Use this to set up 10/100/1000 MBit LAN cards.</p>\ |
23 | " | 23 | " |
24 | ); | 24 | ); |
25 | } | 25 | } |
26 | 26 | ||
27 | ANetNodeInstance * LanCardNetNode::createInstance( void ) { | 27 | ANetNodeInstance * LanCardNetNode::createInstance( void ) { |
28 | return new ALanCard( this ); | 28 | return new ALanCard( this ); |
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 | |||
@@ -1,44 +1,46 @@ | |||
1 | #ifndef LANCARD_NETNODE_H | 1 | #ifndef LANCARD_NETNODE_H |
2 | #define LANCARD_NETNODE_H | 2 | #define LANCARD_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class ALanCard; | 6 | class ALanCard; |
7 | 7 | ||
8 | class LanCardNetNode : public ANetNode{ | 8 | class LanCardNetNode : public ANetNode{ |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | LanCardNetNode(); | 14 | LanCardNetNode(); |
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 | |||
@@ -1,44 +1,58 @@ | |||
1 | #include "lancardedit.h" | 1 | #include "lancardedit.h" |
2 | #include "lancard_NNI.h" | 2 | #include "lancard_NNI.h" |
3 | #include "lancard_NN.h" | 3 | #include "lancard_NN.h" |
4 | 4 | ||
5 | ALanCard::ALanCard( LanCardNetNode * PNN ) : ANetNodeInstance( PNN ) { | 5 | ALanCard::ALanCard( LanCardNetNode * PNN ) : ANetNodeInstance( PNN ) { |
6 | 6 | ||
7 | Data.AnyLanCard = 1; | 7 | Data.AnyLanCard = 1; |
8 | Data.HWAddresses.clear(); | 8 | Data.HWAddresses.clear(); |
9 | 9 | ||
10 | GUI = 0; | 10 | GUI = 0; |
11 | RT = 0; | 11 | RT = 0; |
12 | } | 12 | } |
13 | 13 | ||
14 | void ALanCard::setSpecificAttribute( QString & A, QString & V ) { | 14 | void ALanCard::setSpecificAttribute( QString & A, QString & V ) { |
15 | if( A == "matchanycard" ) { | 15 | if( A == "matchanycard" ) { |
16 | Data.AnyLanCard = (V == "yes" ); | 16 | Data.AnyLanCard = (V == "yes" ); |
17 | } else if( A == "match" ) { | 17 | } else if( A == "match" ) { |
18 | Data.HWAddresses.append( V ); | 18 | Data.HWAddresses.append( V ); |
19 | } | 19 | } |
20 | } | 20 | } |
21 | 21 | ||
22 | void ALanCard::saveSpecificAttribute( QTextStream & TS) { | 22 | void ALanCard::saveSpecificAttribute( QTextStream & TS) { |
23 | TS << "matchanycard=" << | 23 | TS << "matchanycard=" << |
24 | ((Data.AnyLanCard) ? "yes" : "no") << endl; | 24 | ((Data.AnyLanCard) ? "yes" : "no") << endl; |
25 | for( QStringList::Iterator it = Data.HWAddresses.begin(); | 25 | for( QStringList::Iterator it = Data.HWAddresses.begin(); |
26 | it != Data.HWAddresses.end(); ++it ) { | 26 | it != Data.HWAddresses.end(); ++it ) { |
27 | TS << "match=" << quote( *it ) << endl; | 27 | TS << "match=" << quote( *it ) << endl; |
28 | } | 28 | } |
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 | |||
@@ -1,43 +1,45 @@ | |||
1 | #ifndef LANCARD_H | 1 | #ifndef LANCARD_H |
2 | #define LANCARD_H | 2 | #define LANCARD_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "lancarddata.h" | 5 | #include "lancarddata.h" |
6 | #include "lancardrun.h" | 6 | #include "lancardrun.h" |
7 | 7 | ||
8 | class LanCardNetNode; | 8 | class LanCardNetNode; |
9 | class LanCardEdit; | 9 | class LanCardEdit; |
10 | 10 | ||
11 | class ALanCard : public ANetNodeInstance { | 11 | class ALanCard : public ANetNodeInstance { |
12 | 12 | ||
13 | public : | 13 | 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 | |||
@@ -1,155 +1,163 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | #include <qtextstream.h> | 2 | #include <qtextstream.h> |
3 | #include <resources.h> | 3 | #include <resources.h> |
4 | #include "lancardrun.h" | 4 | #include "lancardrun.h" |
5 | 5 | ||
6 | void LanCardRun::detectState( NodeCollection * NC ) { | 6 | void LanCardRun::detectState( NodeCollection * NC ) { |
7 | 7 | ||
8 | // unavailable : no card found | 8 | // unavailable : no card found |
9 | // available : card found and assigned to us or free | 9 | // available : card found and assigned to us or free |
10 | // up : card found and assigned to us and up | 10 | // up : card found and assigned to us and up |
11 | 11 | ||
12 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); | 12 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); |
13 | System & Sys = NSResources->system(); | 13 | System & Sys = NSResources->system(); |
14 | InterfaceInfo * Run; | 14 | InterfaceInfo * Run; |
15 | 15 | ||
16 | QFile F( S ); | 16 | QFile F( S ); |
17 | 17 | ||
18 | if( F.open( IO_ReadOnly ) ) { | 18 | if( F.open( IO_ReadOnly ) ) { |
19 | // could open file -> read interface and assign | 19 | // could open file -> read interface and assign |
20 | QString X; | 20 | QString X; |
21 | QTextStream TS(&F); | 21 | QTextStream TS(&F); |
22 | X = TS.readLine(); | 22 | X = TS.readLine(); |
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 | } |
56 | // no free found | 65 | // no free found |
57 | 66 | ||
58 | NC->setCurrentState( Unavailable ); | 67 | NC->setCurrentState( Unavailable ); |
59 | 68 | ||
60 | } | 69 | } |
61 | 70 | ||
62 | bool LanCardRun::setState( NodeCollection * NC, Action_t A ) { | 71 | bool LanCardRun::setState( NodeCollection * NC, Action_t A ) { |
63 | 72 | ||
64 | // we only handle activate and deactivate | 73 | // we only handle activate and deactivate |
65 | switch( A ) { | 74 | switch( A ) { |
66 | case Activate : | 75 | case Activate : |
67 | { | 76 | { |
68 | if( NC->currentState() != Off ) { | 77 | if( NC->currentState() != Off ) { |
69 | return 0; | 78 | return 0; |
70 | } | 79 | } |
71 | InterfaceInfo * N = getInterface(); | 80 | InterfaceInfo * N = getInterface(); |
72 | if( ! N ) { | 81 | if( ! N ) { |
73 | // no interface available | 82 | // no interface available |
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 ) { |
108 | case Activate : | 116 | case Activate : |
109 | { // at least available | 117 | { // at least available |
110 | if( Curr == Available ) { | 118 | if( Curr == Available ) { |
111 | return 1; | 119 | return 1; |
112 | } | 120 | } |
113 | // or we can make one available | 121 | // or we can make one available |
114 | InterfaceInfo * N = getInterface(); | 122 | InterfaceInfo * N = getInterface(); |
115 | if( ! N || N->assignedNode() != 0 ) { | 123 | if( ! N || N->assignedNode() != 0 ) { |
116 | // non available or assigned | 124 | // non available or assigned |
117 | return 0; | 125 | return 0; |
118 | } | 126 | } |
119 | return 1; | 127 | return 1; |
120 | } | 128 | } |
121 | case Deactivate : | 129 | case Deactivate : |
122 | return ( Curr >= Available ); | 130 | return ( Curr >= Available ); |
123 | default : | 131 | default : |
124 | // FT | 132 | // FT |
125 | break; | 133 | break; |
126 | } | 134 | } |
127 | return 0; | 135 | return 0; |
128 | } | 136 | } |
129 | 137 | ||
130 | // get interface that is free or assigned to us | 138 | // get interface that is free or assigned to us |
131 | InterfaceInfo * LanCardRun::getInterface( void ) { | 139 | InterfaceInfo * LanCardRun::getInterface( void ) { |
132 | 140 | ||
133 | System & S = NSResources->system(); | 141 | System & S = NSResources->system(); |
134 | InterfaceInfo * best = 0, * Run; | 142 | InterfaceInfo * best = 0, * Run; |
135 | 143 | ||
136 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | 144 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); |
137 | It.current(); | 145 | It.current(); |
138 | ++It ) { | 146 | ++It ) { |
139 | Run = It.current(); | 147 | Run = It.current(); |
140 | if( handlesInterface( Run->Name ) && | 148 | if( handlesInterface( Run->Name ) && |
141 | Run->CardType == ARPHRD_ETHER | 149 | Run->CardType == ARPHRD_ETHER |
142 | ) { | 150 | ) { |
143 | // this is a LAN card | 151 | // this is a LAN card |
144 | if( Run->assignedNode() == netNode() ) { | 152 | if( Run->assignedNode() == netNode() ) { |
145 | // assigned to us | 153 | // assigned to us |
146 | return Run; | 154 | return Run; |
147 | } else if( Run->assignedNode() == 0 ) { | 155 | } else if( Run->assignedNode() == 0 ) { |
148 | // free | 156 | // free |
149 | best = Run; | 157 | best = Run; |
150 | } | 158 | } |
151 | } | 159 | } |
152 | } | 160 | } |
153 | return best; // can be 0 | 161 | return best; // can be 0 |
154 | } | 162 | } |
155 | 163 | ||
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 | |||
@@ -1,38 +1,42 @@ | |||
1 | #ifndef LANCARDRUN_H | 1 | #ifndef LANCARDRUN_H |
2 | #define LANCARDRUN_H | 2 | #define LANCARDRUN_H |
3 | 3 | ||
4 | #include <asdevice.h> | 4 | #include <asdevice.h> |
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 | |||
@@ -1,60 +1,67 @@ | |||
1 | #include "modem_NN.h" | 1 | #include "modem_NN.h" |
2 | #include "modem_NNI.h" | 2 | #include "modem_NNI.h" |
3 | 3 | ||
4 | static const char * ModemNeeds[] = | 4 | static const char * ModemNeeds[] = |
5 | { "line" | 5 | { "line" |
6 | }; | 6 | }; |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * Constructor, find all of the possible interfaces | 9 | * Constructor, find all of the possible interfaces |
10 | */ | 10 | */ |
11 | ModemNetNode::ModemNetNode() : ANetNode() { | 11 | ModemNetNode::ModemNetNode() : ANetNode() { |
12 | } | 12 | } |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * Delete any interfaces that we own. | 15 | * Delete any interfaces that we own. |
16 | */ | 16 | */ |
17 | ModemNetNode::~ModemNetNode(){ | 17 | ModemNetNode::~ModemNetNode(){ |
18 | } | 18 | } |
19 | 19 | ||
20 | const QString ModemNetNode::nodeDescription(){ | 20 | const QString ModemNetNode::nodeDescription(){ |
21 | return tr("\ | 21 | return tr("\ |
22 | <p>Sets up a dialing procedures.</p>\ | 22 | <p>Sets up a dialing procedures.</p>\ |
23 | <p>Use this to dial up over modems, ISDN, GSM, ...</p>\ | 23 | <p>Use this to dial up over modems, ISDN, GSM, ...</p>\ |
24 | " | 24 | " |
25 | ); | 25 | ); |
26 | } | 26 | } |
27 | 27 | ||
28 | ANetNodeInstance * ModemNetNode::createInstance( void ) { | 28 | 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 | |||
@@ -1,44 +1,46 @@ | |||
1 | #ifndef MODEM_NETNODE_H | 1 | #ifndef MODEM_NETNODE_H |
2 | #define MODEM_NETNODE_H | 2 | #define MODEM_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class AModem; | 6 | class AModem; |
7 | 7 | ||
8 | class ModemNetNode : public ANetNode{ | 8 | class ModemNetNode : public ANetNode{ |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | ModemNetNode(); | 14 | ModemNetNode(); |
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 | |||
@@ -1,64 +1,71 @@ | |||
1 | #include "network_NN.h" | 1 | #include "network_NN.h" |
2 | #include "network_NNI.h" | 2 | #include "network_NNI.h" |
3 | 3 | ||
4 | static const char * NetworkNeeds[] = | 4 | static const char * NetworkNeeds[] = |
5 | { "device", | 5 | { "device", |
6 | 0 | 6 | 0 |
7 | }; | 7 | }; |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * Constructor, find all of the possible interfaces | 10 | * Constructor, find all of the possible interfaces |
11 | */ | 11 | */ |
12 | NetworkNetNode::NetworkNetNode() : ANetNode() { | 12 | NetworkNetNode::NetworkNetNode() : ANetNode() { |
13 | } | 13 | } |
14 | 14 | ||
15 | /** | 15 | /** |
16 | * Delete any interfaces that we own. | 16 | * Delete any interfaces that we own. |
17 | */ | 17 | */ |
18 | NetworkNetNode::~NetworkNetNode(){ | 18 | NetworkNetNode::~NetworkNetNode(){ |
19 | } | 19 | } |
20 | 20 | ||
21 | const QString NetworkNetNode::nodeDescription(){ | 21 | const QString NetworkNetNode::nodeDescription(){ |
22 | return tr("\ | 22 | return tr("\ |
23 | <p>Sets up TCP/IP options.</p>\ | 23 | <p>Sets up TCP/IP options.</p>\ |
24 | <p>Use this to configure the TCP/IP protocol</p>\ | 24 | <p>Use this to configure the TCP/IP protocol</p>\ |
25 | " | 25 | " |
26 | ); | 26 | ); |
27 | } | 27 | } |
28 | 28 | ||
29 | ANetNodeInstance * NetworkNetNode::createInstance( void ) { | 29 | 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 | |||
@@ -1,44 +1,46 @@ | |||
1 | #ifndef NETWORK_NETNODE_H | 1 | #ifndef NETWORK_NETNODE_H |
2 | #define NETWORK_NETNODE_H | 2 | #define NETWORK_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class ANetwork; | 6 | class ANetwork; |
7 | 7 | ||
8 | class NetworkNetNode : public ANetNode{ | 8 | class NetworkNetNode : public ANetNode{ |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | NetworkNetNode(); | 14 | NetworkNetNode(); |
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 | |||
@@ -43,128 +43,123 @@ void ANetwork::setSpecificAttribute( QString & A, QString & V ) { | |||
43 | Data.DNS2 = V; | 43 | Data.DNS2 = V; |
44 | } else if( A == "preup" ) { | 44 | } else if( A == "preup" ) { |
45 | Data.PreUp_SL.append( V ); | 45 | Data.PreUp_SL.append( V ); |
46 | } else if( A == "predown" ) { | 46 | } else if( A == "predown" ) { |
47 | Data.PreDown_SL.append( V ); | 47 | Data.PreDown_SL.append( V ); |
48 | } else if( A == "postup" ) { | 48 | } else if( A == "postup" ) { |
49 | Data.PostUp_SL.append( V ); | 49 | Data.PostUp_SL.append( V ); |
50 | } else if( A == "postdown" ) { | 50 | } else if( A == "postdown" ) { |
51 | Data.PostDown_SL.append( V ); | 51 | Data.PostDown_SL.append( V ); |
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | void ANetwork::saveSpecificAttribute( QTextStream & TS ) { | 55 | void ANetwork::saveSpecificAttribute( QTextStream & TS ) { |
56 | TS << "usedhcp=" << ((Data.UseDHCP) ? "yes" : "no") << endl; | 56 | TS << "usedhcp=" << ((Data.UseDHCP) ? "yes" : "no") << endl; |
57 | TS << "sendhostname=" << ((Data.SendHostname) ? "yes" : "no") << endl; | 57 | TS << "sendhostname=" << ((Data.SendHostname) ? "yes" : "no") << endl; |
58 | TS << "hostname=" << Data.Hostname << endl; | 58 | TS << "hostname=" << Data.Hostname << endl; |
59 | TS << "ipaddress=" << Data.IPAddress << endl; | 59 | TS << "ipaddress=" << Data.IPAddress << endl; |
60 | TS << "netmask=" << Data.NetMask << endl; | 60 | TS << "netmask=" << Data.NetMask << endl; |
61 | TS << "broadcast=" << Data.Broadcast << endl; | 61 | TS << "broadcast=" << Data.Broadcast << endl; |
62 | TS << "gateway=" << Data.Gateway << endl; | 62 | TS << "gateway=" << Data.Gateway << endl; |
63 | TS << "dns1=" << Data.DNS1 << endl; | 63 | TS << "dns1=" << Data.DNS1 << endl; |
64 | TS << "dns2=" << Data.DNS2 << endl; | 64 | TS << "dns2=" << Data.DNS2 << endl; |
65 | for ( QStringList::Iterator it = Data.PreUp_SL.begin(); | 65 | for ( QStringList::Iterator it = Data.PreUp_SL.begin(); |
66 | it != Data.PreUp_SL.end(); | 66 | it != Data.PreUp_SL.end(); |
67 | ++it ) { | 67 | ++it ) { |
68 | TS << "preup=" << quote(*it) << endl; | 68 | TS << "preup=" << quote(*it) << endl; |
69 | } | 69 | } |
70 | for ( QStringList::Iterator it = Data.PreDown_SL.begin(); | 70 | for ( QStringList::Iterator it = Data.PreDown_SL.begin(); |
71 | it != Data.PreDown_SL.end(); | 71 | it != Data.PreDown_SL.end(); |
72 | ++it ) { | 72 | ++it ) { |
73 | TS << "predown=" << quote(*it) << endl; | 73 | TS << "predown=" << quote(*it) << endl; |
74 | } | 74 | } |
75 | for ( QStringList::Iterator it = Data.PostUp_SL.begin(); | 75 | for ( QStringList::Iterator it = Data.PostUp_SL.begin(); |
76 | it != Data.PostUp_SL.end(); | 76 | it != Data.PostUp_SL.end(); |
77 | ++it ) { | 77 | ++it ) { |
78 | TS << "postup=" << quote(*it) << endl; | 78 | TS << "postup=" << quote(*it) << endl; |
79 | } | 79 | } |
80 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); | 80 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); |
81 | it != Data.PostDown_SL.end(); | 81 | it != Data.PostDown_SL.end(); |
82 | ++it ) { | 82 | ++it ) { |
83 | TS << "postdown=" << quote(*it) << endl; | 83 | TS << "postdown=" << quote(*it) << endl; |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | QWidget * ANetwork::edit( QWidget * parent ) { | 87 | QWidget * ANetwork::edit( QWidget * parent ) { |
88 | GUI = new NetworkEdit( parent ); | 88 | GUI = new NetworkEdit( parent ); |
89 | GUI->showData( Data ); | 89 | GUI->showData( Data ); |
90 | return GUI; | 90 | return GUI; |
91 | } | 91 | } |
92 | 92 | ||
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() << |
128 | ".up" << Data.IPAddress << endl; | 123 | ".up" << Data.IPAddress << endl; |
129 | S << " down rm -f /tmp/profile-" << connection()->number() << | 124 | S << " down rm -f /tmp/profile-" << connection()->number() << |
130 | ".up" << Data.IPAddress << endl; | 125 | ".up" << Data.IPAddress << endl; |
131 | S << " address " << Data.IPAddress << endl; | 126 | S << " address " << Data.IPAddress << endl; |
132 | S << " broadcast " << Data.Broadcast << endl; | 127 | S << " broadcast " << Data.Broadcast << endl; |
133 | S << " netmask " << Data.NetMask << endl; | 128 | S << " netmask " << Data.NetMask << endl; |
134 | 129 | ||
135 | // derive network address = IPAddress & netmask | 130 | // derive network address = IPAddress & netmask |
136 | { QString NW; | 131 | { QString NW; |
137 | QStringList ipal = QStringList::split( '.', Data.IPAddress ); | 132 | QStringList ipal = QStringList::split( '.', Data.IPAddress ); |
138 | QStringList nmal = QStringList::split( '.', Data.NetMask ); | 133 | QStringList nmal = QStringList::split( '.', Data.NetMask ); |
139 | 134 | ||
140 | NW = QString( "%1.%2.%3.%4" ). | 135 | NW = QString( "%1.%2.%3.%4" ). |
141 | arg( ipal[0].toShort() & nmal[0].toShort() ). | 136 | arg( ipal[0].toShort() & nmal[0].toShort() ). |
142 | arg( ipal[1].toShort() & nmal[1].toShort() ). | 137 | arg( ipal[1].toShort() & nmal[1].toShort() ). |
143 | arg( ipal[2].toShort() & nmal[2].toShort() ). | 138 | arg( ipal[2].toShort() & nmal[2].toShort() ). |
144 | arg( ipal[3].toShort() & nmal[3].toShort() ); | 139 | arg( ipal[3].toShort() & nmal[3].toShort() ); |
145 | S << " network " << NW << endl; | 140 | S << " network " << NW << endl; |
146 | } | 141 | } |
147 | } | 142 | } |
148 | for ( QStringList::Iterator it = Data.PreUp_SL.begin(); | 143 | for ( QStringList::Iterator it = Data.PreUp_SL.begin(); |
149 | it != Data.PreUp_SL.end(); | 144 | it != Data.PreUp_SL.end(); |
150 | ++it ) { | 145 | ++it ) { |
151 | S << " pre-up " << (*it) << endl; | 146 | S << " pre-up " << (*it) << endl; |
152 | } | 147 | } |
153 | for ( QStringList::Iterator it = Data.PostUp_SL.begin(); | 148 | for ( QStringList::Iterator it = Data.PostUp_SL.begin(); |
154 | it != Data.PostUp_SL.end(); | 149 | it != Data.PostUp_SL.end(); |
155 | ++it ) { | 150 | ++it ) { |
156 | S << " up " << (*it) << endl; | 151 | S << " up " << (*it) << endl; |
157 | } | 152 | } |
158 | for ( QStringList::Iterator it = Data.PreDown_SL.begin(); | 153 | for ( QStringList::Iterator it = Data.PreDown_SL.begin(); |
159 | it != Data.PreDown_SL.end(); | 154 | it != Data.PreDown_SL.end(); |
160 | ++it ) { | 155 | ++it ) { |
161 | S << " down " << (*it) << endl; | 156 | S << " down " << (*it) << endl; |
162 | } | 157 | } |
163 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); | 158 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); |
164 | it != Data.PostDown_SL.end(); | 159 | it != Data.PostDown_SL.end(); |
165 | ++it ) { | 160 | ++it ) { |
166 | S << " post-down " << (*it) << endl; | 161 | S << " post-down " << (*it) << endl; |
167 | } | 162 | } |
168 | } | 163 | } |
169 | return 0; | 164 | return 0; |
170 | } | 165 | } |
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 | |||
@@ -1,125 +1,125 @@ | |||
1 | #include <qtoolbutton.h> | 1 | #include <qtoolbutton.h> |
2 | #include <qcheckbox.h> | 2 | #include <qcheckbox.h> |
3 | #include <qlineedit.h> | 3 | #include <qlineedit.h> |
4 | #include <qlistbox.h> | 4 | #include <qlistbox.h> |
5 | #include <GUIUtils.h> | 5 | #include <GUIUtils.h> |
6 | #include <resources.h> | 6 | #include <resources.h> |
7 | #include "networkedit.h" | 7 | #include "networkedit.h" |
8 | 8 | ||
9 | NetworkEdit::NetworkEdit( QWidget * Parent ) : NetworkGUI( Parent ){ | 9 | NetworkEdit::NetworkEdit( QWidget * Parent ) : NetworkGUI( Parent ){ |
10 | 10 | ||
11 | AddPreDown_TB->setPixmap( NSResources->getPixmap( "add" ) ); | 11 | AddPreDown_TB->setPixmap( NSResources->getPixmap( "add" ) ); |
12 | AddPreUp_TB->setPixmap( NSResources->getPixmap( "add" ) ); | 12 | AddPreUp_TB->setPixmap( NSResources->getPixmap( "add" ) ); |
13 | AddPostDown_TB->setPixmap( NSResources->getPixmap( "add" ) ); | 13 | AddPostDown_TB->setPixmap( NSResources->getPixmap( "add" ) ); |
14 | AddPostUp_TB->setPixmap( NSResources->getPixmap( "add" ) ); | 14 | AddPostUp_TB->setPixmap( NSResources->getPixmap( "add" ) ); |
15 | 15 | ||
16 | DeletePreDown_TB->setPixmap( NSResources->getPixmap( "remove" ) ); | 16 | DeletePreDown_TB->setPixmap( NSResources->getPixmap( "remove" ) ); |
17 | DeletePreUp_TB->setPixmap( NSResources->getPixmap( "remove" ) ); | 17 | DeletePreUp_TB->setPixmap( NSResources->getPixmap( "remove" ) ); |
18 | DeletePostDown_TB->setPixmap( NSResources->getPixmap( "remove" ) ); | 18 | DeletePostDown_TB->setPixmap( NSResources->getPixmap( "remove" ) ); |
19 | DeletePostUp_TB->setPixmap( NSResources->getPixmap( "remove" ) ); | 19 | DeletePostUp_TB->setPixmap( NSResources->getPixmap( "remove" ) ); |
20 | 20 | ||
21 | UpPreDown_TB->setPixmap( NSResources->getPixmap( "up" ) ); | 21 | UpPreDown_TB->setPixmap( NSResources->getPixmap( "up" ) ); |
22 | UpPreUp_TB->setPixmap( NSResources->getPixmap( "up" ) ); | 22 | UpPreUp_TB->setPixmap( NSResources->getPixmap( "up" ) ); |
23 | UpPostDown_TB->setPixmap( NSResources->getPixmap( "up" ) ); | 23 | UpPostDown_TB->setPixmap( NSResources->getPixmap( "up" ) ); |
24 | UpPostUp_TB->setPixmap( NSResources->getPixmap( "up" ) ); | 24 | UpPostUp_TB->setPixmap( NSResources->getPixmap( "up" ) ); |
25 | 25 | ||
26 | DownPreDown_TB->setPixmap( NSResources->getPixmap( "down" ) ); | 26 | DownPreDown_TB->setPixmap( NSResources->getPixmap( "down" ) ); |
27 | DownPreUp_TB->setPixmap( NSResources->getPixmap( "down" ) ); | 27 | DownPreUp_TB->setPixmap( NSResources->getPixmap( "down" ) ); |
28 | DownPostDown_TB->setPixmap( NSResources->getPixmap( "down" ) ); | 28 | DownPostDown_TB->setPixmap( NSResources->getPixmap( "down" ) ); |
29 | DownPostUp_TB->setPixmap( NSResources->getPixmap( "down" ) ); | 29 | DownPostUp_TB->setPixmap( NSResources->getPixmap( "down" ) ); |
30 | 30 | ||
31 | } | 31 | } |
32 | 32 | ||
33 | QString NetworkEdit::acceptable( void ) { | 33 | QString NetworkEdit::acceptable( void ) { |
34 | if( DHCP_CB->isChecked() ) { | 34 | if( DHCP_CB->isChecked() ) { |
35 | if( SendHostname_CB->isChecked() ) | 35 | if( SendHostname_CB->isChecked() ) |
36 | if( Hostname_LE->text().isEmpty() ) | 36 | if( Hostname_LE->text().isEmpty() ) |
37 | return tr("Hostname needed"); | 37 | return tr("Hostname needed"); |
38 | return QString(); | 38 | return QString(); |
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 ); |
78 | 78 | ||
79 | SM |= updateList( Data.PreUp_SL, PreUp_LB ); | 79 | SM |= updateList( Data.PreUp_SL, PreUp_LB ); |
80 | SM |= updateList( Data.PostUp_SL, PostUp_LB ); | 80 | SM |= updateList( Data.PostUp_SL, PostUp_LB ); |
81 | SM |= updateList( Data.PreDown_SL, PreDown_LB ); | 81 | SM |= updateList( Data.PreDown_SL, PreDown_LB ); |
82 | SM |= updateList( Data.PostDown_SL, PostDown_LB ); | 82 | SM |= updateList( Data.PostDown_SL, PostDown_LB ); |
83 | 83 | ||
84 | return SM; | 84 | return SM; |
85 | } | 85 | } |
86 | 86 | ||
87 | void NetworkEdit::showData( NetworkData_t & Data ) { | 87 | void NetworkEdit::showData( NetworkData_t & Data ) { |
88 | DHCP_CB->setChecked( Data.UseDHCP ); | 88 | DHCP_CB->setChecked( Data.UseDHCP ); |
89 | SendHostname_CB->setChecked( Data.SendHostname ); | 89 | SendHostname_CB->setChecked( Data.SendHostname ); |
90 | Hostname_LE->setText( Data.Hostname ); | 90 | Hostname_LE->setText( Data.Hostname ); |
91 | IPAddress_LE->setText( Data.IPAddress ); | 91 | IPAddress_LE->setText( Data.IPAddress ); |
92 | Gateway_LE->setText( Data.Gateway ); | 92 | Gateway_LE->setText( Data.Gateway ); |
93 | SubnetMask_LE->setText( Data.NetMask ); | 93 | SubnetMask_LE->setText( Data.NetMask ); |
94 | Broadcast_LE->setText( Data.Broadcast ); | 94 | Broadcast_LE->setText( Data.Broadcast ); |
95 | DNS1_LE->setText( Data.DNS1 ); | 95 | DNS1_LE->setText( Data.DNS1 ); |
96 | DNS2_LE->setText( Data.DNS2 ); | 96 | DNS2_LE->setText( Data.DNS2 ); |
97 | 97 | ||
98 | populateList( Data.PreUp_SL, PreUp_LB ); | 98 | populateList( Data.PreUp_SL, PreUp_LB ); |
99 | populateList( Data.PostUp_SL, PostUp_LB ); | 99 | populateList( Data.PostUp_SL, PostUp_LB ); |
100 | populateList( Data.PreDown_SL, PreDown_LB ); | 100 | populateList( Data.PreDown_SL, PreDown_LB ); |
101 | populateList( Data.PostDown_SL, PostDown_LB ); | 101 | populateList( Data.PostDown_SL, PostDown_LB ); |
102 | } | 102 | } |
103 | 103 | ||
104 | bool NetworkEdit::updateList( QStringList & SL, QListBox * LB ) { | 104 | bool NetworkEdit::updateList( QStringList & SL, QListBox * LB ) { |
105 | bool Changed; | 105 | bool Changed; |
106 | QStringList NewSL; | 106 | QStringList NewSL; |
107 | 107 | ||
108 | // collect new list | 108 | // collect new list |
109 | for( unsigned int i = 0; i < LB->count() ; i ++ ) { | 109 | for( unsigned int i = 0; i < LB->count() ; i ++ ) { |
110 | NewSL.append( LB->text(i) ); | 110 | NewSL.append( LB->text(i) ); |
111 | } | 111 | } |
112 | 112 | ||
113 | // check if at least ONE item in new list is NEW | 113 | // check if at least ONE item in new list is NEW |
114 | Changed = 0; | 114 | Changed = 0; |
115 | for ( QStringList::Iterator it = NewSL.begin(); | 115 | for ( QStringList::Iterator it = NewSL.begin(); |
116 | it != NewSL.end(); | 116 | it != NewSL.end(); |
117 | ++it ) { | 117 | ++it ) { |
118 | if( SL.findIndex( (*it) ) < 0 ) { | 118 | if( SL.findIndex( (*it) ) < 0 ) { |
119 | // new or modified item | 119 | // new or modified item |
120 | Changed = 1; | 120 | Changed = 1; |
121 | SL = NewSL; | 121 | SL = NewSL; |
122 | break; | 122 | break; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | return Changed; | 125 | return Changed; |
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 | |||
@@ -1,63 +1,65 @@ | |||
1 | #include <system.h> | 1 | #include <system.h> |
2 | #include <asdevice.h> | 2 | #include <asdevice.h> |
3 | #include "networkrun.h" | 3 | #include "networkrun.h" |
4 | 4 | ||
5 | void NetworkRun::detectState( NodeCollection * NC ) { | 5 | void NetworkRun::detectState( NodeCollection * NC ) { |
6 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 6 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); |
7 | AsDevice * Next = RI->asDevice(); | 7 | AsDevice * Next = RI->asDevice(); |
8 | InterfaceInfo * II = Next->assignedInterface(); | 8 | InterfaceInfo * II = Next->assignedInterface(); |
9 | 9 | ||
10 | if( II ) { | 10 | if( II ) { |
11 | // device has assigned interface | 11 | // device has assigned interface |
12 | NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); | 12 | NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); |
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 | } |
56 | // delegate | 58 | // delegate |
57 | return RI->canSetState( Curr, A ); | 59 | return RI->canSetState( Curr, A ); |
58 | } | 60 | } |
59 | 61 | ||
60 | bool NetworkRun::handlesInterface( const QString & S ) { | 62 | bool NetworkRun::handlesInterface( const QString & S ) { |
61 | // donno -> pass deeper | 63 | // donno -> pass deeper |
62 | return netNode()->nextNode()->runtime()->handlesInterface(S); | 64 | return netNode()->nextNode()->runtime()->handlesInterface(S); |
63 | } | 65 | } |
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 | |||
@@ -107,158 +107,176 @@ void NetworkSettings::SLOT_RefreshStates( void ) { | |||
107 | 107 | ||
108 | /* -> LATER !! | 108 | /* -> LATER !! |
109 | bool is; | 109 | bool is; |
110 | NodeCollection * NC; | 110 | NodeCollection * NC; |
111 | 111 | ||
112 | for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) { | 112 | for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) { |
113 | NC = NSResources->findConnection( Profiles_LB->text(i) ); | 113 | NC = NSResources->findConnection( Profiles_LB->text(i) ); |
114 | if( NC ) { | 114 | if( NC ) { |
115 | State_t OldS = NC->state(); | 115 | State_t OldS = NC->state(); |
116 | State_t NewS = NC->state(1); | 116 | State_t NewS = NC->state(1); |
117 | if( OldS != NewS ) { | 117 | if( OldS != NewS ) { |
118 | is = Profiles_LB->isSelected(i); | 118 | is = Profiles_LB->isSelected(i); |
119 | Profiles_LB->changeItem( NC->statePixmap(NewS), | 119 | Profiles_LB->changeItem( NC->statePixmap(NewS), |
120 | NC->name(), | 120 | NC->name(), |
121 | i ); | 121 | i ); |
122 | if( is ) { | 122 | if( is ) { |
123 | Profiles_LB->setSelected( i, TRUE ); | 123 | Profiles_LB->setSelected( i, TRUE ); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | } | 126 | } |
127 | } | 127 | } |
128 | if( ci >= 0 ) | 128 | if( ci >= 0 ) |
129 | Profiles_LB->setCurrentItem( ci ); | 129 | Profiles_LB->setCurrentItem( ci ); |
130 | */ | 130 | */ |
131 | } | 131 | } |
132 | 132 | ||
133 | void NetworkSettings::SLOT_AddNode( void ) { | 133 | void NetworkSettings::SLOT_AddNode( void ) { |
134 | SLOT_EditNode( 0 ); | 134 | SLOT_EditNode( 0 ); |
135 | } | 135 | } |
136 | 136 | ||
137 | void NetworkSettings::SLOT_DeleteNode( void ) { | 137 | void NetworkSettings::SLOT_DeleteNode( void ) { |
138 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); | 138 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
139 | 139 | ||
140 | if ( ! LBI ) | 140 | if ( ! LBI ) |
141 | return; | 141 | return; |
142 | 142 | ||
143 | if( QMessageBox::warning( | 143 | if( QMessageBox::warning( |
144 | 0, | 144 | 0, |
145 | tr( "Removing profile" ), | 145 | tr( "Removing profile" ), |
146 | tr( "Remove selected profile ?" ), | 146 | tr( "Remove selected profile ?" ), |
147 | 1, 0 ) == 1 ) { | 147 | 1, 0 ) == 1 ) { |
148 | NSResources->removeConnection( LBI->text() ); | 148 | NSResources->removeConnection( LBI->text() ); |
149 | delete LBI; | 149 | delete LBI; |
150 | setModified( 1 ); | 150 | setModified( 1 ); |
151 | NSD.forceGeneration(1); | 151 | NSD.forceGeneration(1); |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
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 | ||
217 | EnabledPossible = OnPossible = ConnectPossible = 1; | 235 | EnabledPossible = OnPossible = ConnectPossible = 1; |
218 | DisabledOn = 1; | 236 | DisabledOn = 1; |
219 | OnOn = ConnectOn = 0; | 237 | OnOn = ConnectOn = 0; |
220 | 238 | ||
221 | switch( NC->state() ) { | 239 | switch( NC->state() ) { |
222 | case Unknown : | 240 | case Unknown : |
223 | // cannot occur here | 241 | // cannot occur here |
224 | break; | 242 | break; |
225 | case Unchecked : | 243 | case Unchecked : |
226 | case Unavailable : | 244 | case Unavailable : |
227 | // cannot do anything but recheck | 245 | // cannot do anything but recheck |
228 | EnabledPossible = OnPossible = ConnectPossible = 0; | 246 | EnabledPossible = OnPossible = ConnectPossible = 0; |
229 | break; | 247 | break; |
230 | case Disabled : | 248 | case Disabled : |
231 | OnPossible = ConnectPossible = 0; | 249 | OnPossible = ConnectPossible = 0; |
232 | break; | 250 | break; |
233 | case Off : | 251 | case Off : |
234 | DisabledOn = 0; | 252 | DisabledOn = 0; |
235 | break; | 253 | break; |
236 | case Available : | 254 | case Available : |
237 | OnOn = 1; | 255 | OnOn = 1; |
238 | DisabledOn = 0; | 256 | DisabledOn = 0; |
239 | break; | 257 | break; |
240 | case IsUp : | 258 | case IsUp : |
241 | OnOn = ConnectOn = 1; | 259 | OnOn = ConnectOn = 1; |
242 | DisabledOn = 0; | 260 | DisabledOn = 0; |
243 | break; | 261 | break; |
244 | } | 262 | } |
245 | 263 | ||
246 | // set button state | 264 | // set button state |
247 | Enable_TB->setEnabled( EnabledPossible ); | 265 | Enable_TB->setEnabled( EnabledPossible ); |
248 | On_TB->setEnabled( OnPossible ); | 266 | On_TB->setEnabled( OnPossible ); |
249 | Connect_TB->setEnabled( ConnectPossible ); | 267 | Connect_TB->setEnabled( ConnectPossible ); |
250 | 268 | ||
251 | Enable_TB->setOn( DisabledOn ); | 269 | Enable_TB->setOn( DisabledOn ); |
252 | On_TB->setOn( OnOn ); | 270 | On_TB->setOn( OnOn ); |
253 | Connect_TB->setOn( ConnectOn ); | 271 | Connect_TB->setOn( ConnectOn ); |
254 | 272 | ||
255 | if( NC->description().isEmpty() ) { | 273 | if( NC->description().isEmpty() ) { |
256 | Description_LBL->setText( tr( "No description" ) ); | 274 | Description_LBL->setText( tr( "No description" ) ); |
257 | } else { | 275 | } else { |
258 | Description_LBL->setText( NC->description() ); | 276 | Description_LBL->setText( NC->description() ); |
259 | } | 277 | } |
260 | 278 | ||
261 | CurProfile_GB->setTitle( LBI->text() ); | 279 | CurProfile_GB->setTitle( LBI->text() ); |
262 | State_LBL->setText( NC->stateName() ); | 280 | State_LBL->setText( NC->stateName() ); |
263 | } | 281 | } |
264 | 282 | ||
@@ -272,140 +290,134 @@ void NetworkSettings::SLOT_CheckState( void ) { | |||
272 | void NetworkSettings::updateProfileState( QListBoxItem * LBI ) { | 290 | void NetworkSettings::updateProfileState( QListBoxItem * LBI ) { |
273 | if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) { | 291 | if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) { |
274 | SLOT_ShowNode( LBI ); | 292 | SLOT_ShowNode( LBI ); |
275 | } | 293 | } |
276 | } | 294 | } |
277 | 295 | ||
278 | void NetworkSettings::SLOT_GenerateConfig( void ) { | 296 | void NetworkSettings::SLOT_GenerateConfig( void ) { |
279 | QString S = NSD.generateSettings( TRUE ); | 297 | QString S = NSD.generateSettings( TRUE ); |
280 | 298 | ||
281 | if( ! S.isEmpty() ) { | 299 | if( ! S.isEmpty() ) { |
282 | QMessageBox::warning( | 300 | QMessageBox::warning( |
283 | 0, | 301 | 0, |
284 | tr( "Generating system configuration" ), | 302 | tr( "Generating system configuration" ), |
285 | S | 303 | S |
286 | ); | 304 | ); |
287 | } | 305 | } |
288 | } | 306 | } |
289 | 307 | ||
290 | void NetworkSettings::SLOT_Enable( void ) { | 308 | void NetworkSettings::SLOT_Enable( void ) { |
291 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); | 309 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
292 | QString Msg; | 310 | QString Msg; |
293 | if ( ! LBI ) | 311 | if ( ! LBI ) |
294 | return; | 312 | return; |
295 | 313 | ||
296 | NodeCollection * NC = | 314 | NodeCollection * NC = |
297 | NSResources->findConnection( LBI->text() ); | 315 | NSResources->findConnection( LBI->text() ); |
298 | 316 | ||
299 | bool rv; | 317 | bool rv; |
300 | switch( NC->state() ) { | 318 | switch( NC->state() ) { |
301 | case Disabled : | 319 | case Disabled : |
302 | Msg = tr( "Cannot enable profile" ); | 320 | Msg = tr( "Cannot enable profile" ); |
303 | rv = NC->setState( Enable ); | 321 | rv = NC->setState( Enable ); |
304 | break; | 322 | break; |
305 | default : | 323 | default : |
306 | Msg = tr( "Cannot disable profile" ); | 324 | Msg = tr( "Cannot disable profile" ); |
307 | rv = NC->setState( Disable ); | 325 | rv = NC->setState( Disable ); |
308 | break; | 326 | break; |
309 | } | 327 | } |
310 | 328 | ||
311 | if( ! rv ) { | 329 | if( ! rv ) { |
312 | QMessageBox::warning( | 330 | QMessageBox::warning( |
313 | 0, | 331 | 0, |
314 | tr( "Activating profile" ), | 332 | tr( "Activating profile" ), |
315 | Msg ); | 333 | Msg ); |
316 | return; | 334 | return; |
317 | } | 335 | } |
318 | updateProfileState( LBI ); | 336 | updateProfileState( LBI ); |
319 | } | 337 | } |
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 | } */ |
411 | } | 423 | } |
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 | |||
@@ -34,257 +34,261 @@ typedef enum State { | |||
34 | Unchecked = 0, | 34 | Unchecked = 0, |
35 | // if we cannot determine the state | 35 | // if we cannot determine the state |
36 | Unknown = 1, | 36 | Unknown = 1, |
37 | // if connection cannot be established e.g. because | 37 | // if connection cannot be established e.g. because |
38 | // the hardware is not available | 38 | // the hardware is not available |
39 | Unavailable = 2, | 39 | Unavailable = 2, |
40 | // if the connection cannot be establishec but NOT | 40 | // if the connection cannot be establishec but NOT |
41 | // because it is physically impossible but because | 41 | // because it is physically impossible but because |
42 | // it has been disabled for FUNCTIONAL reasons | 42 | // it has been disabled for FUNCTIONAL reasons |
43 | Disabled = 3, | 43 | Disabled = 3, |
44 | // if connection is available to is currently down | 44 | // if connection is available to is currently down |
45 | // i.e. the corresponding hardware is not activated | 45 | // i.e. the corresponding hardware is not activated |
46 | Off = 4, | 46 | Off = 4, |
47 | // if connection is available to be used (i.e. the | 47 | // if connection is available to be used (i.e. the |
48 | // devices if fully ready to be used | 48 | // devices if fully ready to be used |
49 | Available = 5, | 49 | Available = 5, |
50 | // if connection is being used | 50 | // if connection is being used |
51 | IsUp = 6 | 51 | IsUp = 6 |
52 | } State_t; | 52 | } State_t; |
53 | 53 | ||
54 | typedef enum Action { | 54 | typedef enum Action { |
55 | // to make the device unavailable functionally | 55 | // to make the device unavailable functionally |
56 | Disable = 0, | 56 | Disable = 0, |
57 | // to make the device available functionally | 57 | // to make the device available functionally |
58 | Enable = 1, | 58 | Enable = 1, |
59 | // bring the hardware up | 59 | // bring the hardware up |
60 | Activate = 2, | 60 | Activate = 2, |
61 | // bring the hardware down | 61 | // bring the hardware down |
62 | Deactivate = 3, | 62 | Deactivate = 3, |
63 | // bring the connection up | 63 | // bring the connection up |
64 | Up = 4, | 64 | Up = 4, |
65 | // bring the connection down | 65 | // bring the connection down |
66 | Down = 5 | 66 | Down = 5 |
67 | } Action_t; | 67 | } Action_t; |
68 | 68 | ||
69 | class ANetNode : public QObject{ | 69 | class ANetNode : public QObject{ |
70 | 70 | ||
71 | public: | 71 | public: |
72 | 72 | ||
73 | typedef QArray<ANetNode *> NetNodeList; | 73 | typedef QArray<ANetNode *> NetNodeList; |
74 | 74 | ||
75 | ANetNode(){}; | 75 | ANetNode(){}; |
76 | virtual ~ANetNode(){}; | 76 | virtual ~ANetNode(){}; |
77 | 77 | ||
78 | // pixmap needed for this NetNode | 78 | // pixmap needed for this NetNode |
79 | virtual const QString pixmapName() = 0; | 79 | virtual const QString pixmapName() = 0; |
80 | 80 | ||
81 | // name of this NetNode | 81 | // name of this NetNode |
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 : |
119 | }; | 123 | }; |
120 | 124 | ||
121 | class ANetNodeInstance : public QObject { | 125 | class ANetNodeInstance : public QObject { |
122 | 126 | ||
123 | public: | 127 | public: |
124 | 128 | ||
125 | ANetNodeInstance( ANetNode * NN ) : QObject() | 129 | ANetNodeInstance( ANetNode * NN ) : QObject() |
126 | { IsModified=0; NodeType = NN; IsNew = TRUE; } | 130 | { IsModified=0; NodeType = NN; IsNew = TRUE; } |
127 | virtual ~ANetNodeInstance( void ) { } | 131 | virtual ~ANetNodeInstance( void ) { } |
128 | 132 | ||
129 | virtual RuntimeInfo * runtime( void ) = 0; | 133 | virtual RuntimeInfo * runtime( void ) = 0; |
130 | 134 | ||
131 | void setConnection( NodeCollection * NC ) | 135 | void setConnection( NodeCollection * NC ) |
132 | { Connection = NC; } | 136 | { Connection = NC; } |
133 | NodeCollection * connection( void ) | 137 | NodeCollection * connection( void ) |
134 | { return Connection; } | 138 | { return Connection; } |
135 | 139 | ||
136 | // create edit widget under parent | 140 | // create edit widget under parent |
137 | virtual QWidget * edit( QWidget * parent ) = 0; | 141 | virtual QWidget * edit( QWidget * parent ) = 0; |
138 | // is given data acceptable | 142 | // is given data acceptable |
139 | virtual QString acceptable( void ) = 0; | 143 | virtual QString acceptable( void ) = 0; |
140 | 144 | ||
141 | // return data was modified | 145 | // return data was modified |
142 | void setModified( bool M ) | 146 | void setModified( bool M ) |
143 | { IsModified = M; } | 147 | { IsModified = M; } |
144 | bool isModified( void ) | 148 | bool isModified( void ) |
145 | { return IsModified; } | 149 | { return IsModified; } |
146 | 150 | ||
147 | // get data from GUI and store in node | 151 | // get data from GUI and store in node |
148 | virtual void commit( void ) = 0; | 152 | virtual void commit( void ) = 0; |
149 | 153 | ||
150 | // get next node | 154 | // get next node |
151 | ANetNodeInstance * nextNode(); | 155 | ANetNodeInstance * nextNode(); |
152 | // return NetNode this is an instance of | 156 | // return NetNode this is an instance of |
153 | ANetNode * netNode( void ) | 157 | ANetNode * netNode( void ) |
154 | { return NodeType; } | 158 | { return NodeType; } |
155 | 159 | ||
156 | // intialize am instance of a net node | 160 | // intialize am instance of a net node |
157 | void initialize( void ); | 161 | void initialize( void ); |
158 | 162 | ||
159 | // set the value of an attribute | 163 | // set the value of an attribute |
160 | void setAttribute( QString & Attr, QString & Value ) ; | 164 | void setAttribute( QString & Attr, QString & Value ) ; |
161 | void saveAttributes( QTextStream & TS ) ; | 165 | void saveAttributes( QTextStream & TS ) ; |
162 | 166 | ||
163 | // return true if node isntance is NEW and not loaded | 167 | // return true if node isntance is NEW and not loaded |
164 | void setNew( bool IsN ) | 168 | void setNew( bool IsN ) |
165 | { IsNew = IsN; } | 169 | { IsNew = IsN; } |
166 | bool isNew( void ) | 170 | bool isNew( void ) |
167 | { return IsNew; } | 171 | { return IsNew; } |
168 | 172 | ||
169 | // return logical name of this instance | 173 | // return logical name of this instance |
170 | QString & nodeName( void ) | 174 | QString & nodeName( void ) |
171 | { return NodeName; } | 175 | { return NodeName; } |
172 | void setNodeName( const QString & S ) | 176 | void setNodeName( const QString & S ) |
173 | { NodeName = S; } | 177 | { NodeName = S; } |
174 | // return description for this instance | 178 | // return description for this instance |
175 | QString & description( void ) | 179 | QString & description( void ) |
176 | { return Description; } | 180 | { return Description; } |
177 | void setDescription( const QString & S ) | 181 | void setDescription( const QString & S ) |
178 | { Description = S; } | 182 | { Description = S; } |
179 | 183 | ||
180 | // pixmap for this instance -> from NetNode | 184 | // pixmap for this instance -> from NetNode |
181 | const QString pixmapName( void ) | 185 | const QString pixmapName( void ) |
182 | { return NodeType->pixmapName(); } | 186 | { return NodeType->pixmapName(); } |
183 | 187 | ||
184 | const char * provides( void ) | 188 | const char * provides( void ) |
185 | { return NodeType->provides(); } | 189 | { return NodeType->provides(); } |
186 | 190 | ||
187 | const char ** needs( void ) | 191 | const char ** needs( void ) |
188 | { return NodeType->needs(); } | 192 | { return NodeType->needs(); } |
189 | 193 | ||
190 | // returns node specific data -> only useful for 'buddy' | 194 | // returns node specific data -> only useful for 'buddy' |
191 | virtual void * data( void ) = 0; | 195 | virtual void * data( void ) = 0; |
192 | 196 | ||
193 | protected : | 197 | protected : |
194 | 198 | ||
195 | virtual void setSpecificAttribute( QString & , QString & ) = 0; | 199 | virtual void setSpecificAttribute( QString & , QString & ) = 0; |
196 | virtual void saveSpecificAttribute( QTextStream & ) = 0; | 200 | virtual void saveSpecificAttribute( QTextStream & ) = 0; |
197 | 201 | ||
198 | ANetNode * NodeType; | 202 | ANetNode * NodeType; |
199 | // connection to which this node belongs to | 203 | // connection to which this node belongs to |
200 | NodeCollection * Connection; | 204 | NodeCollection * Connection; |
201 | QString NodeName; | 205 | QString NodeName; |
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; |
243 | 247 | ||
244 | signals : | 248 | signals : |
245 | 249 | ||
246 | // sent by device if state changes | 250 | // sent by device if state changes |
247 | void stateChanged( State_t S, ANetNodeInstance * NNI ); | 251 | void stateChanged( State_t S, ANetNodeInstance * NNI ); |
248 | 252 | ||
249 | protected : | 253 | protected : |
250 | 254 | ||
251 | // connection this runtime info belongs to | 255 | // connection this runtime info belongs to |
252 | ANetNodeInstance * NNI; | 256 | ANetNodeInstance * NNI; |
253 | }; | 257 | }; |
254 | 258 | ||
255 | class NodeCollection : public QList<ANetNodeInstance> { | 259 | class NodeCollection : public QList<ANetNodeInstance> { |
256 | 260 | ||
257 | public : | 261 | public : |
258 | 262 | ||
259 | NodeCollection( void ); | 263 | NodeCollection( void ); |
260 | NodeCollection( QTextStream & TS ); | 264 | NodeCollection( QTextStream & TS ); |
261 | ~NodeCollection( void ); | 265 | ~NodeCollection( void ); |
262 | 266 | ||
263 | int number( void ) | 267 | int number( void ) |
264 | { return Number; } | 268 | { return Number; } |
265 | void setNumber( int i ) | 269 | void setNumber( int i ) |
266 | { Number = i; if( MaxNr < i ) MaxNr = i; } | 270 | { Number = i; if( MaxNr < i ) MaxNr = i; } |
267 | bool isNew( void ) | 271 | bool isNew( void ) |
268 | { return IsNew; } | 272 | { return IsNew; } |
269 | void setNew( bool N ) | 273 | void setNew( bool N ) |
270 | { IsNew = N ; } | 274 | { IsNew = N ; } |
271 | bool isModified( void ) | 275 | bool isModified( void ) |
272 | { return IsModified; } | 276 | { return IsModified; } |
273 | void setModified( bool N ) | 277 | void setModified( bool N ) |
274 | { IsModified = N ; } | 278 | { IsModified = N ; } |
275 | 279 | ||
276 | bool handlesInterface( const QString & S ) { | 280 | bool handlesInterface( const QString & S ) { |
277 | return getToplevel()->runtime()->handlesInterface( S ); | 281 | return getToplevel()->runtime()->handlesInterface( S ); |
278 | } | 282 | } |
279 | 283 | ||
280 | InterfaceInfo * assignedInterface( void ) { | 284 | InterfaceInfo * assignedInterface( void ) { |
281 | return getToplevel()->runtime()->assignedInterface(); | 285 | return getToplevel()->runtime()->assignedInterface(); |
282 | } | 286 | } |
283 | 287 | ||
284 | AsDevice * device() { | 288 | AsDevice * device() { |
285 | return getToplevel()->runtime()->device(); | 289 | return getToplevel()->runtime()->device(); |
286 | } | 290 | } |
287 | 291 | ||
288 | State_t state( bool Update = 0 ) | 292 | State_t state( bool Update = 0 ) |
289 | { if( CurrentState == Unchecked || Update ) { | 293 | { if( CurrentState == Unchecked || Update ) { |
290 | // need to get current state | 294 | // need to get current state |
@@ -323,118 +327,121 @@ public : | |||
323 | { return Name; } | 327 | { return Name; } |
324 | 328 | ||
325 | const QString & description( void ); | 329 | const QString & description( void ); |
326 | 330 | ||
327 | void setName( const QString & N) | 331 | void setName( const QString & N) |
328 | { Name = N; } | 332 | { Name = N; } |
329 | 333 | ||
330 | State_t currentState( void ) | 334 | State_t currentState( void ) |
331 | { return CurrentState; } | 335 | { return CurrentState; } |
332 | void setCurrentState( State_t S ) | 336 | void setCurrentState( State_t S ) |
333 | { CurrentState = S; } | 337 | { CurrentState = S; } |
334 | 338 | ||
335 | long maxConnectionNumber( void ) | 339 | long maxConnectionNumber( void ) |
336 | { return MaxNr; } | 340 | { return MaxNr; } |
337 | 341 | ||
338 | static void resetMaxNr( void ) | 342 | static void resetMaxNr( void ) |
339 | { MaxNr = -1; } | 343 | { MaxNr = -1; } |
340 | 344 | ||
341 | private : | 345 | private : |
342 | 346 | ||
343 | int compareItems ( QCollection::Item item1, | 347 | int compareItems ( QCollection::Item item1, |
344 | QCollection::Item item2 ); | 348 | QCollection::Item item2 ); |
345 | 349 | ||
346 | static long MaxNr; | 350 | static long MaxNr; |
347 | long Number; | 351 | long Number; |
348 | 352 | ||
349 | // state of this connection | 353 | // state of this connection |
350 | State_t CurrentState; | 354 | State_t CurrentState; |
351 | 355 | ||
352 | QString Name; | 356 | QString Name; |
353 | // true if this collection was just created (and not | 357 | // true if this collection was just created (and not |
354 | // loaded from file | 358 | // loaded from file |
355 | bool IsNew; | 359 | bool IsNew; |
356 | // index in listbox | 360 | // index in listbox |
357 | int Index; | 361 | int Index; |
358 | bool IsModified; | 362 | bool IsModified; |
359 | 363 | ||
360 | }; | 364 | }; |
361 | 365 | ||
362 | // | 366 | // |
363 | // special node that is used to remember entries for plugins | 367 | // special node that is used to remember entries for plugins |
364 | // that seem missing. This way we never loose data | 368 | // that seem missing. This way we never loose data |
365 | // | 369 | // |
366 | 370 | ||
367 | class FakeNetNode : public ANetNode { | 371 | class FakeNetNode : public ANetNode { |
368 | 372 | ||
369 | public: | 373 | public: |
370 | 374 | ||
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 | ||
408 | // create edit widget under parent | 415 | // create edit widget under parent |
409 | virtual QWidget * edit( QWidget * ) | 416 | virtual QWidget * edit( QWidget * ) |
410 | { return 0; } | 417 | { return 0; } |
411 | // is given data acceptable | 418 | // is given data acceptable |
412 | virtual QString acceptable( void ) | 419 | virtual QString acceptable( void ) |
413 | { return QString(""); } | 420 | { return QString(""); } |
414 | 421 | ||
415 | // get data from GUI and store in node | 422 | // get data from GUI and store in node |
416 | virtual void commit( void ) {} | 423 | virtual void commit( void ) {} |
417 | 424 | ||
418 | // get next node | 425 | // get next node |
419 | ANetNodeInstance * nextNode() | 426 | ANetNodeInstance * nextNode() |
420 | { return 0; } | 427 | { return 0; } |
421 | // return NetNode this is an instance of | 428 | // return NetNode this is an instance of |
422 | 429 | ||
423 | // intialize am instance of a net node | 430 | // intialize am instance of a net node |
424 | void initialize( void ){} | 431 | void initialize( void ){} |
425 | 432 | ||
426 | // returns node specific data -> only useful for 'buddy' | 433 | // returns node specific data -> only useful for 'buddy' |
427 | virtual void * data( void ) | 434 | virtual void * data( void ) |
428 | { return 0; } | 435 | { return 0; } |
429 | 436 | ||
430 | protected : | 437 | protected : |
431 | 438 | ||
432 | virtual void setSpecificAttribute( QString & , QString & ); | 439 | virtual void setSpecificAttribute( QString & , QString & ); |
433 | virtual void saveSpecificAttribute( QTextStream & ); | 440 | virtual void saveSpecificAttribute( QTextStream & ); |
434 | 441 | ||
435 | QDict<QString> ValAttrPairs; | 442 | QDict<QString> ValAttrPairs; |
436 | }; | 443 | }; |
437 | 444 | ||
438 | extern FakeNetNode * FakeNode; | 445 | extern FakeNetNode * FakeNode; |
439 | 446 | ||
440 | #endif | 447 | #endif |
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 | |||
@@ -1,112 +1,113 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <sys/types.h> | 2 | #include <sys/types.h> |
3 | #include <sys/wait.h> | 3 | #include <sys/wait.h> |
4 | #include <qfile.h> | 4 | #include <qfile.h> |
5 | #include <qtextstream.h> | 5 | #include <qtextstream.h> |
6 | #include <net/if.h> | 6 | #include <net/if.h> |
7 | #include <net/if_arp.h> | 7 | #include <net/if_arp.h> |
8 | #include <netinet/in.h> | 8 | #include <netinet/in.h> |
9 | #include <arpa/inet.h> | 9 | #include <arpa/inet.h> |
10 | #include <sys/ioctl.h> | 10 | #include <sys/ioctl.h> |
11 | #include <sys/socket.h> | 11 | #include <sys/socket.h> |
12 | 12 | ||
13 | #include "resources.h" | 13 | #include "resources.h" |
14 | #include "system.h" | 14 | #include "system.h" |
15 | 15 | ||
16 | #define PROCNETDEV "/proc/net/dev" | 16 | #define PROCNETDEV "/proc/net/dev" |
17 | 17 | ||
18 | static char Dig2Hex[] = { | 18 | static char Dig2Hex[] = { |
19 | '0', '1', '2', '3', | 19 | '0', '1', '2', '3', |
20 | '4', '5', '6', '7', | 20 | '4', '5', '6', '7', |
21 | '8', '9', 'A', 'B', | 21 | '8', '9', 'A', 'B', |
22 | 'C', 'D', 'E', 'F' | 22 | 'C', 'D', 'E', 'F' |
23 | }; | 23 | }; |
24 | 24 | ||
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 |
65 | return 3; | 66 | return 3; |
66 | } | 67 | } |
67 | } | 68 | } |
68 | // all is fine | 69 | // all is fine |
69 | return 0; | 70 | return 0; |
70 | } | 71 | } |
71 | 72 | ||
72 | void System::refreshStatistics( InterfaceInfo & I ) { | 73 | void System::refreshStatistics( InterfaceInfo & I ) { |
73 | if( ! ProcDevNet ) { | 74 | if( ! ProcDevNet ) { |
74 | return; | 75 | return; |
75 | } | 76 | } |
76 | // cannot seek on dev | 77 | // cannot seek on dev |
77 | ProcDevNet->close(); | 78 | ProcDevNet->close(); |
78 | ProcDevNet->open( IO_ReadOnly ); | 79 | ProcDevNet->open( IO_ReadOnly ); |
79 | 80 | ||
80 | QString line; | 81 | QString line; |
81 | QTextStream procTs(ProcDevNet); | 82 | QTextStream procTs(ProcDevNet); |
82 | QStringList SL; | 83 | QStringList SL; |
83 | int loc = -1; | 84 | int loc = -1; |
84 | int version; | 85 | int version; |
85 | 86 | ||
86 | procTs.readLine(); | 87 | procTs.readLine(); |
87 | line = procTs.readLine(); | 88 | line = procTs.readLine(); |
88 | // get version | 89 | // get version |
89 | if( line.find("compressed") ) | 90 | if( line.find("compressed") ) |
90 | version = 3; | 91 | version = 3; |
91 | else if( line.find( "bytes" ) ) | 92 | else if( line.find( "bytes" ) ) |
92 | version = 2; | 93 | version = 2; |
93 | else | 94 | else |
94 | version = 1; | 95 | version = 1; |
95 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { | 96 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { |
96 | if( (loc = line.find(":") ) == -1) { | 97 | if( (loc = line.find(":") ) == -1) { |
97 | continue; | 98 | continue; |
98 | } | 99 | } |
99 | 100 | ||
100 | if( I.Name != line.left(loc) ) | 101 | if( I.Name != line.left(loc) ) |
101 | continue; | 102 | continue; |
102 | 103 | ||
103 | // tokenize | 104 | // tokenize |
104 | SL = QStringList::split( ' ', line, FALSE ); | 105 | SL = QStringList::split( ' ', line, FALSE ); |
105 | 106 | ||
106 | // update data | 107 | // update data |
107 | switch( version ) { | 108 | switch( version ) { |
108 | case 1 : | 109 | case 1 : |
109 | I.RcvBytes = SL[1]; | 110 | I.RcvBytes = SL[1]; |
110 | I.RcvErrors = SL[3]; | 111 | I.RcvErrors = SL[3]; |
111 | I.RcvDropped = SL[4]; | 112 | I.RcvDropped = SL[4]; |
112 | I.SndBytes = SL[6]; | 113 | I.SndBytes = SL[6]; |
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 | |||
@@ -1,144 +1,187 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <qfileinfo.h> | 3 | #include <qfileinfo.h> |
4 | #include <qmessagebox.h> | 4 | #include <qmessagebox.h> |
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
7 | 7 | ||
8 | #include "resources.h" | 8 | #include "resources.h" |
9 | #include "systemfile.h" | 9 | #include "systemfile.h" |
10 | 10 | ||
11 | #define TEMPLATEDIR "networktemplates/" | 11 | #define TEMPLATEDIR "networktemplates/" |
12 | QString TemplDir; | 12 | QString TemplDir; |
13 | 13 | ||
14 | SystemFile::SystemFile( const QString & N, const QString & P ){ | 14 | SystemFile::SystemFile( const QString & N, const QString & P ){ |
15 | Name = N; | 15 | Name = N; |
16 | Path = P; | 16 | Path = 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 ) ) { |
67 | return 0; | 75 | return 0; |
68 | } | 76 | } |
69 | setDevice( F ); | 77 | setDevice( F ); |
70 | return 1; | 78 | return 1; |
71 | } | 79 | } |
72 | 80 | ||
73 | bool SystemFile::close( void ) { | 81 | bool SystemFile::close( void ) { |
74 | if( ! F ) { | 82 | if( ! F ) { |
75 | return 1 ; | 83 | return 1 ; |
76 | } | 84 | } |
77 | 85 | ||
78 | QString OldP = Path + "bup"; | 86 | QString OldP = Path + "bup"; |
79 | 87 | ||
80 | F->close(); | 88 | F->close(); |
81 | delete F; | 89 | delete F; |
82 | F = 0; | 90 | F = 0; |
83 | 91 | ||
84 | return ( rename( OldP.latin1(), Path.latin1() ) >= 0 ); | 92 | return ( rename( OldP.latin1(), Path.latin1() ) >= 0 ); |
85 | } | 93 | } |
86 | 94 | ||
87 | bool SystemFile::preSection( void ) { | 95 | bool SystemFile::preSection( void ) { |
88 | if( hasPreSection ) { | 96 | if( hasPreSection ) { |
89 | QFile Fl( TemplDir + Name + "/presection" ); | 97 | QFile Fl( TemplDir + Name + "/presection" ); |
90 | if( ! Fl.open( IO_ReadOnly ) ) | 98 | if( ! Fl.open( IO_ReadOnly ) ) |
91 | return 1; // error | 99 | return 1; // error |
92 | // copy file to this file | 100 | // copy file to this file |
93 | F->writeBlock( Fl.readAll() ); | 101 | F->writeBlock( Fl.readAll() ); |
94 | } | 102 | } |
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 | |||
@@ -1,39 +1,43 @@ | |||
1 | #ifndef __SYSTEMFILE__H | 1 | #ifndef __SYSTEMFILE__H |
2 | #define __SYSTEMFILE__H | 2 | #define __SYSTEMFILE__H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qtextstream.h> | 5 | #include <qtextstream.h> |
6 | 6 | ||
7 | class QFile; | 7 | class QFile; |
8 | class ANetNodeInstance; | 8 | class ANetNodeInstance; |
9 | 9 | ||
10 | class SystemFile : public QTextStream { | 10 | 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 | |||
@@ -127,277 +127,429 @@ QString NetworkSettingsData::saveSettings( void ) { | |||
127 | QFile F( CfgFile + ".bup" ); | 127 | QFile F( CfgFile + ".bup" ); |
128 | 128 | ||
129 | printf( "Saving settings to %s\n", CfgFile.latin1() ); | 129 | printf( "Saving settings to %s\n", CfgFile.latin1() ); |
130 | if( ! F.open( IO_WriteOnly | IO_Truncate ) ) { | 130 | if( ! F.open( IO_WriteOnly | IO_Truncate ) ) { |
131 | ErrS = qApp->translate( "NetworkSettings", | 131 | ErrS = qApp->translate( "NetworkSettings", |
132 | "<p>Could not save setup to %1 !</p>" ). | 132 | "<p>Could not save setup to %1 !</p>" ). |
133 | arg(CfgFile); | 133 | arg(CfgFile); |
134 | // problem | 134 | // problem |
135 | return ErrS; | 135 | return ErrS; |
136 | } | 136 | } |
137 | 137 | ||
138 | QTextStream TS( &F ); | 138 | QTextStream TS( &F ); |
139 | { Name2Connection_t & M = NSResources->connections(); | 139 | { Name2Connection_t & M = NSResources->connections(); |
140 | ANetNodeInstance * NNI; | 140 | ANetNodeInstance * NNI; |
141 | 141 | ||
142 | // for all connections | 142 | // for all connections |
143 | for( QDictIterator<NodeCollection> it(M); | 143 | for( QDictIterator<NodeCollection> it(M); |
144 | it.current(); | 144 | it.current(); |
145 | ++it ) { | 145 | ++it ) { |
146 | // all nodes in those connections | 146 | // all nodes in those connections |
147 | for( QListIterator<ANetNodeInstance> nit(*(it.current())); | 147 | for( QListIterator<ANetNodeInstance> nit(*(it.current())); |
148 | nit.current(); | 148 | nit.current(); |
149 | ++nit ) { | 149 | ++nit ) { |
150 | // header | 150 | // header |
151 | NNI = nit.current(); | 151 | NNI = nit.current(); |
152 | TS << '[' <<NNI->netNode()->nodeName() << ']' << endl; | 152 | TS << '[' <<NNI->netNode()->nodeName() << ']' << endl; |
153 | NNI->saveAttributes( TS ); | 153 | NNI->saveAttributes( TS ); |
154 | TS << endl; | 154 | TS << endl; |
155 | } | 155 | } |
156 | 156 | ||
157 | TS << "[connection]" << endl; | 157 | TS << "[connection]" << endl; |
158 | it.current()->save(TS); | 158 | it.current()->save(TS); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | QDir D("."); | 162 | QDir D("."); |
163 | D.rename( CfgFile + ".bup", CfgFile ); | 163 | D.rename( CfgFile + ".bup", CfgFile ); |
164 | 164 | ||
165 | // | 165 | // |
166 | // proper files AND system files regenerated | 166 | // proper files AND system files regenerated |
167 | // | 167 | // |
168 | 168 | ||
169 | setModified( 0 ); | 169 | setModified( 0 ); |
170 | return ErrS; | 170 | return ErrS; |
171 | } | 171 | } |
172 | 172 | ||
173 | QString NetworkSettingsData::generateSettings( bool ForceReq ) { | 173 | QString NetworkSettingsData::generateSettings( bool ForceReq ) { |
174 | bool ForceIt; | 174 | bool ForceIt; |
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); |
356 | it.current(); | 508 | it.current(); |
357 | ++it ) { | 509 | ++it ) { |
358 | NC = it.current(); | 510 | NC = it.current(); |
359 | // check if this profile handles the requested interface | 511 | // check if this profile handles the requested interface |
360 | if( NC->handlesInterface( Interface ) && // if different Intf. | 512 | if( NC->handlesInterface( Interface ) && // if different Intf. |
361 | NC->state() != Disabled && // if not enabled | 513 | NC->state() != Disabled && // if not enabled |
362 | NC->state() != IsUp // if already used | 514 | NC->state() != IsUp // if already used |
363 | ) { | 515 | ) { |
364 | PossibleConnections.append( NC ); | 516 | PossibleConnections.append( NC ); |
365 | } | 517 | } |
366 | } | 518 | } |
367 | return PossibleConnections; | 519 | return PossibleConnections; |
368 | } | 520 | } |
369 | 521 | ||
370 | 522 | ||
371 | /* | 523 | /* |
372 | Called by the system to see if interface can be brought UP | 524 | Called by the system to see if interface can be brought UP |
373 | 525 | ||
374 | if allowed, echo Interface-allowed else Interface-disallowed | 526 | if allowed, echo Interface-allowed else Interface-disallowed |
375 | */ | 527 | */ |
376 | 528 | ||
377 | void NetworkSettingsData::canStart( const char * Interface ) { | 529 | void NetworkSettingsData::canStart( const char * Interface ) { |
378 | // load situation | 530 | // load situation |
379 | NodeCollection * NC = 0; | 531 | NodeCollection * NC = 0; |
380 | QList<NodeCollection> PossibleConnections; | 532 | QList<NodeCollection> PossibleConnections; |
381 | 533 | ||
382 | PossibleConnections = collectPossible( Interface ); | 534 | PossibleConnections = collectPossible( Interface ); |
383 | 535 | ||
384 | switch( PossibleConnections.count() ) { | 536 | switch( PossibleConnections.count() ) { |
385 | case 0 : // no connections | 537 | case 0 : // no connections |
386 | break; | 538 | break; |
387 | case 1 : // one connection | 539 | case 1 : // one connection |
388 | NC = PossibleConnections.first(); | 540 | NC = PossibleConnections.first(); |
389 | break; | 541 | break; |
390 | default : // need to ask user ? | 542 | default : // need to ask user ? |
391 | // are we connected to a server | 543 | // are we connected to a server |
392 | // system( "su %d networksettings2 --prompt %s\n", | 544 | // system( "su %d networksettings2 --prompt %s\n", |
393 | // "", Interface ); | 545 | // "", Interface ); |
394 | break; | 546 | break; |
395 | } | 547 | } |
396 | 548 | ||
397 | if( NC ) { | 549 | if( NC ) { |
398 | switch( NC->state() ) { | 550 | switch( NC->state() ) { |
399 | case Unchecked : | 551 | case Unchecked : |
400 | case Unknown : | 552 | case Unknown : |
401 | case Unavailable : | 553 | case Unavailable : |
402 | case Disabled : | 554 | case Disabled : |
403 | // this profile does not allow interface to be UP | 555 | // this profile does not allow interface to be UP |
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 | |||
@@ -1,62 +1,69 @@ | |||
1 | #include "ppp_NN.h" | 1 | #include "ppp_NN.h" |
2 | #include "ppp_NNI.h" | 2 | #include "ppp_NNI.h" |
3 | 3 | ||
4 | static const char * PPPNeeds[] = | 4 | static const char * PPPNeeds[] = |
5 | { "line", | 5 | { "line", |
6 | "modem", | 6 | "modem", |
7 | 0 | 7 | 0 |
8 | }; | 8 | }; |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * Constructor, find all of the possible interfaces | 11 | * Constructor, find all of the possible interfaces |
12 | */ | 12 | */ |
13 | PPPNetNode::PPPNetNode() : ANetNode() { | 13 | PPPNetNode::PPPNetNode() : ANetNode() { |
14 | } | 14 | } |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * Delete any interfaces that we own. | 17 | * Delete any interfaces that we own. |
18 | */ | 18 | */ |
19 | PPPNetNode::~PPPNetNode(){ | 19 | PPPNetNode::~PPPNetNode(){ |
20 | } | 20 | } |
21 | 21 | ||
22 | const QString PPPNetNode::nodeDescription(){ | 22 | const QString PPPNetNode::nodeDescription(){ |
23 | return tr("\ | 23 | return tr("\ |
24 | <p>Sets up IP using PPP.</p>\ | 24 | <p>Sets up IP using PPP.</p>\ |
25 | <p>Use this for dialup devices or serial setups</p>\ | 25 | <p>Use this for dialup devices or serial setups</p>\ |
26 | " | 26 | " |
27 | ); | 27 | ); |
28 | } | 28 | } |
29 | 29 | ||
30 | ANetNodeInstance * PPPNetNode::createInstance( void ) { | 30 | 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 | |||
@@ -1,44 +1,46 @@ | |||
1 | #ifndef PPP_NETNODE_H | 1 | #ifndef PPP_NETNODE_H |
2 | #define PPP_NETNODE_H | 2 | #define PPP_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class APPP; | 6 | class APPP; |
7 | 7 | ||
8 | class PPPNetNode : public ANetNode{ | 8 | class PPPNetNode : public ANetNode{ |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | PPPNetNode(); | 14 | PPPNetNode(); |
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 | |||
@@ -1,90 +1,82 @@ | |||
1 | #include <resources.h> | 1 | #include <resources.h> |
2 | #include "ppprun.h" | 2 | #include "ppprun.h" |
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; |
44 | case Up : | 36 | case Up : |
45 | if( NC->currentState() != IsUp ) { | 37 | if( NC->currentState() != IsUp ) { |
46 | // start my PPPD | 38 | // start my PPPD |
47 | NC->setCurrentState( IsUp ); | 39 | NC->setCurrentState( IsUp ); |
48 | } | 40 | } |
49 | break; | 41 | break; |
50 | case Down : | 42 | case Down : |
51 | if( NC->currentState() == IsUp ) { | 43 | if( NC->currentState() == IsUp ) { |
52 | // stop my PPPD | 44 | // stop my PPPD |
53 | NC->setCurrentState( Available ); | 45 | NC->setCurrentState( Available ); |
54 | } | 46 | } |
55 | break; | 47 | break; |
56 | default : // FT | 48 | default : // FT |
57 | break; | 49 | break; |
58 | } | 50 | } |
59 | return 1; | 51 | return 1; |
60 | } | 52 | } |
61 | 53 | ||
62 | bool PPPRun::isMyPPPDRunning( void ) { | 54 | bool PPPRun::isMyPPPDRunning( void ) { |
63 | return 0; | 55 | return 0; |
64 | } | 56 | } |
65 | 57 | ||
66 | bool PPPRun::isMyPPPUp( void ) { | 58 | bool PPPRun::isMyPPPUp( void ) { |
67 | System & S = NSResources->system(); | 59 | System & S = NSResources->system(); |
68 | InterfaceInfo * Run; | 60 | InterfaceInfo * Run; |
69 | QRegExp R( "ppp[0-9]" ); | 61 | QRegExp R( "ppp[0-9]" ); |
70 | 62 | ||
71 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | 63 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); |
72 | It.current(); | 64 | It.current(); |
73 | ++It ) { | 65 | ++It ) { |
74 | Run = It.current(); | 66 | Run = It.current(); |
75 | if( R.match( Run->Name ) >= 0 && | 67 | if( R.match( Run->Name ) >= 0 && |
76 | Run->IsPointToPoint | 68 | Run->IsPointToPoint |
77 | ) { | 69 | ) { |
78 | // this is a LAN card | 70 | // this is a LAN card |
79 | if( Run->assignedNode() == AsDevice::netNode() ) { | 71 | if( Run->assignedNode() == AsDevice::netNode() ) { |
80 | // assigned to us | 72 | // assigned to us |
81 | return 1; | 73 | return 1; |
82 | } | 74 | } |
83 | } | 75 | } |
84 | } | 76 | } |
85 | return 0; | 77 | return 0; |
86 | } | 78 | } |
87 | 79 | ||
88 | bool PPPRun::handlesInterface( const QString & S ) { | 80 | bool PPPRun::handlesInterface( const QString & S ) { |
89 | return Pat.match( S ) >= 0; | 81 | return Pat.match( S ) >= 0; |
90 | } | 82 | } |
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 | |||
@@ -1,43 +1,49 @@ | |||
1 | #ifndef PPPRUN_H | 1 | #ifndef PPPRUN_H |
2 | #define PPPRUN_H | 2 | #define PPPRUN_H |
3 | 3 | ||
4 | #include <qregexp.h> | 4 | #include <qregexp.h> |
5 | #include <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 ); |
36 | bool isMyPPPUp( void ); | 42 | bool isMyPPPUp( void ); |
37 | 43 | ||
38 | PPPData_t * D; | 44 | PPPData_t * D; |
39 | QRegExp Pat; | 45 | QRegExp Pat; |
40 | 46 | ||
41 | }; | 47 | }; |
42 | 48 | ||
43 | #endif | 49 | #endif |
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 | |||
@@ -1,61 +1,68 @@ | |||
1 | #include "profile_NN.h" | 1 | #include "profile_NN.h" |
2 | #include "profile_NNI.h" | 2 | #include "profile_NNI.h" |
3 | 3 | ||
4 | static const char * ProfileNeeds[] = | 4 | static const char * ProfileNeeds[] = |
5 | { "connection", | 5 | { "connection", |
6 | 0 | 6 | 0 |
7 | }; | 7 | }; |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * Constructor, find all of the possible interfaces | 10 | * Constructor, find all of the possible interfaces |
11 | */ | 11 | */ |
12 | ProfileNetNode::ProfileNetNode() : ANetNode() { | 12 | ProfileNetNode::ProfileNetNode() : ANetNode() { |
13 | } | 13 | } |
14 | 14 | ||
15 | /** | 15 | /** |
16 | * Delete any interfaces that we own. | 16 | * Delete any interfaces that we own. |
17 | */ | 17 | */ |
18 | ProfileNetNode::~ProfileNetNode(){ | 18 | ProfileNetNode::~ProfileNetNode(){ |
19 | } | 19 | } |
20 | 20 | ||
21 | const QString ProfileNetNode::nodeDescription(){ | 21 | const QString ProfileNetNode::nodeDescription(){ |
22 | return tr("\ | 22 | return tr("\ |
23 | <p>Define use of an IP connection.</p>\ | 23 | <p>Define use of an IP connection.</p>\ |
24 | <p>Configure if and when this connection needs to be established</p>\ | 24 | <p>Configure if and when this connection needs to be established</p>\ |
25 | " | 25 | " |
26 | ); | 26 | ); |
27 | } | 27 | } |
28 | 28 | ||
29 | ANetNodeInstance * ProfileNetNode::createInstance( void ) { | 29 | 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 | |||
@@ -1,44 +1,46 @@ | |||
1 | #ifndef PROFILE_NETNODE_H | 1 | #ifndef PROFILE_NETNODE_H |
2 | #define PROFILE_NETNODE_H | 2 | #define PROFILE_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class AProfile; | 6 | class AProfile; |
7 | 7 | ||
8 | class ProfileNetNode : public ANetNode{ | 8 | class ProfileNetNode : public ANetNode{ |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | ProfileNetNode(); | 14 | ProfileNetNode(); |
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 | |||
@@ -1,67 +1,65 @@ | |||
1 | #include <resources.h> | 1 | #include <resources.h> |
2 | 2 | ||
3 | #include "profilerun.h" | 3 | #include "profilerun.h" |
4 | 4 | ||
5 | void ProfileRun::detectState( NodeCollection * NC ) { | 5 | 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 : |
57 | break; | 55 | break; |
58 | } | 56 | } |
59 | RI = netNode()->nextNode()->runtime(); | 57 | RI = netNode()->nextNode()->runtime(); |
60 | return ( Curr != Disabled ) ? | 58 | return ( Curr != Disabled ) ? |
61 | RI->canSetState(Curr, A) : 0; | 59 | RI->canSetState(Curr, A) : 0; |
62 | } | 60 | } |
63 | 61 | ||
64 | bool ProfileRun::handlesInterface( const QString & S ) { | 62 | bool ProfileRun::handlesInterface( const QString & S ) { |
65 | // donno -> pass deeper | 63 | // donno -> pass deeper |
66 | return netNode()->nextNode()->runtime()->handlesInterface(S); | 64 | return netNode()->nextNode()->runtime()->handlesInterface(S); |
67 | } | 65 | } |
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 | |||
@@ -1,28 +1,31 @@ | |||
1 | #ifndef PROFILERUN_H | 1 | #ifndef PROFILERUN_H |
2 | #define PROFILERUN_H | 2 | #define PROFILERUN_H |
3 | 3 | ||
4 | #include <asfullsetup.h> | 4 | #include <asfullsetup.h> |
5 | #include "profiledata.h" | 5 | #include "profiledata.h" |
6 | 6 | ||
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 | |||
@@ -1,60 +1,67 @@ | |||
1 | #include "usb_NN.h" | 1 | #include "usb_NN.h" |
2 | #include "usb_NNI.h" | 2 | #include "usb_NNI.h" |
3 | 3 | ||
4 | static const char * USBNeeds[] = | 4 | static const char * USBNeeds[] = |
5 | { 0 | 5 | { 0 |
6 | }; | 6 | }; |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * Constructor, find all of the possible interfaces | 9 | * Constructor, find all of the possible interfaces |
10 | */ | 10 | */ |
11 | USBNetNode::USBNetNode() : ANetNode() { | 11 | USBNetNode::USBNetNode() : ANetNode() { |
12 | } | 12 | } |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * Delete any interfaces that we own. | 15 | * Delete any interfaces that we own. |
16 | */ | 16 | */ |
17 | USBNetNode::~USBNetNode(){ | 17 | USBNetNode::~USBNetNode(){ |
18 | } | 18 | } |
19 | 19 | ||
20 | const QString USBNetNode::nodeDescription(){ | 20 | const QString USBNetNode::nodeDescription(){ |
21 | return tr("\ | 21 | return tr("\ |
22 | <p>Configure Ethernet over USB.</p>\ | 22 | <p>Configure Ethernet over USB.</p>\ |
23 | <p>Use this for a computer to computer USB cable connection</p>\ | 23 | <p>Use this for a computer to computer USB cable connection</p>\ |
24 | " | 24 | " |
25 | ); | 25 | ); |
26 | } | 26 | } |
27 | 27 | ||
28 | ANetNodeInstance * USBNetNode::createInstance( void ) { | 28 | 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 | |||
@@ -1,44 +1,46 @@ | |||
1 | #ifndef USB_NETNODE_H | 1 | #ifndef USB_NETNODE_H |
2 | #define USB_NETNODE_H | 2 | #define USB_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class AUSB; | 6 | class AUSB; |
7 | 7 | ||
8 | class USBNetNode : public ANetNode{ | 8 | class USBNetNode : public ANetNode{ |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | USBNetNode(); | 14 | USBNetNode(); |
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 | |||
@@ -1,46 +1,57 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include "usbedit.h" | 2 | #include "usbedit.h" |
3 | #include "usb_NNI.h" | 3 | #include "usb_NNI.h" |
4 | #include "usb_NN.h" | 4 | #include "usb_NN.h" |
5 | 5 | ||
6 | AUSB::AUSB( USBNetNode * PNN ) : ANetNodeInstance( PNN ) { | 6 | AUSB::AUSB( USBNetNode * PNN ) : ANetNodeInstance( PNN ) { |
7 | 7 | ||
8 | GUI = 0; | 8 | GUI = 0; |
9 | RT = 0; | 9 | RT = 0; |
10 | } | 10 | } |
11 | 11 | ||
12 | void AUSB::setSpecificAttribute( QString & , QString & ) { | 12 | void AUSB::setSpecificAttribute( QString & , QString & ) { |
13 | } | 13 | } |
14 | 14 | ||
15 | void AUSB::saveSpecificAttribute( QTextStream & ) { | 15 | void AUSB::saveSpecificAttribute( QTextStream & ) { |
16 | } | 16 | } |
17 | 17 | ||
18 | 18 | ||
19 | QWidget * AUSB::edit( QWidget * parent ) { | 19 | QWidget * AUSB::edit( QWidget * parent ) { |
20 | GUI = new USBEdit( parent ); | 20 | GUI = new USBEdit( parent ); |
21 | GUI->showData( Data ); | 21 | GUI->showData( Data ); |
22 | return GUI; | 22 | return GUI; |
23 | } | 23 | } |
24 | 24 | ||
25 | QString AUSB::acceptable( void ) { | 25 | QString AUSB::acceptable( void ) { |
26 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 26 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
27 | } | 27 | } |
28 | 28 | ||
29 | void AUSB::commit( void ) { | 29 | 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 | |||
@@ -1,44 +1,45 @@ | |||
1 | #ifndef USB_H | 1 | #ifndef USB_H |
2 | #define USB_H | 2 | #define USB_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "usbdata.h" | 5 | #include "usbdata.h" |
6 | #include "usbrun.h" | 6 | #include "usbrun.h" |
7 | 7 | ||
8 | class USBNetNode; | 8 | class USBNetNode; |
9 | class USBEdit; | 9 | class USBEdit; |
10 | 10 | ||
11 | class AUSB : public ANetNodeInstance { | 11 | class AUSB : public ANetNodeInstance { |
12 | 12 | ||
13 | public : | 13 | public : |
14 | 14 | ||
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 | |||
@@ -1,160 +1,171 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | #include <qfileinfo.h> | 2 | #include <qfileinfo.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <resources.h> | 4 | #include <resources.h> |
5 | #include "usbrun.h" | 5 | #include "usbrun.h" |
6 | 6 | ||
7 | void USBRun::detectState( NodeCollection * NC ) { | 7 | void USBRun::detectState( NodeCollection * NC ) { |
8 | // unavailable : no card found | 8 | // unavailable : no card found |
9 | // available : card found and assigned to us or free | 9 | // available : card found and assigned to us or free |
10 | // up : card found and assigned to us and up | 10 | // up : card found and assigned to us and up |
11 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); | 11 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); |
12 | System & Sys = NSResources->system(); | 12 | System & Sys = NSResources->system(); |
13 | InterfaceInfo * Run; | 13 | InterfaceInfo * Run; |
14 | QFile F( S ); | 14 | QFile F( S ); |
15 | 15 | ||
16 | if( F.open( IO_ReadOnly ) ) { | 16 | if( F.open( IO_ReadOnly ) ) { |
17 | // could open file -> read interface and assign | 17 | // could open file -> read interface and assign |
18 | QString X; | 18 | QString X; |
19 | QTextStream TS(&F); | 19 | QTextStream TS(&F); |
20 | X = TS.readLine(); | 20 | X = TS.readLine(); |
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 ) { |
113 | case Activate : | 124 | case Activate : |
114 | { // at least available | 125 | { // at least available |
115 | if( Curr == Available ) { | 126 | if( Curr == Available ) { |
116 | return 1; | 127 | return 1; |
117 | } | 128 | } |
118 | // or we can make one available | 129 | // or we can make one available |
119 | InterfaceInfo * N = getInterface(); | 130 | InterfaceInfo * N = getInterface(); |
120 | if( ! N || N->assignedNode() != 0 ) { | 131 | if( ! N || N->assignedNode() != 0 ) { |
121 | // non available or assigned | 132 | // non available or assigned |
122 | return 0; | 133 | return 0; |
123 | } | 134 | } |
124 | return 1; | 135 | return 1; |
125 | } | 136 | } |
126 | case Deactivate : | 137 | case Deactivate : |
127 | return ( Curr >= Available ); | 138 | return ( Curr >= Available ); |
128 | default : | 139 | default : |
129 | // FT | 140 | // FT |
130 | break; | 141 | break; |
131 | } | 142 | } |
132 | return 0; | 143 | return 0; |
133 | } | 144 | } |
134 | 145 | ||
135 | // get interface that is free or assigned to us | 146 | // get interface that is free or assigned to us |
136 | InterfaceInfo * USBRun::getInterface( void ) { | 147 | InterfaceInfo * USBRun::getInterface( void ) { |
137 | 148 | ||
138 | System & S = NSResources->system(); | 149 | System & S = NSResources->system(); |
139 | InterfaceInfo * best = 0, * Run; | 150 | InterfaceInfo * best = 0, * Run; |
140 | QRegExp R( "usb[0-9abcdef]" ); | 151 | QRegExp R( "usb[0-9abcdef]" ); |
141 | 152 | ||
142 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | 153 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); |
143 | It.current(); | 154 | It.current(); |
144 | ++It ) { | 155 | ++It ) { |
145 | Run = It.current(); | 156 | Run = It.current(); |
146 | if( handlesInterface( Run->Name ) && | 157 | if( handlesInterface( Run->Name ) && |
147 | Run->CardType == ARPHRD_ETHER | 158 | Run->CardType == ARPHRD_ETHER |
148 | ) { | 159 | ) { |
149 | // this is a USB card | 160 | // this is a USB card |
150 | if( Run->assignedNode() == netNode() ) { | 161 | if( Run->assignedNode() == netNode() ) { |
151 | // assigned to us | 162 | // assigned to us |
152 | return Run; | 163 | return Run; |
153 | } else if( Run->assignedNode() == 0 ) { | 164 | } else if( Run->assignedNode() == 0 ) { |
154 | // free | 165 | // free |
155 | best = Run; | 166 | best = Run; |
156 | } | 167 | } |
157 | } | 168 | } |
158 | } | 169 | } |
159 | return best; // can be 0 | 170 | return best; // can be 0 |
160 | } | 171 | } |
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 | |||
@@ -1,38 +1,41 @@ | |||
1 | #ifndef USBRUN_H | 1 | #ifndef USBRUN_H |
2 | #define USBRUN_H | 2 | #define USBRUN_H |
3 | 3 | ||
4 | #include <asdevice.h> | 4 | #include <asdevice.h> |
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 | |||
@@ -1,61 +1,68 @@ | |||
1 | #include "vpn_NN.h" | 1 | #include "vpn_NN.h" |
2 | #include "vpn_NNI.h" | 2 | #include "vpn_NNI.h" |
3 | 3 | ||
4 | static const char * VPNNeeds[] = | 4 | static const char * VPNNeeds[] = |
5 | { "connection", | 5 | { "connection", |
6 | 0 | 6 | 0 |
7 | }; | 7 | }; |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * Constructor, find all of the possible interfaces | 10 | * Constructor, find all of the possible interfaces |
11 | */ | 11 | */ |
12 | VPNNetNode::VPNNetNode() : ANetNode() { | 12 | VPNNetNode::VPNNetNode() : ANetNode() { |
13 | } | 13 | } |
14 | 14 | ||
15 | /** | 15 | /** |
16 | * Delete any interfaces that we own. | 16 | * Delete any interfaces that we own. |
17 | */ | 17 | */ |
18 | VPNNetNode::~VPNNetNode(){ | 18 | VPNNetNode::~VPNNetNode(){ |
19 | } | 19 | } |
20 | 20 | ||
21 | const QString VPNNetNode::nodeDescription(){ | 21 | const QString VPNNetNode::nodeDescription(){ |
22 | return tr("\ | 22 | return tr("\ |
23 | <p>Configure private IP connection.</p>\ | 23 | <p>Configure private IP connection.</p>\ |
24 | <p>Defines Secure tunnels over non secure IP sessions</p>\ | 24 | <p>Defines Secure tunnels over non secure IP sessions</p>\ |
25 | " | 25 | " |
26 | ); | 26 | ); |
27 | } | 27 | } |
28 | 28 | ||
29 | ANetNodeInstance * VPNNetNode::createInstance( void ) { | 29 | 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 | |||
@@ -1,44 +1,46 @@ | |||
1 | #ifndef VPN_NETNODE_H | 1 | #ifndef VPN_NETNODE_H |
2 | #define VPN_NETNODE_H | 2 | #define VPN_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class AVPN; | 6 | class AVPN; |
7 | 7 | ||
8 | class VPNNetNode : public ANetNode{ | 8 | class VPNNetNode : public ANetNode{ |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | VPNNetNode(); | 14 | VPNNetNode(); |
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 | |||
@@ -1,60 +1,67 @@ | |||
1 | #include "wlan_NN.h" | 1 | #include "wlan_NN.h" |
2 | #include "wlan_NNI.h" | 2 | #include "wlan_NNI.h" |
3 | 3 | ||
4 | static const char * WLanNeeds[] = | 4 | static const char * WLanNeeds[] = |
5 | { 0 | 5 | { 0 |
6 | }; | 6 | }; |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * Constructor, find all of the possible interfaces | 9 | * Constructor, find all of the possible interfaces |
10 | */ | 10 | */ |
11 | WLanNetNode::WLanNetNode() : ANetNode() { | 11 | WLanNetNode::WLanNetNode() : ANetNode() { |
12 | } | 12 | } |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * Delete any interfaces that we own. | 15 | * Delete any interfaces that we own. |
16 | */ | 16 | */ |
17 | WLanNetNode::~WLanNetNode(){ | 17 | WLanNetNode::~WLanNetNode(){ |
18 | } | 18 | } |
19 | 19 | ||
20 | const QString WLanNetNode::nodeDescription(){ | 20 | const QString WLanNetNode::nodeDescription(){ |
21 | return tr("\ | 21 | return tr("\ |
22 | <p>Configure Wi/Fi or WLan network cards.</p>\ | 22 | <p>Configure Wi/Fi or WLan network cards.</p>\ |
23 | <p>Defines Wireless options for those cards</p>\ | 23 | <p>Defines Wireless options for those cards</p>\ |
24 | " | 24 | " |
25 | ); | 25 | ); |
26 | } | 26 | } |
27 | 27 | ||
28 | ANetNodeInstance * WLanNetNode::createInstance( void ) { | 28 | 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 | |||
@@ -1,44 +1,46 @@ | |||
1 | #ifndef WLAN_NETNODE_H | 1 | #ifndef WLAN_NETNODE_H |
2 | #define WLAN_NETNODE_H | 2 | #define WLAN_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class AWLan; | 6 | class AWLan; |
7 | 7 | ||
8 | class WLanNetNode : public ANetNode{ | 8 | class WLanNetNode : public ANetNode{ |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | WLanNetNode(); | 14 | WLanNetNode(); |
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 | |||
@@ -1,30 +1,42 @@ | |||
1 | #include "wlanedit.h" | 1 | #include "wlanedit.h" |
2 | #include "wlan_NNI.h" | 2 | #include "wlan_NNI.h" |
3 | #include "wlan_NN.h" | 3 | #include "wlan_NN.h" |
4 | 4 | ||
5 | AWLan::AWLan( WLanNetNode * PNN ) : ANetNodeInstance( PNN ) { | 5 | AWLan::AWLan( WLanNetNode * PNN ) : ANetNodeInstance( PNN ) { |
6 | GUI = 0; | 6 | GUI = 0; |
7 | RT = 0; | 7 | RT = 0; |
8 | } | 8 | } |
9 | 9 | ||
10 | void AWLan::setSpecificAttribute( QString & , QString & ) { | 10 | void AWLan::setSpecificAttribute( QString & , QString & ) { |
11 | } | 11 | } |
12 | 12 | ||
13 | void AWLan::saveSpecificAttribute( QTextStream & ) { | 13 | void AWLan::saveSpecificAttribute( QTextStream & ) { |
14 | } | 14 | } |
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 | |||
@@ -1,43 +1,45 @@ | |||
1 | #ifndef WLAN_H | 1 | #ifndef WLAN_H |
2 | #define WLAN_H | 2 | #define WLAN_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "wlandata.h" | 5 | #include "wlandata.h" |
6 | #include "wlanrun.h" | 6 | #include "wlanrun.h" |
7 | 7 | ||
8 | class WLanNetNode; | 8 | class WLanNetNode; |
9 | class WLanEdit; | 9 | class WLanEdit; |
10 | 10 | ||
11 | class AWLan : public ANetNodeInstance { | 11 | class AWLan : public ANetNodeInstance { |
12 | 12 | ||
13 | public : | 13 | 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 | |||
@@ -1,42 +1,44 @@ | |||
1 | #ifndef WLANRUN_H | 1 | #ifndef WLANRUN_H |
2 | #define WLANRUN_H | 2 | #define WLANRUN_H |
3 | 3 | ||
4 | #include <qregexp.h> | 4 | #include <qregexp.h> |
5 | #include <asdevice.h> | 5 | #include <asdevice.h> |
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 | ||
39 | QRegExp Pat; | 41 | QRegExp Pat; |
40 | }; | 42 | }; |
41 | 43 | ||
42 | #endif | 44 | #endif |