author | wimpie <wimpie> | 2004-04-05 22:58:06 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-04-05 22:58:06 (UTC) |
commit | 9aeac7cefc3c8baf32944e7275b57e0a0cde1515 (patch) (unidiff) | |
tree | dc8161657d98d0e97d5f29554cb35d9b57202c49 | |
parent | 1d958f56a9e1357c20e76d763579d4dc184978e0 (diff) | |
download | opie-9aeac7cefc3c8baf32944e7275b57e0a0cde1515.zip opie-9aeac7cefc3c8baf32944e7275b57e0a0cde1515.tar.gz opie-9aeac7cefc3c8baf32944e7275b57e0a0cde1515.tar.bz2 |
Add save of node specific config data
27 files changed, 224 insertions, 135 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp index 3d1aa69..4579e37 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp | |||
@@ -1,123 +1,143 @@ | |||
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 | InstanceCount = 7; // default | ||
19 | } | 20 | } |
20 | 21 | ||
21 | /** | 22 | /** |
22 | * Delete any interfaces that we own. | 23 | * Delete any interfaces that we own. |
23 | */ | 24 | */ |
24 | BluetoothBNEPNetNode::~BluetoothBNEPNetNode(){ | 25 | BluetoothBNEPNetNode::~BluetoothBNEPNetNode(){ |
25 | } | 26 | } |
26 | 27 | ||
27 | const QString BluetoothBNEPNetNode::nodeDescription(){ | 28 | const QString BluetoothBNEPNetNode::nodeDescription(){ |
28 | return tr("\ | 29 | return tr("\ |
29 | <p>Sets up a bluetooth link using the bluetooth Network profile.</p>\ | 30 | <p>Sets up a bluetooth link using the bluetooth Network profile.</p>\ |
30 | <p>Use this to connect two computing devices.</p>\ | 31 | <p>Use this to connect two computing devices.</p>\ |
31 | " | 32 | " |
32 | ); | 33 | ); |
33 | } | 34 | } |
34 | 35 | ||
35 | ANetNodeInstance * BluetoothBNEPNetNode::createInstance( void ) { | 36 | ANetNodeInstance * BluetoothBNEPNetNode::createInstance( void ) { |
36 | return new ABluetoothBNEP( this ); | 37 | return new ABluetoothBNEP( this ); |
37 | } | 38 | } |
38 | 39 | ||
39 | const char ** BluetoothBNEPNetNode::needs( void ) { | 40 | const char ** BluetoothBNEPNetNode::needs( void ) { |
40 | return BluetoothBNEPNeeds; | 41 | return BluetoothBNEPNeeds; |
41 | } | 42 | } |
42 | 43 | ||
43 | const char * BluetoothBNEPNetNode::provides( void ) { | 44 | const char * BluetoothBNEPNetNode::provides( void ) { |
44 | return "device"; | 45 | return "device"; |
45 | } | 46 | } |
46 | 47 | ||
47 | bool BluetoothBNEPNetNode::generateProperFilesFor( | 48 | bool BluetoothBNEPNetNode::generateProperFilesFor( |
48 | ANetNodeInstance * ) { | 49 | ANetNodeInstance * ) { |
49 | return 1; | 50 | return 1; |
50 | } | 51 | } |
51 | 52 | ||
52 | bool BluetoothBNEPNetNode::hasDataFor( const QString & S ) { | 53 | bool BluetoothBNEPNetNode::hasDataFor( const QString & S ) { |
53 | return S == "interfaces"; | 54 | return S == "interfaces"; |
54 | } | 55 | } |
55 | 56 | ||
56 | bool BluetoothBNEPNetNode::generateDeviceDataForCommonFile( | 57 | bool BluetoothBNEPNetNode::generateDeviceDataForCommonFile( |
57 | SystemFile & , | 58 | SystemFile & , |
58 | long ) { | 59 | long ) { |
59 | return 1; | 60 | return 1; |
60 | } | 61 | } |
61 | 62 | ||
62 | QString BluetoothBNEPNetNode::genNic( long nr ) { | 63 | QString BluetoothBNEPNetNode::genNic( long nr ) { |
63 | QString S; | 64 | QString S; |
64 | return S.sprintf( "bnep%ld", nr ); | 65 | return S.sprintf( "bnep%ld", nr ); |
65 | } | 66 | } |
66 | 67 | ||
68 | |||
69 | void BluetoothBNEPNetNode::setSpecificAttribute( QString & A, QString & V ) { | ||
70 | if( A == "interfacecount" ) { | ||
71 | InstanceCount = V.toLong(); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | void BluetoothBNEPNetNode::saveSpecificAttribute( QTextStream & TS) { | ||
76 | TS << "interfacecount=" | ||
77 | << InstanceCount | ||
78 | << endl; | ||
79 | } | ||
80 | |||
67 | // | 81 | // |
68 | // | 82 | // |
69 | // BLUETOOTH PAN/NAP node | 83 | // BLUETOOTH RFCOMM |
70 | // | 84 | // |
71 | // | 85 | // |
72 | 86 | ||
73 | static const char * BluetoothRFCOMMNeeds[] = | 87 | static const char * BluetoothRFCOMMNeeds[] = |
74 | { 0 | 88 | { 0 |
75 | }; | 89 | }; |
76 | 90 | ||
77 | BluetoothRFCOMMNetNode::BluetoothRFCOMMNetNode() : ANetNode() { | 91 | BluetoothRFCOMMNetNode::BluetoothRFCOMMNetNode() : ANetNode() { |
78 | } | 92 | } |
79 | 93 | ||
80 | BluetoothRFCOMMNetNode::~BluetoothRFCOMMNetNode(){ | 94 | BluetoothRFCOMMNetNode::~BluetoothRFCOMMNetNode(){ |
81 | } | 95 | } |
82 | 96 | ||
83 | const QString BluetoothRFCOMMNetNode::nodeDescription(){ | 97 | const QString BluetoothRFCOMMNetNode::nodeDescription(){ |
84 | return tr("\ | 98 | return tr("\ |
85 | <p>Sets up a bluetooth link using the bluetooth serial profile.</p>\ | 99 | <p>Sets up a bluetooth link using the bluetooth serial profile.</p>\ |
86 | <p>Use this to connect to a GSM.</p>\ | 100 | <p>Use this to connect to a GSM.</p>\ |
87 | " | 101 | " |
88 | ); | 102 | ); |
89 | } | 103 | } |
90 | 104 | ||
91 | ANetNodeInstance * BluetoothRFCOMMNetNode::createInstance( void ) { | 105 | ANetNodeInstance * BluetoothRFCOMMNetNode::createInstance( void ) { |
92 | return new ABluetoothRFCOMM( this ); | 106 | return new ABluetoothRFCOMM( this ); |
93 | } | 107 | } |
94 | 108 | ||
95 | const char ** BluetoothRFCOMMNetNode::needs( void ) { | 109 | const char ** BluetoothRFCOMMNetNode::needs( void ) { |
96 | return BluetoothRFCOMMNeeds; | 110 | return BluetoothRFCOMMNeeds; |
97 | } | 111 | } |
98 | 112 | ||
99 | const char * BluetoothRFCOMMNetNode::provides( void ) { | 113 | const char * BluetoothRFCOMMNetNode::provides( void ) { |
100 | return "line"; | 114 | return "line"; |
101 | } | 115 | } |
102 | 116 | ||
103 | bool BluetoothRFCOMMNetNode::generateProperFilesFor( | 117 | bool BluetoothRFCOMMNetNode::generateProperFilesFor( |
104 | ANetNodeInstance * ) { | 118 | ANetNodeInstance * ) { |
105 | return 0; | 119 | return 0; |
106 | } | 120 | } |
107 | 121 | ||
108 | bool BluetoothRFCOMMNetNode::hasDataFor( const QString & ) { | 122 | bool BluetoothRFCOMMNetNode::hasDataFor( const QString & ) { |
109 | return 0; | 123 | return 0; |
110 | } | 124 | } |
111 | 125 | ||
112 | bool BluetoothRFCOMMNetNode::generateDeviceDataForCommonFile( | 126 | bool BluetoothRFCOMMNetNode::generateDeviceDataForCommonFile( |
113 | SystemFile & , | 127 | SystemFile & , |
114 | long ) { | 128 | long ) { |
115 | return 0; | 129 | return 0; |
116 | } | 130 | } |
117 | 131 | ||
132 | void BluetoothRFCOMMNetNode::setSpecificAttribute( QString &, QString & ) { | ||
133 | } | ||
134 | |||
135 | void BluetoothRFCOMMNetNode::saveSpecificAttribute( QTextStream & ) { | ||
136 | } | ||
137 | |||
118 | extern "C" { | 138 | extern "C" { |
119 | void create_plugin( QList<ANetNode> & PNN ) { | 139 | void create_plugin( QList<ANetNode> & PNN ) { |
120 | PNN.append( new BluetoothBNEPNetNode() ); | 140 | PNN.append( new BluetoothBNEPNetNode() ); |
121 | PNN.append( new BluetoothRFCOMMNetNode() ); | 141 | PNN.append( new BluetoothRFCOMMNetNode() ); |
122 | } | 142 | } |
123 | } | 143 | } |
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h index 5cd6c52..882d2e3 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h | |||
@@ -1,79 +1,87 @@ | |||
1 | #ifndef BLUETOOTH_NETNODE_H | 1 | #ifndef BLUETOOTH_NETNODE_H |
2 | #define BLUETOOTH_NETNODE_H | 2 | #define BLUETOOTH_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class ABluetoothBNEP; | 6 | class ABluetoothBNEP; |
7 | 7 | ||
8 | class BluetoothBNEPNetNode : public ANetNode { | 8 | class BluetoothBNEPNetNode : public ANetNode { |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | BluetoothBNEPNetNode(); | 14 | BluetoothBNEPNetNode(); |
15 | virtual ~BluetoothBNEPNetNode(); | 15 | virtual ~BluetoothBNEPNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/bluetooth"; } | 18 | { return "Devices/bluetooth"; } |
19 | 19 | ||
20 | virtual const QString nodeName() | 20 | virtual const QString nodeName() |
21 | { return tr("Bluetooth PAN/NAP"); } | 21 | { return tr("Bluetooth PAN/NAP"); } |
22 | 22 | ||
23 | virtual const QString nodeDescription() ; | 23 | virtual const QString nodeDescription() ; |
24 | 24 | ||
25 | virtual ANetNodeInstance * createInstance( void ); | 25 | virtual ANetNodeInstance * createInstance( void ); |
26 | 26 | ||
27 | virtual const char ** needs( void ); | 27 | virtual const char ** needs( void ); |
28 | virtual const char * provides( void ); | 28 | virtual const char * provides( void ); |
29 | 29 | ||
30 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | 30 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); |
31 | virtual bool hasDataFor( const QString & S ); | 31 | virtual bool hasDataFor( const QString & S ); |
32 | virtual bool generateDeviceDataForCommonFile( | 32 | virtual bool generateDeviceDataForCommonFile( |
33 | SystemFile & , long DevNr ); | 33 | SystemFile & , long DevNr ); |
34 | 34 | ||
35 | virtual long instanceCount( void ) | 35 | virtual long instanceCount( void ) |
36 | { return 7; } | 36 | { return InstanceCount; } |
37 | virtual QString genNic( long ); | 37 | virtual QString genNic( long ); |
38 | 38 | ||
39 | private: | 39 | private: |
40 | 40 | ||
41 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | ||
42 | virtual void saveSpecificAttribute( QTextStream & TS ); | ||
43 | |||
44 | // number of interfaces for this device | ||
45 | long InstanceCount; | ||
46 | |||
41 | }; | 47 | }; |
42 | 48 | ||
43 | class BluetoothRFCOMMNetNode : public ANetNode { | 49 | class BluetoothRFCOMMNetNode : public ANetNode { |
44 | 50 | ||
45 | Q_OBJECT | 51 | Q_OBJECT |
46 | 52 | ||
47 | public: | 53 | public: |
48 | 54 | ||
49 | BluetoothRFCOMMNetNode(); | 55 | BluetoothRFCOMMNetNode(); |
50 | virtual ~BluetoothRFCOMMNetNode(); | 56 | virtual ~BluetoothRFCOMMNetNode(); |
51 | 57 | ||
52 | virtual const QString pixmapName() | 58 | virtual const QString pixmapName() |
53 | { return "Devices/bluetooth"; } | 59 | { return "Devices/bluetooth"; } |
54 | 60 | ||
55 | virtual const QString nodeName() | 61 | virtual const QString nodeName() |
56 | { return tr("Bluetooth serial link"); } | 62 | { return tr("Bluetooth serial link"); } |
57 | 63 | ||
58 | virtual const QString nodeDescription() ; | 64 | virtual const QString nodeDescription() ; |
59 | 65 | ||
60 | virtual ANetNodeInstance * createInstance( void ); | 66 | virtual ANetNodeInstance * createInstance( void ); |
61 | 67 | ||
62 | virtual const char ** needs( void ); | 68 | virtual const char ** needs( void ); |
63 | virtual const char * provides( void ); | 69 | virtual const char * provides( void ); |
64 | 70 | ||
65 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | 71 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); |
66 | virtual bool hasDataFor( const QString & S ); | 72 | virtual bool hasDataFor( const QString & S ); |
67 | virtual bool generateDeviceDataForCommonFile( | 73 | virtual bool generateDeviceDataForCommonFile( |
68 | SystemFile & , long ); | 74 | SystemFile & , long ); |
69 | 75 | ||
70 | private: | 76 | private: |
71 | 77 | ||
78 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | ||
79 | virtual void saveSpecificAttribute( QTextStream & TS ); | ||
72 | }; | 80 | }; |
73 | 81 | ||
74 | extern "C" | 82 | extern "C" |
75 | { | 83 | { |
76 | void create_plugin( QList<ANetNode> & PNN ); | 84 | void create_plugin( QList<ANetNode> & PNN ); |
77 | }; | 85 | }; |
78 | 86 | ||
79 | #endif | 87 | #endif |
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp index a6be4d5..dd41c1f 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.cpp +++ b/noncore/settings/networksettings2/cable/cable_NN.cpp | |||
@@ -1,54 +1,60 @@ | |||
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::generateDeviceDataForCommonFile( | 44 | bool CableNetNode::generateDeviceDataForCommonFile( |
45 | SystemFile & , | 45 | SystemFile & , |
46 | long ) { | 46 | long ) { |
47 | return 1; | 47 | return 1; |
48 | } | 48 | } |
49 | 49 | ||
50 | void CableNetNode::setSpecificAttribute( QString & , QString & ) { | ||
51 | } | ||
52 | |||
53 | void CableNetNode::saveSpecificAttribute( QTextStream & ) { | ||
54 | } | ||
55 | |||
50 | extern "C" { | 56 | extern "C" { |
51 | void create_plugin( QList<ANetNode> & PNN ) { | 57 | void create_plugin( QList<ANetNode> & PNN ) { |
52 | PNN.append( new CableNetNode() ); | 58 | PNN.append( new CableNetNode() ); |
53 | } | 59 | } |
54 | } | 60 | } |
diff --git a/noncore/settings/networksettings2/cable/cable_NN.h b/noncore/settings/networksettings2/cable/cable_NN.h index 83b98e0..b37f31a 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.h +++ b/noncore/settings/networksettings2/cable/cable_NN.h | |||
@@ -1,45 +1,47 @@ | |||
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 & ) | 31 | virtual bool hasDataFor( const QString & ) |
32 | { return 0; } | 32 | { return 0; } |
33 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
34 | SystemFile & SF, long DevNr); | 34 | SystemFile & SF, long DevNr); |
35 | 35 | ||
36 | private: | 36 | private: |
37 | 37 | ||
38 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | ||
39 | virtual void saveSpecificAttribute( QTextStream & TS ); | ||
38 | }; | 40 | }; |
39 | 41 | ||
40 | extern "C" | 42 | extern "C" |
41 | { | 43 | { |
42 | void create_plugin( QList<ANetNode> & PNN ); | 44 | void create_plugin( QList<ANetNode> & PNN ); |
43 | }; | 45 | }; |
44 | 46 | ||
45 | #endif | 47 | #endif |
diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp index 96327a5..49b7707 100644 --- a/noncore/settings/networksettings2/irda/irda_NN.cpp +++ b/noncore/settings/networksettings2/irda/irda_NN.cpp | |||
@@ -1,54 +1,60 @@ | |||
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::generateDeviceDataForCommonFile( | 44 | bool IRDANetNode::generateDeviceDataForCommonFile( |
45 | SystemFile & , | 45 | SystemFile & , |
46 | long ) { | 46 | long ) { |
47 | return 1; | 47 | return 1; |
48 | } | 48 | } |
49 | 49 | ||
50 | void IRDANetNode::setSpecificAttribute( QString & , QString & ) { | ||
51 | } | ||
52 | |||
53 | void IRDANetNode::saveSpecificAttribute( QTextStream & ) { | ||
54 | } | ||
55 | |||
50 | extern "C" { | 56 | extern "C" { |
51 | void create_plugin( QList<ANetNode> & PNN ) { | 57 | void create_plugin( QList<ANetNode> & PNN ) { |
52 | PNN.append( new IRDANetNode() ); | 58 | PNN.append( new IRDANetNode() ); |
53 | } | 59 | } |
54 | } | 60 | } |
diff --git a/noncore/settings/networksettings2/irda/irda_NN.h b/noncore/settings/networksettings2/irda/irda_NN.h index a5b6cc5..2dcef74 100644 --- a/noncore/settings/networksettings2/irda/irda_NN.h +++ b/noncore/settings/networksettings2/irda/irda_NN.h | |||
@@ -1,45 +1,47 @@ | |||
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 & ) | 31 | virtual bool hasDataFor( const QString & ) |
32 | { return 0; } | 32 | { return 0; } |
33 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
34 | SystemFile & SF, long DevNr ); | 34 | SystemFile & SF, long DevNr ); |
35 | 35 | ||
36 | private: | 36 | private: |
37 | 37 | ||
38 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | ||
39 | virtual void saveSpecificAttribute( QTextStream & TS ); | ||
38 | }; | 40 | }; |
39 | 41 | ||
40 | extern "C" | 42 | extern "C" |
41 | { | 43 | { |
42 | void create_plugin( QList<ANetNode> & PNN ); | 44 | void create_plugin( QList<ANetNode> & PNN ); |
43 | }; | 45 | }; |
44 | 46 | ||
45 | #endif | 47 | #endif |
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp index 480ddf9..ba1c1f8 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp +++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp | |||
@@ -1,72 +1,85 @@ | |||
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 | InstanceCount = 2; | ||
11 | } | 12 | } |
12 | 13 | ||
13 | /** | 14 | /** |
14 | * Delete any interfaces that we own. | 15 | * Delete any interfaces that we own. |
15 | */ | 16 | */ |
16 | LanCardNetNode::~LanCardNetNode(){ | 17 | LanCardNetNode::~LanCardNetNode(){ |
17 | } | 18 | } |
18 | 19 | ||
19 | const QString LanCardNetNode::nodeDescription(){ | 20 | const QString LanCardNetNode::nodeDescription(){ |
20 | return tr("\ | 21 | return tr("\ |
21 | <p>Sets up a wired regular LAN card.</p>\ | 22 | <p>Sets up a wired regular LAN card.</p>\ |
22 | <p>Use this to set up 10/100/1000 MBit LAN cards.</p>\ | 23 | <p>Use this to set up 10/100/1000 MBit LAN cards.</p>\ |
23 | " | 24 | " |
24 | ); | 25 | ); |
25 | } | 26 | } |
26 | 27 | ||
27 | ANetNodeInstance * LanCardNetNode::createInstance( void ) { | 28 | ANetNodeInstance * LanCardNetNode::createInstance( void ) { |
28 | return new ALanCard( this ); | 29 | return new ALanCard( this ); |
29 | } | 30 | } |
30 | 31 | ||
31 | 32 | ||
32 | const char ** LanCardNetNode::needs( void ) { | 33 | const char ** LanCardNetNode::needs( void ) { |
33 | return LanCardNeeds; | 34 | return LanCardNeeds; |
34 | } | 35 | } |
35 | 36 | ||
36 | const char * LanCardNetNode::provides( void ) { | 37 | const char * LanCardNetNode::provides( void ) { |
37 | return "device"; | 38 | return "device"; |
38 | } | 39 | } |
39 | 40 | ||
40 | bool LanCardNetNode::generateProperFilesFor( | 41 | bool LanCardNetNode::generateProperFilesFor( |
41 | ANetNodeInstance * ) { | 42 | ANetNodeInstance * ) { |
42 | return 1; | 43 | return 1; |
43 | } | 44 | } |
44 | 45 | ||
45 | bool LanCardNetNode::hasDataFor( const QString & S ) { | 46 | bool LanCardNetNode::hasDataFor( const QString & S ) { |
46 | return S == "interfaces"; | 47 | return S == "interfaces"; |
47 | } | 48 | } |
48 | 49 | ||
49 | bool LanCardNetNode::generateDeviceDataForCommonFile( | 50 | bool LanCardNetNode::generateDeviceDataForCommonFile( |
50 | SystemFile & S , | 51 | SystemFile & S , |
51 | long DevNr ) { | 52 | long DevNr ) { |
52 | QString NIC = genNic( DevNr ); | 53 | QString NIC = genNic( DevNr ); |
53 | 54 | ||
54 | if( S.name() == "interfaces" ) { | 55 | if( S.name() == "interfaces" ) { |
55 | // generate mapping stanza for this interface | 56 | // generate mapping stanza for this interface |
56 | S << "# check if " << NIC << " can be brought UP" << endl; | 57 | S << "# check if " << NIC << " can be brought UP" << endl; |
57 | S << "mapping " << NIC << endl; | 58 | S << "mapping " << NIC << endl; |
58 | S << " script networksettings2-request" << endl << endl; | 59 | S << " script networksettings2-request" << endl << endl; |
59 | } | 60 | } |
60 | return 0; | 61 | return 0; |
61 | } | 62 | } |
62 | 63 | ||
63 | QString LanCardNetNode::genNic( long nr ) { | 64 | QString LanCardNetNode::genNic( long nr ) { |
64 | QString S; | 65 | QString S; |
65 | return S.sprintf( "eth%ld", nr ); | 66 | return S.sprintf( "eth%ld", nr ); |
66 | } | 67 | } |
67 | 68 | ||
69 | void LanCardNetNode::setSpecificAttribute( QString & A, QString & V ) { | ||
70 | if( A == "interfacecount" ) { | ||
71 | InstanceCount = V.toLong(); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | void LanCardNetNode::saveSpecificAttribute( QTextStream & TS) { | ||
76 | TS << "interfacecount=" | ||
77 | << InstanceCount | ||
78 | << endl; | ||
79 | } | ||
80 | |||
68 | extern "C" { | 81 | extern "C" { |
69 | void create_plugin( QList<ANetNode> & PNN ) { | 82 | void create_plugin( QList<ANetNode> & PNN ) { |
70 | PNN.append( new LanCardNetNode() ); | 83 | PNN.append( new LanCardNetNode() ); |
71 | } | 84 | } |
72 | } | 85 | } |
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h index dcdd0da..5f2b25d 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.h +++ b/noncore/settings/networksettings2/lancard/lancard_NN.h | |||
@@ -1,49 +1,55 @@ | |||
1 | #ifndef LANCARD_NETNODE_H | 1 | #ifndef LANCARD_NETNODE_H |
2 | #define LANCARD_NETNODE_H | 2 | #define LANCARD_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class ALanCard; | 6 | class ALanCard; |
7 | 7 | ||
8 | class LanCardNetNode : public ANetNode{ | 8 | class LanCardNetNode : public ANetNode{ |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | LanCardNetNode(); | 14 | LanCardNetNode(); |
15 | virtual ~LanCardNetNode(); | 15 | virtual ~LanCardNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/card"; } | 18 | { return "Devices/card"; } |
19 | 19 | ||
20 | virtual const QString nodeName() | 20 | virtual const QString nodeName() |
21 | { return tr("LAN card"); } | 21 | { return tr("LAN card"); } |
22 | 22 | ||
23 | virtual const QString nodeDescription() ; | 23 | virtual const QString nodeDescription() ; |
24 | 24 | ||
25 | virtual ANetNodeInstance * createInstance( void ); | 25 | virtual ANetNodeInstance * createInstance( void ); |
26 | 26 | ||
27 | virtual const char ** needs( void ); | 27 | virtual const char ** needs( void ); |
28 | virtual const char * provides( void ); | 28 | virtual const char * provides( void ); |
29 | 29 | ||
30 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | 30 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); |
31 | virtual bool hasDataFor( const QString & S ); | 31 | virtual bool hasDataFor( const QString & S ); |
32 | virtual bool generateDeviceDataForCommonFile( | 32 | virtual bool generateDeviceDataForCommonFile( |
33 | SystemFile & SF, long DevNr ); | 33 | SystemFile & SF, long DevNr ); |
34 | 34 | ||
35 | virtual long instanceCount( void ) | 35 | virtual long instanceCount( void ) |
36 | { return 2; } | 36 | { return InstanceCount; } |
37 | 37 | ||
38 | virtual QString genNic( long ); | 38 | virtual QString genNic( long ); |
39 | 39 | ||
40 | private: | 40 | private: |
41 | 41 | ||
42 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | ||
43 | virtual void saveSpecificAttribute( QTextStream & TS ); | ||
44 | |||
45 | // number of interfaces for this device | ||
46 | long InstanceCount; | ||
47 | |||
42 | }; | 48 | }; |
43 | 49 | ||
44 | extern "C" | 50 | extern "C" |
45 | { | 51 | { |
46 | void create_plugin( QList<ANetNode> & PNN ); | 52 | void create_plugin( QList<ANetNode> & PNN ); |
47 | }; | 53 | }; |
48 | 54 | ||
49 | #endif | 55 | #endif |
diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp index 65b06ee..1cc8524 100644 --- a/noncore/settings/networksettings2/modem/modem_NN.cpp +++ b/noncore/settings/networksettings2/modem/modem_NN.cpp | |||
@@ -1,55 +1,61 @@ | |||
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::generateDeviceDataForCommonFile( | 45 | bool ModemNetNode::generateDeviceDataForCommonFile( |
46 | SystemFile & , | 46 | SystemFile & , |
47 | long ) { | 47 | long ) { |
48 | return 1; | 48 | return 1; |
49 | } | 49 | } |
50 | 50 | ||
51 | void ModemNetNode::setSpecificAttribute( QString & , QString & ) { | ||
52 | } | ||
53 | |||
54 | void ModemNetNode::saveSpecificAttribute( QTextStream & ) { | ||
55 | } | ||
56 | |||
51 | extern "C" { | 57 | extern "C" { |
52 | void create_plugin( QList<ANetNode> & PNN ) { | 58 | void create_plugin( QList<ANetNode> & PNN ) { |
53 | PNN.append( new ModemNetNode() ); | 59 | PNN.append( new ModemNetNode() ); |
54 | } | 60 | } |
55 | } | 61 | } |
diff --git a/noncore/settings/networksettings2/modem/modem_NN.h b/noncore/settings/networksettings2/modem/modem_NN.h index 49244b2..849f928 100644 --- a/noncore/settings/networksettings2/modem/modem_NN.h +++ b/noncore/settings/networksettings2/modem/modem_NN.h | |||
@@ -1,45 +1,47 @@ | |||
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 & ) | 31 | virtual bool hasDataFor( const QString & ) |
32 | { return 0; } | 32 | { return 0; } |
33 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
34 | SystemFile & SF, long DevNr ); | 34 | SystemFile & SF, long DevNr ); |
35 | 35 | ||
36 | private: | 36 | private: |
37 | 37 | ||
38 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | ||
39 | virtual void saveSpecificAttribute( QTextStream & TS ); | ||
38 | }; | 40 | }; |
39 | 41 | ||
40 | extern "C" | 42 | extern "C" |
41 | { | 43 | { |
42 | void create_plugin( QList<ANetNode> & PNN ); | 44 | void create_plugin( QList<ANetNode> & PNN ); |
43 | }; | 45 | }; |
44 | 46 | ||
45 | #endif | 47 | #endif |
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index 4a77e6a..d27d54a 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp | |||
@@ -1,56 +1,62 @@ | |||
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::generateDeviceDataForCommonFile( | 46 | bool NetworkNetNode::generateDeviceDataForCommonFile( |
47 | SystemFile & , | 47 | SystemFile & , |
48 | long ) { | 48 | long ) { |
49 | return 1; | 49 | return 1; |
50 | } | 50 | } |
51 | 51 | ||
52 | void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { | ||
53 | } | ||
54 | |||
55 | void NetworkNetNode::saveSpecificAttribute( QTextStream & ) { | ||
56 | } | ||
57 | |||
52 | extern "C" { | 58 | extern "C" { |
53 | void create_plugin( QList<ANetNode> & PNN ) { | 59 | void create_plugin( QList<ANetNode> & PNN ) { |
54 | PNN.append( new NetworkNetNode() ); | 60 | PNN.append( new NetworkNetNode() ); |
55 | } | 61 | } |
56 | } | 62 | } |
diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h index 59f0526..0f87e1b 100644 --- a/noncore/settings/networksettings2/network/network_NN.h +++ b/noncore/settings/networksettings2/network/network_NN.h | |||
@@ -1,45 +1,47 @@ | |||
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 & ) | 31 | virtual bool hasDataFor( const QString & ) |
32 | { return 0; } | 32 | { return 0; } |
33 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
34 | SystemFile & SF, long DevNr ); | 34 | SystemFile & SF, long DevNr ); |
35 | 35 | ||
36 | private: | 36 | private: |
37 | 37 | ||
38 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | ||
39 | virtual void saveSpecificAttribute( QTextStream & TS ); | ||
38 | }; | 40 | }; |
39 | 41 | ||
40 | extern "C" | 42 | extern "C" |
41 | { | 43 | { |
42 | void create_plugin( QList<ANetNode> & PNN ); | 44 | void create_plugin( QList<ANetNode> & PNN ); |
43 | }; | 45 | }; |
44 | 46 | ||
45 | #endif | 47 | #endif |
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index fcc6044..3691e5a 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp | |||
@@ -1,302 +1,299 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <time.h> | 2 | #include <time.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qpixmap.h> | 4 | #include <qpixmap.h> |
5 | 5 | ||
6 | #include "resources.h" | 6 | #include "resources.h" |
7 | #include "netnode.h" | 7 | #include "netnode.h" |
8 | 8 | ||
9 | #include "asdevice.h" | 9 | #include "asdevice.h" |
10 | #include "asline.h" | 10 | #include "asline.h" |
11 | #include "asconnection.h" | 11 | #include "asconnection.h" |
12 | #include "asfullsetup.h" | 12 | #include "asfullsetup.h" |
13 | 13 | ||
14 | QString & deQuote( QString & X ) { | 14 | QString & deQuote( QString & X ) { |
15 | if( X[0] == '"' ) { | 15 | if( X[0] == '"' ) { |
16 | // remove end and trailing "" and \x -> x | 16 | // remove end and trailing "" and \x -> x |
17 | QChar R; | 17 | QChar R; |
18 | long idx; | 18 | long idx; |
19 | idx = X.length()-1; | 19 | idx = X.length()-1; |
20 | X = X.mid( 1, idx ); | 20 | X = X.mid( 1, idx ); |
21 | 21 | ||
22 | idx = 0; | 22 | idx = 0; |
23 | while( ( idx = X.find( '\\', idx ) ) >= 0 ) { | 23 | while( ( idx = X.find( '\\', idx ) ) >= 0 ) { |
24 | R = X[idx+1]; | 24 | R = X[idx+1]; |
25 | X.replace( idx, 2, &R, 1 ); | 25 | X.replace( idx, 2, &R, 1 ); |
26 | } | 26 | } |
27 | X = X.left( X.length()-1 ); | 27 | X = X.left( X.length()-1 ); |
28 | } | 28 | } |
29 | return X; | 29 | return X; |
30 | } | 30 | } |
31 | 31 | ||
32 | QString quote( QString X ) { | 32 | QString quote( QString X ) { |
33 | if( X.find( QRegExp( "[ \n\"\\\t]" ) ) >= 0 ) { | 33 | if( X.find( QRegExp( "[ \n\"\\\t]" ) ) >= 0 ) { |
34 | // need to quote this | 34 | // need to quote this |
35 | QString OutString = "\""; | 35 | QString OutString = "\""; |
36 | 36 | ||
37 | X.replace( QRegExp("\""), "\\\"" ); | 37 | X.replace( QRegExp("\""), "\\\"" ); |
38 | X.replace( QRegExp("\\"), "\\\\" ); | 38 | X.replace( QRegExp("\\"), "\\\\" ); |
39 | X.replace( QRegExp(" "), "\\ " ); | 39 | X.replace( QRegExp(" "), "\\ " ); |
40 | 40 | ||
41 | OutString += X; | 41 | OutString += X; |
42 | OutString += "\""; | 42 | OutString += "\""; |
43 | X = OutString; | 43 | X = OutString; |
44 | } | 44 | } |
45 | return X; | 45 | return X; |
46 | } | 46 | } |
47 | 47 | ||
48 | |||
49 | // | ||
50 | // | ||
51 | // ANETNODE | ||
48 | // | 52 | // |
49 | // | 53 | // |
54 | |||
55 | void ANetNode::saveAttributes( QTextStream & TS ) { | ||
56 | saveSpecificAttribute( TS ); | ||
57 | } | ||
58 | |||
59 | void ANetNode::setAttribute( QString & Attr, QString & Value ){ | ||
60 | setSpecificAttribute( Attr, Value ); | ||
61 | } | ||
62 | |||
63 | // | ||
50 | // | 64 | // |
65 | // ANETNODEINSTANCE | ||
51 | // | 66 | // |
52 | // | 67 | // |
53 | 68 | ||
54 | long ANetNodeInstance::InstanceCounter = -1; | 69 | long ANetNodeInstance::InstanceCounter = -1; |
55 | 70 | ||
56 | void ANetNodeInstance::initialize( void ) { | 71 | void ANetNodeInstance::initialize( void ) { |
57 | if( InstanceCounter == -1 ) | 72 | if( InstanceCounter == -1 ) |
58 | InstanceCounter = time(0); | 73 | InstanceCounter = time(0); |
59 | // set name | 74 | // set name |
60 | QString N; | 75 | QString N; |
61 | N.sprintf( "-%ld", InstanceCounter++ ); | 76 | N.sprintf( "-%ld", InstanceCounter++ ); |
62 | N.prepend( NodeType->nodeName() ); | 77 | N.prepend( NodeType->nodeName() ); |
63 | setNodeName( N ); | 78 | setNodeName( N ); |
64 | } | 79 | } |
65 | 80 | ||
66 | void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ | 81 | void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ |
67 | if( Attr == "name" ) { | 82 | if( Attr == "name" ) { |
68 | NodeName = Value; | 83 | NodeName = Value; |
69 | } else { | 84 | } else { |
70 | setSpecificAttribute( Attr, Value ); | 85 | setSpecificAttribute( Attr, Value ); |
71 | } | 86 | } |
72 | } | 87 | } |
73 | 88 | ||
74 | void ANetNodeInstance::saveAttributes( QTextStream & TS ) { | 89 | void ANetNodeInstance::saveAttributes( QTextStream & TS ) { |
75 | TS << "name=" << quote( NodeName ) << endl; | 90 | TS << "name=" << quote( NodeName ) << endl; |
76 | saveSpecificAttribute( TS ); | 91 | saveSpecificAttribute( TS ); |
77 | } | 92 | } |
78 | 93 | ||
79 | ANetNodeInstance * ANetNodeInstance::nextNode( void ) { | 94 | ANetNodeInstance * ANetNodeInstance::nextNode( void ) { |
80 | return connection()->findNext( this ); | 95 | return connection()->findNext( this ); |
81 | } | 96 | } |
82 | 97 | ||
83 | // | 98 | // |
84 | // | 99 | // |
85 | // | 100 | // NODECOLLECTION |
86 | // | 101 | // |
87 | // | 102 | // |
88 | 103 | ||
89 | long NodeCollection::MaxNr = -1; | 104 | long NodeCollection::MaxNr = -1; |
90 | 105 | ||
91 | NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { | 106 | NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { |
92 | IsModified = 0; | 107 | IsModified = 0; |
93 | Index = -1; | 108 | Index = -1; |
94 | Name=""; | 109 | Name=""; |
95 | IsNew = 1; | 110 | IsNew = 1; |
96 | CurrentState = Unchecked; | 111 | CurrentState = Unchecked; |
97 | } | 112 | } |
98 | 113 | ||
99 | NodeCollection::NodeCollection( QTextStream & TS ) : | 114 | NodeCollection::NodeCollection( QTextStream & TS ) : |
100 | QList<ANetNodeInstance>() { | 115 | QList<ANetNodeInstance>() { |
101 | long idx; | 116 | long idx; |
102 | bool InError = 0; | 117 | bool InError = 0; |
103 | QString S, A, N; | 118 | QString S, A, N; |
104 | IsModified = 0; | 119 | IsModified = 0; |
105 | Index = -1; | 120 | Index = -1; |
106 | Name=""; | 121 | Name=""; |
107 | IsNew = 0; | 122 | IsNew = 0; |
108 | CurrentState = Unchecked; | 123 | CurrentState = Unchecked; |
109 | 124 | ||
110 | do { | 125 | do { |
111 | S = TS.readLine(); | 126 | S = TS.readLine(); |
112 | if( S.isEmpty() ) { | 127 | if( S.isEmpty() ) { |
113 | if( InError ) { | 128 | if( InError ) { |
114 | // remove all nodes | 129 | // remove all nodes |
115 | clear(); | 130 | clear(); |
116 | } | 131 | } |
117 | // empty line | 132 | // empty line |
118 | break; | 133 | break; |
119 | } | 134 | } |
120 | 135 | ||
121 | idx = S.find('='); | 136 | idx = S.find('='); |
122 | S.stripWhiteSpace(); | 137 | S.stripWhiteSpace(); |
123 | A = S.left( idx ); | 138 | A = S.left( idx ); |
124 | A.lower(); | 139 | A.lower(); |
125 | N = S.mid( idx+1, S.length() ); | 140 | N = S.mid( idx+1, S.length() ); |
126 | N.stripWhiteSpace(); | 141 | N.stripWhiteSpace(); |
127 | N = deQuote( N ); | 142 | N = deQuote( N ); |
128 | 143 | ||
129 | if( A == "name" ) { | 144 | if( A == "name" ) { |
130 | Name = N; | 145 | Name = N; |
131 | } else if( A == "number" ) { | 146 | } else if( A == "number" ) { |
132 | setNumber( N.toLong() ); | 147 | setNumber( N.toLong() ); |
133 | } else if( A == "node" ) { | 148 | } else if( A == "node" ) { |
134 | ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); | 149 | ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); |
135 | if( NNI && ! InError ) { | 150 | if( NNI && ! InError ) { |
136 | append( NSResources->findNodeInstance( N ) ); | 151 | append( NSResources->findNodeInstance( N ) ); |
137 | } else { | 152 | } else { |
138 | // could not find a node type -> collection invalid | 153 | // could not find a node type -> collection invalid |
139 | InError = 1; | 154 | InError = 1; |
140 | } | 155 | } |
141 | } | 156 | } |
142 | } while( 1 ); | 157 | } while( 1 ); |
143 | } | 158 | } |
144 | 159 | ||
145 | 160 | ||
146 | NodeCollection::~NodeCollection( void ) { | 161 | NodeCollection::~NodeCollection( void ) { |
147 | } | 162 | } |
148 | 163 | ||
149 | const QString & NodeCollection::description( void ) { | 164 | const QString & NodeCollection::description( void ) { |
150 | ANetNodeInstance * NNI = getToplevel(); | 165 | ANetNodeInstance * NNI = getToplevel(); |
151 | return (NNI) ? NNI->runtime()->asFullSetup()->description() : Name; | 166 | return (NNI) ? NNI->runtime()->asFullSetup()->description() : Name; |
152 | } | 167 | } |
153 | 168 | ||
154 | void NodeCollection::append( ANetNodeInstance * NNI ) { | 169 | void NodeCollection::append( ANetNodeInstance * NNI ) { |
155 | NNI->setConnection( this ); | 170 | NNI->setConnection( this ); |
156 | QList<ANetNodeInstance>::append( NNI ); | 171 | QList<ANetNodeInstance>::append( NNI ); |
157 | } | 172 | } |
158 | 173 | ||
159 | void NodeCollection::save( QTextStream & TS ) { | 174 | void NodeCollection::save( QTextStream & TS ) { |
160 | 175 | ||
161 | TS << "name=" << quote( Name ) << endl; | 176 | TS << "name=" << quote( Name ) << endl; |
162 | TS << "number=" << number() << endl; | 177 | TS << "number=" << number() << endl; |
163 | ANetNodeInstance * NNI; | 178 | ANetNodeInstance * NNI; |
164 | for( QListIterator<ANetNodeInstance> it(*this); | 179 | for( QListIterator<ANetNodeInstance> it(*this); |
165 | it.current(); | 180 | it.current(); |
166 | ++it ) { | 181 | ++it ) { |
167 | NNI = it.current(); | 182 | NNI = it.current(); |
168 | TS << "node=" << quote( NNI->nodeName() ) << endl; | 183 | TS << "node=" << quote( NNI->nodeName() ) << endl; |
169 | } | 184 | } |
170 | TS << endl; | 185 | TS << endl; |
171 | IsNew = 0; | 186 | IsNew = 0; |
172 | } | 187 | } |
173 | 188 | ||
174 | ANetNodeInstance * NodeCollection::getToplevel( void ) { | 189 | ANetNodeInstance * NodeCollection::getToplevel( void ) { |
175 | ANetNodeInstance * NNI = 0; | 190 | ANetNodeInstance * NNI = 0; |
176 | for( QListIterator<ANetNodeInstance> it(*this); | 191 | for( QListIterator<ANetNodeInstance> it(*this); |
177 | it.current(); | 192 | it.current(); |
178 | ++it ) { | 193 | ++it ) { |
179 | NNI = it.current(); | 194 | NNI = it.current(); |
180 | if( NNI->nodeClass()->isToplevel() ) | 195 | if( NNI->nodeClass()->isToplevel() ) |
181 | break; | 196 | break; |
182 | } | 197 | } |
183 | return NNI; | 198 | return NNI; |
184 | } | 199 | } |
185 | 200 | ||
186 | ANetNodeInstance * NodeCollection::findByName( const QString & S ) { | 201 | ANetNodeInstance * NodeCollection::findByName( const QString & S ) { |
187 | ANetNodeInstance * NNI = 0; | 202 | ANetNodeInstance * NNI = 0; |
188 | for( QListIterator<ANetNodeInstance> it(*this); | 203 | for( QListIterator<ANetNodeInstance> it(*this); |
189 | it.current(); | 204 | it.current(); |
190 | ++it ) { | 205 | ++it ) { |
191 | NNI = it.current(); | 206 | NNI = it.current(); |
192 | if( NNI->name() == S ) | 207 | if( NNI->name() == S ) |
193 | break; | 208 | break; |
194 | } | 209 | } |
195 | return NNI; | 210 | return NNI; |
196 | } | 211 | } |
197 | 212 | ||
198 | ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { | 213 | ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { |
199 | ANetNodeInstance * NNNI; | 214 | ANetNodeInstance * NNNI; |
200 | 215 | ||
201 | if( ! NNI ) | 216 | if( ! NNI ) |
202 | getToplevel(); | 217 | getToplevel(); |
203 | 218 | ||
204 | for( QListIterator<ANetNodeInstance> it(*this); | 219 | for( QListIterator<ANetNodeInstance> it(*this); |
205 | it.current(); | 220 | it.current(); |
206 | ++it ) { | 221 | ++it ) { |
207 | NNNI = it.current(); | 222 | NNNI = it.current(); |
208 | if( NNNI == NNI ) { | 223 | if( NNNI == NNI ) { |
209 | ++it; | 224 | ++it; |
210 | return it.current(); | 225 | return it.current(); |
211 | } | 226 | } |
212 | } | 227 | } |
213 | return 0; // no more next | 228 | return 0; // no more next |
214 | } | 229 | } |
215 | 230 | ||
216 | int NodeCollection::compareItems( QCollection::Item I1, | 231 | int NodeCollection::compareItems( QCollection::Item I1, |
217 | QCollection::Item I2 ) { | 232 | QCollection::Item I2 ) { |
218 | ANetNodeInstance * NNI1, * NNI2; | 233 | ANetNodeInstance * NNI1, * NNI2; |
219 | NNI1 = (ANetNodeInstance *)I1; | 234 | NNI1 = (ANetNodeInstance *)I1; |
220 | NNI2 = (ANetNodeInstance *)I2; | 235 | NNI2 = (ANetNodeInstance *)I2; |
221 | return NNI1->nodeName().compare( NNI2->nodeName() ); | 236 | return NNI1->nodeName().compare( NNI2->nodeName() ); |
222 | } | 237 | } |
223 | 238 | ||
224 | static char * State2PixmapTbl[] = { | 239 | static char * State2PixmapTbl[] = { |
225 | "NULL", // Unchecked : no pixmap | 240 | "NULL", // Unchecked : no pixmap |
226 | "check", // Unknown | 241 | "check", // Unknown |
227 | "delete", // unavailable | 242 | "delete", // unavailable |
228 | "disabled", // disabled | 243 | "disabled", // disabled |
229 | "off", // off | 244 | "off", // off |
230 | "disconnected", // available | 245 | "disconnected", // available |
231 | "connected" // up | 246 | "connected" // up |
232 | }; | 247 | }; |
233 | 248 | ||
234 | QPixmap NodeCollection::devicePixmap( void ) { | 249 | QPixmap NodeCollection::devicePixmap( void ) { |
235 | return NSResources->getPixmap( | 250 | return NSResources->getPixmap( |
236 | device()->netNode()->pixmapName()+"-large" ); | 251 | device()->netNode()->pixmapName()+"-large" ); |
237 | } | 252 | } |
238 | 253 | ||
239 | QPixmap NodeCollection::statePixmap( State_t S) { | 254 | QPixmap NodeCollection::statePixmap( State_t S) { |
240 | return NSResources->getPixmap( State2PixmapTbl[S] ); | 255 | return NSResources->getPixmap( State2PixmapTbl[S] ); |
241 | } | 256 | } |
242 | 257 | ||
243 | QString NodeCollection::stateName( State_t S) { | 258 | QString NodeCollection::stateName( State_t S) { |
244 | switch( S ) { | 259 | switch( S ) { |
245 | case Unknown : | 260 | case Unknown : |
246 | return qApp->translate( "networksettings2", "Unknown"); | 261 | return qApp->translate( "networksettings2", "Unknown"); |
247 | case Unavailable : | 262 | case Unavailable : |
248 | return qApp->translate( "networksettings2", "Unavailable"); | 263 | return qApp->translate( "networksettings2", "Unavailable"); |
249 | case Disabled : | 264 | case Disabled : |
250 | return qApp->translate( "networksettings2", "Disabled"); | 265 | return qApp->translate( "networksettings2", "Disabled"); |
251 | case Off : | 266 | case Off : |
252 | return qApp->translate( "networksettings2", "Off"); | 267 | return qApp->translate( "networksettings2", "Off"); |
253 | case Available : | 268 | case Available : |
254 | return qApp->translate( "networksettings2", "Available"); | 269 | return qApp->translate( "networksettings2", "Available"); |
255 | case IsUp : | 270 | case IsUp : |
256 | return qApp->translate( "networksettings2", "IsUp"); | 271 | return qApp->translate( "networksettings2", "IsUp"); |
257 | case Unchecked : /* FT */ | 272 | case Unchecked : /* FT */ |
258 | default : | 273 | default : |
259 | break; | 274 | break; |
260 | } | 275 | } |
261 | return QString(""); | 276 | return QString(""); |
262 | } | 277 | } |
263 | 278 | ||
264 | void NodeCollection::reassign( void ) { | 279 | void NodeCollection::reassign( void ) { |
265 | for( QListIterator<ANetNodeInstance> it(*this); | 280 | for( QListIterator<ANetNodeInstance> it(*this); |
266 | it.current(); | 281 | it.current(); |
267 | ++it ) { | 282 | ++it ) { |
268 | it.current()->setConnection( this ); | 283 | it.current()->setConnection( this ); |
269 | } | 284 | } |
270 | } | 285 | } |
271 | 286 | ||
287 | // | ||
288 | // | ||
289 | // RUNTIMEINFO | ||
290 | // | ||
291 | // | ||
292 | |||
272 | InterfaceInfo * RuntimeInfo::assignedInterface( void ) { | 293 | InterfaceInfo * RuntimeInfo::assignedInterface( void ) { |
273 | return netNode()->nextNode()->runtime()->assignedInterface(); | 294 | return netNode()->nextNode()->runtime()->assignedInterface(); |
274 | } | 295 | } |
275 | 296 | ||
276 | AsDevice * RuntimeInfo::device( void ) { | 297 | AsDevice * RuntimeInfo::device( void ) { |
277 | return netNode()->nextNode()->runtime()->device(); | 298 | return netNode()->nextNode()->runtime()->device(); |
278 | } | 299 | } |
279 | |||
280 | ANetNodeInstance * FakeNetNode::createInstance( void ) { | ||
281 | return new FakeNetNodeInstance( this ); | ||
282 | } | ||
283 | |||
284 | void FakeNetNodeInstance::setSpecificAttribute( | ||
285 | QString & A, QString & V ) { | ||
286 | ValAttrPairs.insert( A, new QString(V) ); | ||
287 | } | ||
288 | |||
289 | void FakeNetNodeInstance::saveSpecificAttribute( QTextStream &TS ) { | ||
290 | for( QDictIterator<QString> it( ValAttrPairs ); | ||
291 | it.current(); | ||
292 | ++ it ) { | ||
293 | TS << it.currentKey().latin1() | ||
294 | << "=" | ||
295 | << quote( *(it.current())) | ||
296 | << endl ; | ||
297 | ++it; | ||
298 | } | ||
299 | } | ||
300 | |||
301 | // collects all info that no plugin acceps | ||
302 | FakeNetNode * FakeNode = 0; | ||
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h index 9681c6e..6ec9ef6 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.h +++ b/noncore/settings/networksettings2/networksettings2/netnode.h | |||
@@ -1,465 +1,389 @@ | |||
1 | #ifndef NETNODE_H | 1 | #ifndef NETNODE_H |
2 | #define NETNODE_H | 2 | #define NETNODE_H |
3 | 3 | ||
4 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qpixmap.h> | 7 | #include <qpixmap.h> |
8 | #include <qobject.h> | 8 | #include <qobject.h> |
9 | #include <time.h> | 9 | #include <time.h> |
10 | 10 | ||
11 | // difference feature interfaces | 11 | // difference feature interfaces |
12 | class AsDevice; | 12 | class AsDevice; |
13 | class AsLine; | 13 | class AsLine; |
14 | class AsConnection; | 14 | class AsConnection; |
15 | class AsFullSetup; | 15 | class AsFullSetup; |
16 | 16 | ||
17 | // needed for plugin creation function | 17 | // needed for plugin creation function |
18 | #include <qlist.h> | 18 | #include <qlist.h> |
19 | 19 | ||
20 | class ANetNode; | 20 | class ANetNode; |
21 | class ANetNodeInstance; | 21 | class ANetNodeInstance; |
22 | class NodeCollection; | 22 | class NodeCollection; |
23 | class QTextStream; | 23 | class QTextStream; |
24 | class RuntimeInfo; | 24 | class RuntimeInfo; |
25 | class InterfaceInfo; | 25 | class InterfaceInfo; |
26 | 26 | ||
27 | extern QString & deQuote( QString & X ); | 27 | extern QString & deQuote( QString & X ); |
28 | extern QString quote( QString X ); | 28 | extern QString quote( QString X ); |
29 | 29 | ||
30 | #include "systemfile.h" | 30 | #include "systemfile.h" |
31 | 31 | ||
32 | typedef enum State { | 32 | typedef enum State { |
33 | // if we have not yet detected the state of the device | 33 | // if we have not yet detected the state of the device |
34 | Unchecked = 0, | 34 | Unchecked = 0, |
35 | // if we cannot determine the state | 35 | // if we cannot determine the state |
36 | Unknown = 1, | 36 | Unknown = 1, |
37 | // if connection cannot be established e.g. because | 37 | // if connection cannot be established e.g. because |
38 | // the hardware is not available | 38 | // the hardware is not available |
39 | Unavailable = 2, | 39 | Unavailable = 2, |
40 | // if the connection cannot be establishec but NOT | 40 | // if the connection cannot be establishec but NOT |
41 | // because it is physically impossible but because | 41 | // because it is physically impossible but because |
42 | // it has been disabled for FUNCTIONAL reasons | 42 | // it has been disabled for FUNCTIONAL reasons |
43 | Disabled = 3, | 43 | Disabled = 3, |
44 | // if connection is available to is currently down | 44 | // if connection is available to is currently down |
45 | // i.e. the corresponding hardware is not activated | 45 | // i.e. the corresponding hardware is not activated |
46 | Off = 4, | 46 | Off = 4, |
47 | // if connection is available to be used (i.e. the | 47 | // if connection is available to be used (i.e. the |
48 | // devices if fully ready to be used | 48 | // devices if fully ready to be used |
49 | Available = 5, | 49 | Available = 5, |
50 | // if connection is being used | 50 | // if connection is being used |
51 | IsUp = 6 | 51 | IsUp = 6 |
52 | } State_t; | 52 | } State_t; |
53 | 53 | ||
54 | typedef enum Action { | 54 | typedef enum Action { |
55 | // to make the device unavailable functionally | 55 | // to make the device unavailable functionally |
56 | Disable = 0, | 56 | Disable = 0, |
57 | // to make the device available functionally | 57 | // to make the device available functionally |
58 | Enable = 1, | 58 | Enable = 1, |
59 | // bring the hardware up | 59 | // bring the hardware up |
60 | Activate = 2, | 60 | Activate = 2, |
61 | // bring the hardware down | 61 | // bring the hardware down |
62 | Deactivate = 3, | 62 | Deactivate = 3, |
63 | // bring the connection up | 63 | // bring the connection up |
64 | Up = 4, | 64 | Up = 4, |
65 | // bring the connection down | 65 | // bring the connection down |
66 | Down = 5 | 66 | Down = 5 |
67 | } Action_t; | 67 | } Action_t; |
68 | 68 | ||
69 | class ANetNode : public QObject{ | 69 | class ANetNode : public QObject{ |
70 | 70 | ||
71 | public: | 71 | public: |
72 | 72 | ||
73 | typedef QArray<ANetNode *> NetNodeList; | 73 | typedef QArray<ANetNode *> NetNodeList; |
74 | 74 | ||
75 | ANetNode(){}; | 75 | ANetNode(){}; |
76 | virtual ~ANetNode(){}; | 76 | virtual ~ANetNode(){}; |
77 | 77 | ||
78 | // pixmap needed for this NetNode | 78 | // pixmap needed for this NetNode |
79 | virtual const QString pixmapName() = 0; | 79 | virtual const QString pixmapName() = 0; |
80 | 80 | ||
81 | // name of this NetNode | 81 | // name of this NetNode |
82 | virtual const QString nodeName() = 0; | 82 | virtual const QString nodeName() = 0; |
83 | 83 | ||
84 | // description for this NetNode | 84 | // description for this NetNode |
85 | virtual const QString nodeDescription() = 0; | 85 | virtual const QString nodeDescription() = 0; |
86 | 86 | ||
87 | // create a blank instance of a net node | 87 | // create a blank instance of a net node |
88 | virtual ANetNodeInstance * createInstance( void ) = 0; | 88 | virtual ANetNodeInstance * createInstance( void ) = 0; |
89 | 89 | ||
90 | // return feature this NetNode provides | 90 | // return feature this NetNode provides |
91 | virtual const char * provides( void ) = 0; | 91 | virtual const char * provides( void ) = 0; |
92 | virtual const char ** needs( void ) = 0; | 92 | virtual const char ** needs( void ) = 0; |
93 | 93 | ||
94 | // generate files specific for this node (if any) | 94 | // generate files specific for this node (if any) |
95 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0; | 95 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0; |
96 | // return TRUE if this node has data to be inserted in systemfile | 96 | // return TRUE if this node has data to be inserted in systemfile |
97 | // with name S | 97 | // with name S |
98 | virtual bool hasDataFor( const QString & S ) = 0; | 98 | virtual bool hasDataFor( const QString & S ) = 0; |
99 | // generate data specific for the device for the system file S | 99 | // generate data specific for the device for the system file S |
100 | // called only IF data was needed | 100 | // called only IF data was needed |
101 | virtual bool generateDeviceDataForCommonFile( | 101 | virtual bool generateDeviceDataForCommonFile( |
102 | SystemFile & SF, long DevNr ) = 0; | 102 | SystemFile & SF, long DevNr ) = 0; |
103 | 103 | ||
104 | // does this Node provide a Connection | 104 | // does this Node provide a Connection |
105 | bool isToplevel( void ) | 105 | bool isToplevel( void ) |
106 | { return strcmp( provides(), "fullsetup") == 0 ; } | 106 | { return strcmp( provides(), "fullsetup") == 0 ; } |
107 | 107 | ||
108 | // generate NIC name based on instance nr | 108 | // generate NIC name based on instance nr |
109 | // only relevant if node instances are devices | 109 | // only relevant if node instances are devices |
110 | virtual QString genNic( long ) | 110 | virtual QString genNic( long ) |
111 | { return QString(""); } | 111 | { return QString(""); } |
112 | 112 | ||
113 | // max number of instances for this node type | 113 | // max number of instances for this node type |
114 | // only relevant if node instances are devices | 114 | // only relevant if node instances are devices |
115 | virtual long instanceCount( void ) | 115 | virtual long instanceCount( void ) |
116 | { return 1; } | 116 | { return 1; } |
117 | 117 | ||
118 | // set the value of an attribute | ||
119 | void setAttribute( QString & Attr, QString & Value ) ; | ||
120 | void saveAttributes( QTextStream & TS ) ; | ||
121 | |||
118 | // compiled references to 'needed' NetNodes -> needs list | 122 | // compiled references to 'needed' NetNodes -> needs list |
119 | void setAlternatives( NetNodeList * Alt ) | 123 | void setAlternatives( NetNodeList * Alt ) |
120 | { Alternatives = Alt; } | 124 | { Alternatives = Alt; } |
121 | NetNodeList & alternatives( void ) | 125 | NetNodeList & alternatives( void ) |
122 | { return *Alternatives; } | 126 | { return *Alternatives; } |
123 | 127 | ||
124 | protected : | 128 | protected : |
125 | 129 | ||
126 | NetNodeList * Alternatives; | 130 | NetNodeList * Alternatives; |
127 | 131 | ||
128 | private : | 132 | private : |
133 | |||
134 | virtual void setSpecificAttribute( QString & , QString & ) = 0; | ||
135 | virtual void saveSpecificAttribute( QTextStream & ) = 0; | ||
136 | |||
129 | }; | 137 | }; |
130 | 138 | ||
131 | class ANetNodeInstance : public QObject { | 139 | class ANetNodeInstance : public QObject { |
132 | 140 | ||
133 | public: | 141 | public: |
134 | 142 | ||
135 | ANetNodeInstance( ANetNode * NN ) : QObject() | 143 | ANetNodeInstance( ANetNode * NN ) : QObject() |
136 | { IsModified=0; NodeType = NN; IsNew = TRUE; } | 144 | { IsModified=0; NodeType = NN; IsNew = TRUE; } |
137 | virtual ~ANetNodeInstance( void ) { } | 145 | virtual ~ANetNodeInstance( void ) { } |
138 | 146 | ||
139 | virtual RuntimeInfo * runtime( void ) = 0; | 147 | virtual RuntimeInfo * runtime( void ) = 0; |
140 | 148 | ||
141 | void setConnection( NodeCollection * NC ) | 149 | void setConnection( NodeCollection * NC ) |
142 | { Connection = NC; } | 150 | { Connection = NC; } |
143 | NodeCollection * connection( void ) | 151 | NodeCollection * connection( void ) |
144 | { return Connection; } | 152 | { return Connection; } |
145 | 153 | ||
146 | // create edit widget under parent | 154 | // create edit widget under parent |
147 | virtual QWidget * edit( QWidget * parent ) = 0; | 155 | virtual QWidget * edit( QWidget * parent ) = 0; |
148 | // is given data acceptable | 156 | // is given data acceptable |
149 | virtual QString acceptable( void ) = 0; | 157 | virtual QString acceptable( void ) = 0; |
150 | 158 | ||
151 | // return data was modified | 159 | // return data was modified |
152 | void setModified( bool M ) | 160 | void setModified( bool M ) |
153 | { IsModified = M; } | 161 | { IsModified = M; } |
154 | bool isModified( void ) | 162 | bool isModified( void ) |
155 | { return IsModified; } | 163 | { return IsModified; } |
156 | 164 | ||
157 | // get data from GUI and store in node | 165 | // get data from GUI and store in node |
158 | virtual void commit( void ) = 0; | 166 | virtual void commit( void ) = 0; |
159 | 167 | ||
160 | // get next node | 168 | // get next node |
161 | ANetNodeInstance * nextNode(); | 169 | ANetNodeInstance * nextNode(); |
162 | // return NetNode this is an instance of | 170 | // return NetNode this is an instance of |
163 | ANetNode * nodeClass( void ) | 171 | ANetNode * nodeClass( void ) |
164 | { return NodeType; } | 172 | { return NodeType; } |
165 | 173 | ||
166 | // intialize am instance of a net node | 174 | // intialize am instance of a net node |
167 | void initialize( void ); | 175 | void initialize( void ); |
168 | 176 | ||
169 | // set the value of an attribute | 177 | // set the value of an attribute |
170 | void setAttribute( QString & Attr, QString & Value ) ; | 178 | void setAttribute( QString & Attr, QString & Value ) ; |
171 | void saveAttributes( QTextStream & TS ) ; | 179 | void saveAttributes( QTextStream & TS ) ; |
172 | 180 | ||
173 | // return true if node isntance is NEW and not loaded | 181 | // return true if node isntance is NEW and not loaded |
174 | void setNew( bool IsN ) | 182 | void setNew( bool IsN ) |
175 | { IsNew = IsN; } | 183 | { IsNew = IsN; } |
176 | bool isNew( void ) | 184 | bool isNew( void ) |
177 | { return IsNew; } | 185 | { return IsNew; } |
178 | 186 | ||
179 | // return logical name of this instance | 187 | // return logical name of this instance |
180 | QString & nodeName( void ) | 188 | QString & nodeName( void ) |
181 | { return NodeName; } | 189 | { return NodeName; } |
182 | void setNodeName( const QString & S ) | 190 | void setNodeName( const QString & S ) |
183 | { NodeName = S; } | 191 | { NodeName = S; } |
184 | // return description for this instance | 192 | // return description for this instance |
185 | QString & description( void ) | 193 | QString & description( void ) |
186 | { return Description; } | 194 | { return Description; } |
187 | void setDescription( const QString & S ) | 195 | void setDescription( const QString & S ) |
188 | { Description = S; } | 196 | { Description = S; } |
189 | 197 | ||
190 | // pixmap for this instance -> from NetNode | 198 | // pixmap for this instance -> from NetNode |
191 | const QString pixmapName( void ) | 199 | const QString pixmapName( void ) |
192 | { return NodeType->pixmapName(); } | 200 | { return NodeType->pixmapName(); } |
193 | 201 | ||
194 | const char * provides( void ) | 202 | const char * provides( void ) |
195 | { return NodeType->provides(); } | 203 | { return NodeType->provides(); } |
196 | 204 | ||
197 | const char ** needs( void ) | 205 | const char ** needs( void ) |
198 | { return NodeType->needs(); } | 206 | { return NodeType->needs(); } |
199 | 207 | ||
200 | // returns node specific data -> only useful for 'buddy' | 208 | // returns node specific data -> only useful for 'buddy' |
201 | virtual void * data( void ) = 0; | 209 | virtual void * data( void ) = 0; |
202 | 210 | ||
203 | // return TRUE if this node has data to be inserted in systemfile | 211 | // return TRUE if this node has data to be inserted in systemfile |
204 | // with name S | 212 | // with name S |
205 | virtual bool hasDataFor( const QString & S ) = 0; | 213 | virtual bool hasDataFor( const QString & S ) = 0; |
206 | 214 | ||
207 | // generate data specific for a profile and for the system file S | 215 | // generate data specific for a profile and for the system file S |
208 | // called only IF data was needed | 216 | // called only IF data was needed |
209 | virtual bool generateDataForCommonFile( | 217 | virtual bool generateDataForCommonFile( |
210 | SystemFile & SF, long DevNr ) = 0; | 218 | SystemFile & SF, long DevNr ) = 0; |
211 | 219 | ||
212 | protected : | 220 | protected : |
213 | 221 | ||
214 | virtual void setSpecificAttribute( QString & , QString & ) = 0; | 222 | virtual void setSpecificAttribute( QString & , QString & ) = 0; |
215 | virtual void saveSpecificAttribute( QTextStream & ) = 0; | 223 | virtual void saveSpecificAttribute( QTextStream & ) = 0; |
216 | 224 | ||
217 | ANetNode * NodeType; | 225 | ANetNode * NodeType; |
218 | // connection to which this node belongs to | 226 | // connection to which this node belongs to |
219 | NodeCollection * Connection; | 227 | NodeCollection * Connection; |
220 | QString NodeName; | 228 | QString NodeName; |
221 | QString Description; | 229 | QString Description; |
222 | bool IsModified; | 230 | bool IsModified; |
223 | bool IsNew; | 231 | bool IsNew; |
224 | 232 | ||
225 | static long InstanceCounter; | 233 | static long InstanceCounter; |
226 | }; | 234 | }; |
227 | 235 | ||
228 | class RuntimeInfo : public QObject { | 236 | class RuntimeInfo : public QObject { |
229 | 237 | ||
230 | Q_OBJECT | 238 | Q_OBJECT |
231 | 239 | ||
232 | public : | 240 | public : |
233 | 241 | ||
234 | RuntimeInfo( ANetNodeInstance * TheNNI ) | 242 | RuntimeInfo( ANetNodeInstance * TheNNI ) |
235 | { NNI = TheNNI; } | 243 | { NNI = TheNNI; } |
236 | 244 | ||
237 | // downcast implemented by specify runtime classes | 245 | // downcast implemented by specify runtime classes |
238 | virtual AsDevice * asDevice( void ) | 246 | virtual AsDevice * asDevice( void ) |
239 | { return 0; } | 247 | { return 0; } |
240 | virtual AsConnection * asConnection( void ) | 248 | virtual AsConnection * asConnection( void ) |
241 | { return 0; } | 249 | { return 0; } |
242 | virtual AsLine * asLine( void ) | 250 | virtual AsLine * asLine( void ) |
243 | { return 0; } | 251 | { return 0; } |
244 | virtual AsFullSetup * asFullSetup( void ) | 252 | virtual AsFullSetup * asFullSetup( void ) |
245 | { return 0; } | 253 | { return 0; } |
246 | 254 | ||
247 | // does this node handles this interface e.g.eth0 | 255 | // does this node handles this interface e.g.eth0 |
248 | // recurse deeper if this node cannot answer that question | 256 | // recurse deeper if this node cannot answer that question |
249 | virtual bool handlesInterface( const QString & ) | 257 | virtual bool handlesInterface( const QString & ) |
250 | { return 0; } | 258 | { return 0; } |
251 | virtual InterfaceInfo * assignedInterface( void ); | 259 | virtual InterfaceInfo * assignedInterface( void ); |
252 | virtual AsDevice * device( void ); | 260 | virtual AsDevice * device( void ); |
253 | 261 | ||
254 | ANetNodeInstance * netNode() | 262 | ANetNodeInstance * netNode() |
255 | { return NNI; } | 263 | { return NNI; } |
256 | NodeCollection * connection() | 264 | NodeCollection * connection() |
257 | { return NNI->connection(); } | 265 | { return NNI->connection(); } |
258 | 266 | ||
259 | virtual void detectState( NodeCollection * NC ) = 0; | 267 | virtual void detectState( NodeCollection * NC ) = 0; |
260 | virtual bool setState( NodeCollection * NC, Action_t A ) = 0; | 268 | virtual bool setState( NodeCollection * NC, Action_t A ) = 0; |
261 | virtual bool canSetState( State_t Curr, Action_t A ) = 0; | 269 | virtual bool canSetState( State_t Curr, Action_t A ) = 0; |
262 | 270 | ||
263 | signals : | 271 | signals : |
264 | 272 | ||
265 | // sent by device if state changes | 273 | // sent by device if state changes |
266 | void stateChanged( State_t S, ANetNodeInstance * NNI ); | 274 | void stateChanged( State_t S, ANetNodeInstance * NNI ); |
267 | 275 | ||
268 | protected : | 276 | protected : |
269 | 277 | ||
270 | // connection this runtime info belongs to | 278 | // connection this runtime info belongs to |
271 | ANetNodeInstance * NNI; | 279 | ANetNodeInstance * NNI; |
272 | }; | 280 | }; |
273 | 281 | ||
274 | class NodeCollection : public QList<ANetNodeInstance> { | 282 | class NodeCollection : public QList<ANetNodeInstance> { |
275 | 283 | ||
276 | public : | 284 | public : |
277 | 285 | ||
278 | NodeCollection( void ); | 286 | NodeCollection( void ); |
279 | NodeCollection( QTextStream & TS ); | 287 | NodeCollection( QTextStream & TS ); |
280 | ~NodeCollection( void ); | 288 | ~NodeCollection( void ); |
281 | 289 | ||
282 | int number( void ) | 290 | int number( void ) |
283 | { return Number; } | 291 | { return Number; } |
284 | void setNumber( int i ) | 292 | void setNumber( int i ) |
285 | { Number = i; if( MaxNr < i ) MaxNr = i; } | 293 | { Number = i; if( MaxNr < i ) MaxNr = i; } |
286 | bool isNew( void ) | 294 | bool isNew( void ) |
287 | { return IsNew; } | 295 | { return IsNew; } |
288 | void setNew( bool N ) | 296 | void setNew( bool N ) |
289 | { IsNew = N ; } | 297 | { IsNew = N ; } |
290 | bool isModified( void ) | 298 | bool isModified( void ) |
291 | { return IsModified; } | 299 | { return IsModified; } |
292 | void setModified( bool N ) | 300 | void setModified( bool N ) |
293 | { IsModified = N ; } | 301 | { IsModified = N ; } |
294 | 302 | ||
295 | bool handlesInterface( const QString & S ) { | 303 | bool handlesInterface( const QString & S ) { |
296 | return getToplevel()->runtime()->handlesInterface( S ); | 304 | return getToplevel()->runtime()->handlesInterface( S ); |
297 | } | 305 | } |
298 | 306 | ||
299 | InterfaceInfo * assignedInterface( void ) { | 307 | InterfaceInfo * assignedInterface( void ) { |
300 | return getToplevel()->runtime()->assignedInterface(); | 308 | return getToplevel()->runtime()->assignedInterface(); |
301 | } | 309 | } |
302 | 310 | ||
303 | AsDevice * device() { | 311 | AsDevice * device() { |
304 | return getToplevel()->runtime()->device(); | 312 | return getToplevel()->runtime()->device(); |
305 | } | 313 | } |
306 | 314 | ||
307 | State_t state( bool Update = 0 ) | 315 | State_t state( bool Update = 0 ) |
308 | { if( CurrentState == Unchecked || Update ) { | 316 | { if( CurrentState == Unchecked || Update ) { |
309 | // need to get current state | 317 | // need to get current state |
310 | getToplevel()->runtime()->detectState( this ); | 318 | getToplevel()->runtime()->detectState( this ); |
311 | } | 319 | } |
312 | return CurrentState; | 320 | return CurrentState; |
313 | } | 321 | } |
314 | 322 | ||
315 | // get the ixmap for this device | 323 | // get the ixmap for this device |
316 | QPixmap devicePixmap( void ); | 324 | QPixmap devicePixmap( void ); |
317 | QPixmap statePixmap( State_t S ); | 325 | QPixmap statePixmap( State_t S ); |
318 | QPixmap statePixmap( bool Update = 0 ) | 326 | QPixmap statePixmap( bool Update = 0 ) |
319 | { return statePixmap( state(Update) ); } | 327 | { return statePixmap( state(Update) ); } |
320 | QString stateName( State_t ); | 328 | QString stateName( State_t ); |
321 | QString stateName( bool Update = 0 ) | 329 | QString stateName( bool Update = 0 ) |
322 | { return stateName( state(Update) ); } | 330 | { return stateName( state(Update) ); } |
323 | 331 | ||
324 | bool setState( Action_t A ) | 332 | bool setState( Action_t A ) |
325 | { return getToplevel()->runtime()->setState( this, A ); } | 333 | { return getToplevel()->runtime()->setState( this, A ); } |
326 | bool canSetState( Action_t A ) | 334 | bool canSetState( Action_t A ) |
327 | { return getToplevel()->runtime()->canSetState( CurrentState, A ); } | 335 | { return getToplevel()->runtime()->canSetState( CurrentState, A ); } |
328 | 336 | ||
329 | void save( QTextStream & TS ); | 337 | void save( QTextStream & TS ); |
330 | 338 | ||
331 | void append( ANetNodeInstance * NNI ); | 339 | void append( ANetNodeInstance * NNI ); |
332 | 340 | ||
333 | // makes sure that all items in the connection point to | 341 | // makes sure that all items in the connection point to |
334 | // that connectoin | 342 | // that connectoin |
335 | void reassign( void ); | 343 | void reassign( void ); |
336 | 344 | ||
337 | ANetNodeInstance * getToplevel( void ); | 345 | ANetNodeInstance * getToplevel( void ); |
338 | ANetNodeInstance * findNext( ANetNodeInstance * NNI ); | 346 | ANetNodeInstance * findNext( ANetNodeInstance * NNI ); |
339 | ANetNodeInstance * findByName( const QString & S ); | 347 | ANetNodeInstance * findByName( const QString & S ); |
340 | 348 | ||
341 | const QString & name() | 349 | const QString & name() |
342 | { return Name; } | 350 | { return Name; } |
343 | 351 | ||
344 | const QString & description( void ); | 352 | const QString & description( void ); |
345 | 353 | ||
346 | void setName( const QString & N) | 354 | void setName( const QString & N) |
347 | { Name = N; } | 355 | { Name = N; } |
348 | 356 | ||
349 | State_t currentState( void ) | 357 | State_t currentState( void ) |
350 | { return CurrentState; } | 358 | { return CurrentState; } |
351 | void setCurrentState( State_t S ) | 359 | void setCurrentState( State_t S ) |
352 | { CurrentState = S; } | 360 | { CurrentState = S; } |
353 | 361 | ||
354 | long maxConnectionNumber( void ) | 362 | long maxConnectionNumber( void ) |
355 | { return MaxNr; } | 363 | { return MaxNr; } |
356 | 364 | ||
357 | static void resetMaxNr( void ) | 365 | static void resetMaxNr( void ) |
358 | { MaxNr = -1; } | 366 | { MaxNr = -1; } |
359 | 367 | ||
360 | private : | 368 | private : |
361 | 369 | ||
362 | int compareItems ( QCollection::Item item1, | 370 | int compareItems ( QCollection::Item item1, |
363 | QCollection::Item item2 ); | 371 | QCollection::Item item2 ); |
364 | 372 | ||
365 | static long MaxNr; | 373 | static long MaxNr; |
366 | long Number; | 374 | long Number; |
367 | 375 | ||
368 | // state of this connection | 376 | // state of this connection |
369 | State_t CurrentState; | 377 | State_t CurrentState; |
370 | 378 | ||
371 | QString Name; | 379 | QString Name; |
372 | // true if this collection was just created (and not | 380 | // true if this collection was just created (and not |
373 | // loaded from file | 381 | // loaded from file |
374 | bool IsNew; | 382 | bool IsNew; |
375 | // index in listbox | 383 | // index in listbox |
376 | int Index; | 384 | int Index; |
377 | bool IsModified; | 385 | bool IsModified; |
378 | 386 | ||
379 | }; | 387 | }; |
380 | 388 | ||
381 | // | ||
382 | // special node that is used to remember entries for plugins | ||
383 | // that seem missing. This way we never loose data | ||
384 | // | ||
385 | |||
386 | class FakeNetNode : public ANetNode { | ||
387 | |||
388 | public: | ||
389 | |||
390 | FakeNetNode( ) { }; | ||
391 | virtual ~FakeNetNode(){}; | ||
392 | |||
393 | const QString pixmapName() | ||
394 | { return QString(""); } | ||
395 | const QString nodeName() | ||
396 | { return QString("Fake node" ); } | ||
397 | const QString nodeDescription() | ||
398 | { return QString("Fake node" ); } | ||
399 | ANetNodeInstance * createInstance( void ); | ||
400 | const char * provides( void ) | ||
401 | { return ""; } | ||
402 | virtual const char ** needs( void ) | ||
403 | { return 0; } | ||
404 | virtual bool generateProperFilesFor( ANetNodeInstance * ) | ||
405 | { return 0; } | ||
406 | virtual bool hasDataFor( const QString & ) | ||
407 | { return 0; } | ||
408 | virtual bool generateDeviceDataForCommonFile( | ||
409 | SystemFile & , long ) | ||
410 | {return 1; } | ||
411 | |||
412 | private : | ||
413 | |||
414 | }; | ||
415 | |||
416 | class FakeNetNodeInstance : public ANetNodeInstance { | ||
417 | |||
418 | public: | ||
419 | |||
420 | FakeNetNodeInstance( ANetNode * NN ) : | ||
421 | ANetNodeInstance( NN ), ValAttrPairs() { } | ||
422 | virtual ~FakeNetNodeInstance( void ) { } | ||
423 | |||
424 | virtual RuntimeInfo * runtime( void ) | ||
425 | { return 0; } | ||
426 | |||
427 | // create edit widget under parent | ||
428 | virtual QWidget * edit( QWidget * ) | ||
429 | { return 0; } | ||
430 | // is given data acceptable | ||
431 | virtual QString acceptable( void ) | ||
432 | { return QString(""); } | ||
433 | |||
434 | // get data from GUI and store in node | ||
435 | virtual void commit( void ) {} | ||
436 | |||
437 | // get next node | ||
438 | ANetNodeInstance * nextNode() | ||
439 | { return 0; } | ||
440 | // return NetNode this is an instance of | ||
441 | |||
442 | // intialize am instance of a net node | ||
443 | void initialize( void ){} | ||
444 | |||
445 | // returns node specific data -> only useful for 'buddy' | ||
446 | virtual void * data( void ) | ||
447 | { return 0; } | ||
448 | |||
449 | virtual bool hasDataFor( const QString & ) | ||
450 | { return 0; } | ||
451 | |||
452 | virtual bool generateDataForCommonFile( SystemFile & , long ) | ||
453 | { return 1; } | ||
454 | |||
455 | protected : | ||
456 | |||
457 | virtual void setSpecificAttribute( QString & , QString & ); | ||
458 | virtual void saveSpecificAttribute( QTextStream & ); | ||
459 | |||
460 | QDict<QString> ValAttrPairs; | ||
461 | }; | ||
462 | |||
463 | extern FakeNetNode * FakeNode; | ||
464 | |||
465 | #endif | 389 | #endif |
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h index 3048fb3..7050f10 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.h +++ b/noncore/settings/networksettings2/networksettings2/resources.h | |||
@@ -1,128 +1,128 @@ | |||
1 | #ifndef __RESOURCES__H | 1 | #ifndef __RESOURCES__H |
2 | #define __RESOURCES__H | 2 | #define __RESOURCES__H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qdict.h> | 5 | #include <qdict.h> |
6 | #include <qmap.h> | 6 | #include <qmap.h> |
7 | #include <qlist.h> | 7 | #include <qlist.h> |
8 | #include "netnode.h" | 8 | #include "netnode.h" |
9 | #include "systemfile.h" | 9 | #include "systemfile.h" |
10 | #include "system.h" | 10 | #include "system.h" |
11 | 11 | ||
12 | class QLibrary; | 12 | class QLibrary; |
13 | class QPixmap; | 13 | class QPixmap; |
14 | class ANetNode; | 14 | class ANetNode; |
15 | class ANetNodeInstance; | 15 | class ANetNodeInstance; |
16 | 16 | ||
17 | typedef void (*GetNetNodeListFt_t)(QList<ANetNode>& PNN ); | 17 | typedef void (*GetNetNodeListFt_t)(QList<ANetNode>& PNN ); |
18 | 18 | ||
19 | typedef struct NetNode_S { | 19 | typedef struct NetNode_S { |
20 | ANetNode * NetNode; | 20 | ANetNode * NetNode; |
21 | QLibrary * TheLibrary; | 21 | QLibrary * TheLibrary; |
22 | long NodeCountInLib; | 22 | long NodeCountInLib; |
23 | } NetNode_t; | 23 | } NetNode_t; |
24 | 24 | ||
25 | class CurrentQPEUser { | 25 | class CurrentQPEUser { |
26 | 26 | ||
27 | public : | 27 | public : |
28 | CurrentQPEUser() : UserName(), HomeDir(), EnvList() {} | 28 | CurrentQPEUser() : UserName(), HomeDir(), EnvList() {} |
29 | 29 | ||
30 | QString UserName; | 30 | QString UserName; |
31 | QString HomeDir; | 31 | QString HomeDir; |
32 | int Uid; | 32 | int Uid; |
33 | int Gid; | 33 | int Gid; |
34 | QArray<char *> EnvList; | 34 | QArray<char *> EnvList; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | typedef QDict<NetNode_t> Name2NetNode_t; | 37 | typedef QDict<NetNode_t> Name2NetNode_t; |
38 | typedef QDict<ANetNodeInstance > Name2Instance_t; | 38 | typedef QDict<ANetNodeInstance > Name2Instance_t; |
39 | typedef QDict<NodeCollection> Name2Connection_t; | 39 | typedef QDict<NodeCollection> Name2Connection_t; |
40 | typedef QDict<SystemFile> Name2SystemFile_t; | 40 | typedef QDict<SystemFile> Name2SystemFile_t; |
41 | 41 | ||
42 | class TheNSResources { | 42 | class TheNSResources { |
43 | 43 | ||
44 | public : | 44 | public : |
45 | 45 | ||
46 | TheNSResources( void ); | 46 | TheNSResources( void ); |
47 | ~TheNSResources( ); | 47 | ~TheNSResources( ); |
48 | 48 | ||
49 | System & system() | 49 | System & system() |
50 | { return *TheSystem; } | 50 | { return *TheSystem; } |
51 | 51 | ||
52 | QPixmap getPixmap( const QString & Name ); | 52 | QPixmap getPixmap( const QString & Name ); |
53 | 53 | ||
54 | Name2NetNode_t & netNodes( void ) | 54 | Name2NetNode_t & netNodes( void ) |
55 | { return AllNodeTypes; } | 55 | { return AllNodeTypes; } |
56 | bool netNodeExists( const QString & X ) | 56 | bool netNodeExists( const QString & X ) |
57 | { return AllNodeTypes.find(X)!=0; } | 57 | { return AllNodeTypes.find(X)!=0; } |
58 | ANetNode * findNetNode( const QString & N ) | ||
59 | { NetNode_t * NNT = AllNodeTypes.find(N); | ||
60 | return (NNT) ? NNT->NetNode : 0; | ||
61 | } | ||
58 | 62 | ||
59 | Name2SystemFile_t & systemFiles( void ) | 63 | Name2SystemFile_t & systemFiles( void ) |
60 | { return SystemFiles; } | 64 | { return SystemFiles; } |
61 | void addSystemFile( SystemFile * SF ) | 65 | void addSystemFile( SystemFile * SF ) |
62 | { SystemFiles.insert( SF->name(), SF ); } | 66 | { SystemFiles.insert( SF->name(), SF ); } |
63 | 67 | ||
64 | ANetNodeInstance * createNodeInstance( const QString & S ) | 68 | ANetNodeInstance * createNodeInstance( const QString & S ) |
65 | { ANetNodeInstance * NNI = 0; | 69 | { ANetNodeInstance * NNI = 0; |
66 | NetNode_t * NNT = AllNodeTypes[S]; | 70 | NetNode_t * NNT = AllNodeTypes[S]; |
67 | ANetNode * NN; | ||
68 | if( ! NNT ) { | 71 | if( ! NNT ) { |
69 | NN = FakeNode = | 72 | return 0; |
70 | ( FakeNode ) ? FakeNode : new FakeNetNode(); | ||
71 | } else { | ||
72 | NN = NNT->NetNode; | ||
73 | } | 73 | } |
74 | NNI = NN->createInstance(); | 74 | NNI = NNT->NetNode->createInstance(); |
75 | NNI->initialize(); | 75 | NNI->initialize(); |
76 | return NNI; | 76 | return NNI; |
77 | } | 77 | } |
78 | 78 | ||
79 | Name2Instance_t & netNodeInstances( void ) | 79 | Name2Instance_t & netNodeInstances( void ) |
80 | { return AllNodes; } | 80 | { return AllNodes; } |
81 | void addNodeInstance( ANetNodeInstance * I ) | 81 | void addNodeInstance( ANetNodeInstance * I ) |
82 | { AllNodes.insert( I->nodeName(), I ); } | 82 | { AllNodes.insert( I->nodeName(), I ); } |
83 | void removeNodeInstance( const QString & N ) | 83 | void removeNodeInstance( const QString & N ) |
84 | { AllNodes.remove( N );} | 84 | { AllNodes.remove( N );} |
85 | ANetNodeInstance * findNodeInstance( const QString & S ) | 85 | ANetNodeInstance * findNodeInstance( const QString & S ) |
86 | { return (AllNodes.find(S)!=0) ? AllNodes[S] : 0; } | 86 | { return (AllNodes.find(S)!=0) ? AllNodes[S] : 0; } |
87 | 87 | ||
88 | const QString & netNode2Name( const char * Type ); | 88 | const QString & netNode2Name( const char * Type ); |
89 | const QString & netNode2Description( const char * Type ); | 89 | const QString & netNode2Description( const char * Type ); |
90 | 90 | ||
91 | void renumberConnections( void ); | 91 | void renumberConnections( void ); |
92 | void addConnection( NodeCollection * NC ); | 92 | void addConnection( NodeCollection * NC ); |
93 | void removeConnection( const QString & N ); | 93 | void removeConnection( const QString & N ); |
94 | NodeCollection * findConnection( const QString & N ); | 94 | NodeCollection * findConnection( const QString & N ); |
95 | Name2Connection_t & connections( void ) | 95 | Name2Connection_t & connections( void ) |
96 | { return ConnectionsMap; } | 96 | { return ConnectionsMap; } |
97 | 97 | ||
98 | CurrentQPEUser & currentUser( void ) | 98 | CurrentQPEUser & currentUser( void ) |
99 | { return CurrentUser; } | 99 | { return CurrentUser; } |
100 | 100 | ||
101 | private : | 101 | private : |
102 | 102 | ||
103 | void detectCurrentUser( void ); | 103 | void detectCurrentUser( void ); |
104 | QString tr( const char * path ); | 104 | QString tr( const char * path ); |
105 | void findAvailableNetNodes( const QString &path ); | 105 | void findAvailableNetNodes( const QString &path ); |
106 | bool loadNetNode( | 106 | bool loadNetNode( |
107 | const QString &pluginFileName, | 107 | const QString &pluginFileName, |
108 | const QString &resolveString = "create_plugin"); | 108 | const QString &resolveString = "create_plugin"); |
109 | 109 | ||
110 | QMap< QString, QString> NodeTypeNameMap; | 110 | QMap< QString, QString> NodeTypeNameMap; |
111 | QMap< QString, QString> NodeTypeDescriptionMap; | 111 | QMap< QString, QString> NodeTypeDescriptionMap; |
112 | Name2Connection_t ConnectionsMap; | 112 | Name2Connection_t ConnectionsMap; |
113 | System * TheSystem; | 113 | System * TheSystem; |
114 | Name2SystemFile_t SystemFiles; | 114 | Name2SystemFile_t SystemFiles; |
115 | 115 | ||
116 | // all node type classes | 116 | // all node type classes |
117 | Name2NetNode_t AllNodeTypes; | 117 | Name2NetNode_t AllNodeTypes; |
118 | 118 | ||
119 | // all nodes | 119 | // all nodes |
120 | Name2Instance_t AllNodes; | 120 | Name2Instance_t AllNodes; |
121 | 121 | ||
122 | CurrentQPEUser CurrentUser; | 122 | CurrentQPEUser CurrentUser; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | extern TheNSResources * _NSResources; | 125 | extern TheNSResources * _NSResources; |
126 | #define NSResources _NSResources | 126 | #define NSResources _NSResources |
127 | 127 | ||
128 | #endif | 128 | #endif |
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index b4d9aaa..13979ce 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp | |||
@@ -1,524 +1,559 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qdir.h> | 4 | #include <qdir.h> |
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | #include <qfileinfo.h> | 6 | #include <qfileinfo.h> |
7 | 7 | ||
8 | #include "nsdata.h" | 8 | #include "nsdata.h" |
9 | #include <asdevice.h> | 9 | #include <asdevice.h> |
10 | #include <resources.h> | 10 | #include <resources.h> |
11 | 11 | ||
12 | static QString CfgFile; | 12 | static QString CfgFile; |
13 | 13 | ||
14 | NetworkSettingsData::NetworkSettingsData( void ) { | 14 | NetworkSettingsData::NetworkSettingsData( void ) { |
15 | // init global resources structure | 15 | // init global resources structure |
16 | new TheNSResources(); | 16 | new TheNSResources(); |
17 | 17 | ||
18 | CfgFile.sprintf( "%s/NETCONFIG", | 18 | CfgFile.sprintf( "%s/NETCONFIG", |
19 | NSResources->currentUser().HomeDir.latin1() ); | 19 | NSResources->currentUser().HomeDir.latin1() ); |
20 | fprintf( stderr, "Cfg from %s\n", CfgFile.latin1() ); | 20 | fprintf( stderr, "Cfg from %s\n", CfgFile.latin1() ); |
21 | 21 | ||
22 | // load settings | 22 | // load settings |
23 | Force = 0; | 23 | Force = 0; |
24 | IsModified = 0; | 24 | IsModified = 0; |
25 | loadSettings(); | 25 | loadSettings(); |
26 | } | 26 | } |
27 | 27 | ||
28 | // saving is done by caller | 28 | // saving is done by caller |
29 | NetworkSettingsData::~NetworkSettingsData( void ) { | 29 | NetworkSettingsData::~NetworkSettingsData( void ) { |
30 | delete NSResources; | 30 | delete NSResources; |
31 | } | 31 | } |
32 | 32 | ||
33 | void NetworkSettingsData::loadSettings( void ) { | 33 | void NetworkSettingsData::loadSettings( void ) { |
34 | QString S; | 34 | QString Line, S; |
35 | ANetNodeInstance* NNI; | ||
36 | QString Attr, Value; | 35 | QString Attr, Value; |
37 | long idx; | 36 | long idx; |
38 | 37 | ||
39 | QFile F( CfgFile ); | 38 | QFile F( CfgFile ); |
40 | QTextStream TS( &F ); | 39 | QTextStream TS( &F ); |
41 | 40 | ||
42 | do { | 41 | do { |
43 | 42 | ||
44 | if( ! F.open(IO_ReadOnly) ) | 43 | if( ! F.open(IO_ReadOnly) ) |
45 | break; | 44 | break; |
46 | 45 | ||
47 | /* load the file -> | 46 | /* load the file -> |
48 | 47 | ||
49 | FORMAT : | 48 | FORMAT : |
50 | 49 | ||
51 | [NETNODETYPE] | 50 | [NETNODETYPE] |
52 | Entries ... | 51 | Entries ... |
53 | <EMPTYLINE> | 52 | <EMPTYLINE> |
54 | [connection] | 53 | [connection] |
55 | Name=Name | 54 | Name=Name |
56 | Node=Name | 55 | Node=Name |
57 | <EMPTYLINE> | 56 | <EMPTYLINE> |
58 | */ | 57 | */ |
59 | while( ! TS.atEnd() ) { | 58 | while( ! TS.atEnd() ) { |
60 | S = TS.readLine(); | 59 | S = Line = TS.readLine(); |
61 | 60 | ||
62 | if ( S.isEmpty() || S[0] != '[' ) | 61 | if ( S.isEmpty() || S[0] != '[' ) |
63 | continue; | 62 | continue; |
64 | 63 | ||
65 | S = S.mid( 1, S.length()-2 ); | 64 | S = S.mid( 1, S.length()-2 ); |
66 | 65 | ||
67 | if( ! NSResources ) { | 66 | if( ! NSResources ) { |
68 | continue; | 67 | continue; |
69 | } | 68 | } |
70 | 69 | ||
71 | if( S == "connection" ) { | 70 | if( S == "connection" ) { |
72 | // load connections -> collections of nodes | 71 | // load connections -> collections of nodes |
73 | NodeCollection * NC = new NodeCollection( TS ); | 72 | NodeCollection * NC = new NodeCollection( TS ); |
74 | NSResources->addConnection( NC ); | 73 | NSResources->addConnection( NC ); |
75 | } else { | 74 | } else { |
76 | // load nodes | 75 | ANetNode * NN = 0; |
77 | NNI = NSResources->createNodeInstance( S ); | 76 | ANetNodeInstance* NNI = 0; |
78 | if( ! NNI ) { | 77 | if( S.startsWith( "nodetype " ) ) { |
79 | printf( "SKIPPING %s\n", S.latin1() ); | 78 | S = S.mid( 9, S.length()-9-1 ); |
79 | fprintf( stderr, "Node %s\n", S.latin1() ); | ||
80 | // try to find netnode | ||
81 | NN = NSResources->findNetNode( S ); | ||
82 | } else { | ||
83 | // try to find instance | ||
84 | NNI = NSResources->createNodeInstance( S ); | ||
80 | } | 85 | } |
81 | 86 | ||
82 | do { | 87 | do { |
83 | S = TS.readLine(); | 88 | S = TS.readLine(); |
84 | if( S.isEmpty() ) { | 89 | |
85 | // empty line | 90 | if( NN || NNI ) { |
86 | break; | 91 | if( S.isEmpty() ) { |
87 | } | 92 | // empty line |
88 | // node found ? | 93 | break; |
89 | if( NNI ) { | 94 | } |
90 | idx = S.find( '=' ); | 95 | idx = S.find( '=' ); |
91 | if( idx > 0 ) { | 96 | if( idx > 0 ) { |
92 | Attr = S.left( idx ); | 97 | Attr = S.left( idx ); |
93 | Value = S.mid( idx+1, S.length() ); | 98 | Value = S.mid( idx+1, S.length() ); |
94 | } else { | 99 | } else { |
95 | Value=""; | 100 | Value=""; |
96 | Attr = S; | 101 | Attr = S; |
97 | } | 102 | } |
98 | 103 | ||
99 | Value.stripWhiteSpace(); | 104 | Value.stripWhiteSpace(); |
100 | Attr.stripWhiteSpace(); | 105 | Attr.stripWhiteSpace(); |
101 | Attr.lower(); | 106 | Attr.lower(); |
102 | // dequote Attr | 107 | // dequote Attr |
103 | Value = deQuote(Value); | 108 | Value = deQuote(Value); |
104 | 109 | ||
105 | // set the attribute | 110 | if( NN ) { |
106 | NNI->setAttribute( Attr, Value ); | 111 | // set the attribute |
112 | NNI->setAttribute( Attr, Value ); | ||
113 | } else { | ||
114 | // set the attribute | ||
115 | NNI->setAttribute( Attr, Value ); | ||
116 | } | ||
117 | } else { | ||
118 | LeftOvers.append( Line ); | ||
119 | // add empty line too as delimiter | ||
120 | if( S.isEmpty() ) { | ||
121 | // empty line | ||
122 | break; | ||
123 | } | ||
107 | } | 124 | } |
108 | |||
109 | } while( 1 ); | 125 | } while( 1 ); |
110 | if( NNI ) { | 126 | if( NNI ) { |
111 | // loading from file -> exists | 127 | // loading from file -> exists |
112 | NNI->setNew( FALSE ); | 128 | NNI->setNew( FALSE ); |
113 | NSResources->addNodeInstance( NNI ); | 129 | NSResources->addNodeInstance( NNI ); |
114 | } | 130 | } |
115 | } | 131 | } |
116 | } | 132 | } |
117 | 133 | ||
118 | } while( 0 ); | 134 | } while( 0 ); |
119 | 135 | ||
120 | } | 136 | } |
121 | 137 | ||
122 | QString NetworkSettingsData::saveSettings( void ) { | 138 | QString NetworkSettingsData::saveSettings( void ) { |
123 | QString ErrS = ""; | 139 | QString ErrS = ""; |
124 | 140 | ||
125 | if( ! isModified() ) | 141 | if( ! isModified() ) |
126 | return ErrS; | 142 | return ErrS; |
127 | 143 | ||
128 | QString S; | 144 | QString S; |
129 | QFile F( CfgFile + ".bup" ); | 145 | QFile F( CfgFile + ".bup" ); |
130 | 146 | ||
131 | printf( "Saving settings to %s\n", CfgFile.latin1() ); | 147 | printf( "Saving settings to %s\n", CfgFile.latin1() ); |
132 | if( ! F.open( IO_WriteOnly | IO_Truncate ) ) { | 148 | if( ! F.open( IO_WriteOnly | IO_Truncate ) ) { |
133 | ErrS = qApp->translate( "NetworkSettings", | 149 | ErrS = qApp->translate( "NetworkSettings", |
134 | "<p>Could not save setup to \"%1\" !</p>" ). | 150 | "<p>Could not save setup to \"%1\" !</p>" ). |
135 | arg(CfgFile); | 151 | arg(CfgFile); |
136 | // problem | 152 | // problem |
137 | return ErrS; | 153 | return ErrS; |
138 | } | 154 | } |
139 | 155 | ||
140 | QTextStream TS( &F ); | 156 | QTextStream TS( &F ); |
157 | |||
158 | // save leftovers | ||
159 | for ( QStringList::Iterator it = LeftOvers.begin(); | ||
160 | it != LeftOvers.end(); ++it ) { | ||
161 | TS << (*it) << endl; | ||
162 | } | ||
163 | |||
164 | // save global configs | ||
165 | for( QDictIterator<NetNode_t> it( NSResources->netNodes() ); | ||
166 | it.current(); | ||
167 | ++it ) { | ||
168 | TS << "[nodetype " | ||
169 | << it.current()->NetNode->name() | ||
170 | << "]" | ||
171 | << endl; | ||
172 | |||
173 | it.current()->NetNode->saveAttributes( TS ); | ||
174 | } | ||
175 | |||
141 | { Name2Connection_t & M = NSResources->connections(); | 176 | { Name2Connection_t & M = NSResources->connections(); |
142 | ANetNodeInstance * NNI; | 177 | ANetNodeInstance * NNI; |
143 | 178 | ||
144 | // for all connections | 179 | // for all connections |
145 | for( QDictIterator<NodeCollection> it(M); | 180 | for( QDictIterator<NodeCollection> it(M); |
146 | it.current(); | 181 | it.current(); |
147 | ++it ) { | 182 | ++it ) { |
148 | // all nodes in those connections | 183 | // all nodes in those connections |
149 | for( QListIterator<ANetNodeInstance> nit(*(it.current())); | 184 | for( QListIterator<ANetNodeInstance> nit(*(it.current())); |
150 | nit.current(); | 185 | nit.current(); |
151 | ++nit ) { | 186 | ++nit ) { |
152 | // header | 187 | // header |
153 | NNI = nit.current(); | 188 | NNI = nit.current(); |
154 | TS << '[' <<NNI->nodeClass()->nodeName() << ']' << endl; | 189 | TS << '[' <<NNI->nodeClass()->nodeName() << ']' << endl; |
155 | NNI->saveAttributes( TS ); | 190 | NNI->saveAttributes( TS ); |
156 | TS << endl; | 191 | TS << endl; |
157 | } | 192 | } |
158 | 193 | ||
159 | TS << "[connection]" << endl; | 194 | TS << "[connection]" << endl; |
160 | it.current()->save(TS); | 195 | it.current()->save(TS); |
161 | } | 196 | } |
162 | } | 197 | } |
163 | 198 | ||
164 | QDir D("."); | 199 | QDir D("."); |
165 | D.rename( CfgFile + ".bup", CfgFile ); | 200 | D.rename( CfgFile + ".bup", CfgFile ); |
166 | 201 | ||
167 | // | 202 | // |
168 | // proper files AND system files regenerated | 203 | // proper files AND system files regenerated |
169 | // | 204 | // |
170 | 205 | ||
171 | setModified( 0 ); | 206 | setModified( 0 ); |
172 | return ErrS; | 207 | return ErrS; |
173 | } | 208 | } |
174 | 209 | ||
175 | QString NetworkSettingsData::generateSettings( bool ForceReq ) { | 210 | QString NetworkSettingsData::generateSettings( bool ForceReq ) { |
176 | bool ForceIt; | 211 | bool ForceIt; |
177 | QString S = ""; | 212 | QString S = ""; |
178 | 213 | ||
179 | // include own force flag | 214 | // include own force flag |
180 | ForceIt = (Force) ? 1 : ForceReq; | 215 | ForceIt = (Force) ? 1 : ForceReq; |
181 | 216 | ||
182 | if( ! ForceIt && ! isModified() ) | 217 | if( ! ForceIt && ! isModified() ) |
183 | return S; | 218 | return S; |
184 | 219 | ||
185 | // regenerate system files | 220 | // regenerate system files |
186 | fprintf( stderr, "Generating settings from %s\n", CfgFile.latin1() ); | 221 | fprintf( stderr, "Generating settings from %s\n", CfgFile.latin1() ); |
187 | 222 | ||
188 | { Name2SystemFile_t & SFM = NSResources->systemFiles(); | 223 | { Name2SystemFile_t & SFM = NSResources->systemFiles(); |
189 | Name2Connection_t & M = NSResources->connections(); | 224 | Name2Connection_t & M = NSResources->connections(); |
190 | NodeCollection * NC; | 225 | NodeCollection * NC; |
191 | ANetNodeInstance * NNI; | 226 | ANetNodeInstance * NNI; |
192 | SystemFile * SF; | 227 | SystemFile * SF; |
193 | AsDevice * CurDev; | 228 | AsDevice * CurDev; |
194 | ANetNode * CurDevNN; | 229 | ANetNode * CurDevNN; |
195 | bool needToRegenerate = ForceIt; | 230 | bool needToRegenerate = ForceIt; |
196 | 231 | ||
197 | // | 232 | // |
198 | // check if we need to generate at least one of the system files | 233 | // check if we need to generate at least one of the system files |
199 | // | 234 | // |
200 | if( ! ForceIt ) { | 235 | if( ! ForceIt ) { |
201 | for( QDictIterator<SystemFile> sfit(SFM); | 236 | for( QDictIterator<SystemFile> sfit(SFM); |
202 | sfit.current(); | 237 | sfit.current(); |
203 | ++sfit ) { | 238 | ++sfit ) { |
204 | SF = sfit.current(); | 239 | SF = sfit.current(); |
205 | 240 | ||
206 | // check if there are nodes that are modified and require | 241 | // check if there are nodes that are modified and require |
207 | // data for this system file | 242 | // data for this system file |
208 | 243 | ||
209 | // for all connections | 244 | // for all connections |
210 | for( QDictIterator<NodeCollection> ncit(M); | 245 | for( QDictIterator<NodeCollection> ncit(M); |
211 | ncit.current(); | 246 | ncit.current(); |
212 | ++ncit ) { | 247 | ++ncit ) { |
213 | NC = ncit.current(); | 248 | NC = ncit.current(); |
214 | 249 | ||
215 | if( NC->isModified() ) { | 250 | if( NC->isModified() ) { |
216 | // does this connection 'touch' this system file ? | 251 | // does this connection 'touch' this system file ? |
217 | for( QListIterator<ANetNodeInstance> cncit(*NC); | 252 | for( QListIterator<ANetNodeInstance> cncit(*NC); |
218 | cncit.current(); | 253 | cncit.current(); |
219 | ++cncit ) { | 254 | ++cncit ) { |
220 | NNI = cncit.current(); | 255 | NNI = cncit.current(); |
221 | if( ( NNI->nodeClass()->hasDataFor( SF->name() ) || | 256 | if( ( NNI->nodeClass()->hasDataFor( SF->name() ) || |
222 | NNI->hasDataFor( SF->name() ) | 257 | NNI->hasDataFor( SF->name() ) |
223 | ) && | 258 | ) && |
224 | NNI->isModified() ) { | 259 | NNI->isModified() ) { |
225 | needToRegenerate = 1; | 260 | needToRegenerate = 1; |
226 | break; | 261 | break; |
227 | } | 262 | } |
228 | } | 263 | } |
229 | } | 264 | } |
230 | if( needToRegenerate ) | 265 | if( needToRegenerate ) |
231 | break; | 266 | break; |
232 | } | 267 | } |
233 | if( needToRegenerate ) | 268 | if( needToRegenerate ) |
234 | break; | 269 | break; |
235 | } | 270 | } |
236 | } | 271 | } |
237 | 272 | ||
238 | // we cannot renumber with a FORCE request since | 273 | // we cannot renumber with a FORCE request since |
239 | // we probably are NOT going to save the config | 274 | // we probably are NOT going to save the config |
240 | // e.g. when using --regen option | 275 | // e.g. when using --regen option |
241 | if( ! ForceReq && needToRegenerate ) { | 276 | if( ! ForceReq && needToRegenerate ) { |
242 | NSResources->renumberConnections(); | 277 | NSResources->renumberConnections(); |
243 | setModified(1); | 278 | setModified(1); |
244 | } | 279 | } |
245 | 280 | ||
246 | // | 281 | // |
247 | // generate files proper to each netnodeinstance | 282 | // generate files proper to each netnodeinstance |
248 | // | 283 | // |
249 | { Name2Instance_t & NNIs = NSResources->netNodeInstances(); | 284 | { Name2Instance_t & NNIs = NSResources->netNodeInstances(); |
250 | 285 | ||
251 | for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); | 286 | for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); |
252 | NNIIt.current(); | 287 | NNIIt.current(); |
253 | ++NNIIt | 288 | ++NNIIt |
254 | ){ | 289 | ){ |
255 | // for all nodes find those that are modified | 290 | // for all nodes find those that are modified |
256 | NNI = NNIIt.current(); | 291 | NNI = NNIIt.current(); |
257 | 292 | ||
258 | if( ForceIt || NNI->isModified() ) { | 293 | if( ForceIt || NNI->isModified() ) { |
259 | if( ! NNI->nodeClass()->generateProperFilesFor( NNI ) ) { | 294 | if( ! NNI->nodeClass()->generateProperFilesFor( NNI ) ) { |
260 | // problem generating | 295 | // problem generating |
261 | S = qApp->translate( "NetworkSettings", | 296 | S = qApp->translate( "NetworkSettings", |
262 | "<p>Cannot generate files proper to \"%1\"</p>" ). | 297 | "<p>Cannot generate files proper to \"%1\"</p>" ). |
263 | arg(NNI->nodeClass()->nodeName()) ; | 298 | arg(NNI->nodeClass()->nodeName()) ; |
264 | return S; | 299 | return S; |
265 | } | 300 | } |
266 | } | 301 | } |
267 | } | 302 | } |
268 | } | 303 | } |
269 | 304 | ||
270 | // | 305 | // |
271 | // generate all system files | 306 | // generate all system files |
272 | // | 307 | // |
273 | for( QDictIterator<SystemFile> sfit(SFM); | 308 | for( QDictIterator<SystemFile> sfit(SFM); |
274 | sfit.current(); | 309 | sfit.current(); |
275 | ++sfit ) { | 310 | ++sfit ) { |
276 | SF = sfit.current(); | 311 | SF = sfit.current(); |
277 | 312 | ||
278 | fprintf( stderr, "Generating %s\n", SF->name().latin1() ); | 313 | fprintf( stderr, "Generating %s\n", SF->name().latin1() ); |
279 | SF->open(); | 314 | SF->open(); |
280 | 315 | ||
281 | do { // so we can break; | 316 | do { // so we can break; |
282 | 317 | ||
283 | // global presection for this system file | 318 | // global presection for this system file |
284 | if( SF->preSection() ) { | 319 | if( SF->preSection() ) { |
285 | S = qApp->translate( "NetworkSettings", | 320 | S = qApp->translate( "NetworkSettings", |
286 | "<p>Error in preSection for file \"%1\"</p>" ). | 321 | "<p>Error in preSection for file \"%1\"</p>" ). |
287 | arg( SF->name() ); | 322 | arg( SF->name() ); |
288 | return S; | 323 | return S; |
289 | } | 324 | } |
290 | 325 | ||
291 | // find all netnodes and figure out if | 326 | // find all netnodes and figure out if |
292 | // for that node there are instances | 327 | // for that node there are instances |
293 | for( QDictIterator<NetNode_t> nnit( | 328 | for( QDictIterator<NetNode_t> nnit( |
294 | NSResources->netNodes() ); | 329 | NSResources->netNodes() ); |
295 | nnit.current(); | 330 | nnit.current(); |
296 | ++nnit ) { | 331 | ++nnit ) { |
297 | 332 | ||
298 | CurDevNN = nnit.current()->NetNode; | 333 | CurDevNN = nnit.current()->NetNode; |
299 | 334 | ||
300 | // are there instances for this netnode ? | 335 | // are there instances for this netnode ? |
301 | NNI = 0; | 336 | NNI = 0; |
302 | for( QDictIterator<ANetNodeInstance> nniit( | 337 | for( QDictIterator<ANetNodeInstance> nniit( |
303 | NSResources->netNodeInstances() ); | 338 | NSResources->netNodeInstances() ); |
304 | nniit.current(); | 339 | nniit.current(); |
305 | ++nniit ) { | 340 | ++nniit ) { |
306 | if( nniit.current()->nodeClass() == CurDevNN ) { | 341 | if( nniit.current()->nodeClass() == CurDevNN ) { |
307 | NNI = nniit.current(); | 342 | NNI = nniit.current(); |
308 | break; | 343 | break; |
309 | } | 344 | } |
310 | } | 345 | } |
311 | 346 | ||
312 | if( ! NNI ) | 347 | if( ! NNI ) |
313 | // no instances -> next netnode type | 348 | // no instances -> next netnode type |
314 | continue; | 349 | continue; |
315 | 350 | ||
316 | // has this node data for this system file ? | 351 | // has this node data for this system file ? |
317 | if( (CurDev = NNI->runtime()->asDevice() ) ) { | 352 | if( (CurDev = NNI->runtime()->asDevice() ) ) { |
318 | // generate start for this nodetype for all possible devices of this type | 353 | // generate start for this nodetype for all possible devices of this type |
319 | for( int i = 0; i < CurDevNN->instanceCount(); i ++ ) { | 354 | for( int i = 0; i < CurDevNN->instanceCount(); i ++ ) { |
320 | S = generateSystemFileNode( *SF, CurDev, NNI, i ); | 355 | S = generateSystemFileNode( *SF, CurDev, NNI, i ); |
321 | if( ! S.isEmpty() ) | 356 | if( ! S.isEmpty() ) |
322 | return S; | 357 | return S; |
323 | } | 358 | } |
324 | } else { | 359 | } else { |
325 | S = generateSystemFileNode( *SF, 0, NNI, -1 ); | 360 | S = generateSystemFileNode( *SF, 0, NNI, -1 ); |
326 | if( ! S.isEmpty() ) | 361 | if( ! S.isEmpty() ) |
327 | return S; | 362 | return S; |
328 | } | 363 | } |
329 | } | 364 | } |
330 | 365 | ||
331 | if( SF->postSection() ) { | 366 | if( SF->postSection() ) { |
332 | S = qApp->translate( "NetworkSettings", | 367 | S = qApp->translate( "NetworkSettings", |
333 | "<p>Error in postSection for file \"%1\"</p>" ). | 368 | "<p>Error in postSection for file \"%1\"</p>" ). |
334 | arg( SF->name() ); | 369 | arg( SF->name() ); |
335 | return S; | 370 | return S; |
336 | } | 371 | } |
337 | 372 | ||
338 | } while( 0 ); | 373 | } while( 0 ); |
339 | SF->close(); | 374 | SF->close(); |
340 | } | 375 | } |
341 | } | 376 | } |
342 | Force = 0; | 377 | Force = 0; |
343 | return S; | 378 | return S; |
344 | } | 379 | } |
345 | 380 | ||
346 | QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) { | 381 | QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) { |
347 | // collect connections that can work on top of this interface | 382 | // collect connections that can work on top of this interface |
348 | NodeCollection * NC; | 383 | NodeCollection * NC; |
349 | QList<NodeCollection> PossibleConnections; | 384 | QList<NodeCollection> PossibleConnections; |
350 | Name2Connection_t & M = NSResources->connections(); | 385 | Name2Connection_t & M = NSResources->connections(); |
351 | 386 | ||
352 | // for all connections | 387 | // for all connections |
353 | for( QDictIterator<NodeCollection> it(M); | 388 | for( QDictIterator<NodeCollection> it(M); |
354 | it.current(); | 389 | it.current(); |
355 | ++it ) { | 390 | ++it ) { |
356 | NC = it.current(); | 391 | NC = it.current(); |
357 | // check if this profile handles the requested interface | 392 | // check if this profile handles the requested interface |
358 | fprintf( stderr, "check %s\n", NC->name().latin1() ); | 393 | fprintf( stderr, "check %s\n", NC->name().latin1() ); |
359 | if( NC->handlesInterface( Interface ) && // if different Intf. | 394 | if( NC->handlesInterface( Interface ) && // if different Intf. |
360 | NC->state() != Disabled && // if not enabled | 395 | NC->state() != Disabled && // if not enabled |
361 | NC->state() != IsUp // if already used | 396 | NC->state() != IsUp // if already used |
362 | ) { | 397 | ) { |
363 | fprintf( stderr, "Append %s\n", NC->name().latin1() ); | 398 | fprintf( stderr, "Append %s\n", NC->name().latin1() ); |
364 | PossibleConnections.append( NC ); | 399 | PossibleConnections.append( NC ); |
365 | } | 400 | } |
366 | } | 401 | } |
367 | return PossibleConnections; | 402 | return PossibleConnections; |
368 | } | 403 | } |
369 | 404 | ||
370 | 405 | ||
371 | /* | 406 | /* |
372 | Called by the system to see if interface can be brought UP | 407 | Called by the system to see if interface can be brought UP |
373 | 408 | ||
374 | if allowed, echo Interface-allowed else Interface-disallowed | 409 | if allowed, echo Interface-allowed else Interface-disallowed |
375 | */ | 410 | */ |
376 | 411 | ||
377 | bool NetworkSettingsData::canStart( const char * Interface ) { | 412 | bool NetworkSettingsData::canStart( const char * Interface ) { |
378 | // load situation | 413 | // load situation |
379 | NodeCollection * NC = 0; | 414 | NodeCollection * NC = 0; |
380 | QList<NodeCollection> PossibleConnections; | 415 | QList<NodeCollection> PossibleConnections; |
381 | 416 | ||
382 | PossibleConnections = collectPossible( Interface ); | 417 | PossibleConnections = collectPossible( Interface ); |
383 | 418 | ||
384 | fprintf( stderr, "Possiblilies %d\n", | 419 | fprintf( stderr, "Possiblilies %d\n", |
385 | PossibleConnections.count() ); | 420 | PossibleConnections.count() ); |
386 | switch( PossibleConnections.count() ) { | 421 | switch( PossibleConnections.count() ) { |
387 | case 0 : // no connections | 422 | case 0 : // no connections |
388 | break; | 423 | break; |
389 | case 1 : // one connection | 424 | case 1 : // one connection |
390 | NC = PossibleConnections.first(); | 425 | NC = PossibleConnections.first(); |
391 | break; | 426 | break; |
392 | default : // need to ask user ? | 427 | default : // need to ask user ? |
393 | return 1; | 428 | return 1; |
394 | } | 429 | } |
395 | 430 | ||
396 | if( NC ) { | 431 | if( NC ) { |
397 | switch( NC->state() ) { | 432 | switch( NC->state() ) { |
398 | case Unchecked : | 433 | case Unchecked : |
399 | case Unknown : | 434 | case Unknown : |
400 | case Unavailable : | 435 | case Unavailable : |
401 | case Disabled : | 436 | case Disabled : |
402 | // this profile does not allow interface to be UP | 437 | // this profile does not allow interface to be UP |
403 | // -> try others | 438 | // -> try others |
404 | break; | 439 | break; |
405 | case Off : | 440 | case Off : |
406 | // try to UP the device | 441 | // try to UP the device |
407 | if( ! NC->setState( Activate ) ) { | 442 | if( ! NC->setState( Activate ) ) { |
408 | // cannot bring device Online -> try other alters | 443 | // cannot bring device Online -> try other alters |
409 | break; | 444 | break; |
410 | } | 445 | } |
411 | // FT | 446 | // FT |
412 | case Available : | 447 | case Available : |
413 | case IsUp : // also called for 'ifdown' | 448 | case IsUp : // also called for 'ifdown' |
414 | // device is ready -> done | 449 | // device is ready -> done |
415 | printf( "%s-c%d-allowed\n", Interface, NC->number() ); | 450 | printf( "%s-c%d-allowed\n", Interface, NC->number() ); |
416 | return 0; | 451 | return 0; |
417 | } | 452 | } |
418 | } | 453 | } |
419 | 454 | ||
420 | // if we come here no alternatives are possible | 455 | // if we come here no alternatives are possible |
421 | printf( "%s-cnn-disallowed\n", Interface ); | 456 | printf( "%s-cnn-disallowed\n", Interface ); |
422 | return 0; | 457 | return 0; |
423 | } | 458 | } |
424 | 459 | ||
425 | /* | 460 | /* |
426 | Called by the system to regenerate config files | 461 | Called by the system to regenerate config files |
427 | */ | 462 | */ |
428 | 463 | ||
429 | bool NetworkSettingsData::regenerate( void ) { | 464 | bool NetworkSettingsData::regenerate( void ) { |
430 | QString S; | 465 | QString S; |
431 | // load situation | 466 | // load situation |
432 | S = generateSettings( TRUE ); | 467 | S = generateSettings( TRUE ); |
433 | if( ! S.isEmpty() ) { | 468 | if( ! S.isEmpty() ) { |
434 | fprintf( stdout, "%s\n", S.latin1() ); | 469 | fprintf( stdout, "%s\n", S.latin1() ); |
435 | return 1; | 470 | return 1; |
436 | } | 471 | } |
437 | return 0; | 472 | return 0; |
438 | } | 473 | } |
439 | 474 | ||
440 | QString NetworkSettingsData::generateSystemFileNode( | 475 | QString NetworkSettingsData::generateSystemFileNode( |
441 | SystemFile &SF, | 476 | SystemFile &SF, |
442 | AsDevice * CurDev, | 477 | AsDevice * CurDev, |
443 | ANetNodeInstance * DevNNI, | 478 | ANetNodeInstance * DevNNI, |
444 | long DevInstNr ) { | 479 | long DevInstNr ) { |
445 | 480 | ||
446 | QString S=""; | 481 | QString S=""; |
447 | ANetNode * CurDevNN = DevNNI->nodeClass(); | 482 | ANetNode * CurDevNN = DevNNI->nodeClass(); |
448 | Name2Connection_t & M = NSResources->connections(); | 483 | Name2Connection_t & M = NSResources->connections(); |
449 | 484 | ||
450 | if( SF.preDeviceSection( CurDevNN ) ) { | 485 | if( SF.preDeviceSection( CurDevNN ) ) { |
451 | S = qApp->translate( "NetworkSettings", | 486 | S = qApp->translate( "NetworkSettings", |
452 | "<p>Error in preDeviceSection for file \"%1\" and nodetype \"%2\"</p>" ). | 487 | "<p>Error in preDeviceSection for file \"%1\" and nodetype \"%2\"</p>" ). |
453 | arg( SF.name() ). | 488 | arg( SF.name() ). |
454 | arg( CurDevNN->nodeName() ); | 489 | arg( CurDevNN->nodeName() ); |
455 | return S; | 490 | return S; |
456 | } | 491 | } |
457 | 492 | ||
458 | if( CurDevNN->hasDataFor( SF.name() ) ) { | 493 | if( CurDevNN->hasDataFor( SF.name() ) ) { |
459 | if( CurDevNN->generateDeviceDataForCommonFile( SF, DevInstNr ) ) { | 494 | if( CurDevNN->generateDeviceDataForCommonFile( SF, DevInstNr ) ) { |
460 | S = qApp->translate( "NetworkSettings", | 495 | S = qApp->translate( "NetworkSettings", |
461 | "<p>Error in node Device part for file \"%1\" and node \"%2\"</p>" ). | 496 | "<p>Error in node Device part for file \"%1\" and node \"%2\"</p>" ). |
462 | arg( SF.name() ). | 497 | arg( SF.name() ). |
463 | arg( CurDevNN->nodeName() ); | 498 | arg( CurDevNN->nodeName() ); |
464 | return S; | 499 | return S; |
465 | } | 500 | } |
466 | } | 501 | } |
467 | 502 | ||
468 | if( CurDev ) | 503 | if( CurDev ) |
469 | fprintf( stderr, "Cur %s\n", CurDevNN->nodeName().latin1() ); | 504 | fprintf( stderr, "Cur %s\n", CurDevNN->nodeName().latin1() ); |
470 | else | 505 | else |
471 | fprintf( stderr, "Cur NO\n" ); | 506 | fprintf( stderr, "Cur NO\n" ); |
472 | 507 | ||
473 | // now generate profile specific data for all | 508 | // now generate profile specific data for all |
474 | // connections working on a device of the current | 509 | // connections working on a device of the current |
475 | // netnode type | 510 | // netnode type |
476 | for( QDictIterator<NodeCollection> ncit(M); | 511 | for( QDictIterator<NodeCollection> ncit(M); |
477 | ncit.current(); | 512 | ncit.current(); |
478 | ++ncit ) { | 513 | ++ncit ) { |
479 | NodeCollection * NC = ncit.current(); | 514 | NodeCollection * NC = ncit.current(); |
480 | 515 | ||
481 | // currenly only those connections that work on | 516 | // currenly only those connections that work on |
482 | // the current device (or on no device if no current) | 517 | // the current device (or on no device if no current) |
483 | AsDevice * Dev = NC->device(); | 518 | AsDevice * Dev = NC->device(); |
484 | 519 | ||
485 | fprintf( stderr, "%s\n", Dev->netNode()->nodeName().latin1() ); | 520 | fprintf( stderr, "%s\n", Dev->netNode()->nodeName().latin1() ); |
486 | if( CurDev ) { | 521 | if( CurDev ) { |
487 | if( CurDevNN != Dev->netNode()->nodeClass() ) { | 522 | if( CurDevNN != Dev->netNode()->nodeClass() ) { |
488 | // other device type -> later | 523 | // other device type -> later |
489 | fprintf( stderr, "Other Dev type\n" ); | 524 | fprintf( stderr, "Other Dev type\n" ); |
490 | continue; | 525 | continue; |
491 | } | 526 | } |
492 | } else { | 527 | } else { |
493 | if( Dev ) { | 528 | if( Dev ) { |
494 | // other | 529 | // other |
495 | continue; | 530 | continue; |
496 | } | 531 | } |
497 | } | 532 | } |
498 | 533 | ||
499 | // generate 'entry' | 534 | // generate 'entry' |
500 | if( SF.preNodeSection( DevNNI, DevInstNr ) ) { | 535 | if( SF.preNodeSection( DevNNI, DevInstNr ) ) { |
501 | S = qApp->translate( "NetworkSettings", | 536 | S = qApp->translate( "NetworkSettings", |
502 | "<p>Error in preNodeSection for file \"%1\" and node \"%2\"</p>" ). | 537 | "<p>Error in preNodeSection for file \"%1\" and node \"%2\"</p>" ). |
503 | arg( SF.name() ). | 538 | arg( SF.name() ). |
504 | arg( CurDevNN->nodeName() ); | 539 | arg( CurDevNN->nodeName() ); |
505 | return S; | 540 | return S; |
506 | } | 541 | } |
507 | 542 | ||
508 | // ask all nodes in connection | 543 | // ask all nodes in connection |
509 | for( QListIterator<ANetNodeInstance> cncit(*NC); | 544 | for( QListIterator<ANetNodeInstance> cncit(*NC); |
510 | cncit.current(); | 545 | cncit.current(); |
511 | ++cncit ) { | 546 | ++cncit ) { |
512 | ANetNodeInstance * NNI = cncit.current(); | 547 | ANetNodeInstance * NNI = cncit.current(); |
513 | 548 | ||
514 | if( NNI->hasDataFor( SF.name() ) ) { | 549 | if( NNI->hasDataFor( SF.name() ) ) { |
515 | if( NNI->generateDataForCommonFile(SF,DevInstNr) ) { | 550 | if( NNI->generateDataForCommonFile(SF,DevInstNr) ) { |
516 | S = qApp->translate( "NetworkSettings", | 551 | S = qApp->translate( "NetworkSettings", |
517 | "<p>Error in node part for file \"%1\" and node \"%2\"</p>" ). | 552 | "<p>Error in node part for file \"%1\" and node \"%2\"</p>" ). |
518 | arg( SF.name() ). | 553 | arg( SF.name() ). |
519 | arg( NNI->nodeClass()->nodeName() ); | 554 | arg( NNI->nodeClass()->nodeName() ); |
520 | return S; | 555 | return S; |
521 | } | 556 | } |
522 | } | 557 | } |
523 | } | 558 | } |
524 | 559 | ||
diff --git a/noncore/settings/networksettings2/nsdata.h b/noncore/settings/networksettings2/nsdata.h index eb96930..57eb722 100644 --- a/noncore/settings/networksettings2/nsdata.h +++ b/noncore/settings/networksettings2/nsdata.h | |||
@@ -1,43 +1,46 @@ | |||
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 | // return TRUE if we need gui to decide | 24 | // return TRUE if we need gui to decide |
25 | bool canStart( const char * Interface ); | 25 | bool canStart( const char * Interface ); |
26 | bool regenerate( void ); | 26 | bool regenerate( void ); |
27 | 27 | ||
28 | void forceGeneration( bool m ) | 28 | void forceGeneration( bool m ) |
29 | { Force = m; } | 29 | { Force = m; } |
30 | 30 | ||
31 | private : | 31 | private : |
32 | 32 | ||
33 | QString NetworkSettingsData::generateSystemFileNode( | 33 | QString NetworkSettingsData::generateSystemFileNode( |
34 | SystemFile & SF, | 34 | SystemFile & SF, |
35 | AsDevice * CurDev, | 35 | AsDevice * CurDev, |
36 | ANetNodeInstance * DevNNI, | 36 | ANetNodeInstance * DevNNI, |
37 | long DevInstNr ); | 37 | long DevInstNr ); |
38 | bool IsModified; | 38 | bool IsModified; |
39 | bool Force; | 39 | bool Force; |
40 | 40 | ||
41 | // collect strings in config file nobody wants | ||
42 | QStringList LeftOvers; | ||
43 | |||
41 | }; | 44 | }; |
42 | 45 | ||
43 | #endif | 46 | #endif |
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp index b3f70c5..0bf415b 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp | |||
@@ -1,62 +1,68 @@ | |||
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::generateDeviceDataForCommonFile( | 47 | bool PPPNetNode::generateDeviceDataForCommonFile( |
48 | SystemFile & , | 48 | SystemFile & , |
49 | long ) { | 49 | long ) { |
50 | return 1; | 50 | return 1; |
51 | } | 51 | } |
52 | 52 | ||
53 | QString PPPNetNode::genNic( long NicNr ) { | 53 | QString PPPNetNode::genNic( long NicNr ) { |
54 | QString S; | 54 | QString S; |
55 | return S.sprintf( "ppp%ld", NicNr ); | 55 | return S.sprintf( "ppp%ld", NicNr ); |
56 | } | 56 | } |
57 | 57 | ||
58 | void PPPNetNode::setSpecificAttribute( QString & , QString & ) { | ||
59 | } | ||
60 | |||
61 | void PPPNetNode::saveSpecificAttribute( QTextStream & ) { | ||
62 | } | ||
63 | |||
58 | extern "C" { | 64 | extern "C" { |
59 | void create_plugin( QList<ANetNode> & PNN ) { | 65 | void create_plugin( QList<ANetNode> & PNN ) { |
60 | PNN.append( new PPPNetNode() ); | 66 | PNN.append( new PPPNetNode() ); |
61 | } | 67 | } |
62 | } | 68 | } |
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.h b/noncore/settings/networksettings2/ppp/ppp_NN.h index c33f281..fbbbbe1 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.h +++ b/noncore/settings/networksettings2/ppp/ppp_NN.h | |||
@@ -1,47 +1,49 @@ | |||
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 & ) | 31 | virtual bool hasDataFor( const QString & ) |
32 | { return 0; } | 32 | { return 0; } |
33 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
34 | SystemFile & SF, long DevNr ); | 34 | SystemFile & SF, long DevNr ); |
35 | 35 | ||
36 | virtual QString genNic( long NicNr ); | 36 | virtual QString genNic( long NicNr ); |
37 | 37 | ||
38 | private: | 38 | private: |
39 | 39 | ||
40 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | ||
41 | virtual void saveSpecificAttribute( QTextStream & TS ); | ||
40 | }; | 42 | }; |
41 | 43 | ||
42 | extern "C" | 44 | extern "C" |
43 | { | 45 | { |
44 | void create_plugin( QList<ANetNode> & PNN ); | 46 | void create_plugin( QList<ANetNode> & PNN ); |
45 | }; | 47 | }; |
46 | 48 | ||
47 | #endif | 49 | #endif |
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp index 7609cdc..0f71dc7 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.cpp +++ b/noncore/settings/networksettings2/profile/profile_NN.cpp | |||
@@ -1,56 +1,62 @@ | |||
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::generateDeviceDataForCommonFile( | 46 | bool ProfileNetNode::generateDeviceDataForCommonFile( |
47 | SystemFile & , | 47 | SystemFile & , |
48 | long ) { | 48 | long ) { |
49 | return 1; | 49 | return 1; |
50 | } | 50 | } |
51 | 51 | ||
52 | void ProfileNetNode::setSpecificAttribute( QString & , QString & ) { | ||
53 | } | ||
54 | |||
55 | void ProfileNetNode::saveSpecificAttribute( QTextStream & ) { | ||
56 | } | ||
57 | |||
52 | extern "C" { | 58 | extern "C" { |
53 | void create_plugin( QList<ANetNode> & PNN ) { | 59 | void create_plugin( QList<ANetNode> & PNN ) { |
54 | PNN.append( new ProfileNetNode() ); | 60 | PNN.append( new ProfileNetNode() ); |
55 | } | 61 | } |
56 | } | 62 | } |
diff --git a/noncore/settings/networksettings2/profile/profile_NN.h b/noncore/settings/networksettings2/profile/profile_NN.h index f7c2b22..1313ab2 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.h +++ b/noncore/settings/networksettings2/profile/profile_NN.h | |||
@@ -1,45 +1,47 @@ | |||
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 & ) | 31 | virtual bool hasDataFor( const QString & ) |
32 | { return 0; } | 32 | { return 0; } |
33 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
34 | SystemFile & SF, long DevNr); | 34 | SystemFile & SF, long DevNr); |
35 | 35 | ||
36 | private: | 36 | private: |
37 | 37 | ||
38 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | ||
39 | virtual void saveSpecificAttribute( QTextStream & TS ); | ||
38 | }; | 40 | }; |
39 | 41 | ||
40 | extern "C" | 42 | extern "C" |
41 | { | 43 | { |
42 | void create_plugin( QList<ANetNode> & PNN ); | 44 | void create_plugin( QList<ANetNode> & PNN ); |
43 | }; | 45 | }; |
44 | 46 | ||
45 | #endif | 47 | #endif |
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp index 30c72db..d5971cf 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.cpp +++ b/noncore/settings/networksettings2/usb/usb_NN.cpp | |||
@@ -1,71 +1,77 @@ | |||
1 | #include "usb_NN.h" | 1 | #include "usb_NN.h" |
2 | #include "usb_NNI.h" | 2 | #include "usb_NNI.h" |
3 | 3 | ||
4 | static const char * USBNeeds[] = | 4 | static const char * USBNeeds[] = |
5 | { 0 | 5 | { 0 |
6 | }; | 6 | }; |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * Constructor, find all of the possible interfaces | 9 | * Constructor, find all of the possible interfaces |
10 | */ | 10 | */ |
11 | USBNetNode::USBNetNode() : ANetNode() { | 11 | USBNetNode::USBNetNode() : ANetNode() { |
12 | } | 12 | } |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * Delete any interfaces that we own. | 15 | * Delete any interfaces that we own. |
16 | */ | 16 | */ |
17 | USBNetNode::~USBNetNode(){ | 17 | USBNetNode::~USBNetNode(){ |
18 | } | 18 | } |
19 | 19 | ||
20 | const QString USBNetNode::nodeDescription(){ | 20 | const QString USBNetNode::nodeDescription(){ |
21 | return tr("\ | 21 | return tr("\ |
22 | <p>Configure Ethernet over USB.</p>\ | 22 | <p>Configure Ethernet over USB.</p>\ |
23 | <p>Use this for a computer to computer USB cable connection</p>\ | 23 | <p>Use this for a computer to computer USB cable connection</p>\ |
24 | " | 24 | " |
25 | ); | 25 | ); |
26 | } | 26 | } |
27 | 27 | ||
28 | ANetNodeInstance * USBNetNode::createInstance( void ) { | 28 | ANetNodeInstance * USBNetNode::createInstance( void ) { |
29 | return new AUSB( this ); | 29 | return new AUSB( this ); |
30 | } | 30 | } |
31 | 31 | ||
32 | const char ** USBNetNode::needs( void ) { | 32 | const char ** USBNetNode::needs( void ) { |
33 | return USBNeeds; | 33 | return USBNeeds; |
34 | } | 34 | } |
35 | 35 | ||
36 | const char * USBNetNode::provides( void ) { | 36 | const char * USBNetNode::provides( void ) { |
37 | return "device"; | 37 | return "device"; |
38 | } | 38 | } |
39 | 39 | ||
40 | bool USBNetNode::generateProperFilesFor( | 40 | bool USBNetNode::generateProperFilesFor( |
41 | ANetNodeInstance * ) { | 41 | ANetNodeInstance * ) { |
42 | return 1; | 42 | return 1; |
43 | } | 43 | } |
44 | 44 | ||
45 | bool USBNetNode::hasDataFor( const QString & S ) { | 45 | bool USBNetNode::hasDataFor( const QString & S ) { |
46 | return (S== "interfaces"); | 46 | return (S== "interfaces"); |
47 | } | 47 | } |
48 | 48 | ||
49 | bool USBNetNode::generateDeviceDataForCommonFile( | 49 | bool USBNetNode::generateDeviceDataForCommonFile( |
50 | SystemFile & S , | 50 | SystemFile & S , |
51 | long DevNr ) { | 51 | long DevNr ) { |
52 | QString NIC = genNic( DevNr ); | 52 | QString NIC = genNic( DevNr ); |
53 | 53 | ||
54 | if( S.name() == "interfaces" ) { | 54 | if( S.name() == "interfaces" ) { |
55 | // generate mapping stanza for this interface | 55 | // generate mapping stanza for this interface |
56 | S << "# check if " << NIC << " can be brought UP" << endl; | 56 | S << "# check if " << NIC << " can be brought UP" << endl; |
57 | S << "mapping " << NIC << endl; | 57 | S << "mapping " << NIC << endl; |
58 | S << " script networksettings2-request" << endl << endl; | 58 | S << " script networksettings2-request" << endl << endl; |
59 | } | 59 | } |
60 | return 0; | 60 | return 0; |
61 | } | 61 | } |
62 | 62 | ||
63 | QString USBNetNode::genNic( long ) { | 63 | QString USBNetNode::genNic( long ) { |
64 | return QString( "usbf" ); | 64 | return QString( "usbf" ); |
65 | } | 65 | } |
66 | 66 | ||
67 | void USBNetNode::setSpecificAttribute( QString & , QString & ) { | ||
68 | } | ||
69 | |||
70 | void USBNetNode::saveSpecificAttribute( QTextStream & ) { | ||
71 | } | ||
72 | |||
67 | extern "C" { | 73 | extern "C" { |
68 | void create_plugin( QList<ANetNode> & PNN ) { | 74 | void create_plugin( QList<ANetNode> & PNN ) { |
69 | PNN.append( new USBNetNode() ); | 75 | PNN.append( new USBNetNode() ); |
70 | } | 76 | } |
71 | } | 77 | } |
diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h index ba22b1c..0b83ea6 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.h +++ b/noncore/settings/networksettings2/usb/usb_NN.h | |||
@@ -1,46 +1,48 @@ | |||
1 | #ifndef USB_NETNODE_H | 1 | #ifndef USB_NETNODE_H |
2 | #define USB_NETNODE_H | 2 | #define USB_NETNODE_H |
3 | 3 | ||
4 | #include "netnode.h" | 4 | #include "netnode.h" |
5 | 5 | ||
6 | class AUSB; | 6 | class AUSB; |
7 | 7 | ||
8 | class USBNetNode : public ANetNode{ | 8 | class USBNetNode : public ANetNode{ |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | 13 | ||
14 | USBNetNode(); | 14 | USBNetNode(); |
15 | virtual ~USBNetNode(); | 15 | virtual ~USBNetNode(); |
16 | 16 | ||
17 | virtual const QString pixmapName() | 17 | virtual const QString pixmapName() |
18 | { return "Devices/usb"; } | 18 | { return "Devices/usb"; } |
19 | 19 | ||
20 | virtual const QString nodeName() | 20 | virtual const QString nodeName() |
21 | { return tr("USB Cable Connect"); } | 21 | { return tr("USB Cable Connect"); } |
22 | 22 | ||
23 | virtual const QString nodeDescription() ; | 23 | virtual const QString nodeDescription() ; |
24 | 24 | ||
25 | virtual ANetNodeInstance * createInstance( void ); | 25 | virtual ANetNodeInstance * createInstance( void ); |
26 | 26 | ||
27 | virtual const char ** needs( void ); | 27 | virtual const char ** needs( void ); |
28 | virtual const char * provides( void ); | 28 | virtual const char * provides( void ); |
29 | 29 | ||
30 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | 30 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); |
31 | virtual bool hasDataFor( const QString & S); | 31 | virtual bool hasDataFor( const QString & S); |
32 | virtual bool generateDeviceDataForCommonFile( | 32 | virtual bool generateDeviceDataForCommonFile( |
33 | SystemFile & SF, long DevNr ); | 33 | SystemFile & SF, long DevNr ); |
34 | 34 | ||
35 | virtual QString genNic( long nr ); | 35 | virtual QString genNic( long nr ); |
36 | 36 | ||
37 | private: | 37 | private: |
38 | 38 | ||
39 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | ||
40 | virtual void saveSpecificAttribute( QTextStream & TS ); | ||
39 | }; | 41 | }; |
40 | 42 | ||
41 | extern "C" | 43 | extern "C" |
42 | { | 44 | { |
43 | void create_plugin( QList<ANetNode> & PNN ); | 45 | void create_plugin( QList<ANetNode> & PNN ); |
44 | }; | 46 | }; |
45 | 47 | ||
46 | #endif | 48 | #endif |
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp index d9aa892..307e9dd 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp +++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp | |||
@@ -1,56 +1,62 @@ | |||
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::generateDeviceDataForCommonFile( | 46 | bool VPNNetNode::generateDeviceDataForCommonFile( |
47 | SystemFile & , | 47 | SystemFile & , |
48 | long ) { | 48 | long ) { |
49 | return 1; | 49 | return 1; |
50 | } | 50 | } |
51 | 51 | ||
52 | void VPNNetNode::setSpecificAttribute( QString & , QString & ) { | ||
53 | } | ||
54 | |||
55 | void VPNNetNode::saveSpecificAttribute( QTextStream & ) { | ||
56 | } | ||
57 | |||
52 | extern "C" { | 58 | extern "C" { |
53 | void create_plugin( QList<ANetNode> & PNN ) { | 59 | void create_plugin( QList<ANetNode> & PNN ) { |
54 | PNN.append( new VPNNetNode() ); | 60 | PNN.append( new VPNNetNode() ); |
55 | } | 61 | } |
56 | } | 62 | } |
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.h b/noncore/settings/networksettings2/vpn/vpn_NN.h index 7ce8e3a..1cd3fcc 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.h +++ b/noncore/settings/networksettings2/vpn/vpn_NN.h | |||
@@ -1,45 +1,47 @@ | |||
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 & ) | 31 | virtual bool hasDataFor( const QString & ) |
32 | { return 0; } | 32 | { return 0; } |
33 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
34 | SystemFile & SF, long DevNr ); | 34 | SystemFile & SF, long DevNr ); |
35 | 35 | ||
36 | private: | 36 | private: |
37 | 37 | ||
38 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | ||
39 | virtual void saveSpecificAttribute( QTextStream & TS ); | ||
38 | }; | 40 | }; |
39 | 41 | ||
40 | extern "C" | 42 | extern "C" |
41 | { | 43 | { |
42 | void create_plugin( QList<ANetNode> & PNN ); | 44 | void create_plugin( QList<ANetNode> & PNN ); |
43 | }; | 45 | }; |
44 | 46 | ||
45 | #endif | 47 | #endif |
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp index 4e59ac1..e0c4db2 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp | |||
@@ -1,72 +1,85 @@ | |||
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 | InstanceCount = 2; | ||
12 | } | 13 | } |
13 | 14 | ||
14 | /** | 15 | /** |
15 | * Delete any interfaces that we own. | 16 | * Delete any interfaces that we own. |
16 | */ | 17 | */ |
17 | WLanNetNode::~WLanNetNode(){ | 18 | WLanNetNode::~WLanNetNode(){ |
18 | } | 19 | } |
19 | 20 | ||
20 | const QString WLanNetNode::nodeDescription(){ | 21 | const QString WLanNetNode::nodeDescription(){ |
21 | return tr("\ | 22 | return tr("\ |
22 | <p>Configure Wi/Fi or WLan network cards.</p>\ | 23 | <p>Configure Wi/Fi or WLan network cards.</p>\ |
23 | <p>Defines Wireless options for those cards</p>\ | 24 | <p>Defines Wireless options for those cards</p>\ |
24 | " | 25 | " |
25 | ); | 26 | ); |
26 | } | 27 | } |
27 | 28 | ||
28 | ANetNodeInstance * WLanNetNode::createInstance( void ) { | 29 | ANetNodeInstance * WLanNetNode::createInstance( void ) { |
29 | return new AWLan( this ); | 30 | return new AWLan( this ); |
30 | } | 31 | } |
31 | 32 | ||
32 | const char ** WLanNetNode::needs( void ) { | 33 | const char ** WLanNetNode::needs( void ) { |
33 | return WLanNeeds; | 34 | return WLanNeeds; |
34 | } | 35 | } |
35 | 36 | ||
36 | const char * WLanNetNode::provides( void ) { | 37 | const char * WLanNetNode::provides( void ) { |
37 | return "device"; | 38 | return "device"; |
38 | } | 39 | } |
39 | 40 | ||
40 | bool WLanNetNode::generateProperFilesFor( | 41 | bool WLanNetNode::generateProperFilesFor( |
41 | ANetNodeInstance * ) { | 42 | ANetNodeInstance * ) { |
42 | return 1; | 43 | return 1; |
43 | } | 44 | } |
44 | 45 | ||
45 | bool WLanNetNode::hasDataFor( const QString & S ) { | 46 | bool WLanNetNode::hasDataFor( const QString & S ) { |
46 | return S == "interfaces"; | 47 | return S == "interfaces"; |
47 | } | 48 | } |
48 | 49 | ||
49 | bool WLanNetNode::generateDeviceDataForCommonFile( | 50 | bool WLanNetNode::generateDeviceDataForCommonFile( |
50 | SystemFile & S, | 51 | SystemFile & S, |
51 | long DevNr ) { | 52 | long DevNr ) { |
52 | QString NIC = genNic( DevNr ); | 53 | QString NIC = genNic( DevNr ); |
53 | 54 | ||
54 | if( S.name() == "interfaces" ) { | 55 | if( S.name() == "interfaces" ) { |
55 | // generate mapping stanza for this interface | 56 | // generate mapping stanza for this interface |
56 | S << "# check if " << NIC << " can be brought UP" << endl; | 57 | S << "# check if " << NIC << " can be brought UP" << endl; |
57 | S << "mapping " << NIC << endl; | 58 | S << "mapping " << NIC << endl; |
58 | S << " script networksettings2-request" << endl << endl; | 59 | S << " script networksettings2-request" << endl << endl; |
59 | } | 60 | } |
60 | return 0; | 61 | return 0; |
61 | } | 62 | } |
62 | 63 | ||
63 | QString WLanNetNode::genNic( long nr ) { | 64 | QString WLanNetNode::genNic( long nr ) { |
64 | QString S; | 65 | QString S; |
65 | return S.sprintf( "wlan%ld", nr ); | 66 | return S.sprintf( "wlan%ld", nr ); |
66 | } | 67 | } |
67 | 68 | ||
69 | void WLanNetNode::setSpecificAttribute( QString & A, QString & V ) { | ||
70 | if( A == "interfacecount" ) { | ||
71 | InstanceCount = V.toLong(); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | void WLanNetNode::saveSpecificAttribute( QTextStream & TS ) { | ||
76 | TS << "interfacecount=" | ||
77 | << InstanceCount | ||
78 | << endl; | ||
79 | } | ||
80 | |||
68 | extern "C" { | 81 | extern "C" { |
69 | void create_plugin( QList<ANetNode> & PNN ) { | 82 | void create_plugin( QList<ANetNode> & PNN ) { |
70 | PNN.append( new WLanNetNode() ); | 83 | PNN.append( new WLanNetNode() ); |
71 | } | 84 | } |
72 | } | 85 | } |
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.h b/noncore/settings/networksettings2/wlan/wlan_NN.h index f27e71c..e93a89a 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.h +++ b/noncore/settings/networksettings2/wlan/wlan_NN.h | |||
@@ -1,50 +1,56 @@ | |||
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 | 31 | ||
32 | virtual bool hasDataFor( const QString & S ); | 32 | virtual bool hasDataFor( const QString & S ); |
33 | virtual bool generateDeviceDataForCommonFile( | 33 | virtual bool generateDeviceDataForCommonFile( |
34 | SystemFile & SF, long DevNr ); | 34 | SystemFile & SF, long DevNr ); |
35 | 35 | ||
36 | virtual long instanceCount( void ) | 36 | virtual long instanceCount( void ) |
37 | { return 2; } | 37 | { return InstanceCount; } |
38 | 38 | ||
39 | virtual QString genNic( long ); | 39 | virtual QString genNic( long ); |
40 | 40 | ||
41 | private: | 41 | private: |
42 | 42 | ||
43 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | ||
44 | virtual void saveSpecificAttribute( QTextStream & TS ); | ||
45 | |||
46 | // number of interfaces for this device | ||
47 | long InstanceCount; | ||
48 | |||
43 | }; | 49 | }; |
44 | 50 | ||
45 | extern "C" | 51 | extern "C" |
46 | { | 52 | { |
47 | void create_plugin( QList<ANetNode> & PNN ); | 53 | void create_plugin( QList<ANetNode> & PNN ); |
48 | }; | 54 | }; |
49 | 55 | ||
50 | #endif | 56 | #endif |