author | wimpie <wimpie> | 2004-08-12 12:46:55 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-08-12 12:46:55 (UTC) |
commit | 8f215ba9ceb395f262517855a99d7d2d303ca760 (patch) (unidiff) | |
tree | aa5f9b14c249217b4d3fc30f4771bdaf1c3545d3 | |
parent | ef64880308b5035cc8ca2e4e79325db613af525b (diff) | |
download | opie-8f215ba9ceb395f262517855a99d7d2d303ca760.zip opie-8f215ba9ceb395f262517855a99d7d2d303ca760.tar.gz opie-8f215ba9ceb395f262517855a99d7d2d303ca760.tar.bz2 |
MANY changes
- now generates peers/pap-chap secrets files
(no chatscript yet)
(not all usefull ppp options included yet)
- still not ready for prime time yet
69 files changed, 1308 insertions, 1190 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp index d8420b9..398dcdc 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp | |||
@@ -41,10 +41,2 @@ void ABluetoothBNEP::commit( void ) { | |||
41 | setModified( 1 ); | 41 | setModified( 1 ); |
42 | } | 42 | } |
43 | |||
44 | bool ABluetoothBNEP::hasDataFor( const QString & ) { | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | bool ABluetoothBNEP::generateDataForCommonFile( SystemFile & , long ){ | ||
49 | return 0; | ||
50 | } | ||
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h index bb3e7e7..1bf0f48 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h | |||
@@ -15,20 +15,16 @@ public : | |||
15 | ABluetoothBNEP( BluetoothBNEPNetNode * PNN ); | 15 | ABluetoothBNEP( BluetoothBNEPNetNode * PNN ); |
16 | 16 | ||
17 | RuntimeInfo * runtime( void ) | ||
18 | { return | ||
19 | ( RT ) ? RT : ( RT = new BluetoothBNEPRun( this, Data ) ); | ||
20 | } | ||
21 | |||
17 | QWidget * edit( QWidget * parent ); | 22 | QWidget * edit( QWidget * parent ); |
18 | QString acceptable( void ); | 23 | QString acceptable( void ); |
19 | void commit( void ); | 24 | void commit( void ); |
20 | 25 | ||
21 | RuntimeInfo * runtime( void ) | ||
22 | { if( RT == 0 ) | ||
23 | RT = new BluetoothBNEPRun( this, Data ); | ||
24 | return RT; | ||
25 | } | ||
26 | |||
27 | virtual void * data( void ) | 26 | virtual void * data( void ) |
28 | { return (void *)&Data; } | 27 | { return (void *)&Data; } |
29 | 28 | ||
30 | virtual bool hasDataFor( const QString & S ); | ||
31 | virtual bool generateDataForCommonFile( SystemFile & SF, long ); | ||
32 | |||
33 | protected : | 29 | protected : |
34 | 30 | ||
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp index cff2639..7ec8288 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp | |||
@@ -29,10 +29,2 @@ void ABluetoothRFCOMM::commit( void ) { | |||
29 | setModified( 1 ); | 29 | setModified( 1 ); |
30 | } | 30 | } |
31 | |||
32 | bool ABluetoothRFCOMM::hasDataFor( const QString & ) { | ||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | bool ABluetoothRFCOMM::generateDataForCommonFile( SystemFile & , long ){ | ||
37 | return 0; | ||
38 | } | ||
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h index 97bd29c..820fc17 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h | |||
@@ -15,20 +15,16 @@ public : | |||
15 | ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN ); | 15 | ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN ); |
16 | 16 | ||
17 | RuntimeInfo * runtime( void ) | ||
18 | { return | ||
19 | ( RT ) ? RT : ( RT = new BluetoothRFCOMMRun( this, Data ) ); | ||
20 | } | ||
21 | |||
17 | QWidget * edit( QWidget * parent ); | 22 | QWidget * edit( QWidget * parent ); |
18 | QString acceptable( void ); | 23 | QString acceptable( void ); |
19 | void commit( void ); | 24 | void commit( void ); |
20 | 25 | ||
21 | RuntimeInfo * runtime( void ) | ||
22 | { if( RT == 0 ) | ||
23 | RT = new BluetoothRFCOMMRun( this, Data ); | ||
24 | return RT; | ||
25 | } | ||
26 | |||
27 | virtual void * data( void ) | 26 | virtual void * data( void ) |
28 | { return (void *)&Data; } | 27 | { return (void *)&Data; } |
29 | 28 | ||
30 | virtual bool hasDataFor( const QString & S ); | ||
31 | virtual bool generateDataForCommonFile( SystemFile & SF, long ); | ||
32 | |||
33 | protected : | 29 | protected : |
34 | 30 | ||
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h index aff1f59..65fd686 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h | |||
@@ -13,4 +13,7 @@ public : | |||
13 | { return (AsLine *)this; } | 13 | { return (AsLine *)this; } |
14 | 14 | ||
15 | virtual QString deviceFile( void ) | ||
16 | { return QString( "/dev/rfcomm..." ); } | ||
17 | |||
15 | protected : | 18 | protected : |
16 | 19 | ||
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp index b59b4f0..443a627 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp | |||
@@ -47,27 +47,4 @@ const char * BluetoothBNEPNetNode::provides( void ) { | |||
47 | } | 47 | } |
48 | 48 | ||
49 | bool BluetoothBNEPNetNode::generateProperFilesFor( | ||
50 | ANetNodeInstance * ) { | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | bool BluetoothBNEPNetNode::hasDataFor( const QString & S ) { | ||
55 | return S == "interfaces"; | ||
56 | } | ||
57 | |||
58 | bool BluetoothBNEPNetNode::generateDeviceDataForCommonFile( | ||
59 | SystemFile & S , | ||
60 | long DevNr) { | ||
61 | QString NIC = genNic( DevNr ); | ||
62 | |||
63 | if( S.name() == "interfaces" ) { | ||
64 | // generate mapping stanza for this interface | ||
65 | S << "# check if " << NIC << " can be brought UP" << endl; | ||
66 | S << "mapping " << NIC << endl; | ||
67 | S << " script networksettings2-request" << endl << endl; | ||
68 | } | ||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | QString BluetoothBNEPNetNode::genNic( long nr ) { | 49 | QString BluetoothBNEPNetNode::genNic( long nr ) { |
73 | QString S; | 50 | QString S; |
@@ -125,19 +102,4 @@ const char * BluetoothRFCOMMNetNode::provides( void ) { | |||
125 | } | 102 | } |
126 | 103 | ||
127 | bool BluetoothRFCOMMNetNode::generateProperFilesFor( | ||
128 | ANetNodeInstance * ) { | ||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | bool BluetoothRFCOMMNetNode::hasDataFor( const QString & ) { | ||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | bool BluetoothRFCOMMNetNode::generateDeviceDataForCommonFile( | ||
137 | SystemFile & , | ||
138 | long ) { | ||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | void BluetoothRFCOMMNetNode::setSpecificAttribute( QString &, QString & ) { | 104 | void BluetoothRFCOMMNetNode::setSpecificAttribute( QString &, QString & ) { |
143 | } | 105 | } |
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h index 2e5e1d2..4d6a3c1 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h | |||
@@ -8,29 +8,21 @@ class ABluetoothBNEP; | |||
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 QString genNic( long ); |
18 | { return "Devices/bluetooth"; } | 18 | virtual long instanceCount( void ) |
19 | { return InstanceCount; } | ||
20 | virtual const QString pixmapName() | ||
21 | { return "Devices/bluetooth"; } | ||
19 | 22 | ||
20 | virtual const QString nodeDescription() ; | 23 | virtual const QString nodeDescription() ; |
21 | 24 | virtual ANetNodeInstance * createInstance( void ); | |
22 | virtual ANetNodeInstance * createInstance( void ); | 25 | virtual const char * provides( void ); |
23 | 26 | virtual const char ** needs( void ); | |
24 | virtual const char ** needs( void ); | ||
25 | virtual const char * provides( void ); | ||
26 | |||
27 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | ||
28 | virtual bool hasDataFor( const QString & S ); | ||
29 | virtual bool generateDeviceDataForCommonFile( | ||
30 | SystemFile & , long DevNr ); | ||
31 | |||
32 | virtual long instanceCount( void ) | ||
33 | { return InstanceCount; } | ||
34 | virtual QString genNic( long ); | ||
35 | 27 | ||
36 | private: | 28 | private: |
@@ -46,25 +38,18 @@ private: | |||
46 | class BluetoothRFCOMMNetNode : public ANetNode { | 38 | class BluetoothRFCOMMNetNode : public ANetNode { |
47 | 39 | ||
48 | Q_OBJECT | 40 | Q_OBJECT |
49 | 41 | ||
50 | public: | 42 | public: |
51 | 43 | ||
52 | BluetoothRFCOMMNetNode(); | 44 | BluetoothRFCOMMNetNode(); |
53 | virtual ~BluetoothRFCOMMNetNode(); | 45 | virtual ~BluetoothRFCOMMNetNode(); |
54 | |||
55 | virtual const QString pixmapName() | ||
56 | { return "Devices/bluetooth"; } | ||
57 | |||
58 | virtual const QString nodeDescription() ; | ||
59 | |||
60 | virtual ANetNodeInstance * createInstance( void ); | ||
61 | 46 | ||
62 | virtual const char ** needs( void ); | 47 | virtual const QString pixmapName() |
63 | virtual const char * provides( void ); | 48 | { return "Devices/bluetooth"; } |
64 | 49 | ||
65 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | 50 | virtual const QString nodeDescription() ; |
66 | virtual bool hasDataFor( const QString & S ); | 51 | virtual ANetNodeInstance * createInstance( void ); |
67 | virtual bool generateDeviceDataForCommonFile( | 52 | virtual const char ** needs( void ); |
68 | SystemFile & , long ); | 53 | virtual const char * provides( void ); |
69 | 54 | ||
70 | private: | 55 | private: |
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp index b8c690b..38568df 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.cpp +++ b/noncore/settings/networksettings2/cable/cable_NN.cpp | |||
@@ -37,15 +37,4 @@ const char * CableNetNode::provides( void ) { | |||
37 | } | 37 | } |
38 | 38 | ||
39 | bool CableNetNode::generateProperFilesFor( | ||
40 | ANetNodeInstance * ) { | ||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | bool CableNetNode::generateDeviceDataForCommonFile( | ||
45 | SystemFile & , | ||
46 | long ) { | ||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | void CableNetNode::setSpecificAttribute( QString & , QString & ) { | 39 | void CableNetNode::setSpecificAttribute( QString & , QString & ) { |
51 | } | 40 | } |
diff --git a/noncore/settings/networksettings2/cable/cable_NN.h b/noncore/settings/networksettings2/cable/cable_NN.h index c48037a..5cc2b2d 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.h +++ b/noncore/settings/networksettings2/cable/cable_NN.h | |||
@@ -8,26 +8,18 @@ class ACable; | |||
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 nodeDescription() ; | 20 | virtual const QString nodeDescription() ; |
21 | 21 | virtual ANetNodeInstance * createInstance( void ); | |
22 | virtual ANetNodeInstance * createInstance( void ); | 22 | virtual const char ** needs( void ); |
23 | 23 | virtual const char * provides( void ); | |
24 | virtual const char ** needs( void ); | ||
25 | virtual const char * provides( void ); | ||
26 | |||
27 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | ||
28 | virtual bool hasDataFor( const QString & ) | ||
29 | { return 0; } | ||
30 | virtual bool generateDeviceDataForCommonFile( | ||
31 | SystemFile & SF, long DevNr); | ||
32 | 24 | ||
33 | private: | 25 | private: |
diff --git a/noncore/settings/networksettings2/cable/cable_NNI.cpp b/noncore/settings/networksettings2/cable/cable_NNI.cpp index ca21135..4bd9421 100644 --- a/noncore/settings/networksettings2/cable/cable_NNI.cpp +++ b/noncore/settings/networksettings2/cable/cable_NNI.cpp | |||
@@ -50,4 +50,27 @@ void ACable::saveSpecificAttribute( QTextStream & TS ) { | |||
50 | } | 50 | } |
51 | 51 | ||
52 | short ACable::generateFileEmbedded( const QString & ID, | ||
53 | const QString & Path, | ||
54 | QTextStream & TS, | ||
55 | long DevNr ) { | ||
56 | short rvl, rvd; | ||
57 | |||
58 | rvl = 1; | ||
59 | if( ID == "peers" ) { | ||
60 | TS << Data.Device | ||
61 | << endl; | ||
62 | TS << Data.Speed | ||
63 | << endl; | ||
64 | TS << "lock " | ||
65 | << Data.LockFile | ||
66 | << endl; | ||
67 | rvl = 0; | ||
68 | } | ||
69 | |||
70 | rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); | ||
71 | return (rvd == 2 || rvl == 2 ) ? 2 : | ||
72 | (rvd == 0 || rvl == 0 ) ? 0 : 1; | ||
73 | } | ||
74 | |||
52 | QWidget * ACable::edit( QWidget * parent ) { | 75 | QWidget * ACable::edit( QWidget * parent ) { |
53 | GUI = new CableEdit( parent ); | 76 | GUI = new CableEdit( parent ); |
@@ -65,9 +88,2 @@ void ACable::commit( void ) { | |||
65 | } | 88 | } |
66 | } | 89 | } |
67 | |||
68 | bool ACable::generateDataForCommonFile( | ||
69 | SystemFile & , | ||
70 | long ) { | ||
71 | return 1; | ||
72 | } | ||
73 | |||
diff --git a/noncore/settings/networksettings2/cable/cable_NNI.h b/noncore/settings/networksettings2/cable/cable_NNI.h index bf3e292..d06cbbe 100644 --- a/noncore/settings/networksettings2/cable/cable_NNI.h +++ b/noncore/settings/networksettings2/cable/cable_NNI.h | |||
@@ -15,22 +15,20 @@ public : | |||
15 | ACable( CableNetNode * PNN ); | 15 | ACable( CableNetNode * PNN ); |
16 | 16 | ||
17 | RuntimeInfo * runtime( void ) | ||
18 | { return | ||
19 | ( RT ) ? RT : ( RT = new CableRun( this, Data ) ); | ||
20 | } | ||
21 | |||
17 | QWidget * edit( QWidget * parent ); | 22 | QWidget * edit( QWidget * parent ); |
18 | QString acceptable( void ); | 23 | QString acceptable( void ); |
19 | void commit( void ); | 24 | void commit( void ); |
20 | 25 | ||
21 | RuntimeInfo * runtime( void ) | ||
22 | { if( RT == 0 ) | ||
23 | RT = new CableRun( this, Data ); | ||
24 | return RT; | ||
25 | } | ||
26 | |||
27 | virtual void * data( void ) | 26 | virtual void * data( void ) |
28 | { return (void *)&Data; } | 27 | { return (void *)&Data; } |
29 | 28 | ||
30 | virtual bool hasDataFor( const QString & ) | 29 | short generateFileEmbedded( const QString & ID, |
31 | { return 0; } | 30 | const QString & Path, |
32 | virtual bool generateDataForCommonFile( | 31 | QTextStream & TS, |
33 | SystemFile & SF, long DevNr ); | 32 | long DevNr ); |
34 | |||
35 | protected : | 33 | protected : |
36 | 34 | ||
diff --git a/noncore/settings/networksettings2/cable/cablerun.cpp b/noncore/settings/networksettings2/cable/cablerun.cpp index 5e99237..85660f6 100644 --- a/noncore/settings/networksettings2/cable/cablerun.cpp +++ b/noncore/settings/networksettings2/cable/cablerun.cpp | |||
@@ -5,5 +5,5 @@ | |||
5 | void CableRun::detectState( NodeCollection * NC ) { | 5 | void CableRun::detectState( NodeCollection * NC ) { |
6 | 6 | ||
7 | int fd = open( D->Device.latin1(), O_RDWR ); | 7 | int fd = open( Data->Device.latin1(), O_RDWR ); |
8 | 8 | ||
9 | if( fd < 0 ) { | 9 | if( fd < 0 ) { |
@@ -25,2 +25,6 @@ bool CableRun::canSetState( State_t , Action_t ) { | |||
25 | return 1; | 25 | return 1; |
26 | } | 26 | } |
27 | |||
28 | QString CableRun::deviceFile( void ) { | ||
29 | return Data->Device; | ||
30 | } | ||
diff --git a/noncore/settings/networksettings2/cable/cablerun.h b/noncore/settings/networksettings2/cable/cablerun.h index c5b59d5..20608f6 100644 --- a/noncore/settings/networksettings2/cable/cablerun.h +++ b/noncore/settings/networksettings2/cable/cablerun.h | |||
@@ -7,10 +7,12 @@ public : | |||
7 | 7 | ||
8 | CableRun( ANetNodeInstance * NNI, | 8 | CableRun( ANetNodeInstance * NNI, |
9 | CableData & Data ) : AsLine( NNI ) | 9 | CableData_t & D ) : AsLine( NNI ) |
10 | { D = &Data; } | 10 | { Data = &D; } |
11 | 11 | ||
12 | virtual AsLine * asLine( void ) | 12 | virtual AsLine * asLine( void ) |
13 | { return (AsLine *)this; } | 13 | { return (AsLine *)this; } |
14 | 14 | ||
15 | virtual QString deviceFile( void ); | ||
16 | |||
15 | protected : | 17 | protected : |
16 | 18 | ||
@@ -21,4 +23,4 @@ protected : | |||
21 | private : | 23 | private : |
22 | 24 | ||
23 | CableData_t * D; | 25 | CableData_t * Data; |
24 | }; | 26 | }; |
diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp index 49bc06e..9483e22 100644 --- a/noncore/settings/networksettings2/irda/irda_NN.cpp +++ b/noncore/settings/networksettings2/irda/irda_NN.cpp | |||
@@ -37,15 +37,4 @@ const char * IRDANetNode::provides( void ) { | |||
37 | } | 37 | } |
38 | 38 | ||
39 | bool IRDANetNode::generateProperFilesFor( | ||
40 | ANetNodeInstance * ) { | ||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | bool IRDANetNode::generateDeviceDataForCommonFile( | ||
45 | SystemFile & , | ||
46 | long ) { | ||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | void IRDANetNode::setSpecificAttribute( QString & , QString & ) { | 39 | void IRDANetNode::setSpecificAttribute( QString & , QString & ) { |
51 | } | 40 | } |
diff --git a/noncore/settings/networksettings2/irda/irda_NN.h b/noncore/settings/networksettings2/irda/irda_NN.h index fa6408d..900bbc6 100644 --- a/noncore/settings/networksettings2/irda/irda_NN.h +++ b/noncore/settings/networksettings2/irda/irda_NN.h | |||
@@ -8,26 +8,18 @@ class AIRDA; | |||
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 nodeDescription() ; | 20 | virtual const QString nodeDescription() ; |
21 | 21 | virtual ANetNodeInstance * createInstance( void ); | |
22 | virtual ANetNodeInstance * createInstance( void ); | 22 | virtual const char ** needs( void ); |
23 | 23 | virtual const char * provides( void ); | |
24 | virtual const char ** needs( void ); | ||
25 | virtual const char * provides( void ); | ||
26 | |||
27 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | ||
28 | virtual bool hasDataFor( const QString & ) | ||
29 | { return 0; } | ||
30 | virtual bool generateDeviceDataForCommonFile( | ||
31 | SystemFile & SF, long DevNr ); | ||
32 | 24 | ||
33 | private: | 25 | private: |
diff --git a/noncore/settings/networksettings2/irda/irda_NNI.cpp b/noncore/settings/networksettings2/irda/irda_NNI.cpp index f00a1d5..9cf443b 100644 --- a/noncore/settings/networksettings2/irda/irda_NNI.cpp +++ b/noncore/settings/networksettings2/irda/irda_NNI.cpp | |||
@@ -30,8 +30,2 @@ void AIRDA::commit( void ) { | |||
30 | } | 30 | } |
31 | 31 | ||
32 | bool AIRDA::generateDataForCommonFile( | ||
33 | SystemFile & , | ||
34 | long ) { | ||
35 | return 1; | ||
36 | } | ||
37 | |||
diff --git a/noncore/settings/networksettings2/irda/irda_NNI.h b/noncore/settings/networksettings2/irda/irda_NNI.h index 210d87d..e21b68f 100644 --- a/noncore/settings/networksettings2/irda/irda_NNI.h +++ b/noncore/settings/networksettings2/irda/irda_NNI.h | |||
@@ -15,22 +15,16 @@ public : | |||
15 | AIRDA( IRDANetNode * PNN ); | 15 | AIRDA( IRDANetNode * PNN ); |
16 | 16 | ||
17 | RuntimeInfo * runtime( void ) | ||
18 | { return | ||
19 | ( RT ) ? RT : ( RT = new IRDARun( this, Data ) ); | ||
20 | } | ||
21 | |||
17 | QWidget * edit( QWidget * parent ); | 22 | QWidget * edit( QWidget * parent ); |
18 | QString acceptable( void ); | 23 | QString acceptable( void ); |
19 | void commit( void ); | 24 | void commit( void ); |
20 | 25 | ||
21 | RuntimeInfo * runtime( void ) | ||
22 | { if( RT == 0 ) | ||
23 | RT = new IRDARun( this, Data ); | ||
24 | return RT; | ||
25 | } | ||
26 | |||
27 | virtual void * data( void ) | 26 | virtual void * data( void ) |
28 | { return (void *)&Data; } | 27 | { return (void *)&Data; } |
29 | 28 | ||
30 | virtual bool hasDataFor( const QString & ) | ||
31 | { return 0; } | ||
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & SF, long DevNr ); | ||
34 | |||
35 | protected : | 29 | protected : |
36 | 30 | ||
diff --git a/noncore/settings/networksettings2/irda/irdarun.h b/noncore/settings/networksettings2/irda/irdarun.h index 4c903cc..4258aff 100644 --- a/noncore/settings/networksettings2/irda/irdarun.h +++ b/noncore/settings/networksettings2/irda/irdarun.h | |||
@@ -13,4 +13,7 @@ public : | |||
13 | { return (AsLine *)this; } | 13 | { return (AsLine *)this; } |
14 | 14 | ||
15 | virtual QString deviceFile( void ) | ||
16 | { return QString( "/dev/irda" ); } | ||
17 | |||
15 | protected : | 18 | protected : |
16 | 19 | ||
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp index 05cd06d..20ae7f6 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp +++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp | |||
@@ -39,27 +39,4 @@ const char * LanCardNetNode::provides( void ) { | |||
39 | } | 39 | } |
40 | 40 | ||
41 | bool LanCardNetNode::generateProperFilesFor( | ||
42 | ANetNodeInstance * ) { | ||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | bool LanCardNetNode::hasDataFor( const QString & S ) { | ||
47 | return S == "interfaces"; | ||
48 | } | ||
49 | |||
50 | bool LanCardNetNode::generateDeviceDataForCommonFile( | ||
51 | SystemFile & S , | ||
52 | long DevNr ) { | ||
53 | QString NIC = genNic( DevNr ); | ||
54 | |||
55 | if( S.name() == "interfaces" ) { | ||
56 | // generate mapping stanza for this interface | ||
57 | S << "# check if " << NIC << " can be brought UP" << endl; | ||
58 | S << "mapping " << NIC << endl; | ||
59 | S << " script networksettings2-request" << endl << endl; | ||
60 | } | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | QString LanCardNetNode::genNic( long nr ) { | 41 | QString LanCardNetNode::genNic( long nr ) { |
65 | QString S; | 42 | QString S; |
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h index d58823c..6882af7 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.h +++ b/noncore/settings/networksettings2/lancard/lancard_NN.h | |||
@@ -19,21 +19,14 @@ public: | |||
19 | { return "Devices/card"; } | 19 | { return "Devices/card"; } |
20 | 20 | ||
21 | virtual const QString nodeDescription() ; | 21 | virtual QString genNic( long ); |
22 | virtual long instanceCount( void ) | ||
23 | { return InstanceCount; } | ||
22 | 24 | ||
25 | virtual const QString nodeDescription() ; | ||
23 | virtual ANetNodeInstance * createInstance( void ); | 26 | virtual ANetNodeInstance * createInstance( void ); |
24 | |||
25 | virtual const char ** needs( void ); | 27 | virtual const char ** needs( void ); |
26 | virtual const char * provides( void ); | 28 | virtual const char * provides( void ); |
27 | 29 | ||
28 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | 30 | QStringList & addressesOfNIC( void ) |
29 | virtual bool hasDataFor( const QString & S ); | ||
30 | virtual bool generateDeviceDataForCommonFile( | ||
31 | SystemFile & SF, long DevNr ); | ||
32 | |||
33 | virtual long instanceCount( void ) | ||
34 | { return InstanceCount; } | ||
35 | |||
36 | virtual QString genNic( long ); | ||
37 | virtual QStringList & addressesOfNIC( void ) | ||
38 | { return NICMACAddresses; } | 31 | { return NICMACAddresses; } |
39 | 32 | ||
diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp index 99c033e..9fb05b9 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp +++ b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp | |||
@@ -44,8 +44,2 @@ void ALanCard::commit( void ) { | |||
44 | } | 44 | } |
45 | 45 | ||
46 | bool ALanCard::generateDataForCommonFile( | ||
47 | SystemFile & , | ||
48 | long ) { | ||
49 | return 1; | ||
50 | } | ||
51 | |||
diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.h b/noncore/settings/networksettings2/lancard/lancard_NNI.h index 4e91523..8e55a19 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NNI.h +++ b/noncore/settings/networksettings2/lancard/lancard_NNI.h | |||
@@ -15,21 +15,16 @@ public : | |||
15 | ALanCard( LanCardNetNode * PNN ); | 15 | ALanCard( LanCardNetNode * PNN ); |
16 | 16 | ||
17 | RuntimeInfo * runtime( void ) | ||
18 | { return | ||
19 | ( RT ) ? RT : ( RT = new LanCardRun( this, Data ) ); | ||
20 | } | ||
21 | |||
17 | QWidget * edit( QWidget * parent ); | 22 | QWidget * edit( QWidget * parent ); |
18 | QString acceptable( void ); | 23 | QString acceptable( void ); |
19 | void commit( void ); | 24 | void commit( void ); |
20 | 25 | ||
21 | RuntimeInfo * runtime( void ) | ||
22 | { if( RT == 0 ) | ||
23 | RT = new LanCardRun( this, Data ); | ||
24 | return RT; | ||
25 | } | ||
26 | |||
27 | virtual void * data( void ) | 26 | virtual void * data( void ) |
28 | { return (void *)&Data; } | 27 | { return (void *)&Data; } |
29 | 28 | ||
30 | virtual bool hasDataFor( const QString & ) | ||
31 | { return 0; } | ||
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & S, long DevNr ); | ||
34 | protected : | 29 | protected : |
35 | 30 | ||
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp index 6c969fc..b32b323 100644 --- a/noncore/settings/networksettings2/main.cpp +++ b/noncore/settings/networksettings2/main.cpp | |||
@@ -1,4 +1,5 @@ | |||
1 | #include "nsdata.h" | 1 | #include "nsdata.h" |
2 | #include "activateprofile.h" | 2 | #include "activateprofile.h" |
3 | #include "activatevpn.h" | ||
3 | #include "networksettings.h" | 4 | #include "networksettings.h" |
4 | 5 | ||
@@ -22,4 +23,6 @@ OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) | |||
22 | // used by interfaces to request user prompt | 23 | // used by interfaces to request user prompt |
23 | #define ACT_PROMPT 3 | 24 | #define ACT_PROMPT 3 |
25 | // used by interfaces to trigger VPN | ||
26 | #define ACT_VPN 4 | ||
24 | 27 | ||
25 | int main( int argc, char * argv[] ) { | 28 | int main( int argc, char * argv[] ) { |
@@ -45,4 +48,7 @@ int main( int argc, char * argv[] ) { | |||
45 | Action = ACT_PROMPT; | 48 | Action = ACT_PROMPT; |
46 | rmv = 1; | 49 | rmv = 1; |
50 | } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) { | ||
51 | Action = ACT_VPN; | ||
52 | rmv = 1; | ||
47 | } | 53 | } |
48 | if( rmv ) { | 54 | if( rmv ) { |
@@ -79,8 +85,6 @@ int main( int argc, char * argv[] ) { | |||
79 | case ACT_REQUEST : | 85 | case ACT_REQUEST : |
80 | { NetworkSettingsData NS; | 86 | { NetworkSettingsData NS; |
81 | Log(("ACT_REQUEST\n")); | ||
82 | if( NS.canStart( argv[1] ) ) { | 87 | if( NS.canStart( argv[1] ) ) { |
83 | QString S; | 88 | QString S; |
84 | Log(("NEED FOR PROMPT\n" )); | ||
85 | S.sprintf( QPEApplication::qpeDir()+ | 89 | S.sprintf( QPEApplication::qpeDir()+ |
86 | "/bin/networksettings2" ); | 90 | "/bin/networksettings2" ); |
@@ -98,5 +102,4 @@ int main( int argc, char * argv[] ) { | |||
98 | case ACT_REGEN : | 102 | case ACT_REGEN : |
99 | { NetworkSettingsData NS; | 103 | { NetworkSettingsData NS; |
100 | Log(("REGEN\n" )); | ||
101 | // regen returns 0 if OK | 104 | // regen returns 0 if OK |
102 | rv = (NS.regenerate()) ? 1 : 0; | 105 | rv = (NS.regenerate()) ? 1 : 0; |
@@ -105,5 +108,4 @@ int main( int argc, char * argv[] ) { | |||
105 | case ACT_PROMPT : | 108 | case ACT_PROMPT : |
106 | { ActivateProfile AP(argv[1]); | 109 | { ActivateProfile AP(argv[1]); |
107 | Log(("PROMPT\n" )); | ||
108 | if( AP.exec() == QDialog::Accepted ) { | 110 | if( AP.exec() == QDialog::Accepted ) { |
109 | printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); | 111 | printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); |
@@ -113,7 +115,11 @@ int main( int argc, char * argv[] ) { | |||
113 | } | 115 | } |
114 | break; | 116 | break; |
117 | case ACT_VPN : | ||
118 | { ActivateVPN AVPN; | ||
119 | AVPN.exec(); | ||
120 | } | ||
121 | break; | ||
115 | case ACT_GUI : | 122 | case ACT_GUI : |
116 | { QWidget * W = new NetworkSettings(0); | 123 | { QWidget * W = new NetworkSettings(0); |
117 | Log(("GUI\n" )); | ||
118 | TheApp->setMainWidget( W ); | 124 | TheApp->setMainWidget( W ); |
119 | W->show(); | 125 | W->show(); |
diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp index 18aa480..ee61b10 100644 --- a/noncore/settings/networksettings2/modem/modem_NN.cpp +++ b/noncore/settings/networksettings2/modem/modem_NN.cpp | |||
@@ -38,15 +38,4 @@ const char * ModemNetNode::provides( void ) { | |||
38 | } | 38 | } |
39 | 39 | ||
40 | bool ModemNetNode::generateProperFilesFor( | ||
41 | ANetNodeInstance * ) { | ||
42 | return 0; | ||
43 | } | ||
44 | |||
45 | bool ModemNetNode::generateDeviceDataForCommonFile( | ||
46 | SystemFile & , | ||
47 | long ) { | ||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | void ModemNetNode::setSpecificAttribute( QString & , QString & ) { | 40 | void ModemNetNode::setSpecificAttribute( QString & , QString & ) { |
52 | } | 41 | } |
diff --git a/noncore/settings/networksettings2/modem/modem_NN.h b/noncore/settings/networksettings2/modem/modem_NN.h index 2f496dd..a76525f 100644 --- a/noncore/settings/networksettings2/modem/modem_NN.h +++ b/noncore/settings/networksettings2/modem/modem_NN.h | |||
@@ -19,16 +19,8 @@ public: | |||
19 | 19 | ||
20 | virtual const QString nodeDescription() ; | 20 | virtual const QString nodeDescription() ; |
21 | |||
22 | virtual ANetNodeInstance * createInstance( void ); | 21 | virtual ANetNodeInstance * createInstance( void ); |
23 | |||
24 | virtual const char ** needs( void ); | 22 | virtual const char ** needs( void ); |
25 | virtual const char * provides( void ); | 23 | virtual const char * provides( void ); |
26 | 24 | ||
27 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | ||
28 | virtual bool hasDataFor( const QString & ) | ||
29 | { return 0; } | ||
30 | virtual bool generateDeviceDataForCommonFile( | ||
31 | SystemFile & SF, long DevNr ); | ||
32 | |||
33 | private: | 25 | private: |
34 | 26 | ||
diff --git a/noncore/settings/networksettings2/modem/modem_NNI.cpp b/noncore/settings/networksettings2/modem/modem_NNI.cpp index 6c76b56..91df22b 100644 --- a/noncore/settings/networksettings2/modem/modem_NNI.cpp +++ b/noncore/settings/networksettings2/modem/modem_NNI.cpp | |||
@@ -30,8 +30,2 @@ void AModem::commit( void ) { | |||
30 | } | 30 | } |
31 | 31 | ||
32 | bool AModem::generateDataForCommonFile( | ||
33 | SystemFile & , | ||
34 | long ) { | ||
35 | return 1; | ||
36 | } | ||
37 | |||
diff --git a/noncore/settings/networksettings2/modem/modem_NNI.h b/noncore/settings/networksettings2/modem/modem_NNI.h index a623704..ca7c279 100644 --- a/noncore/settings/networksettings2/modem/modem_NNI.h +++ b/noncore/settings/networksettings2/modem/modem_NNI.h | |||
@@ -15,22 +15,16 @@ public : | |||
15 | AModem( ModemNetNode * PNN ); | 15 | AModem( ModemNetNode * PNN ); |
16 | 16 | ||
17 | RuntimeInfo * runtime( void ) | ||
18 | { return | ||
19 | ( RT ) ? RT : ( RT = new ModemRun( this, Data ) ); | ||
20 | } | ||
21 | |||
17 | QWidget * edit( QWidget * parent ); | 22 | QWidget * edit( QWidget * parent ); |
18 | QString acceptable( void ); | 23 | QString acceptable( void ); |
19 | void commit( void ); | 24 | void commit( void ); |
20 | 25 | ||
21 | RuntimeInfo * runtime( void ) | ||
22 | { if( RT == 0 ) | ||
23 | RT = new ModemRun( this, Data ); | ||
24 | return RT; | ||
25 | } | ||
26 | |||
27 | virtual void * data( void ) | 26 | virtual void * data( void ) |
28 | { return (void *)&Data; } | 27 | { return (void *)&Data; } |
29 | 28 | ||
30 | virtual bool hasDataFor( const QString & ) | ||
31 | { return 0; } | ||
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & SF, long DevNr ); | ||
34 | |||
35 | protected : | 29 | protected : |
36 | 30 | ||
diff --git a/noncore/settings/networksettings2/modem/modemrun.h b/noncore/settings/networksettings2/modem/modemrun.h index 336462e..491a677 100644 --- a/noncore/settings/networksettings2/modem/modemrun.h +++ b/noncore/settings/networksettings2/modem/modemrun.h | |||
@@ -13,4 +13,7 @@ public : | |||
13 | { return (AsLine *)this; } | 13 | { return (AsLine *)this; } |
14 | 14 | ||
15 | virtual QString deviceFile( void ) | ||
16 | { return QString("/dev/modem"); } | ||
17 | |||
15 | protected : | 18 | protected : |
16 | 19 | ||
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index b4313c4..1feffdb 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp | |||
@@ -1,2 +1,3 @@ | |||
1 | #include <asdevice.h> | ||
1 | #include "network_NN.h" | 2 | #include "network_NN.h" |
2 | #include "network_NNI.h" | 3 | #include "network_NNI.h" |
@@ -31,21 +32,40 @@ ANetNodeInstance * NetworkNetNode::createInstance( void ) { | |||
31 | } | 32 | } |
32 | 33 | ||
33 | const char ** NetworkNetNode::needs( void ) { | 34 | bool NetworkNetNode::hasDataForFile( const QString & S ) { |
34 | return NetworkNeeds; | 35 | return S == "interfaces"; |
35 | } | 36 | } |
36 | 37 | ||
37 | const char * NetworkNetNode::provides( void ) { | 38 | short NetworkNetNode::generateFile( const QString & ID, |
38 | return "connection"; | 39 | const QString & , |
40 | QTextStream & TS, | ||
41 | ANetNodeInstance * NNI, | ||
42 | long DevNr ) { | ||
43 | |||
44 | QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); | ||
45 | |||
46 | if( ID == "interfaces" ) { | ||
47 | Log(("Generate entry for %s in %s\n", NIC.latin1(), ID.latin1() )); | ||
48 | // generate mapping stanza for this interface | ||
49 | TS << "# check if " | ||
50 | << NIC | ||
51 | << " can be brought UP" | ||
52 | << endl; | ||
53 | TS << "mapping " | ||
54 | << NIC | ||
55 | << endl; | ||
56 | TS << " script networksettings2-request" | ||
57 | << endl | ||
58 | << endl; | ||
59 | return 0; | ||
60 | } | ||
61 | return 1; | ||
39 | } | 62 | } |
40 | 63 | ||
41 | bool NetworkNetNode::generateProperFilesFor( | 64 | const char ** NetworkNetNode::needs( void ) { |
42 | ANetNodeInstance * ) { | 65 | return NetworkNeeds; |
43 | return 0; | ||
44 | } | 66 | } |
45 | 67 | ||
46 | bool NetworkNetNode::generateDeviceDataForCommonFile( | 68 | const char * NetworkNetNode::provides( void ) { |
47 | SystemFile & , | 69 | return "connection"; |
48 | long ) { | ||
49 | return 0; | ||
50 | } | 70 | } |
51 | 71 | ||
diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h index 6548c32..745d1a7 100644 --- a/noncore/settings/networksettings2/network/network_NN.h +++ b/noncore/settings/networksettings2/network/network_NN.h | |||
@@ -8,26 +8,25 @@ class ANetwork; | |||
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 bool hasDataForFile( const QString & S ); |
18 | { return "Devices/tcpip"; } | ||
19 | 18 | ||
20 | virtual const QString nodeDescription() ; | 19 | virtual short generateFile( const QString & ID, |
20 | const QString & Path, | ||
21 | QTextStream & TS, | ||
22 | ANetNodeInstance * NNI, | ||
23 | long DevNr ); | ||
24 | virtual const QString pixmapName() | ||
25 | { return "Devices/tcpip"; } | ||
21 | 26 | ||
22 | virtual ANetNodeInstance * createInstance( void ); | 27 | virtual const QString nodeDescription() ; |
23 | 28 | virtual ANetNodeInstance * createInstance( void ); | |
24 | virtual const char ** needs( void ); | 29 | virtual const char ** needs( void ); |
25 | virtual const char * provides( void ); | 30 | virtual const char * provides( void ); |
26 | |||
27 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | ||
28 | virtual bool hasDataFor( const QString & ) | ||
29 | { return 0; } | ||
30 | virtual bool generateDeviceDataForCommonFile( | ||
31 | SystemFile & SF, long DevNr ); | ||
32 | 31 | ||
33 | private: | 32 | private: |
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp index 3e368a2..324c6e2 100644 --- a/noncore/settings/networksettings2/network/network_NNI.cpp +++ b/noncore/settings/networksettings2/network/network_NNI.cpp | |||
@@ -100,55 +100,69 @@ void ANetwork::commit( void ) { | |||
100 | } | 100 | } |
101 | 101 | ||
102 | bool ANetwork::hasDataFor( const QString & S ) { | 102 | bool ANetwork::hasDataForFile( const QString & S ) { |
103 | return S == "interfaces"; | 103 | return S == "interfaces"; |
104 | } | 104 | } |
105 | 105 | ||
106 | bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | 106 | short ANetwork::generateFile( const QString & ID, |
107 | const QString & Path, | ||
108 | QTextStream &TS, | ||
109 | long DevNr | ||
110 | ) { | ||
111 | |||
112 | short rvl, rvd ; | ||
107 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); | 113 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); |
108 | 114 | ||
109 | if( S.name() == "interfaces" ) { | 115 | rvl = 1; |
116 | if( ID == "interfaces" ) { | ||
117 | Log(("Generate Network for %s\n", ID.latin1() )); | ||
110 | // we can safely call from here since device item is deeper | 118 | // we can safely call from here since device item is deeper |
111 | if( Data.UseDHCP ) { | 119 | if( Data.UseDHCP ) { |
112 | S << "iface " | 120 | TS << "iface " |
113 | << NIC | 121 | << NIC |
114 | << "-c" | 122 | << "-c" |
115 | << connection()->number() | 123 | << connection()->number() |
116 | << "-allowed inet dhcp" | 124 | << "-allowed inet dhcp" |
117 | << endl; | 125 | << endl; |
118 | S << " up echo \"" | 126 | TS << " up echo \"" |
119 | << NIC | 127 | << NIC |
120 | << "\" > /tmp/profile-" | 128 | << "\" > /tmp/profile-" |
121 | << connection()->number() | 129 | << connection()->number() |
122 | << ".up" | 130 | << ".up" |
123 | << endl; | 131 | << endl; |
124 | if( Data.SendHostname ) { | 132 | if( Data.SendHostname ) { |
125 | S << " hostname " | 133 | TS << " hostname " |
126 | << Data.Hostname | 134 | << Data.Hostname |
127 | << endl; | 135 | << endl; |
128 | } | 136 | } |
129 | 137 | ||
130 | S << " down rm -f /tmp/profile-" | 138 | TS << " down rm -f /tmp/profile-" |
131 | << connection()->number() | 139 | << connection()->number() |
132 | << ".up" | 140 | << ".up" |
133 | << endl; | 141 | << endl; |
134 | } else { | 142 | } else { |
135 | S << "iface " | 143 | TS << "iface " |
136 | << NIC << "-c" | 144 | << NIC << "-c" |
137 | << connection()->number() | 145 | << connection()->number() |
138 | << "-allowed inet static" | 146 | << "-allowed inet static" |
139 | << endl; | 147 | << endl; |
140 | S << " up echo \"" | 148 | TS << " up echo \"" |
141 | << NIC | 149 | << NIC |
142 | << "\" > /tmp/profile-" | 150 | << "\" > /tmp/profile-" |
143 | << connection()->number() | 151 | << connection()->number() |
144 | << ".up" | 152 | << ".up" |
145 | << endl; | 153 | << endl; |
146 | S << " down rm -f /tmp/profile-" | 154 | TS << " down rm -f /tmp/profile-" |
147 | << connection()->number() | 155 | << connection()->number() |
148 | << ".up" | 156 | << ".up" |
149 | << endl; | 157 | << endl; |
150 | S << " address " << Data.IPAddress << endl; | 158 | TS << " address " |
151 | S << " broadcast " << Data.Broadcast << endl; | 159 | << Data.IPAddress |
152 | S << " netmask " << Data.NetMask << endl; | 160 | << endl; |
161 | TS << " broadcast " | ||
162 | << Data.Broadcast | ||
163 | << endl; | ||
164 | TS << " netmask " | ||
165 | << Data.NetMask | ||
166 | << endl; | ||
153 | 167 | ||
154 | // derive network address = IPAddress & netmask | 168 | // derive network address = IPAddress & netmask |
@@ -162,5 +176,7 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
162 | arg( ipal[2].toShort() & nmal[2].toShort() ). | 176 | arg( ipal[2].toShort() & nmal[2].toShort() ). |
163 | arg( ipal[3].toShort() & nmal[3].toShort() ); | 177 | arg( ipal[3].toShort() & nmal[3].toShort() ); |
164 | S << " network " << NW << endl; | 178 | TS << " network " |
179 | << NW | ||
180 | << endl; | ||
165 | } | 181 | } |
166 | } | 182 | } |
@@ -168,22 +184,36 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
168 | it != Data.PreUp_SL.end(); | 184 | it != Data.PreUp_SL.end(); |
169 | ++it ) { | 185 | ++it ) { |
170 | S << " pre-up " << (*it) << endl; | 186 | TS << " pre-up " |
187 | << (*it) | ||
188 | << endl; | ||
171 | } | 189 | } |
172 | for ( QStringList::Iterator it = Data.PostUp_SL.begin(); | 190 | for ( QStringList::Iterator it = Data.PostUp_SL.begin(); |
173 | it != Data.PostUp_SL.end(); | 191 | it != Data.PostUp_SL.end(); |
174 | ++it ) { | 192 | ++it ) { |
175 | S << " up " << (*it) << endl; | 193 | TS << " up " |
194 | << (*it) | ||
195 | << endl; | ||
176 | } | 196 | } |
177 | for ( QStringList::Iterator it = Data.PreDown_SL.begin(); | 197 | for ( QStringList::Iterator it = Data.PreDown_SL.begin(); |
178 | it != Data.PreDown_SL.end(); | 198 | it != Data.PreDown_SL.end(); |
179 | ++it ) { | 199 | ++it ) { |
180 | S << " down " << (*it) << endl; | 200 | TS << " down " |
201 | << (*it) | ||
202 | << endl; | ||
181 | } | 203 | } |
182 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); | 204 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); |
183 | it != Data.PostDown_SL.end(); | 205 | it != Data.PostDown_SL.end(); |
184 | ++it ) { | 206 | ++it ) { |
185 | S << " post-down " << (*it) << endl; | 207 | TS << " post-down " |
208 | << (*it) | ||
209 | << endl; | ||
186 | } | 210 | } |
211 | rvl = 0; | ||
187 | } | 212 | } |
188 | return 0; | 213 | |
214 | // embed other info in it | ||
215 | rvd = connection()->getToplevel()->generateFileEmbedded( ID, Path, TS, DevNr ); | ||
216 | |||
217 | return (rvd == 2 || rvl == 2 ) ? 2 : | ||
218 | (rvd == 0 || rvl == 0 ) ? 0 : 1; | ||
189 | } | 219 | } |
diff --git a/noncore/settings/networksettings2/network/network_NNI.h b/noncore/settings/networksettings2/network/network_NNI.h index 0058793..5e42503 100644 --- a/noncore/settings/networksettings2/network/network_NNI.h +++ b/noncore/settings/networksettings2/network/network_NNI.h | |||
@@ -16,20 +16,21 @@ public : | |||
16 | ANetwork( NetworkNetNode * PNN ); | 16 | ANetwork( NetworkNetNode * PNN ); |
17 | 17 | ||
18 | RuntimeInfo * runtime( void ) | ||
19 | { return | ||
20 | ( RT ) ? RT : ( RT = new NetworkRun( this, Data ) ); | ||
21 | } | ||
22 | |||
18 | QWidget * edit( QWidget * parent ); | 23 | QWidget * edit( QWidget * parent ); |
19 | QString acceptable( void ); | 24 | QString acceptable( void ); |
20 | void commit( void ); | 25 | void commit( void ); |
21 | 26 | ||
22 | RuntimeInfo * runtime( void ) | ||
23 | { if( RT == 0 ) | ||
24 | RT = new NetworkRun( this, Data ); | ||
25 | return RT; | ||
26 | } | ||
27 | |||
28 | virtual void * data( void ) | 27 | virtual void * data( void ) |
29 | { return (void *)&Data; } | 28 | { return (void *)&Data; } |
30 | 29 | ||
31 | virtual bool hasDataFor( const QString & S ); | 30 | virtual bool hasDataForFile( const QString & S ); |
32 | virtual bool generateDataForCommonFile( | 31 | virtual short generateFile( const QString & ID, |
33 | SystemFile & SF, long DevNr ); | 32 | const QString & Path, |
33 | QTextStream &TS, | ||
34 | long DevNr ); | ||
34 | 35 | ||
35 | protected : | 36 | protected : |
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp index 6ee4106..ce0eabc 100644 --- a/noncore/settings/networksettings2/networksettings.cpp +++ b/noncore/settings/networksettings2/networksettings.cpp | |||
@@ -1,4 +1,5 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <unistd.h> | 2 | #include <unistd.h> |
3 | #include <errno.h> | ||
3 | 4 | ||
4 | #include <qpe/qpeapplication.h> | 5 | #include <qpe/qpeapplication.h> |
@@ -13,4 +14,5 @@ | |||
13 | #include <qpe/qpeapplication.h> | 14 | #include <qpe/qpeapplication.h> |
14 | #include <qtoolbutton.h> | 15 | #include <qtoolbutton.h> |
16 | #include <qevent.h> | ||
15 | 17 | ||
16 | #include <asdevice.h> | 18 | #include <asdevice.h> |
@@ -42,4 +44,11 @@ NetworkSettings::NetworkSettings( QWidget *parent, | |||
42 | // populate main Listbox | 44 | // populate main Listbox |
43 | Profiles_LB->clear(); | 45 | Profiles_LB->clear(); |
46 | QPEApplication::setStylusOperation( | ||
47 | Profiles_LB->viewport(), QPEApplication::RightOnHold ); | ||
48 | |||
49 | connect( Profiles_LB, | ||
50 | SIGNAL(rightButtonPressed(QListBoxItem*,const QPoint&)), | ||
51 | this, SLOT(SLOT_EditNode(QListBoxItem*)) ); | ||
52 | |||
44 | { Name2Connection_t & M = NSResources->connections(); | 53 | { Name2Connection_t & M = NSResources->connections(); |
45 | NodeCollection * NC; | 54 | NodeCollection * NC; |
@@ -79,20 +88,16 @@ NetworkSettings::~NetworkSettings() { | |||
79 | QString S; | 88 | QString S; |
80 | 89 | ||
81 | S = NSD.generateSettings(); | 90 | if( isModified() ) { |
82 | if( ! S.isEmpty() ) { | 91 | S = NSD.saveSettings(); |
83 | QMessageBox::warning( | 92 | if( ! S.isEmpty() ) { |
84 | 0, | 93 | // problem saving |
85 | tr( "In System Config" ), | 94 | QMessageBox::warning( |
86 | S | 95 | 0, |
87 | ); | 96 | tr( "Saving setup" ), S ); |
88 | } | 97 | } |
89 | 98 | ||
90 | S = NSD.saveSettings(); | 99 | SLOT_GenerateConfig(); |
91 | if( ! S.isEmpty() ) { | ||
92 | // problem saving | ||
93 | QMessageBox::warning( | ||
94 | 0, | ||
95 | tr( "Saving setup" ), S ); | ||
96 | } | 100 | } |
101 | |||
97 | } | 102 | } |
98 | 103 | ||
@@ -146,7 +151,4 @@ void NetworkSettings::SLOT_RefreshStates( void ) { | |||
146 | } | 151 | } |
147 | 152 | ||
148 | void NetworkSettings::SLOT_NoLongerBusy( void ) { | ||
149 | NSResources->busy( FALSE ); | ||
150 | } | ||
151 | void NetworkSettings::SLOT_AddNode( void ) { | 153 | void NetworkSettings::SLOT_AddNode( void ) { |
152 | SLOT_EditNode( 0 ); | 154 | SLOT_EditNode( 0 ); |
@@ -167,5 +169,4 @@ void NetworkSettings::SLOT_DeleteNode( void ) { | |||
167 | delete LBI; | 169 | delete LBI; |
168 | setModified( 1 ); | 170 | setModified( 1 ); |
169 | NSD.forceGeneration(1); | ||
170 | } | 171 | } |
171 | } | 172 | } |
@@ -173,4 +174,6 @@ void NetworkSettings::SLOT_DeleteNode( void ) { | |||
173 | void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { | 174 | void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { |
174 | QString OldName = ""; | 175 | QString OldName = ""; |
176 | |||
177 | printf( "------------------ Edit NOde\n" ); | ||
175 | EditConnection EC( this ); | 178 | EditConnection EC( this ); |
176 | 179 | ||
@@ -187,6 +190,5 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { | |||
187 | // disable refresh timer | 190 | // disable refresh timer |
188 | UpdateTimer->stop(); | 191 | UpdateTimer->stop(); |
189 | NSResources->busy( TRUE ); | 192 | |
190 | QTimer::singleShot( 1000, this, SLOT( SLOT_NoLongerBusy() )); | ||
191 | // we need to retry | 193 | // we need to retry |
192 | while( 1 ) { | 194 | while( 1 ) { |
@@ -320,13 +322,5 @@ void NetworkSettings::updateProfileState( QListBoxItem * LBI ) { | |||
320 | 322 | ||
321 | void NetworkSettings::SLOT_GenerateConfig( void ) { | 323 | void NetworkSettings::SLOT_GenerateConfig( void ) { |
322 | QString S = NSD.generateSettings( TRUE ); | 324 | NSD.regenerate(); |
323 | |||
324 | if( ! S.isEmpty() ) { | ||
325 | QMessageBox::warning( | ||
326 | 0, | ||
327 | tr( "Generating system configuration" ), | ||
328 | S | ||
329 | ); | ||
330 | } | ||
331 | } | 325 | } |
332 | 326 | ||
diff --git a/noncore/settings/networksettings2/networksettings.h b/noncore/settings/networksettings2/networksettings.h index 8ffde06..8ec5d08 100644 --- a/noncore/settings/networksettings2/networksettings.h +++ b/noncore/settings/networksettings2/networksettings.h | |||
@@ -7,4 +7,5 @@ class ANetNodeInstance; | |||
7 | class QTimer; | 7 | class QTimer; |
8 | class QListBoxItem; | 8 | class QListBoxItem; |
9 | class QEvent; | ||
9 | 10 | ||
10 | class NetworkSettings : public NetworkSettingsGUI { | 11 | class NetworkSettings : public NetworkSettingsGUI { |
@@ -29,5 +30,4 @@ public : | |||
29 | public slots : | 30 | public slots : |
30 | 31 | ||
31 | void SLOT_NoLongerBusy( void ); | ||
32 | void SLOT_AddNode( void ); | 32 | void SLOT_AddNode( void ); |
33 | void SLOT_DeleteNode( void ); | 33 | void SLOT_DeleteNode( void ); |
@@ -51,4 +51,3 @@ private : | |||
51 | QTimer * UpdateTimer; | 51 | QTimer * UpdateTimer; |
52 | NetworkSettingsData NSD; | 52 | NetworkSettingsData NSD; |
53 | |||
54 | }; | 53 | }; |
diff --git a/noncore/settings/networksettings2/networksettings.pro b/noncore/settings/networksettings2/networksettings.pro index ff147b1..f04289b 100644 --- a/noncore/settings/networksettings2/networksettings.pro +++ b/noncore/settings/networksettings2/networksettings.pro | |||
@@ -4,4 +4,5 @@ CONFIG = qt warn_on debug | |||
4 | HEADERS = networksettings.h \ | 4 | HEADERS = networksettings.h \ |
5 | activateprofile.h \ | 5 | activateprofile.h \ |
6 | activatevpn.h \ | ||
6 | editconnection.h | 7 | editconnection.h |
7 | SOURCES = main.cpp \ | 8 | SOURCES = main.cpp \ |
@@ -9,4 +10,5 @@ SOURCES = main.cpp \ | |||
9 | nsdata.cpp \ | 10 | nsdata.cpp \ |
10 | activateprofile.cpp \ | 11 | activateprofile.cpp \ |
12 | activatevpn.cpp \ | ||
11 | editconnection.cpp | 13 | editconnection.cpp |
12 | INCLUDEPATH += $(OPIEDIR)/include networksettings2/ | 14 | INCLUDEPATH += $(OPIEDIR)/include networksettings2/ |
@@ -15,4 +17,5 @@ LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings2 -lnetworksettings2 -l | |||
15 | INTERFACES = networksettingsGUI.ui \ | 17 | INTERFACES = networksettingsGUI.ui \ |
16 | editconnectionGUI.ui \ | 18 | editconnectionGUI.ui \ |
19 | activatevpnGUI.ui \ | ||
17 | activateprofileGUI.ui | 20 | activateprofileGUI.ui |
18 | TARGET = $(OPIEDIR)/bin/networksettings2 | 21 | TARGET = $(OPIEDIR)/bin/networksettings2 |
diff --git a/noncore/settings/networksettings2/networksettings2/Utils.h b/noncore/settings/networksettings2/networksettings2/Utils.h index 63ef51c..739476e 100644 --- a/noncore/settings/networksettings2/networksettings2/Utils.h +++ b/noncore/settings/networksettings2/networksettings2/Utils.h | |||
@@ -5,4 +5,5 @@ | |||
5 | extern void VLog( char * Format, ... ); | 5 | extern void VLog( char * Format, ... ); |
6 | extern void LogClose( void ); | 6 | extern void LogClose( void ); |
7 | extern QString removeSpaces( const QString & X ); | ||
7 | 8 | ||
8 | #endif | 9 | #endif |
diff --git a/noncore/settings/networksettings2/networksettings2/asline.h b/noncore/settings/networksettings2/networksettings2/asline.h index 6bd93ec..ee4de38 100644 --- a/noncore/settings/networksettings2/networksettings2/asline.h +++ b/noncore/settings/networksettings2/networksettings2/asline.h | |||
@@ -14,4 +14,6 @@ public : | |||
14 | } | 14 | } |
15 | 15 | ||
16 | virtual QString deviceFile( void ) = 0; | ||
17 | |||
16 | }; | 18 | }; |
17 | 19 | ||
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index 8c80e0b..4a2440a 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp | |||
@@ -145,5 +145,5 @@ NodeCollection::NodeCollection( QTextStream & TS ) : | |||
145 | Name = N; | 145 | Name = N; |
146 | } else if( A == "number" ) { | 146 | } else if( A == "number" ) { |
147 | Log(( "read number %s\n", N.latin1() )); | 147 | Log(( "Profile number %s\n", N.latin1() )); |
148 | setNumber( N.toLong() ); | 148 | setNumber( N.toLong() ); |
149 | } else if( A == "node" ) { | 149 | } else if( A == "node" ) { |
@@ -296,6 +296,25 @@ void NodeCollection::reassign( void ) { | |||
296 | 296 | ||
297 | bool NodeCollection::triggersVPN() { | 297 | bool NodeCollection::triggersVPN() { |
298 | return getToplevel()->runtime()->asFullSetup()->triggersVPN(); | 298 | return getToplevel()->runtime()->asFullSetup()->triggersVPN(); |
299 | } | 299 | } |
300 | |||
301 | bool NodeCollection::hasDataForFile( const QString & S ) { | ||
302 | return ( firstWithDataForFile( S ) != 0 ); | ||
303 | } | ||
304 | |||
305 | ANetNodeInstance * NodeCollection::firstWithDataForFile( const QString & S ) { | ||
306 | for( QListIterator<ANetNodeInstance> it(*this); | ||
307 | it.current(); | ||
308 | ++it ) { | ||
309 | if( it.current()->hasDataForFile( S ) ) { | ||
310 | Log(( "Node %s has data for %s\n", | ||
311 | it.current()->nodeClass()->name(), | ||
312 | S.latin1() )); | ||
313 | return it.current(); | ||
314 | } | ||
315 | } | ||
316 | return 0; | ||
317 | } | ||
318 | |||
300 | // | 319 | // |
301 | // | 320 | // |
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h index ca35c27..d3d7b34 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.h +++ b/noncore/settings/networksettings2/networksettings2/netnode.h | |||
@@ -6,4 +6,5 @@ | |||
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qpixmap.h> | 7 | #include <qpixmap.h> |
8 | #include <qstringlist.h> | ||
8 | #include <qobject.h> | 9 | #include <qobject.h> |
9 | #include <time.h> | 10 | #include <time.h> |
@@ -33,38 +34,38 @@ extern QString quote( QString X ); | |||
33 | 34 | ||
34 | typedef enum State { | 35 | typedef enum State { |
35 | // if we have not yet detected the state of the device | 36 | // if we have not yet detected the state of the device |
36 | Unchecked = 0, | 37 | Unchecked = 0, |
37 | // if we cannot determine the state | 38 | // if we cannot determine the state |
38 | Unknown = 1, | 39 | Unknown = 1, |
39 | // if connection cannot be established e.g. because | 40 | // if connection cannot be established e.g. because |
40 | // the hardware is not available | 41 | // the hardware is not available |
41 | Unavailable = 2, | 42 | Unavailable = 2, |
42 | // if the connection cannot be establishec but NOT | 43 | // if the connection cannot be establishec but NOT |
43 | // because it is physically impossible but because | 44 | // because it is physically impossible but because |
44 | // it has been disabled for FUNCTIONAL reasons | 45 | // it has been disabled for FUNCTIONAL reasons |
45 | Disabled = 3, | 46 | Disabled = 3, |
46 | // if connection is available to is currently down | 47 | // if connection is available to is currently down |
47 | // i.e. the corresponding hardware is not activated | 48 | // i.e. the corresponding hardware is not activated |
48 | Off = 4, | 49 | Off = 4, |
49 | // if connection is available to be used (i.e. the | 50 | // if connection is available to be used (i.e. the |
50 | // devices if fully ready to be used | 51 | // devices if fully ready to be used |
51 | Available = 5, | 52 | Available = 5, |
52 | // if connection is being used | 53 | // if connection is being used |
53 | IsUp = 6 | 54 | IsUp = 6 |
54 | } State_t; | 55 | } State_t; |
55 | 56 | ||
56 | typedef enum Action { | 57 | typedef enum Action { |
57 | // to make the device unavailable functionally | 58 | // to make the device unavailable functionally |
58 | Disable = 0, | 59 | Disable = 0, |
59 | // to make the device available functionally | 60 | // to make the device available functionally |
60 | Enable = 1, | 61 | Enable = 1, |
61 | // bring the hardware up | 62 | // bring the hardware up |
62 | Activate = 2, | 63 | Activate = 2, |
63 | // bring the hardware down | 64 | // bring the hardware down |
64 | Deactivate = 3, | 65 | Deactivate = 3, |
65 | // bring the connection up | 66 | // bring the connection up |
66 | Up = 4, | 67 | Up = 4, |
67 | // bring the connection down | 68 | // bring the connection down |
68 | Down = 5 | 69 | Down = 5 |
69 | } Action_t; | 70 | } Action_t; |
70 | 71 | ||
@@ -73,64 +74,104 @@ class ANetNode : public QObject{ | |||
73 | public: | 74 | public: |
74 | 75 | ||
75 | typedef QArray<ANetNode *> NetNodeList; | 76 | typedef QArray<ANetNode *> NetNodeList; |
76 | 77 | ||
77 | ANetNode( const char * Name ) : QObject( 0, Name ) {} | 78 | ANetNode( const char * Name ) : QObject( 0, Name ) {} |
78 | virtual ~ANetNode(){}; | 79 | virtual ~ANetNode(){}; |
79 | 80 | ||
80 | // pixmap needed for this NetNode | 81 | // |
81 | virtual const QString pixmapName() = 0; | 82 | // |
82 | 83 | // standard methods with sensible default | |
83 | // description for this NetNode | 84 | // |
84 | virtual const QString nodeDescription() = 0; | 85 | // |
85 | 86 | ||
86 | // create a blank instance of a net node | 87 | inline int done( void ) |
87 | virtual ANetNodeInstance * createInstance( void ) = 0; | 88 | { return Done; } |
88 | 89 | inline void setDone( int D ) | |
89 | // return feature this NetNode provides | 90 | { Done = D; } |
90 | virtual const char * provides( void ) = 0; | 91 | |
91 | virtual const char ** needs( void ) = 0; | 92 | // does this Node provide a Connection |
92 | 93 | inline bool isToplevel( void ) | |
93 | // generate files specific for this node (if any) | 94 | { return strcmp( provides(), "fullsetup") == 0 ; } |
94 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0; | 95 | |
95 | // return TRUE if this node has data to be inserted in systemfile | 96 | // set the value of an attribute |
96 | // with name S | 97 | void setAttribute( QString & Attr, QString & Value ) ; |
97 | virtual bool hasDataFor( const QString & S ) = 0; | 98 | void saveAttributes( QTextStream & TS ) ; |
98 | // generate data specific for the device for the system file S | 99 | |
99 | // called only IF data was needed | 100 | // compiled references to 'needed' NetNodes -> needs list |
100 | virtual bool generateDeviceDataForCommonFile( | 101 | inline void setAlternatives( NetNodeList * Alt ) |
101 | SystemFile & SF, long DevNr ) = 0; | 102 | { Alternatives = Alt; } |
102 | 103 | inline NetNodeList & alternatives( void ) | |
103 | // does this Node provide a Connection | 104 | { return *Alternatives; } |
104 | bool isToplevel( void ) | 105 | |
105 | { return strcmp( provides(), "fullsetup") == 0 ; } | 106 | // |
106 | 107 | // | |
107 | // generate NIC name based on instance nr | 108 | // Virtual methods with sensible default |
108 | // only relevant if node instances are devices | 109 | // |
109 | virtual QString genNic( long ) | 110 | // |
110 | { return QString(""); } | 111 | |
111 | 112 | // do instances of this noce class have data for this file | |
112 | // max number of instances for this node type | 113 | virtual bool hasDataForFile( const QString & ) |
113 | // only relevant if node instances are devices | 114 | { return 0; } |
114 | virtual long instanceCount( void ) | 115 | |
115 | { return 1; } | 116 | // generate instance independent stuff |
116 | 117 | // 0 : data output, 1 no data, 2 error | |
117 | // set the value of an attribute | 118 | virtual short generateFile( const QString & , |
118 | void setAttribute( QString & Attr, QString & Value ) ; | 119 | const QString & , |
119 | void saveAttributes( QTextStream & TS ) ; | 120 | QTextStream & , |
120 | 121 | long ) | |
121 | // compiled references to 'needed' NetNodes -> needs list | 122 | { return 1; } |
122 | void setAlternatives( NetNodeList * Alt ) | 123 | |
123 | { Alternatives = Alt; } | 124 | // generate instance dependent but profile common stuff |
124 | NetNodeList & alternatives( void ) | 125 | // 0 : data output, 1 no data, 2 error |
125 | { return *Alternatives; } | 126 | virtual short generateFile( const QString & , |
127 | const QString & , | ||
128 | QTextStream & , | ||
129 | ANetNodeInstance * , | ||
130 | long ) | ||
131 | { return 1; } | ||
132 | |||
133 | |||
134 | // generate NIC name based on instance nr | ||
135 | // only relevant if node instances are devices | ||
136 | virtual QString genNic( long ) | ||
137 | { return QString(""); } | ||
138 | |||
139 | // max number of instances for this node type | ||
140 | // only relevant if node instances are devices | ||
141 | virtual long instanceCount( void ) | ||
142 | { return 1; } | ||
143 | |||
144 | // return list of files that are specific for this node class | ||
145 | virtual QStringList * properFiles( void ) | ||
146 | { return 0; } | ||
147 | |||
148 | // | ||
149 | // | ||
150 | // pure virtual methods with sensible default | ||
151 | // | ||
152 | // | ||
153 | |||
154 | // pixmap needed for this NetNode | ||
155 | virtual const QString pixmapName() = 0; | ||
156 | |||
157 | // description for this NetNode | ||
158 | virtual const QString nodeDescription() = 0; | ||
159 | |||
160 | // create a blank instance of a net node | ||
161 | virtual ANetNodeInstance * createInstance( void ) = 0; | ||
162 | |||
163 | // return feature this NetNode provides | ||
164 | virtual const char * provides( void ) = 0; | ||
165 | virtual const char ** needs( void ) = 0; | ||
126 | 166 | ||
127 | protected : | 167 | protected : |
128 | 168 | ||
129 | NetNodeList * Alternatives; | 169 | NetNodeList * Alternatives; |
130 | 170 | ||
131 | private : | 171 | private : |
132 | 172 | ||
133 | virtual void setSpecificAttribute( QString & , QString & ) = 0; | 173 | virtual void setSpecificAttribute( QString & , QString & ) = 0; |
134 | virtual void saveSpecificAttribute( QTextStream & ) = 0; | 174 | virtual void saveSpecificAttribute( QTextStream & ) = 0; |
175 | int Done; | ||
135 | 176 | ||
136 | }; | 177 | }; |
@@ -140,89 +181,136 @@ class ANetNodeInstance : public QObject { | |||
140 | public: | 181 | public: |
141 | 182 | ||
142 | ANetNodeInstance( ANetNode * NN ) : QObject() | 183 | ANetNodeInstance( ANetNode * NN ) : QObject() |
143 | { IsModified=0; NodeType = NN; IsNew = TRUE; } | 184 | { IsModified=0; NodeType = NN; IsNew = TRUE; } |
144 | virtual ~ANetNodeInstance( void ) { } | 185 | virtual ~ANetNodeInstance( void ) { } |
145 | 186 | ||
146 | virtual RuntimeInfo * runtime( void ) = 0; | 187 | inline int done( void ) |
147 | 188 | { return Done; } | |
148 | void setConnection( NodeCollection * NC ) | 189 | inline void setDone( int D ) |
149 | { Connection = NC; } | 190 | { Done = D; } |
150 | NodeCollection * connection( void ) | 191 | |
151 | { return Connection; } | 192 | // return data was modified |
152 | 193 | inline void setModified( bool M ) | |
153 | // create edit widget under parent | 194 | { IsModified = M; } |
154 | virtual QWidget * edit( QWidget * parent ) = 0; | 195 | inline bool isModified( void ) |
155 | // is given data acceptable | 196 | { return IsModified; } |
156 | virtual QString acceptable( void ) = 0; | 197 | |
157 | 198 | // get next node | |
158 | // return data was modified | 199 | ANetNodeInstance * nextNode(); |
159 | void setModified( bool M ) | 200 | // return NetNode this is an instance of |
160 | { IsModified = M; } | 201 | ANetNode * nodeClass( void ) |
161 | bool isModified( void ) | 202 | { return NodeType; } |
162 | { return IsModified; } | 203 | |
163 | 204 | // intialize am instance of a net node | |
164 | // get data from GUI and store in node | 205 | void initialize( void ); |
165 | virtual void commit( void ) = 0; | 206 | |
166 | 207 | // set the value of an attribute | |
167 | // get next node | 208 | void setAttribute( QString & Attr, QString & Value ) ; |
168 | ANetNodeInstance * nextNode(); | 209 | void saveAttributes( QTextStream & TS ) ; |
169 | // return NetNode this is an instance of | 210 | |
170 | ANetNode * nodeClass( void ) | 211 | // return true if node isntance is NEW and not loaded |
171 | { return NodeType; } | 212 | inline void setNew( bool IsN ) |
172 | 213 | { IsNew = IsN; } | |
173 | // intialize am instance of a net node | 214 | inline bool isNew( void ) |
174 | void initialize( void ); | 215 | { return IsNew; } |
175 | 216 | ||
176 | // set the value of an attribute | 217 | // return description for this instance |
177 | void setAttribute( QString & Attr, QString & Value ) ; | 218 | inline QString & description( void ) |
178 | void saveAttributes( QTextStream & TS ) ; | 219 | { return Description; } |
220 | inline void setDescription( const QString & S ) | ||
221 | { Description = S; } | ||
222 | |||
223 | // pixmap for this instance -> from NetNode | ||
224 | inline const QString pixmapName( void ) | ||
225 | { return NodeType->pixmapName(); } | ||
226 | |||
227 | inline const char * provides( void ) | ||
228 | { return NodeType->provides(); } | ||
229 | |||
230 | inline const char ** needs( void ) | ||
231 | { return NodeType->needs(); } | ||
232 | |||
233 | inline void setConnection( NodeCollection * NC ) | ||
234 | { Connection = NC; } | ||
235 | inline NodeCollection * connection( void ) | ||
236 | { return Connection; } | ||
237 | |||
238 | // | ||
239 | // | ||
240 | // Virtual methods with sensible defaults | ||
241 | // | ||
242 | // | ||
243 | |||
244 | |||
245 | |||
246 | // open proper file identified by S | ||
247 | virtual QFile * openFile( const QString & ) | ||
248 | { return 0; } | ||
249 | |||
250 | // check if this node (or sub nodes) have data for this file | ||
251 | virtual bool hasDataForFile( const QString & S ) | ||
252 | { return nodeClass()->hasDataForFile( S ); } | ||
253 | |||
254 | // generate code specific for this node but embedded | ||
255 | // in the section of the parent | ||
256 | // this is called within the code of the parent | ||
257 | virtual short generateFileEmbedded( const QString & ID, | ||
258 | const QString & Path, | ||
259 | QTextStream & TS, | ||
260 | long DevNr ) | ||
261 | { ANetNodeInstance * NNI = nextNode(); | ||
262 | return (NNI) ? NNI->generateFileEmbedded( ID, Path, TS, DevNr ) : 1; | ||
263 | } | ||
179 | 264 | ||
180 | // return true if node isntance is NEW and not loaded | 265 | // generate code specific for this node |
181 | void setNew( bool IsN ) | 266 | // (or find the first node that does) |
182 | { IsNew = IsN; } | 267 | virtual short generateFile( const QString & ID, |
183 | bool isNew( void ) | 268 | const QString & Path, |
184 | { return IsNew; } | 269 | QTextStream & TS, |
270 | long DevNr ) | ||
271 | { ANetNodeInstance * NNI = nextNode(); | ||
272 | return (NNI) ? NNI->generateFile( ID, Path, TS, DevNr ) : 1; | ||
273 | } | ||
185 | 274 | ||
186 | // return description for this instance | 275 | // return true if this node instance is triggered by this trigger |
187 | QString & description( void ) | 276 | // could be delegated to deeper instances |
188 | { return Description; } | 277 | virtual bool triggeredBy( const QString & ) |
189 | void setDescription( const QString & S ) | 278 | { return 0; } |
190 | { Description = S; } | ||
191 | 279 | ||
192 | // pixmap for this instance -> from NetNode | 280 | // |
193 | const QString pixmapName( void ) | 281 | // |
194 | { return NodeType->pixmapName(); } | 282 | // Pure virtual functions |
283 | // | ||
284 | // | ||
195 | 285 | ||
196 | const char * provides( void ) | 286 | // return runtime information for this node |
197 | { return NodeType->provides(); } | 287 | virtual RuntimeInfo * runtime( void ) = 0; |
198 | 288 | ||
199 | const char ** needs( void ) | 289 | // create edit widget under parent |
200 | { return NodeType->needs(); } | 290 | virtual QWidget * edit( QWidget * parent ) = 0; |
201 | 291 | ||
202 | // returns node specific data -> only useful for 'buddy' | 292 | // is given data acceptable |
203 | virtual void * data( void ) = 0; | 293 | virtual QString acceptable( void ) = 0; |
204 | 294 | ||
205 | // return TRUE if this node has data to be inserted in systemfile | 295 | // get data from GUI and store in node |
206 | // with name S | 296 | virtual void commit( void ) = 0; |
207 | virtual bool hasDataFor( const QString & S ) = 0; | ||
208 | 297 | ||
209 | // generate data specific for a profile and for the system file S | 298 | // returns node specific data -> only useful for 'buddy' |
210 | // called only IF data was needed | 299 | virtual void * data( void ) = 0; |
211 | virtual bool generateDataForCommonFile( | ||
212 | SystemFile & SF, long DevNr ) = 0; | ||
213 | 300 | ||
214 | protected : | 301 | protected : |
215 | 302 | ||
216 | virtual void setSpecificAttribute( QString & , QString & ) = 0; | 303 | virtual void setSpecificAttribute( QString & , QString & ) = 0; |
217 | virtual void saveSpecificAttribute( QTextStream & ) = 0; | 304 | virtual void saveSpecificAttribute( QTextStream & ) = 0; |
218 | 305 | ||
219 | ANetNode * NodeType; | 306 | ANetNode * NodeType; |
220 | // connection to which this node belongs to | 307 | // connection to which this node belongs to |
221 | NodeCollection * Connection; | 308 | NodeCollection * Connection; |
222 | QString Description; | 309 | QString Description; |
223 | bool IsModified; | 310 | bool IsModified; |
224 | bool IsNew; | 311 | bool IsNew; |
312 | int Done; | ||
225 | 313 | ||
226 | static long InstanceCounter; | 314 | static long InstanceCounter; |
227 | }; | 315 | }; |
228 | 316 | ||
@@ -283,26 +371,31 @@ public : | |||
283 | ~NodeCollection( void ); | 371 | ~NodeCollection( void ); |
284 | 372 | ||
285 | int number( void ) | 373 | inline int done( void ) |
374 | { return Done; } | ||
375 | inline void setDone( int D ) | ||
376 | { Done = D; } | ||
377 | |||
378 | inline int number( void ) | ||
286 | { return Number; } | 379 | { return Number; } |
287 | void setNumber( int i ) | 380 | inline void setNumber( int i ) |
288 | { Number = i; } | 381 | { Number = i; } |
289 | bool isNew( void ) | 382 | inline bool isNew( void ) |
290 | { return IsNew; } | 383 | { return IsNew; } |
291 | void setNew( bool N ) | 384 | inline void setNew( bool N ) |
292 | { IsNew = N ; } | 385 | { IsNew = N ; } |
293 | bool isModified( void ) | 386 | inline bool isModified( void ) |
294 | { return IsModified; } | 387 | { return IsModified; } |
295 | void setModified( bool N ) | 388 | inline void setModified( bool N ) |
296 | { IsModified = N ; } | 389 | { IsModified = N ; } |
297 | 390 | ||
298 | bool handlesInterface( const QString & S ) { | 391 | inline bool handlesInterface( const QString & S ) { |
299 | return getToplevel()->runtime()->handlesInterface( S ); | 392 | return getToplevel()->runtime()->handlesInterface( S ); |
300 | } | 393 | } |
301 | 394 | ||
302 | InterfaceInfo * assignedInterface( void ) { | 395 | inline InterfaceInfo * assignedInterface( void ) { |
303 | return getToplevel()->runtime()->assignedInterface(); | 396 | return getToplevel()->runtime()->assignedInterface(); |
304 | } | 397 | } |
305 | 398 | ||
306 | AsDevice * device() { | 399 | inline AsDevice * device() { |
307 | return getToplevel()->runtime()->device(); | 400 | return getToplevel()->runtime()->device(); |
308 | } | 401 | } |
@@ -310,5 +403,5 @@ public : | |||
310 | bool triggersVPN(); | 403 | bool triggersVPN(); |
311 | 404 | ||
312 | State_t state( bool Update = 0 ) | 405 | inline State_t state( bool Update = 0 ) |
313 | { Log(( "%s state %d(=%d?)\n", Name.latin1(), CurrentState, | 406 | { Log(( "%s state %d(=%d?)\n", Name.latin1(), CurrentState, |
314 | Unchecked )); | 407 | Unchecked )); |
@@ -326,13 +419,13 @@ public : | |||
326 | QPixmap devicePixmap( void ); | 419 | QPixmap devicePixmap( void ); |
327 | QPixmap statePixmap( State_t S ); | 420 | QPixmap statePixmap( State_t S ); |
328 | QPixmap statePixmap( bool Update = 0 ) | 421 | inline QPixmap statePixmap( bool Update = 0 ) |
329 | { return statePixmap( state(Update) ); } | 422 | { return statePixmap( state(Update) ); } |
330 | QString stateName( State_t ); | 423 | QString stateName( State_t ); |
331 | QString stateName( bool Update = 0 ) | 424 | inline QString stateName( bool Update = 0 ) |
332 | { return stateName( state(Update) ); } | 425 | { return stateName( state(Update) ); } |
333 | 426 | ||
334 | bool setState( Action_t A, bool Force =0 ) | 427 | inline bool setState( Action_t A, bool Force =0 ) |
335 | { return getToplevel()->runtime()->setState( this, A, Force ); } | 428 | { return getToplevel()->runtime()->setState( this, A, Force ); } |
336 | bool canSetState( Action_t A ) | 429 | inline bool canSetState( Action_t A ) |
337 | { return getToplevel()->runtime()->canSetState( CurrentState, A ); } | 430 | { return getToplevel()->runtime()->canSetState( CurrentState, A ); } |
338 | 431 | ||
@@ -349,17 +442,33 @@ public : | |||
349 | ANetNodeInstance * findByName( const QString & S ); | 442 | ANetNodeInstance * findByName( const QString & S ); |
350 | 443 | ||
351 | const QString & name() | 444 | inline const QString & name() |
352 | { return Name; } | 445 | { return Name; } |
353 | 446 | ||
354 | const QString & description( void ); | 447 | const QString & description( void ); |
355 | 448 | ||
356 | void setName( const QString & N) | 449 | inline void setName( const QString & N) |
357 | { Name = N; } | 450 | { Name = N; } |
358 | 451 | ||
359 | State_t currentState( void ) | 452 | inline State_t currentState( void ) |
360 | { return CurrentState; } | 453 | { return CurrentState; } |
361 | void setCurrentState( State_t S ) | 454 | inline void setCurrentState( State_t S ) |
362 | { CurrentState = S; } | 455 | { CurrentState = S; } |
363 | 456 | ||
457 | // return TRUE if this node can have data to be inserted in | ||
458 | // file identified by S | ||
459 | bool hasDataForFile( const QString & S ); | ||
460 | ANetNodeInstance * firstWithDataForFile( const QString & S ); | ||
461 | |||
462 | // generate items for this file -> toplevel call | ||
463 | short generateFile( const QString & FID, // identification of file | ||
464 | const QString & FName, // effective filename of file | ||
465 | QTextStream & TS, // stream to file | ||
466 | long DN // device number | ||
467 | ) | ||
468 | { return getToplevel()->generateFile( FID, FName, TS, DN ); } | ||
469 | |||
470 | bool triggeredBy( const QString & Trigger ) | ||
471 | { return getToplevel()->triggeredBy( Trigger ); } | ||
472 | |||
364 | private : | 473 | private : |
365 | 474 | ||
@@ -379,4 +488,5 @@ private : | |||
379 | int Index; | 488 | int Index; |
380 | bool IsModified; | 489 | bool IsModified; |
490 | int Done; | ||
381 | 491 | ||
382 | }; | 492 | }; |
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp index 71e84cd..7ece817 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.cpp +++ b/noncore/settings/networksettings2/networksettings2/resources.cpp | |||
@@ -78,5 +78,5 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), | |||
78 | 78 | ||
79 | // define system files | 79 | // define system files |
80 | addSystemFile( new SystemFile( "interfaces", "./interfaces" ) ); | 80 | addSystemFile( "interfaces", "/tmp/interfaces", 1 ); |
81 | 81 | ||
82 | // get access to the system | 82 | // get access to the system |
@@ -89,5 +89,14 @@ TheNSResources::~TheNSResources( void ) { | |||
89 | } | 89 | } |
90 | 90 | ||
91 | void TheNSResources::busy( bool B ) { | 91 | void TheNSResources::addSystemFile( const QString & ID, |
92 | const QString & P, | ||
93 | bool KDI ) { | ||
94 | if( ! SystemFiles.find( ID ) ) { | ||
95 | // new system file | ||
96 | SystemFiles.insert( ID, new SystemFile( ID, P, KDI ) ); | ||
97 | } // else existed | ||
98 | } | ||
99 | |||
100 | void TheNSResources::busy( bool ) { | ||
92 | /* | 101 | /* |
93 | if( B ) { | 102 | if( B ) { |
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h index 55d2f29..16355ba 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.h +++ b/noncore/settings/networksettings2/networksettings2/resources.h | |||
@@ -67,6 +67,7 @@ public : | |||
67 | Name2SystemFile_t & systemFiles( void ) | 67 | Name2SystemFile_t & systemFiles( void ) |
68 | { return SystemFiles; } | 68 | { return SystemFiles; } |
69 | void addSystemFile( SystemFile * SF ) | 69 | void addSystemFile( const QString & ID, |
70 | { SystemFiles.insert( SF->name(), SF ); } | 70 | const QString & P, |
71 | bool KDI ); | ||
71 | 72 | ||
72 | ANetNodeInstance * createNodeInstance( const QString & S ) | 73 | ANetNodeInstance * createNodeInstance( const QString & S ) |
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp index a579396..271e73d 100644 --- a/noncore/settings/networksettings2/networksettings2/system.cpp +++ b/noncore/settings/networksettings2/networksettings2/system.cpp | |||
@@ -391,6 +391,9 @@ void VLog( char * Format, ... ) { | |||
391 | 391 | ||
392 | if( logf == (FILE *)0 ) { | 392 | if( logf == (FILE *)0 ) { |
393 | // logf = fopen( "/tmp/ns2log", "a" ); | 393 | if( getenv("NS2STDERR") ) { |
394 | logf = stderr; | 394 | logf = stderr; |
395 | } else { | ||
396 | logf = fopen( "/tmp/ns2log", "a" ); | ||
397 | } | ||
395 | if( ! logf ) { | 398 | if( ! logf ) { |
396 | fprintf( stderr, "Cannot open logfile /tmp/ns2log %d\n", | 399 | fprintf( stderr, "Cannot open logfile /tmp/ns2log %d\n", |
@@ -412,6 +415,15 @@ void LogClose( void ) { | |||
412 | if( (long)logf > 1 ) { | 415 | if( (long)logf > 1 ) { |
413 | fprintf( logf, "____ CLOSE LOGFILE ____\n"); | 416 | fprintf( logf, "____ CLOSE LOGFILE ____\n"); |
414 | fclose( logf ); | 417 | if( logf != stderr ) { |
418 | fclose( logf ); | ||
419 | } | ||
415 | logf = 0; | 420 | logf = 0; |
416 | } | 421 | } |
417 | } | 422 | } |
423 | |||
424 | QString removeSpaces( const QString & X ) { | ||
425 | QStringList SL; | ||
426 | |||
427 | SL = QStringList::split( " ", X ); | ||
428 | return SL.join( "_" ); | ||
429 | } | ||
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp index b3fc1a5..2b40834 100644 --- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp +++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp | |||
@@ -12,5 +12,7 @@ | |||
12 | QString TemplDir; | 12 | QString TemplDir; |
13 | 13 | ||
14 | SystemFile::SystemFile( const QString & N, const QString & P ){ | 14 | SystemFile::SystemFile( const QString & N, |
15 | const QString & P, | ||
16 | bool KDI ){ | ||
15 | Name = N; | 17 | Name = N; |
16 | Path = P; | 18 | Path = P; |
@@ -58,4 +60,6 @@ SystemFile::SystemFile( const QString & N, const QString & P ){ | |||
58 | hasPostDeviceSection = ( FI.exists() && FI.isReadable() ); | 60 | hasPostDeviceSection = ( FI.exists() && FI.isReadable() ); |
59 | } | 61 | } |
62 | |||
63 | KnowsDeviceInstances = KDI; | ||
60 | } | 64 | } |
61 | 65 | ||
@@ -97,9 +101,9 @@ bool SystemFile::preSection( void ) { | |||
97 | QFile Fl( TemplDir + Name + "/presection" ); | 101 | QFile Fl( TemplDir + Name + "/presection" ); |
98 | if( ! Fl.open( IO_ReadOnly ) ) | 102 | if( ! Fl.open( IO_ReadOnly ) ) |
99 | return 1; // error | 103 | return 0; // error |
100 | // copy file to this file | 104 | // copy file to this file |
101 | F->writeBlock( Fl.readAll() ); | 105 | F->writeBlock( Fl.readAll() ); |
102 | } | 106 | } |
103 | return 0; | 107 | return 1; |
104 | } | 108 | } |
105 | 109 | ||
@@ -108,9 +112,9 @@ bool SystemFile::postSection( void ) { | |||
108 | QFile Fl( TemplDir + Name + "/postsection" ); | 112 | QFile Fl( TemplDir + Name + "/postsection" ); |
109 | if( ! Fl.open( IO_ReadOnly ) ) | 113 | if( ! Fl.open( IO_ReadOnly ) ) |
110 | return 1; // error | 114 | return 0; // error |
111 | // copy file to this file | 115 | // copy file to this file |
112 | F->writeBlock( Fl.readAll() ); | 116 | F->writeBlock( Fl.readAll() ); |
113 | } | 117 | } |
114 | return 0; | 118 | return 1; |
115 | } | 119 | } |
116 | 120 | ||
@@ -119,5 +123,5 @@ bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) { | |||
119 | QFile Fl( TemplDir + Name + "/prenodesection" ); | 123 | QFile Fl( TemplDir + Name + "/prenodesection" ); |
120 | if( ! Fl.open( IO_ReadOnly ) ) | 124 | if( ! Fl.open( IO_ReadOnly ) ) |
121 | return 1; // error | 125 | return 0; // error |
122 | QTextStream TX( &Fl ); | 126 | QTextStream TX( &Fl ); |
123 | QString Out; | 127 | QString Out; |
@@ -130,5 +134,5 @@ bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) { | |||
130 | } | 134 | } |
131 | } | 135 | } |
132 | return 0; | 136 | return 1; |
133 | } | 137 | } |
134 | 138 | ||
@@ -137,5 +141,5 @@ bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) { | |||
137 | QFile Fl( TemplDir + Name + "/postnodesection" ); | 141 | QFile Fl( TemplDir + Name + "/postnodesection" ); |
138 | if( ! Fl.open( IO_ReadOnly ) ) | 142 | if( ! Fl.open( IO_ReadOnly ) ) |
139 | return 1; // error | 143 | return 0; // error |
140 | QTextStream TX( &Fl ); | 144 | QTextStream TX( &Fl ); |
141 | QString Out; | 145 | QString Out; |
@@ -148,5 +152,5 @@ bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) { | |||
148 | } | 152 | } |
149 | } | 153 | } |
150 | return 0; | 154 | return 1; |
151 | } | 155 | } |
152 | 156 | ||
@@ -155,5 +159,5 @@ bool SystemFile::preDeviceSection( ANetNode * NN ) { | |||
155 | QFile Fl( TemplDir + Name + "/predevicesection" ); | 159 | QFile Fl( TemplDir + Name + "/predevicesection" ); |
156 | if( ! Fl.open( IO_ReadOnly ) ) | 160 | if( ! Fl.open( IO_ReadOnly ) ) |
157 | return 1; // error | 161 | return 0; // error |
158 | QTextStream TX( &Fl ); | 162 | QTextStream TX( &Fl ); |
159 | QString Out; | 163 | QString Out; |
@@ -165,5 +169,5 @@ bool SystemFile::preDeviceSection( ANetNode * NN ) { | |||
165 | } | 169 | } |
166 | } | 170 | } |
167 | return 0; | 171 | return 1; |
168 | } | 172 | } |
169 | 173 | ||
@@ -172,5 +176,5 @@ bool SystemFile::postDeviceSection( ANetNode * NN ) { | |||
172 | QFile Fl( TemplDir + Name + "/postdevicesection" ); | 176 | QFile Fl( TemplDir + Name + "/postdevicesection" ); |
173 | if( ! Fl.open( IO_ReadOnly ) ) | 177 | if( ! Fl.open( IO_ReadOnly ) ) |
174 | return 1; // error | 178 | return 0; // error |
175 | QTextStream TX( &Fl ); | 179 | QTextStream TX( &Fl ); |
176 | QString Out; | 180 | QString Out; |
@@ -182,4 +186,4 @@ bool SystemFile::postDeviceSection( ANetNode * NN ) { | |||
182 | } | 186 | } |
183 | } | 187 | } |
184 | return 0; | 188 | return 1; |
185 | } | 189 | } |
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.h b/noncore/settings/networksettings2/networksettings2/systemfile.h index f57dab0..ceed605 100644 --- a/noncore/settings/networksettings2/networksettings2/systemfile.h +++ b/noncore/settings/networksettings2/networksettings2/systemfile.h | |||
@@ -12,9 +12,15 @@ class SystemFile : public QTextStream { | |||
12 | public : | 12 | public : |
13 | 13 | ||
14 | SystemFile( const QString & Name, const QString & Path ); | 14 | SystemFile( const QString & Name, |
15 | const QString & Path, | ||
16 | bool KnowsDevicesInstances ); | ||
15 | ~SystemFile( void ); | 17 | ~SystemFile( void ); |
16 | 18 | ||
17 | const QString & name( void ) | 19 | const QString & name( void ) const |
18 | { return Name; } | 20 | { return Name; } |
21 | const QString & path( void ) const | ||
22 | { return Path; } | ||
23 | bool knowsDeviceInstances( void ) const | ||
24 | { return KnowsDeviceInstances; } | ||
19 | 25 | ||
20 | bool open( void ); | 26 | bool open( void ); |
@@ -39,4 +45,5 @@ private : | |||
39 | bool hasPreDeviceSection; | 45 | bool hasPreDeviceSection; |
40 | bool hasPostDeviceSection; | 46 | bool hasPostDeviceSection; |
47 | bool KnowsDeviceInstances; | ||
41 | 48 | ||
42 | }; | 49 | }; |
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index 3b17548..d709c0a 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp | |||
@@ -21,5 +21,4 @@ NetworkSettingsData::NetworkSettingsData( void ) { | |||
21 | 21 | ||
22 | // load settings | 22 | // load settings |
23 | Force = 0; | ||
24 | IsModified = 0; | 23 | IsModified = 0; |
25 | loadSettings(); | 24 | loadSettings(); |
@@ -219,86 +218,112 @@ QString NetworkSettingsData::saveSettings( void ) { | |||
219 | } | 218 | } |
220 | 219 | ||
221 | QString NetworkSettingsData::generateSettings( bool ForceReq ) { | 220 | QString NetworkSettingsData::generateSettings( void ) { |
222 | bool ForceIt; | ||
223 | QString S = ""; | 221 | QString S = ""; |
224 | 222 | Name2SystemFile_t & SFM = NSResources->systemFiles(); | |
225 | // include own force flag | 223 | Name2Connection_t & M = NSResources->connections(); |
226 | ForceIt = (Force) ? 1 : ForceReq; | 224 | NodeCollection * NC; |
227 | 225 | ANetNodeInstance * NNI; | |
228 | if( ! ForceIt && ! isModified() ) | 226 | ANetNodeInstance * FirstWithData; |
229 | return S; | 227 | SystemFile * SF; |
228 | AsDevice * CurDev; | ||
229 | ANetNode * NN, * CurDevNN = 0; | ||
230 | long NoOfDevs; | ||
231 | long DevCtStart; | ||
232 | bool needToGenerate; | ||
230 | 233 | ||
231 | // regenerate system files | 234 | // regenerate system files |
232 | Log( ( "Generating settings from %s\n", CfgFile.latin1() )); | 235 | Log( ( "Generating settings from %s\n", CfgFile.latin1() )); |
233 | 236 | ||
234 | { Name2SystemFile_t & SFM = NSResources->systemFiles(); | 237 | // |
235 | Name2Connection_t & M = NSResources->connections(); | 238 | // generate files proper to each netnodeinstance |
236 | NodeCollection * NC; | 239 | // |
237 | ANetNodeInstance * NNI; | 240 | { Name2Instance_t & NNIs = NSResources->netNodeInstances(); |
238 | SystemFile * SF; | 241 | |
239 | AsDevice * CurDev; | 242 | for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); |
240 | ANetNode * CurDevNN; | 243 | NNIIt.current(); |
241 | bool needToRegenerate = ForceIt; | 244 | ++NNIIt ) { |
242 | 245 | // for all nodes find those that are modified | |
243 | // | 246 | NNI = NNIIt.current(); |
244 | // check if we need to generate at least one of the system files | 247 | |
245 | // | 248 | { // get list of proper files for this nodeclass (if any) |
246 | if( ! ForceIt ) { | 249 | QStringList * PF = NNI->nodeClass()->properFiles(); |
247 | for( QDictIterator<SystemFile> sfit(SFM); | 250 | |
248 | sfit.current(); | 251 | if( PF ) { |
249 | ++sfit ) { | 252 | for ( QStringList::Iterator it = PF->begin(); |
250 | SF = sfit.current(); | 253 | it != PF->end(); |
251 | 254 | ++it ) { | |
252 | // check if there are nodes that are modified and require | 255 | QFile * F = NNI->openFile( (*it) ); |
253 | // data for this system file | 256 | if( F ) { |
254 | 257 | QTextStream TS( F ); | |
255 | // for all connections | 258 | if( NNI->generateFile( (*it), F->name(), TS, -1 ) == 2 ) { |
256 | for( QDictIterator<NodeCollection> ncit(M); | 259 | // problem generating |
257 | ncit.current(); | 260 | S = qApp->translate( "NetworkSettings", |
258 | ++ncit ) { | 261 | "<p>Cannot generate files proper to \"%1\"</p>" ). |
259 | NC = ncit.current(); | 262 | arg(NNI->nodeClass()->name()) ; |
260 | 263 | delete F; | |
261 | if( NC->isModified() ) { | 264 | return S; |
262 | // does this connection 'touch' this system file ? | ||
263 | for( QListIterator<ANetNodeInstance> cncit(*NC); | ||
264 | cncit.current(); | ||
265 | ++cncit ) { | ||
266 | NNI = cncit.current(); | ||
267 | if( ( NNI->nodeClass()->hasDataFor( SF->name() ) || | ||
268 | NNI->hasDataFor( SF->name() ) | ||
269 | ) && | ||
270 | NNI->isModified() ) { | ||
271 | needToRegenerate = 1; | ||
272 | break; | ||
273 | } | 265 | } |
266 | delete F; | ||
274 | } | 267 | } |
275 | } | 268 | } |
276 | if( needToRegenerate ) | ||
277 | break; | ||
278 | } | 269 | } |
279 | if( needToRegenerate ) | ||
280 | break; | ||
281 | } | 270 | } |
282 | } | 271 | } |
272 | } | ||
283 | 273 | ||
284 | // | 274 | // |
285 | // generate files proper to each netnodeinstance | 275 | // generate all system files |
286 | // | 276 | // |
287 | { Name2Instance_t & NNIs = NSResources->netNodeInstances(); | 277 | for( QDictIterator<SystemFile> sfit(SFM); |
288 | 278 | sfit.current(); | |
289 | for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); | 279 | ++sfit ) { |
290 | NNIIt.current(); | 280 | SF = sfit.current(); |
291 | ++NNIIt | 281 | |
292 | ){ | 282 | // reset all |
293 | // for all nodes find those that are modified | 283 | for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); |
294 | NNI = NNIIt.current(); | 284 | nnit.current(); |
295 | 285 | ++nnit ) { | |
296 | if( ForceIt || NNI->isModified() ) { | 286 | nnit.current()->NetNode->setDone(0); |
297 | if( NNI->nodeClass()->generateProperFilesFor( NNI ) ) { | 287 | } |
298 | // problem generating | 288 | |
299 | S = qApp->translate( "NetworkSettings", | 289 | for( QDictIterator<ANetNodeInstance> nniit( |
300 | "<p>Cannot generate files proper to \"%1\"</p>" ). | 290 | NSResources->netNodeInstances() ); |
301 | arg(NNI->nodeClass()->name()) ; | 291 | nniit.current(); |
302 | return S; | 292 | ++nniit ) { |
293 | nniit.current()->setDone(0); | ||
294 | } | ||
295 | |||
296 | for( QDictIterator<NodeCollection> ncit(M); | ||
297 | ncit.current(); | ||
298 | ++ncit ) { | ||
299 | ncit.current()->setDone(0); | ||
300 | } | ||
301 | |||
302 | Log( ( "Generating %s\n", SF->name().latin1() )); | ||
303 | |||
304 | needToGenerate = 0; | ||
305 | |||
306 | // are there netnodes that have instances and need | ||
307 | // to write data in this system file ? | ||
308 | for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); | ||
309 | ! needToGenerate && nnit.current(); | ||
310 | ++nnit ) { | ||
311 | |||
312 | NN = nnit.current()->NetNode; | ||
313 | |||
314 | if( NN->hasDataForFile( SF->name() ) ) { | ||
315 | // netnode can have data | ||
316 | |||
317 | // are there instances of this node ? | ||
318 | for( QDictIterator<ANetNodeInstance> nniit( | ||
319 | NSResources->netNodeInstances() ); | ||
320 | ! needToGenerate && nniit.current(); | ||
321 | ++nniit ) { | ||
322 | if( nniit.current()->nodeClass() == NN ) { | ||
323 | // yes | ||
324 | Log(("Node %s has data\n", | ||
325 | nniit.current()->name() )); | ||
326 | needToGenerate = 1; | ||
327 | break; | ||
303 | } | 328 | } |
304 | } | 329 | } |
@@ -306,77 +331,173 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { | |||
306 | } | 331 | } |
307 | 332 | ||
308 | // | 333 | if( ! needToGenerate ) { |
309 | // generate all system files | 334 | // no instances found that might need to write data |
310 | // | 335 | // in this systemfile |
311 | for( QDictIterator<SystemFile> sfit(SFM); | 336 | Log(("No nodes for systemfile %s\n", SF->name().latin1() )); |
312 | sfit.current(); | 337 | continue; |
313 | ++sfit ) { | 338 | } |
314 | SF = sfit.current(); | ||
315 | 339 | ||
316 | Log( ( "Generating %s\n", SF->name().latin1() )); | 340 | // ok generate this system file |
317 | SF->open(); | 341 | SF->open(); |
318 | 342 | ||
319 | do { // so we can break; | 343 | // global presection for this system file |
344 | if( ! SF->preSection() ) { | ||
345 | S = qApp->translate( "NetworkSettings", | ||
346 | "<p>Error in section \"Preamble\" for file \"%1\"</p>" ). | ||
347 | arg( SF->name() ); | ||
348 | return S; | ||
349 | } | ||
320 | 350 | ||
321 | // global presection for this system file | 351 | // find connections that want to write to this file |
322 | if( SF->preSection() ) { | 352 | for( QDictIterator<NodeCollection> ncit(M); |
353 | ncit.current(); | ||
354 | ++ncit ) { | ||
355 | |||
356 | NC = ncit.current(); | ||
357 | |||
358 | if( NC->done() ) { | ||
359 | // already done | ||
360 | continue; | ||
361 | } | ||
362 | |||
363 | if( ! NC->hasDataForFile( SF->name() ) ) { | ||
364 | // no data | ||
365 | continue; | ||
366 | } | ||
367 | |||
368 | Log(("Generating %s for connection %s\n", | ||
369 | SF->name().latin1(), NC->name().latin1() )); | ||
370 | // find highest item that wants to write data to this file | ||
371 | FirstWithData = NC->firstWithDataForFile( SF->name() ); | ||
372 | |||
373 | // find device on which this connection works | ||
374 | CurDev = NC->device(); | ||
375 | // class of that node | ||
376 | CurDevNN = CurDev->netNode()->nodeClass(); | ||
377 | |||
378 | Log(( "%s is done %d\n", | ||
379 | FirstWithData->nodeClass()->name(), | ||
380 | FirstWithData->nodeClass()->done() )); | ||
381 | |||
382 | if( ! FirstWithData->nodeClass()->done() ) { | ||
383 | // generate fixed part | ||
384 | if( ! SF->preDeviceSection( CurDevNN ) ) { | ||
323 | S = qApp->translate( "NetworkSettings", | 385 | S = qApp->translate( "NetworkSettings", |
324 | "<p>Error in preSection for file \"%1\"</p>" ). | 386 | "<p>Error in section \"Pre-Device\" for file \"%1\"</p>" ). |
325 | arg( SF->name() ); | 387 | arg( SF->name() ); |
326 | return S; | 388 | return S; |
327 | } | 389 | } |
328 | 390 | ||
329 | // find all netnodes and figure out if | 391 | if( FirstWithData->nodeClass()->generateFile( |
330 | // for that node there are instances | 392 | SF->name(), SF->path(), *SF, -1 ) == 2 ) { |
331 | for( QDictIterator<NetNode_t> nnit( | 393 | S = qApp->translate( "NetworkSettings", |
332 | NSResources->netNodes() ); | 394 | "<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ). |
333 | nnit.current(); | 395 | arg( SF->name() ). |
334 | ++nnit ) { | 396 | arg( CurDevNN->name() ); |
335 | 397 | return S; | |
336 | CurDevNN = nnit.current()->NetNode; | 398 | } |
337 | 399 | FirstWithData->nodeClass()->setDone( 1 ); | |
338 | // are there instances for this netnode ? | 400 | } |
339 | NNI = 0; | 401 | |
340 | for( QDictIterator<ANetNodeInstance> nniit( | 402 | NoOfDevs = 0; |
341 | NSResources->netNodeInstances() ); | 403 | DevCtStart = -1; |
342 | nniit.current(); | 404 | |
343 | ++nniit ) { | 405 | if( SF->knowsDeviceInstances() ) { |
344 | if( nniit.current()->nodeClass() == CurDevNN ) { | 406 | DevCtStart = 0; |
345 | NNI = nniit.current(); | 407 | NoOfDevs = CurDevNN->instanceCount(); |
346 | break; | 408 | } |
347 | } | 409 | |
410 | Log(( "Node %s is done %d\n", | ||
411 | CurDev->netNode()->nodeClass()->name(), | ||
412 | CurDev->netNode()->nodeClass()->done() )); | ||
413 | |||
414 | if( ! CurDev->netNode()->nodeClass()->done() ) { | ||
415 | // first time this device is handled | ||
416 | // generate common device specific part | ||
417 | for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { | ||
418 | |||
419 | if( FirstWithData->nodeClass()->generateFile( | ||
420 | SF->name(), SF->path(), *SF, CurDev->netNode(), i ) == 2 ) { | ||
421 | S = qApp->translate( "NetworkSettings", | ||
422 | "<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ). | ||
423 | arg( SF->name() ). | ||
424 | arg( CurDevNN->name() ); | ||
425 | return S; | ||
348 | } | 426 | } |
427 | } | ||
428 | CurDev->netNode()->nodeClass()->setDone( 1 ); | ||
429 | } | ||
349 | 430 | ||
350 | if( ! NNI ) | 431 | // generate profile specific info |
351 | // no instances -> next netnode type | 432 | // for all nodeconnections that work on the same device |
352 | continue; | 433 | for( QDictIterator<NodeCollection> ncit2(M); |
434 | ncit2.current(); | ||
435 | ++ncit2 ) { | ||
353 | 436 | ||
354 | // has this node data for this system file ? | 437 | if( ncit2.current()->device() != CurDev ) { |
355 | if( (CurDev = NNI->runtime()->asDevice() ) ) { | 438 | // different device |
356 | // generate start for this nodetype for all possible devices of this type | 439 | continue; |
357 | for( int i = 0; i < CurDevNN->instanceCount(); i ++ ) { | 440 | } |
358 | S = generateSystemFileNode( *SF, CurDev, NNI, i ); | 441 | |
359 | if( ! S.isEmpty() ) | 442 | Log(("Connection %s of same family\n", ncit2.current()->name().latin1() )); |
360 | return S; | 443 | // generate |
361 | } | 444 | NNI = ncit2.current()->firstWithDataForFile( SF->name() ); |
362 | } else { | 445 | for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { |
363 | S = generateSystemFileNode( *SF, 0, NNI, -1 ); | 446 | if( ! SF->preNodeSection( NNI, i ) ) { |
364 | if( ! S.isEmpty() ) | 447 | S = qApp->translate( "NetworkSettings", |
448 | "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ). | ||
449 | arg( SF->name() ). | ||
450 | arg( CurDevNN->name() ); | ||
451 | return S; | ||
452 | } | ||
453 | |||
454 | switch( NNI->generateFile( | ||
455 | SF->name(), SF->path(), *SF, i ) ) { | ||
456 | case 0 : | ||
457 | (*SF) << endl; | ||
458 | break; | ||
459 | case 1 : | ||
460 | break; | ||
461 | case 2 : | ||
462 | S = qApp->translate( "NetworkSettings", | ||
463 | "<p>Error in section \"Node\" for file \"%1\" and node \"%2\"</p>" ). | ||
464 | arg( SF->name() ). | ||
465 | arg( CurDevNN->name() ); | ||
365 | return S; | 466 | return S; |
366 | } | 467 | } |
367 | } | ||
368 | 468 | ||
369 | if( SF->postSection() ) { | 469 | if( ! SF->postNodeSection( NNI, i ) ) { |
370 | S = qApp->translate( "NetworkSettings", | 470 | S = qApp->translate( "NetworkSettings", |
371 | "<p>Error in postSection for file \"%1\"</p>" ). | 471 | "<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ). |
372 | arg( SF->name() ); | 472 | arg( SF->name() ). |
373 | return S; | 473 | arg( CurDevNN->name() ); |
474 | return S; | ||
475 | } | ||
374 | } | 476 | } |
375 | 477 | ||
376 | } while( 0 ); | 478 | ncit2.current()->setDone( 1 ); |
377 | SF->close(); | 479 | |
480 | } | ||
481 | } | ||
482 | |||
483 | if( ! SF->postDeviceSection( CurDevNN ) ) { | ||
484 | S = qApp->translate( "NetworkSettings", | ||
485 | "<p>Error in section \"Post-Device\" for file \"%1\" and node \"%2\"</p>" ). | ||
486 | arg( SF->name() ). | ||
487 | arg( CurDevNN->name() ); | ||
488 | return S; | ||
489 | } | ||
490 | |||
491 | |||
492 | if( ! SF->postSection() ) { | ||
493 | S = qApp->translate( "NetworkSettings", | ||
494 | "<p>Error in section \"Closure\" for file \"%1\"</p>" ). | ||
495 | arg( SF->name() ); | ||
496 | return S; | ||
378 | } | 497 | } |
498 | |||
499 | // end of file | ||
500 | SF->close(); | ||
379 | } | 501 | } |
380 | Force = 0; | ||
381 | return S; | 502 | return S; |
382 | } | 503 | } |
@@ -464,7 +585,5 @@ bool NetworkSettingsData::canStart( const char * Interface ) { | |||
464 | 585 | ||
465 | bool NetworkSettingsData::regenerate( void ) { | 586 | bool NetworkSettingsData::regenerate( void ) { |
466 | QString S; | 587 | QString S = generateSettings(); |
467 | // load situation | ||
468 | S = generateSettings( TRUE ); | ||
469 | if( ! S.isEmpty() ) { | 588 | if( ! S.isEmpty() ) { |
470 | fprintf( stdout, "%s\n", S.latin1() ); | 589 | fprintf( stdout, "%s\n", S.latin1() ); |
@@ -473,101 +592,2 @@ bool NetworkSettingsData::regenerate( void ) { | |||
473 | return 0; | 592 | return 0; |
474 | } | 593 | } |
475 | |||
476 | QString NetworkSettingsData::generateSystemFileNode( | ||
477 | SystemFile &SF, | ||
478 | AsDevice * CurDev, | ||
479 | ANetNodeInstance * DevNNI, | ||
480 | long DevInstNr ) { | ||
481 | |||
482 | QString S=""; | ||
483 | ANetNode * CurDevNN = DevNNI->nodeClass(); | ||
484 | Name2Connection_t & M = NSResources->connections(); | ||
485 | |||
486 | if( SF.preDeviceSection( CurDevNN ) ) { | ||
487 | S = qApp->translate( "NetworkSettings", | ||
488 | "<p>Error in \"Pre-Device Part\" for file \"%1\" and nodetype \"%2\"</p>" ). | ||
489 | arg( SF.name() ). | ||
490 | arg( CurDevNN->name() ); | ||
491 | return S; | ||
492 | } | ||
493 | |||
494 | if( CurDevNN->hasDataFor( SF.name() ) ) { | ||
495 | if( CurDevNN->generateDeviceDataForCommonFile( SF, DevInstNr ) ) { | ||
496 | S = qApp->translate( "NetworkSettings", | ||
497 | "<p>Error in \"Device Part\" for file \"%1\" and node \"%2\"</p>" ). | ||
498 | arg( SF.name() ). | ||
499 | arg( CurDevNN->name() ); | ||
500 | return S; | ||
501 | } | ||
502 | } | ||
503 | |||
504 | // now generate profile specific data for all | ||
505 | // connections working on a device of the current | ||
506 | // netnode type | ||
507 | for( QDictIterator<NodeCollection> ncit(M); | ||
508 | ncit.current(); | ||
509 | ++ncit ) { | ||
510 | NodeCollection * NC = ncit.current(); | ||
511 | |||
512 | // currenly only those connections that work on | ||
513 | // the current device (or on no device if no current) | ||
514 | AsDevice * Dev = NC->device(); | ||
515 | |||
516 | if( CurDev ) { | ||
517 | if( CurDevNN != Dev->netNode()->nodeClass() ) { | ||
518 | // other device type -> later | ||
519 | continue; | ||
520 | } | ||
521 | } else { | ||
522 | if( Dev ) { | ||
523 | // other | ||
524 | continue; | ||
525 | } | ||
526 | } | ||
527 | |||
528 | // generate 'entry' | ||
529 | if( SF.preNodeSection( DevNNI, DevInstNr ) ) { | ||
530 | S = qApp->translate( "NetworkSettings", | ||
531 | "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ). | ||
532 | arg( SF.name() ). | ||
533 | arg( CurDevNN->name() ); | ||
534 | return S; | ||
535 | } | ||
536 | |||
537 | // ask all nodes in connection | ||
538 | for( QListIterator<ANetNodeInstance> cncit(*NC); | ||
539 | cncit.current(); | ||
540 | ++cncit ) { | ||
541 | ANetNodeInstance * NNI = cncit.current(); | ||
542 | |||
543 | if( NNI->hasDataFor( SF.name() ) ) { | ||
544 | if( NNI->generateDataForCommonFile(SF,DevInstNr) ) { | ||
545 | S = qApp->translate( "NetworkSettings", | ||
546 | "<p>Error in \"Node Part\" for file \"%1\" and node \"%2\"</p>" ). | ||
547 | arg( SF.name() ). | ||
548 | arg( NNI->nodeClass()->name() ); | ||
549 | return S; | ||
550 | } | ||
551 | } | ||
552 | } | ||
553 | |||
554 | if( SF.postNodeSection( DevNNI, DevInstNr ) ) { | ||
555 | S = qApp->translate( "NetworkSettings", | ||
556 | "<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ). | ||
557 | arg( SF.name() ). | ||
558 | arg( CurDevNN->name() ); | ||
559 | return S; | ||
560 | } | ||
561 | SF << endl; | ||
562 | } | ||
563 | |||
564 | if( SF.postDeviceSection( CurDevNN ) ) { | ||
565 | S = qApp->translate( "NetworkSettings", | ||
566 | "<p>Error in \"Post-Device Part\" for file \"%1\" and node \"%2\"</p>" ). | ||
567 | arg( SF.name() ). | ||
568 | arg( CurDevNN->name() ); | ||
569 | return S; | ||
570 | } | ||
571 | |||
572 | return S; | ||
573 | } | ||
diff --git a/noncore/settings/networksettings2/nsdata.h b/noncore/settings/networksettings2/nsdata.h index 57eb722..507185e 100644 --- a/noncore/settings/networksettings2/nsdata.h +++ b/noncore/settings/networksettings2/nsdata.h | |||
@@ -14,5 +14,5 @@ public : | |||
14 | QString saveSettings( void ); | 14 | QString saveSettings( void ); |
15 | 15 | ||
16 | QString generateSettings( bool Force = FALSE ); | 16 | QString generateSettings( void ); |
17 | 17 | ||
18 | bool isModified( void ) | 18 | bool isModified( void ) |
@@ -26,16 +26,7 @@ public : | |||
26 | bool regenerate( void ); | 26 | bool regenerate( void ); |
27 | 27 | ||
28 | void forceGeneration( bool m ) | ||
29 | { Force = m; } | ||
30 | |||
31 | private : | 28 | private : |
32 | 29 | ||
33 | QString NetworkSettingsData::generateSystemFileNode( | ||
34 | SystemFile & SF, | ||
35 | AsDevice * CurDev, | ||
36 | ANetNodeInstance * DevNNI, | ||
37 | long DevInstNr ); | ||
38 | bool IsModified; | 30 | bool IsModified; |
39 | bool Force; | ||
40 | 31 | ||
41 | // collect strings in config file nobody wants | 32 | // collect strings in config file nobody wants |
diff --git a/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui b/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui index 826843a..0c5f4c8 100644 --- a/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui +++ b/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui | |||
@@ -12,5 +12,5 @@ | |||
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>249</width> | 14 | <width>245</width> |
15 | <height>209</height> | 15 | <height>209</height> |
16 | </rect> | 16 | </rect> |
@@ -58,9 +58,9 @@ | |||
58 | <property stdset="1"> | 58 | <property stdset="1"> |
59 | <name>margin</name> | 59 | <name>margin</name> |
60 | <number>0</number> | 60 | <number>3</number> |
61 | </property> | 61 | </property> |
62 | <property stdset="1"> | 62 | <property stdset="1"> |
63 | <name>spacing</name> | 63 | <name>spacing</name> |
64 | <number>0</number> | 64 | <number>2</number> |
65 | </property> | 65 | </property> |
66 | <widget> | 66 | <widget> |
@@ -192,13 +192,52 @@ | |||
192 | </widget> | 192 | </widget> |
193 | <widget> | 193 | <widget> |
194 | <class>QRadioButton</class> | 194 | <class>QLayoutWidget</class> |
195 | <property stdset="1"> | 195 | <property stdset="1"> |
196 | <name>name</name> | 196 | <name>name</name> |
197 | <cstring>PapChap_RB</cstring> | 197 | <cstring>Layout3</cstring> |
198 | </property> | ||
199 | <property stdset="1"> | ||
200 | <name>text</name> | ||
201 | <string>Pap/Chap/EAP</string> | ||
202 | </property> | 198 | </property> |
199 | <hbox> | ||
200 | <property stdset="1"> | ||
201 | <name>margin</name> | ||
202 | <number>0</number> | ||
203 | </property> | ||
204 | <property stdset="1"> | ||
205 | <name>spacing</name> | ||
206 | <number>6</number> | ||
207 | </property> | ||
208 | <widget> | ||
209 | <class>QRadioButton</class> | ||
210 | <property stdset="1"> | ||
211 | <name>name</name> | ||
212 | <cstring>Pap_RB</cstring> | ||
213 | </property> | ||
214 | <property stdset="1"> | ||
215 | <name>text</name> | ||
216 | <string>Pap</string> | ||
217 | </property> | ||
218 | </widget> | ||
219 | <widget> | ||
220 | <class>QRadioButton</class> | ||
221 | <property stdset="1"> | ||
222 | <name>name</name> | ||
223 | <cstring>Chap_RB</cstring> | ||
224 | </property> | ||
225 | <property stdset="1"> | ||
226 | <name>text</name> | ||
227 | <string>Chap</string> | ||
228 | </property> | ||
229 | </widget> | ||
230 | <widget> | ||
231 | <class>QRadioButton</class> | ||
232 | <property stdset="1"> | ||
233 | <name>name</name> | ||
234 | <cstring>EAP_RB</cstring> | ||
235 | </property> | ||
236 | <property stdset="1"> | ||
237 | <name>text</name> | ||
238 | <string>EAP</string> | ||
239 | </property> | ||
240 | </widget> | ||
241 | </hbox> | ||
203 | </widget> | 242 | </widget> |
204 | <widget> | 243 | <widget> |
@@ -276,7 +315,7 @@ | |||
276 | <property stdset="1"> | 315 | <property stdset="1"> |
277 | <name>spacing</name> | 316 | <name>spacing</name> |
278 | <number>1</number> | 317 | <number>2</number> |
279 | </property> | 318 | </property> |
280 | <widget row="2" column="0" > | 319 | <widget row="1" column="0" > |
281 | <class>QLabel</class> | 320 | <class>QLabel</class> |
282 | <property stdset="1"> | 321 | <property stdset="1"> |
@@ -289,5 +328,5 @@ | |||
289 | </property> | 328 | </property> |
290 | </widget> | 329 | </widget> |
291 | <widget row="3" column="0" > | 330 | <widget row="2" column="0" > |
292 | <class>QLabel</class> | 331 | <class>QLabel</class> |
293 | <property stdset="1"> | 332 | <property stdset="1"> |
@@ -300,52 +339,23 @@ | |||
300 | </property> | 339 | </property> |
301 | </widget> | 340 | </widget> |
302 | <widget row="0" column="1" > | 341 | <widget row="1" column="1" > |
303 | <class>QComboBox</class> | 342 | <class>QLineEdit</class> |
304 | <item> | ||
305 | <property> | ||
306 | <name>text</name> | ||
307 | <string>PAP</string> | ||
308 | </property> | ||
309 | </item> | ||
310 | <item> | ||
311 | <property> | ||
312 | <name>text</name> | ||
313 | <string>CHAP</string> | ||
314 | </property> | ||
315 | </item> | ||
316 | <item> | ||
317 | <property> | ||
318 | <name>text</name> | ||
319 | <string>EAP</string> | ||
320 | </property> | ||
321 | </item> | ||
322 | <property stdset="1"> | ||
323 | <name>name</name> | ||
324 | <cstring>AuthMethod_CB</cstring> | ||
325 | </property> | ||
326 | </widget> | ||
327 | <widget row="1" column="0" > | ||
328 | <class>QLabel</class> | ||
329 | <property stdset="1"> | 343 | <property stdset="1"> |
330 | <name>name</name> | 344 | <name>name</name> |
331 | <cstring>TextLabel1</cstring> | 345 | <cstring>Server_LE</cstring> |
332 | </property> | 346 | </property> |
333 | <property stdset="1"> | 347 | <property stdset="1"> |
334 | <name>text</name> | 348 | <name>text</name> |
335 | <string>Client</string> | 349 | <string>*</string> |
336 | </property> | 350 | </property> |
337 | </widget> | 351 | </widget> |
338 | <widget row="0" column="0" > | 352 | <widget row="2" column="1" > |
339 | <class>QLabel</class> | 353 | <class>QLineEdit</class> |
340 | <property stdset="1"> | 354 | <property stdset="1"> |
341 | <name>name</name> | 355 | <name>name</name> |
342 | <cstring>TextLabel1_4</cstring> | 356 | <cstring>Secret_LE</cstring> |
343 | </property> | ||
344 | <property stdset="1"> | ||
345 | <name>text</name> | ||
346 | <string>Method</string> | ||
347 | </property> | 357 | </property> |
348 | </widget> | 358 | </widget> |
349 | <widget row="1" column="1" rowspan="1" colspan="2" > | 359 | <widget row="0" column="1" > |
350 | <class>QLineEdit</class> | 360 | <class>QLineEdit</class> |
351 | <property stdset="1"> | 361 | <property stdset="1"> |
@@ -358,43 +368,15 @@ | |||
358 | </property> | 368 | </property> |
359 | </widget> | 369 | </widget> |
360 | <widget row="2" column="1" rowspan="1" colspan="2" > | 370 | <widget row="0" column="0" > |
361 | <class>QLineEdit</class> | 371 | <class>QLabel</class> |
362 | <property stdset="1"> | 372 | <property stdset="1"> |
363 | <name>name</name> | 373 | <name>name</name> |
364 | <cstring>Server_LE</cstring> | 374 | <cstring>TextLabel1</cstring> |
365 | </property> | 375 | </property> |
366 | <property stdset="1"> | 376 | <property stdset="1"> |
367 | <name>text</name> | 377 | <name>text</name> |
368 | <string>*</string> | 378 | <string>Client</string> |
369 | </property> | ||
370 | </widget> | ||
371 | <widget row="3" column="1" rowspan="1" colspan="2" > | ||
372 | <class>QLineEdit</class> | ||
373 | <property stdset="1"> | ||
374 | <name>name</name> | ||
375 | <cstring>Secret_LE</cstring> | ||
376 | </property> | 379 | </property> |
377 | </widget> | 380 | </widget> |
378 | <spacer row="0" column="2" > | ||
379 | <property> | ||
380 | <name>name</name> | ||
381 | <cstring>Spacer7</cstring> | ||
382 | </property> | ||
383 | <property stdset="1"> | ||
384 | <name>orientation</name> | ||
385 | <enum>Horizontal</enum> | ||
386 | </property> | ||
387 | <property stdset="1"> | ||
388 | <name>sizeType</name> | ||
389 | <enum>Expanding</enum> | ||
390 | </property> | ||
391 | <property> | ||
392 | <name>sizeHint</name> | ||
393 | <size> | ||
394 | <width>20</width> | ||
395 | <height>20</height> | ||
396 | </size> | ||
397 | </property> | ||
398 | </spacer> | ||
399 | </grid> | 381 | </grid> |
400 | </widget> | 382 | </widget> |
@@ -418,5 +400,5 @@ | |||
418 | <connections> | 400 | <connections> |
419 | <connection> | 401 | <connection> |
420 | <sender>PapChap_RB</sender> | 402 | <sender>Pap_RB</sender> |
421 | <signal>toggled(bool)</signal> | 403 | <signal>toggled(bool)</signal> |
422 | <receiver>GroupBox3</receiver> | 404 | <receiver>GroupBox3</receiver> |
@@ -429,4 +411,16 @@ | |||
429 | <slot>setEnabled(bool)</slot> | 411 | <slot>setEnabled(bool)</slot> |
430 | </connection> | 412 | </connection> |
413 | <connection> | ||
414 | <sender>Chap_RB</sender> | ||
415 | <signal>toggled(bool)</signal> | ||
416 | <receiver>GroupBox3</receiver> | ||
417 | <slot>setEnabled(bool)</slot> | ||
418 | </connection> | ||
419 | <connection> | ||
420 | <sender>EAP_RB</sender> | ||
421 | <signal>toggled(bool)</signal> | ||
422 | <receiver>GroupBox3</receiver> | ||
423 | <slot>setEnabled(bool)</slot> | ||
424 | </connection> | ||
431 | </connections> | 425 | </connections> |
432 | </UI> | 426 | </UI> |
diff --git a/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp index f305cc4..450d560 100644 --- a/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp +++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp | |||
@@ -10,4 +10,11 @@ PPPAuthEdit::PPPAuthEdit( QWidget * Parent ) : PPPAuthGUI( Parent ){ | |||
10 | } | 10 | } |
11 | 11 | ||
12 | bool PPPAuthEdit::PAP_Checked( void ) { | ||
13 | return ( Pap_RB->isChecked() || | ||
14 | Chap_RB->isChecked() || | ||
15 | EAP_RB->isChecked() | ||
16 | ); | ||
17 | } | ||
18 | |||
12 | QString PPPAuthEdit::acceptable( void ) { | 19 | QString PPPAuthEdit::acceptable( void ) { |
13 | if( Login_RB->isChecked() ) { | 20 | if( Login_RB->isChecked() ) { |
@@ -20,5 +27,5 @@ QString PPPAuthEdit::acceptable( void ) { | |||
20 | if( PasswordExpect_LE->text().isEmpty() ) | 27 | if( PasswordExpect_LE->text().isEmpty() ) |
21 | return tr("Password expect missing"); | 28 | return tr("Password expect missing"); |
22 | } else if( PapChap_RB->isChecked() ) { | 29 | } else if( PAP_Checked() ) { |
23 | if( Client_LE->text().isEmpty() ) | 30 | if( Client_LE->text().isEmpty() ) |
24 | return tr("Pap/Chap/EAP client id missing"); | 31 | return tr("Pap/Chap/EAP client id missing"); |
@@ -35,5 +42,5 @@ bool PPPAuthEdit::commit( PPPData_t & D ) { | |||
35 | 42 | ||
36 | if( ( D.Auth.Mode == 0 && ! Login_RB->isChecked() ) || | 43 | if( ( D.Auth.Mode == 0 && ! Login_RB->isChecked() ) || |
37 | ( D.Auth.Mode == 1 && ! PapChap_RB->isChecked() ) || | 44 | ( D.Auth.Mode == 1 && ! PAP_Checked() ) || |
38 | ( D.Auth.Mode == 2 && ! Terminal_RB->isChecked() ) ) { | 45 | ( D.Auth.Mode == 2 && ! Terminal_RB->isChecked() ) ) { |
39 | // mode modifed | 46 | // mode modifed |
@@ -41,6 +48,5 @@ bool PPPAuthEdit::commit( PPPData_t & D ) { | |||
41 | D.Auth.Mode = ( Login_RB->isChecked() ) ? | 48 | D.Auth.Mode = ( Login_RB->isChecked() ) ? |
42 | 0 : | 49 | 0 : |
43 | ( ( PapChap_RB->isChecked() ) ? | 50 | ( PAP_Checked() ) ? 1 : 2; |
44 | 1 : 2 ); | ||
45 | } | 51 | } |
46 | 52 | ||
@@ -50,9 +56,15 @@ bool PPPAuthEdit::commit( PPPData_t & D ) { | |||
50 | TXTM( D.Auth.Password.Expect, PasswordExpect_LE, SM ); | 56 | TXTM( D.Auth.Password.Expect, PasswordExpect_LE, SM ); |
51 | TXTM( D.Auth.Password.Send, PasswordSend_LE, SM ); | 57 | TXTM( D.Auth.Password.Send, PasswordSend_LE, SM ); |
52 | } else if( PapChap_RB->isChecked() ) { | 58 | } else if( PAP_Checked() ) { |
53 | TXTM( D.Auth.Client, Client_LE, SM ); | 59 | TXTM( D.Auth.Client, Client_LE, SM ); |
54 | TXTM( D.Auth.Server, Server_LE, SM ); | 60 | TXTM( D.Auth.Server, Server_LE, SM ); |
55 | TXTM( D.Auth.Secret, Secret_LE, SM ); | 61 | TXTM( D.Auth.Secret, Secret_LE, SM ); |
56 | CIM( D.Auth.PCEMode, AuthMethod_CB, SM ); | 62 | if( Pap_RB->isChecked() ) { |
63 | D.Auth.PCEMode = 0; | ||
64 | } else if( Chap_RB->isChecked() ) { | ||
65 | D.Auth.PCEMode = 1; | ||
66 | } else if( EAP_RB->isChecked() ) { | ||
67 | D.Auth.PCEMode = 2; | ||
68 | } | ||
57 | } | 69 | } |
58 | return SM; | 70 | return SM; |
@@ -63,11 +75,21 @@ void PPPAuthEdit::showData( PPPData_t & D ) { | |||
63 | switch( D.Auth.Mode ) { | 75 | switch( D.Auth.Mode ) { |
64 | case 0 : | 76 | case 0 : |
65 | Login_RB->isChecked(); | 77 | Login_RB->setChecked( TRUE ); |
66 | break; | 78 | break; |
67 | case 1 : | 79 | case 1 : |
68 | PapChap_RB->isChecked(); | 80 | switch( D.Auth.PCEMode ) { |
81 | case 0 : | ||
82 | Pap_RB->setChecked( TRUE ); | ||
83 | break; | ||
84 | case 1 : | ||
85 | Chap_RB->setChecked( TRUE ); | ||
86 | break; | ||
87 | case 2 : | ||
88 | EAP_RB->setChecked( TRUE ); | ||
89 | break; | ||
90 | } | ||
69 | break; | 91 | break; |
70 | case 2 : | 92 | case 2 : |
71 | Terminal_RB->isChecked(); | 93 | Terminal_RB->setChecked( TRUE ); |
72 | break; | 94 | break; |
73 | } | 95 | } |
@@ -81,5 +103,3 @@ void PPPAuthEdit::showData( PPPData_t & D ) { | |||
81 | Server_LE->setText( D.Auth.Server ); | 103 | Server_LE->setText( D.Auth.Server ); |
82 | Secret_LE->setText( D.Auth.Secret ); | 104 | Secret_LE->setText( D.Auth.Secret ); |
83 | |||
84 | AuthMethod_CB->setCurrentItem( D.Auth.PCEMode ); | ||
85 | } | 105 | } |
diff --git a/noncore/settings/networksettings2/ppp/PPPAuthedit.h b/noncore/settings/networksettings2/ppp/PPPAuthedit.h index cbd540e..2392569 100644 --- a/noncore/settings/networksettings2/ppp/PPPAuthedit.h +++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.h | |||
@@ -10,4 +10,6 @@ public : | |||
10 | bool commit( PPPData_t & Data ); | 10 | bool commit( PPPData_t & Data ); |
11 | void showData( PPPData_t & Data ); | 11 | void showData( PPPData_t & Data ); |
12 | bool PAP_Checked( void ); | ||
13 | |||
12 | 14 | ||
13 | private : | 15 | private : |
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp index b7edf87..ff4465c 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp | |||
@@ -1,5 +1,9 @@ | |||
1 | #include <qfile.h> | ||
2 | #include <qtextstream.h> | ||
1 | #include "ppp_NN.h" | 3 | #include "ppp_NN.h" |
2 | #include "ppp_NNI.h" | 4 | #include "ppp_NNI.h" |
3 | 5 | ||
6 | QStringList * PPPNetNode::ProperFiles = 0; | ||
7 | |||
4 | static const char * PPPNeeds[] = | 8 | static const char * PPPNeeds[] = |
5 | { "line", | 9 | { "line", |
@@ -12,4 +16,15 @@ static const char * PPPNeeds[] = | |||
12 | */ | 16 | */ |
13 | PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) { | 17 | PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) { |
18 | |||
19 | // proper files : will leak | ||
20 | ProperFiles =new QStringList; | ||
21 | *ProperFiles << "peers"; | ||
22 | *ProperFiles << "chatscript"; | ||
23 | |||
24 | // system files | ||
25 | NSResources->addSystemFile( | ||
26 | "pap-secrets", "/tmp/pap-secrets", 0 ); | ||
27 | NSResources->addSystemFile( | ||
28 | "chap-secrets", "/tmp/chap-secrets", 0 ); | ||
14 | } | 29 | } |
15 | 30 | ||
@@ -40,13 +55,15 @@ const char * PPPNetNode::provides( void ) { | |||
40 | } | 55 | } |
41 | 56 | ||
42 | bool PPPNetNode::generateProperFilesFor( | 57 | QStringList * PPPNetNode::properFiles( void ) { |
43 | ANetNodeInstance * ) { | 58 | return ProperFiles; |
44 | return 0; | 59 | |
45 | } | 60 | } |
46 | 61 | ||
47 | bool PPPNetNode::generateDeviceDataForCommonFile( | 62 | // need to generate : |
48 | SystemFile & , | 63 | // /etc/ppp/pap-secrets |
49 | long ) { | 64 | // /etc/ppp/pap-secrets |
50 | return 0; | 65 | bool PPPNetNode::hasDataForFile( const QString & S ) { |
66 | return S == "pap-secrets" || | ||
67 | S == "chap-secrets" ; | ||
51 | } | 68 | } |
52 | 69 | ||
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.h b/noncore/settings/networksettings2/ppp/ppp_NN.h index b1483c4..249be5a 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.h +++ b/noncore/settings/networksettings2/ppp/ppp_NN.h | |||
@@ -8,28 +8,23 @@ class APPP; | |||
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 nodeDescription() ; | 20 | virtual bool hasDataForFile( const QString & S ); |
21 | 21 | ||
22 | virtual ANetNodeInstance * createInstance( void ); | 22 | virtual const QString nodeDescription() ; |
23 | virtual ANetNodeInstance * createInstance( void ); | ||
24 | virtual const char ** needs( void ); | ||
25 | virtual const char * provides( void ); | ||
23 | 26 | ||
24 | virtual const char ** needs( void ); | 27 | virtual QString genNic( long NicNr ); |
25 | virtual const char * provides( void ); | 28 | virtual QStringList * properFiles( void ); |
26 | |||
27 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | ||
28 | virtual bool hasDataFor( const QString & ) | ||
29 | { return 0; } | ||
30 | virtual bool generateDeviceDataForCommonFile( | ||
31 | SystemFile & SF, long DevNr ); | ||
32 | |||
33 | virtual QString genNic( long NicNr ); | ||
34 | 29 | ||
35 | private: | 30 | private: |
@@ -37,4 +32,6 @@ private: | |||
37 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 32 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
38 | virtual void saveSpecificAttribute( QTextStream & TS ); | 33 | virtual void saveSpecificAttribute( QTextStream & TS ); |
34 | |||
35 | static QStringList * ProperFiles; | ||
39 | }; | 36 | }; |
40 | 37 | ||
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp index d0fd31c..ba639de 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp | |||
@@ -1,2 +1,4 @@ | |||
1 | #include <qfile.h> | ||
2 | #include <qfileinfo.h> | ||
1 | #include "PPPedit.h" | 3 | #include "PPPedit.h" |
2 | #include "ppp_NNI.h" | 4 | #include "ppp_NNI.h" |
@@ -114,8 +116,106 @@ void APPP::commit( void ) { | |||
114 | } | 116 | } |
115 | 117 | ||
116 | bool APPP::generateDataForCommonFile( | 118 | QFile * APPP::openFile( const QString & ID ) { |
117 | SystemFile & , | 119 | QFile * F = 0; |
118 | long) { | 120 | QString S; |
119 | return 1; | 121 | |
122 | if( ID == "peers" ) { | ||
123 | S = removeSpaces( QString("/tmp/") + connection()->name() ); | ||
124 | |||
125 | F = new QFile( S ); | ||
126 | |||
127 | if( ! F->open( IO_WriteOnly ) ) { | ||
128 | Log(("Cannot open file %s\n", S.latin1() )); | ||
129 | return 0; | ||
130 | } | ||
131 | } else if ( ID == "chatscripts" ) { | ||
132 | S = removeSpaces( QString("/tmp/") + connection()->name() + ".chat" ); | ||
133 | F = new QFile( S ); | ||
134 | |||
135 | if( ! F->open( IO_WriteOnly ) ) { | ||
136 | Log(("Cannot open file %s\n", S.latin1() )); | ||
137 | return 0; | ||
138 | } | ||
139 | } | ||
140 | if( F ) { | ||
141 | Log(("Generate proper file %s = %s\n", | ||
142 | ID.latin1(), F->name().latin1())); | ||
143 | } | ||
144 | return F; | ||
120 | } | 145 | } |
121 | 146 | ||
147 | short APPP::generateFile( const QString & ID, | ||
148 | const QString & Path, | ||
149 | QTextStream & TS, | ||
150 | long DevNr ) { | ||
151 | short rvl, rvd; | ||
152 | |||
153 | rvl = 1; | ||
154 | rvd = 1; | ||
155 | |||
156 | if( ID == "pap-secrets" ) { | ||
157 | Log(("Generate PPP for %s\n", ID.latin1() )); | ||
158 | if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) { | ||
159 | TS << "# secrets for " | ||
160 | << connection()->name().latin1() | ||
161 | << endl; | ||
162 | TS << Data.Auth.Client | ||
163 | << " " | ||
164 | << Data.Auth.Server | ||
165 | << " " | ||
166 | << Data.Auth.Secret | ||
167 | << endl; | ||
168 | rvl = 0; | ||
169 | rvd = connection()->getToplevel()->generateFileEmbedded( | ||
170 | ID, Path, TS, DevNr ); | ||
171 | } | ||
172 | } else if( ID == "chap-secrets" ) { | ||
173 | Log(("Generate PPP for %s\n", ID.latin1() )); | ||
174 | if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) { | ||
175 | // used for both EAP and Chap | ||
176 | TS << "# secrets for " | ||
177 | << connection()->name().latin1() | ||
178 | << endl; | ||
179 | TS << Data.Auth.Client | ||
180 | << " " | ||
181 | << Data.Auth.Server | ||
182 | << " " | ||
183 | << Data.Auth.Secret | ||
184 | << endl; | ||
185 | |||
186 | rvl = 0; | ||
187 | rvd = connection()->getToplevel()->generateFileEmbedded( | ||
188 | ID, Path, TS, DevNr ); | ||
189 | } | ||
190 | } else if ( ID == "peers" ) { | ||
191 | QFileInfo FI(Path); | ||
192 | Log(("Generate PPP for %s\n", ID.latin1() )); | ||
193 | |||
194 | TS << "connect \"/usr/sbin/chat -v -f /etc/ppp/" | ||
195 | << FI.baseName() | ||
196 | << ".chat\"" | ||
197 | << endl; | ||
198 | |||
199 | if( Data.IP.GWIsDefault ) { | ||
200 | TS << "defaultroute" | ||
201 | << endl; | ||
202 | } | ||
203 | |||
204 | TS << "linkname " | ||
205 | << removeSpaces( ID.latin1() ) | ||
206 | << endl; | ||
207 | |||
208 | // insert other data here | ||
209 | rvl = 0; | ||
210 | rvd = connection()->getToplevel()->generateFileEmbedded( | ||
211 | ID, Path, TS, DevNr ); | ||
212 | } else if ( ID == "chatscripts" ) { | ||
213 | Log(("Generate PPP for %s\n", ID.latin1() )); | ||
214 | rvl = 0; | ||
215 | rvd = connection()->getToplevel()->generateFileEmbedded( | ||
216 | ID, Path, TS, DevNr ); | ||
217 | } | ||
218 | |||
219 | return (rvd == 2 || rvl == 2 ) ? 2 : | ||
220 | (rvd == 0 || rvl == 0 ) ? 0 : 1; | ||
221 | } | ||
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.h b/noncore/settings/networksettings2/ppp/ppp_NNI.h index 989c2f0..0bf8fa9 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NNI.h +++ b/noncore/settings/networksettings2/ppp/ppp_NNI.h | |||
@@ -8,4 +8,5 @@ | |||
8 | class PPPNetNode; | 8 | class PPPNetNode; |
9 | class PPPEdit; | 9 | class PPPEdit; |
10 | class QTextStream; | ||
10 | 11 | ||
11 | class APPP : public ANetNodeInstance { | 12 | class APPP : public ANetNodeInstance { |
@@ -15,22 +16,24 @@ public : | |||
15 | APPP( PPPNetNode * PNN ); | 16 | APPP( PPPNetNode * PNN ); |
16 | 17 | ||
17 | QWidget * edit( QWidget * parent ); | ||
18 | QString acceptable( void ); | ||
19 | void commit( void ); | ||
20 | |||
21 | RuntimeInfo * runtime( void ) | 18 | RuntimeInfo * runtime( void ) |
22 | { if( RT == 0 ) | 19 | { if( RT == 0 ) { |
23 | RT = new PPPRun( this, Data ); | 20 | RT = new PPPRun( this, Data ); |
21 | } | ||
24 | return RT->runtimeInfo(); | 22 | return RT->runtimeInfo(); |
25 | } | 23 | } |
26 | 24 | ||
25 | QWidget * edit( QWidget * parent ); | ||
26 | QString acceptable( void ); | ||
27 | void commit( void ); | ||
28 | |||
27 | virtual void * data( void ) | 29 | virtual void * data( void ) |
28 | { return (void *)&Data; } | 30 | { return (void *)&Data; } |
29 | 31 | ||
30 | virtual bool hasDataFor( const QString & ) | 32 | virtual QFile * openFile( const QString & ID ); |
31 | { return 0; } | 33 | short generateFile( const QString & ID, |
34 | const QString & Path, | ||
35 | QTextStream & TS, | ||
36 | long DevNr ); | ||
32 | 37 | ||
33 | virtual bool generateDataForCommonFile( | ||
34 | SystemFile & SF, long DevNr ); | ||
35 | protected : | 38 | protected : |
36 | 39 | ||
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp index 59c34a3..945b48d 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.cpp +++ b/noncore/settings/networksettings2/profile/profile_NN.cpp | |||
@@ -10,5 +10,5 @@ static const char * ProfileNeeds[] = | |||
10 | * Constructor, find all of the possible interfaces | 10 | * Constructor, find all of the possible interfaces |
11 | */ | 11 | */ |
12 | ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular profile")) { | 12 | ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) { |
13 | } | 13 | } |
14 | 14 | ||
@@ -39,15 +39,4 @@ const char * ProfileNetNode::provides( void ) { | |||
39 | } | 39 | } |
40 | 40 | ||
41 | bool ProfileNetNode::generateProperFilesFor( | ||
42 | ANetNodeInstance * ) { | ||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | bool ProfileNetNode::generateDeviceDataForCommonFile( | ||
47 | SystemFile & , | ||
48 | long ) { | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | void ProfileNetNode::setSpecificAttribute( QString & , QString & ) { | 41 | void ProfileNetNode::setSpecificAttribute( QString & , QString & ) { |
53 | } | 42 | } |
diff --git a/noncore/settings/networksettings2/profile/profile_NN.h b/noncore/settings/networksettings2/profile/profile_NN.h index e602bd7..1f1ee2c 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.h +++ b/noncore/settings/networksettings2/profile/profile_NN.h | |||
@@ -19,16 +19,8 @@ public: | |||
19 | 19 | ||
20 | virtual const QString nodeDescription() ; | 20 | virtual const QString nodeDescription() ; |
21 | |||
22 | virtual ANetNodeInstance * createInstance( void ); | 21 | virtual ANetNodeInstance * createInstance( void ); |
23 | |||
24 | virtual const char ** needs( void ); | 22 | virtual const char ** needs( void ); |
25 | virtual const char * provides( void ); | 23 | virtual const char * provides( void ); |
26 | 24 | ||
27 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | ||
28 | virtual bool hasDataFor( const QString & ) | ||
29 | { return 0; } | ||
30 | virtual bool generateDeviceDataForCommonFile( | ||
31 | SystemFile & SF, long DevNr); | ||
32 | |||
33 | private: | 25 | private: |
34 | 26 | ||
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.cpp b/noncore/settings/networksettings2/profile/profile_NNI.cpp index cb52b2a..f0f0b97 100644 --- a/noncore/settings/networksettings2/profile/profile_NNI.cpp +++ b/noncore/settings/networksettings2/profile/profile_NNI.cpp | |||
@@ -51,8 +51,27 @@ void AProfile::commit( void ) { | |||
51 | } | 51 | } |
52 | 52 | ||
53 | bool AProfile::generateDataForCommonFile( | 53 | short AProfile::generateFileEmbedded( const QString & ID, |
54 | SystemFile & , | 54 | const QString & Path, |
55 | long) { | 55 | QTextStream & TS, |
56 | return 1; | 56 | long DevNr ) { |
57 | |||
58 | short rvl, rvd; | ||
59 | |||
60 | rvl = 1; | ||
61 | |||
62 | if( ID == "interfaces" ) { | ||
63 | Log(("Generate Profile for %s\n", ID.latin1() )); | ||
64 | if( Data.TriggerVPN ) { | ||
65 | // this profile triggers VPN -> insert trigger | ||
66 | TS << " up networksettings2 --triggervpn" | ||
67 | << endl; | ||
68 | rvl = 0; | ||
69 | } | ||
70 | } | ||
71 | rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); | ||
72 | return (rvd == 2 || rvl == 2 ) ? 2 : | ||
73 | (rvd == 0 || rvl == 0 ) ? 0 : 1; | ||
57 | } | 74 | } |
58 | 75 | ||
76 | |||
77 | |||
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.h b/noncore/settings/networksettings2/profile/profile_NNI.h index 2c2db7f..957f4af 100644 --- a/noncore/settings/networksettings2/profile/profile_NNI.h +++ b/noncore/settings/networksettings2/profile/profile_NNI.h | |||
@@ -15,24 +15,23 @@ public : | |||
15 | AProfile( ProfileNetNode * PNN ); | 15 | AProfile( ProfileNetNode * PNN ); |
16 | 16 | ||
17 | RuntimeInfo * runtime( void ) | ||
18 | { return | ||
19 | ( RT ) ? RT : ( RT = new ProfileRun( this, Data ) ); | ||
20 | } | ||
21 | |||
17 | QWidget * edit( QWidget * parent ); | 22 | QWidget * edit( QWidget * parent ); |
18 | QString acceptable( void ); | 23 | QString acceptable( void ); |
19 | void commit( void ); | 24 | void commit( void ); |
20 | 25 | ||
21 | const QString & description( void ) | ||
22 | { return Data.Description; } | ||
23 | RuntimeInfo * runtime( void ) | ||
24 | { if( RT == 0 ) | ||
25 | RT = new ProfileRun( this, Data ); | ||
26 | return RT; | ||
27 | } | ||
28 | |||
29 | virtual void * data( void ) | 26 | virtual void * data( void ) |
30 | { return (void *)&Data; } | 27 | { return (void *)&Data; } |
31 | 28 | ||
32 | virtual bool hasDataFor( const QString & ) | 29 | virtual short generateFileEmbedded( const QString & ID, |
33 | { return 0; } | 30 | const QString & Path, |
31 | QTextStream & TS, | ||
32 | long DevNr ); | ||
34 | 33 | ||
35 | virtual bool generateDataForCommonFile( | 34 | const QString & description( void ) |
36 | SystemFile & SF, long DevNr); | 35 | { return Data.Description; } |
37 | 36 | ||
38 | protected : | 37 | protected : |
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp index c10a09c..14c479a 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.cpp +++ b/noncore/settings/networksettings2/usb/usb_NN.cpp | |||
@@ -38,27 +38,4 @@ const char * USBNetNode::provides( void ) { | |||
38 | } | 38 | } |
39 | 39 | ||
40 | bool USBNetNode::generateProperFilesFor( | ||
41 | ANetNodeInstance * ) { | ||
42 | return 0; | ||
43 | } | ||
44 | |||
45 | bool USBNetNode::hasDataFor( const QString & S ) { | ||
46 | return (S== "interfaces"); | ||
47 | } | ||
48 | |||
49 | bool USBNetNode::generateDeviceDataForCommonFile( | ||
50 | SystemFile & S , | ||
51 | long DevNr ) { | ||
52 | QString NIC = genNic( DevNr ); | ||
53 | |||
54 | if( S.name() == "interfaces" ) { | ||
55 | // generate mapping stanza for this interface | ||
56 | S << "# check if " << NIC << " can be brought UP" << endl; | ||
57 | S << "mapping " << NIC << endl; | ||
58 | S << " script networksettings2-request" << endl << endl; | ||
59 | } | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | QString USBNetNode::genNic( long ) { | 40 | QString USBNetNode::genNic( long ) { |
64 | return QString( "usbf" ); | 41 | return QString( "usbf" ); |
diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h index fea89f0..73da15a 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.h +++ b/noncore/settings/networksettings2/usb/usb_NN.h | |||
@@ -19,15 +19,8 @@ public: | |||
19 | 19 | ||
20 | virtual const QString nodeDescription() ; | 20 | virtual const QString nodeDescription() ; |
21 | |||
22 | virtual ANetNodeInstance * createInstance( void ); | 21 | virtual ANetNodeInstance * createInstance( void ); |
23 | |||
24 | virtual const char ** needs( void ); | 22 | virtual const char ** needs( void ); |
25 | virtual const char * provides( void ); | 23 | virtual const char * provides( void ); |
26 | 24 | ||
27 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | ||
28 | virtual bool hasDataFor( const QString & S); | ||
29 | virtual bool generateDeviceDataForCommonFile( | ||
30 | SystemFile & SF, long DevNr ); | ||
31 | |||
32 | virtual QString genNic( long nr ); | 25 | virtual QString genNic( long nr ); |
33 | 26 | ||
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.cpp b/noncore/settings/networksettings2/usb/usb_NNI.cpp index e90204c..50c6e8d 100644 --- a/noncore/settings/networksettings2/usb/usb_NNI.cpp +++ b/noncore/settings/networksettings2/usb/usb_NNI.cpp | |||
@@ -33,20 +33,29 @@ void AUSB::commit( void ) { | |||
33 | } | 33 | } |
34 | 34 | ||
35 | bool AUSB::hasDataFor( const QString & S ) { | 35 | short AUSB::generateFileEmbedded( const QString & ID, |
36 | return (S== "interfaces"); | 36 | const QString & Path, |
37 | } | 37 | QTextStream & TS, |
38 | 38 | long DevNr ) { | |
39 | bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) { | 39 | |
40 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); | 40 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); |
41 | short rvl, rvd; | ||
42 | |||
43 | rvl = 1; | ||
41 | 44 | ||
42 | if( S.name() == "interfaces" ) { | 45 | if( ID == "interfaces" ) { |
46 | Log(("Generate USB for %s\n", ID.latin1() )); | ||
43 | // generate mapping stanza for this interface | 47 | // generate mapping stanza for this interface |
44 | S << " pre-up " | 48 | TS << " pre-up " |
45 | << QPEApplication::qpeDir() | 49 | << QPEApplication::qpeDir() |
46 | << "bin/setmacaddress.sh " | 50 | << "bin/setmacaddress.sh " |
47 | << NIC | 51 | << NIC |
48 | << " || true" | 52 | << " || true" |
49 | << endl; | 53 | << endl; |
54 | rvl = 0; | ||
50 | } | 55 | } |
51 | return 0; | 56 | rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); |
57 | |||
58 | return (rvd == 2 || rvl == 2 ) ? 2 : | ||
59 | (rvd == 0 || rvl == 0 ) ? 0 : 1; | ||
60 | |||
52 | } | 61 | } |
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.h b/noncore/settings/networksettings2/usb/usb_NNI.h index d2ee217..fcdfd91 100644 --- a/noncore/settings/networksettings2/usb/usb_NNI.h +++ b/noncore/settings/networksettings2/usb/usb_NNI.h | |||
@@ -15,20 +15,20 @@ public : | |||
15 | AUSB( USBNetNode * PNN ); | 15 | AUSB( USBNetNode * PNN ); |
16 | 16 | ||
17 | RuntimeInfo * runtime( void ) | ||
18 | { return | ||
19 | ( RT ) ? RT : ( RT = new USBRun( this, Data ) ); | ||
20 | } | ||
21 | |||
17 | QWidget * edit( QWidget * parent ); | 22 | QWidget * edit( QWidget * parent ); |
18 | QString acceptable( void ); | 23 | QString acceptable( void ); |
19 | void commit( void ); | 24 | void commit( void ); |
20 | 25 | ||
21 | RuntimeInfo * runtime( void ) | ||
22 | { if( RT == 0 ) | ||
23 | RT = new USBRun( this, Data ); | ||
24 | return RT; | ||
25 | } | ||
26 | |||
27 | virtual void * data( void ) | 26 | virtual void * data( void ) |
28 | { return (void *)&Data; } | 27 | { return (void *)&Data; } |
29 | 28 | ||
30 | virtual bool hasDataFor( const QString & S); | 29 | virtual short generateFileEmbedded( const QString & ID, |
31 | virtual bool generateDataForCommonFile( | 30 | const QString & Path, |
32 | SystemFile & SF, long DevNr ); | 31 | QTextStream & TS, |
32 | long DevNr ); | ||
33 | 33 | ||
34 | protected : | 34 | protected : |
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp index 6c7b308..9d3b6e7 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp +++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp | |||
@@ -3,6 +3,5 @@ | |||
3 | 3 | ||
4 | static const char * VPNNeeds[] = | 4 | static const char * VPNNeeds[] = |
5 | { "connection", | 5 | { 0 |
6 | 0 | ||
7 | }; | 6 | }; |
8 | 7 | ||
@@ -39,15 +38,4 @@ const char * VPNNetNode::provides( void ) { | |||
39 | } | 38 | } |
40 | 39 | ||
41 | bool VPNNetNode::generateProperFilesFor( | ||
42 | ANetNodeInstance * ) { | ||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | bool VPNNetNode::generateDeviceDataForCommonFile( | ||
47 | SystemFile & , | ||
48 | long ) { | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | void VPNNetNode::setSpecificAttribute( QString & , QString & ) { | 40 | void VPNNetNode::setSpecificAttribute( QString & , QString & ) { |
53 | } | 41 | } |
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.h b/noncore/settings/networksettings2/vpn/vpn_NN.h index 5b6632e..3c7b5e0 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.h +++ b/noncore/settings/networksettings2/vpn/vpn_NN.h | |||
@@ -19,16 +19,8 @@ public: | |||
19 | 19 | ||
20 | virtual const QString nodeDescription() ; | 20 | virtual const QString nodeDescription() ; |
21 | |||
22 | virtual ANetNodeInstance * createInstance( void ); | 21 | virtual ANetNodeInstance * createInstance( void ); |
23 | |||
24 | virtual const char ** needs( void ); | 22 | virtual const char ** needs( void ); |
25 | virtual const char * provides( void ); | 23 | virtual const char * provides( void ); |
26 | 24 | ||
27 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | ||
28 | virtual bool hasDataFor( const QString & ) | ||
29 | { return 0; } | ||
30 | virtual bool generateDeviceDataForCommonFile( | ||
31 | SystemFile & SF, long DevNr ); | ||
32 | |||
33 | private: | 25 | private: |
34 | 26 | ||
diff --git a/noncore/settings/networksettings2/vpn/vpn_NNI.cpp b/noncore/settings/networksettings2/vpn/vpn_NNI.cpp index ee999e8..6c20aeb 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NNI.cpp +++ b/noncore/settings/networksettings2/vpn/vpn_NNI.cpp | |||
@@ -29,8 +29,2 @@ void AVPN::commit( void ) { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | bool AVPN::generateDataForCommonFile( | ||
32 | SystemFile & , | ||
33 | long) { | ||
34 | return 1; | ||
35 | } | ||
36 | |||
diff --git a/noncore/settings/networksettings2/vpn/vpn_NNI.h b/noncore/settings/networksettings2/vpn/vpn_NNI.h index c3eb016..aee5891 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NNI.h +++ b/noncore/settings/networksettings2/vpn/vpn_NNI.h | |||
@@ -15,21 +15,17 @@ public : | |||
15 | AVPN( VPNNetNode * PNN ); | 15 | AVPN( VPNNetNode * PNN ); |
16 | 16 | ||
17 | RuntimeInfo * runtime( void ) | ||
18 | { return | ||
19 | ( RT ) ? RT : ( RT = new VPNRun( this, Data ) ); | ||
20 | } | ||
21 | |||
17 | QWidget * edit( QWidget * parent ); | 22 | QWidget * edit( QWidget * parent ); |
18 | QString acceptable( void ); | 23 | QString acceptable( void ); |
19 | void commit( void ); | 24 | void commit( void ); |
20 | 25 | ||
21 | RuntimeInfo * runtime( void ) | ||
22 | { if( RT == 0 ) | ||
23 | RT = new VPNRun( this, Data ); | ||
24 | return RT; | ||
25 | } | ||
26 | |||
27 | virtual void * data( void ) | 26 | virtual void * data( void ) |
28 | { return (void *)&Data; } | 27 | { return (void *)&Data; } |
29 | 28 | ||
30 | virtual bool hasDataFor( const QString & ) | 29 | |
31 | { return 0; } | ||
32 | virtual bool generateDataForCommonFile( | ||
33 | SystemFile & SF, long DevNr ); | ||
34 | protected : | 30 | protected : |
35 | 31 | ||
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp index ce8a734..e4c3f60 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp | |||
@@ -39,27 +39,4 @@ const char * WLanNetNode::provides( void ) { | |||
39 | } | 39 | } |
40 | 40 | ||
41 | bool WLanNetNode::generateProperFilesFor( | ||
42 | ANetNodeInstance * ) { | ||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | bool WLanNetNode::hasDataFor( const QString & S ) { | ||
47 | return S == "interfaces"; | ||
48 | } | ||
49 | |||
50 | bool WLanNetNode::generateDeviceDataForCommonFile( | ||
51 | SystemFile & S, | ||
52 | long DevNr ) { | ||
53 | QString NIC = genNic( DevNr ); | ||
54 | |||
55 | if( S.name() == "interfaces" ) { | ||
56 | // generate mapping stanza for this interface | ||
57 | S << "# check if " << NIC << " can be brought UP" << endl; | ||
58 | S << "mapping " << NIC << endl; | ||
59 | S << " script networksettings2-request" << endl << endl; | ||
60 | } | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | QString WLanNetNode::genNic( long nr ) { | 41 | QString WLanNetNode::genNic( long nr ) { |
65 | QString S; | 42 | QString S; |
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.h b/noncore/settings/networksettings2/wlan/wlan_NN.h index b5ff3fd..c13c05c 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.h +++ b/noncore/settings/networksettings2/wlan/wlan_NN.h | |||
@@ -19,19 +19,10 @@ public: | |||
19 | 19 | ||
20 | virtual const QString nodeDescription() ; | 20 | virtual const QString nodeDescription() ; |
21 | |||
22 | virtual ANetNodeInstance * createInstance( void ); | 21 | virtual ANetNodeInstance * createInstance( void ); |
23 | |||
24 | virtual const char ** needs( void ); | 22 | virtual const char ** needs( void ); |
25 | virtual const char * provides( void ); | 23 | virtual const char * provides( void ); |
26 | 24 | ||
27 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | ||
28 | |||
29 | virtual bool hasDataFor( const QString & S ); | ||
30 | virtual bool generateDeviceDataForCommonFile( | ||
31 | SystemFile & SF, long DevNr ); | ||
32 | |||
33 | virtual long instanceCount( void ) | 25 | virtual long instanceCount( void ) |
34 | { return InstanceCount; } | 26 | { return InstanceCount; } |
35 | |||
36 | virtual QString genNic( long ); | 27 | virtual QString genNic( long ); |
37 | 28 | ||
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp index 61969f2..0e4fc4c 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp | |||
@@ -80,61 +80,72 @@ void AWLan::commit( void ) { | |||
80 | } | 80 | } |
81 | 81 | ||
82 | bool AWLan::generateDataForCommonFile( | 82 | short AWLan::generateFileEmbedded( const QString & ID, |
83 | SystemFile & S, | 83 | const QString & Path, |
84 | long ) { | 84 | QTextStream & TS, |
85 | long DevNr ) { | ||
85 | 86 | ||
86 | S << " wireless_essid \"" | 87 | short rvl, rvd; |
87 | << Data.ESSID | ||
88 | << "\"" | ||
89 | << endl; | ||
90 | 88 | ||
91 | if( ! Data.NodeName.isEmpty() ) { | 89 | rvl = 1; |
92 | if( Data.NodeName == tr("<UseHostName>") ) { | 90 | |
93 | char Buf[100]; | 91 | if( ID == "interfaces" ) { |
94 | if( gethostname(Buf, sizeof(Buf) ) == 0 ) { | 92 | Log(("Generate WLanNNI for %s\n", ID.latin1() )); |
95 | Buf[99] = '\0'; // just to make sure | 93 | TS << " wireless_essid \"" |
96 | S << " wireless_nick " | 94 | << Data.ESSID |
97 | << Buf | 95 | << "\"" |
98 | << endl; | 96 | << endl; |
97 | |||
98 | if( ! Data.NodeName.isEmpty() ) { | ||
99 | if( Data.NodeName == tr("<UseHostName>") ) { | ||
100 | char Buf[100]; | ||
101 | if( gethostname(Buf, sizeof(Buf) ) == 0 ) { | ||
102 | Buf[99] = '\0'; // just to make sure | ||
103 | TS << " wireless_nick " | ||
104 | << Buf | ||
105 | << endl; | ||
106 | } | ||
107 | } else { | ||
108 | TS << " wireless_nick \"" | ||
109 | << Data.NodeName | ||
110 | << "\"" | ||
111 | << endl; | ||
99 | } | 112 | } |
100 | } else { | ||
101 | S << " wireless_nick \"" | ||
102 | << Data.NodeName | ||
103 | << "\"" | ||
104 | << endl; | ||
105 | } | 113 | } |
106 | } | ||
107 | 114 | ||
108 | char * M; | 115 | char * M = "Auto"; |
109 | switch ( Data.Mode ) { | 116 | switch ( Data.Mode ) { |
110 | case 0 : | 117 | case 0 : |
111 | M = "Auto"; | 118 | break; |
112 | break; | 119 | case 1 : |
113 | case 1 : | 120 | M = "Managed"; |
114 | M = "Managed"; | 121 | break; |
115 | break; | 122 | case 2 : |
116 | case 2 : | 123 | M = "Ad-Hoc"; |
117 | M = "Ad-Hoc"; | 124 | break; |
118 | break; | 125 | } |
119 | } | ||
120 | 126 | ||
121 | S << " wireless_mode " | 127 | TS << " wireless_mode " |
122 | << M | 128 | << M |
123 | << endl; | 129 | << endl; |
124 | if( Data.Encrypted ) { | 130 | if( Data.Encrypted ) { |
125 | for( int i = 0; i < 4; i ++ ) { | 131 | for( int i = 0; i < 4; i ++ ) { |
126 | if( ! Data.Key[i].isEmpty() ) { | 132 | if( ! Data.Key[i].isEmpty() ) { |
127 | S << " wireless_key" | 133 | TS << " wireless_key" |
128 | << i | 134 | << i |
129 | << " " | 135 | << " " |
130 | << Data.Key[i] | 136 | << Data.Key[i] |
131 | << endl; | 137 | << endl; |
138 | } | ||
132 | } | 139 | } |
140 | TS << " wireless_keymode " | ||
141 | << ((Data.AcceptNonEncrypted) ? "open" : "restricted") | ||
142 | << endl; | ||
133 | } | 143 | } |
134 | S << " wireless_keymode " | 144 | rvl = 0; |
135 | << ((Data.AcceptNonEncrypted) ? "open" : "restricted") | ||
136 | << endl; | ||
137 | } | 145 | } |
138 | return 0; | 146 | rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr); |
147 | |||
148 | return (rvd == 2 || rvl == 2 ) ? 2 : | ||
149 | (rvd == 0 || rvl == 0 ) ? 0 : 1; | ||
139 | } | 150 | } |
140 | 151 | ||
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.h b/noncore/settings/networksettings2/wlan/wlan_NNI.h index 2211c47..a9be65f 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NNI.h +++ b/noncore/settings/networksettings2/wlan/wlan_NNI.h | |||
@@ -15,21 +15,21 @@ public : | |||
15 | AWLan( WLanNetNode * PNN ); | 15 | AWLan( WLanNetNode * PNN ); |
16 | 16 | ||
17 | RuntimeInfo * runtime( void ) | ||
18 | { return | ||
19 | ( RT ) ? RT : ( RT = new WLanRun( this, Data ) ); | ||
20 | } | ||
21 | |||
17 | QWidget * edit( QWidget * parent ); | 22 | QWidget * edit( QWidget * parent ); |
18 | QString acceptable( void ); | 23 | QString acceptable( void ); |
19 | void commit( void ); | 24 | void commit( void ); |
20 | 25 | ||
21 | RuntimeInfo * runtime( void ) | ||
22 | { if( RT == 0 ) | ||
23 | RT = new WLanRun( this, Data ); | ||
24 | return RT; | ||
25 | } | ||
26 | |||
27 | virtual void * data( void ) | 26 | virtual void * data( void ) |
28 | { return (void *)&Data; } | 27 | { return (void *)&Data; } |
29 | 28 | ||
30 | virtual bool hasDataFor( const QString & ) | 29 | virtual short generateFileEmbedded( const QString & ID, |
31 | { return 1; } | 30 | const QString & Path, |
32 | virtual bool generateDataForCommonFile( | 31 | QTextStream & TS, |
33 | SystemFile & SF, long DevNr ); | 32 | long DevNr ); |
33 | |||
34 | protected : | 34 | protected : |
35 | 35 | ||