summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp8
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h14
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp8
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h14
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h3
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp38
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth_NN.h23
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.cpp11
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.h8
-rw-r--r--noncore/settings/networksettings2/cable/cable_NNI.cpp30
-rw-r--r--noncore/settings/networksettings2/cable/cable_NNI.h20
-rw-r--r--noncore/settings/networksettings2/cable/cablerun.cpp6
-rw-r--r--noncore/settings/networksettings2/cable/cablerun.h8
-rw-r--r--noncore/settings/networksettings2/irda/irda_NN.cpp11
-rw-r--r--noncore/settings/networksettings2/irda/irda_NN.h8
-rw-r--r--noncore/settings/networksettings2/irda/irda_NNI.cpp6
-rw-r--r--noncore/settings/networksettings2/irda/irda_NNI.h16
-rw-r--r--noncore/settings/networksettings2/irda/irdarun.h3
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.cpp23
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.h17
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NNI.cpp6
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NNI.h15
-rw-r--r--noncore/settings/networksettings2/main.cpp16
-rw-r--r--noncore/settings/networksettings2/modem/modem_NN.cpp11
-rw-r--r--noncore/settings/networksettings2/modem/modem_NN.h8
-rw-r--r--noncore/settings/networksettings2/modem/modem_NNI.cpp6
-rw-r--r--noncore/settings/networksettings2/modem/modem_NNI.h16
-rw-r--r--noncore/settings/networksettings2/modem/modemrun.h3
-rw-r--r--noncore/settings/networksettings2/network/network_NN.cpp42
-rw-r--r--noncore/settings/networksettings2/network/network_NN.h15
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.cpp68
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.h19
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp42
-rw-r--r--noncore/settings/networksettings2/networksettings.h3
-rw-r--r--noncore/settings/networksettings2/networksettings.pro3
-rw-r--r--noncore/settings/networksettings2/networksettings2/Utils.h1
-rw-r--r--noncore/settings/networksettings2/networksettings2/asline.h2
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.cpp21
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h268
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp13
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.h5
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp14
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.cpp30
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.h11
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp416
-rw-r--r--noncore/settings/networksettings2/nsdata.h11
-rw-r--r--noncore/settings/networksettings2/ppp/PPPAuthGUI.ui150
-rw-r--r--noncore/settings/networksettings2/ppp/PPPAuthedit.cpp42
-rw-r--r--noncore/settings/networksettings2/ppp/PPPAuthedit.h2
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.cpp31
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.h13
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.cpp108
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.h21
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.cpp13
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.h8
-rw-r--r--noncore/settings/networksettings2/profile/profile_NNI.cpp27
-rw-r--r--noncore/settings/networksettings2/profile/profile_NNI.h23
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.cpp23
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.h7
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.cpp23
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.h18
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.cpp14
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.h8
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NNI.cpp6
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NNI.h16
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.cpp23
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.h9
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NNI.cpp35
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NNI.h20
69 files changed, 1049 insertions, 931 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
@@ -40,11 +40,3 @@ void ABluetoothBNEP::commit( void ) {
40 if( GUI && GUI->commit( Data ) ) 40 if( GUI && GUI->commit( Data ) )
41 setModified( 1 ); 41 setModified( 1 );
42} 42}
43
44bool ABluetoothBNEP::hasDataFor( const QString & ) {
45 return 0;
46}
47
48bool 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
@@ -14,22 +14,18 @@ public :
14 14
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
33protected : 29protected :
34 30
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 31 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -28,11 +28,3 @@ void ABluetoothRFCOMM::commit( void ) {
28 if( GUI->commit( Data ) ) 28 if( GUI->commit( Data ) )
29 setModified( 1 ); 29 setModified( 1 );
30} 30}
31
32bool ABluetoothRFCOMM::hasDataFor( const QString & ) {
33 return 0;
34}
35
36bool 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
@@ -14,22 +14,18 @@ public :
14 14
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
33protected : 29protected :
34 30
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 31 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -12,6 +12,9 @@ public :
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 { return QString( "/dev/rfcomm..." ); }
17
15protected : 18protected :
16 19
17 void detectState( NodeCollection * ) 20 void detectState( NodeCollection * )
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
@@ -46,29 +46,6 @@ const char * BluetoothBNEPNetNode::provides( void ) {
46 return "device"; 46 return "device";
47} 47}
48 48
49bool BluetoothBNEPNetNode::generateProperFilesFor(
50 ANetNodeInstance * ) {
51 return 0;
52}
53
54bool BluetoothBNEPNetNode::hasDataFor( const QString & S ) {
55 return S == "interfaces";
56}
57
58bool 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
72QString BluetoothBNEPNetNode::genNic( long nr ) { 49QString BluetoothBNEPNetNode::genNic( long nr ) {
73 QString S; 50 QString S;
74 return S.sprintf( "bnep%ld", nr ); 51 return S.sprintf( "bnep%ld", nr );
@@ -124,21 +101,6 @@ const char * BluetoothRFCOMMNetNode::provides( void ) {
124 return "line"; 101 return "line";
125} 102}
126 103
127bool BluetoothRFCOMMNetNode::generateProperFilesFor(
128 ANetNodeInstance * ) {
129 return 0;
130}
131
132bool BluetoothRFCOMMNetNode::hasDataFor( const QString & ) {
133 return 0;
134}
135
136bool BluetoothRFCOMMNetNode::generateDeviceDataForCommonFile(
137 SystemFile & ,
138 long ) {
139 return 0;
140}
141
142void BluetoothRFCOMMNetNode::setSpecificAttribute( QString &, QString & ) { 104void BluetoothRFCOMMNetNode::setSpecificAttribute( QString &, QString & ) {
143} 105}
144 106
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
@@ -14,24 +14,16 @@ public:
14 BluetoothBNEPNetNode(); 14 BluetoothBNEPNetNode();
15 virtual ~BluetoothBNEPNetNode(); 15 virtual ~BluetoothBNEPNetNode();
16 16
17 virtual QString genNic( long );
18 virtual long instanceCount( void )
19 { return InstanceCount; }
17 virtual const QString pixmapName() 20 virtual const QString pixmapName()
18 { return "Devices/bluetooth"; } 21 { return "Devices/bluetooth"; }
19 22
20 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
21
22 virtual ANetNodeInstance * createInstance( void ); 24 virtual ANetNodeInstance * createInstance( void );
23
24 virtual const char ** needs( void );
25 virtual const char * provides( void ); 25 virtual const char * provides( void );
26 26 virtual const char ** needs( void );
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
36private: 28private:
37 29
@@ -56,17 +48,10 @@ public:
56 { return "Devices/bluetooth"; } 48 { return "Devices/bluetooth"; }
57 49
58 virtual const QString nodeDescription() ; 50 virtual const QString nodeDescription() ;
59
60 virtual ANetNodeInstance * createInstance( void ); 51 virtual ANetNodeInstance * createInstance( void );
61
62 virtual const char ** needs( void ); 52 virtual const char ** needs( void );
63 virtual const char * provides( void ); 53 virtual const char * provides( void );
64 54
65 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
66 virtual bool hasDataFor( const QString & S );
67 virtual bool generateDeviceDataForCommonFile(
68 SystemFile & , long );
69
70private: 55private:
71 56
72 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 57 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -36,17 +36,6 @@ const char * CableNetNode::provides( void ) {
36 return "line"; 36 return "line";
37} 37}
38 38
39bool CableNetNode::generateProperFilesFor(
40 ANetNodeInstance * ) {
41 return 0;
42}
43
44bool CableNetNode::generateDeviceDataForCommonFile(
45 SystemFile & ,
46 long ) {
47 return 0;
48}
49
50void CableNetNode::setSpecificAttribute( QString & , QString & ) { 39void CableNetNode::setSpecificAttribute( QString & , QString & ) {
51} 40}
52 41
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
@@ -18,18 +18,10 @@ public:
18 { return "Devices/cable"; } 18 { return "Devices/cable"; }
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
33private: 25private:
34 26
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -49,6 +49,29 @@ void ACable::saveSpecificAttribute( QTextStream & TS ) {
49 ((Data.SoftwareControl) ? "yes" : "no") << endl; 49 ((Data.SoftwareControl) ? "yes" : "no") << endl;
50} 50}
51 51
52short 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
52QWidget * ACable::edit( QWidget * parent ) { 75QWidget * ACable::edit( QWidget * parent ) {
53 GUI = new CableEdit( parent ); 76 GUI = new CableEdit( parent );
54 GUI->showData( Data ); 77 GUI->showData( Data );
@@ -64,10 +87,3 @@ void ACable::commit( void ) {
64 setModified( 1 ); 87 setModified( 1 );
65 } 88 }
66} 89}
67
68bool 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
@@ -14,24 +14,22 @@ public :
14 14
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
35protected : 33protected :
36 34
37 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 35 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -4,7 +4,7 @@
4 4
5void CableRun::detectState( NodeCollection * NC ) { 5void 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 ) {
10 NC->setCurrentState( Unavailable ); 10 NC->setCurrentState( Unavailable );
@@ -24,3 +24,7 @@ bool CableRun::setState( NodeCollection * NC, Action_t A, bool ) {
24bool CableRun::canSetState( State_t , Action_t ) { 24bool CableRun::canSetState( State_t , Action_t ) {
25 return 1; 25 return 1;
26} 26}
27
28QString 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
@@ -6,12 +6,14 @@ class CableRun : public AsLine {
6public : 6public :
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
15protected : 17protected :
16 18
17 void detectState( NodeCollection * NC ); 19 void detectState( NodeCollection * NC );
@@ -20,5 +22,5 @@ protected :
20 22
21private : 23private :
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
@@ -36,17 +36,6 @@ const char * IRDANetNode::provides( void ) {
36 return "line"; 36 return "line";
37} 37}
38 38
39bool IRDANetNode::generateProperFilesFor(
40 ANetNodeInstance * ) {
41 return 0;
42}
43
44bool IRDANetNode::generateDeviceDataForCommonFile(
45 SystemFile & ,
46 long ) {
47 return 0;
48}
49
50void IRDANetNode::setSpecificAttribute( QString & , QString & ) { 39void IRDANetNode::setSpecificAttribute( QString & , QString & ) {
51} 40}
52 41
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
@@ -18,18 +18,10 @@ public:
18 { return "Devices/irda"; } 18 { return "Devices/irda"; }
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
33private: 25private:
34 26
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -29,9 +29,3 @@ void AIRDA::commit( void ) {
29 setModified( 1 ); 29 setModified( 1 );
30} 30}
31 31
32bool 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
@@ -14,24 +14,18 @@ public :
14 14
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
35protected : 29protected :
36 30
37 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 31 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -12,6 +12,9 @@ public :
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 { return QString( "/dev/irda" ); }
17
15protected : 18protected :
16 19
17 void detectState( NodeCollection * ) 20 void detectState( NodeCollection * )
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
@@ -38,29 +38,6 @@ const char * LanCardNetNode::provides( void ) {
38 return "device"; 38 return "device";
39} 39}
40 40
41bool LanCardNetNode::generateProperFilesFor(
42 ANetNodeInstance * ) {
43 return 0;
44}
45
46bool LanCardNetNode::hasDataFor( const QString & S ) {
47 return S == "interfaces";
48}
49
50bool 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
64QString LanCardNetNode::genNic( long nr ) { 41QString LanCardNetNode::genNic( long nr ) {
65 QString S; 42 QString S;
66 return S.sprintf( "eth%ld", nr ); 43 return S.sprintf( "eth%ld", nr );
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
@@ -18,23 +18,16 @@ public:
18 virtual const QString pixmapName() 18 virtual const QString pixmapName()
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
40private: 33private:
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
@@ -43,9 +43,3 @@ void ALanCard::commit( void ) {
43 setModified( 1 ); 43 setModified( 1 );
44} 44}
45 45
46bool 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
@@ -14,23 +14,18 @@ public :
14 14
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 );
34protected : 29protected :
35 30
36 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 31 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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,5 +1,6 @@
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
5#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
@@ -21,6 +22,8 @@ OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> )
21#define ACT_REGEN 2 22#define ACT_REGEN 2
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
25int main( int argc, char * argv[] ) { 28int main( int argc, char * argv[] ) {
26 int rv = 0; 29 int rv = 0;
@@ -44,6 +47,9 @@ int main( int argc, char * argv[] ) {
44 } else if( strcmp( argv[i], "--prompt" ) == 0 ) { 47 } else if( strcmp( argv[i], "--prompt" ) == 0 ) {
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 ) {
49 memmove( argv+i, argv+i+rmv, 55 memmove( argv+i, argv+i+rmv,
@@ -78,10 +84,8 @@ int main( int argc, char * argv[] ) {
78 switch( Action ) { 84 switch( Action ) {
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" );
87 char * MyArgv[4]; 91 char * MyArgv[4];
@@ -97,14 +101,12 @@ int main( int argc, char * argv[] ) {
97 break; 101 break;
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;
103 } 106 }
104 break; 107 break;
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() );
110 } else { 112 } else {
@@ -112,9 +114,13 @@ int main( int argc, char * argv[] ) {
112 } 114 }
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();
120#ifdef _WS_QWS_ 126#ifdef _WS_QWS_
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
@@ -37,17 +37,6 @@ const char * ModemNetNode::provides( void ) {
37 return "line"; 37 return "line";
38} 38}
39 39
40bool ModemNetNode::generateProperFilesFor(
41 ANetNodeInstance * ) {
42 return 0;
43}
44
45bool ModemNetNode::generateDeviceDataForCommonFile(
46 SystemFile & ,
47 long ) {
48 return 0;
49}
50
51void ModemNetNode::setSpecificAttribute( QString & , QString & ) { 40void ModemNetNode::setSpecificAttribute( QString & , QString & ) {
52} 41}
53 42
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
@@ -18,18 +18,10 @@ public:
18 { return "Devices/modem"; } 18 { return "Devices/modem"; }
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
33private: 25private:
34 26
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -29,9 +29,3 @@ void AModem::commit( void ) {
29 setModified( 1 ); 29 setModified( 1 );
30} 30}
31 31
32bool 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
@@ -14,24 +14,18 @@ public :
14 14
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
35protected : 29protected :
36 30
37 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 31 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -12,6 +12,9 @@ public :
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 { return QString("/dev/modem"); }
17
15protected : 18protected :
16 19
17 void detectState( NodeCollection * ) 20 void detectState( NodeCollection * )
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,3 +1,4 @@
1#include <asdevice.h>
1#include "network_NN.h" 2#include "network_NN.h"
2#include "network_NNI.h" 3#include "network_NNI.h"
3 4
@@ -30,23 +31,42 @@ ANetNodeInstance * NetworkNetNode::createInstance( void ) {
30 return new ANetwork( this ); 31 return new ANetwork( this );
31} 32}
32 33
33const char ** NetworkNetNode::needs( void ) { 34bool NetworkNetNode::hasDataForFile( const QString & S ) {
34 return NetworkNeeds; 35 return S == "interfaces";
35} 36}
36 37
37const char * NetworkNetNode::provides( void ) { 38short NetworkNetNode::generateFile( const QString & ID,
38 return "connection"; 39 const QString & ,
39} 40 QTextStream & TS,
41 ANetNodeInstance * NNI,
42 long DevNr ) {
43
44 QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
40 45
41bool NetworkNetNode::generateProperFilesFor( 46 if( ID == "interfaces" ) {
42 ANetNodeInstance * ) { 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;
43 return 0; 59 return 0;
44} 60}
61 return 1;
62}
45 63
46bool NetworkNetNode::generateDeviceDataForCommonFile( 64const char ** NetworkNetNode::needs( void ) {
47 SystemFile & , 65 return NetworkNeeds;
48 long ) { 66}
49 return 0; 67
68const char * NetworkNetNode::provides( void ) {
69 return "connection";
50} 70}
51 71
52void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { 72void NetworkNetNode::setSpecificAttribute( QString & , QString & ) {
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
@@ -14,22 +14,21 @@ public:
14 NetworkNetNode(); 14 NetworkNetNode();
15 virtual ~NetworkNetNode(); 15 virtual ~NetworkNetNode();
16 16
17 virtual bool hasDataForFile( const QString & S );
18
19 virtual short generateFile( const QString & ID,
20 const QString & Path,
21 QTextStream & TS,
22 ANetNodeInstance * NNI,
23 long DevNr );
17 virtual const QString pixmapName() 24 virtual const QString pixmapName()
18 { return "Devices/tcpip"; } 25 { return "Devices/tcpip"; }
19 26
20 virtual const QString nodeDescription() ; 27 virtual const QString nodeDescription() ;
21
22 virtual ANetNodeInstance * createInstance( void ); 28 virtual ANetNodeInstance * createInstance( void );
23
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 31
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
33private: 32private:
34 33
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 34 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -99,57 +99,71 @@ void ANetwork::commit( void ) {
99 setModified( 1 ); 99 setModified( 1 );
100} 100}
101 101
102bool ANetwork::hasDataFor( const QString & S ) { 102bool ANetwork::hasDataForFile( const QString & S ) {
103 return S == "interfaces"; 103 return S == "interfaces";
104} 104}
105 105
106bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { 106short 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
155 { QString NW; 169 { QString NW;
@@ -161,29 +175,45 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) {
161 arg( ipal[1].toShort() & nmal[1].toShort() ). 175 arg( ipal[1].toShort() & nmal[1].toShort() ).
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 }
167 for ( QStringList::Iterator it = Data.PreUp_SL.begin(); 183 for ( QStringList::Iterator it = Data.PreUp_SL.begin();
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
@@ -15,22 +15,23 @@ public :
15 15
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
35protected : 36protected :
36 37
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,5 +1,6 @@
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>
5#include <qlistbox.h> 6#include <qlistbox.h>
@@ -12,6 +13,7 @@
12#include <qtimer.h> 13#include <qtimer.h>
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>
17#include "networksettings.h" 19#include "networksettings.h"
@@ -41,6 +43,13 @@ NetworkSettings::NetworkSettings( QWidget *parent,
41 43
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;
46 // for all connections 55 // for all connections
@@ -78,15 +87,7 @@ NetworkSettings::NetworkSettings( QWidget *parent,
78NetworkSettings::~NetworkSettings() { 87NetworkSettings::~NetworkSettings() {
79 QString S; 88 QString S;
80 89
81 S = NSD.generateSettings(); 90 if( isModified() ) {
82 if( ! S.isEmpty() ) {
83 QMessageBox::warning(
84 0,
85 tr( "In System Config" ),
86 S
87 );
88 }
89
90 S = NSD.saveSettings(); 91 S = NSD.saveSettings();
91 if( ! S.isEmpty() ) { 92 if( ! S.isEmpty() ) {
92 // problem saving 93 // problem saving
@@ -94,6 +95,10 @@ NetworkSettings::~NetworkSettings() {
94 0, 95 0,
95 tr( "Saving setup" ), S ); 96 tr( "Saving setup" ), S );
96 } 97 }
98
99 SLOT_GenerateConfig();
100 }
101
97} 102}
98 103
99void NetworkSettings::SLOT_CmdMessage( const QString & S ) { 104void NetworkSettings::SLOT_CmdMessage( const QString & S ) {
@@ -145,9 +150,6 @@ void NetworkSettings::SLOT_RefreshStates( void ) {
145 */ 150 */
146} 151}
147 152
148void NetworkSettings::SLOT_NoLongerBusy( void ) {
149 NSResources->busy( FALSE );
150}
151void NetworkSettings::SLOT_AddNode( void ) { 153void NetworkSettings::SLOT_AddNode( void ) {
152 SLOT_EditNode( 0 ); 154 SLOT_EditNode( 0 );
153} 155}
@@ -166,12 +168,13 @@ void NetworkSettings::SLOT_DeleteNode( void ) {
166 NSResources->removeConnection( LBI->text() ); 168 NSResources->removeConnection( LBI->text() );
167 delete LBI; 169 delete LBI;
168 setModified( 1 ); 170 setModified( 1 );
169 NSD.forceGeneration(1);
170 } 171 }
171} 172}
172 173
173void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { 174void 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
177 if( LBI ) { 180 if( LBI ) {
@@ -186,8 +189,7 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
186 EC.showMaximized(); 189 EC.showMaximized();
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 ) {
193 if( EC.exec() == QDialog::Accepted ) { 195 if( EC.exec() == QDialog::Accepted ) {
@@ -319,15 +321,7 @@ void NetworkSettings::updateProfileState( QListBoxItem * LBI ) {
319} 321}
320 322
321void NetworkSettings::SLOT_GenerateConfig( void ) { 323void 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
333void NetworkSettings::SLOT_Enable( void ) { 327void NetworkSettings::SLOT_Enable( void ) {
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
@@ -6,6 +6,7 @@ class ANetNode;
6class ANetNodeInstance; 6class ANetNodeInstance;
7class QTimer; 7class QTimer;
8class QListBoxItem; 8class QListBoxItem;
9class QEvent;
9 10
10class NetworkSettings : public NetworkSettingsGUI { 11class NetworkSettings : public NetworkSettingsGUI {
11 12
@@ -28,7 +29,6 @@ public :
28 29
29public slots : 30public 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 );
34 void SLOT_ShowNode( QListBoxItem * ); 34 void SLOT_ShowNode( QListBoxItem * );
@@ -50,5 +50,4 @@ private :
50 void updateProfileState( QListBoxItem * it ); 50 void updateProfileState( QListBoxItem * it );
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
@@ -3,17 +3,20 @@ CONFIG = qt warn_on debug
3#CONFIG = qt warn_on release 3#CONFIG = qt warn_on release
4HEADERS = networksettings.h \ 4HEADERS = networksettings.h \
5 activateprofile.h \ 5 activateprofile.h \
6 activatevpn.h \
6 editconnection.h 7 editconnection.h
7SOURCES = main.cpp \ 8SOURCES = main.cpp \
8 networksettings.cpp \ 9 networksettings.cpp \
9 nsdata.cpp \ 10 nsdata.cpp \
10 activateprofile.cpp \ 11 activateprofile.cpp \
12 activatevpn.cpp \
11 editconnection.cpp 13 editconnection.cpp
12INCLUDEPATH += $(OPIEDIR)/include networksettings2/ 14INCLUDEPATH += $(OPIEDIR)/include networksettings2/
13DEPENDPATH += $(OPIEDIR)/include networksettings2/ 15DEPENDPATH += $(OPIEDIR)/include networksettings2/
14LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings2 -lnetworksettings2 -lopiecore2 16LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings2 -lnetworksettings2 -lopiecore2
15INTERFACES = networksettingsGUI.ui \ 17INTERFACES = networksettingsGUI.ui \
16 editconnectionGUI.ui \ 18 editconnectionGUI.ui \
19 activatevpnGUI.ui \
17 activateprofileGUI.ui 20 activateprofileGUI.ui
18TARGET = $(OPIEDIR)/bin/networksettings2 21TARGET = $(OPIEDIR)/bin/networksettings2
19 22
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
@@ -4,5 +4,6 @@
4#define Log(x) VLog x 4#define Log(x) VLog x
5extern void VLog( char * Format, ... ); 5extern void VLog( char * Format, ... );
6extern void LogClose( void ); 6extern void LogClose( void );
7extern 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
@@ -13,6 +13,8 @@ public :
13 RuntimeInfo( NNI ) { 13 RuntimeInfo( NNI ) {
14 } 14 }
15 15
16 virtual QString deviceFile( void ) = 0;
17
16}; 18};
17 19
18#endif 20#endif
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
@@ -144,7 +144,7 @@ NodeCollection::NodeCollection( QTextStream & TS ) :
144 if( A == "name" ) { 144 if( A == "name" ) {
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" ) {
150 ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); 150 ANetNodeInstance * NNI = NSResources->findNodeInstance( N );
@@ -297,6 +297,25 @@ void NodeCollection::reassign( void ) {
297bool NodeCollection::triggersVPN() { 297bool NodeCollection::triggersVPN() {
298 return getToplevel()->runtime()->asFullSetup()->triggersVPN(); 298 return getToplevel()->runtime()->asFullSetup()->triggersVPN();
299} 299}
300
301bool NodeCollection::hasDataForFile( const QString & S ) {
302 return ( firstWithDataForFile( S ) != 0 );
303}
304
305ANetNodeInstance * 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//
302// RUNTIMEINFO 321// RUNTIMEINFO
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
@@ -5,6 +5,7 @@
5#include <qlist.h> 5#include <qlist.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qstringlist.h>
8#include <qobject.h> 9#include <qobject.h>
9#include <time.h> 10#include <time.h>
10 11
@@ -77,32 +78,58 @@ public:
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 //
83 // standard methods with sensible default
84 //
85 //
82 86
83 // description for this NetNode 87 inline int done( void )
84 virtual const QString nodeDescription() = 0; 88 { return Done; }
89 inline void setDone( int D )
90 { Done = D; }
85 91
86 // create a blank instance of a net node 92 // does this Node provide a Connection
87 virtual ANetNodeInstance * createInstance( void ) = 0; 93 inline bool isToplevel( void )
94 { return strcmp( provides(), "fullsetup") == 0 ; }
88 95
89 // return feature this NetNode provides 96 // set the value of an attribute
90 virtual const char * provides( void ) = 0; 97 void setAttribute( QString & Attr, QString & Value ) ;
91 virtual const char ** needs( void ) = 0; 98 void saveAttributes( QTextStream & TS ) ;
92 99
93 // generate files specific for this node (if any) 100 // compiled references to 'needed' NetNodes -> needs list
94 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0; 101 inline void setAlternatives( NetNodeList * Alt )
95 // return TRUE if this node has data to be inserted in systemfile 102 { Alternatives = Alt; }
96 // with name S 103 inline NetNodeList & alternatives( void )
97 virtual bool hasDataFor( const QString & S ) = 0; 104 { return *Alternatives; }
98 // generate data specific for the device for the system file S 105
99 // called only IF data was needed 106 //
100 virtual bool generateDeviceDataForCommonFile( 107 //
101 SystemFile & SF, long DevNr ) = 0; 108 // Virtual methods with sensible default
109 //
110 //
111
112 // do instances of this noce class have data for this file
113 virtual bool hasDataForFile( const QString & )
114 { return 0; }
115
116 // generate instance independent stuff
117 // 0 : data output, 1 no data, 2 error
118 virtual short generateFile( const QString & ,
119 const QString & ,
120 QTextStream & ,
121 long )
122 { return 1; }
123
124 // generate instance dependent but profile common stuff
125 // 0 : data output, 1 no data, 2 error
126 virtual short generateFile( const QString & ,
127 const QString & ,
128 QTextStream & ,
129 ANetNodeInstance * ,
130 long )
131 { return 1; }
102 132
103 // does this Node provide a Connection
104 bool isToplevel( void )
105 { return strcmp( provides(), "fullsetup") == 0 ; }
106 133
107 // generate NIC name based on instance nr 134 // generate NIC name based on instance nr
108 // only relevant if node instances are devices 135 // only relevant if node instances are devices
@@ -114,15 +141,28 @@ public:
114 virtual long instanceCount( void ) 141 virtual long instanceCount( void )
115 { return 1; } 142 { return 1; }
116 143
117 // set the value of an attribute 144 // return list of files that are specific for this node class
118 void setAttribute( QString & Attr, QString & Value ) ; 145 virtual QStringList * properFiles( void )
119 void saveAttributes( QTextStream & TS ) ; 146 { return 0; }
120 147
121 // compiled references to 'needed' NetNodes -> needs list 148 //
122 void setAlternatives( NetNodeList * Alt ) 149 //
123 { Alternatives = Alt; } 150 // pure virtual methods with sensible default
124 NetNodeList & alternatives( void ) 151 //
125 { return *Alternatives; } 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
127protected : 167protected :
128 168
@@ -132,6 +172,7 @@ 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};
137 178
@@ -143,27 +184,17 @@ public:
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 )
151 { return Connection; }
152
153 // create edit widget under parent
154 virtual QWidget * edit( QWidget * parent ) = 0;
155 // is given data acceptable
156 virtual QString acceptable( void ) = 0;
157 191
158 // return data was modified 192 // return data was modified
159 void setModified( bool M ) 193 inline void setModified( bool M )
160 { IsModified = M; } 194 { IsModified = M; }
161 bool isModified( void ) 195 inline bool isModified( void )
162 { return IsModified; } 196 { return IsModified; }
163 197
164 // get data from GUI and store in node
165 virtual void commit( void ) = 0;
166
167 // get next node 198 // get next node
168 ANetNodeInstance * nextNode(); 199 ANetNodeInstance * nextNode();
169 // return NetNode this is an instance of 200 // return NetNode this is an instance of
@@ -178,38 +209,94 @@ public:
178 void saveAttributes( QTextStream & TS ) ; 209 void saveAttributes( QTextStream & TS ) ;
179 210
180 // return true if node isntance is NEW and not loaded 211 // return true if node isntance is NEW and not loaded
181 void setNew( bool IsN ) 212 inline void setNew( bool IsN )
182 { IsNew = IsN; } 213 { IsNew = IsN; }
183 bool isNew( void ) 214 inline bool isNew( void )
184 { return IsNew; } 215 { return IsNew; }
185 216
186 // return description for this instance 217 // return description for this instance
187 QString & description( void ) 218 inline QString & description( void )
188 { return Description; } 219 { return Description; }
189 void setDescription( const QString & S ) 220 inline void setDescription( const QString & S )
190 { Description = S; } 221 { Description = S; }
191 222
192 // pixmap for this instance -> from NetNode 223 // pixmap for this instance -> from NetNode
193 const QString pixmapName( void ) 224 inline const QString pixmapName( void )
194 { return NodeType->pixmapName(); } 225 { return NodeType->pixmapName(); }
195 226
196 const char * provides( void ) 227 inline const char * provides( void )
197 { return NodeType->provides(); } 228 { return NodeType->provides(); }
198 229
199 const char ** needs( void ) 230 inline const char ** needs( void )
200 { return NodeType->needs(); } 231 { return NodeType->needs(); }
201 232
202 // returns node specific data -> only useful for 'buddy' 233 inline void setConnection( NodeCollection * NC )
203 virtual void * data( void ) = 0; 234 { Connection = NC; }
235 inline NodeCollection * connection( void )
236 { return Connection; }
237
238 //
239 //
240 // Virtual methods with sensible defaults
241 //
242 //
204 243
205 // return TRUE if this node has data to be inserted in systemfile
206 // with name S
207 virtual bool hasDataFor( const QString & S ) = 0;
208 244
209 // generate data specific for a profile and for the system file S 245
210 // called only IF data was needed 246 // open proper file identified by S
211 virtual bool generateDataForCommonFile( 247 virtual QFile * openFile( const QString & )
212 SystemFile & SF, long DevNr ) = 0; 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 }
264
265 // generate code specific for this node
266 // (or find the first node that does)
267 virtual short generateFile( const QString & ID,
268 const QString & Path,
269 QTextStream & TS,
270 long DevNr )
271 { ANetNodeInstance * NNI = nextNode();
272 return (NNI) ? NNI->generateFile( ID, Path, TS, DevNr ) : 1;
273 }
274
275 // return true if this node instance is triggered by this trigger
276 // could be delegated to deeper instances
277 virtual bool triggeredBy( const QString & )
278 { return 0; }
279
280 //
281 //
282 // Pure virtual functions
283 //
284 //
285
286 // return runtime information for this node
287 virtual RuntimeInfo * runtime( void ) = 0;
288
289 // create edit widget under parent
290 virtual QWidget * edit( QWidget * parent ) = 0;
291
292 // is given data acceptable
293 virtual QString acceptable( void ) = 0;
294
295 // get data from GUI and store in node
296 virtual void commit( void ) = 0;
297
298 // returns node specific data -> only useful for 'buddy'
299 virtual void * data( void ) = 0;
213 300
214protected : 301protected :
215 302
@@ -222,6 +309,7 @@ protected :
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};
@@ -282,34 +370,39 @@ public :
282 NodeCollection( QTextStream & TS ); 370 NodeCollection( QTextStream & TS );
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 }
309 402
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 ));
315 if( CurrentState == Unchecked || Update ) { 408 if( CurrentState == Unchecked || Update ) {
@@ -325,15 +418,15 @@ public :
325 // get the ixmap for this device 418 // get the ixmap for this device
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
339 void save( QTextStream & TS ); 432 void save( QTextStream & TS );
@@ -348,19 +441,35 @@ public :
348 ANetNodeInstance * findNext( ANetNodeInstance * NNI ); 441 ANetNodeInstance * findNext( ANetNodeInstance * NNI );
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
364private : 473private :
365 474
366 int compareItems ( QCollection::Item item1, 475 int compareItems ( QCollection::Item item1,
@@ -378,6 +487,7 @@ private :
378 // index in listbox 487 // index in listbox
379 int Index; 488 int Index;
380 bool IsModified; 489 bool IsModified;
490 int Done;
381 491
382}; 492};
383 493
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
@@ -77,7 +77,7 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
77 tr( "<p>Fully configured connection profile</p>" ) ); 77 tr( "<p>Fully configured connection profile</p>" ) );
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
83 TheSystem = new System(); 83 TheSystem = new System();
@@ -88,7 +88,16 @@ TheNSResources::~TheNSResources( void ) {
88 delete TheSystem; 88 delete TheSystem;
89} 89}
90 90
91void TheNSResources::busy( bool B ) { 91void 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
100void TheNSResources::busy( bool ) {
92/* 101/*
93 if( B ) { 102 if( B ) {
94 ShowWait->show(); 103 ShowWait->show();
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
@@ -66,8 +66,9 @@ public :
66 66
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 )
73 { ANetNodeInstance * NNI = 0; 74 { ANetNodeInstance * NNI = 0;
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
@@ -390,8 +390,11 @@ void VLog( char * Format, ... ) {
390 va_start(l, Format ); 390 va_start(l, 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",
397 errno ); 400 errno );
@@ -411,7 +414,16 @@ void VLog( char * Format, ... ) {
411void LogClose( void ) { 414void LogClose( void ) {
412 if( (long)logf > 1 ) { 415 if( (long)logf > 1 ) {
413 fprintf( logf, "____ CLOSE LOGFILE ____\n"); 416 fprintf( logf, "____ CLOSE LOGFILE ____\n");
417 if( logf != stderr ) {
414 fclose( logf ); 418 fclose( logf );
419 }
415 logf = 0; 420 logf = 0;
416 } 421 }
417} 422}
423
424QString 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
@@ -11,7 +11,9 @@
11#define TEMPLATEDIR "networktemplates/" 11#define TEMPLATEDIR "networktemplates/"
12QString TemplDir; 12QString TemplDir;
13 13
14SystemFile::SystemFile( const QString & N, const QString & P ){ 14SystemFile::SystemFile( const QString & N,
15 const QString & P,
16 bool KDI ){
15 Name = N; 17 Name = N;
16 Path = P; 18 Path = P;
17 F = 0; 19 F = 0;
@@ -57,6 +59,8 @@ SystemFile::SystemFile( const QString & N, const QString & P ){
57 FI.setFile( S ); 59 FI.setFile( S );
58 hasPostDeviceSection = ( FI.exists() && FI.isReadable() ); 60 hasPostDeviceSection = ( FI.exists() && FI.isReadable() );
59 } 61 }
62
63 KnowsDeviceInstances = KDI;
60} 64}
61 65
62SystemFile::~SystemFile( void ) { 66SystemFile::~SystemFile( void ) {
@@ -96,29 +100,29 @@ bool SystemFile::preSection( void ) {
96 if( hasPreSection ) { 100 if( hasPreSection ) {
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
106bool SystemFile::postSection( void ) { 110bool SystemFile::postSection( void ) {
107 if( hasPostSection ) { 111 if( hasPostSection ) {
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
117bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) { 121bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) {
118 if( hasPreNodeSection ) { 122 if( hasPreNodeSection ) {
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;
124 QString S = TX.readLine(); 128 QString S = TX.readLine();
@@ -129,14 +133,14 @@ bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) {
129 S = TX.readLine(); 133 S = TX.readLine();
130 } 134 }
131 } 135 }
132 return 0; 136 return 1;
133} 137}
134 138
135bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) { 139bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) {
136 if( hasPostNodeSection ) { 140 if( hasPostNodeSection ) {
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;
142 QString S = TX.readLine(); 146 QString S = TX.readLine();
@@ -147,14 +151,14 @@ bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) {
147 S = TX.readLine(); 151 S = TX.readLine();
148 } 152 }
149 } 153 }
150 return 0; 154 return 1;
151} 155}
152 156
153bool SystemFile::preDeviceSection( ANetNode * NN ) { 157bool SystemFile::preDeviceSection( ANetNode * NN ) {
154 if( hasPreDeviceSection ) { 158 if( hasPreDeviceSection ) {
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;
160 QString S = TX.readLine(); 164 QString S = TX.readLine();
@@ -164,14 +168,14 @@ bool SystemFile::preDeviceSection( ANetNode * NN ) {
164 S = TX.readLine(); 168 S = TX.readLine();
165 } 169 }
166 } 170 }
167 return 0; 171 return 1;
168} 172}
169 173
170bool SystemFile::postDeviceSection( ANetNode * NN ) { 174bool SystemFile::postDeviceSection( ANetNode * NN ) {
171 if( hasPostDeviceSection ) { 175 if( hasPostDeviceSection ) {
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;
177 QString S = TX.readLine(); 181 QString S = TX.readLine();
@@ -181,5 +185,5 @@ bool SystemFile::postDeviceSection( ANetNode * NN ) {
181 S = TX.readLine(); 185 S = TX.readLine();
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
@@ -11,11 +11,17 @@ class SystemFile : public QTextStream {
11 11
12public : 12public :
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 );
21 bool close( void ); 27 bool close( void );
@@ -38,6 +44,7 @@ private :
38 bool hasPostNodeSection; 44 bool hasPostNodeSection;
39 bool hasPreDeviceSection; 45 bool hasPreDeviceSection;
40 bool hasPostDeviceSection; 46 bool hasPostDeviceSection;
47 bool KnowsDeviceInstances;
41 48
42}; 49};
43#endif 50#endif
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
@@ -20,7 +20,6 @@ NetworkSettingsData::NetworkSettingsData( void ) {
20 Log(( "Cfg from %s\n", CfgFile.latin1() )); 20 Log(( "Cfg from %s\n", CfgFile.latin1() ));
21 21
22 // load settings 22 // load settings
23 Force = 0;
24 IsModified = 0; 23 IsModified = 0;
25 loadSettings(); 24 loadSettings();
26} 25}
@@ -218,68 +217,22 @@ QString NetworkSettingsData::saveSettings( void ) {
218 return ErrS; 217 return ErrS;
219} 218}
220 219
221QString NetworkSettingsData::generateSettings( bool ForceReq ) { 220QString NetworkSettingsData::generateSettings( void ) {
222 bool ForceIt;
223 QString S = ""; 221 QString S = "";
224 222 Name2SystemFile_t & SFM = NSResources->systemFiles();
225 // include own force flag
226 ForceIt = (Force) ? 1 : ForceReq;
227
228 if( ! ForceIt && ! isModified() )
229 return S;
230
231 // regenerate system files
232 Log( ( "Generating settings from %s\n", CfgFile.latin1() ));
233
234 { Name2SystemFile_t & SFM = NSResources->systemFiles();
235 Name2Connection_t & M = NSResources->connections(); 223 Name2Connection_t & M = NSResources->connections();
236 NodeCollection * NC; 224 NodeCollection * NC;
237 ANetNodeInstance * NNI; 225 ANetNodeInstance * NNI;
226 ANetNodeInstance * FirstWithData;
238 SystemFile * SF; 227 SystemFile * SF;
239 AsDevice * CurDev; 228 AsDevice * CurDev;
240 ANetNode * CurDevNN; 229 ANetNode * NN, * CurDevNN = 0;
241 bool needToRegenerate = ForceIt; 230 long NoOfDevs;
231 long DevCtStart;
232 bool needToGenerate;
242 233
243 // 234 // regenerate system files
244 // check if we need to generate at least one of the system files 235 Log( ( "Generating settings from %s\n", CfgFile.latin1() ));
245 //
246 if( ! ForceIt ) {
247 for( QDictIterator<SystemFile> sfit(SFM);
248 sfit.current();
249 ++sfit ) {
250 SF = sfit.current();
251
252 // check if there are nodes that are modified and require
253 // data for this system file
254
255 // for all connections
256 for( QDictIterator<NodeCollection> ncit(M);
257 ncit.current();
258 ++ncit ) {
259 NC = ncit.current();
260
261 if( NC->isModified() ) {
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 }
274 }
275 }
276 if( needToRegenerate )
277 break;
278 }
279 if( needToRegenerate )
280 break;
281 }
282 }
283 236
284 // 237 //
285 // generate files proper to each netnodeinstance 238 // generate files proper to each netnodeinstance
@@ -288,19 +241,32 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
288 241
289 for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); 242 for( QDictIterator<ANetNodeInstance> NNIIt(NNIs);
290 NNIIt.current(); 243 NNIIt.current();
291 ++NNIIt 244 ++NNIIt ) {
292 ){
293 // for all nodes find those that are modified 245 // for all nodes find those that are modified
294 NNI = NNIIt.current(); 246 NNI = NNIIt.current();
295 247
296 if( ForceIt || NNI->isModified() ) { 248 { // get list of proper files for this nodeclass (if any)
297 if( NNI->nodeClass()->generateProperFilesFor( NNI ) ) { 249 QStringList * PF = NNI->nodeClass()->properFiles();
250
251 if( PF ) {
252 for ( QStringList::Iterator it = PF->begin();
253 it != PF->end();
254 ++it ) {
255 QFile * F = NNI->openFile( (*it) );
256 if( F ) {
257 QTextStream TS( F );
258 if( NNI->generateFile( (*it), F->name(), TS, -1 ) == 2 ) {
298 // problem generating 259 // problem generating
299 S = qApp->translate( "NetworkSettings", 260 S = qApp->translate( "NetworkSettings",
300 "<p>Cannot generate files proper to \"%1\"</p>" ). 261 "<p>Cannot generate files proper to \"%1\"</p>" ).
301 arg(NNI->nodeClass()->name()) ; 262 arg(NNI->nodeClass()->name()) ;
263 delete F;
302 return S; 264 return S;
303 } 265 }
266 delete F;
267 }
268 }
269 }
304 } 270 }
305 } 271 }
306 } 272 }
@@ -313,71 +279,226 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
313 ++sfit ) { 279 ++sfit ) {
314 SF = sfit.current(); 280 SF = sfit.current();
315 281
316 Log( ( "Generating %s\n", SF->name().latin1() )); 282 // reset all
317 SF->open(); 283 for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() );
284 nnit.current();
285 ++nnit ) {
286 nnit.current()->NetNode->setDone(0);
287 }
318 288
319 do { // so we can break; 289 for( QDictIterator<ANetNodeInstance> nniit(
290 NSResources->netNodeInstances() );
291 nniit.current();
292 ++nniit ) {
293 nniit.current()->setDone(0);
294 }
320 295
321 // global presection for this system file 296 for( QDictIterator<NodeCollection> ncit(M);
322 if( SF->preSection() ) { 297 ncit.current();
323 S = qApp->translate( "NetworkSettings", 298 ++ncit ) {
324 "<p>Error in preSection for file \"%1\"</p>" ). 299 ncit.current()->setDone(0);
325 arg( SF->name() );
326 return S;
327 } 300 }
328 301
329 // find all netnodes and figure out if 302 Log( ( "Generating %s\n", SF->name().latin1() ));
330 // for that node there are instances 303
331 for( QDictIterator<NetNode_t> nnit( 304 needToGenerate = 0;
332 NSResources->netNodes() ); 305
333 nnit.current(); 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();
334 ++nnit ) { 310 ++nnit ) {
335 311
336 CurDevNN = nnit.current()->NetNode; 312 NN = nnit.current()->NetNode;
313
314 if( NN->hasDataForFile( SF->name() ) ) {
315 // netnode can have data
337 316
338 // are there instances for this netnode ? 317 // are there instances of this node ?
339 NNI = 0;
340 for( QDictIterator<ANetNodeInstance> nniit( 318 for( QDictIterator<ANetNodeInstance> nniit(
341 NSResources->netNodeInstances() ); 319 NSResources->netNodeInstances() );
342 nniit.current(); 320 ! needToGenerate && nniit.current();
343 ++nniit ) { 321 ++nniit ) {
344 if( nniit.current()->nodeClass() == CurDevNN ) { 322 if( nniit.current()->nodeClass() == NN ) {
345 NNI = nniit.current(); 323 // yes
324 Log(("Node %s has data\n",
325 nniit.current()->name() ));
326 needToGenerate = 1;
346 break; 327 break;
347 } 328 }
348 } 329 }
330 }
331 }
349 332
350 if( ! NNI ) 333 if( ! needToGenerate ) {
351 // no instances -> next netnode type 334 // no instances found that might need to write data
335 // in this systemfile
336 Log(("No nodes for systemfile %s\n", SF->name().latin1() ));
352 continue; 337 continue;
338 }
339
340 // ok generate this system file
341 SF->open();
353 342
354 // has this node data for this system file ? 343 // global presection for this system file
355 if( (CurDev = NNI->runtime()->asDevice() ) ) { 344 if( ! SF->preSection() ) {
356 // generate start for this nodetype for all possible devices of this type 345 S = qApp->translate( "NetworkSettings",
357 for( int i = 0; i < CurDevNN->instanceCount(); i ++ ) { 346 "<p>Error in section \"Preamble\" for file \"%1\"</p>" ).
358 S = generateSystemFileNode( *SF, CurDev, NNI, i ); 347 arg( SF->name() );
359 if( ! S.isEmpty() )
360 return S; 348 return S;
361 } 349 }
362 } else { 350
363 S = generateSystemFileNode( *SF, 0, NNI, -1 ); 351 // find connections that want to write to this file
364 if( ! S.isEmpty() ) 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 ) ) {
385 S = qApp->translate( "NetworkSettings",
386 "<p>Error in section \"Pre-Device\" for file \"%1\"</p>" ).
387 arg( SF->name() );
365 return S; 388 return S;
366 } 389 }
390
391 if( FirstWithData->nodeClass()->generateFile(
392 SF->name(), SF->path(), *SF, -1 ) == 2 ) {
393 S = qApp->translate( "NetworkSettings",
394 "<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ).
395 arg( SF->name() ).
396 arg( CurDevNN->name() );
397 return S;
398 }
399 FirstWithData->nodeClass()->setDone( 1 );
400 }
401
402 NoOfDevs = 0;
403 DevCtStart = -1;
404
405 if( SF->knowsDeviceInstances() ) {
406 DevCtStart = 0;
407 NoOfDevs = CurDevNN->instanceCount();
367 } 408 }
368 409
369 if( SF->postSection() ) { 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 ) {
370 S = qApp->translate( "NetworkSettings", 421 S = qApp->translate( "NetworkSettings",
371 "<p>Error in postSection for file \"%1\"</p>" ). 422 "<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ).
423 arg( SF->name() ).
424 arg( CurDevNN->name() );
425 return S;
426 }
427 }
428 CurDev->netNode()->nodeClass()->setDone( 1 );
429 }
430
431 // generate profile specific info
432 // for all nodeconnections that work on the same device
433 for( QDictIterator<NodeCollection> ncit2(M);
434 ncit2.current();
435 ++ncit2 ) {
436
437 if( ncit2.current()->device() != CurDev ) {
438 // different device
439 continue;
440 }
441
442 Log(("Connection %s of same family\n", ncit2.current()->name().latin1() ));
443 // generate
444 NNI = ncit2.current()->firstWithDataForFile( SF->name() );
445 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) {
446 if( ! SF->preNodeSection( NNI, i ) ) {
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() );
466 return S;
467 }
468
469 if( ! SF->postNodeSection( NNI, i ) ) {
470 S = qApp->translate( "NetworkSettings",
471 "<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
472 arg( SF->name() ).
473 arg( CurDevNN->name() );
474 return S;
475 }
476 }
477
478 ncit2.current()->setDone( 1 );
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>" ).
372 arg( SF->name() ); 495 arg( SF->name() );
373 return S; 496 return S;
374 } 497 }
375 498
376 } while( 0 ); 499 // end of file
377 SF->close(); 500 SF->close();
378 } 501 }
379 }
380 Force = 0;
381 return S; 502 return S;
382} 503}
383 504
@@ -463,111 +584,10 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
463*/ 584*/
464 585
465bool NetworkSettingsData::regenerate( void ) { 586bool 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() );
471 return 1; 590 return 1;
472 } 591 }
473 return 0; 592 return 0;
474} 593}
475
476QString 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
@@ -13,7 +13,7 @@ public :
13 void loadSettings( void ); 13 void loadSettings( void );
14 QString saveSettings( void ); 14 QString saveSettings( void );
15 15
16 QString generateSettings( bool Force = FALSE ); 16 QString generateSettings( void );
17 17
18 bool isModified( void ) 18 bool isModified( void )
19 { return IsModified; } 19 { return IsModified; }
@@ -25,18 +25,9 @@ public :
25 bool canStart( const char * Interface ); 25 bool canStart( const char * Interface );
26 bool regenerate( void ); 26 bool regenerate( void );
27 27
28 void forceGeneration( bool m )
29 { Force = m; }
30
31private : 28private :
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
42 QStringList LeftOvers; 33 QStringList LeftOvers;
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
@@ -11,7 +11,7 @@
11 <rect> 11 <rect>
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>
17 </property> 17 </property>
@@ -57,11 +57,11 @@
57 <vbox> 57 <vbox>
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>
67 <class>QRadioButton</class> 67 <class>QRadioButton</class>
@@ -191,16 +191,55 @@
191 </hbox> 191 </hbox>
192 </widget> 192 </widget>
193 <widget> 193 <widget>
194 <class>QLayoutWidget</class>
195 <property stdset="1">
196 <name>name</name>
197 <cstring>Layout3</cstring>
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>
194 <class>QRadioButton</class> 231 <class>QRadioButton</class>
195 <property stdset="1"> 232 <property stdset="1">
196 <name>name</name> 233 <name>name</name>
197 <cstring>PapChap_RB</cstring> 234 <cstring>EAP_RB</cstring>
198 </property> 235 </property>
199 <property stdset="1"> 236 <property stdset="1">
200 <name>text</name> 237 <name>text</name>
201 <string>Pap/Chap/EAP</string> 238 <string>EAP</string>
202 </property> 239 </property>
203 </widget> 240 </widget>
241 </hbox>
242 </widget>
204 <widget> 243 <widget>
205 <class>QLayoutWidget</class> 244 <class>QLayoutWidget</class>
206 <property stdset="1"> 245 <property stdset="1">
@@ -275,9 +314,9 @@
275 </property> 314 </property>
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">
283 <name>name</name> 322 <name>name</name>
@@ -288,7 +327,7 @@
288 <string>Server</string> 327 <string>Server</string>
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">
294 <name>name</name> 333 <name>name</name>
@@ -299,54 +338,25 @@
299 <string>Secret</string> 338 <string>Secret</string>
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">
352 <name>name</name> 362 <name>name</name>
@@ -357,45 +367,17 @@
357 <string>*</string> 367 <string>*</string>
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>
401 </hbox> 383 </hbox>
@@ -417,7 +399,7 @@
417</widget> 399</widget>
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>
423 <slot>setEnabled(bool)</slot> 405 <slot>setEnabled(bool)</slot>
@@ -428,5 +410,17 @@
428 <receiver>GroupBox1</receiver> 410 <receiver>GroupBox1</receiver>
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
@@ -9,6 +9,13 @@
9PPPAuthEdit::PPPAuthEdit( QWidget * Parent ) : PPPAuthGUI( Parent ){ 9PPPAuthEdit::PPPAuthEdit( QWidget * Parent ) : PPPAuthGUI( Parent ){
10} 10}
11 11
12bool PPPAuthEdit::PAP_Checked( void ) {
13 return ( Pap_RB->isChecked() ||
14 Chap_RB->isChecked() ||
15 EAP_RB->isChecked()
16 );
17}
18
12QString PPPAuthEdit::acceptable( void ) { 19QString PPPAuthEdit::acceptable( void ) {
13 if( Login_RB->isChecked() ) { 20 if( Login_RB->isChecked() ) {
14 if( LoginSend_LE->text().isEmpty() ) 21 if( LoginSend_LE->text().isEmpty() )
@@ -19,7 +26,7 @@ QString PPPAuthEdit::acceptable( void ) {
19 return tr("Password send missing"); 26 return tr("Password send missing");
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");
25 if( Server_LE->text().isEmpty() ) 32 if( Server_LE->text().isEmpty() )
@@ -34,14 +41,13 @@ bool PPPAuthEdit::commit( PPPData_t & D ) {
34 bool SM = 0; 41 bool SM = 0;
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
40 SM = 1; 47 SM = 1;
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
47 if( Login_RB->isChecked() ) { 53 if( Login_RB->isChecked() ) {
@@ -49,11 +55,17 @@ bool PPPAuthEdit::commit( PPPData_t & D ) {
49 TXTM( D.Auth.Login.Send, LoginSend_LE, SM ); 55 TXTM( D.Auth.Login.Send, LoginSend_LE, SM );
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;
59} 71}
@@ -62,13 +74,23 @@ void PPPAuthEdit::showData( PPPData_t & D ) {
62 74
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 );
78 break;
79 case 1 :
80 switch( D.Auth.PCEMode ) {
81 case 0 :
82 Pap_RB->setChecked( TRUE );
66 break; 83 break;
67 case 1 : 84 case 1 :
68 PapChap_RB->isChecked(); 85 Chap_RB->setChecked( TRUE );
69 break; 86 break;
70 case 2 : 87 case 2 :
71 Terminal_RB->isChecked(); 88 EAP_RB->setChecked( TRUE );
89 break;
90 }
91 break;
92 case 2 :
93 Terminal_RB->setChecked( TRUE );
72 break; 94 break;
73 } 95 }
74 96
@@ -80,6 +102,4 @@ void PPPAuthEdit::showData( PPPData_t & D ) {
80 Client_LE->setText( D.Auth.Client ); 102 Client_LE->setText( D.Auth.Client );
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
@@ -9,6 +9,8 @@ public :
9 QString acceptable( void ); 9 QString acceptable( void );
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
13private : 15private :
14 16
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,6 +1,10 @@
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
6QStringList * PPPNetNode::ProperFiles = 0;
7
4static const char * PPPNeeds[] = 8static const char * PPPNeeds[] =
5 { "line", 9 { "line",
6 "modem", 10 "modem",
@@ -11,6 +15,17 @@ static const char * PPPNeeds[] =
11 * Constructor, find all of the possible interfaces 15 * Constructor, find all of the possible interfaces
12 */ 16 */
13PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) { 17PPPNetNode::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
16/** 31/**
@@ -39,15 +54,17 @@ const char * PPPNetNode::provides( void ) {
39 return "connection"; 54 return "connection";
40} 55}
41 56
42bool PPPNetNode::generateProperFilesFor( 57QStringList * PPPNetNode::properFiles( void ) {
43 ANetNodeInstance * ) { 58 return ProperFiles;
44 return 0; 59
45} 60}
46 61
47bool PPPNetNode::generateDeviceDataForCommonFile( 62// need to generate :
48 SystemFile & , 63// /etc/ppp/pap-secrets
49 long ) { 64// /etc/ppp/pap-secrets
50 return 0; 65bool PPPNetNode::hasDataForFile( const QString & S ) {
66 return S == "pap-secrets" ||
67 S == "chap-secrets" ;
51} 68}
52 69
53QString PPPNetNode::genNic( long NicNr ) { 70QString PPPNetNode::genNic( long NicNr ) {
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
@@ -17,25 +17,22 @@ public:
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 const QString nodeDescription() ;
22 virtual ANetNodeInstance * createInstance( void ); 23 virtual ANetNodeInstance * createInstance( void );
23
24 virtual const char ** needs( void ); 24 virtual const char ** needs( void );
25 virtual const char * provides( void ); 25 virtual const char * provides( void );
26 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 ); 27 virtual QString genNic( long NicNr );
28 virtual QStringList * properFiles( void );
34 29
35private: 30private:
36 31
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
41extern "C" 38extern "C"
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,3 +1,5 @@
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"
3#include "ppp_NN.h" 5#include "ppp_NN.h"
@@ -113,9 +115,107 @@ void APPP::commit( void ) {
113 } 115 }
114} 116}
115 117
116bool APPP::generateDataForCommonFile( 118QFile * 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;
120} 130}
131 } else if ( ID == "chatscripts" ) {
132 S = removeSpaces( QString("/tmp/") + connection()->name() + ".chat" );
133 F = new QFile( S );
121 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;
145}
146
147short 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
@@ -7,6 +7,7 @@
7 7
8class PPPNetNode; 8class PPPNetNode;
9class PPPEdit; 9class PPPEdit;
10class QTextStream;
10 11
11class APPP : public ANetNodeInstance { 12class APPP : public ANetNodeInstance {
12 13
@@ -14,24 +15,26 @@ public :
14 15
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 );
35protected : 38protected :
36 39
37 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 40 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -9,7 +9,7 @@ static const char * ProfileNeeds[] =
9/** 9/**
10 * Constructor, find all of the possible interfaces 10 * Constructor, find all of the possible interfaces
11 */ 11 */
12ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular profile")) { 12ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) {
13} 13}
14 14
15/** 15/**
@@ -38,17 +38,6 @@ const char * ProfileNetNode::provides( void ) {
38 return "fullsetup"; 38 return "fullsetup";
39} 39}
40 40
41bool ProfileNetNode::generateProperFilesFor(
42 ANetNodeInstance * ) {
43 return 0;
44}
45
46bool ProfileNetNode::generateDeviceDataForCommonFile(
47 SystemFile & ,
48 long ) {
49 return 0;
50}
51
52void ProfileNetNode::setSpecificAttribute( QString & , QString & ) { 41void ProfileNetNode::setSpecificAttribute( QString & , QString & ) {
53} 42}
54 43
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
@@ -18,18 +18,10 @@ public:
18 { return "Devices/commprofile"; } 18 { return "Devices/commprofile"; }
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
33private: 25private:
34 26
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -50,9 +50,28 @@ void AProfile::commit( void ) {
50 setModified( 1 ); 50 setModified( 1 );
51} 51}
52 52
53bool AProfile::generateDataForCommonFile( 53short 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 }
57} 70}
71 rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr );
72 return (rvd == 2 || rvl == 2 ) ? 2 :
73 (rvd == 0 || rvl == 0 ) ? 0 : 1;
74}
75
76
58 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
@@ -14,26 +14,25 @@ public :
14 14
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
38protected : 37protected :
39 38
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
@@ -37,29 +37,6 @@ const char * USBNetNode::provides( void ) {
37 return "device"; 37 return "device";
38} 38}
39 39
40bool USBNetNode::generateProperFilesFor(
41 ANetNodeInstance * ) {
42 return 0;
43}
44
45bool USBNetNode::hasDataFor( const QString & S ) {
46 return (S== "interfaces");
47}
48
49bool 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
63QString USBNetNode::genNic( long ) { 40QString USBNetNode::genNic( long ) {
64 return QString( "usbf" ); 41 return QString( "usbf" );
65} 42}
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
@@ -18,17 +18,10 @@ public:
18 { return "Devices/usb"; } 18 { return "Devices/usb"; }
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
34private: 27private:
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
@@ -32,21 +32,30 @@ void AUSB::commit( void ) {
32 } 32 }
33} 33}
34 34
35bool AUSB::hasDataFor( const QString & S ) { 35short AUSB::generateFileEmbedded( const QString & ID,
36 return (S== "interfaces"); 36 const QString & Path,
37} 37 QTextStream & TS,
38 long DevNr ) {
38 39
39bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) {
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
@@ -14,22 +14,22 @@ public :
14 14
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
34protected : 34protected :
35 35
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
@@ -2,8 +2,7 @@
2#include "vpn_NNI.h" 2#include "vpn_NNI.h"
3 3
4static const char * VPNNeeds[] = 4static const char * VPNNeeds[] =
5 { "connection", 5 { 0
6 0
7 }; 6 };
8 7
9/** 8/**
@@ -38,17 +37,6 @@ const char * VPNNetNode::provides( void ) {
38 return "connection"; 37 return "connection";
39} 38}
40 39
41bool VPNNetNode::generateProperFilesFor(
42 ANetNodeInstance * ) {
43 return 0;
44}
45
46bool VPNNetNode::generateDeviceDataForCommonFile(
47 SystemFile & ,
48 long ) {
49 return 0;
50}
51
52void VPNNetNode::setSpecificAttribute( QString & , QString & ) { 40void VPNNetNode::setSpecificAttribute( QString & , QString & ) {
53} 41}
54 42
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
@@ -18,18 +18,10 @@ public:
18 { return "Devices/vpn"; } 18 { return "Devices/vpn"; }
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
33private: 25private:
34 26
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -28,9 +28,3 @@ void AVPN::commit( void ) {
28 setModified( 1 ); 28 setModified( 1 );
29} 29}
30 30
31bool 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
@@ -14,23 +14,19 @@ public :
14 14
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 );
34protected : 30protected :
35 31
36 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 32 virtual void setSpecificAttribute( QString & Attr, QString & Value );
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
@@ -38,29 +38,6 @@ const char * WLanNetNode::provides( void ) {
38 return "device"; 38 return "device";
39} 39}
40 40
41bool WLanNetNode::generateProperFilesFor(
42 ANetNodeInstance * ) {
43 return 0;
44}
45
46bool WLanNetNode::hasDataFor( const QString & S ) {
47 return S == "interfaces";
48}
49
50bool 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
64QString WLanNetNode::genNic( long nr ) { 41QString WLanNetNode::genNic( long nr ) {
65 QString S; 42 QString S;
66 return S.sprintf( "wlan%ld", nr ); 43 return S.sprintf( "wlan%ld", nr );
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
@@ -18,21 +18,12 @@ public:
18 { return "Devices/wlan"; } 18 { return "Devices/wlan"; }
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
38private: 29private:
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
@@ -79,11 +79,18 @@ void AWLan::commit( void ) {
79 setModified( 1 ); 79 setModified( 1 );
80} 80}
81 81
82bool AWLan::generateDataForCommonFile( 82short 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;
88
89 rvl = 1;
90
91 if( ID == "interfaces" ) {
92 Log(("Generate WLanNNI for %s\n", ID.latin1() ));
93 TS << " wireless_essid \""
87 << Data.ESSID 94 << Data.ESSID
88 << "\"" 95 << "\""
89 << endl; 96 << endl;
@@ -93,22 +100,21 @@ bool AWLan::generateDataForCommonFile(
93 char Buf[100]; 100 char Buf[100];
94 if( gethostname(Buf, sizeof(Buf) ) == 0 ) { 101 if( gethostname(Buf, sizeof(Buf) ) == 0 ) {
95 Buf[99] = '\0'; // just to make sure 102 Buf[99] = '\0'; // just to make sure
96 S << " wireless_nick " 103 TS << " wireless_nick "
97 << Buf 104 << Buf
98 << endl; 105 << endl;
99 } 106 }
100 } else { 107 } else {
101 S << " wireless_nick \"" 108 TS << " wireless_nick \""
102 << Data.NodeName 109 << Data.NodeName
103 << "\"" 110 << "\""
104 << endl; 111 << endl;
105 } 112 }
106 } 113 }
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";
112 break; 118 break;
113 case 1 : 119 case 1 :
114 M = "Managed"; 120 M = "Managed";
@@ -118,23 +124,28 @@ bool AWLan::generateDataForCommonFile(
118 break; 124 break;
119 } 125 }
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;
132 } 138 }
133 } 139 }
134 S << " wireless_keymode " 140 TS << " wireless_keymode "
135 << ((Data.AcceptNonEncrypted) ? "open" : "restricted") 141 << ((Data.AcceptNonEncrypted) ? "open" : "restricted")
136 << endl; 142 << endl;
137 } 143 }
138 return 0; 144 rvl = 0;
145 }
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
@@ -14,23 +14,23 @@ public :
14 14
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
34protected : 34protected :
35 35
36 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 36 virtual void setSpecificAttribute( QString & Attr, QString & Value );