60 files changed, 435 insertions, 505 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h index a21f574..bb3e7e7 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h | |||
@@ -1,43 +1,46 @@ | |||
1 | #ifndef BLUETOOTHBNEP_H | 1 | #ifndef BLUETOOTHBNEP_H |
2 | #define BLUETOOTHBNEP_H | 2 | #define BLUETOOTHBNEP_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "bluetoothBNEPdata.h" | 5 | #include "bluetoothBNEPdata.h" |
6 | #include "bluetoothBNEPrun.h" | 6 | #include "bluetoothBNEPrun.h" |
7 | 7 | ||
8 | class BluetoothBNEPNetNode; | 8 | class BluetoothBNEPNetNode; |
9 | class BluetoothBNEPEdit; | 9 | class BluetoothBNEPEdit; |
10 | 10 | ||
11 | class ABluetoothBNEP : public ANetNodeInstance { | 11 | class ABluetoothBNEP : public ANetNodeInstance { |
12 | 12 | ||
13 | public : | 13 | public : |
14 | 14 | ||
15 | ABluetoothBNEP( BluetoothBNEPNetNode * PNN ); | 15 | ABluetoothBNEP( BluetoothBNEPNetNode * 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 BluetoothBNEPRun( this, Data ); | 23 | RT = new BluetoothBNEPRun( 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 | virtual bool hasDataFor( const QString & S ); | ||
31 | virtual bool generateDataForCommonFile( SystemFile & SF, long ); | ||
32 | |||
30 | protected : | 33 | protected : |
31 | 34 | ||
32 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 35 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
33 | virtual void saveSpecificAttribute( QTextStream & TS ); | 36 | virtual void saveSpecificAttribute( QTextStream & TS ); |
34 | 37 | ||
35 | private : | 38 | private : |
36 | 39 | ||
37 | BluetoothBNEPEdit * GUI; | 40 | BluetoothBNEPEdit * GUI; |
38 | BluetoothBNEPData Data; | 41 | BluetoothBNEPData Data; |
39 | BluetoothBNEPRun * RT; | 42 | BluetoothBNEPRun * RT; |
40 | 43 | ||
41 | }; | 44 | }; |
42 | 45 | ||
43 | #endif | 46 | #endif |
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h index 347da0c..4a773cd 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h | |||
@@ -1,36 +1,31 @@ | |||
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 ) | ||
13 | { return 3; } | ||
14 | virtual QString genNic( long nr ) | ||
15 | { QString S; return S.sprintf( "bnep%ld", nr ); } | ||
16 | |||
17 | virtual AsDevice * asDevice( void ) | 12 | virtual AsDevice * asDevice( void ) |
18 | { return (AsDevice *)this; } | 13 | { return (AsDevice *)this; } |
19 | 14 | ||
20 | virtual AsDevice * device( void ) | 15 | virtual AsDevice * device( void ) |
21 | { return asDevice(); } | 16 | { return asDevice(); } |
22 | 17 | ||
23 | protected : | 18 | protected : |
24 | 19 | ||
25 | void detectState( NodeCollection * ) | 20 | void detectState( NodeCollection * ) |
26 | { } | 21 | { } |
27 | 22 | ||
28 | bool setState( NodeCollection * , Action_t ) | 23 | bool setState( NodeCollection * , Action_t ) |
29 | { return 0; } | 24 | { return 0; } |
30 | 25 | ||
31 | bool canSetState( State_t , Action_t ) | 26 | bool canSetState( State_t , Action_t ) |
32 | { return 0; } | 27 | { return 0; } |
33 | 28 | ||
34 | bool handlesInterface( const QString & ) | 29 | bool handlesInterface( const QString & ) |
35 | { return 0; } | 30 | { return 0; } |
36 | }; | 31 | }; |
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h index 57ff95e..97bd29c 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h | |||
@@ -1,42 +1,45 @@ | |||
1 | #ifndef BLUETOOTHRFCOMM_H | 1 | #ifndef BLUETOOTHRFCOMM_H |
2 | #define BLUETOOTHRFCOMM_H | 2 | #define BLUETOOTHRFCOMM_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "bluetoothRFCOMMdata.h" | 5 | #include "bluetoothRFCOMMdata.h" |
6 | #include "bluetoothRFCOMMrun.h" | 6 | #include "bluetoothRFCOMMrun.h" |
7 | 7 | ||
8 | class BluetoothRFCOMMNetNode; | 8 | class BluetoothRFCOMMNetNode; |
9 | class BluetoothRFCOMMEdit; | 9 | class BluetoothRFCOMMEdit; |
10 | 10 | ||
11 | class ABluetoothRFCOMM : public ANetNodeInstance { | 11 | class ABluetoothRFCOMM : public ANetNodeInstance { |
12 | 12 | ||
13 | public : | 13 | public : |
14 | 14 | ||
15 | ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN ); | 15 | ABluetoothRFCOMM( BluetoothRFCOMMNetNode * 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 BluetoothRFCOMMRun( this, Data ); | 23 | RT = new BluetoothRFCOMMRun( 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 | virtual bool hasDataFor( const QString & S ); | ||
31 | virtual bool generateDataForCommonFile( SystemFile & SF, long ); | ||
32 | |||
30 | protected : | 33 | protected : |
31 | 34 | ||
32 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 35 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
33 | virtual void saveSpecificAttribute( QTextStream & TS ); | 36 | virtual void saveSpecificAttribute( QTextStream & TS ); |
34 | 37 | ||
35 | private : | 38 | private : |
36 | 39 | ||
37 | BluetoothRFCOMMEdit * GUI; | 40 | BluetoothRFCOMMEdit * GUI; |
38 | BluetoothRFCOMMData Data; | 41 | BluetoothRFCOMMData Data; |
39 | BluetoothRFCOMMRun * RT; | 42 | BluetoothRFCOMMRun * RT; |
40 | }; | 43 | }; |
41 | 44 | ||
42 | #endif | 45 | #endif |
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp index 47272c4..3d1aa69 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp | |||
@@ -1,127 +1,123 @@ | |||
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 & S, bool DS ) { | 52 | bool BluetoothBNEPNetNode::hasDataFor( const QString & S ) { |
53 | return DS && S == "interfaces"; | 53 | return S == "interfaces"; |
54 | } | 54 | } |
55 | 55 | ||
56 | bool BluetoothBNEPNetNode::generateDataForCommonFile( | 56 | bool BluetoothBNEPNetNode::generateDeviceDataForCommonFile( |
57 | SystemFile & , | 57 | SystemFile & , |
58 | long , | 58 | long ) { |
59 | ANetNodeInstance * ) { | ||
60 | return 1; | 59 | return 1; |
61 | } | 60 | } |
62 | 61 | ||
63 | bool BluetoothBNEPNetNode::generateDeviceDataForCommonFile( | 62 | QString BluetoothBNEPNetNode::genNic( long nr ) { |
64 | SystemFile & , | 63 | QString S; |
65 | long , | 64 | return S.sprintf( "bnep%ld", nr ); |
66 | ANetNodeInstance * ) { | ||
67 | return 1; | ||
68 | } | 65 | } |
69 | 66 | ||
70 | // | 67 | // |
71 | // | 68 | // |
72 | // BLUETOOTH PAN/NAP node | 69 | // BLUETOOTH PAN/NAP node |
73 | // | 70 | // |
74 | // | 71 | // |
75 | 72 | ||
76 | static const char * BluetoothRFCOMMNeeds[] = | 73 | static const char * BluetoothRFCOMMNeeds[] = |
77 | { 0 | 74 | { 0 |
78 | }; | 75 | }; |
79 | 76 | ||
80 | BluetoothRFCOMMNetNode::BluetoothRFCOMMNetNode() : ANetNode() { | 77 | BluetoothRFCOMMNetNode::BluetoothRFCOMMNetNode() : ANetNode() { |
81 | } | 78 | } |
82 | 79 | ||
83 | BluetoothRFCOMMNetNode::~BluetoothRFCOMMNetNode(){ | 80 | BluetoothRFCOMMNetNode::~BluetoothRFCOMMNetNode(){ |
84 | } | 81 | } |
85 | 82 | ||
86 | const QString BluetoothRFCOMMNetNode::nodeDescription(){ | 83 | const QString BluetoothRFCOMMNetNode::nodeDescription(){ |
87 | return tr("\ | 84 | return tr("\ |
88 | <p>Sets up a bluetooth link using the bluetooth serial profile.</p>\ | 85 | <p>Sets up a bluetooth link using the bluetooth serial profile.</p>\ |
89 | <p>Use this to connect to a GSM.</p>\ | 86 | <p>Use this to connect to a GSM.</p>\ |
90 | " | 87 | " |
91 | ); | 88 | ); |
92 | } | 89 | } |
93 | 90 | ||
94 | ANetNodeInstance * BluetoothRFCOMMNetNode::createInstance( void ) { | 91 | ANetNodeInstance * BluetoothRFCOMMNetNode::createInstance( void ) { |
95 | return new ABluetoothRFCOMM( this ); | 92 | return new ABluetoothRFCOMM( this ); |
96 | } | 93 | } |
97 | 94 | ||
98 | const char ** BluetoothRFCOMMNetNode::needs( void ) { | 95 | const char ** BluetoothRFCOMMNetNode::needs( void ) { |
99 | return BluetoothRFCOMMNeeds; | 96 | return BluetoothRFCOMMNeeds; |
100 | } | 97 | } |
101 | 98 | ||
102 | const char * BluetoothRFCOMMNetNode::provides( void ) { | 99 | const char * BluetoothRFCOMMNetNode::provides( void ) { |
103 | return "line"; | 100 | return "line"; |
104 | } | 101 | } |
105 | 102 | ||
106 | bool BluetoothRFCOMMNetNode::generateProperFilesFor( | 103 | bool BluetoothRFCOMMNetNode::generateProperFilesFor( |
107 | ANetNodeInstance * ) { | 104 | ANetNodeInstance * ) { |
108 | return 0; | 105 | return 0; |
109 | } | 106 | } |
110 | 107 | ||
111 | bool BluetoothRFCOMMNetNode::hasDataFor( const QString &, bool ) { | 108 | bool BluetoothRFCOMMNetNode::hasDataFor( const QString & ) { |
112 | return 0; | 109 | return 0; |
113 | } | 110 | } |
114 | 111 | ||
115 | bool BluetoothRFCOMMNetNode::generateDataForCommonFile( | 112 | bool BluetoothRFCOMMNetNode::generateDeviceDataForCommonFile( |
116 | SystemFile & , | 113 | SystemFile & , |
117 | long, | 114 | long ) { |
118 | ANetNodeInstance * ) { | ||
119 | return 0; | 115 | return 0; |
120 | } | 116 | } |
121 | 117 | ||
122 | extern "C" { | 118 | extern "C" { |
123 | void create_plugin( QList<ANetNode> & PNN ) { | 119 | void create_plugin( QList<ANetNode> & PNN ) { |
124 | PNN.append( new BluetoothBNEPNetNode() ); | 120 | PNN.append( new BluetoothBNEPNetNode() ); |
125 | PNN.append( new BluetoothRFCOMMNetNode() ); | 121 | PNN.append( new BluetoothRFCOMMNetNode() ); |
126 | } | 122 | } |
127 | } | 123 | } |
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h index d72b0d4..5cd6c52 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h | |||
@@ -1,79 +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, bool DS ); | 31 | virtual bool hasDataFor( const QString & S ); |
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | ||
34 | virtual bool generateDeviceDataForCommonFile( | 32 | virtual bool generateDeviceDataForCommonFile( |
35 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | 33 | SystemFile & , long DevNr ); |
34 | |||
35 | virtual long instanceCount( void ) | ||
36 | { return 7; } | ||
37 | virtual QString genNic( long ); | ||
36 | 38 | ||
37 | private: | 39 | private: |
38 | 40 | ||
39 | }; | 41 | }; |
40 | 42 | ||
41 | class BluetoothRFCOMMNetNode : public ANetNode { | 43 | class BluetoothRFCOMMNetNode : public ANetNode { |
42 | 44 | ||
43 | Q_OBJECT | 45 | Q_OBJECT |
44 | 46 | ||
45 | public: | 47 | public: |
46 | 48 | ||
47 | BluetoothRFCOMMNetNode(); | 49 | BluetoothRFCOMMNetNode(); |
48 | virtual ~BluetoothRFCOMMNetNode(); | 50 | virtual ~BluetoothRFCOMMNetNode(); |
49 | 51 | ||
50 | virtual const QString pixmapName() | 52 | virtual const QString pixmapName() |
51 | { return "Devices/bluetooth"; } | 53 | { return "Devices/bluetooth"; } |
52 | 54 | ||
53 | virtual const QString nodeName() | 55 | virtual const QString nodeName() |
54 | { return tr("Bluetooth serial link"); } | 56 | { return tr("Bluetooth serial link"); } |
55 | 57 | ||
56 | virtual const QString nodeDescription() ; | 58 | virtual const QString nodeDescription() ; |
57 | 59 | ||
58 | virtual ANetNodeInstance * createInstance( void ); | 60 | virtual ANetNodeInstance * createInstance( void ); |
59 | 61 | ||
60 | virtual const char ** needs( void ); | 62 | virtual const char ** needs( void ); |
61 | virtual const char * provides( void ); | 63 | virtual const char * provides( void ); |
62 | 64 | ||
63 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | 65 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); |
64 | virtual bool hasDataFor( const QString & S, bool ); | 66 | virtual bool hasDataFor( const QString & S ); |
65 | virtual bool generateDataForCommonFile( | ||
66 | SystemFile & SF, long, ANetNodeInstance * NNI ); | ||
67 | virtual bool generateDeviceDataForCommonFile( | 67 | virtual bool generateDeviceDataForCommonFile( |
68 | SystemFile & SF, long, ANetNodeInstance * NNI ); | 68 | SystemFile & , long ); |
69 | 69 | ||
70 | private: | 70 | private: |
71 | 71 | ||
72 | }; | 72 | }; |
73 | 73 | ||
74 | extern "C" | 74 | extern "C" |
75 | { | 75 | { |
76 | void create_plugin( QList<ANetNode> & PNN ); | 76 | void create_plugin( QList<ANetNode> & PNN ); |
77 | }; | 77 | }; |
78 | 78 | ||
79 | #endif | 79 | #endif |
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp index 6f62772..a6be4d5 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.cpp +++ b/noncore/settings/networksettings2/cable/cable_NN.cpp | |||
@@ -1,66 +1,54 @@ | |||
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 &, bool ) { | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | bool CableNetNode::generateDataForCommonFile( | ||
49 | SystemFile & , | ||
50 | long , | ||
51 | ANetNodeInstance * ) { | ||
52 | return 1; | ||
53 | } | ||
54 | |||
55 | bool CableNetNode::generateDeviceDataForCommonFile( | 44 | bool CableNetNode::generateDeviceDataForCommonFile( |
56 | SystemFile & , | 45 | SystemFile & , |
57 | long , | 46 | long ) { |
58 | ANetNodeInstance * ) { | ||
59 | return 1; | 47 | return 1; |
60 | } | 48 | } |
61 | 49 | ||
62 | extern "C" { | 50 | extern "C" { |
63 | void create_plugin( QList<ANetNode> & PNN ) { | 51 | void create_plugin( QList<ANetNode> & PNN ) { |
64 | PNN.append( new CableNetNode() ); | 52 | PNN.append( new CableNetNode() ); |
65 | } | 53 | } |
66 | } | 54 | } |
diff --git a/noncore/settings/networksettings2/cable/cable_NN.h b/noncore/settings/networksettings2/cable/cable_NN.h index 3875af6..83b98e0 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.h +++ b/noncore/settings/networksettings2/cable/cable_NN.h | |||
@@ -1,46 +1,45 @@ | |||
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, bool DS ); | 31 | virtual bool hasDataFor( const QString & ) |
32 | virtual bool generateDataForCommonFile( | 32 | { return 0; } |
33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | ||
34 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
35 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | 34 | SystemFile & SF, long DevNr); |
36 | 35 | ||
37 | private: | 36 | private: |
38 | 37 | ||
39 | }; | 38 | }; |
40 | 39 | ||
41 | extern "C" | 40 | extern "C" |
42 | { | 41 | { |
43 | void create_plugin( QList<ANetNode> & PNN ); | 42 | void create_plugin( QList<ANetNode> & PNN ); |
44 | }; | 43 | }; |
45 | 44 | ||
46 | #endif | 45 | #endif |
diff --git a/noncore/settings/networksettings2/cable/cable_NNI.cpp b/noncore/settings/networksettings2/cable/cable_NNI.cpp index d26afd1..ca21135 100644 --- a/noncore/settings/networksettings2/cable/cable_NNI.cpp +++ b/noncore/settings/networksettings2/cable/cable_NNI.cpp | |||
@@ -3,64 +3,71 @@ | |||
3 | #include "cable_NN.h" | 3 | #include "cable_NN.h" |
4 | 4 | ||
5 | ACable::ACable( CableNetNode * PNN ) : ANetNodeInstance( PNN ) { | 5 | ACable::ACable( CableNetNode * PNN ) : ANetNodeInstance( PNN ) { |
6 | // default values | 6 | // default values |
7 | Data.Device = "/dev/ttyS0"; | 7 | Data.Device = "/dev/ttyS0"; |
8 | Data.LockFile = "/var/Lock"; | 8 | Data.LockFile = "/var/Lock"; |
9 | Data.Speed = 115200; | 9 | Data.Speed = 115200; |
10 | Data.DataBits = 8; | 10 | Data.DataBits = 8; |
11 | Data.Parity = 0; | 11 | Data.Parity = 0; |
12 | Data.StopBits = 1; | 12 | Data.StopBits = 1; |
13 | Data.HardwareControl = 0; | 13 | Data.HardwareControl = 0; |
14 | Data.SoftwareControl = 0; | 14 | Data.SoftwareControl = 0; |
15 | GUI = 0; | 15 | GUI = 0; |
16 | RT = 0; | 16 | RT = 0; |
17 | } | 17 | } |
18 | 18 | ||
19 | void ACable::setSpecificAttribute( QString & A, QString & V) { | 19 | void ACable::setSpecificAttribute( QString & A, QString & V) { |
20 | if( A == "device" ) { | 20 | if( A == "device" ) { |
21 | Data.Device = V; | 21 | Data.Device = V; |
22 | } else if ( A == "lockfile" ) { | 22 | } else if ( A == "lockfile" ) { |
23 | Data.LockFile = V; | 23 | Data.LockFile = V; |
24 | } else if ( A == "speed" ) { | 24 | } else if ( A == "speed" ) { |
25 | Data.Speed = V.toLong(); | 25 | Data.Speed = V.toLong(); |
26 | } else if ( A == "parity" ) { | 26 | } else if ( A == "parity" ) { |
27 | Data.Parity = V.toShort(); | 27 | Data.Parity = V.toShort(); |
28 | } else if ( A == "databits" ) { | 28 | } else if ( A == "databits" ) { |
29 | Data.DataBits = V.toShort(); | 29 | Data.DataBits = V.toShort(); |
30 | } else if ( A == "stopbits" ) { | 30 | } else if ( A == "stopbits" ) { |
31 | Data.StopBits = V.toShort(); | 31 | Data.StopBits = V.toShort(); |
32 | } else if ( A == "hardwarecontrol" ) { | 32 | } else if ( A == "hardwarecontrol" ) { |
33 | Data.HardwareControl = ( V == "yes" ); | 33 | Data.HardwareControl = ( V == "yes" ); |
34 | } else if ( A == "softwarecontrol" ) { | 34 | } else if ( A == "softwarecontrol" ) { |
35 | Data.SoftwareControl = ( V == "yes" ); | 35 | Data.SoftwareControl = ( V == "yes" ); |
36 | } | 36 | } |
37 | } | 37 | } |
38 | 38 | ||
39 | void ACable::saveSpecificAttribute( QTextStream & TS ) { | 39 | void ACable::saveSpecificAttribute( QTextStream & TS ) { |
40 | TS << "device=" << quote( Data.Device ) << endl; | 40 | TS << "device=" << quote( Data.Device ) << endl; |
41 | TS << "lockfile=" << quote( Data.LockFile ) << endl; | 41 | TS << "lockfile=" << quote( Data.LockFile ) << endl; |
42 | TS << "speed=" << Data.Speed << endl; | 42 | TS << "speed=" << Data.Speed << endl; |
43 | TS << "parity=" << Data.Parity << endl; | 43 | TS << "parity=" << Data.Parity << endl; |
44 | TS << "databits=" << Data.DataBits << endl; | 44 | TS << "databits=" << Data.DataBits << endl; |
45 | TS << "stopbits=" << Data.StopBits << endl; | 45 | TS << "stopbits=" << Data.StopBits << endl; |
46 | TS << "hardwarecontrol=" << | 46 | TS << "hardwarecontrol=" << |
47 | ((Data.HardwareControl) ? "yes" : "no") << endl; | 47 | ((Data.HardwareControl) ? "yes" : "no") << endl; |
48 | TS << "softwarecontrol=" << | 48 | TS << "softwarecontrol=" << |
49 | ((Data.SoftwareControl) ? "yes" : "no") << endl; | 49 | ((Data.SoftwareControl) ? "yes" : "no") << endl; |
50 | } | 50 | } |
51 | 51 | ||
52 | QWidget * ACable::edit( QWidget * parent ) { | 52 | QWidget * ACable::edit( QWidget * parent ) { |
53 | GUI = new CableEdit( parent ); | 53 | GUI = new CableEdit( parent ); |
54 | GUI->showData( Data ); | 54 | GUI->showData( Data ); |
55 | return GUI; | 55 | return GUI; |
56 | } | 56 | } |
57 | 57 | ||
58 | QString ACable::acceptable( void ) { | 58 | QString ACable::acceptable( void ) { |
59 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 59 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
60 | } | 60 | } |
61 | 61 | ||
62 | void ACable::commit( void ) { | 62 | void ACable::commit( void ) { |
63 | if( GUI && GUI->commit( Data ) ) { | 63 | if( GUI && GUI->commit( Data ) ) { |
64 | setModified( 1 ); | 64 | setModified( 1 ); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | |||
68 | bool ACable::generateDataForCommonFile( | ||
69 | SystemFile & , | ||
70 | long ) { | ||
71 | return 1; | ||
72 | } | ||
73 | |||
diff --git a/noncore/settings/networksettings2/cable/cable_NNI.h b/noncore/settings/networksettings2/cable/cable_NNI.h index 0654a5d..bf3e292 100644 --- a/noncore/settings/networksettings2/cable/cable_NNI.h +++ b/noncore/settings/networksettings2/cable/cable_NNI.h | |||
@@ -1,43 +1,48 @@ | |||
1 | #ifndef CABLE_H | 1 | #ifndef CABLE_H |
2 | #define CABLE_H | 2 | #define CABLE_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "cabledata.h" | 5 | #include "cabledata.h" |
6 | #include "cablerun.h" | 6 | #include "cablerun.h" |
7 | 7 | ||
8 | class CableNetNode; | 8 | class CableNetNode; |
9 | class CableEdit; | 9 | class CableEdit; |
10 | 10 | ||
11 | class ACable : public ANetNodeInstance { | 11 | class ACable : public ANetNodeInstance { |
12 | 12 | ||
13 | public : | 13 | public : |
14 | 14 | ||
15 | ACable( CableNetNode * PNN ); | 15 | ACable( CableNetNode * 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 CableRun( this, Data ); | 23 | RT = new CableRun( 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 | virtual bool hasDataFor( const QString & ) | ||
31 | { return 0; } | ||
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & SF, long DevNr ); | ||
34 | |||
30 | protected : | 35 | protected : |
31 | 36 | ||
32 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 37 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
33 | virtual void saveSpecificAttribute( QTextStream & TS ); | 38 | virtual void saveSpecificAttribute( QTextStream & TS ); |
34 | 39 | ||
35 | private : | 40 | private : |
36 | 41 | ||
37 | CableEdit * GUI; | 42 | CableEdit * GUI; |
38 | CableData_t Data; | 43 | CableData_t Data; |
39 | CableRun * RT; | 44 | CableRun * RT; |
40 | 45 | ||
41 | }; | 46 | }; |
42 | 47 | ||
43 | #endif | 48 | #endif |
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp index ce13573..4bbe502 100644 --- a/noncore/settings/networksettings2/editconnection.cpp +++ b/noncore/settings/networksettings2/editconnection.cpp | |||
@@ -43,271 +43,266 @@ void MyQCheckListItem::paintCell( QPainter *p, const QColorGroup &cg, | |||
43 | QColor c = _cg.text(); | 43 | QColor c = _cg.text(); |
44 | if ( ! isSelectable() ) | 44 | if ( ! isSelectable() ) |
45 | _cg.setColor( QColorGroup::Text, Qt::lightGray ); | 45 | _cg.setColor( QColorGroup::Text, Qt::lightGray ); |
46 | QCheckListItem::paintCell( p, _cg, column, width, alignment ); | 46 | QCheckListItem::paintCell( p, _cg, column, width, alignment ); |
47 | _cg.setColor( QColorGroup::Text, c ); | 47 | _cg.setColor( QColorGroup::Text, c ); |
48 | } | 48 | } |
49 | 49 | ||
50 | class MyQListViewItem : public QListViewItem | 50 | class MyQListViewItem : public QListViewItem |
51 | { | 51 | { |
52 | public: | 52 | public: |
53 | MyQListViewItem( QListView *parent, const QString & S ) : | 53 | MyQListViewItem( QListView *parent, const QString & S ) : |
54 | QListViewItem( parent, S ) { } | 54 | QListViewItem( parent, S ) { } |
55 | MyQListViewItem( QListViewItem *parent, const QString & S ) : | 55 | MyQListViewItem( QListViewItem *parent, const QString & S ) : |
56 | QListViewItem( parent, S ) { } | 56 | QListViewItem( parent, S ) { } |
57 | 57 | ||
58 | virtual void paintCell( QPainter *p, const QColorGroup &cg, | 58 | virtual void paintCell( QPainter *p, const QColorGroup &cg, |
59 | int column, int width, int alignment ); | 59 | int column, int width, int alignment ); |
60 | 60 | ||
61 | }; | 61 | }; |
62 | 62 | ||
63 | void MyQListViewItem::paintCell( QPainter *p, const QColorGroup &cg, | 63 | void MyQListViewItem::paintCell( QPainter *p, const QColorGroup &cg, |
64 | int column, int width, int alignment ) | 64 | int column, int width, int alignment ) |
65 | { | 65 | { |
66 | QColorGroup _cg( cg ); | 66 | QColorGroup _cg( cg ); |
67 | QColor c = _cg.text(); | 67 | QColor c = _cg.text(); |
68 | if ( ! isSelectable() ) | 68 | if ( ! isSelectable() ) |
69 | _cg.setColor( QColorGroup::Text, Qt::lightGray ); | 69 | _cg.setColor( QColorGroup::Text, Qt::lightGray ); |
70 | QListViewItem::paintCell( p, _cg, column, width, alignment ); | 70 | QListViewItem::paintCell( p, _cg, column, width, alignment ); |
71 | _cg.setColor( QColorGroup::Text, c ); | 71 | _cg.setColor( QColorGroup::Text, c ); |
72 | } | 72 | } |
73 | 73 | ||
74 | // | 74 | // |
75 | // | 75 | // |
76 | // REAL GUI | 76 | // REAL GUI |
77 | // | 77 | // |
78 | // | 78 | // |
79 | 79 | ||
80 | bool EditConnection::AutoCollapse = 1; | 80 | bool EditConnection::AutoCollapse = 1; |
81 | 81 | ||
82 | EditConnection::EditConnection( QWidget* parent ) : | 82 | EditConnection::EditConnection( QWidget* parent ) : |
83 | EditConnectionGUI( parent, 0, TRUE ), TmpCollection() { | 83 | EditConnectionGUI( parent, 0, TRUE ), TmpCollection() { |
84 | 84 | ||
85 | Tab_TB->setTabEnabled( Setup_FRM, FALSE ); | 85 | Tab_TB->setTabEnabled( Setup_FRM, FALSE ); |
86 | Setup_FRM->setEnabled( FALSE ); | 86 | Setup_FRM->setEnabled( FALSE ); |
87 | 87 | ||
88 | TmpIsValid = 0; | 88 | TmpIsValid = 0; |
89 | SelectedNodes = 0; | 89 | SelectedNodes = 0; |
90 | 90 | ||
91 | AutoCollapse_CB->setChecked( AutoCollapse ); | 91 | AutoCollapse_CB->setChecked( AutoCollapse ); |
92 | 92 | ||
93 | Mapping = new QPtrDict<ANetNode>; | 93 | Mapping = new QPtrDict<ANetNode>; |
94 | Mapping->setAutoDelete( FALSE ); | 94 | Mapping->setAutoDelete( FALSE ); |
95 | Nodes_LV->header()->hide(); | 95 | Nodes_LV->header()->hide(); |
96 | // popluate tree with all NetNodes | 96 | // popluate tree with all NetNodes |
97 | buildFullTree(); | 97 | buildFullTree(); |
98 | } | 98 | } |
99 | 99 | ||
100 | NodeCollection * EditConnection::getTmpCollection( void ) { | 100 | NodeCollection * EditConnection::getTmpCollection( void ) { |
101 | 101 | ||
102 | if( TmpIsValid ) | 102 | if( TmpIsValid ) |
103 | // content is stil OK | 103 | // content is stil OK |
104 | return &(TmpCollection); | 104 | return &(TmpCollection); |
105 | 105 | ||
106 | // reset collection -> delete all NEW NetNodes | 106 | // reset collection -> delete all NEW NetNodes |
107 | { ANetNodeInstance * NNI; | 107 | for( QListIterator<ANetNodeInstance> it(TmpCollection); |
108 | for( QListIterator<ANetNodeInstance> it(TmpCollection); | 108 | it.current(); |
109 | it.current(); | 109 | ++it ) { |
110 | ++it ) { | 110 | if( it.current()->isNew() ) { |
111 | if( it.current()->isNew() ) { | 111 | delete it.current(); |
112 | delete it.current(); | ||
113 | } | ||
114 | } | 112 | } |
115 | TmpCollection.clear(); | ||
116 | } | 113 | } |
114 | TmpCollection.clear(); | ||
117 | 115 | ||
118 | // update content | 116 | // update content |
119 | QListViewItem * it = Nodes_LV->firstChild(); | 117 | QListViewItem * it = Nodes_LV->firstChild(); |
120 | ANetNode * NN; | 118 | ANetNode * NN; |
121 | // start iter | 119 | // start iter |
122 | ANetNodeInstance * NNI = | 120 | ANetNodeInstance * NNI = |
123 | (SelectedNodes) ? SelectedNodes->first() : 0 ; | 121 | (SelectedNodes) ? SelectedNodes->first() : 0 ; |
124 | 122 | ||
125 | TmpCollection.setModified( 0 ); | 123 | TmpCollection.setModified( 0 ); |
126 | 124 | ||
127 | while ( it ) { | 125 | while ( it ) { |
128 | NN = (*Mapping)[it]; | 126 | NN = (*Mapping)[it]; |
129 | if( NN == 0 ) { | 127 | if( NN == 0 ) { |
130 | // child is controller -> has sub radio | 128 | // child is controller -> has sub radio |
131 | // check if one radio is selected | 129 | // check if one radio is selected |
132 | it = it->firstChild(); | 130 | it = it->firstChild(); |
133 | while( it ) { | 131 | while( it ) { |
134 | if( ((QCheckListItem *)it)->isOn() ) { | 132 | if( ((QCheckListItem *)it)->isOn() ) { |
135 | // this radio is selected -> go deeper | 133 | // this radio is selected -> go deeper |
136 | if( SelectedNodes == 0 || | 134 | if( SelectedNodes == 0 || |
137 | NNI == 0 || | 135 | NNI == 0 || |
138 | NNI->netNode()->nodeName() != it->text(0) ) { | 136 | NNI->nodeClass()->nodeName() != it->text(0) ) { |
139 | // new item not in previous collection | 137 | // new item not in previous collection |
140 | ANetNodeInstance * NNI = (*Mapping)[it]->createInstance(); | 138 | ANetNodeInstance * NNI = (*Mapping)[it]->createInstance(); |
141 | NNI->initialize(); | 139 | NNI->initialize(); |
142 | // this node type not in collection | 140 | // this node type not in collection |
143 | TmpCollection.append( NNI ); | 141 | TmpCollection.append( NNI ); |
144 | // master collection changed because new item in it | 142 | // master collection changed because new item in it |
145 | TmpCollection.setModified( 1 ); | 143 | TmpCollection.setModified( 1 ); |
146 | // no more valid items in old list | 144 | // no more valid items in old list |
147 | NNI = 0; | 145 | NNI = 0; |
148 | } else { | 146 | } else { |
149 | // already in list -> copy pointer | 147 | // already in list -> copy pointer |
150 | TmpCollection.append( NNI ); | 148 | TmpCollection.append( NNI ); |
151 | NNI = SelectedNodes->next(); | 149 | NNI = SelectedNodes->next(); |
152 | } | 150 | } |
153 | it = it->firstChild(); | 151 | it = it->firstChild(); |
154 | // do not bother to check other items | 152 | // do not bother to check other items |
155 | break; | 153 | break; |
156 | } | 154 | } |
157 | it = it->nextSibling(); | 155 | it = it->nextSibling(); |
158 | } | 156 | } |
159 | } else { | 157 | } else { |
160 | // check children | 158 | // check children |
161 | it = it->firstChild(); | 159 | it = it->firstChild(); |
162 | } | 160 | } |
163 | } | 161 | } |
164 | 162 | ||
165 | TmpIsValid = 1; | 163 | TmpIsValid = 1; |
166 | return &(TmpCollection); | 164 | return &(TmpCollection); |
167 | } | 165 | } |
168 | 166 | ||
169 | // pass a connection NodeCollection to be edited | 167 | // pass a connection NodeCollection to be edited |
170 | void EditConnection::setConnection( NodeCollection * NC ) { | 168 | void EditConnection::setConnection( NodeCollection * NC ) { |
171 | ANetNodeInstance * NNI; | 169 | ANetNodeInstance * NNI; |
172 | ANetNode * NN; | 170 | ANetNode * NN; |
173 | 171 | ||
174 | SelectedNodes = NC; | 172 | SelectedNodes = NC; |
175 | Name_LE->setText( NC->name() ); | 173 | Name_LE->setText( NC->name() ); |
176 | NNI = NC->first(); | 174 | NNI = NC->first(); |
177 | 175 | ||
178 | // show configure tabl | 176 | // show configure tabl |
179 | Tab_TB->setCurrentPage( 1 ); | 177 | Tab_TB->setCurrentPage( 1 ); |
180 | 178 | ||
181 | // valid colledction | 179 | // valid colledction |
182 | Tab_TB->setTabEnabled( Setup_FRM, FALSE ); | 180 | Tab_TB->setTabEnabled( Setup_FRM, FALSE ); |
183 | Setup_FRM->setEnabled( FALSE ); | 181 | Setup_FRM->setEnabled( FALSE ); |
184 | 182 | ||
185 | // select items in collection | 183 | // select items in collection |
186 | QListViewItem * it = Nodes_LV->firstChild(); | 184 | QListViewItem * it = Nodes_LV->firstChild(); |
187 | bool Found; | 185 | bool Found; |
188 | 186 | ||
189 | TmpIsValid = 0; | 187 | TmpIsValid = 0; |
190 | 188 | ||
191 | while ( it ) { | 189 | while ( it ) { |
192 | // listitem corresponds to netnode | 190 | // listitem corresponds to netnode |
193 | NN = (*Mapping)[it]; | 191 | NN = (*Mapping)[it]; |
194 | if( NN == 0 ) { | 192 | if( NN == 0 ) { |
195 | // child is controller -> has sub radio | 193 | // child is controller -> has sub radio |
196 | QString Ctr = it->text(0); | 194 | QString Ctr = it->text(0); |
197 | // check if one radio is selected | 195 | // check if one radio is selected |
198 | it = it->firstChild(); | 196 | it = it->firstChild(); |
199 | Found = 0; | 197 | Found = 0; |
200 | while( it ) { | 198 | while( it ) { |
201 | if( NNI && NNI->netNode()->nodeName() == it->text(0) ) { | 199 | if( NNI && NNI->nodeClass()->nodeName() == it->text(0) ) { |
202 | // this radio is part of the collection | 200 | // this radio is part of the collection |
203 | ((QCheckListItem *)it)->setOn( 1 ); | 201 | ((QCheckListItem *)it)->setOn( 1 ); |
204 | updateGUI( it, NNI->netNode() ); | 202 | updateGUI( it, NNI->nodeClass() ); |
205 | // check its children | 203 | // check its children |
206 | Found = 1; | 204 | Found = 1; |
207 | it = it->firstChild(); | 205 | it = it->firstChild(); |
208 | NNI = SelectedNodes->next(); | 206 | NNI = SelectedNodes->next(); |
209 | // do not bother to check other items | 207 | // do not bother to check other items |
210 | break; | 208 | break; |
211 | } | 209 | } |
212 | it = it->nextSibling(); | 210 | it = it->nextSibling(); |
213 | } | 211 | } |
214 | if( ! Found ) { | 212 | if( ! Found ) { |
215 | // this means that this level is NOT present in collection | 213 | // this means that this level is NOT present in collection |
216 | // probably INCOMPATIBEL collection OR Missing plugin | 214 | // probably INCOMPATIBEL collection OR Missing plugin |
217 | QMessageBox::warning( | 215 | QMessageBox::warning( |
218 | 0, | 216 | 0, |
219 | tr( "Error presentig Connection" ), | 217 | tr( "Error presentig Connection" ), |
220 | tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). | 218 | tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). |
221 | arg(Ctr) ); | 219 | arg(Ctr) ); |
222 | return; | 220 | return; |
223 | } | 221 | } |
224 | } else { | 222 | } else { |
225 | // automatic item -> check children | 223 | // automatic item -> check children |
226 | it = it->firstChild(); | 224 | it = it->firstChild(); |
227 | } | 225 | } |
228 | } | 226 | } |
229 | } | 227 | } |
230 | 228 | ||
231 | // get result of editing (either new OR updated collection | 229 | // get result of editing (either new OR updated collection |
232 | NodeCollection * EditConnection::connection( void ) { | 230 | NodeCollection * EditConnection::connection( void ) { |
233 | 231 | ||
234 | if( SelectedNodes == 0 ) { | 232 | if( SelectedNodes == 0 ) { |
235 | // new collection | 233 | // new collection |
236 | SelectedNodes = new NodeCollection; | 234 | SelectedNodes = new NodeCollection; |
237 | } | 235 | } |
238 | 236 | ||
239 | // clean out old entries | 237 | // clean out old entries |
240 | SelectedNodes->clear(); | 238 | SelectedNodes->clear(); |
241 | 239 | ||
242 | // transfer | 240 | // transfer |
243 | { ANetNodeInstance * NNI; | 241 | for( QListIterator<ANetNodeInstance> it(TmpCollection); |
244 | 242 | it.current(); | |
245 | for( QListIterator<ANetNodeInstance> it(TmpCollection); | 243 | ++it ) { |
246 | it.current(); | 244 | SelectedNodes->append( it.current() ); |
247 | ++it ) { | ||
248 | SelectedNodes->append( it.current() ); | ||
249 | } | ||
250 | } | 245 | } |
251 | 246 | ||
252 | if( TmpCollection.isModified() ) | 247 | if( TmpCollection.isModified() ) |
253 | SelectedNodes->setModified( 1 ); | 248 | SelectedNodes->setModified( 1 ); |
254 | 249 | ||
255 | if( SelectedNodes->name() != Name_LE->text() ) { | 250 | if( SelectedNodes->name() != Name_LE->text() ) { |
256 | SelectedNodes->setName( Name_LE->text() ); | 251 | SelectedNodes->setName( Name_LE->text() ); |
257 | SelectedNodes->setModified( 1 ); | 252 | SelectedNodes->setModified( 1 ); |
258 | } | 253 | } |
259 | 254 | ||
260 | return SelectedNodes; | 255 | return SelectedNodes; |
261 | } | 256 | } |
262 | 257 | ||
263 | // Build device tree -> start | 258 | // Build device tree -> start |
264 | void EditConnection::buildFullTree( void ) { | 259 | void EditConnection::buildFullTree( void ) { |
265 | ANetNode * NN; | 260 | ANetNode * NN; |
266 | 261 | ||
267 | // toplevel item | 262 | // toplevel item |
268 | MyQCheckListItem * TheTop = new MyQCheckListItem( | 263 | MyQCheckListItem * TheTop = new MyQCheckListItem( |
269 | Nodes_LV, | 264 | Nodes_LV, |
270 | NSResources->netNode2Name("fullsetup"), | 265 | NSResources->netNode2Name("fullsetup"), |
271 | QCheckListItem::Controller ); | 266 | QCheckListItem::Controller ); |
272 | TheTop->setOpen( TRUE ); | 267 | TheTop->setOpen( TRUE ); |
273 | Description_LBL->setText( | 268 | Description_LBL->setText( |
274 | NSResources->netNode2Description( "fullsetup" ) ); | 269 | NSResources->netNode2Description( "fullsetup" ) ); |
275 | Nodes_LV->setSelected( TheTop, TRUE ); | 270 | Nodes_LV->setSelected( TheTop, TRUE ); |
276 | 271 | ||
277 | // find all Nodes that care toplevel nodes -> ie provide | 272 | // find all Nodes that care toplevel nodes -> ie provide |
278 | // TCP/IP Connection | 273 | // TCP/IP Connection |
279 | for( QDictIterator<NetNode_t> Iter(NSResources->netNodes()); | 274 | for( QDictIterator<NetNode_t> Iter(NSResources->netNodes()); |
280 | Iter.current(); | 275 | Iter.current(); |
281 | ++Iter ) { | 276 | ++Iter ) { |
282 | 277 | ||
283 | NN = Iter.current()->NetNode; | 278 | NN = Iter.current()->NetNode; |
284 | 279 | ||
285 | if( ! NN->isToplevel() ) { | 280 | if( ! NN->isToplevel() ) { |
286 | continue; | 281 | continue; |
287 | } | 282 | } |
288 | 283 | ||
289 | MyQCheckListItem * it = new MyQCheckListItem( TheTop, | 284 | MyQCheckListItem * it = new MyQCheckListItem( TheTop, |
290 | NN->nodeName(), | 285 | NN->nodeName(), |
291 | QCheckListItem::RadioButton ); | 286 | QCheckListItem::RadioButton ); |
292 | it->setPixmap( 0, NSResources->getPixmap( "Devices/commprofile" ) ); | 287 | it->setPixmap( 0, NSResources->getPixmap( "Devices/commprofile" ) ); |
293 | // remember that this node maps to this listitem | 288 | // remember that this node maps to this listitem |
294 | Mapping->insert( it, NN ); | 289 | Mapping->insert( it, NN ); |
295 | buildSubTree( it, NN ); | 290 | buildSubTree( it, NN ); |
296 | } | 291 | } |
297 | } | 292 | } |
298 | 293 | ||
299 | // Build device tree -> help function | 294 | // Build device tree -> help function |
300 | void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) { | 295 | void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) { |
301 | ANetNode::NetNodeList & NNL = NN->alternatives(); | 296 | ANetNode::NetNodeList & NNL = NN->alternatives(); |
302 | 297 | ||
303 | if( NNL.size() > 1 ) { | 298 | if( NNL.size() > 1 ) { |
304 | // this node has alternatives -> needs radio buttons | 299 | // this node has alternatives -> needs radio buttons |
305 | it = new MyQCheckListItem( | 300 | it = new MyQCheckListItem( |
306 | it, | 301 | it, |
307 | NSResources->netNode2Name(NNL[0]->provides()), | 302 | NSResources->netNode2Name(NNL[0]->provides()), |
308 | QCheckListItem::Controller ); | 303 | QCheckListItem::Controller ); |
309 | it->setSelectable( FALSE ); | 304 | it->setSelectable( FALSE ); |
310 | } | 305 | } |
311 | 306 | ||
312 | for ( unsigned int i=0; i < NNL.size(); i++ ) { | 307 | for ( unsigned int i=0; i < NNL.size(); i++ ) { |
313 | QListViewItem * CI; | 308 | QListViewItem * CI; |
@@ -387,130 +382,130 @@ void EditConnection::SLOT_SelectNode( QListViewItem * it ) { | |||
387 | return; | 382 | return; |
388 | } | 383 | } |
389 | 384 | ||
390 | // store conversion from lvitem to node | 385 | // store conversion from lvitem to node |
391 | NN = (*Mapping)[ it ]; | 386 | NN = (*Mapping)[ it ]; |
392 | 387 | ||
393 | if( ! NN ) { | 388 | if( ! NN ) { |
394 | // intermediate node | 389 | // intermediate node |
395 | NN = (*Mapping)[ it->firstChild() ]; | 390 | NN = (*Mapping)[ it->firstChild() ]; |
396 | if( NN ) { | 391 | if( NN ) { |
397 | // figure out type of this node -> produce mesage | 392 | // figure out type of this node -> produce mesage |
398 | Description_LBL->setText( NSResources->netNode2Description(NN->provides()) ); | 393 | Description_LBL->setText( NSResources->netNode2Description(NN->provides()) ); |
399 | } else { | 394 | } else { |
400 | Description_LBL->setText( "" ); | 395 | Description_LBL->setText( "" ); |
401 | } | 396 | } |
402 | return; | 397 | return; |
403 | } | 398 | } |
404 | 399 | ||
405 | Description_LBL->setText( NN->nodeDescription() ); | 400 | Description_LBL->setText( NN->nodeDescription() ); |
406 | 401 | ||
407 | if( ! it->isSelectable() ) { | 402 | if( ! it->isSelectable() ) { |
408 | return; | 403 | return; |
409 | } | 404 | } |
410 | 405 | ||
411 | if( ! ((QCheckListItem *)it)->isOn() ) { | 406 | if( ! ((QCheckListItem *)it)->isOn() ) { |
412 | // clicked on line but NOT on Check or Radio item | 407 | // clicked on line but NOT on Check or Radio item |
413 | return; | 408 | return; |
414 | } | 409 | } |
415 | 410 | ||
416 | // item has really changed -> update | 411 | // item has really changed -> update |
417 | TmpIsValid = 0; | 412 | TmpIsValid = 0; |
418 | updateGUI( it, NN ); | 413 | updateGUI( it, NN ); |
419 | } | 414 | } |
420 | 415 | ||
421 | // cliecked on TAB to go to setup | 416 | // cliecked on TAB to go to setup |
422 | void EditConnection::SLOT_AlterTab( const QString & S ) { | 417 | void EditConnection::SLOT_AlterTab( const QString & S ) { |
423 | if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) { | 418 | if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) { |
424 | // switched to setup -> update CB and populate ws with | 419 | // switched to setup -> update CB and populate ws with |
425 | // forms for devices | 420 | // forms for devices |
426 | 421 | ||
427 | if( ! TmpIsValid ) { | 422 | if( ! TmpIsValid ) { |
428 | getTmpCollection(); | 423 | getTmpCollection(); |
429 | 424 | ||
430 | // clear CB and Ws | 425 | // clear CB and Ws |
431 | { QWidget * W; | 426 | { QWidget * W; |
432 | int i = 0; | 427 | int i = 0; |
433 | 428 | ||
434 | Devices_CB->clear(); | 429 | Devices_CB->clear(); |
435 | while( ( W = Setup_WS->widget( i ) ) ) { | 430 | while( ( W = Setup_WS->widget( i ) ) ) { |
436 | Setup_WS->removeWidget( W ); | 431 | Setup_WS->removeWidget( W ); |
437 | i ++; | 432 | i ++; |
438 | } | 433 | } |
439 | } | 434 | } |
440 | 435 | ||
441 | // update CB | 436 | // update CB |
442 | // and populate WidgetStack | 437 | // and populate WidgetStack |
443 | { ANetNodeInstance * NNI; | 438 | { ANetNodeInstance * NNI; |
444 | QListIterator<ANetNodeInstance> it(TmpCollection); | 439 | QListIterator<ANetNodeInstance> it(TmpCollection); |
445 | int i = 0; | 440 | int i = 0; |
446 | QWidget * W; | 441 | QWidget * W; |
447 | 442 | ||
448 | for ( ; it.current(); ++it ) { | 443 | for ( ; it.current(); ++it ) { |
449 | NNI = it.current(); | 444 | NNI = it.current(); |
450 | Devices_CB->insertItem( | 445 | Devices_CB->insertItem( |
451 | NSResources->getPixmap( NNI->netNode()->pixmapName() ), | 446 | NSResources->getPixmap( NNI->nodeClass()->pixmapName() ), |
452 | NNI->netNode()->nodeName() | 447 | NNI->nodeClass()->nodeName() |
453 | ); | 448 | ); |
454 | 449 | ||
455 | // add edit widget | 450 | // add edit widget |
456 | W = NNI->edit( Setup_WS ); | 451 | W = NNI->edit( Setup_WS ); |
457 | if( ! W) { | 452 | if( ! W) { |
458 | W = new QLabel( Setup_WS, | 453 | W = new QLabel( Setup_WS, |
459 | tr("No configuration required")); | 454 | tr("No configuration required")); |
460 | } | 455 | } |
461 | Setup_WS->addWidget( W , i ); | 456 | Setup_WS->addWidget( W , i ); |
462 | i ++; | 457 | i ++; |
463 | } | 458 | } |
464 | } | 459 | } |
465 | Setup_WS->raiseWidget( 0 ); | 460 | Setup_WS->raiseWidget( 0 ); |
466 | } // still valid | 461 | } // still valid |
467 | } | 462 | } |
468 | } | 463 | } |
469 | 464 | ||
470 | // update visual feedback of selection state | 465 | // update visual feedback of selection state |
471 | void EditConnection::updateGUI( QListViewItem * it, ANetNode * NN ) { | 466 | void EditConnection::updateGUI( QListViewItem * it, ANetNode * NN ) { |
472 | 467 | ||
473 | bool HCC = haveCompleteConfig( it ); | 468 | bool HCC = haveCompleteConfig( it ); |
474 | Tab_TB->setTabEnabled( Setup_FRM, HCC ); | 469 | Tab_TB->setTabEnabled( Setup_FRM, HCC ); |
475 | Setup_FRM->setEnabled( HCC ); | 470 | Setup_FRM->setEnabled( HCC ); |
476 | 471 | ||
477 | // disable children of all siblings at same level | 472 | // disable children of all siblings at same level |
478 | QListViewItem * Sbl = it->parent()->firstChild(); | 473 | QListViewItem * Sbl = it->parent()->firstChild(); |
479 | while( Sbl ) { | 474 | while( Sbl ) { |
480 | if ( Sbl != it ) { | 475 | if ( Sbl != it ) { |
481 | disableTree( Sbl->firstChild(), FALSE ); | 476 | disableTree( Sbl->firstChild(), FALSE ); |
482 | Sbl->setSelectable( TRUE ); | 477 | Sbl->setSelectable( TRUE ); |
483 | if( AutoCollapse ) | 478 | if( AutoCollapse ) |
484 | Sbl->setOpen( FALSE ); | 479 | Sbl->setOpen( FALSE ); |
485 | } | 480 | } |
486 | Sbl = Sbl->nextSibling(); | 481 | Sbl = Sbl->nextSibling(); |
487 | } | 482 | } |
488 | 483 | ||
489 | // enable selected path (as deep as it goes | 484 | // enable selected path (as deep as it goes |
490 | it->setOpen( TRUE ); | 485 | it->setOpen( TRUE ); |
491 | enablePath( it->firstChild(), | 486 | enablePath( it->firstChild(), |
492 | (it->depth()==1) ? | 487 | (it->depth()==1) ? |
493 | 1 : // toplevel always alternatives | 488 | 1 : // toplevel always alternatives |
494 | (NN->alternatives().size() > 1) ); | 489 | (NN->alternatives().size() > 1) ); |
495 | } | 490 | } |
496 | 491 | ||
497 | void EditConnection::disableTree( QListViewItem * it, bool Mode ) { | 492 | void EditConnection::disableTree( QListViewItem * it, bool Mode ) { |
498 | while( it ) { | 493 | while( it ) { |
499 | // disable sbl's chidren | 494 | // disable sbl's chidren |
500 | it->setSelectable( Mode ); | 495 | it->setSelectable( Mode ); |
501 | if( AutoCollapse ) | 496 | if( AutoCollapse ) |
502 | it->setOpen( Mode ); | 497 | it->setOpen( Mode ); |
503 | disableTree( it->firstChild(), Mode ); | 498 | disableTree( it->firstChild(), Mode ); |
504 | it = it->nextSibling(); | 499 | it = it->nextSibling(); |
505 | } | 500 | } |
506 | } | 501 | } |
507 | 502 | ||
508 | // pah : ParentHasAlternatives | 503 | // pah : ParentHasAlternatives |
509 | void EditConnection::enablePath( QListViewItem * it, bool pha ) { | 504 | void EditConnection::enablePath( QListViewItem * it, bool pha ) { |
510 | while( it ) { | 505 | while( it ) { |
511 | ANetNode * NN; | 506 | ANetNode * NN; |
512 | NN = (*Mapping)[it]; | 507 | NN = (*Mapping)[it]; |
513 | if( NN ) { | 508 | if( NN ) { |
514 | if( pha ) { | 509 | if( pha ) { |
515 | bool doOn = ((QCheckListItem *)it)->isOn(); | 510 | bool doOn = ((QCheckListItem *)it)->isOn(); |
516 | // we are a checklistitem for sure | 511 | // we are a checklistitem for sure |
diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp index 4347191..96327a5 100644 --- a/noncore/settings/networksettings2/irda/irda_NN.cpp +++ b/noncore/settings/networksettings2/irda/irda_NN.cpp | |||
@@ -1,66 +1,54 @@ | |||
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 &, bool ) { | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | bool IRDANetNode::generateDataForCommonFile( | ||
49 | SystemFile & , | ||
50 | long , | ||
51 | ANetNodeInstance * ) { | ||
52 | return 1; | ||
53 | } | ||
54 | |||
55 | bool IRDANetNode::generateDeviceDataForCommonFile( | 44 | bool IRDANetNode::generateDeviceDataForCommonFile( |
56 | SystemFile & , | 45 | SystemFile & , |
57 | long , | 46 | long ) { |
58 | ANetNodeInstance * ) { | ||
59 | return 1; | 47 | return 1; |
60 | } | 48 | } |
61 | 49 | ||
62 | extern "C" { | 50 | extern "C" { |
63 | void create_plugin( QList<ANetNode> & PNN ) { | 51 | void create_plugin( QList<ANetNode> & PNN ) { |
64 | PNN.append( new IRDANetNode() ); | 52 | PNN.append( new IRDANetNode() ); |
65 | } | 53 | } |
66 | } | 54 | } |
diff --git a/noncore/settings/networksettings2/irda/irda_NN.h b/noncore/settings/networksettings2/irda/irda_NN.h index a772f69..a5b6cc5 100644 --- a/noncore/settings/networksettings2/irda/irda_NN.h +++ b/noncore/settings/networksettings2/irda/irda_NN.h | |||
@@ -1,46 +1,45 @@ | |||
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, bool DS ); | 31 | virtual bool hasDataFor( const QString & ) |
32 | virtual bool generateDataForCommonFile( | 32 | { return 0; } |
33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | ||
34 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
35 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | 34 | SystemFile & SF, long DevNr ); |
36 | 35 | ||
37 | private: | 36 | private: |
38 | 37 | ||
39 | }; | 38 | }; |
40 | 39 | ||
41 | extern "C" | 40 | extern "C" |
42 | { | 41 | { |
43 | void create_plugin( QList<ANetNode> & PNN ); | 42 | void create_plugin( QList<ANetNode> & PNN ); |
44 | }; | 43 | }; |
45 | 44 | ||
46 | #endif | 45 | #endif |
diff --git a/noncore/settings/networksettings2/irda/irda_NNI.cpp b/noncore/settings/networksettings2/irda/irda_NNI.cpp index 78d6ff9..f00a1d5 100644 --- a/noncore/settings/networksettings2/irda/irda_NNI.cpp +++ b/noncore/settings/networksettings2/irda/irda_NNI.cpp | |||
@@ -1,30 +1,37 @@ | |||
1 | #include "irdaedit.h" | 1 | #include "irdaedit.h" |
2 | #include "irda_NNI.h" | 2 | #include "irda_NNI.h" |
3 | #include "irda_NN.h" | 3 | #include "irda_NN.h" |
4 | 4 | ||
5 | AIRDA::AIRDA( IRDANetNode * PNN ) : ANetNodeInstance( PNN ) { | 5 | AIRDA::AIRDA( IRDANetNode * PNN ) : ANetNodeInstance( PNN ) { |
6 | 6 | ||
7 | GUI = 0; | 7 | GUI = 0; |
8 | RT = 0; | 8 | RT = 0; |
9 | } | 9 | } |
10 | 10 | ||
11 | void AIRDA::setSpecificAttribute( QString & , QString & ) { | 11 | void AIRDA::setSpecificAttribute( QString & , QString & ) { |
12 | } | 12 | } |
13 | 13 | ||
14 | void AIRDA::saveSpecificAttribute( QTextStream & ) { | 14 | void AIRDA::saveSpecificAttribute( QTextStream & ) { |
15 | } | 15 | } |
16 | 16 | ||
17 | QWidget * AIRDA::edit( QWidget * parent ) { | 17 | QWidget * AIRDA::edit( QWidget * parent ) { |
18 | GUI = new IRDAEdit( parent ); | 18 | GUI = new IRDAEdit( parent ); |
19 | GUI->showData( Data ); | 19 | GUI->showData( Data ); |
20 | return GUI; | 20 | return GUI; |
21 | } | 21 | } |
22 | 22 | ||
23 | QString AIRDA::acceptable( void ) { | 23 | QString AIRDA::acceptable( void ) { |
24 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 24 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
25 | } | 25 | } |
26 | 26 | ||
27 | void AIRDA::commit( void ) { | 27 | void AIRDA::commit( void ) { |
28 | if( GUI && GUI->commit( Data ) ) | 28 | if( GUI && GUI->commit( Data ) ) |
29 | setModified( 1 ); | 29 | setModified( 1 ); |
30 | } | 30 | } |
31 | |||
32 | bool AIRDA::generateDataForCommonFile( | ||
33 | SystemFile & , | ||
34 | long ) { | ||
35 | return 1; | ||
36 | } | ||
37 | |||
diff --git a/noncore/settings/networksettings2/irda/irda_NNI.h b/noncore/settings/networksettings2/irda/irda_NNI.h index c2d6875..210d87d 100644 --- a/noncore/settings/networksettings2/irda/irda_NNI.h +++ b/noncore/settings/networksettings2/irda/irda_NNI.h | |||
@@ -1,43 +1,48 @@ | |||
1 | #ifndef IRDA_H | 1 | #ifndef IRDA_H |
2 | #define IRDA_H | 2 | #define IRDA_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "irdadata.h" | 5 | #include "irdadata.h" |
6 | #include "irdarun.h" | 6 | #include "irdarun.h" |
7 | 7 | ||
8 | class IRDANetNode; | 8 | class IRDANetNode; |
9 | class IRDAEdit; | 9 | class IRDAEdit; |
10 | 10 | ||
11 | class AIRDA : public ANetNodeInstance { | 11 | class AIRDA : public ANetNodeInstance { |
12 | 12 | ||
13 | public : | 13 | public : |
14 | 14 | ||
15 | AIRDA( IRDANetNode * PNN ); | 15 | AIRDA( IRDANetNode * 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 IRDARun( this, Data ); | 23 | RT = new IRDARun( 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 | virtual bool hasDataFor( const QString & ) | ||
31 | { return 0; } | ||
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & SF, long DevNr ); | ||
34 | |||
30 | protected : | 35 | protected : |
31 | 36 | ||
32 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 37 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
33 | virtual void saveSpecificAttribute( QTextStream & TS ); | 38 | virtual void saveSpecificAttribute( QTextStream & TS ); |
34 | 39 | ||
35 | private : | 40 | private : |
36 | 41 | ||
37 | IRDAEdit * GUI; | 42 | IRDAEdit * GUI; |
38 | IRDAData Data; | 43 | IRDAData Data; |
39 | IRDARun * RT; | 44 | IRDARun * RT; |
40 | 45 | ||
41 | }; | 46 | }; |
42 | 47 | ||
43 | #endif | 48 | #endif |
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp index 7d36918..480ddf9 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp +++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp | |||
@@ -1,67 +1,72 @@ | |||
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 & S, bool DS ) { | 45 | bool LanCardNetNode::hasDataFor( const QString & S ) { |
46 | return DS && S == "interfaces"; | 46 | return S == "interfaces"; |
47 | } | ||
48 | |||
49 | bool LanCardNetNode::generateDataForCommonFile( | ||
50 | SystemFile & , | ||
51 | long , | ||
52 | ANetNodeInstance * ) { | ||
53 | return 1; | ||
54 | } | 47 | } |
55 | 48 | ||
56 | bool LanCardNetNode::generateDeviceDataForCommonFile( | 49 | bool LanCardNetNode::generateDeviceDataForCommonFile( |
57 | SystemFile & S , | 50 | SystemFile & S , |
58 | long DevNr , | 51 | long DevNr ) { |
59 | ANetNodeInstance * NNI ) { | 52 | QString NIC = genNic( DevNr ); |
60 | return ((ALanCard *)NNI)->generateDeviceDataForCommonFile(S, DevNr); | 53 | |
54 | if( S.name() == "interfaces" ) { | ||
55 | // generate mapping stanza for this interface | ||
56 | S << "# check if " << NIC << " can be brought UP" << endl; | ||
57 | S << "mapping " << NIC << endl; | ||
58 | S << " script networksettings2-request" << endl << endl; | ||
59 | } | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | QString LanCardNetNode::genNic( long nr ) { | ||
64 | QString S; | ||
65 | return S.sprintf( "eth%ld", nr ); | ||
61 | } | 66 | } |
62 | 67 | ||
63 | extern "C" { | 68 | extern "C" { |
64 | void create_plugin( QList<ANetNode> & PNN ) { | 69 | void create_plugin( QList<ANetNode> & PNN ) { |
65 | PNN.append( new LanCardNetNode() ); | 70 | PNN.append( new LanCardNetNode() ); |
66 | } | 71 | } |
67 | } | 72 | } |
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h index 9690c76..dcdd0da 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.h +++ b/noncore/settings/networksettings2/lancard/lancard_NN.h | |||
@@ -1,46 +1,49 @@ | |||
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, bool DS ); | 31 | virtual bool hasDataFor( const QString & S ); |
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | ||
34 | virtual bool generateDeviceDataForCommonFile( | 32 | virtual bool generateDeviceDataForCommonFile( |
35 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | 33 | SystemFile & SF, long DevNr ); |
34 | |||
35 | virtual long instanceCount( void ) | ||
36 | { return 2; } | ||
37 | |||
38 | virtual QString genNic( long ); | ||
36 | 39 | ||
37 | private: | 40 | private: |
38 | 41 | ||
39 | }; | 42 | }; |
40 | 43 | ||
41 | extern "C" | 44 | extern "C" |
42 | { | 45 | { |
43 | void create_plugin( QList<ANetNode> & PNN ); | 46 | void create_plugin( QList<ANetNode> & PNN ); |
44 | }; | 47 | }; |
45 | 48 | ||
46 | #endif | 49 | #endif |
diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp index a6401db..5962d52 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp +++ b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp | |||
@@ -1,58 +1,51 @@ | |||
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 | 45 | ||
46 | bool ALanCard::generateDeviceDataForCommonFile( SystemFile & S, long DevNr ) { | 46 | bool ALanCard::generateDataForCommonFile( |
47 | AsDevice * Dev = runtime()->device(); | 47 | SystemFile & , |
48 | QString NIC = Dev->genNic( DevNr ); | 48 | long ) { |
49 | 49 | return 1; | |
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 | } | 50 | } |
58 | 51 | ||
diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.h b/noncore/settings/networksettings2/lancard/lancard_NNI.h index 16f5f56..4e91523 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NNI.h +++ b/noncore/settings/networksettings2/lancard/lancard_NNI.h | |||
@@ -1,45 +1,47 @@ | |||
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 ); | 30 | virtual bool hasDataFor( const QString & ) |
31 | 31 | { return 0; } | |
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & S, long DevNr ); | ||
32 | protected : | 34 | protected : |
33 | 35 | ||
34 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 36 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
35 | virtual void saveSpecificAttribute( QTextStream & TS ); | 37 | virtual void saveSpecificAttribute( QTextStream & TS ); |
36 | 38 | ||
37 | private : | 39 | private : |
38 | 40 | ||
39 | LanCardEdit * GUI; | 41 | LanCardEdit * GUI; |
40 | LanCardData Data; | 42 | LanCardData Data; |
41 | LanCardRun * RT; | 43 | LanCardRun * RT; |
42 | 44 | ||
43 | }; | 45 | }; |
44 | 46 | ||
45 | #endif | 47 | #endif |
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.h b/noncore/settings/networksettings2/lancard/lancardrun.h index 8dbd1b1..499b417 100644 --- a/noncore/settings/networksettings2/lancard/lancardrun.h +++ b/noncore/settings/networksettings2/lancard/lancardrun.h | |||
@@ -1,42 +1,37 @@ | |||
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 ) | ||
18 | { return 2; } | ||
19 | virtual QString genNic( long nr ) | ||
20 | { QString S; return S.sprintf( "eth%ld", nr ); } | ||
21 | |||
22 | virtual AsDevice * device( void ) | 17 | virtual AsDevice * device( void ) |
23 | { return (AsDevice *)this; } | 18 | { return (AsDevice *)this; } |
24 | 19 | ||
25 | virtual AsDevice * asDevice( void ) | 20 | virtual AsDevice * asDevice( void ) |
26 | { return (AsDevice *)this; } | 21 | { return (AsDevice *)this; } |
27 | 22 | ||
28 | protected : | 23 | protected : |
29 | 24 | ||
30 | void detectState( NodeCollection * NC ); | 25 | void detectState( NodeCollection * NC ); |
31 | bool setState( NodeCollection * NC, Action_t A ); | 26 | bool setState( NodeCollection * NC, Action_t A ); |
32 | bool canSetState( State_t Curr, Action_t A ); | 27 | bool canSetState( State_t Curr, Action_t A ); |
33 | 28 | ||
34 | bool handlesInterface( const QString & I ); | 29 | bool handlesInterface( const QString & I ); |
35 | 30 | ||
36 | private : | 31 | private : |
37 | 32 | ||
38 | InterfaceInfo * getInterface( void ); | 33 | InterfaceInfo * getInterface( void ); |
39 | QRegExp Pat; | 34 | QRegExp Pat; |
40 | 35 | ||
41 | }; | 36 | }; |
42 | #endif | 37 | #endif |
diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp index 2807963..65b06ee 100644 --- a/noncore/settings/networksettings2/modem/modem_NN.cpp +++ b/noncore/settings/networksettings2/modem/modem_NN.cpp | |||
@@ -1,67 +1,55 @@ | |||
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 &, bool ) { | ||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | bool ModemNetNode::generateDataForCommonFile( | ||
50 | SystemFile & , | ||
51 | long , | ||
52 | ANetNodeInstance * ) { | ||
53 | return 1; | ||
54 | } | ||
55 | |||
56 | bool ModemNetNode::generateDeviceDataForCommonFile( | 45 | bool ModemNetNode::generateDeviceDataForCommonFile( |
57 | SystemFile & , | 46 | SystemFile & , |
58 | long , | 47 | long ) { |
59 | ANetNodeInstance * ) { | ||
60 | return 1; | 48 | return 1; |
61 | } | 49 | } |
62 | 50 | ||
63 | extern "C" { | 51 | extern "C" { |
64 | void create_plugin( QList<ANetNode> & PNN ) { | 52 | void create_plugin( QList<ANetNode> & PNN ) { |
65 | PNN.append( new ModemNetNode() ); | 53 | PNN.append( new ModemNetNode() ); |
66 | } | 54 | } |
67 | } | 55 | } |
diff --git a/noncore/settings/networksettings2/modem/modem_NN.h b/noncore/settings/networksettings2/modem/modem_NN.h index bd921c6..49244b2 100644 --- a/noncore/settings/networksettings2/modem/modem_NN.h +++ b/noncore/settings/networksettings2/modem/modem_NN.h | |||
@@ -1,46 +1,45 @@ | |||
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, bool DS ); | 31 | virtual bool hasDataFor( const QString & ) |
32 | virtual bool generateDataForCommonFile( | 32 | { return 0; } |
33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | ||
34 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
35 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | 34 | SystemFile & SF, long DevNr ); |
36 | 35 | ||
37 | private: | 36 | private: |
38 | 37 | ||
39 | }; | 38 | }; |
40 | 39 | ||
41 | extern "C" | 40 | extern "C" |
42 | { | 41 | { |
43 | void create_plugin( QList<ANetNode> & PNN ); | 42 | void create_plugin( QList<ANetNode> & PNN ); |
44 | }; | 43 | }; |
45 | 44 | ||
46 | #endif | 45 | #endif |
diff --git a/noncore/settings/networksettings2/modem/modem_NNI.cpp b/noncore/settings/networksettings2/modem/modem_NNI.cpp index 91df22b..6c76b56 100644 --- a/noncore/settings/networksettings2/modem/modem_NNI.cpp +++ b/noncore/settings/networksettings2/modem/modem_NNI.cpp | |||
@@ -1,31 +1,37 @@ | |||
1 | #include "modemedit.h" | 1 | #include "modemedit.h" |
2 | #include "modem_NNI.h" | 2 | #include "modem_NNI.h" |
3 | #include "modem_NN.h" | 3 | #include "modem_NN.h" |
4 | 4 | ||
5 | AModem::AModem( ModemNetNode * PNN ) : ANetNodeInstance( PNN ) { | 5 | AModem::AModem( ModemNetNode * PNN ) : ANetNodeInstance( PNN ) { |
6 | 6 | ||
7 | GUI = 0; | 7 | GUI = 0; |
8 | RT = 0; | 8 | RT = 0; |
9 | } | 9 | } |
10 | 10 | ||
11 | void AModem::setSpecificAttribute( QString & , QString & ) { | 11 | void AModem::setSpecificAttribute( QString & , QString & ) { |
12 | } | 12 | } |
13 | 13 | ||
14 | void AModem::saveSpecificAttribute( QTextStream & ) { | 14 | void AModem::saveSpecificAttribute( QTextStream & ) { |
15 | } | 15 | } |
16 | 16 | ||
17 | QWidget * AModem::edit( QWidget * parent ) { | 17 | QWidget * AModem::edit( QWidget * parent ) { |
18 | GUI = new ModemEdit( parent ); | 18 | GUI = new ModemEdit( parent ); |
19 | GUI->showData( Data ); | 19 | GUI->showData( Data ); |
20 | return GUI; | 20 | return GUI; |
21 | } | 21 | } |
22 | 22 | ||
23 | QString AModem::acceptable( void ) { | 23 | QString AModem::acceptable( void ) { |
24 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 24 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
25 | } | 25 | } |
26 | 26 | ||
27 | void AModem::commit( void ) { | 27 | void AModem::commit( void ) { |
28 | if( GUI && GUI->commit( Data ) ) | 28 | if( GUI && GUI->commit( Data ) ) |
29 | setModified( 1 ); | 29 | setModified( 1 ); |
30 | } | 30 | } |
31 | 31 | ||
32 | bool AModem::generateDataForCommonFile( | ||
33 | SystemFile & , | ||
34 | long ) { | ||
35 | return 1; | ||
36 | } | ||
37 | |||
diff --git a/noncore/settings/networksettings2/modem/modem_NNI.h b/noncore/settings/networksettings2/modem/modem_NNI.h index 7543e7d..a623704 100644 --- a/noncore/settings/networksettings2/modem/modem_NNI.h +++ b/noncore/settings/networksettings2/modem/modem_NNI.h | |||
@@ -1,43 +1,48 @@ | |||
1 | #ifndef Modem_H | 1 | #ifndef Modem_H |
2 | #define Modem_H | 2 | #define Modem_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "modemdata.h" | 5 | #include "modemdata.h" |
6 | #include "modemrun.h" | 6 | #include "modemrun.h" |
7 | 7 | ||
8 | class ModemNetNode; | 8 | class ModemNetNode; |
9 | class ModemEdit; | 9 | class ModemEdit; |
10 | 10 | ||
11 | class AModem : public ANetNodeInstance { | 11 | class AModem : public ANetNodeInstance { |
12 | 12 | ||
13 | public : | 13 | public : |
14 | 14 | ||
15 | AModem( ModemNetNode * PNN ); | 15 | AModem( ModemNetNode * 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 ModemRun( this, Data ); | 23 | RT = new ModemRun( 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 | virtual bool hasDataFor( const QString & ) | ||
31 | { return 0; } | ||
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & SF, long DevNr ); | ||
34 | |||
30 | protected : | 35 | protected : |
31 | 36 | ||
32 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 37 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
33 | virtual void saveSpecificAttribute( QTextStream & TS ); | 38 | virtual void saveSpecificAttribute( QTextStream & TS ); |
34 | 39 | ||
35 | private : | 40 | private : |
36 | 41 | ||
37 | ModemEdit * GUI; | 42 | ModemEdit * GUI; |
38 | ModemData Data; | 43 | ModemData Data; |
39 | ModemRun * RT; | 44 | ModemRun * RT; |
40 | 45 | ||
41 | }; | 46 | }; |
42 | 47 | ||
43 | #endif | 48 | #endif |
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index a6b15c6..4a77e6a 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp | |||
@@ -1,71 +1,56 @@ | |||
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, bool DS ) { | ||
47 | if( ! DS && S == "interfaces" ) { | ||
48 | return 1; | ||
49 | } | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | bool NetworkNetNode::generateDataForCommonFile( | ||
54 | SystemFile & S, | ||
55 | long DevNr, | ||
56 | ANetNodeInstance * NNI ) { | ||
57 | return ((ANetwork *)NNI)->generateDataForCommonFile(S, DevNr); | ||
58 | } | ||
59 | |||
60 | bool NetworkNetNode::generateDeviceDataForCommonFile( | 46 | bool NetworkNetNode::generateDeviceDataForCommonFile( |
61 | SystemFile & , | 47 | SystemFile & , |
62 | long , | 48 | long ) { |
63 | ANetNodeInstance * ) { | ||
64 | return 1; | 49 | return 1; |
65 | } | 50 | } |
66 | 51 | ||
67 | extern "C" { | 52 | extern "C" { |
68 | void create_plugin( QList<ANetNode> & PNN ) { | 53 | void create_plugin( QList<ANetNode> & PNN ) { |
69 | PNN.append( new NetworkNetNode() ); | 54 | PNN.append( new NetworkNetNode() ); |
70 | } | 55 | } |
71 | } | 56 | } |
diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h index 62a3f10..59f0526 100644 --- a/noncore/settings/networksettings2/network/network_NN.h +++ b/noncore/settings/networksettings2/network/network_NN.h | |||
@@ -1,46 +1,45 @@ | |||
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, bool DS ); | 31 | virtual bool hasDataFor( const QString & ) |
32 | virtual bool generateDataForCommonFile( | 32 | { return 0; } |
33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | ||
34 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
35 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | 34 | SystemFile & SF, long DevNr ); |
36 | 35 | ||
37 | private: | 36 | private: |
38 | 37 | ||
39 | }; | 38 | }; |
40 | 39 | ||
41 | extern "C" | 40 | extern "C" |
42 | { | 41 | { |
43 | void create_plugin( QList<ANetNode> & PNN ); | 42 | void create_plugin( QList<ANetNode> & PNN ); |
44 | }; | 43 | }; |
45 | 44 | ||
46 | #endif | 45 | #endif |
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp index eac2d66..054385a 100644 --- a/noncore/settings/networksettings2/network/network_NNI.cpp +++ b/noncore/settings/networksettings2/network/network_NNI.cpp | |||
@@ -38,128 +38,131 @@ void ANetwork::setSpecificAttribute( QString & A, QString & V ) { | |||
38 | } else if( A == "gateway" ) { | 38 | } else if( A == "gateway" ) { |
39 | Data.Gateway = V; | 39 | Data.Gateway = V; |
40 | } else if( A == "dns1" ) { | 40 | } else if( A == "dns1" ) { |
41 | Data.DNS1 = V; | 41 | Data.DNS1 = V; |
42 | } else if( A == "dns2" ) { | 42 | } else if( A == "dns2" ) { |
43 | Data.DNS2 = V; | 43 | Data.DNS2 = V; |
44 | } else if( A == "preup" ) { | 44 | } else if( A == "preup" ) { |
45 | Data.PreUp_SL.append( V ); | 45 | Data.PreUp_SL.append( V ); |
46 | } else if( A == "predown" ) { | 46 | } else if( A == "predown" ) { |
47 | Data.PreDown_SL.append( V ); | 47 | Data.PreDown_SL.append( V ); |
48 | } else if( A == "postup" ) { | 48 | } else if( A == "postup" ) { |
49 | Data.PostUp_SL.append( V ); | 49 | Data.PostUp_SL.append( V ); |
50 | } else if( A == "postdown" ) { | 50 | } else if( A == "postdown" ) { |
51 | Data.PostDown_SL.append( V ); | 51 | Data.PostDown_SL.append( V ); |
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
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::hasDataFor( const QString & S ) { | ||
103 | return S == "interfaces"; | ||
104 | } | ||
105 | |||
102 | bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | 106 | bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { |
103 | AsDevice * Dev = runtime()->device(); | 107 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); |
104 | QString NIC = Dev->genNic( DevNr ); | ||
105 | 108 | ||
106 | if( S.name() == "interfaces" ) { | 109 | if( S.name() == "interfaces" ) { |
107 | // we can safely call from here since device item is deeper | 110 | // we can safely call from here since device item is deeper |
108 | if( Data.UseDHCP ) { | 111 | if( Data.UseDHCP ) { |
109 | S << "iface " << NIC << "-c" << connection()->number() << | 112 | S << "iface " << NIC << "-c" << connection()->number() << |
110 | "-allowed inet dhcp" << endl; | 113 | "-allowed inet dhcp" << endl; |
111 | S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << | 114 | S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << |
112 | ".up" << Data.IPAddress << endl; | 115 | ".up" << Data.IPAddress << endl; |
113 | if( Data.SendHostname ) { | 116 | if( Data.SendHostname ) { |
114 | S << " hostname "<< Data.Hostname << endl; | 117 | S << " hostname "<< Data.Hostname << endl; |
115 | } | 118 | } |
116 | 119 | ||
117 | S << " down rm -f /tmp/profile-" << connection()->number() << | 120 | S << " down rm -f /tmp/profile-" << connection()->number() << |
118 | ".up" << Data.IPAddress << endl; | 121 | ".up" << Data.IPAddress << endl; |
119 | } else { | 122 | } else { |
120 | S << "iface " << NIC << "-c" << connection()->number() << | 123 | S << "iface " << NIC << "-c" << connection()->number() << |
121 | "-allowed inet static" << endl; | 124 | "-allowed inet static" << endl; |
122 | S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << | 125 | S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << |
123 | ".up" << Data.IPAddress << endl; | 126 | ".up" << Data.IPAddress << endl; |
124 | S << " down rm -f /tmp/profile-" << connection()->number() << | 127 | S << " down rm -f /tmp/profile-" << connection()->number() << |
125 | ".up" << Data.IPAddress << endl; | 128 | ".up" << Data.IPAddress << endl; |
126 | S << " address " << Data.IPAddress << endl; | 129 | S << " address " << Data.IPAddress << endl; |
127 | S << " broadcast " << Data.Broadcast << endl; | 130 | S << " broadcast " << Data.Broadcast << endl; |
128 | S << " netmask " << Data.NetMask << endl; | 131 | S << " netmask " << Data.NetMask << endl; |
129 | 132 | ||
130 | // derive network address = IPAddress & netmask | 133 | // derive network address = IPAddress & netmask |
131 | { QString NW; | 134 | { QString NW; |
132 | QStringList ipal = QStringList::split( '.', Data.IPAddress ); | 135 | QStringList ipal = QStringList::split( '.', Data.IPAddress ); |
133 | QStringList nmal = QStringList::split( '.', Data.NetMask ); | 136 | QStringList nmal = QStringList::split( '.', Data.NetMask ); |
134 | 137 | ||
135 | NW = QString( "%1.%2.%3.%4" ). | 138 | NW = QString( "%1.%2.%3.%4" ). |
136 | arg( ipal[0].toShort() & nmal[0].toShort() ). | 139 | arg( ipal[0].toShort() & nmal[0].toShort() ). |
137 | arg( ipal[1].toShort() & nmal[1].toShort() ). | 140 | arg( ipal[1].toShort() & nmal[1].toShort() ). |
138 | arg( ipal[2].toShort() & nmal[2].toShort() ). | 141 | arg( ipal[2].toShort() & nmal[2].toShort() ). |
139 | arg( ipal[3].toShort() & nmal[3].toShort() ); | 142 | arg( ipal[3].toShort() & nmal[3].toShort() ); |
140 | S << " network " << NW << endl; | 143 | S << " network " << NW << endl; |
141 | } | 144 | } |
142 | } | 145 | } |
143 | for ( QStringList::Iterator it = Data.PreUp_SL.begin(); | 146 | for ( QStringList::Iterator it = Data.PreUp_SL.begin(); |
144 | it != Data.PreUp_SL.end(); | 147 | it != Data.PreUp_SL.end(); |
145 | ++it ) { | 148 | ++it ) { |
146 | S << " pre-up " << (*it) << endl; | 149 | S << " pre-up " << (*it) << endl; |
147 | } | 150 | } |
148 | for ( QStringList::Iterator it = Data.PostUp_SL.begin(); | 151 | for ( QStringList::Iterator it = Data.PostUp_SL.begin(); |
149 | it != Data.PostUp_SL.end(); | 152 | it != Data.PostUp_SL.end(); |
150 | ++it ) { | 153 | ++it ) { |
151 | S << " up " << (*it) << endl; | 154 | S << " up " << (*it) << endl; |
152 | } | 155 | } |
153 | for ( QStringList::Iterator it = Data.PreDown_SL.begin(); | 156 | for ( QStringList::Iterator it = Data.PreDown_SL.begin(); |
154 | it != Data.PreDown_SL.end(); | 157 | it != Data.PreDown_SL.end(); |
155 | ++it ) { | 158 | ++it ) { |
156 | S << " down " << (*it) << endl; | 159 | S << " down " << (*it) << endl; |
157 | } | 160 | } |
158 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); | 161 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); |
159 | it != Data.PostDown_SL.end(); | 162 | it != Data.PostDown_SL.end(); |
160 | ++it ) { | 163 | ++it ) { |
161 | S << " post-down " << (*it) << endl; | 164 | S << " post-down " << (*it) << endl; |
162 | } | 165 | } |
163 | } | 166 | } |
164 | return 0; | 167 | return 0; |
165 | } | 168 | } |
diff --git a/noncore/settings/networksettings2/network/network_NNI.h b/noncore/settings/networksettings2/network/network_NNI.h index b98ff6e..0058793 100644 --- a/noncore/settings/networksettings2/network/network_NNI.h +++ b/noncore/settings/networksettings2/network/network_NNI.h | |||
@@ -1,45 +1,47 @@ | |||
1 | #ifndef NETWORK_H | 1 | #ifndef NETWORK_H |
2 | #define NETWORK_H | 2 | #define NETWORK_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "networkdata.h" | 5 | #include "networkdata.h" |
6 | #include "networkrun.h" | 6 | #include "networkrun.h" |
7 | 7 | ||
8 | class NetworkNetNode; | 8 | class NetworkNetNode; |
9 | class NetworkEdit; | 9 | class NetworkEdit; |
10 | class SystemFile; | 10 | class SystemFile; |
11 | 11 | ||
12 | class ANetwork : public ANetNodeInstance{ | 12 | class ANetwork : public ANetNodeInstance{ |
13 | 13 | ||
14 | public : | 14 | public : |
15 | 15 | ||
16 | ANetwork( NetworkNetNode * PNN ); | 16 | ANetwork( NetworkNetNode * PNN ); |
17 | 17 | ||
18 | QWidget * edit( QWidget * parent ); | 18 | QWidget * edit( QWidget * parent ); |
19 | QString acceptable( void ); | 19 | QString acceptable( void ); |
20 | void commit( void ); | 20 | void commit( void ); |
21 | 21 | ||
22 | RuntimeInfo * runtime( void ) | 22 | RuntimeInfo * runtime( void ) |
23 | { if( RT == 0 ) | 23 | { if( RT == 0 ) |
24 | RT = new NetworkRun( this, Data ); | 24 | RT = new NetworkRun( this, Data ); |
25 | return RT; | 25 | return RT; |
26 | } | 26 | } |
27 | 27 | ||
28 | virtual void * data( void ) | 28 | virtual void * data( void ) |
29 | { return (void *)&Data; } | 29 | { return (void *)&Data; } |
30 | 30 | ||
31 | bool generateDataForCommonFile( SystemFile & S, long DevNr ); | 31 | virtual bool hasDataFor( const QString & S ); |
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & SF, long DevNr ); | ||
32 | 34 | ||
33 | protected : | 35 | protected : |
34 | 36 | ||
35 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 37 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
36 | virtual void saveSpecificAttribute( QTextStream & TS ); | 38 | virtual void saveSpecificAttribute( QTextStream & TS ); |
37 | 39 | ||
38 | private : | 40 | private : |
39 | 41 | ||
40 | NetworkEdit * GUI; | 42 | NetworkEdit * GUI; |
41 | NetworkData_t Data; | 43 | NetworkData_t Data; |
42 | NetworkRun * RT; | 44 | NetworkRun * RT; |
43 | }; | 45 | }; |
44 | 46 | ||
45 | #endif | 47 | #endif |
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp index f34fdbf..ddb9a5f 100644 --- a/noncore/settings/networksettings2/network/networkrun.cpp +++ b/noncore/settings/networksettings2/network/networkrun.cpp | |||
@@ -1,65 +1,66 @@ | |||
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 | return; | ||
13 | } | 14 | } |
14 | 15 | ||
15 | // has no interface -> delegate | 16 | // has no interface -> delegate |
16 | RI->detectState( NC ); | 17 | RI->detectState( NC ); |
17 | } | 18 | } |
18 | 19 | ||
19 | bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { | 20 | bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { |
20 | // we handle UP and DOWN | 21 | // we handle UP and DOWN |
21 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 22 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); |
22 | AsDevice * Next = RI->asDevice(); | 23 | AsDevice * Next = RI->asDevice(); |
23 | InterfaceInfo * II = Next->assignedInterface(); | 24 | InterfaceInfo * II = Next->assignedInterface(); |
24 | 25 | ||
25 | if( A == Up ) { | 26 | if( A == Up ) { |
26 | // we can bring UP if lower level is available | 27 | // we can bring UP if lower level is available |
27 | if( NC->currentState() == Available ) { | 28 | if( NC->currentState() == Available ) { |
28 | QString S; | 29 | QString S; |
29 | S.sprintf( "ifup %s=%s-c%d-allowed", | 30 | S.sprintf( "ifup %s=%s-c%d-allowed", |
30 | II->Name.latin1(), II->Name.latin1(), | 31 | II->Name.latin1(), II->Name.latin1(), |
31 | connection()->number() ); | 32 | connection()->number() ); |
32 | NSResources->system().execute( S ); | 33 | NSResources->system().execute( S ); |
33 | } | 34 | } |
34 | return 1; | 35 | return 1; |
35 | } else if( A == Down ) { | 36 | } else if( A == Down ) { |
36 | if( NC->currentState() == IsUp ) { | 37 | if( NC->currentState() == IsUp ) { |
37 | QString S; | 38 | QString S; |
38 | S.sprintf( "ifdown %s=%s-c%d-allowed", | 39 | S.sprintf( "ifdown %s=%s-c%d-allowed", |
39 | II->Name.latin1(), II->Name.latin1(), | 40 | II->Name.latin1(), II->Name.latin1(), |
40 | connection()->number() ); | 41 | connection()->number() ); |
41 | NSResources->system().execute( S ); | 42 | NSResources->system().execute( S ); |
42 | } | 43 | } |
43 | return 1; | 44 | return 1; |
44 | } | 45 | } |
45 | // delegate | 46 | // delegate |
46 | return RI->setState( NC, A ); | 47 | return RI->setState( NC, A ); |
47 | } | 48 | } |
48 | 49 | ||
49 | bool NetworkRun::canSetState( State_t Curr, Action_t A ) { | 50 | bool NetworkRun::canSetState( State_t Curr, Action_t A ) { |
50 | // we handle UP and DOWN | 51 | // we handle UP and DOWN |
51 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 52 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); |
52 | 53 | ||
53 | if( A == Up ) { | 54 | if( A == Up ) { |
54 | return ( Curr == Available ); | 55 | return ( Curr == Available ); |
55 | } else if( A == Down ) { | 56 | } else if( A == Down ) { |
56 | return ( Curr == IsUp ); | 57 | return ( Curr == IsUp ); |
57 | } | 58 | } |
58 | // delegate | 59 | // delegate |
59 | return RI->canSetState( Curr, A ); | 60 | return RI->canSetState( Curr, A ); |
60 | } | 61 | } |
61 | 62 | ||
62 | bool NetworkRun::handlesInterface( const QString & S ) { | 63 | bool NetworkRun::handlesInterface( const QString & S ) { |
63 | // donno -> pass deeper | 64 | // donno -> pass deeper |
64 | return netNode()->nextNode()->runtime()->handlesInterface(S); | 65 | return netNode()->nextNode()->runtime()->handlesInterface(S); |
65 | } | 66 | } |
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp index c3e6572..3ddcbde 100644 --- a/noncore/settings/networksettings2/networksettings.cpp +++ b/noncore/settings/networksettings2/networksettings.cpp | |||
@@ -12,239 +12,239 @@ | |||
12 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
13 | #include <qtoolbutton.h> | 13 | #include <qtoolbutton.h> |
14 | 14 | ||
15 | #include <asdevice.h> | 15 | #include <asdevice.h> |
16 | #include "networksettings.h" | 16 | #include "networksettings.h" |
17 | #include "netnode.h" | 17 | #include "netnode.h" |
18 | #include "editconnection.h" | 18 | #include "editconnection.h" |
19 | 19 | ||
20 | NetworkSettings::NetworkSettings( QWidget *parent, | 20 | NetworkSettings::NetworkSettings( QWidget *parent, |
21 | const char *name, | 21 | const char *name, |
22 | WFlags fl ) : NetworkSettingsGUI(parent,name,fl), | 22 | WFlags fl ) : NetworkSettingsGUI(parent,name,fl), |
23 | NSD() { | 23 | NSD() { |
24 | 24 | ||
25 | UpdateTimer = new QTimer( this ); | 25 | UpdateTimer = new QTimer( this ); |
26 | // set pixmaps | 26 | // set pixmaps |
27 | Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); | 27 | Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); |
28 | Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) ); | 28 | Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) ); |
29 | CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) ); | 29 | CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) ); |
30 | Enable_TB->setPixmap( NSResources->getPixmap( "disabled" ) ); | 30 | Enable_TB->setPixmap( NSResources->getPixmap( "disabled" ) ); |
31 | GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) ); | 31 | GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) ); |
32 | 32 | ||
33 | Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) ); | 33 | Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) ); |
34 | 34 | ||
35 | On_TB->setPixmap( NSResources->getPixmap( "off" ) ); | 35 | On_TB->setPixmap( NSResources->getPixmap( "off" ) ); |
36 | 36 | ||
37 | // populate main Listbox | 37 | // populate main Listbox |
38 | Profiles_LB->clear(); | 38 | Profiles_LB->clear(); |
39 | { Name2Connection_t & M = NSResources->connections(); | 39 | { Name2Connection_t & M = NSResources->connections(); |
40 | NodeCollection * NC; | 40 | NodeCollection * NC; |
41 | // for all connections | 41 | // for all connections |
42 | for( QDictIterator<NodeCollection> it(M); | 42 | for( QDictIterator<NodeCollection> it(M); |
43 | it.current(); | 43 | it.current(); |
44 | ++it ) { | 44 | ++it ) { |
45 | NC = it.current(); | 45 | NC = it.current(); |
46 | Profiles_LB->insertItem( NC->devicePixmap(), | 46 | Profiles_LB->insertItem( NC->devicePixmap(), |
47 | NC->name() ); | 47 | NC->name() ); |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | if( Profiles_LB->count() ) { | 51 | if( Profiles_LB->count() ) { |
52 | Profiles_LB->setSelected( 0, TRUE ); | 52 | Profiles_LB->setSelected( 0, TRUE ); |
53 | } | 53 | } |
54 | 54 | ||
55 | // if no profiles -> auto popup editing | 55 | // if no profiles -> auto popup editing |
56 | if( NSResources->connections().count() == 0 ) { | 56 | if( NSResources->connections().count() == 0 ) { |
57 | QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) ); | 57 | QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) ); |
58 | } | 58 | } |
59 | 59 | ||
60 | UpdateTimer->start( 5000 ); | 60 | UpdateTimer->start( 5000 ); |
61 | connect( UpdateTimer, SIGNAL( timeout() ), | 61 | connect( UpdateTimer, SIGNAL( timeout() ), |
62 | this, SLOT( SLOT_RefreshStates() ) ); | 62 | this, SLOT( SLOT_RefreshStates() ) ); |
63 | 63 | ||
64 | /* Add QCopChannel */ | 64 | /* Add QCopChannel */ |
65 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), | 65 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
66 | this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) ); | 66 | this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) ); |
67 | } | 67 | } |
68 | 68 | ||
69 | NetworkSettings::~NetworkSettings() { | 69 | NetworkSettings::~NetworkSettings() { |
70 | QString S; | 70 | QString S; |
71 | 71 | ||
72 | S = NSD.generateSettings(); | 72 | S = NSD.generateSettings(); |
73 | if( ! S.isEmpty() ) { | 73 | if( ! S.isEmpty() ) { |
74 | QMessageBox::warning( | 74 | QMessageBox::warning( |
75 | 0, | 75 | 0, |
76 | tr( "Generating system configuration" ), | 76 | tr( "In System Config" ), |
77 | S | 77 | S |
78 | ); | 78 | ); |
79 | } | 79 | } |
80 | 80 | ||
81 | S = NSD.saveSettings(); | 81 | S = NSD.saveSettings(); |
82 | if( ! S.isEmpty() ) { | 82 | if( ! S.isEmpty() ) { |
83 | // problem saving | 83 | // problem saving |
84 | QMessageBox::warning( | 84 | QMessageBox::warning( |
85 | 0, | 85 | 0, |
86 | tr( "Saving setup" ), S ); | 86 | tr( "Saving setup" ), S ); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | void NetworkSettings::SLOT_RefreshStates( void ) { | 90 | void NetworkSettings::SLOT_RefreshStates( void ) { |
91 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember | 91 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember |
92 | 92 | ||
93 | if( LBI ) { | 93 | if( LBI ) { |
94 | NodeCollection * NC; | 94 | NodeCollection * NC; |
95 | NSResources->system().probeInterfaces(); | 95 | NSResources->system().probeInterfaces(); |
96 | // update current selection only | 96 | // update current selection only |
97 | NC = NSResources->findConnection( LBI->text() ); | 97 | NC = NSResources->findConnection( LBI->text() ); |
98 | if( NC ) { | 98 | if( NC ) { |
99 | State_t OldS = NC->state(); | 99 | State_t OldS = NC->state(); |
100 | State_t NewS = NC->state(1); | 100 | State_t NewS = NC->state(1); |
101 | if( OldS != NewS ) { | 101 | if( OldS != NewS ) { |
102 | updateProfileState( LBI ); | 102 | updateProfileState( LBI ); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
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 | // we need to retry | 171 | // we need to retry |
172 | while( 1 ) { | 172 | while( 1 ) { |
173 | if( EC.exec() == QDialog::Accepted ) { | 173 | if( EC.exec() == QDialog::Accepted ) { |
174 | // toplevel item -> store | 174 | // toplevel item -> store |
175 | NodeCollection * NC = EC.connection(); | 175 | NodeCollection * NC = EC.connection(); |
176 | if( NC->isModified() ) { | 176 | if( NC->isModified() ) { |
177 | setModified( 1 ); | 177 | setModified( 1 ); |
178 | if( LBI ) { | 178 | if( LBI ) { |
179 | if( NC->name() != OldName ) { | 179 | if( NC->name() != OldName ) { |
180 | // find if new name is free | 180 | // find if new name is free |
181 | NodeCollection * LCN = NSResources->findConnection( | 181 | NodeCollection * LCN = NSResources->findConnection( |
182 | NC->name() ); | 182 | NC->name() ); |
183 | if( LCN ) { | 183 | if( LCN ) { |
184 | QMessageBox::warning( | 184 | QMessageBox::warning( |
185 | 0, | 185 | 0, |
186 | tr( "Generating system configuration" ), | 186 | tr( "In System Config" ), |
187 | tr( "Name %1 already exists" ).arg(NC->name()) | 187 | tr( "Name %1 already exists" ).arg(NC->name()) |
188 | ); | 188 | ); |
189 | continue; // restart exec | 189 | continue; // restart exec |
190 | } // else new name | 190 | } // else new name |
191 | // new name -> remove item | 191 | // new name -> remove item |
192 | NSResources->removeConnection( OldName ); | 192 | NSResources->removeConnection( OldName ); |
193 | NSResources->addConnection( NC ); | 193 | NSResources->addConnection( NC ); |
194 | } // else not changed | 194 | } // else not changed |
195 | 195 | ||
196 | // must add it here since change will trigger event | 196 | // must add it here since change will trigger event |
197 | Profiles_LB->changeItem( NC->devicePixmap(), | 197 | Profiles_LB->changeItem( NC->devicePixmap(), |
198 | NC->name(), | 198 | NC->name(), |
199 | Profiles_LB->index( LBI ) | 199 | Profiles_LB->index( LBI ) |
200 | ); | 200 | ); |
201 | } else { | 201 | } else { |
202 | // new item | 202 | // new item |
203 | int ci = Profiles_LB->count(); | 203 | int ci = Profiles_LB->count(); |
204 | NSResources->addConnection( NC ); | 204 | NSResources->addConnection( NC ); |
205 | NC->setNumber( NC->maxConnectionNumber()+1 ); | 205 | NC->setNumber( NC->maxConnectionNumber()+1 ); |
206 | Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); | 206 | Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); |
207 | Profiles_LB->setSelected( ci, TRUE ); | 207 | Profiles_LB->setSelected( ci, TRUE ); |
208 | } | 208 | } |
209 | updateProfileState( LBI ); | 209 | updateProfileState( LBI ); |
210 | } | 210 | } |
211 | } else { | 211 | } else { |
212 | // cancelled : reset connection | 212 | // cancelled : reset connection |
213 | if( LBI ) { | 213 | if( LBI ) { |
214 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); | 214 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); |
215 | NC->reassign(); | 215 | NC->reassign(); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | break; | 218 | break; |
219 | } | 219 | } |
220 | // reenable | 220 | // reenable |
221 | UpdateTimer->start( 5000 ); | 221 | UpdateTimer->start( 5000 ); |
222 | } | 222 | } |
223 | 223 | ||
224 | void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { | 224 | void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { |
225 | if( LBI == 0 ) | 225 | if( LBI == 0 ) |
226 | return; | 226 | return; |
227 | 227 | ||
228 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); | 228 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); |
229 | 229 | ||
230 | // is button possible | 230 | // is button possible |
231 | bool EnabledPossible, OnPossible, ConnectPossible; | 231 | bool EnabledPossible, OnPossible, ConnectPossible; |
232 | // is button On or Off | 232 | // is button On or Off |
233 | bool DisabledOn, OnOn, ConnectOn; | 233 | bool DisabledOn, OnOn, ConnectOn; |
234 | 234 | ||
235 | EnabledPossible = OnPossible = ConnectPossible = 1; | 235 | EnabledPossible = OnPossible = ConnectPossible = 1; |
236 | DisabledOn = 1; | 236 | DisabledOn = 1; |
237 | OnOn = ConnectOn = 0; | 237 | OnOn = ConnectOn = 0; |
238 | 238 | ||
239 | switch( NC->state() ) { | 239 | switch( NC->state() ) { |
240 | case Unknown : | 240 | case Unknown : |
241 | // cannot occur here | 241 | // cannot occur here |
242 | break; | 242 | break; |
243 | case Unchecked : | 243 | case Unchecked : |
244 | case Unavailable : | 244 | case Unavailable : |
245 | // cannot do anything but recheck | 245 | // cannot do anything but recheck |
246 | EnabledPossible = OnPossible = ConnectPossible = 0; | 246 | EnabledPossible = OnPossible = ConnectPossible = 0; |
247 | break; | 247 | break; |
248 | case Disabled : | 248 | case Disabled : |
249 | OnPossible = ConnectPossible = 0; | 249 | OnPossible = ConnectPossible = 0; |
250 | break; | 250 | break; |
diff --git a/noncore/settings/networksettings2/networksettings2/asdevice.h b/noncore/settings/networksettings2/networksettings2/asdevice.h index 058fc4c..19241c1 100644 --- a/noncore/settings/networksettings2/networksettings2/asdevice.h +++ b/noncore/settings/networksettings2/networksettings2/asdevice.h | |||
@@ -1,37 +1,31 @@ | |||
1 | #ifndef ASDEVICE_H | 1 | #ifndef ASDEVICE_H |
2 | #define ASDEVICE_H | 2 | #define ASDEVICE_H |
3 | 3 | ||
4 | #include "system.h" | 4 | #include "system.h" |
5 | #include "netnode.h" | 5 | #include "netnode.h" |
6 | 6 | ||
7 | // pure virtual (component oriented) interface of any | 7 | // pure virtual (component oriented) interface of any |
8 | // plugin that offers a device | 8 | // plugin that offers a device |
9 | class AsDevice : public RuntimeInfo { | 9 | class AsDevice : public RuntimeInfo { |
10 | 10 | ||
11 | public : | 11 | public : |
12 | 12 | ||
13 | AsDevice( ANetNodeInstance * NNI ) : | 13 | AsDevice( ANetNodeInstance * NNI ) : |
14 | RuntimeInfo( NNI ) { | 14 | RuntimeInfo( NNI ) { |
15 | AssignedInterface = 0; | 15 | AssignedInterface = 0; |
16 | } | 16 | } |
17 | 17 | ||
18 | // return the interface assigned to this device | 18 | // return the interface assigned to this device |
19 | // e.g eth0, wlan, ... | 19 | // e.g eth0, wlan, ... |
20 | InterfaceInfo * assignedInterface( void ) | 20 | InterfaceInfo * assignedInterface( void ) |
21 | { return AssignedInterface; } | 21 | { return AssignedInterface; } |
22 | virtual void assignInterface( InterfaceInfo * NI ) | 22 | virtual void assignInterface( InterfaceInfo * NI ) |
23 | { AssignedInterface = NI; } | 23 | { AssignedInterface = NI; } |
24 | 24 | ||
25 | // number of device to configure for this Device type | ||
26 | virtual long count( void ) | ||
27 | { return 1; } | ||
28 | // generate NIC name of device number ... | ||
29 | virtual QString genNic( long NicNr ) = 0; | ||
30 | |||
31 | private : | 25 | private : |
32 | 26 | ||
33 | InterfaceInfo * AssignedInterface; | 27 | InterfaceInfo * AssignedInterface; |
34 | 28 | ||
35 | }; | 29 | }; |
36 | 30 | ||
37 | #endif | 31 | #endif |
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index f040c99..fcc6044 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp | |||
@@ -116,129 +116,129 @@ NodeCollection::NodeCollection( QTextStream & TS ) : | |||
116 | } | 116 | } |
117 | // empty line | 117 | // empty line |
118 | break; | 118 | break; |
119 | } | 119 | } |
120 | 120 | ||
121 | idx = S.find('='); | 121 | idx = S.find('='); |
122 | S.stripWhiteSpace(); | 122 | S.stripWhiteSpace(); |
123 | A = S.left( idx ); | 123 | A = S.left( idx ); |
124 | A.lower(); | 124 | A.lower(); |
125 | N = S.mid( idx+1, S.length() ); | 125 | N = S.mid( idx+1, S.length() ); |
126 | N.stripWhiteSpace(); | 126 | N.stripWhiteSpace(); |
127 | N = deQuote( N ); | 127 | N = deQuote( N ); |
128 | 128 | ||
129 | if( A == "name" ) { | 129 | if( A == "name" ) { |
130 | Name = N; | 130 | Name = N; |
131 | } else if( A == "number" ) { | 131 | } else if( A == "number" ) { |
132 | setNumber( N.toLong() ); | 132 | setNumber( N.toLong() ); |
133 | } else if( A == "node" ) { | 133 | } else if( A == "node" ) { |
134 | ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); | 134 | ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); |
135 | if( NNI && ! InError ) { | 135 | if( NNI && ! InError ) { |
136 | append( NSResources->findNodeInstance( N ) ); | 136 | append( NSResources->findNodeInstance( N ) ); |
137 | } else { | 137 | } else { |
138 | // could not find a node type -> collection invalid | 138 | // could not find a node type -> collection invalid |
139 | InError = 1; | 139 | InError = 1; |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } while( 1 ); | 142 | } while( 1 ); |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | NodeCollection::~NodeCollection( void ) { | 146 | NodeCollection::~NodeCollection( void ) { |
147 | } | 147 | } |
148 | 148 | ||
149 | const QString & NodeCollection::description( void ) { | 149 | const QString & NodeCollection::description( void ) { |
150 | ANetNodeInstance * NNI = getToplevel(); | 150 | ANetNodeInstance * NNI = getToplevel(); |
151 | return (NNI) ? NNI->runtime()->asFullSetup()->description() : Name; | 151 | return (NNI) ? NNI->runtime()->asFullSetup()->description() : Name; |
152 | } | 152 | } |
153 | 153 | ||
154 | void NodeCollection::append( ANetNodeInstance * NNI ) { | 154 | void NodeCollection::append( ANetNodeInstance * NNI ) { |
155 | NNI->setConnection( this ); | 155 | NNI->setConnection( this ); |
156 | QList<ANetNodeInstance>::append( NNI ); | 156 | QList<ANetNodeInstance>::append( NNI ); |
157 | } | 157 | } |
158 | 158 | ||
159 | void NodeCollection::save( QTextStream & TS ) { | 159 | void NodeCollection::save( QTextStream & TS ) { |
160 | 160 | ||
161 | TS << "name=" << quote( Name ) << endl; | 161 | TS << "name=" << quote( Name ) << endl; |
162 | TS << "number=" << number() << endl; | 162 | TS << "number=" << number() << endl; |
163 | ANetNodeInstance * NNI; | 163 | ANetNodeInstance * NNI; |
164 | for( QListIterator<ANetNodeInstance> it(*this); | 164 | for( QListIterator<ANetNodeInstance> it(*this); |
165 | it.current(); | 165 | it.current(); |
166 | ++it ) { | 166 | ++it ) { |
167 | NNI = it.current(); | 167 | NNI = it.current(); |
168 | TS << "node=" << quote( NNI->nodeName() ) << endl; | 168 | TS << "node=" << quote( NNI->nodeName() ) << endl; |
169 | } | 169 | } |
170 | TS << endl; | 170 | TS << endl; |
171 | IsNew = 0; | 171 | IsNew = 0; |
172 | } | 172 | } |
173 | 173 | ||
174 | ANetNodeInstance * NodeCollection::getToplevel( void ) { | 174 | ANetNodeInstance * NodeCollection::getToplevel( void ) { |
175 | ANetNodeInstance * NNI = 0; | 175 | ANetNodeInstance * NNI = 0; |
176 | for( QListIterator<ANetNodeInstance> it(*this); | 176 | for( QListIterator<ANetNodeInstance> it(*this); |
177 | it.current(); | 177 | it.current(); |
178 | ++it ) { | 178 | ++it ) { |
179 | NNI = it.current(); | 179 | NNI = it.current(); |
180 | if( NNI->netNode()->isToplevel() ) | 180 | if( NNI->nodeClass()->isToplevel() ) |
181 | break; | 181 | break; |
182 | } | 182 | } |
183 | return NNI; | 183 | return NNI; |
184 | } | 184 | } |
185 | 185 | ||
186 | ANetNodeInstance * NodeCollection::findByName( const QString & S ) { | 186 | ANetNodeInstance * NodeCollection::findByName( const QString & S ) { |
187 | ANetNodeInstance * NNI = 0; | 187 | ANetNodeInstance * NNI = 0; |
188 | for( QListIterator<ANetNodeInstance> it(*this); | 188 | for( QListIterator<ANetNodeInstance> it(*this); |
189 | it.current(); | 189 | it.current(); |
190 | ++it ) { | 190 | ++it ) { |
191 | NNI = it.current(); | 191 | NNI = it.current(); |
192 | if( NNI->name() == S ) | 192 | if( NNI->name() == S ) |
193 | break; | 193 | break; |
194 | } | 194 | } |
195 | return NNI; | 195 | return NNI; |
196 | } | 196 | } |
197 | 197 | ||
198 | ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { | 198 | ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { |
199 | ANetNodeInstance * NNNI; | 199 | ANetNodeInstance * NNNI; |
200 | 200 | ||
201 | if( ! NNI ) | 201 | if( ! NNI ) |
202 | getToplevel(); | 202 | getToplevel(); |
203 | 203 | ||
204 | for( QListIterator<ANetNodeInstance> it(*this); | 204 | for( QListIterator<ANetNodeInstance> it(*this); |
205 | it.current(); | 205 | it.current(); |
206 | ++it ) { | 206 | ++it ) { |
207 | NNNI = it.current(); | 207 | NNNI = it.current(); |
208 | if( NNNI == NNI ) { | 208 | if( NNNI == NNI ) { |
209 | ++it; | 209 | ++it; |
210 | return it.current(); | 210 | return it.current(); |
211 | } | 211 | } |
212 | } | 212 | } |
213 | return 0; // no more next | 213 | return 0; // no more next |
214 | } | 214 | } |
215 | 215 | ||
216 | int NodeCollection::compareItems( QCollection::Item I1, | 216 | int NodeCollection::compareItems( QCollection::Item I1, |
217 | QCollection::Item I2 ) { | 217 | QCollection::Item I2 ) { |
218 | ANetNodeInstance * NNI1, * NNI2; | 218 | ANetNodeInstance * NNI1, * NNI2; |
219 | NNI1 = (ANetNodeInstance *)I1; | 219 | NNI1 = (ANetNodeInstance *)I1; |
220 | NNI2 = (ANetNodeInstance *)I2; | 220 | NNI2 = (ANetNodeInstance *)I2; |
221 | return NNI1->nodeName().compare( NNI2->nodeName() ); | 221 | return NNI1->nodeName().compare( NNI2->nodeName() ); |
222 | } | 222 | } |
223 | 223 | ||
224 | static char * State2PixmapTbl[] = { | 224 | static char * State2PixmapTbl[] = { |
225 | "NULL", // Unchecked : no pixmap | 225 | "NULL", // Unchecked : no pixmap |
226 | "check", // Unknown | 226 | "check", // Unknown |
227 | "delete", // unavailable | 227 | "delete", // unavailable |
228 | "disabled", // disabled | 228 | "disabled", // disabled |
229 | "off", // off | 229 | "off", // off |
230 | "disconnected", // available | 230 | "disconnected", // available |
231 | "connected" // up | 231 | "connected" // up |
232 | }; | 232 | }; |
233 | 233 | ||
234 | QPixmap NodeCollection::devicePixmap( void ) { | 234 | QPixmap NodeCollection::devicePixmap( void ) { |
235 | return NSResources->getPixmap( | 235 | return NSResources->getPixmap( |
236 | device()->netNode()->pixmapName()+"-large" ); | 236 | device()->netNode()->pixmapName()+"-large" ); |
237 | } | 237 | } |
238 | 238 | ||
239 | QPixmap NodeCollection::statePixmap( State_t S) { | 239 | QPixmap NodeCollection::statePixmap( State_t S) { |
240 | return NSResources->getPixmap( State2PixmapTbl[S] ); | 240 | return NSResources->getPixmap( State2PixmapTbl[S] ); |
241 | } | 241 | } |
242 | 242 | ||
243 | QString NodeCollection::stateName( State_t S) { | 243 | QString NodeCollection::stateName( State_t S) { |
244 | switch( S ) { | 244 | switch( S ) { |
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h index f4a5e30..9681c6e 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.h +++ b/noncore/settings/networksettings2/networksettings2/netnode.h | |||
@@ -34,260 +34,275 @@ 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, bool DeviceSpecific ) = 0; | 98 | virtual bool hasDataFor( const QString & S ) = 0; |
99 | // generate data specific for a profile and for the system file S | ||
100 | // called only IF data was needed | ||
101 | virtual bool generateDataForCommonFile( | ||
102 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ) = 0; | ||
103 | // generate data specific for the device for the system file S | 99 | // generate data specific for the device for the system file S |
104 | // called only IF data was needed | 100 | // called only IF data was needed |
105 | virtual bool generateDeviceDataForCommonFile( | 101 | virtual bool generateDeviceDataForCommonFile( |
106 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ) = 0; | 102 | SystemFile & SF, long DevNr ) = 0; |
107 | 103 | ||
108 | // does this Node provide a Connection | 104 | // does this Node provide a Connection |
109 | bool isToplevel( void ) | 105 | bool isToplevel( void ) |
110 | { return strcmp( provides(), "fullsetup") == 0 ; } | 106 | { return strcmp( provides(), "fullsetup") == 0 ; } |
111 | 107 | ||
108 | // generate NIC name based on instance nr | ||
109 | // only relevant if node instances are devices | ||
110 | virtual QString genNic( long ) | ||
111 | { return QString(""); } | ||
112 | |||
113 | // max number of instances for this node type | ||
114 | // only relevant if node instances are devices | ||
115 | virtual long instanceCount( void ) | ||
116 | { return 1; } | ||
117 | |||
112 | // compiled references to 'needed' NetNodes -> needs list | 118 | // compiled references to 'needed' NetNodes -> needs list |
113 | void setAlternatives( NetNodeList * Alt ) | 119 | void setAlternatives( NetNodeList * Alt ) |
114 | { Alternatives = Alt; } | 120 | { Alternatives = Alt; } |
115 | NetNodeList & alternatives( void ) | 121 | NetNodeList & alternatives( void ) |
116 | { return *Alternatives; } | 122 | { return *Alternatives; } |
117 | 123 | ||
118 | protected : | 124 | protected : |
119 | 125 | ||
120 | NetNodeList * Alternatives; | 126 | NetNodeList * Alternatives; |
121 | 127 | ||
122 | private : | 128 | private : |
123 | }; | 129 | }; |
124 | 130 | ||
125 | class ANetNodeInstance : public QObject { | 131 | class ANetNodeInstance : public QObject { |
126 | 132 | ||
127 | public: | 133 | public: |
128 | 134 | ||
129 | ANetNodeInstance( ANetNode * NN ) : QObject() | 135 | ANetNodeInstance( ANetNode * NN ) : QObject() |
130 | { IsModified=0; NodeType = NN; IsNew = TRUE; } | 136 | { IsModified=0; NodeType = NN; IsNew = TRUE; } |
131 | virtual ~ANetNodeInstance( void ) { } | 137 | virtual ~ANetNodeInstance( void ) { } |
132 | 138 | ||
133 | virtual RuntimeInfo * runtime( void ) = 0; | 139 | virtual RuntimeInfo * runtime( void ) = 0; |
134 | 140 | ||
135 | void setConnection( NodeCollection * NC ) | 141 | void setConnection( NodeCollection * NC ) |
136 | { Connection = NC; } | 142 | { Connection = NC; } |
137 | NodeCollection * connection( void ) | 143 | NodeCollection * connection( void ) |
138 | { return Connection; } | 144 | { return Connection; } |
139 | 145 | ||
140 | // create edit widget under parent | 146 | // create edit widget under parent |
141 | virtual QWidget * edit( QWidget * parent ) = 0; | 147 | virtual QWidget * edit( QWidget * parent ) = 0; |
142 | // is given data acceptable | 148 | // is given data acceptable |
143 | virtual QString acceptable( void ) = 0; | 149 | virtual QString acceptable( void ) = 0; |
144 | 150 | ||
145 | // return data was modified | 151 | // return data was modified |
146 | void setModified( bool M ) | 152 | void setModified( bool M ) |
147 | { IsModified = M; } | 153 | { IsModified = M; } |
148 | bool isModified( void ) | 154 | bool isModified( void ) |
149 | { return IsModified; } | 155 | { return IsModified; } |
150 | 156 | ||
151 | // get data from GUI and store in node | 157 | // get data from GUI and store in node |
152 | virtual void commit( void ) = 0; | 158 | virtual void commit( void ) = 0; |
153 | 159 | ||
154 | // get next node | 160 | // get next node |
155 | ANetNodeInstance * nextNode(); | 161 | ANetNodeInstance * nextNode(); |
156 | // return NetNode this is an instance of | 162 | // return NetNode this is an instance of |
157 | ANetNode * netNode( void ) | 163 | ANetNode * nodeClass( void ) |
158 | { return NodeType; } | 164 | { return NodeType; } |
159 | 165 | ||
160 | // intialize am instance of a net node | 166 | // intialize am instance of a net node |
161 | void initialize( void ); | 167 | void initialize( void ); |
162 | 168 | ||
163 | // set the value of an attribute | 169 | // set the value of an attribute |
164 | void setAttribute( QString & Attr, QString & Value ) ; | 170 | void setAttribute( QString & Attr, QString & Value ) ; |
165 | void saveAttributes( QTextStream & TS ) ; | 171 | void saveAttributes( QTextStream & TS ) ; |
166 | 172 | ||
167 | // return true if node isntance is NEW and not loaded | 173 | // return true if node isntance is NEW and not loaded |
168 | void setNew( bool IsN ) | 174 | void setNew( bool IsN ) |
169 | { IsNew = IsN; } | 175 | { IsNew = IsN; } |
170 | bool isNew( void ) | 176 | bool isNew( void ) |
171 | { return IsNew; } | 177 | { return IsNew; } |
172 | 178 | ||
173 | // return logical name of this instance | 179 | // return logical name of this instance |
174 | QString & nodeName( void ) | 180 | QString & nodeName( void ) |
175 | { return NodeName; } | 181 | { return NodeName; } |
176 | void setNodeName( const QString & S ) | 182 | void setNodeName( const QString & S ) |
177 | { NodeName = S; } | 183 | { NodeName = S; } |
178 | // return description for this instance | 184 | // return description for this instance |
179 | QString & description( void ) | 185 | QString & description( void ) |
180 | { return Description; } | 186 | { return Description; } |
181 | void setDescription( const QString & S ) | 187 | void setDescription( const QString & S ) |
182 | { Description = S; } | 188 | { Description = S; } |
183 | 189 | ||
184 | // pixmap for this instance -> from NetNode | 190 | // pixmap for this instance -> from NetNode |
185 | const QString pixmapName( void ) | 191 | const QString pixmapName( void ) |
186 | { return NodeType->pixmapName(); } | 192 | { return NodeType->pixmapName(); } |
187 | 193 | ||
188 | const char * provides( void ) | 194 | const char * provides( void ) |
189 | { return NodeType->provides(); } | 195 | { return NodeType->provides(); } |
190 | 196 | ||
191 | const char ** needs( void ) | 197 | const char ** needs( void ) |
192 | { return NodeType->needs(); } | 198 | { return NodeType->needs(); } |
193 | 199 | ||
194 | // returns node specific data -> only useful for 'buddy' | 200 | // returns node specific data -> only useful for 'buddy' |
195 | virtual void * data( void ) = 0; | 201 | virtual void * data( void ) = 0; |
196 | 202 | ||
203 | // return TRUE if this node has data to be inserted in systemfile | ||
204 | // with name S | ||
205 | virtual bool hasDataFor( const QString & S ) = 0; | ||
206 | |||
207 | // generate data specific for a profile and for the system file S | ||
208 | // called only IF data was needed | ||
209 | virtual bool generateDataForCommonFile( | ||
210 | SystemFile & SF, long DevNr ) = 0; | ||
211 | |||
197 | protected : | 212 | protected : |
198 | 213 | ||
199 | virtual void setSpecificAttribute( QString & , QString & ) = 0; | 214 | virtual void setSpecificAttribute( QString & , QString & ) = 0; |
200 | virtual void saveSpecificAttribute( QTextStream & ) = 0; | 215 | virtual void saveSpecificAttribute( QTextStream & ) = 0; |
201 | 216 | ||
202 | ANetNode * NodeType; | 217 | ANetNode * NodeType; |
203 | // connection to which this node belongs to | 218 | // connection to which this node belongs to |
204 | NodeCollection * Connection; | 219 | NodeCollection * Connection; |
205 | QString NodeName; | 220 | QString NodeName; |
206 | QString Description; | 221 | QString Description; |
207 | bool IsModified; | 222 | bool IsModified; |
208 | bool IsNew; | 223 | bool IsNew; |
209 | 224 | ||
210 | static long InstanceCounter; | 225 | static long InstanceCounter; |
211 | }; | 226 | }; |
212 | 227 | ||
213 | class RuntimeInfo : public QObject { | 228 | class RuntimeInfo : public QObject { |
214 | 229 | ||
215 | Q_OBJECT | 230 | Q_OBJECT |
216 | 231 | ||
217 | public : | 232 | public : |
218 | 233 | ||
219 | RuntimeInfo( ANetNodeInstance * TheNNI ) | 234 | RuntimeInfo( ANetNodeInstance * TheNNI ) |
220 | { NNI = TheNNI; } | 235 | { NNI = TheNNI; } |
221 | 236 | ||
222 | // downcast implemented by specify runtime classes | 237 | // downcast implemented by specify runtime classes |
223 | AsDevice * asDevice( void ) | 238 | virtual AsDevice * asDevice( void ) |
224 | { return 0; } | 239 | { return 0; } |
225 | AsConnection * asConnection( void ) | 240 | virtual AsConnection * asConnection( void ) |
226 | { return 0; } | 241 | { return 0; } |
227 | AsLine * asLine( void ) | 242 | virtual AsLine * asLine( void ) |
228 | { return 0; } | 243 | { return 0; } |
229 | AsFullSetup * asFullSetup( void ) | 244 | virtual AsFullSetup * asFullSetup( void ) |
230 | { return 0; } | 245 | { return 0; } |
231 | 246 | ||
232 | // does this node handles this interface e.g.eth0 | 247 | // does this node handles this interface e.g.eth0 |
233 | // recurse deeper if this node cannot answer that question | 248 | // recurse deeper if this node cannot answer that question |
234 | virtual bool handlesInterface( const QString & ) | 249 | virtual bool handlesInterface( const QString & ) |
235 | { return 0; } | 250 | { return 0; } |
236 | virtual InterfaceInfo * assignedInterface( void ); | 251 | virtual InterfaceInfo * assignedInterface( void ); |
237 | virtual AsDevice * device( void ); | 252 | virtual AsDevice * device( void ); |
238 | 253 | ||
239 | ANetNodeInstance * netNode() | 254 | ANetNodeInstance * netNode() |
240 | { return NNI; } | 255 | { return NNI; } |
241 | NodeCollection * connection() | 256 | NodeCollection * connection() |
242 | { return NNI->connection(); } | 257 | { return NNI->connection(); } |
243 | 258 | ||
244 | virtual void detectState( NodeCollection * NC ) = 0; | 259 | virtual void detectState( NodeCollection * NC ) = 0; |
245 | virtual bool setState( NodeCollection * NC, Action_t A ) = 0; | 260 | virtual bool setState( NodeCollection * NC, Action_t A ) = 0; |
246 | virtual bool canSetState( State_t Curr, Action_t A ) = 0; | 261 | virtual bool canSetState( State_t Curr, Action_t A ) = 0; |
247 | 262 | ||
248 | signals : | 263 | signals : |
249 | 264 | ||
250 | // sent by device if state changes | 265 | // sent by device if state changes |
251 | void stateChanged( State_t S, ANetNodeInstance * NNI ); | 266 | void stateChanged( State_t S, ANetNodeInstance * NNI ); |
252 | 267 | ||
253 | protected : | 268 | protected : |
254 | 269 | ||
255 | // connection this runtime info belongs to | 270 | // connection this runtime info belongs to |
256 | ANetNodeInstance * NNI; | 271 | ANetNodeInstance * NNI; |
257 | }; | 272 | }; |
258 | 273 | ||
259 | class NodeCollection : public QList<ANetNodeInstance> { | 274 | class NodeCollection : public QList<ANetNodeInstance> { |
260 | 275 | ||
261 | public : | 276 | public : |
262 | 277 | ||
263 | NodeCollection( void ); | 278 | NodeCollection( void ); |
264 | NodeCollection( QTextStream & TS ); | 279 | NodeCollection( QTextStream & TS ); |
265 | ~NodeCollection( void ); | 280 | ~NodeCollection( void ); |
266 | 281 | ||
267 | int number( void ) | 282 | int number( void ) |
268 | { return Number; } | 283 | { return Number; } |
269 | void setNumber( int i ) | 284 | void setNumber( int i ) |
270 | { Number = i; if( MaxNr < i ) MaxNr = i; } | 285 | { Number = i; if( MaxNr < i ) MaxNr = i; } |
271 | bool isNew( void ) | 286 | bool isNew( void ) |
272 | { return IsNew; } | 287 | { return IsNew; } |
273 | void setNew( bool N ) | 288 | void setNew( bool N ) |
274 | { IsNew = N ; } | 289 | { IsNew = N ; } |
275 | bool isModified( void ) | 290 | bool isModified( void ) |
276 | { return IsModified; } | 291 | { return IsModified; } |
277 | void setModified( bool N ) | 292 | void setModified( bool N ) |
278 | { IsModified = N ; } | 293 | { IsModified = N ; } |
279 | 294 | ||
280 | bool handlesInterface( const QString & S ) { | 295 | bool handlesInterface( const QString & S ) { |
281 | return getToplevel()->runtime()->handlesInterface( S ); | 296 | return getToplevel()->runtime()->handlesInterface( S ); |
282 | } | 297 | } |
283 | 298 | ||
284 | InterfaceInfo * assignedInterface( void ) { | 299 | InterfaceInfo * assignedInterface( void ) { |
285 | return getToplevel()->runtime()->assignedInterface(); | 300 | return getToplevel()->runtime()->assignedInterface(); |
286 | } | 301 | } |
287 | 302 | ||
288 | AsDevice * device() { | 303 | AsDevice * device() { |
289 | return getToplevel()->runtime()->device(); | 304 | return getToplevel()->runtime()->device(); |
290 | } | 305 | } |
291 | 306 | ||
292 | State_t state( bool Update = 0 ) | 307 | State_t state( bool Update = 0 ) |
293 | { if( CurrentState == Unchecked || Update ) { | 308 | { if( CurrentState == Unchecked || Update ) { |
@@ -327,121 +342,124 @@ public : | |||
327 | { return Name; } | 342 | { return Name; } |
328 | 343 | ||
329 | const QString & description( void ); | 344 | const QString & description( void ); |
330 | 345 | ||
331 | void setName( const QString & N) | 346 | void setName( const QString & N) |
332 | { Name = N; } | 347 | { Name = N; } |
333 | 348 | ||
334 | State_t currentState( void ) | 349 | State_t currentState( void ) |
335 | { return CurrentState; } | 350 | { return CurrentState; } |
336 | void setCurrentState( State_t S ) | 351 | void setCurrentState( State_t S ) |
337 | { CurrentState = S; } | 352 | { CurrentState = S; } |
338 | 353 | ||
339 | long maxConnectionNumber( void ) | 354 | long maxConnectionNumber( void ) |
340 | { return MaxNr; } | 355 | { return MaxNr; } |
341 | 356 | ||
342 | static void resetMaxNr( void ) | 357 | static void resetMaxNr( void ) |
343 | { MaxNr = -1; } | 358 | { MaxNr = -1; } |
344 | 359 | ||
345 | private : | 360 | private : |
346 | 361 | ||
347 | int compareItems ( QCollection::Item item1, | 362 | int compareItems ( QCollection::Item item1, |
348 | QCollection::Item item2 ); | 363 | QCollection::Item item2 ); |
349 | 364 | ||
350 | static long MaxNr; | 365 | static long MaxNr; |
351 | long Number; | 366 | long Number; |
352 | 367 | ||
353 | // state of this connection | 368 | // state of this connection |
354 | State_t CurrentState; | 369 | State_t CurrentState; |
355 | 370 | ||
356 | QString Name; | 371 | QString Name; |
357 | // true if this collection was just created (and not | 372 | // true if this collection was just created (and not |
358 | // loaded from file | 373 | // loaded from file |
359 | bool IsNew; | 374 | bool IsNew; |
360 | // index in listbox | 375 | // index in listbox |
361 | int Index; | 376 | int Index; |
362 | bool IsModified; | 377 | bool IsModified; |
363 | 378 | ||
364 | }; | 379 | }; |
365 | 380 | ||
366 | // | 381 | // |
367 | // special node that is used to remember entries for plugins | 382 | // special node that is used to remember entries for plugins |
368 | // that seem missing. This way we never loose data | 383 | // that seem missing. This way we never loose data |
369 | // | 384 | // |
370 | 385 | ||
371 | class FakeNetNode : public ANetNode { | 386 | class FakeNetNode : public ANetNode { |
372 | 387 | ||
373 | public: | 388 | public: |
374 | 389 | ||
375 | FakeNetNode( ) { }; | 390 | FakeNetNode( ) { }; |
376 | virtual ~FakeNetNode(){}; | 391 | virtual ~FakeNetNode(){}; |
377 | 392 | ||
378 | const QString pixmapName() | 393 | const QString pixmapName() |
379 | { return QString(""); } | 394 | { return QString(""); } |
380 | const QString nodeName() | 395 | const QString nodeName() |
381 | { return QString("Fake node" ); } | 396 | { return QString("Fake node" ); } |
382 | const QString nodeDescription() | 397 | const QString nodeDescription() |
383 | { return QString("Fake node" ); } | 398 | { return QString("Fake node" ); } |
384 | ANetNodeInstance * createInstance( void ); | 399 | ANetNodeInstance * createInstance( void ); |
385 | const char * provides( void ) | 400 | const char * provides( void ) |
386 | { return ""; } | 401 | { return ""; } |
387 | virtual const char ** needs( void ) | 402 | virtual const char ** needs( void ) |
388 | { return 0; } | 403 | { return 0; } |
389 | virtual bool generateProperFilesFor( ANetNodeInstance * ) | 404 | virtual bool generateProperFilesFor( ANetNodeInstance * ) |
390 | { return 0; } | 405 | { return 0; } |
391 | virtual bool hasDataFor( const QString &, bool DS ) | 406 | virtual bool hasDataFor( const QString & ) |
392 | { return 0; } | 407 | { return 0; } |
393 | virtual bool generateDataForCommonFile( | ||
394 | SystemFile & , long , ANetNodeInstance * ) | ||
395 | {return 1; } | ||
396 | virtual bool generateDeviceDataForCommonFile( | 408 | virtual bool generateDeviceDataForCommonFile( |
397 | SystemFile & , long , ANetNodeInstance * ) | 409 | SystemFile & , long ) |
398 | {return 1; } | 410 | {return 1; } |
399 | 411 | ||
400 | private : | 412 | private : |
401 | 413 | ||
402 | }; | 414 | }; |
403 | 415 | ||
404 | class FakeNetNodeInstance : public ANetNodeInstance { | 416 | class FakeNetNodeInstance : public ANetNodeInstance { |
405 | 417 | ||
406 | public: | 418 | public: |
407 | 419 | ||
408 | FakeNetNodeInstance( ANetNode * NN ) : | 420 | FakeNetNodeInstance( ANetNode * NN ) : |
409 | ANetNodeInstance( NN ), ValAttrPairs() { } | 421 | ANetNodeInstance( NN ), ValAttrPairs() { } |
410 | virtual ~FakeNetNodeInstance( void ) { } | 422 | virtual ~FakeNetNodeInstance( void ) { } |
411 | 423 | ||
412 | virtual RuntimeInfo * runtime( void ) | 424 | virtual RuntimeInfo * runtime( void ) |
413 | { return 0; } | 425 | { return 0; } |
414 | 426 | ||
415 | // create edit widget under parent | 427 | // create edit widget under parent |
416 | virtual QWidget * edit( QWidget * ) | 428 | virtual QWidget * edit( QWidget * ) |
417 | { return 0; } | 429 | { return 0; } |
418 | // is given data acceptable | 430 | // is given data acceptable |
419 | virtual QString acceptable( void ) | 431 | virtual QString acceptable( void ) |
420 | { return QString(""); } | 432 | { return QString(""); } |
421 | 433 | ||
422 | // get data from GUI and store in node | 434 | // get data from GUI and store in node |
423 | virtual void commit( void ) {} | 435 | virtual void commit( void ) {} |
424 | 436 | ||
425 | // get next node | 437 | // get next node |
426 | ANetNodeInstance * nextNode() | 438 | ANetNodeInstance * nextNode() |
427 | { return 0; } | 439 | { return 0; } |
428 | // return NetNode this is an instance of | 440 | // return NetNode this is an instance of |
429 | 441 | ||
430 | // intialize am instance of a net node | 442 | // intialize am instance of a net node |
431 | void initialize( void ){} | 443 | void initialize( void ){} |
432 | 444 | ||
433 | // returns node specific data -> only useful for 'buddy' | 445 | // returns node specific data -> only useful for 'buddy' |
434 | virtual void * data( void ) | 446 | virtual void * data( void ) |
435 | { return 0; } | 447 | { return 0; } |
436 | 448 | ||
449 | virtual bool hasDataFor( const QString & ) | ||
450 | { return 0; } | ||
451 | |||
452 | virtual bool generateDataForCommonFile( SystemFile & , long ) | ||
453 | { return 1; } | ||
454 | |||
437 | protected : | 455 | protected : |
438 | 456 | ||
439 | virtual void setSpecificAttribute( QString & , QString & ); | 457 | virtual void setSpecificAttribute( QString & , QString & ); |
440 | virtual void saveSpecificAttribute( QTextStream & ); | 458 | virtual void saveSpecificAttribute( QTextStream & ); |
441 | 459 | ||
442 | QDict<QString> ValAttrPairs; | 460 | QDict<QString> ValAttrPairs; |
443 | }; | 461 | }; |
444 | 462 | ||
445 | extern FakeNetNode * FakeNode; | 463 | extern FakeNetNode * FakeNode; |
446 | 464 | ||
447 | #endif | 465 | #endif |
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp index 394ff52..62bb6af 100644 --- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp +++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp | |||
@@ -63,125 +63,123 @@ SystemFile::~SystemFile( void ) { | |||
63 | if( F ) | 63 | if( F ) |
64 | delete F; | 64 | delete F; |
65 | } | 65 | } |
66 | 66 | ||
67 | bool SystemFile::open( void ) { | 67 | bool SystemFile::open( void ) { |
68 | if( F ) { | 68 | if( F ) { |
69 | F->close(); | 69 | F->close(); |
70 | delete F; | 70 | delete F; |
71 | } | 71 | } |
72 | 72 | ||
73 | F = new QFile( Path + "bup" ); | 73 | F = new QFile( Path + "bup" ); |
74 | if( ! F->open( IO_WriteOnly ) ) { | 74 | if( ! F->open( IO_WriteOnly ) ) { |
75 | return 0; | 75 | return 0; |
76 | } | 76 | } |
77 | setDevice( F ); | 77 | setDevice( F ); |
78 | return 1; | 78 | return 1; |
79 | } | 79 | } |
80 | 80 | ||
81 | bool SystemFile::close( void ) { | 81 | bool SystemFile::close( void ) { |
82 | if( ! F ) { | 82 | if( ! F ) { |
83 | return 1 ; | 83 | return 1 ; |
84 | } | 84 | } |
85 | 85 | ||
86 | QString OldP = Path + "bup"; | 86 | QString OldP = Path + "bup"; |
87 | 87 | ||
88 | F->close(); | 88 | F->close(); |
89 | delete F; | 89 | delete F; |
90 | F = 0; | 90 | F = 0; |
91 | 91 | ||
92 | return ( rename( OldP.latin1(), Path.latin1() ) >= 0 ); | 92 | return ( rename( OldP.latin1(), Path.latin1() ) >= 0 ); |
93 | } | 93 | } |
94 | 94 | ||
95 | bool SystemFile::preSection( void ) { | 95 | bool SystemFile::preSection( void ) { |
96 | if( hasPreSection ) { | 96 | if( hasPreSection ) { |
97 | QFile Fl( TemplDir + Name + "/presection" ); | 97 | QFile Fl( TemplDir + Name + "/presection" ); |
98 | if( ! Fl.open( IO_ReadOnly ) ) | 98 | if( ! Fl.open( IO_ReadOnly ) ) |
99 | return 1; // error | 99 | return 1; // error |
100 | // copy file to this file | 100 | // copy file to this file |
101 | F->writeBlock( Fl.readAll() ); | 101 | F->writeBlock( Fl.readAll() ); |
102 | } | 102 | } |
103 | return 0; | 103 | return 0; |
104 | } | 104 | } |
105 | 105 | ||
106 | bool SystemFile::postSection( void ) { | 106 | bool SystemFile::postSection( void ) { |
107 | if( hasPostSection ) { | 107 | if( hasPostSection ) { |
108 | QFile Fl( TemplDir + Name + "/postsection" ); | 108 | QFile Fl( TemplDir + Name + "/postsection" ); |
109 | if( ! Fl.open( IO_ReadOnly ) ) | 109 | if( ! Fl.open( IO_ReadOnly ) ) |
110 | return 1; // error | 110 | return 1; // error |
111 | // copy file to this file | 111 | // copy file to this file |
112 | F->writeBlock( Fl.readAll() ); | 112 | F->writeBlock( Fl.readAll() ); |
113 | } | 113 | } |
114 | return 0; | 114 | return 0; |
115 | } | 115 | } |
116 | 116 | ||
117 | bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) { | 117 | bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) { |
118 | if( hasPreNodeSection ) { | 118 | if( hasPreNodeSection ) { |
119 | QFile Fl( TemplDir + Name + "/prenodesection" ); | 119 | QFile Fl( TemplDir + Name + "/prenodesection" ); |
120 | if( ! Fl.open( IO_ReadOnly ) ) | 120 | if( ! Fl.open( IO_ReadOnly ) ) |
121 | return 1; // error | 121 | return 1; // error |
122 | QTextStream TX( &Fl ); | 122 | QTextStream TX( &Fl ); |
123 | QString Out; | 123 | QString Out; |
124 | QString S = TX.readLine(); | 124 | QString S = TX.readLine(); |
125 | while( ! TX.eof() ) { | 125 | while( ! TX.eof() ) { |
126 | Out = S. | 126 | Out = S. |
127 | arg(NNI->netNode()->nodeName()); | 127 | arg(NNI->nodeClass()->nodeName()); |
128 | (*this) << Out << endl; | 128 | (*this) << Out << endl; |
129 | S = TX.readLine(); | 129 | S = TX.readLine(); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | return 0; | 132 | return 0; |
133 | } | 133 | } |
134 | 134 | ||
135 | bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long DevNr ) { | 135 | bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) { |
136 | if( hasPostNodeSection ) { | 136 | if( hasPostNodeSection ) { |
137 | QFile Fl( TemplDir + Name + "/postnodesection" ); | 137 | QFile Fl( TemplDir + Name + "/postnodesection" ); |
138 | if( ! Fl.open( IO_ReadOnly ) ) | 138 | if( ! Fl.open( IO_ReadOnly ) ) |
139 | return 1; // error | 139 | return 1; // error |
140 | QTextStream TX( &Fl ); | 140 | QTextStream TX( &Fl ); |
141 | QString Out; | 141 | QString Out; |
142 | QString S = TX.readLine(); | 142 | QString S = TX.readLine(); |
143 | while( ! TX.eof() ) { | 143 | while( ! TX.eof() ) { |
144 | Out = S. | 144 | Out = S. |
145 | arg(NNI->nodeName()); | 145 | arg(NNI->nodeName()); |
146 | (*this) << Out << endl; | 146 | (*this) << Out << endl; |
147 | S = TX.readLine(); | 147 | S = TX.readLine(); |
148 | } | 148 | } |
149 | } | 149 | } |
150 | return 0; | 150 | return 0; |
151 | } | 151 | } |
152 | 152 | ||
153 | bool SystemFile::preDeviceSection( ANetNodeInstance * NNI, long ) { | 153 | bool SystemFile::preDeviceSection( ANetNode * NN ) { |
154 | if( hasPreDeviceSection ) { | 154 | if( hasPreDeviceSection ) { |
155 | QFile Fl( TemplDir + Name + "/predevicesection" ); | 155 | QFile Fl( TemplDir + Name + "/predevicesection" ); |
156 | if( ! Fl.open( IO_ReadOnly ) ) | 156 | if( ! Fl.open( IO_ReadOnly ) ) |
157 | return 1; // error | 157 | return 1; // error |
158 | QTextStream TX( &Fl ); | 158 | QTextStream TX( &Fl ); |
159 | QString Out; | 159 | QString Out; |
160 | QString S = TX.readLine(); | 160 | QString S = TX.readLine(); |
161 | while( ! TX.eof() ) { | 161 | while( ! TX.eof() ) { |
162 | Out = S. | 162 | Out = S.arg(NN->nodeName()); |
163 | arg(NNI->netNode()->nodeName()); | ||
164 | (*this) << Out << endl; | 163 | (*this) << Out << endl; |
165 | S = TX.readLine(); | 164 | S = TX.readLine(); |
166 | } | 165 | } |
167 | } | 166 | } |
168 | return 0; | 167 | return 0; |
169 | } | 168 | } |
170 | 169 | ||
171 | bool SystemFile::postDeviceSection( ANetNodeInstance * NNI, long DevNr ) { | 170 | bool SystemFile::postDeviceSection( ANetNode * NN ) { |
172 | if( hasPostDeviceSection ) { | 171 | if( hasPostDeviceSection ) { |
173 | QFile Fl( TemplDir + Name + "/postdevicesection" ); | 172 | QFile Fl( TemplDir + Name + "/postdevicesection" ); |
174 | if( ! Fl.open( IO_ReadOnly ) ) | 173 | if( ! Fl.open( IO_ReadOnly ) ) |
175 | return 1; // error | 174 | return 1; // error |
176 | QTextStream TX( &Fl ); | 175 | QTextStream TX( &Fl ); |
177 | QString Out; | 176 | QString Out; |
178 | QString S = TX.readLine(); | 177 | QString S = TX.readLine(); |
179 | while( ! TX.eof() ) { | 178 | while( ! TX.eof() ) { |
180 | Out = S. | 179 | Out = S.arg(NN->nodeName()); |
181 | arg(NNI->nodeName()); | ||
182 | (*this) << Out << endl; | 180 | (*this) << Out << endl; |
183 | S = TX.readLine(); | 181 | S = TX.readLine(); |
184 | } | 182 | } |
185 | } | 183 | } |
186 | return 0; | 184 | return 0; |
187 | } | 185 | } |
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.h b/noncore/settings/networksettings2/networksettings2/systemfile.h index 35e0dfc..f57dab0 100644 --- a/noncore/settings/networksettings2/networksettings2/systemfile.h +++ b/noncore/settings/networksettings2/networksettings2/systemfile.h | |||
@@ -1,43 +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 ); | 27 | bool preDeviceSection( ANetNode * NN ); |
28 | bool postDeviceSection( ANetNodeInstance * NNI, long DevNr ); | 28 | bool postDeviceSection( ANetNode * NN ); |
29 | 29 | ||
30 | private : | 30 | private : |
31 | 31 | ||
32 | QString Name; | 32 | QString Name; |
33 | QString Path; | 33 | QString Path; |
34 | QFile * F; | 34 | QFile * F; |
35 | bool hasPreSection; | 35 | bool hasPreSection; |
36 | bool hasPostSection; | 36 | bool hasPostSection; |
37 | bool hasPreNodeSection; | 37 | bool hasPreNodeSection; |
38 | bool hasPostNodeSection; | 38 | bool hasPostNodeSection; |
39 | bool hasPreDeviceSection; | 39 | bool hasPreDeviceSection; |
40 | bool hasPostDeviceSection; | 40 | bool hasPostDeviceSection; |
41 | 41 | ||
42 | }; | 42 | }; |
43 | #endif | 43 | #endif |
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index 6541596..eb63e02 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp | |||
@@ -68,524 +68,473 @@ void NetworkSettingsData::loadSettings( void ) { | |||
68 | 68 | ||
69 | if( S == "connection" ) { | 69 | if( S == "connection" ) { |
70 | // load connections -> collections of nodes | 70 | // load connections -> collections of nodes |
71 | NodeCollection * NC = new NodeCollection( TS ); | 71 | NodeCollection * NC = new NodeCollection( TS ); |
72 | NSResources->addConnection( NC ); | 72 | NSResources->addConnection( NC ); |
73 | } else { | 73 | } else { |
74 | // load nodes | 74 | // load nodes |
75 | NNI = NSResources->createNodeInstance( S ); | 75 | NNI = NSResources->createNodeInstance( S ); |
76 | if( ! NNI ) { | 76 | if( ! NNI ) { |
77 | printf( "SKIPPING %s\n", S.latin1() ); | 77 | printf( "SKIPPING %s\n", S.latin1() ); |
78 | } | 78 | } |
79 | 79 | ||
80 | do { | 80 | do { |
81 | S = TS.readLine(); | 81 | S = TS.readLine(); |
82 | if( S.isEmpty() ) { | 82 | if( S.isEmpty() ) { |
83 | // empty line | 83 | // empty line |
84 | break; | 84 | break; |
85 | } | 85 | } |
86 | // node found ? | 86 | // node found ? |
87 | if( NNI ) { | 87 | if( NNI ) { |
88 | idx = S.find( '=' ); | 88 | idx = S.find( '=' ); |
89 | if( idx > 0 ) { | 89 | if( idx > 0 ) { |
90 | Attr = S.left( idx ); | 90 | Attr = S.left( idx ); |
91 | Value = S.mid( idx+1, S.length() ); | 91 | Value = S.mid( idx+1, S.length() ); |
92 | } else { | 92 | } else { |
93 | Value=""; | 93 | Value=""; |
94 | Attr = S; | 94 | Attr = S; |
95 | } | 95 | } |
96 | 96 | ||
97 | Value.stripWhiteSpace(); | 97 | Value.stripWhiteSpace(); |
98 | Attr.stripWhiteSpace(); | 98 | Attr.stripWhiteSpace(); |
99 | Attr.lower(); | 99 | Attr.lower(); |
100 | // dequote Attr | 100 | // dequote Attr |
101 | Value = deQuote(Value); | 101 | Value = deQuote(Value); |
102 | 102 | ||
103 | // set the attribute | 103 | // set the attribute |
104 | NNI->setAttribute( Attr, Value ); | 104 | NNI->setAttribute( Attr, Value ); |
105 | } | 105 | } |
106 | 106 | ||
107 | } while( 1 ); | 107 | } while( 1 ); |
108 | if( NNI ) { | 108 | if( NNI ) { |
109 | // loading from file -> exists | 109 | // loading from file -> exists |
110 | NNI->setNew( FALSE ); | 110 | NNI->setNew( FALSE ); |
111 | NSResources->addNodeInstance( NNI ); | 111 | NSResources->addNodeInstance( NNI ); |
112 | } | 112 | } |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | } while( 0 ); | 116 | } while( 0 ); |
117 | 117 | ||
118 | } | 118 | } |
119 | 119 | ||
120 | QString NetworkSettingsData::saveSettings( void ) { | 120 | QString NetworkSettingsData::saveSettings( void ) { |
121 | QString ErrS = ""; | 121 | QString ErrS = ""; |
122 | 122 | ||
123 | if( ! isModified() ) | 123 | if( ! isModified() ) |
124 | return ErrS; | 124 | return ErrS; |
125 | 125 | ||
126 | QString S; | 126 | QString S; |
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->nodeClass()->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 | fprintf( stderr, "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 | AsDevice * CurDev; |
192 | ANetNode * CurDevNN; | ||
192 | bool needToRegenerate = ForceIt; | 193 | bool needToRegenerate = ForceIt; |
193 | 194 | ||
194 | // | 195 | // |
195 | // check if we need to generate at least one of the system files | 196 | // check if we need to generate at least one of the system files |
196 | // | 197 | // |
197 | if( ! ForceIt ) { | 198 | if( ! ForceIt ) { |
198 | for( QDictIterator<SystemFile> sfit(SFM); | 199 | for( QDictIterator<SystemFile> sfit(SFM); |
199 | sfit.current(); | 200 | sfit.current(); |
200 | ++sfit ) { | 201 | ++sfit ) { |
201 | SF = sfit.current(); | 202 | SF = sfit.current(); |
202 | 203 | ||
203 | // check if there are nodes that are modified and require | 204 | // check if there are nodes that are modified and require |
204 | // data for this system file | 205 | // data for this system file |
205 | 206 | ||
206 | // for all connections | 207 | // for all connections |
207 | for( QDictIterator<NodeCollection> ncit(M); | 208 | for( QDictIterator<NodeCollection> ncit(M); |
208 | ncit.current(); | 209 | ncit.current(); |
209 | ++ncit ) { | 210 | ++ncit ) { |
210 | NC = ncit.current(); | 211 | NC = ncit.current(); |
211 | 212 | ||
212 | if( NC->isModified() ) { | 213 | if( NC->isModified() ) { |
213 | // does this connection 'touch' this system file ? | 214 | // does this connection 'touch' this system file ? |
214 | for( QListIterator<ANetNodeInstance> cncit(*NC); | 215 | for( QListIterator<ANetNodeInstance> cncit(*NC); |
215 | cncit.current(); | 216 | cncit.current(); |
216 | ++cncit ) { | 217 | ++cncit ) { |
217 | NNI = cncit.current(); | 218 | NNI = cncit.current(); |
218 | if( ( NNI->netNode()->hasDataFor( SF->name(), 1 ) || | 219 | if( ( NNI->nodeClass()->hasDataFor( SF->name() ) || |
219 | NNI->netNode()->hasDataFor( SF->name(), 0 ) | 220 | NNI->hasDataFor( SF->name() ) |
220 | ) && | 221 | ) && |
221 | NNI->isModified() ) { | 222 | NNI->isModified() ) { |
222 | needToRegenerate = 1; | 223 | needToRegenerate = 1; |
223 | break; | 224 | break; |
224 | } | 225 | } |
225 | } | 226 | } |
226 | } | 227 | } |
227 | if( needToRegenerate ) | 228 | if( needToRegenerate ) |
228 | break; | 229 | break; |
229 | } | 230 | } |
230 | if( needToRegenerate ) | 231 | if( needToRegenerate ) |
231 | break; | 232 | break; |
232 | } | 233 | } |
233 | } | 234 | } |
234 | 235 | ||
235 | // we cannot renumber with a FORCE request since | 236 | // we cannot renumber with a FORCE request since |
236 | // we probably are NOT going to save the config | 237 | // we probably are NOT going to save the config |
237 | // e.g. when using --regen option | 238 | // e.g. when using --regen option |
238 | if( ! ForceReq && needToRegenerate ) { | 239 | if( ! ForceReq && needToRegenerate ) { |
239 | NSResources->renumberConnections(); | 240 | NSResources->renumberConnections(); |
240 | setModified(1); | 241 | setModified(1); |
241 | } | 242 | } |
242 | 243 | ||
243 | // | 244 | // |
244 | // generate files proper to each netnodeinstance | 245 | // generate files proper to each netnodeinstance |
245 | // | 246 | // |
246 | { Name2Instance_t & NNIs = NSResources->netNodeInstances(); | 247 | { Name2Instance_t & NNIs = NSResources->netNodeInstances(); |
247 | 248 | ||
248 | for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); | 249 | for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); |
249 | NNIIt.current(); | 250 | NNIIt.current(); |
250 | ++NNIIt | 251 | ++NNIIt |
251 | ){ | 252 | ){ |
252 | // for all nodes find those that are modified | 253 | // for all nodes find those that are modified |
253 | NNI = NNIIt.current(); | 254 | NNI = NNIIt.current(); |
254 | 255 | ||
255 | if( ForceIt || NNI->isModified() ) { | 256 | if( ForceIt || NNI->isModified() ) { |
256 | if( ! NNI->netNode()->generateProperFilesFor( NNI ) ) { | 257 | if( ! NNI->nodeClass()->generateProperFilesFor( NNI ) ) { |
257 | // problem generating | 258 | // problem generating |
258 | S = qApp->translate( "NetworkSettings", | 259 | S = qApp->translate( "NetworkSettings", |
259 | "<p>Cannot generate files proper to %1</p>" ). | 260 | "<p>Cannot generate files proper to \"%1\"</p>" ). |
260 | arg(NNI->netNode()->nodeName()) ; | 261 | arg(NNI->nodeClass()->nodeName()) ; |
261 | return S; | 262 | return S; |
262 | } | 263 | } |
263 | } | 264 | } |
264 | } | 265 | } |
265 | } | 266 | } |
266 | 267 | ||
267 | // | 268 | // |
268 | // generate all system files | 269 | // generate all system files |
269 | // | 270 | // |
270 | for( QDictIterator<SystemFile> sfit(SFM); | 271 | for( QDictIterator<SystemFile> sfit(SFM); |
271 | sfit.current(); | 272 | sfit.current(); |
272 | ++sfit ) { | 273 | ++sfit ) { |
273 | SF = sfit.current(); | 274 | SF = sfit.current(); |
274 | 275 | ||
275 | printf( "Generating %s\n", SF->name().latin1() ); | 276 | fprintf( stderr, "Generating %s\n", SF->name().latin1() ); |
276 | SF->open(); | 277 | SF->open(); |
277 | 278 | ||
278 | do { // so we can break; | 279 | do { // so we can break; |
279 | 280 | ||
280 | // global presection for this system file | 281 | // global presection for this system file |
281 | if( SF->preSection() ) { | 282 | if( SF->preSection() ) { |
282 | S = qApp->translate( "NetworkSettings", | 283 | S = qApp->translate( "NetworkSettings", |
283 | "<p>Error in preSection for file %1</p>" ). | 284 | "<p>Error in preSection for file \"%1\"</p>" ). |
284 | arg( SF->name() ); | 285 | arg( SF->name() ); |
285 | return S; | 286 | return S; |
286 | } | 287 | } |
287 | 288 | ||
288 | // find all netnodes and figure out if | 289 | // find all netnodes and figure out if |
289 | // for that node there are instances | 290 | // for that node there are instances |
290 | for( QDictIterator<NetNode_t> nnit( | 291 | for( QDictIterator<NetNode_t> nnit( |
291 | NSResources->netNodes() ); | 292 | NSResources->netNodes() ); |
292 | nnit.current(); | 293 | nnit.current(); |
293 | ++nnit ) { | 294 | ++nnit ) { |
294 | ANetNode * NN; | 295 | |
295 | 296 | CurDevNN = nnit.current()->NetNode; | |
296 | NN = nnit.current()->NetNode; | 297 | |
297 | 298 | // are there instances for this netnode ? | |
298 | // are there instances ? | 299 | NNI = 0; |
299 | NNI = 0; | 300 | for( QDictIterator<ANetNodeInstance> nniit( |
300 | for( QDictIterator<ANetNodeInstance> nniit( | 301 | NSResources->netNodeInstances() ); |
301 | NSResources->netNodeInstances() ); | 302 | nniit.current(); |
302 | nniit.current(); | 303 | ++nniit ) { |
303 | ++nniit ) { | 304 | if( nniit.current()->nodeClass() == CurDevNN ) { |
304 | if( nniit.current()->netNode() == NN ) { | 305 | NNI = nniit.current(); |
305 | NNI = nniit.current(); | 306 | break; |
306 | break; | ||
307 | } | ||
308 | } | 307 | } |
308 | } | ||
309 | 309 | ||
310 | if( ! NNI ) | 310 | if( ! NNI ) |
311 | // no instances | 311 | // no instances -> next netnode type |
312 | continue; | 312 | continue; |
313 | 313 | ||
314 | // has this node data for this system file ? | 314 | // has this node data for this system file ? |
315 | if( (CurDev = NNI->runtime()->asDevice() ) ) { | 315 | if( (CurDev = NNI->runtime()->asDevice() ) ) { |
316 | // generate start for this nodetype for all possible devices of this type | 316 | // generate start for this nodetype for all possible devices of this type |
317 | for( int i = 0; i < CurDev->count(); i ++ ) { | 317 | for( int i = 0; i < CurDevNN->instanceCount(); i ++ ) { |
318 | if( SF->preDeviceSection( NNI, i ) ) { | 318 | S = generateSystemFileNode( *SF, CurDev, NNI, i ); |
319 | S = qApp->translate( "NetworkSettings", | 319 | if( ! S.isEmpty() ) |
320 | "<p>Error in preDeviceSection for file %1 and node %2</p>" ). | ||
321 | arg( SF->name() ). | ||
322 | arg( NN->nodeName() ); | ||
323 | return S; | ||
324 | } | ||
325 | |||
326 | if( ! NN->hasDataFor( SF->name(), 1 ) ) { | ||
327 | if( NN->generateDeviceDataForCommonFile( *SF, i, NNI ) ) { | ||
328 | S = qApp->translate( "NetworkSettings", | ||
329 | "<p>Error in node part for file %1 and node %2</p>" ). | ||
330 | arg( SF->name() ). | ||
331 | arg( NN->nodeName() ); | ||
332 | return S; | ||
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(); | ||
364 | |||
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 ) ) { | ||
385 | S = qApp->translate( "NetworkSettings", | ||
386 | "<p>Error in preNodeSection for file %1 and node %2</p>" ). | ||
387 | arg( SF->name() ). | ||
388 | arg( NNI->netNode()->nodeName() ); | ||
389 | return S; | ||
390 | } | ||
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 | |||
410 | if( SF->postNodeSection( NNI, i ) ) { | ||
411 | S = qApp->translate( "NetworkSettings", | ||
412 | "<p>Error in postNodeSection for file %1 and node %2</p>" ). | ||
413 | arg( SF->name() ). | ||
414 | arg( NNI->netNode()->nodeName() ); | ||
415 | return S; | ||
416 | } | ||
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; | 320 | return S; |
472 | } | ||
473 | } | 321 | } |
474 | } else { | 322 | } else { |
475 | if( SF->postDeviceSection( NNI, -1 ) ) { | 323 | S = generateSystemFileNode( *SF, 0, NNI, -1 ); |
476 | S = qApp->translate( "NetworkSettings", | 324 | if( ! S.isEmpty() ) |
477 | "<p>Error in postDeviceSection for file %1 and node %2</p>" ). | ||
478 | arg( SF->name() ). | ||
479 | arg( NNI->netNode()->nodeName() ); | ||
480 | return S; | 325 | return S; |
481 | } | ||
482 | } | 326 | } |
483 | } | 327 | } |
484 | 328 | ||
485 | if( SF->postSection() ) { | 329 | if( SF->postSection() ) { |
486 | S = qApp->translate( "NetworkSettings", | 330 | S = qApp->translate( "NetworkSettings", |
487 | "<p>Error in postSection for file %1</p>" ). | 331 | "<p>Error in postSection for file \"%1\"</p>" ). |
488 | arg( SF->name() ); | 332 | arg( SF->name() ); |
489 | return S; | 333 | return S; |
490 | } | 334 | } |
491 | 335 | ||
492 | } while( 0 ); | 336 | } while( 0 ); |
493 | SF->close(); | 337 | SF->close(); |
494 | } | 338 | } |
495 | } | 339 | } |
496 | Force = 0; | 340 | Force = 0; |
497 | return S; | 341 | return S; |
498 | } | 342 | } |
499 | 343 | ||
500 | QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) { | 344 | QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) { |
501 | // collect connections that can work on top of this interface | 345 | // collect connections that can work on top of this interface |
502 | NodeCollection * NC; | 346 | NodeCollection * NC; |
503 | QList<NodeCollection> PossibleConnections; | 347 | QList<NodeCollection> PossibleConnections; |
504 | Name2Connection_t & M = NSResources->connections(); | 348 | Name2Connection_t & M = NSResources->connections(); |
505 | 349 | ||
506 | // for all connections | 350 | // for all connections |
507 | for( QDictIterator<NodeCollection> it(M); | 351 | for( QDictIterator<NodeCollection> it(M); |
508 | it.current(); | 352 | it.current(); |
509 | ++it ) { | 353 | ++it ) { |
510 | NC = it.current(); | 354 | NC = it.current(); |
511 | // check if this profile handles the requested interface | 355 | // check if this profile handles the requested interface |
512 | if( NC->handlesInterface( Interface ) && // if different Intf. | 356 | if( NC->handlesInterface( Interface ) && // if different Intf. |
513 | NC->state() != Disabled && // if not enabled | 357 | NC->state() != Disabled && // if not enabled |
514 | NC->state() != IsUp // if already used | 358 | NC->state() != IsUp // if already used |
515 | ) { | 359 | ) { |
516 | PossibleConnections.append( NC ); | 360 | PossibleConnections.append( NC ); |
517 | } | 361 | } |
518 | } | 362 | } |
519 | return PossibleConnections; | 363 | return PossibleConnections; |
520 | } | 364 | } |
521 | 365 | ||
522 | 366 | ||
523 | /* | 367 | /* |
524 | Called by the system to see if interface can be brought UP | 368 | Called by the system to see if interface can be brought UP |
525 | 369 | ||
526 | if allowed, echo Interface-allowed else Interface-disallowed | 370 | if allowed, echo Interface-allowed else Interface-disallowed |
527 | */ | 371 | */ |
528 | 372 | ||
529 | void NetworkSettingsData::canStart( const char * Interface ) { | 373 | void NetworkSettingsData::canStart( const char * Interface ) { |
530 | // load situation | 374 | // load situation |
531 | NodeCollection * NC = 0; | 375 | NodeCollection * NC = 0; |
532 | QList<NodeCollection> PossibleConnections; | 376 | QList<NodeCollection> PossibleConnections; |
533 | 377 | ||
534 | PossibleConnections = collectPossible( Interface ); | 378 | PossibleConnections = collectPossible( Interface ); |
535 | 379 | ||
536 | switch( PossibleConnections.count() ) { | 380 | switch( PossibleConnections.count() ) { |
537 | case 0 : // no connections | 381 | case 0 : // no connections |
538 | break; | 382 | break; |
539 | case 1 : // one connection | 383 | case 1 : // one connection |
540 | NC = PossibleConnections.first(); | 384 | NC = PossibleConnections.first(); |
541 | break; | 385 | break; |
542 | default : // need to ask user ? | 386 | default : // need to ask user ? |
543 | // are we connected to a server | 387 | // are we connected to a server |
544 | // system( "su %d networksettings2 --prompt %s\n", | 388 | // system( "su %d networksettings2 --prompt %s\n", |
545 | // "", Interface ); | 389 | // "", Interface ); |
546 | break; | 390 | break; |
547 | } | 391 | } |
548 | 392 | ||
549 | if( NC ) { | 393 | if( NC ) { |
550 | switch( NC->state() ) { | 394 | switch( NC->state() ) { |
551 | case Unchecked : | 395 | case Unchecked : |
552 | case Unknown : | 396 | case Unknown : |
553 | case Unavailable : | 397 | case Unavailable : |
554 | case Disabled : | 398 | case Disabled : |
555 | // this profile does not allow interface to be UP | 399 | // this profile does not allow interface to be UP |
556 | // -> try others | 400 | // -> try others |
557 | break; | 401 | break; |
558 | case Off : | 402 | case Off : |
559 | // try to UP the device | 403 | // try to UP the device |
560 | if( ! NC->setState( Activate ) ) { | 404 | if( ! NC->setState( Activate ) ) { |
561 | // cannot bring device Online -> try other alters | 405 | // cannot bring device Online -> try other alters |
562 | break; | 406 | break; |
563 | } | 407 | } |
564 | // FT | 408 | // FT |
565 | case Available : | 409 | case Available : |
566 | case IsUp : // also called for 'ifdown' | 410 | case IsUp : // also called for 'ifdown' |
567 | // device is ready -> done | 411 | // device is ready -> done |
568 | printf( "%s-c%d-allowed\n", Interface, NC->number() ); | 412 | printf( "%s-c%d-allowed\n", Interface, NC->number() ); |
569 | return; | 413 | return; |
570 | } | 414 | } |
571 | } else { | 415 | } else { |
572 | // if we come here no alternatives are possible | 416 | // if we come here no alternatives are possible |
573 | printf( "%s-cnn-disallowed\n", Interface ); | 417 | printf( "%s-cnn-disallowed\n", Interface ); |
574 | } | 418 | } |
575 | } | 419 | } |
576 | 420 | ||
577 | /* | 421 | /* |
578 | Called by the system to regenerate config files | 422 | Called by the system to regenerate config files |
579 | */ | 423 | */ |
580 | 424 | ||
581 | bool NetworkSettingsData::regenerate( void ) { | 425 | bool NetworkSettingsData::regenerate( void ) { |
582 | QString S; | 426 | QString S; |
583 | // load situation | 427 | // load situation |
584 | S = generateSettings( TRUE ); | 428 | S = generateSettings( TRUE ); |
585 | if( ! S.isEmpty() ) { | 429 | if( ! S.isEmpty() ) { |
586 | fprintf( stdout, "%s\n", S.latin1() ); | 430 | fprintf( stdout, "%s\n", S.latin1() ); |
587 | return 1; | 431 | return 1; |
588 | } | 432 | } |
589 | return 0; | 433 | return 0; |
590 | } | 434 | } |
591 | 435 | ||
436 | QString NetworkSettingsData::generateSystemFileNode( | ||
437 | SystemFile &SF, | ||
438 | AsDevice * CurDev, | ||
439 | ANetNodeInstance * DevNNI, | ||
440 | long DevInstNr ) { | ||
441 | |||
442 | QString S=""; | ||
443 | ANetNode * CurDevNN = DevNNI->nodeClass(); | ||
444 | Name2Connection_t & M = NSResources->connections(); | ||
445 | |||
446 | if( SF.preDeviceSection( CurDevNN ) ) { | ||
447 | S = qApp->translate( "NetworkSettings", | ||
448 | "<p>Error in preDeviceSection for file \"%1\" and nodetype \"%2\"</p>" ). | ||
449 | arg( SF.name() ). | ||
450 | arg( CurDevNN->nodeName() ); | ||
451 | return S; | ||
452 | } | ||
453 | |||
454 | if( CurDevNN->hasDataFor( SF.name() ) ) { | ||
455 | if( CurDevNN->generateDeviceDataForCommonFile( SF, DevInstNr ) ) { | ||
456 | S = qApp->translate( "NetworkSettings", | ||
457 | "<p>Error in node Device part for file \"%1\" and node \"%2\"</p>" ). | ||
458 | arg( SF.name() ). | ||
459 | arg( CurDevNN->nodeName() ); | ||
460 | return S; | ||
461 | } | ||
462 | } | ||
463 | |||
464 | if( CurDev ) | ||
465 | fprintf( stderr, "Cur %s\n", CurDevNN->nodeName().latin1() ); | ||
466 | else | ||
467 | fprintf( stderr, "Cur NO\n" ); | ||
468 | |||
469 | // now generate profile specific data for all | ||
470 | // connections working on a device of the current | ||
471 | // netnode type | ||
472 | for( QDictIterator<NodeCollection> ncit(M); | ||
473 | ncit.current(); | ||
474 | ++ncit ) { | ||
475 | NodeCollection * NC = ncit.current(); | ||
476 | |||
477 | // currenly only those connections that work on | ||
478 | // the current device (or on no device if no current) | ||
479 | AsDevice * Dev = NC->device(); | ||
480 | |||
481 | fprintf( stderr, "%s\n", Dev->netNode()->nodeName().latin1() ); | ||
482 | if( CurDev ) { | ||
483 | if( CurDevNN != Dev->netNode()->nodeClass() ) { | ||
484 | // other device type -> later | ||
485 | fprintf( stderr, "Other Dev type\n" ); | ||
486 | continue; | ||
487 | } | ||
488 | } else { | ||
489 | if( Dev ) { | ||
490 | // other | ||
491 | continue; | ||
492 | } | ||
493 | } | ||
494 | |||
495 | // generate 'entry' | ||
496 | if( SF.preNodeSection( DevNNI, DevInstNr ) ) { | ||
497 | S = qApp->translate( "NetworkSettings", | ||
498 | "<p>Error in preNodeSection for file \"%1\" and node \"%2\"</p>" ). | ||
499 | arg( SF.name() ). | ||
500 | arg( CurDevNN->nodeName() ); | ||
501 | return S; | ||
502 | } | ||
503 | |||
504 | // ask all nodes in connection | ||
505 | for( QListIterator<ANetNodeInstance> cncit(*NC); | ||
506 | cncit.current(); | ||
507 | ++cncit ) { | ||
508 | ANetNodeInstance * NNI = cncit.current(); | ||
509 | |||
510 | if( NNI->hasDataFor( SF.name() ) ) { | ||
511 | if( NNI->generateDataForCommonFile(SF,DevInstNr) ) { | ||
512 | S = qApp->translate( "NetworkSettings", | ||
513 | "<p>Error in node part for file \"%1\" and node \"%2\"</p>" ). | ||
514 | arg( SF.name() ). | ||
515 | arg( NNI->nodeClass()->nodeName() ); | ||
516 | return S; | ||
517 | } | ||
518 | } | ||
519 | } | ||
520 | |||
521 | if( SF.postNodeSection( DevNNI, DevInstNr ) ) { | ||
522 | S = qApp->translate( "NetworkSettings", | ||
523 | "<p>Error in postNodeSection for file \"%1\" and node \"%2\"</p>" ). | ||
524 | arg( SF.name() ). | ||
525 | arg( CurDevNN->nodeName() ); | ||
526 | return S; | ||
527 | } | ||
528 | SF << endl; | ||
529 | } | ||
530 | |||
531 | if( SF.postDeviceSection( CurDevNN ) ) { | ||
532 | S = qApp->translate( "NetworkSettings", | ||
533 | "<p>Error in postDeviceSection for file \"%1\" and node \"%2\"</p>" ). | ||
534 | arg( SF.name() ). | ||
535 | arg( CurDevNN->nodeName() ); | ||
536 | return S; | ||
537 | } | ||
538 | |||
539 | return S; | ||
540 | } | ||
diff --git a/noncore/settings/networksettings2/nsdata.h b/noncore/settings/networksettings2/nsdata.h index 55f8c71..b54df24 100644 --- a/noncore/settings/networksettings2/nsdata.h +++ b/noncore/settings/networksettings2/nsdata.h | |||
@@ -1,37 +1,42 @@ | |||
1 | #ifndef __NSDATA_H | 1 | #ifndef __NSDATA_H |
2 | #define __NSDATA_H | 2 | #define __NSDATA_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class NetworkSettingsData { | 6 | class NetworkSettingsData { |
7 | 7 | ||
8 | public : | 8 | public : |
9 | 9 | ||
10 | NetworkSettingsData( void ); | 10 | NetworkSettingsData( void ); |
11 | ~NetworkSettingsData( void ); | 11 | ~NetworkSettingsData( void ); |
12 | 12 | ||
13 | void loadSettings( void ); | 13 | void loadSettings( void ); |
14 | QString saveSettings( void ); | 14 | QString saveSettings( void ); |
15 | 15 | ||
16 | QString generateSettings( bool Force = FALSE ); | 16 | QString generateSettings( bool Force = FALSE ); |
17 | 17 | ||
18 | bool isModified( void ) | 18 | bool isModified( void ) |
19 | { return IsModified; } | 19 | { return IsModified; } |
20 | void setModified( bool m ) | 20 | void setModified( bool m ) |
21 | { IsModified = m; } | 21 | { IsModified = m; } |
22 | 22 | ||
23 | QList<NodeCollection> collectPossible( const char * Interface ); | 23 | QList<NodeCollection> collectPossible( const char * Interface ); |
24 | void canStart( const char * Interface ); | 24 | void canStart( const char * Interface ); |
25 | bool regenerate( void ); | 25 | bool regenerate( void ); |
26 | 26 | ||
27 | void forceGeneration( bool m ) | 27 | void forceGeneration( bool m ) |
28 | { Force = m; } | 28 | { Force = m; } |
29 | 29 | ||
30 | private : | 30 | private : |
31 | 31 | ||
32 | QString NetworkSettingsData::generateSystemFileNode( | ||
33 | SystemFile & SF, | ||
34 | AsDevice * CurDev, | ||
35 | ANetNodeInstance * DevNNI, | ||
36 | long DevInstNr ); | ||
32 | bool IsModified; | 37 | bool IsModified; |
33 | bool Force; | 38 | bool Force; |
34 | 39 | ||
35 | }; | 40 | }; |
36 | 41 | ||
37 | #endif | 42 | #endif |
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp index 51d17ec..b3f70c5 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp | |||
@@ -1,69 +1,62 @@ | |||
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 &, bool ) { | 47 | bool PPPNetNode::generateDeviceDataForCommonFile( |
48 | return 0; | ||
49 | } | ||
50 | |||
51 | bool PPPNetNode::generateDataForCommonFile( | ||
52 | SystemFile & , | 48 | SystemFile & , |
53 | long, | 49 | long ) { |
54 | ANetNodeInstance * ) { | ||
55 | return 1; | 50 | return 1; |
56 | } | 51 | } |
57 | 52 | ||
58 | bool PPPNetNode::generateDeviceDataForCommonFile( | 53 | QString PPPNetNode::genNic( long NicNr ) { |
59 | SystemFile & , | 54 | QString S; |
60 | long , | 55 | return S.sprintf( "ppp%ld", NicNr ); |
61 | ANetNodeInstance * ) { | ||
62 | return 1; | ||
63 | } | 56 | } |
64 | 57 | ||
65 | extern "C" { | 58 | extern "C" { |
66 | void create_plugin( QList<ANetNode> & PNN ) { | 59 | void create_plugin( QList<ANetNode> & PNN ) { |
67 | PNN.append( new PPPNetNode() ); | 60 | PNN.append( new PPPNetNode() ); |
68 | } | 61 | } |
69 | } | 62 | } |
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.h b/noncore/settings/networksettings2/ppp/ppp_NN.h index 8d56e7f..c33f281 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.h +++ b/noncore/settings/networksettings2/ppp/ppp_NN.h | |||
@@ -1,46 +1,47 @@ | |||
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, bool DS ); | 31 | virtual bool hasDataFor( const QString & ) |
32 | virtual bool generateDataForCommonFile( | 32 | { return 0; } |
33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | ||
34 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
35 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | 34 | SystemFile & SF, long DevNr ); |
35 | |||
36 | virtual QString genNic( long NicNr ); | ||
36 | 37 | ||
37 | private: | 38 | private: |
38 | 39 | ||
39 | }; | 40 | }; |
40 | 41 | ||
41 | extern "C" | 42 | extern "C" |
42 | { | 43 | { |
43 | void create_plugin( QList<ANetNode> & PNN ); | 44 | void create_plugin( QList<ANetNode> & PNN ); |
44 | }; | 45 | }; |
45 | 46 | ||
46 | #endif | 47 | #endif |
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp index d09ecf9..d0fd31c 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp | |||
@@ -52,64 +52,70 @@ void APPP::setSpecificAttribute( QString & A, QString & V ) { | |||
52 | } else if( A == "authclient" ) { | 52 | } else if( A == "authclient" ) { |
53 | Data.Auth.Client = V; | 53 | Data.Auth.Client = V; |
54 | } else if( A == "authserver" ) { | 54 | } else if( A == "authserver" ) { |
55 | Data.Auth.Server = V; | 55 | Data.Auth.Server = V; |
56 | } else if( A == "authsecret" ) { | 56 | } else if( A == "authsecret" ) { |
57 | Data.Auth.Secret = V; | 57 | Data.Auth.Secret = V; |
58 | } | 58 | } |
59 | } else if( A.startsWith( "ip" ) ) { | 59 | } else if( A.startsWith( "ip" ) ) { |
60 | if( A == "ipautomatic" ) { | 60 | if( A == "ipautomatic" ) { |
61 | Data.IP.IPAutomatic = (V == "yes"); | 61 | Data.IP.IPAutomatic = (V == "yes"); |
62 | } else if( A == "gwautomatic" ) { | 62 | } else if( A == "gwautomatic" ) { |
63 | Data.IP.GWAutomatic = (V == "yes"); | 63 | Data.IP.GWAutomatic = (V == "yes"); |
64 | } else if( A == "gwisdefault" ) { | 64 | } else if( A == "gwisdefault" ) { |
65 | Data.IP.GWIsDefault = (V == "yes"); | 65 | Data.IP.GWIsDefault = (V == "yes"); |
66 | } else if( A == "ipaddress" ) { | 66 | } else if( A == "ipaddress" ) { |
67 | Data.IP.IPAddress = V; | 67 | Data.IP.IPAddress = V; |
68 | } else if( A == "ipsubmask" ) { | 68 | } else if( A == "ipsubmask" ) { |
69 | Data.IP.IPSubMask = V; | 69 | Data.IP.IPSubMask = V; |
70 | } else if( A == "gwaddress" ) { | 70 | } else if( A == "gwaddress" ) { |
71 | Data.IP.GWAddress = V; | 71 | Data.IP.GWAddress = V; |
72 | } | 72 | } |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | void APPP::saveSpecificAttribute( QTextStream & TS ) { | 76 | void APPP::saveSpecificAttribute( QTextStream & TS ) { |
77 | TS << "dnsserverassigned=" << | 77 | TS << "dnsserverassigned=" << |
78 | ( ( Data.DNS.ServerAssigned ) ? "yes" : "no" ) << endl; | 78 | ( ( Data.DNS.ServerAssigned ) ? "yes" : "no" ) << endl; |
79 | TS << "dnsdomainname=" << Data.DNS.DomainName << endl; | 79 | TS << "dnsdomainname=" << Data.DNS.DomainName << endl; |
80 | for( unsigned int i = 0; i < Data.DNS.Servers.size(); i ++ ) { | 80 | for( unsigned int i = 0; i < Data.DNS.Servers.size(); i ++ ) { |
81 | TS << "dnsserver=" << *(Data.DNS.Servers[i]) << endl; | 81 | TS << "dnsserver=" << *(Data.DNS.Servers[i]) << endl; |
82 | } | 82 | } |
83 | TS << "authmode=" << Data.Auth.Mode << endl; | 83 | TS << "authmode=" << Data.Auth.Mode << endl; |
84 | TS << "authloginexpect=" << quote( Data.Auth.Login.Expect ) << endl; | 84 | TS << "authloginexpect=" << quote( Data.Auth.Login.Expect ) << endl; |
85 | TS << "authloginsend=" << quote( Data.Auth.Login.Send ) << endl; | 85 | TS << "authloginsend=" << quote( Data.Auth.Login.Send ) << endl; |
86 | TS << "authpasswordexpect=" << quote( Data.Auth.Password.Expect ) << endl; | 86 | TS << "authpasswordexpect=" << quote( Data.Auth.Password.Expect ) << endl; |
87 | TS << "authpasswordsend=" << quote( Data.Auth.Password.Send ) << endl; | 87 | TS << "authpasswordsend=" << quote( Data.Auth.Password.Send ) << endl; |
88 | TS << "authpcemode=" << Data.Auth.PCEMode << endl; | 88 | TS << "authpcemode=" << Data.Auth.PCEMode << endl; |
89 | TS << "authclient=" << Data.Auth.Client << endl; | 89 | TS << "authclient=" << Data.Auth.Client << endl; |
90 | TS << "authserver=" << Data.Auth.Server << endl; | 90 | TS << "authserver=" << Data.Auth.Server << endl; |
91 | TS << "authsecret=" << quote( Data.Auth.Secret ) << endl; | 91 | TS << "authsecret=" << quote( Data.Auth.Secret ) << endl; |
92 | TS << "ipautomatic=" << ( ( Data.IP.IPAutomatic ) ? "yes" : "no" ) << endl; | 92 | TS << "ipautomatic=" << ( ( Data.IP.IPAutomatic ) ? "yes" : "no" ) << endl; |
93 | TS << "gwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl; | 93 | TS << "gwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl; |
94 | TS << "gwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl; | 94 | TS << "gwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl; |
95 | TS << "ipaddress=" << Data.IP.IPAddress << endl; | 95 | TS << "ipaddress=" << Data.IP.IPAddress << endl; |
96 | TS << "ipsubmask=" << Data.IP.IPSubMask << endl; | 96 | TS << "ipsubmask=" << Data.IP.IPSubMask << endl; |
97 | TS << "gwaddress=" << Data.IP.GWAddress << endl; | 97 | TS << "gwaddress=" << Data.IP.GWAddress << endl; |
98 | } | 98 | } |
99 | 99 | ||
100 | QWidget * APPP::edit( QWidget * parent ) { | 100 | QWidget * APPP::edit( QWidget * parent ) { |
101 | GUI = new PPPEdit( parent ); | 101 | GUI = new PPPEdit( parent ); |
102 | GUI->showData( Data ); | 102 | GUI->showData( Data ); |
103 | return GUI; | 103 | return GUI; |
104 | } | 104 | } |
105 | 105 | ||
106 | QString APPP::acceptable( void ) { | 106 | QString APPP::acceptable( void ) { |
107 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 107 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
108 | } | 108 | } |
109 | 109 | ||
110 | void APPP::commit( void ) { | 110 | void APPP::commit( void ) { |
111 | if( GUI && GUI->commit( Data ) ) { | 111 | if( GUI && GUI->commit( Data ) ) { |
112 | setModified( 1 ); | 112 | setModified( 1 ); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | bool APPP::generateDataForCommonFile( | ||
117 | SystemFile & , | ||
118 | long) { | ||
119 | return 1; | ||
120 | } | ||
121 | |||
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.h b/noncore/settings/networksettings2/ppp/ppp_NNI.h index a17721a..989c2f0 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NNI.h +++ b/noncore/settings/networksettings2/ppp/ppp_NNI.h | |||
@@ -1,43 +1,48 @@ | |||
1 | #ifndef PPP_H | 1 | #ifndef PPP_H |
2 | #define PPP_H | 2 | #define PPP_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "pppdata.h" | 5 | #include "pppdata.h" |
6 | #include "ppprun.h" | 6 | #include "ppprun.h" |
7 | 7 | ||
8 | class PPPNetNode; | 8 | class PPPNetNode; |
9 | class PPPEdit; | 9 | class PPPEdit; |
10 | 10 | ||
11 | class APPP : public ANetNodeInstance { | 11 | class APPP : public ANetNodeInstance { |
12 | 12 | ||
13 | public : | 13 | public : |
14 | 14 | ||
15 | APPP( PPPNetNode * PNN ); | 15 | APPP( PPPNetNode * 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 PPPRun( this, Data ); | 23 | RT = new PPPRun( this, Data ); |
24 | return RT->runtimeInfo(); | 24 | return RT->runtimeInfo(); |
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 | virtual bool hasDataFor( const QString & ) | ||
31 | { return 0; } | ||
32 | |||
33 | virtual bool generateDataForCommonFile( | ||
34 | SystemFile & SF, long DevNr ); | ||
30 | protected : | 35 | protected : |
31 | 36 | ||
32 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 37 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
33 | virtual void saveSpecificAttribute( QTextStream & TS ); | 38 | virtual void saveSpecificAttribute( QTextStream & TS ); |
34 | 39 | ||
35 | private : | 40 | private : |
36 | 41 | ||
37 | PPPEdit * GUI; | 42 | PPPEdit * GUI; |
38 | PPPData Data; | 43 | PPPData Data; |
39 | PPPRun * RT; | 44 | PPPRun * RT; |
40 | 45 | ||
41 | }; | 46 | }; |
42 | 47 | ||
43 | #endif | 48 | #endif |
diff --git a/noncore/settings/networksettings2/ppp/ppprun.h b/noncore/settings/networksettings2/ppp/ppprun.h index 765aff2..af51fbe 100644 --- a/noncore/settings/networksettings2/ppp/ppprun.h +++ b/noncore/settings/networksettings2/ppp/ppprun.h | |||
@@ -1,49 +1,47 @@ | |||
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 ) | ||
16 | { QString S; return S.sprintf( "ppp%ld", NicNr ); } | ||
17 | 15 | ||
18 | virtual AsDevice * asDevice( void ) | 16 | virtual AsDevice * asDevice( void ) |
19 | { return (AsDevice *)this; } | 17 | { return (AsDevice *)this; } |
20 | virtual AsConnection * asConnection( void ) | 18 | virtual AsConnection * asConnection( void ) |
21 | { return (AsConnection *)this; } | 19 | { return (AsConnection *)this; } |
22 | 20 | ||
23 | virtual AsDevice * device( void ) | 21 | virtual AsDevice * device( void ) |
24 | { return (AsDevice *)this; } | 22 | { return (AsDevice *)this; } |
25 | 23 | ||
26 | virtual RuntimeInfo * runtimeInfo( void ) | 24 | virtual RuntimeInfo * runtimeInfo( void ) |
27 | { return ( AsConnection *)this; } | 25 | { return ( AsConnection *)this; } |
28 | 26 | ||
29 | protected : | 27 | protected : |
30 | 28 | ||
31 | void detectState( NodeCollection * NC ); | 29 | void detectState( NodeCollection * NC ); |
32 | bool setState( NodeCollection * NC, Action_t A ); | 30 | bool setState( NodeCollection * NC, Action_t A ); |
33 | bool canSetState( State_t S, Action_t A ) | 31 | bool canSetState( State_t S, Action_t A ) |
34 | { return AsDevice::connection()->findNext( | 32 | { return AsDevice::connection()->findNext( |
35 | AsDevice::netNode() )->runtime()->canSetState( S,A ); } | 33 | AsDevice::netNode() )->runtime()->canSetState( S,A ); } |
36 | 34 | ||
37 | bool handlesInterface( const QString & I ); | 35 | bool handlesInterface( const QString & I ); |
38 | 36 | ||
39 | private : | 37 | private : |
40 | 38 | ||
41 | bool isMyPPPDRunning( void ); | 39 | bool isMyPPPDRunning( void ); |
42 | bool isMyPPPUp( void ); | 40 | bool isMyPPPUp( void ); |
43 | 41 | ||
44 | PPPData_t * D; | 42 | PPPData_t * D; |
45 | QRegExp Pat; | 43 | QRegExp Pat; |
46 | 44 | ||
47 | }; | 45 | }; |
48 | 46 | ||
49 | #endif | 47 | #endif |
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp index fcf1ca6..7609cdc 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.cpp +++ b/noncore/settings/networksettings2/profile/profile_NN.cpp | |||
@@ -1,68 +1,56 @@ | |||
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 &, bool ) { | ||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | bool ProfileNetNode::generateDataForCommonFile( | ||
51 | SystemFile & , | ||
52 | long, | ||
53 | ANetNodeInstance * ) { | ||
54 | return 1; | ||
55 | } | ||
56 | |||
57 | bool ProfileNetNode::generateDeviceDataForCommonFile( | 46 | bool ProfileNetNode::generateDeviceDataForCommonFile( |
58 | SystemFile & , | 47 | SystemFile & , |
59 | long , | 48 | long ) { |
60 | ANetNodeInstance * ) { | ||
61 | return 1; | 49 | return 1; |
62 | } | 50 | } |
63 | 51 | ||
64 | extern "C" { | 52 | extern "C" { |
65 | void create_plugin( QList<ANetNode> & PNN ) { | 53 | void create_plugin( QList<ANetNode> & PNN ) { |
66 | PNN.append( new ProfileNetNode() ); | 54 | PNN.append( new ProfileNetNode() ); |
67 | } | 55 | } |
68 | } | 56 | } |
diff --git a/noncore/settings/networksettings2/profile/profile_NN.h b/noncore/settings/networksettings2/profile/profile_NN.h index b64a6dd..f7c2b22 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.h +++ b/noncore/settings/networksettings2/profile/profile_NN.h | |||
@@ -1,46 +1,45 @@ | |||
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, bool DS ); | 31 | virtual bool hasDataFor( const QString & ) |
32 | virtual bool generateDataForCommonFile( | 32 | { return 0; } |
33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | ||
34 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
35 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | 34 | SystemFile & SF, long DevNr); |
36 | 35 | ||
37 | private: | 36 | private: |
38 | 37 | ||
39 | }; | 38 | }; |
40 | 39 | ||
41 | extern "C" | 40 | extern "C" |
42 | { | 41 | { |
43 | void create_plugin( QList<ANetNode> & PNN ); | 42 | void create_plugin( QList<ANetNode> & PNN ); |
44 | }; | 43 | }; |
45 | 44 | ||
46 | #endif | 45 | #endif |
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.cpp b/noncore/settings/networksettings2/profile/profile_NNI.cpp index bc0118e..5b54aa4 100644 --- a/noncore/settings/networksettings2/profile/profile_NNI.cpp +++ b/noncore/settings/networksettings2/profile/profile_NNI.cpp | |||
@@ -1,48 +1,54 @@ | |||
1 | #include "profileedit.h" | 1 | #include "profileedit.h" |
2 | #include "profile_NNI.h" | 2 | #include "profile_NNI.h" |
3 | #include "profile_NN.h" | 3 | #include "profile_NN.h" |
4 | 4 | ||
5 | AProfile::AProfile( ProfileNetNode * PNN ) : ANetNodeInstance( PNN ) { | 5 | AProfile::AProfile( ProfileNetNode * PNN ) : ANetNodeInstance( PNN ) { |
6 | Data.Automatic = 1; | 6 | Data.Automatic = 1; |
7 | Data.Confirm = 0; | 7 | Data.Confirm = 0; |
8 | Data.Description = ""; | 8 | Data.Description = ""; |
9 | Data.Disabled = 0; | 9 | Data.Disabled = 0; |
10 | GUI = 0; | 10 | GUI = 0; |
11 | RT = 0; | 11 | RT = 0; |
12 | } | 12 | } |
13 | 13 | ||
14 | void AProfile::setSpecificAttribute( QString & Attr, QString & Value ) { | 14 | void AProfile::setSpecificAttribute( QString & Attr, QString & Value ) { |
15 | 15 | ||
16 | if ( Attr == "automatic" ) { | 16 | if ( Attr == "automatic" ) { |
17 | Data.Automatic = (Value=="yes"); | 17 | Data.Automatic = (Value=="yes"); |
18 | } else if ( Attr == "preconfirm" ) { | 18 | } else if ( Attr == "preconfirm" ) { |
19 | Data.Confirm = (Value=="yes"); | 19 | Data.Confirm = (Value=="yes"); |
20 | } else if ( Attr == "disabled" ) { | 20 | } else if ( Attr == "disabled" ) { |
21 | Data.Disabled = (Value=="yes"); | 21 | Data.Disabled = (Value=="yes"); |
22 | } else if ( Attr == "description" ) { | 22 | } else if ( Attr == "description" ) { |
23 | Data.Description = Value; | 23 | Data.Description = Value; |
24 | } | 24 | } |
25 | } | 25 | } |
26 | 26 | ||
27 | void AProfile::saveSpecificAttribute( QTextStream & TS ) { | 27 | void AProfile::saveSpecificAttribute( QTextStream & TS ) { |
28 | TS << "automatic=" << ((Data.Automatic) ? "yes" : "no") << endl; | 28 | TS << "automatic=" << ((Data.Automatic) ? "yes" : "no") << endl; |
29 | TS << "preconfirm=" << ((Data.Confirm) ? "yes" : "no") << endl; | 29 | TS << "preconfirm=" << ((Data.Confirm) ? "yes" : "no") << endl; |
30 | TS << "disabled=" << ((Data.Disabled) ? "yes" : "no") << endl; | 30 | TS << "disabled=" << ((Data.Disabled) ? "yes" : "no") << endl; |
31 | TS << "description=" << Data.Description << endl; | 31 | TS << "description=" << Data.Description << endl; |
32 | } | 32 | } |
33 | 33 | ||
34 | QWidget * AProfile::edit( QWidget * parent ) { | 34 | QWidget * AProfile::edit( QWidget * parent ) { |
35 | GUI = new ProfileEdit( parent, this ); | 35 | GUI = new ProfileEdit( parent, this ); |
36 | GUI->showData( Data ); | 36 | GUI->showData( Data ); |
37 | return GUI; | 37 | return GUI; |
38 | } | 38 | } |
39 | 39 | ||
40 | QString AProfile::acceptable( void ) { | 40 | QString AProfile::acceptable( void ) { |
41 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 41 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
42 | } | 42 | } |
43 | 43 | ||
44 | void AProfile::commit( void ) { | 44 | void AProfile::commit( void ) { |
45 | if( GUI && GUI->commit( Data ) ) | 45 | if( GUI && GUI->commit( Data ) ) |
46 | setModified( 1 ); | 46 | setModified( 1 ); |
47 | } | 47 | } |
48 | 48 | ||
49 | bool AProfile::generateDataForCommonFile( | ||
50 | SystemFile & , | ||
51 | long) { | ||
52 | return 1; | ||
53 | } | ||
54 | |||
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.h b/noncore/settings/networksettings2/profile/profile_NNI.h index dfeb178..2c2db7f 100644 --- a/noncore/settings/networksettings2/profile/profile_NNI.h +++ b/noncore/settings/networksettings2/profile/profile_NNI.h | |||
@@ -1,45 +1,51 @@ | |||
1 | #ifndef PROFILE_H | 1 | #ifndef PROFILE_H |
2 | #define PROFILE_H | 2 | #define PROFILE_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "profiledata.h" | 5 | #include "profiledata.h" |
6 | #include "profilerun.h" | 6 | #include "profilerun.h" |
7 | 7 | ||
8 | class ProfileNetNode; | 8 | class ProfileNetNode; |
9 | class ProfileEdit; | 9 | class ProfileEdit; |
10 | 10 | ||
11 | class AProfile : public ANetNodeInstance { | 11 | class AProfile : public ANetNodeInstance { |
12 | 12 | ||
13 | public : | 13 | public : |
14 | 14 | ||
15 | AProfile( ProfileNetNode * PNN ); | 15 | AProfile( ProfileNetNode * 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 | const QString & description( void ) | 21 | const QString & description( void ) |
22 | { return Data.Description; } | 22 | { return Data.Description; } |
23 | RuntimeInfo * runtime( void ) | 23 | RuntimeInfo * runtime( void ) |
24 | { if( RT == 0 ) | 24 | { if( RT == 0 ) |
25 | RT = new ProfileRun( this, Data ); | 25 | RT = new ProfileRun( this, Data ); |
26 | return RT; | 26 | return RT; |
27 | } | 27 | } |
28 | 28 | ||
29 | virtual void * data( void ) | 29 | virtual void * data( void ) |
30 | { return (void *)&Data; } | 30 | { return (void *)&Data; } |
31 | 31 | ||
32 | virtual bool hasDataFor( const QString & ) | ||
33 | { return 0; } | ||
34 | |||
35 | virtual bool generateDataForCommonFile( | ||
36 | SystemFile & SF, long DevNr); | ||
37 | |||
32 | protected : | 38 | protected : |
33 | 39 | ||
34 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 40 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
35 | virtual void saveSpecificAttribute( QTextStream & TS ); | 41 | virtual void saveSpecificAttribute( QTextStream & TS ); |
36 | 42 | ||
37 | private : | 43 | private : |
38 | 44 | ||
39 | ProfileEdit * GUI; | 45 | ProfileEdit * GUI; |
40 | ProfileData Data; | 46 | ProfileData Data; |
41 | ProfileRun * RT; | 47 | ProfileRun * RT; |
42 | 48 | ||
43 | }; | 49 | }; |
44 | 50 | ||
45 | #endif | 51 | #endif |
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp index be4a2bc..30c72db 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.cpp +++ b/noncore/settings/networksettings2/usb/usb_NN.cpp | |||
@@ -1,67 +1,71 @@ | |||
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, bool ) { | 45 | bool USBNetNode::hasDataFor( const QString & S ) { |
46 | return (S== "interfaces"); | 46 | return (S== "interfaces"); |
47 | } | 47 | } |
48 | 48 | ||
49 | bool USBNetNode::generateDataForCommonFile( | 49 | bool USBNetNode::generateDeviceDataForCommonFile( |
50 | SystemFile & S , | 50 | SystemFile & S , |
51 | long DevNr, | 51 | long DevNr ) { |
52 | ANetNodeInstance * NNI) { | 52 | QString NIC = genNic( DevNr ); |
53 | return ((AUSB *)NNI)->generateDataForCommonFile(S, DevNr); | 53 | |
54 | if( S.name() == "interfaces" ) { | ||
55 | // generate mapping stanza for this interface | ||
56 | S << "# check if " << NIC << " can be brought UP" << endl; | ||
57 | S << "mapping " << NIC << endl; | ||
58 | S << " script networksettings2-request" << endl << endl; | ||
59 | } | ||
60 | return 0; | ||
54 | } | 61 | } |
55 | 62 | ||
56 | bool USBNetNode::generateDeviceDataForCommonFile( | 63 | QString USBNetNode::genNic( long ) { |
57 | SystemFile & S , | 64 | return QString( "usbf" ); |
58 | long DevNr, | ||
59 | ANetNodeInstance * NNI) { | ||
60 | return ((AUSB *)NNI)->generateDeviceDataForCommonFile(S, DevNr); | ||
61 | } | 65 | } |
62 | 66 | ||
63 | extern "C" { | 67 | extern "C" { |
64 | void create_plugin( QList<ANetNode> & PNN ) { | 68 | void create_plugin( QList<ANetNode> & PNN ) { |
65 | PNN.append( new USBNetNode() ); | 69 | PNN.append( new USBNetNode() ); |
66 | } | 70 | } |
67 | } | 71 | } |
diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h index 8ff5289..ba22b1c 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.h +++ b/noncore/settings/networksettings2/usb/usb_NN.h | |||
@@ -1,46 +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, bool DeviceSpec ); | 31 | virtual bool hasDataFor( const QString & S); |
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | ||
34 | virtual bool generateDeviceDataForCommonFile( | 32 | virtual bool generateDeviceDataForCommonFile( |
35 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | 33 | SystemFile & SF, long DevNr ); |
34 | |||
35 | virtual QString genNic( long nr ); | ||
36 | 36 | ||
37 | private: | 37 | private: |
38 | 38 | ||
39 | }; | 39 | }; |
40 | 40 | ||
41 | extern "C" | 41 | extern "C" |
42 | { | 42 | { |
43 | void create_plugin( QList<ANetNode> & PNN ); | 43 | void create_plugin( QList<ANetNode> & PNN ); |
44 | }; | 44 | }; |
45 | 45 | ||
46 | #endif | 46 | #endif |
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.cpp b/noncore/settings/networksettings2/usb/usb_NNI.cpp index 6fcd6d5..e90204c 100644 --- a/noncore/settings/networksettings2/usb/usb_NNI.cpp +++ b/noncore/settings/networksettings2/usb/usb_NNI.cpp | |||
@@ -1,57 +1,52 @@ | |||
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::hasDataFor( const QString & S ) { |
36 | AsDevice * Dev = runtime()->device(); | 36 | return (S== "interfaces"); |
37 | QString NIC = Dev->genNic( DevNr ); | ||
38 | |||
39 | if( S.name() == "interfaces" ) { | ||
40 | // generate mapping stanza for this interface | ||
41 | S << " pre-up " << QPEApplication::qpeDir() << "bin/setmacaddress.sh " << NIC << " || true" << endl; | ||
42 | } | ||
43 | return 0; | ||
44 | } | 37 | } |
45 | 38 | ||
46 | bool AUSB::generateDeviceDataForCommonFile( SystemFile & S, long DevNr ) { | 39 | bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) { |
47 | AsDevice * Dev = runtime()->device(); | 40 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); |
48 | QString NIC = Dev->genNic( DevNr ); | ||
49 | 41 | ||
50 | if( S.name() == "interfaces" ) { | 42 | if( S.name() == "interfaces" ) { |
51 | // generate mapping stanza for this interface | 43 | // generate mapping stanza for this interface |
52 | S << "# check if " << NIC << " can be brought UP" << endl; | 44 | S << " pre-up " |
53 | S << "mapping " << NIC << endl; | 45 | << QPEApplication::qpeDir() |
54 | S << " script networksettings2-request" << endl << endl; | 46 | << "bin/setmacaddress.sh " |
47 | << NIC | ||
48 | << " || true" | ||
49 | << endl; | ||
55 | } | 50 | } |
56 | return 0; | 51 | return 0; |
57 | } | 52 | } |
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.h b/noncore/settings/networksettings2/usb/usb_NNI.h index 5dead36..d2ee217 100644 --- a/noncore/settings/networksettings2/usb/usb_NNI.h +++ b/noncore/settings/networksettings2/usb/usb_NNI.h | |||
@@ -1,45 +1,46 @@ | |||
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 | virtual bool hasDataFor( const QString & S); |
31 | bool generateDeviceDataForCommonFile( SystemFile & S, long DevNr ); | 31 | virtual bool generateDataForCommonFile( |
32 | SystemFile & SF, long DevNr ); | ||
32 | 33 | ||
33 | protected : | 34 | protected : |
34 | 35 | ||
35 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 36 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
36 | virtual void saveSpecificAttribute( QTextStream & TS ); | 37 | virtual void saveSpecificAttribute( QTextStream & TS ); |
37 | 38 | ||
38 | private : | 39 | private : |
39 | 40 | ||
40 | USBEdit * GUI; | 41 | USBEdit * GUI; |
41 | USBData Data; | 42 | USBData Data; |
42 | USBRun * RT; | 43 | USBRun * RT; |
43 | }; | 44 | }; |
44 | 45 | ||
45 | #endif | 46 | #endif |
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp index 3007e79..4ce6721 100644 --- a/noncore/settings/networksettings2/usb/usbrun.cpp +++ b/noncore/settings/networksettings2/usb/usbrun.cpp | |||
@@ -113,70 +113,64 @@ bool USBRun::setState( NodeCollection * NC, Action_t A ) { | |||
113 | return 1; | 113 | return 1; |
114 | default : | 114 | default : |
115 | // FT | 115 | // FT |
116 | break; | 116 | break; |
117 | } | 117 | } |
118 | return 0; | 118 | return 0; |
119 | } | 119 | } |
120 | 120 | ||
121 | bool USBRun::canSetState( State_t Curr, Action_t A ) { | 121 | bool USBRun::canSetState( State_t Curr, Action_t A ) { |
122 | // we only handle up down activate and deactivate | 122 | // we only handle up down activate and deactivate |
123 | switch( A ) { | 123 | switch( A ) { |
124 | case Activate : | 124 | case Activate : |
125 | { // at least available | 125 | { // at least available |
126 | if( Curr == Available ) { | 126 | if( Curr == Available ) { |
127 | return 1; | 127 | return 1; |
128 | } | 128 | } |
129 | // or we can make one available | 129 | // or we can make one available |
130 | InterfaceInfo * N = getInterface(); | 130 | InterfaceInfo * N = getInterface(); |
131 | if( ! N || N->assignedNode() != 0 ) { | 131 | if( ! N || N->assignedNode() != 0 ) { |
132 | // non available or assigned | 132 | // non available or assigned |
133 | return 0; | 133 | return 0; |
134 | } | 134 | } |
135 | return 1; | 135 | return 1; |
136 | } | 136 | } |
137 | case Deactivate : | 137 | case Deactivate : |
138 | return ( Curr >= Available ); | 138 | return ( Curr >= Available ); |
139 | default : | 139 | default : |
140 | // FT | 140 | // FT |
141 | break; | 141 | break; |
142 | } | 142 | } |
143 | return 0; | 143 | return 0; |
144 | } | 144 | } |
145 | 145 | ||
146 | // get interface that is free or assigned to us | 146 | // get interface that is free or assigned to us |
147 | InterfaceInfo * USBRun::getInterface( void ) { | 147 | InterfaceInfo * USBRun::getInterface( void ) { |
148 | 148 | ||
149 | System & S = NSResources->system(); | 149 | System & S = NSResources->system(); |
150 | InterfaceInfo * best = 0, * Run; | 150 | InterfaceInfo * best = 0, * Run; |
151 | QRegExp R( "usb[0-9abcdef]" ); | 151 | QRegExp R( "usb[0-9abcdef]" ); |
152 | 152 | ||
153 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | 153 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); |
154 | It.current(); | 154 | It.current(); |
155 | ++It ) { | 155 | ++It ) { |
156 | Run = It.current(); | 156 | Run = It.current(); |
157 | if( handlesInterface( Run->Name ) && | 157 | if( handlesInterface( Run->Name ) && |
158 | Run->CardType == ARPHRD_ETHER | 158 | Run->CardType == ARPHRD_ETHER |
159 | ) { | 159 | ) { |
160 | // this is a USB card | 160 | // this is a USB card |
161 | if( Run->assignedNode() == netNode() ) { | 161 | if( Run->assignedNode() == netNode() ) { |
162 | // assigned to us | 162 | // assigned to us |
163 | return Run; | 163 | return Run; |
164 | } else if( Run->assignedNode() == 0 ) { | 164 | } else if( Run->assignedNode() == 0 ) { |
165 | // free | 165 | // free |
166 | best = Run; | 166 | best = Run; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | } | 169 | } |
170 | return best; // can be 0 | 170 | return best; // can be 0 |
171 | } | 171 | } |
172 | 172 | ||
173 | bool USBRun::handlesInterface( const QString & S ) { | 173 | bool USBRun::handlesInterface( const QString & S ) { |
174 | return Pat.match( S ) >= 0; | 174 | return Pat.match( S ) >= 0; |
175 | } | 175 | } |
176 | 176 | ||
177 | QString USBRun::genNic( long nr ) { | ||
178 | QString S; | ||
179 | S.sprintf( "usbf" ); | ||
180 | return S; | ||
181 | } | ||
182 | |||
diff --git a/noncore/settings/networksettings2/usb/usbrun.h b/noncore/settings/networksettings2/usb/usbrun.h index 60f9fe8..6c6e4e4 100644 --- a/noncore/settings/networksettings2/usb/usbrun.h +++ b/noncore/settings/networksettings2/usb/usbrun.h | |||
@@ -1,41 +1,37 @@ | |||
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 ) | ||
19 | { return 1; } | ||
20 | virtual QString genNic( long nr ); | ||
21 | |||
22 | virtual AsDevice * device( void ) | 18 | virtual AsDevice * device( void ) |
23 | { return (AsDevice *)this; } | 19 | { return (AsDevice *)this; } |
24 | 20 | ||
25 | virtual AsDevice * asDevice( void ) | 21 | virtual AsDevice * asDevice( void ) |
26 | { return (AsDevice *)this; } | 22 | { return (AsDevice *)this; } |
27 | protected : | 23 | protected : |
28 | 24 | ||
29 | void detectState( NodeCollection * ); | 25 | void detectState( NodeCollection * ); |
30 | bool setState( NodeCollection * , Action_t A ); | 26 | bool setState( NodeCollection * , Action_t A ); |
31 | bool canSetState( State_t , Action_t A ); | 27 | bool canSetState( State_t , Action_t A ); |
32 | 28 | ||
33 | bool handlesInterface( const QString & I ); | 29 | bool handlesInterface( const QString & I ); |
34 | 30 | ||
35 | private : | 31 | private : |
36 | 32 | ||
37 | InterfaceInfo * getInterface( void ); | 33 | InterfaceInfo * getInterface( void ); |
38 | QRegExp Pat; | 34 | QRegExp Pat; |
39 | 35 | ||
40 | }; | 36 | }; |
41 | #endif | 37 | #endif |
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp index f570fb2..d9aa892 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp +++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp | |||
@@ -1,68 +1,56 @@ | |||
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 &, bool ) { | ||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | bool VPNNetNode::generateDataForCommonFile( | ||
51 | SystemFile & , | ||
52 | long, | ||
53 | ANetNodeInstance * ) { | ||
54 | return 1; | ||
55 | } | ||
56 | |||
57 | bool VPNNetNode::generateDeviceDataForCommonFile( | 46 | bool VPNNetNode::generateDeviceDataForCommonFile( |
58 | SystemFile & , | 47 | SystemFile & , |
59 | long , | 48 | long ) { |
60 | ANetNodeInstance * ) { | ||
61 | return 1; | 49 | return 1; |
62 | } | 50 | } |
63 | 51 | ||
64 | extern "C" { | 52 | extern "C" { |
65 | void create_plugin( QList<ANetNode> & PNN ) { | 53 | void create_plugin( QList<ANetNode> & PNN ) { |
66 | PNN.append( new VPNNetNode() ); | 54 | PNN.append( new VPNNetNode() ); |
67 | } | 55 | } |
68 | } | 56 | } |
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.h b/noncore/settings/networksettings2/vpn/vpn_NN.h index cdb5117..7ce8e3a 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.h +++ b/noncore/settings/networksettings2/vpn/vpn_NN.h | |||
@@ -1,46 +1,45 @@ | |||
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, bool DS ); | 31 | virtual bool hasDataFor( const QString & ) |
32 | virtual bool generateDataForCommonFile( | 32 | { return 0; } |
33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | ||
34 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
35 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | 34 | SystemFile & SF, long DevNr ); |
36 | 35 | ||
37 | private: | 36 | private: |
38 | 37 | ||
39 | }; | 38 | }; |
40 | 39 | ||
41 | extern "C" | 40 | extern "C" |
42 | { | 41 | { |
43 | void create_plugin( QList<ANetNode> & PNN ); | 42 | void create_plugin( QList<ANetNode> & PNN ); |
44 | }; | 43 | }; |
45 | 44 | ||
46 | #endif | 45 | #endif |
diff --git a/noncore/settings/networksettings2/vpn/vpn_NNI.cpp b/noncore/settings/networksettings2/vpn/vpn_NNI.cpp index 6c20aeb..ee999e8 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NNI.cpp +++ b/noncore/settings/networksettings2/vpn/vpn_NNI.cpp | |||
@@ -1,30 +1,36 @@ | |||
1 | #include "vpnedit.h" | 1 | #include "vpnedit.h" |
2 | #include "vpn_NNI.h" | 2 | #include "vpn_NNI.h" |
3 | #include "vpn_NN.h" | 3 | #include "vpn_NN.h" |
4 | 4 | ||
5 | AVPN::AVPN( VPNNetNode * PNN ) : ANetNodeInstance( PNN ) { | 5 | AVPN::AVPN( VPNNetNode * PNN ) : ANetNodeInstance( PNN ) { |
6 | GUI = 0; | 6 | GUI = 0; |
7 | RT = 0; | 7 | RT = 0; |
8 | } | 8 | } |
9 | 9 | ||
10 | void AVPN::setSpecificAttribute( QString & , QString & ) { | 10 | void AVPN::setSpecificAttribute( QString & , QString & ) { |
11 | } | 11 | } |
12 | 12 | ||
13 | void AVPN::saveSpecificAttribute( QTextStream & ) { | 13 | void AVPN::saveSpecificAttribute( QTextStream & ) { |
14 | } | 14 | } |
15 | 15 | ||
16 | QWidget * AVPN::edit( QWidget * parent ) { | 16 | QWidget * AVPN::edit( QWidget * parent ) { |
17 | GUI = new VPNEdit( parent ); | 17 | GUI = new VPNEdit( parent ); |
18 | GUI->showData( Data ); | 18 | GUI->showData( Data ); |
19 | return GUI; | 19 | return GUI; |
20 | } | 20 | } |
21 | 21 | ||
22 | QString AVPN::acceptable( void ) { | 22 | QString AVPN::acceptable( void ) { |
23 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 23 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
24 | } | 24 | } |
25 | 25 | ||
26 | void AVPN::commit( void ) { | 26 | void AVPN::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 AVPN::generateDataForCommonFile( | ||
32 | SystemFile & , | ||
33 | long) { | ||
34 | return 1; | ||
35 | } | ||
36 | |||
diff --git a/noncore/settings/networksettings2/vpn/vpn_NNI.h b/noncore/settings/networksettings2/vpn/vpn_NNI.h index 31ce0d6..c3eb016 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NNI.h +++ b/noncore/settings/networksettings2/vpn/vpn_NNI.h | |||
@@ -1,43 +1,47 @@ | |||
1 | #ifndef VPN_H | 1 | #ifndef VPN_H |
2 | #define VPN_H | 2 | #define VPN_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "vpndata.h" | 5 | #include "vpndata.h" |
6 | #include "vpnrun.h" | 6 | #include "vpnrun.h" |
7 | 7 | ||
8 | class VPNNetNode; | 8 | class VPNNetNode; |
9 | class VPNEdit; | 9 | class VPNEdit; |
10 | 10 | ||
11 | class AVPN : public ANetNodeInstance { | 11 | class AVPN : public ANetNodeInstance { |
12 | 12 | ||
13 | public : | 13 | public : |
14 | 14 | ||
15 | AVPN( VPNNetNode * PNN ); | 15 | AVPN( VPNNetNode * 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 VPNRun( this, Data ); | 23 | RT = new VPNRun( 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 | virtual bool hasDataFor( const QString & ) | ||
31 | { return 0; } | ||
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & SF, long DevNr ); | ||
30 | protected : | 34 | protected : |
31 | 35 | ||
32 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 36 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
33 | virtual void saveSpecificAttribute( QTextStream & TS ); | 37 | virtual void saveSpecificAttribute( QTextStream & TS ); |
34 | 38 | ||
35 | private : | 39 | private : |
36 | 40 | ||
37 | VPNEdit * GUI; | 41 | VPNEdit * GUI; |
38 | VPNData Data; | 42 | VPNData Data; |
39 | VPNRun * RT; | 43 | VPNRun * RT; |
40 | 44 | ||
41 | }; | 45 | }; |
42 | 46 | ||
43 | #endif | 47 | #endif |
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp index e1e20c0..4e59ac1 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp | |||
@@ -1,67 +1,72 @@ | |||
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 & S, bool DS ) { | 45 | bool WLanNetNode::hasDataFor( const QString & S ) { |
46 | return DS && S == "interfaces"; | 46 | return S == "interfaces"; |
47 | } | ||
48 | |||
49 | bool WLanNetNode::generateDataForCommonFile( | ||
50 | SystemFile &, | ||
51 | long , | ||
52 | ANetNodeInstance * ) { | ||
53 | return 1; | ||
54 | } | 47 | } |
55 | 48 | ||
56 | bool WLanNetNode::generateDeviceDataForCommonFile( | 49 | bool WLanNetNode::generateDeviceDataForCommonFile( |
57 | SystemFile & S, | 50 | SystemFile & S, |
58 | long DevNr, | 51 | long DevNr ) { |
59 | ANetNodeInstance * NNI ) { | 52 | QString NIC = genNic( DevNr ); |
60 | return ((AWLan *)NNI)->generateDeviceDataForCommonFile(S, DevNr); | 53 | |
54 | if( S.name() == "interfaces" ) { | ||
55 | // generate mapping stanza for this interface | ||
56 | S << "# check if " << NIC << " can be brought UP" << endl; | ||
57 | S << "mapping " << NIC << endl; | ||
58 | S << " script networksettings2-request" << endl << endl; | ||
59 | } | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | QString WLanNetNode::genNic( long nr ) { | ||
64 | QString S; | ||
65 | return S.sprintf( "wlan%ld", nr ); | ||
61 | } | 66 | } |
62 | 67 | ||
63 | extern "C" { | 68 | extern "C" { |
64 | void create_plugin( QList<ANetNode> & PNN ) { | 69 | void create_plugin( QList<ANetNode> & PNN ) { |
65 | PNN.append( new WLanNetNode() ); | 70 | PNN.append( new WLanNetNode() ); |
66 | } | 71 | } |
67 | } | 72 | } |
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.h b/noncore/settings/networksettings2/wlan/wlan_NN.h index 9111995..f27e71c 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.h +++ b/noncore/settings/networksettings2/wlan/wlan_NN.h | |||
@@ -1,46 +1,50 @@ | |||
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, bool DS ); | 31 | |
32 | virtual bool generateDataForCommonFile( | 32 | virtual bool hasDataFor( const QString & S ); |
33 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | ||
34 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
35 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); | 34 | SystemFile & SF, long DevNr ); |
35 | |||
36 | virtual long instanceCount( void ) | ||
37 | { return 2; } | ||
38 | |||
39 | virtual QString genNic( long ); | ||
36 | 40 | ||
37 | private: | 41 | private: |
38 | 42 | ||
39 | }; | 43 | }; |
40 | 44 | ||
41 | extern "C" | 45 | extern "C" |
42 | { | 46 | { |
43 | void create_plugin( QList<ANetNode> & PNN ); | 47 | void create_plugin( QList<ANetNode> & PNN ); |
44 | }; | 48 | }; |
45 | 49 | ||
46 | #endif | 50 | #endif |
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp index 8b948e0..78e756c 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp | |||
@@ -1,42 +1,36 @@ | |||
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 ) { | 31 | bool AWLan::generateDataForCommonFile( |
32 | AsDevice * Dev = runtime()->device(); | 32 | SystemFile &, |
33 | QString NIC = Dev->genNic( DevNr ); | 33 | long ) { |
34 | 34 | return 1; | |
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 | } | 35 | } |
36 | |||
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.h b/noncore/settings/networksettings2/wlan/wlan_NNI.h index e464c84..d861d13 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NNI.h +++ b/noncore/settings/networksettings2/wlan/wlan_NNI.h | |||
@@ -1,45 +1,47 @@ | |||
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 ); | 30 | virtual bool hasDataFor( const QString & ) |
31 | 31 | { return 0; } | |
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & SF, long DevNr ); | ||
32 | protected : | 34 | protected : |
33 | 35 | ||
34 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 36 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
35 | virtual void saveSpecificAttribute( QTextStream & TS ); | 37 | virtual void saveSpecificAttribute( QTextStream & TS ); |
36 | 38 | ||
37 | private : | 39 | private : |
38 | 40 | ||
39 | WLanEdit * GUI; | 41 | WLanEdit * GUI; |
40 | WLanData Data; | 42 | WLanData Data; |
41 | WLanRun * RT; | 43 | WLanRun * RT; |
42 | 44 | ||
43 | }; | 45 | }; |
44 | 46 | ||
45 | #endif | 47 | #endif |
diff --git a/noncore/settings/networksettings2/wlan/wlanrun.h b/noncore/settings/networksettings2/wlan/wlanrun.h index b853262..f46bcb7 100644 --- a/noncore/settings/networksettings2/wlan/wlanrun.h +++ b/noncore/settings/networksettings2/wlan/wlanrun.h | |||
@@ -1,44 +1,40 @@ | |||
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 ) | ||
18 | { return 2; } | ||
19 | virtual QString genNic( long nr ) | ||
20 | { QString S; return S.sprintf( "wlan%ld", nr ); } | ||
21 | virtual AsDevice * device( void ) | 17 | virtual AsDevice * device( void ) |
22 | { return (AsDevice *)this; } | 18 | { return (AsDevice *)this; } |
23 | virtual AsDevice * asDevice( void ) | 19 | virtual AsDevice * asDevice( void ) |
24 | { return (AsDevice *)this; } | 20 | { return (AsDevice *)this; } |
25 | 21 | ||
26 | protected : | 22 | protected : |
27 | 23 | ||
28 | void detectState( NodeCollection * ) | 24 | void detectState( NodeCollection * ) |
29 | { } | 25 | { } |
30 | 26 | ||
31 | bool setState( NodeCollection *, Action_t ) | 27 | bool setState( NodeCollection *, Action_t ) |
32 | { return 0; } | 28 | { return 0; } |
33 | 29 | ||
34 | bool canSetState( State_t, Action_t ) | 30 | bool canSetState( State_t, Action_t ) |
35 | { return 0; } | 31 | { return 0; } |
36 | 32 | ||
37 | bool handlesInterface( const QString & I ); | 33 | bool handlesInterface( const QString & I ); |
38 | 34 | ||
39 | private : | 35 | private : |
40 | 36 | ||
41 | QRegExp Pat; | 37 | QRegExp Pat; |
42 | }; | 38 | }; |
43 | 39 | ||
44 | #endif | 40 | #endif |