summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -41,10 +41,2 @@ void ABluetoothBNEP::commit( void ) {
setModified( 1 );
}
-
-bool ABluetoothBNEP::hasDataFor( const QString & ) {
- return 0;
-}
-
-bool ABluetoothBNEP::generateDataForCommonFile( SystemFile & , long ){
- return 0;
-}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h
index bb3e7e7..1bf0f48 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h
@@ -15,20 +15,16 @@ public :
ABluetoothBNEP( BluetoothBNEPNetNode * PNN );
+ RuntimeInfo * runtime( void )
+ { return
+ ( RT ) ? RT : ( RT = new BluetoothBNEPRun( this, Data ) );
+ }
+
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
- RuntimeInfo * runtime( void )
- { if( RT == 0 )
- RT = new BluetoothBNEPRun( this, Data );
- return RT;
- }
-
virtual void * data( void )
{ return (void *)&Data; }
- virtual bool hasDataFor( const QString & S );
- virtual bool generateDataForCommonFile( SystemFile & SF, long );
-
protected :
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp
index cff2639..7ec8288 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp
@@ -29,10 +29,2 @@ void ABluetoothRFCOMM::commit( void ) {
setModified( 1 );
}
-
-bool ABluetoothRFCOMM::hasDataFor( const QString & ) {
- return 0;
-}
-
-bool ABluetoothRFCOMM::generateDataForCommonFile( SystemFile & , long ){
- return 0;
-}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h
index 97bd29c..820fc17 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h
@@ -15,20 +15,16 @@ public :
ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN );
+ RuntimeInfo * runtime( void )
+ { return
+ ( RT ) ? RT : ( RT = new BluetoothRFCOMMRun( this, Data ) );
+ }
+
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
- RuntimeInfo * runtime( void )
- { if( RT == 0 )
- RT = new BluetoothRFCOMMRun( this, Data );
- return RT;
- }
-
virtual void * data( void )
{ return (void *)&Data; }
- virtual bool hasDataFor( const QString & S );
- virtual bool generateDataForCommonFile( SystemFile & SF, long );
-
protected :
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
index aff1f59..65fd686 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
@@ -13,4 +13,7 @@ public :
{ return (AsLine *)this; }
+ virtual QString deviceFile( void )
+ { return QString( "/dev/rfcomm..." ); }
+
protected :
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
index b59b4f0..443a627 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
@@ -47,27 +47,4 @@ const char * BluetoothBNEPNetNode::provides( void ) {
}
-bool BluetoothBNEPNetNode::generateProperFilesFor(
- ANetNodeInstance * ) {
- return 0;
-}
-
-bool BluetoothBNEPNetNode::hasDataFor( const QString & S ) {
- return S == "interfaces";
-}
-
-bool BluetoothBNEPNetNode::generateDeviceDataForCommonFile(
- SystemFile & S ,
- long DevNr) {
- QString NIC = genNic( DevNr );
-
- if( S.name() == "interfaces" ) {
- // generate mapping stanza for this interface
- S << "# check if " << NIC << " can be brought UP" << endl;
- S << "mapping " << NIC << endl;
- S << " script networksettings2-request" << endl << endl;
- }
- return 0;
-}
-
QString BluetoothBNEPNetNode::genNic( long nr ) {
QString S;
@@ -125,19 +102,4 @@ const char * BluetoothRFCOMMNetNode::provides( void ) {
}
-bool BluetoothRFCOMMNetNode::generateProperFilesFor(
- ANetNodeInstance * ) {
- return 0;
-}
-
-bool BluetoothRFCOMMNetNode::hasDataFor( const QString & ) {
- return 0;
-}
-
-bool BluetoothRFCOMMNetNode::generateDeviceDataForCommonFile(
- SystemFile & ,
- long ) {
- return 0;
-}
-
void BluetoothRFCOMMNetNode::setSpecificAttribute( QString &, QString & ) {
}
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
@@ -15,22 +15,14 @@ public:
virtual ~BluetoothBNEPNetNode();
+ virtual QString genNic( long );
+ virtual long instanceCount( void )
+ { return InstanceCount; }
virtual const QString pixmapName()
{ return "Devices/bluetooth"; }
virtual const QString nodeDescription() ;
-
virtual ANetNodeInstance * createInstance( void );
-
- virtual const char ** needs( void );
virtual const char * provides( void );
-
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
- virtual bool hasDataFor( const QString & S );
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & , long DevNr );
-
- virtual long instanceCount( void )
- { return InstanceCount; }
- virtual QString genNic( long );
+ virtual const char ** needs( void );
private:
@@ -57,15 +49,8 @@ public:
virtual const QString nodeDescription() ;
-
virtual ANetNodeInstance * createInstance( void );
-
virtual const char ** needs( void );
virtual const char * provides( void );
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
- virtual bool hasDataFor( const QString & S );
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & , long );
-
private:
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp
index b8c690b..38568df 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NN.cpp
@@ -37,15 +37,4 @@ const char * CableNetNode::provides( void ) {
}
-bool CableNetNode::generateProperFilesFor(
- ANetNodeInstance * ) {
- return 0;
-}
-
-bool CableNetNode::generateDeviceDataForCommonFile(
- SystemFile & ,
- long ) {
- return 0;
-}
-
void CableNetNode::setSpecificAttribute( QString & , QString & ) {
}
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
@@ -19,16 +19,8 @@ public:
virtual const QString nodeDescription() ;
-
virtual ANetNodeInstance * createInstance( void );
-
virtual const char ** needs( void );
virtual const char * provides( void );
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
- virtual bool hasDataFor( const QString & )
- { return 0; }
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr);
-
private:
diff --git a/noncore/settings/networksettings2/cable/cable_NNI.cpp b/noncore/settings/networksettings2/cable/cable_NNI.cpp
index ca21135..4bd9421 100644
--- a/noncore/settings/networksettings2/cable/cable_NNI.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NNI.cpp
@@ -50,4 +50,27 @@ void ACable::saveSpecificAttribute( QTextStream & TS ) {
}
+short ACable::generateFileEmbedded( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr ) {
+ short rvl, rvd;
+
+ rvl = 1;
+ if( ID == "peers" ) {
+ TS << Data.Device
+ << endl;
+ TS << Data.Speed
+ << endl;
+ TS << "lock "
+ << Data.LockFile
+ << endl;
+ rvl = 0;
+ }
+
+ rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr );
+ return (rvd == 2 || rvl == 2 ) ? 2 :
+ (rvd == 0 || rvl == 0 ) ? 0 : 1;
+}
+
QWidget * ACable::edit( QWidget * parent ) {
GUI = new CableEdit( parent );
@@ -65,9 +88,2 @@ void ACable::commit( void ) {
}
}
-
-bool ACable::generateDataForCommonFile(
- SystemFile & ,
- long ) {
- return 1;
-}
-
diff --git a/noncore/settings/networksettings2/cable/cable_NNI.h b/noncore/settings/networksettings2/cable/cable_NNI.h
index bf3e292..d06cbbe 100644
--- a/noncore/settings/networksettings2/cable/cable_NNI.h
+++ b/noncore/settings/networksettings2/cable/cable_NNI.h
@@ -15,22 +15,20 @@ public :
ACable( CableNetNode * PNN );
+ RuntimeInfo * runtime( void )
+ { return
+ ( RT ) ? RT : ( RT = new CableRun( this, Data ) );
+ }
+
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
- RuntimeInfo * runtime( void )
- { if( RT == 0 )
- RT = new CableRun( this, Data );
- return RT;
- }
-
virtual void * data( void )
{ return (void *)&Data; }
- virtual bool hasDataFor( const QString & )
- { return 0; }
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr );
-
+ short generateFileEmbedded( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr );
protected :
diff --git a/noncore/settings/networksettings2/cable/cablerun.cpp b/noncore/settings/networksettings2/cable/cablerun.cpp
index 5e99237..85660f6 100644
--- a/noncore/settings/networksettings2/cable/cablerun.cpp
+++ b/noncore/settings/networksettings2/cable/cablerun.cpp
@@ -5,5 +5,5 @@
void CableRun::detectState( NodeCollection * NC ) {
- int fd = open( D->Device.latin1(), O_RDWR );
+ int fd = open( Data->Device.latin1(), O_RDWR );
if( fd < 0 ) {
@@ -25,2 +25,6 @@ bool CableRun::canSetState( State_t , Action_t ) {
return 1;
}
+
+QString CableRun::deviceFile( void ) {
+ return Data->Device;
+}
diff --git a/noncore/settings/networksettings2/cable/cablerun.h b/noncore/settings/networksettings2/cable/cablerun.h
index c5b59d5..20608f6 100644
--- a/noncore/settings/networksettings2/cable/cablerun.h
+++ b/noncore/settings/networksettings2/cable/cablerun.h
@@ -7,10 +7,12 @@ public :
CableRun( ANetNodeInstance * NNI,
- CableData & Data ) : AsLine( NNI )
- { D = &Data; }
+ CableData_t & D ) : AsLine( NNI )
+ { Data = &D; }
virtual AsLine * asLine( void )
{ return (AsLine *)this; }
+ virtual QString deviceFile( void );
+
protected :
@@ -21,4 +23,4 @@ protected :
private :
- CableData_t * D;
+ CableData_t * Data;
};
diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp
index 49bc06e..9483e22 100644
--- a/noncore/settings/networksettings2/irda/irda_NN.cpp
+++ b/noncore/settings/networksettings2/irda/irda_NN.cpp
@@ -37,15 +37,4 @@ const char * IRDANetNode::provides( void ) {
}
-bool IRDANetNode::generateProperFilesFor(
- ANetNodeInstance * ) {
- return 0;
-}
-
-bool IRDANetNode::generateDeviceDataForCommonFile(
- SystemFile & ,
- long ) {
- return 0;
-}
-
void IRDANetNode::setSpecificAttribute( QString & , QString & ) {
}
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
@@ -19,16 +19,8 @@ public:
virtual const QString nodeDescription() ;
-
virtual ANetNodeInstance * createInstance( void );
-
virtual const char ** needs( void );
virtual const char * provides( void );
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
- virtual bool hasDataFor( const QString & )
- { return 0; }
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr );
-
private:
diff --git a/noncore/settings/networksettings2/irda/irda_NNI.cpp b/noncore/settings/networksettings2/irda/irda_NNI.cpp
index f00a1d5..9cf443b 100644
--- a/noncore/settings/networksettings2/irda/irda_NNI.cpp
+++ b/noncore/settings/networksettings2/irda/irda_NNI.cpp
@@ -30,8 +30,2 @@ void AIRDA::commit( void ) {
}
-bool AIRDA::generateDataForCommonFile(
- SystemFile & ,
- long ) {
- return 1;
-}
-
diff --git a/noncore/settings/networksettings2/irda/irda_NNI.h b/noncore/settings/networksettings2/irda/irda_NNI.h
index 210d87d..e21b68f 100644
--- a/noncore/settings/networksettings2/irda/irda_NNI.h
+++ b/noncore/settings/networksettings2/irda/irda_NNI.h
@@ -15,22 +15,16 @@ public :
AIRDA( IRDANetNode * PNN );
+ RuntimeInfo * runtime( void )
+ { return
+ ( RT ) ? RT : ( RT = new IRDARun( this, Data ) );
+ }
+
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
- RuntimeInfo * runtime( void )
- { if( RT == 0 )
- RT = new IRDARun( this, Data );
- return RT;
- }
-
virtual void * data( void )
{ return (void *)&Data; }
- virtual bool hasDataFor( const QString & )
- { return 0; }
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr );
-
protected :
diff --git a/noncore/settings/networksettings2/irda/irdarun.h b/noncore/settings/networksettings2/irda/irdarun.h
index 4c903cc..4258aff 100644
--- a/noncore/settings/networksettings2/irda/irdarun.h
+++ b/noncore/settings/networksettings2/irda/irdarun.h
@@ -13,4 +13,7 @@ public :
{ return (AsLine *)this; }
+ virtual QString deviceFile( void )
+ { return QString( "/dev/irda" ); }
+
protected :
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
index 05cd06d..20ae7f6 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
@@ -39,27 +39,4 @@ const char * LanCardNetNode::provides( void ) {
}
-bool LanCardNetNode::generateProperFilesFor(
- ANetNodeInstance * ) {
- return 0;
-}
-
-bool LanCardNetNode::hasDataFor( const QString & S ) {
- return S == "interfaces";
-}
-
-bool LanCardNetNode::generateDeviceDataForCommonFile(
- SystemFile & S ,
- long DevNr ) {
- QString NIC = genNic( DevNr );
-
- if( S.name() == "interfaces" ) {
- // generate mapping stanza for this interface
- S << "# check if " << NIC << " can be brought UP" << endl;
- S << "mapping " << NIC << endl;
- S << " script networksettings2-request" << endl << endl;
- }
- return 0;
-}
-
QString LanCardNetNode::genNic( long nr ) {
QString S;
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h
index d58823c..6882af7 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.h
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.h
@@ -19,21 +19,14 @@ public:
{ return "Devices/card"; }
- virtual const QString nodeDescription() ;
+ virtual QString genNic( long );
+ virtual long instanceCount( void )
+ { return InstanceCount; }
+ virtual const QString nodeDescription() ;
virtual ANetNodeInstance * createInstance( void );
-
virtual const char ** needs( void );
virtual const char * provides( void );
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
- virtual bool hasDataFor( const QString & S );
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr );
-
- virtual long instanceCount( void )
- { return InstanceCount; }
-
- virtual QString genNic( long );
- virtual QStringList & addressesOfNIC( void )
+ QStringList & addressesOfNIC( void )
{ return NICMACAddresses; }
diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
index 99c033e..9fb05b9 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
@@ -44,8 +44,2 @@ void ALanCard::commit( void ) {
}
-bool ALanCard::generateDataForCommonFile(
- SystemFile & ,
- long ) {
- return 1;
-}
-
diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.h b/noncore/settings/networksettings2/lancard/lancard_NNI.h
index 4e91523..8e55a19 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NNI.h
+++ b/noncore/settings/networksettings2/lancard/lancard_NNI.h
@@ -15,21 +15,16 @@ public :
ALanCard( LanCardNetNode * PNN );
+ RuntimeInfo * runtime( void )
+ { return
+ ( RT ) ? RT : ( RT = new LanCardRun( this, Data ) );
+ }
+
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
- RuntimeInfo * runtime( void )
- { if( RT == 0 )
- RT = new LanCardRun( this, Data );
- return RT;
- }
-
virtual void * data( void )
{ return (void *)&Data; }
- virtual bool hasDataFor( const QString & )
- { return 0; }
- virtual bool generateDataForCommonFile(
- SystemFile & S, long DevNr );
protected :
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp
index 6c969fc..b32b323 100644
--- a/noncore/settings/networksettings2/main.cpp
+++ b/noncore/settings/networksettings2/main.cpp
@@ -1,4 +1,5 @@
#include "nsdata.h"
#include "activateprofile.h"
+#include "activatevpn.h"
#include "networksettings.h"
@@ -22,4 +23,6 @@ OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> )
// used by interfaces to request user prompt
#define ACT_PROMPT 3
+// used by interfaces to trigger VPN
+#define ACT_VPN 4
int main( int argc, char * argv[] ) {
@@ -45,4 +48,7 @@ int main( int argc, char * argv[] ) {
Action = ACT_PROMPT;
rmv = 1;
+ } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) {
+ Action = ACT_VPN;
+ rmv = 1;
}
if( rmv ) {
@@ -79,8 +85,6 @@ int main( int argc, char * argv[] ) {
case ACT_REQUEST :
{ NetworkSettingsData NS;
- Log(("ACT_REQUEST\n"));
if( NS.canStart( argv[1] ) ) {
QString S;
- Log(("NEED FOR PROMPT\n" ));
S.sprintf( QPEApplication::qpeDir()+
"/bin/networksettings2" );
@@ -98,5 +102,4 @@ int main( int argc, char * argv[] ) {
case ACT_REGEN :
{ NetworkSettingsData NS;
- Log(("REGEN\n" ));
// regen returns 0 if OK
rv = (NS.regenerate()) ? 1 : 0;
@@ -105,5 +108,4 @@ int main( int argc, char * argv[] ) {
case ACT_PROMPT :
{ ActivateProfile AP(argv[1]);
- Log(("PROMPT\n" ));
if( AP.exec() == QDialog::Accepted ) {
printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() );
@@ -113,7 +115,11 @@ int main( int argc, char * argv[] ) {
}
break;
+ case ACT_VPN :
+ { ActivateVPN AVPN;
+ AVPN.exec();
+ }
+ break;
case ACT_GUI :
{ QWidget * W = new NetworkSettings(0);
- Log(("GUI\n" ));
TheApp->setMainWidget( W );
W->show();
diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp
index 18aa480..ee61b10 100644
--- a/noncore/settings/networksettings2/modem/modem_NN.cpp
+++ b/noncore/settings/networksettings2/modem/modem_NN.cpp
@@ -38,15 +38,4 @@ const char * ModemNetNode::provides( void ) {
}
-bool ModemNetNode::generateProperFilesFor(
- ANetNodeInstance * ) {
- return 0;
-}
-
-bool ModemNetNode::generateDeviceDataForCommonFile(
- SystemFile & ,
- long ) {
- return 0;
-}
-
void ModemNetNode::setSpecificAttribute( QString & , QString & ) {
}
diff --git a/noncore/settings/networksettings2/modem/modem_NN.h b/noncore/settings/networksettings2/modem/modem_NN.h
index 2f496dd..a76525f 100644
--- a/noncore/settings/networksettings2/modem/modem_NN.h
+++ b/noncore/settings/networksettings2/modem/modem_NN.h
@@ -19,16 +19,8 @@ public:
virtual const QString nodeDescription() ;
-
virtual ANetNodeInstance * createInstance( void );
-
virtual const char ** needs( void );
virtual const char * provides( void );
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
- virtual bool hasDataFor( const QString & )
- { return 0; }
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr );
-
private:
diff --git a/noncore/settings/networksettings2/modem/modem_NNI.cpp b/noncore/settings/networksettings2/modem/modem_NNI.cpp
index 6c76b56..91df22b 100644
--- a/noncore/settings/networksettings2/modem/modem_NNI.cpp
+++ b/noncore/settings/networksettings2/modem/modem_NNI.cpp
@@ -30,8 +30,2 @@ void AModem::commit( void ) {
}
-bool AModem::generateDataForCommonFile(
- SystemFile & ,
- long ) {
- return 1;
-}
-
diff --git a/noncore/settings/networksettings2/modem/modem_NNI.h b/noncore/settings/networksettings2/modem/modem_NNI.h
index a623704..ca7c279 100644
--- a/noncore/settings/networksettings2/modem/modem_NNI.h
+++ b/noncore/settings/networksettings2/modem/modem_NNI.h
@@ -15,22 +15,16 @@ public :
AModem( ModemNetNode * PNN );
+ RuntimeInfo * runtime( void )
+ { return
+ ( RT ) ? RT : ( RT = new ModemRun( this, Data ) );
+ }
+
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
- RuntimeInfo * runtime( void )
- { if( RT == 0 )
- RT = new ModemRun( this, Data );
- return RT;
- }
-
virtual void * data( void )
{ return (void *)&Data; }
- virtual bool hasDataFor( const QString & )
- { return 0; }
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr );
-
protected :
diff --git a/noncore/settings/networksettings2/modem/modemrun.h b/noncore/settings/networksettings2/modem/modemrun.h
index 336462e..491a677 100644
--- a/noncore/settings/networksettings2/modem/modemrun.h
+++ b/noncore/settings/networksettings2/modem/modemrun.h
@@ -13,4 +13,7 @@ public :
{ return (AsLine *)this; }
+ virtual QString deviceFile( void )
+ { return QString("/dev/modem"); }
+
protected :
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp
index b4313c4..1feffdb 100644
--- a/noncore/settings/networksettings2/network/network_NN.cpp
+++ b/noncore/settings/networksettings2/network/network_NN.cpp
@@ -1,2 +1,3 @@
+#include <asdevice.h>
#include "network_NN.h"
#include "network_NNI.h"
@@ -31,21 +32,40 @@ ANetNodeInstance * NetworkNetNode::createInstance( void ) {
}
-const char ** NetworkNetNode::needs( void ) {
- return NetworkNeeds;
+bool NetworkNetNode::hasDataForFile( const QString & S ) {
+ return S == "interfaces";
}
-const char * NetworkNetNode::provides( void ) {
- return "connection";
-}
+short NetworkNetNode::generateFile( const QString & ID,
+ const QString & ,
+ QTextStream & TS,
+ ANetNodeInstance * NNI,
+ long DevNr ) {
+
+ QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
-bool NetworkNetNode::generateProperFilesFor(
- ANetNodeInstance * ) {
+ if( ID == "interfaces" ) {
+ Log(("Generate entry for %s in %s\n", NIC.latin1(), ID.latin1() ));
+ // generate mapping stanza for this interface
+ TS << "# check if "
+ << NIC
+ << " can be brought UP"
+ << endl;
+ TS << "mapping "
+ << NIC
+ << endl;
+ TS << " script networksettings2-request"
+ << endl
+ << endl;
return 0;
}
+ return 1;
+}
-bool NetworkNetNode::generateDeviceDataForCommonFile(
- SystemFile & ,
- long ) {
- return 0;
+const char ** NetworkNetNode::needs( void ) {
+ return NetworkNeeds;
+}
+
+const char * NetworkNetNode::provides( void ) {
+ return "connection";
}
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
@@ -15,20 +15,19 @@ public:
virtual ~NetworkNetNode();
+ virtual bool hasDataForFile( const QString & S );
+
+ virtual short generateFile( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ ANetNodeInstance * NNI,
+ long DevNr );
virtual const QString pixmapName()
{ return "Devices/tcpip"; }
virtual const QString nodeDescription() ;
-
virtual ANetNodeInstance * createInstance( void );
-
virtual const char ** needs( void );
virtual const char * provides( void );
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
- virtual bool hasDataFor( const QString & )
- { return 0; }
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr );
-
private:
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp
index 3e368a2..324c6e2 100644
--- a/noncore/settings/networksettings2/network/network_NNI.cpp
+++ b/noncore/settings/networksettings2/network/network_NNI.cpp
@@ -100,15 +100,23 @@ void ANetwork::commit( void ) {
}
-bool ANetwork::hasDataFor( const QString & S ) {
+bool ANetwork::hasDataForFile( const QString & S ) {
return S == "interfaces";
}
-bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) {
+short ANetwork::generateFile( const QString & ID,
+ const QString & Path,
+ QTextStream &TS,
+ long DevNr
+ ) {
+
+ short rvl, rvd ;
QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
- if( S.name() == "interfaces" ) {
+ rvl = 1;
+ if( ID == "interfaces" ) {
+ Log(("Generate Network for %s\n", ID.latin1() ));
// we can safely call from here since device item is deeper
if( Data.UseDHCP ) {
- S << "iface "
+ TS << "iface "
<< NIC
<< "-c"
@@ -116,5 +124,5 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) {
<< "-allowed inet dhcp"
<< endl;
- S << " up echo \""
+ TS << " up echo \""
<< NIC
<< "\" > /tmp/profile-"
@@ -123,20 +131,20 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) {
<< endl;
if( Data.SendHostname ) {
- S << " hostname "
+ TS << " hostname "
<< Data.Hostname
<< endl;
}
- S << " down rm -f /tmp/profile-"
+ TS << " down rm -f /tmp/profile-"
<< connection()->number()
<< ".up"
<< endl;
} else {
- S << "iface "
+ TS << "iface "
<< NIC << "-c"
<< connection()->number()
<< "-allowed inet static"
<< endl;
- S << " up echo \""
+ TS << " up echo \""
<< NIC
<< "\" > /tmp/profile-"
@@ -144,11 +152,17 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) {
<< ".up"
<< endl;
- S << " down rm -f /tmp/profile-"
+ TS << " down rm -f /tmp/profile-"
<< connection()->number()
<< ".up"
<< endl;
- S << " address " << Data.IPAddress << endl;
- S << " broadcast " << Data.Broadcast << endl;
- S << " netmask " << Data.NetMask << endl;
+ TS << " address "
+ << Data.IPAddress
+ << endl;
+ TS << " broadcast "
+ << Data.Broadcast
+ << endl;
+ TS << " netmask "
+ << Data.NetMask
+ << endl;
// derive network address = IPAddress & netmask
@@ -162,5 +176,7 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) {
arg( ipal[2].toShort() & nmal[2].toShort() ).
arg( ipal[3].toShort() & nmal[3].toShort() );
- S << " network " << NW << endl;
+ TS << " network "
+ << NW
+ << endl;
}
}
@@ -168,22 +184,36 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) {
it != Data.PreUp_SL.end();
++it ) {
- S << " pre-up " << (*it) << endl;
+ TS << " pre-up "
+ << (*it)
+ << endl;
}
for ( QStringList::Iterator it = Data.PostUp_SL.begin();
it != Data.PostUp_SL.end();
++it ) {
- S << " up " << (*it) << endl;
+ TS << " up "
+ << (*it)
+ << endl;
}
for ( QStringList::Iterator it = Data.PreDown_SL.begin();
it != Data.PreDown_SL.end();
++it ) {
- S << " down " << (*it) << endl;
+ TS << " down "
+ << (*it)
+ << endl;
}
for ( QStringList::Iterator it = Data.PostDown_SL.begin();
it != Data.PostDown_SL.end();
++it ) {
- S << " post-down " << (*it) << endl;
+ TS << " post-down "
+ << (*it)
+ << endl;
}
+ rvl = 0;
}
- return 0;
+
+ // embed other info in it
+ rvd = connection()->getToplevel()->generateFileEmbedded( ID, Path, TS, DevNr );
+
+ return (rvd == 2 || rvl == 2 ) ? 2 :
+ (rvd == 0 || rvl == 0 ) ? 0 : 1;
}
diff --git a/noncore/settings/networksettings2/network/network_NNI.h b/noncore/settings/networksettings2/network/network_NNI.h
index 0058793..5e42503 100644
--- a/noncore/settings/networksettings2/network/network_NNI.h
+++ b/noncore/settings/networksettings2/network/network_NNI.h
@@ -16,20 +16,21 @@ public :
ANetwork( NetworkNetNode * PNN );
+ RuntimeInfo * runtime( void )
+ { return
+ ( RT ) ? RT : ( RT = new NetworkRun( this, Data ) );
+ }
+
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
- RuntimeInfo * runtime( void )
- { if( RT == 0 )
- RT = new NetworkRun( this, Data );
- return RT;
- }
-
virtual void * data( void )
{ return (void *)&Data; }
- virtual bool hasDataFor( const QString & S );
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr );
+ virtual bool hasDataForFile( const QString & S );
+ virtual short generateFile( const QString & ID,
+ const QString & Path,
+ QTextStream &TS,
+ long DevNr );
protected :
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index 6ee4106..ce0eabc 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -1,4 +1,5 @@
#include <stdio.h>
#include <unistd.h>
+#include <errno.h>
#include <qpe/qpeapplication.h>
@@ -13,4 +14,5 @@
#include <qpe/qpeapplication.h>
#include <qtoolbutton.h>
+#include <qevent.h>
#include <asdevice.h>
@@ -42,4 +44,11 @@ NetworkSettings::NetworkSettings( QWidget *parent,
// populate main Listbox
Profiles_LB->clear();
+ QPEApplication::setStylusOperation(
+ Profiles_LB->viewport(), QPEApplication::RightOnHold );
+
+ connect( Profiles_LB,
+ SIGNAL(rightButtonPressed(QListBoxItem*,const QPoint&)),
+ this, SLOT(SLOT_EditNode(QListBoxItem*)) );
+
{ Name2Connection_t & M = NSResources->connections();
NodeCollection * NC;
@@ -79,13 +88,5 @@ NetworkSettings::~NetworkSettings() {
QString S;
- S = NSD.generateSettings();
- if( ! S.isEmpty() ) {
- QMessageBox::warning(
- 0,
- tr( "In System Config" ),
- S
- );
- }
-
+ if( isModified() ) {
S = NSD.saveSettings();
if( ! S.isEmpty() ) {
@@ -95,4 +96,8 @@ NetworkSettings::~NetworkSettings() {
tr( "Saving setup" ), S );
}
+
+ SLOT_GenerateConfig();
+ }
+
}
@@ -146,7 +151,4 @@ void NetworkSettings::SLOT_RefreshStates( void ) {
}
-void NetworkSettings::SLOT_NoLongerBusy( void ) {
- NSResources->busy( FALSE );
-}
void NetworkSettings::SLOT_AddNode( void ) {
SLOT_EditNode( 0 );
@@ -167,5 +169,4 @@ void NetworkSettings::SLOT_DeleteNode( void ) {
delete LBI;
setModified( 1 );
- NSD.forceGeneration(1);
}
}
@@ -173,4 +174,6 @@ void NetworkSettings::SLOT_DeleteNode( void ) {
void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
QString OldName = "";
+
+ printf( "------------------ Edit NOde\n" );
EditConnection EC( this );
@@ -187,6 +190,5 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
// disable refresh timer
UpdateTimer->stop();
- NSResources->busy( TRUE );
- QTimer::singleShot( 1000, this, SLOT( SLOT_NoLongerBusy() ));
+
// we need to retry
while( 1 ) {
@@ -320,13 +322,5 @@ void NetworkSettings::updateProfileState( QListBoxItem * LBI ) {
void NetworkSettings::SLOT_GenerateConfig( void ) {
- QString S = NSD.generateSettings( TRUE );
-
- if( ! S.isEmpty() ) {
- QMessageBox::warning(
- 0,
- tr( "Generating system configuration" ),
- S
- );
- }
+ NSD.regenerate();
}
diff --git a/noncore/settings/networksettings2/networksettings.h b/noncore/settings/networksettings2/networksettings.h
index 8ffde06..8ec5d08 100644
--- a/noncore/settings/networksettings2/networksettings.h
+++ b/noncore/settings/networksettings2/networksettings.h
@@ -7,4 +7,5 @@ class ANetNodeInstance;
class QTimer;
class QListBoxItem;
+class QEvent;
class NetworkSettings : public NetworkSettingsGUI {
@@ -29,5 +30,4 @@ public :
public slots :
- void SLOT_NoLongerBusy( void );
void SLOT_AddNode( void );
void SLOT_DeleteNode( void );
@@ -51,4 +51,3 @@ private :
QTimer * UpdateTimer;
NetworkSettingsData NSD;
-
};
diff --git a/noncore/settings/networksettings2/networksettings.pro b/noncore/settings/networksettings2/networksettings.pro
index ff147b1..f04289b 100644
--- a/noncore/settings/networksettings2/networksettings.pro
+++ b/noncore/settings/networksettings2/networksettings.pro
@@ -4,4 +4,5 @@ CONFIG = qt warn_on debug
HEADERS = networksettings.h \
activateprofile.h \
+ activatevpn.h \
editconnection.h
SOURCES = main.cpp \
@@ -9,4 +10,5 @@ SOURCES = main.cpp \
nsdata.cpp \
activateprofile.cpp \
+ activatevpn.cpp \
editconnection.cpp
INCLUDEPATH += $(OPIEDIR)/include networksettings2/
@@ -15,4 +17,5 @@ LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings2 -lnetworksettings2 -l
INTERFACES = networksettingsGUI.ui \
editconnectionGUI.ui \
+ activatevpnGUI.ui \
activateprofileGUI.ui
TARGET = $(OPIEDIR)/bin/networksettings2
diff --git a/noncore/settings/networksettings2/networksettings2/Utils.h b/noncore/settings/networksettings2/networksettings2/Utils.h
index 63ef51c..739476e 100644
--- a/noncore/settings/networksettings2/networksettings2/Utils.h
+++ b/noncore/settings/networksettings2/networksettings2/Utils.h
@@ -5,4 +5,5 @@
extern void VLog( char * Format, ... );
extern void LogClose( void );
+extern QString removeSpaces( const QString & X );
#endif
diff --git a/noncore/settings/networksettings2/networksettings2/asline.h b/noncore/settings/networksettings2/networksettings2/asline.h
index 6bd93ec..ee4de38 100644
--- a/noncore/settings/networksettings2/networksettings2/asline.h
+++ b/noncore/settings/networksettings2/networksettings2/asline.h
@@ -14,4 +14,6 @@ public :
}
+ virtual QString deviceFile( void ) = 0;
+
};
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp
index 8c80e0b..4a2440a 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.cpp
+++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp
@@ -145,5 +145,5 @@ NodeCollection::NodeCollection( QTextStream & TS ) :
Name = N;
} else if( A == "number" ) {
- Log(( "read number %s\n", N.latin1() ));
+ Log(( "Profile number %s\n", N.latin1() ));
setNumber( N.toLong() );
} else if( A == "node" ) {
@@ -298,4 +298,23 @@ bool NodeCollection::triggersVPN() {
return getToplevel()->runtime()->asFullSetup()->triggersVPN();
}
+
+bool NodeCollection::hasDataForFile( const QString & S ) {
+ return ( firstWithDataForFile( S ) != 0 );
+}
+
+ANetNodeInstance * NodeCollection::firstWithDataForFile( const QString & S ) {
+ for( QListIterator<ANetNodeInstance> it(*this);
+ it.current();
+ ++it ) {
+ if( it.current()->hasDataForFile( S ) ) {
+ Log(( "Node %s has data for %s\n",
+ it.current()->nodeClass()->name(),
+ S.latin1() ));
+ return it.current();
+ }
+ }
+ return 0;
+}
+
//
//
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index ca35c27..d3d7b34 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -6,4 +6,5 @@
#include <qdict.h>
#include <qpixmap.h>
+#include <qstringlist.h>
#include <qobject.h>
#include <time.h>
@@ -78,30 +79,56 @@ public:
virtual ~ANetNode(){};
- // pixmap needed for this NetNode
- virtual const QString pixmapName() = 0;
+ //
+ //
+ // standard methods with sensible default
+ //
+ //
- // description for this NetNode
- virtual const QString nodeDescription() = 0;
+ inline int done( void )
+ { return Done; }
+ inline void setDone( int D )
+ { Done = D; }
- // create a blank instance of a net node
- virtual ANetNodeInstance * createInstance( void ) = 0;
+ // does this Node provide a Connection
+ inline bool isToplevel( void )
+ { return strcmp( provides(), "fullsetup") == 0 ; }
- // return feature this NetNode provides
- virtual const char * provides( void ) = 0;
- virtual const char ** needs( void ) = 0;
+ // set the value of an attribute
+ void setAttribute( QString & Attr, QString & Value ) ;
+ void saveAttributes( QTextStream & TS ) ;
- // generate files specific for this node (if any)
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0;
- // return TRUE if this node has data to be inserted in systemfile
- // with name S
- virtual bool hasDataFor( const QString & S ) = 0;
- // generate data specific for the device for the system file S
- // called only IF data was needed
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr ) = 0;
+ // compiled references to 'needed' NetNodes -> needs list
+ inline void setAlternatives( NetNodeList * Alt )
+ { Alternatives = Alt; }
+ inline NetNodeList & alternatives( void )
+ { return *Alternatives; }
+
+ //
+ //
+ // Virtual methods with sensible default
+ //
+ //
+
+ // do instances of this noce class have data for this file
+ virtual bool hasDataForFile( const QString & )
+ { return 0; }
+
+ // generate instance independent stuff
+ // 0 : data output, 1 no data, 2 error
+ virtual short generateFile( const QString & ,
+ const QString & ,
+ QTextStream & ,
+ long )
+ { return 1; }
+
+ // generate instance dependent but profile common stuff
+ // 0 : data output, 1 no data, 2 error
+ virtual short generateFile( const QString & ,
+ const QString & ,
+ QTextStream & ,
+ ANetNodeInstance * ,
+ long )
+ { return 1; }
- // does this Node provide a Connection
- bool isToplevel( void )
- { return strcmp( provides(), "fullsetup") == 0 ; }
// generate NIC name based on instance nr
@@ -115,13 +142,26 @@ public:
{ return 1; }
- // set the value of an attribute
- void setAttribute( QString & Attr, QString & Value ) ;
- void saveAttributes( QTextStream & TS ) ;
+ // return list of files that are specific for this node class
+ virtual QStringList * properFiles( void )
+ { return 0; }
- // compiled references to 'needed' NetNodes -> needs list
- void setAlternatives( NetNodeList * Alt )
- { Alternatives = Alt; }
- NetNodeList & alternatives( void )
- { return *Alternatives; }
+ //
+ //
+ // pure virtual methods with sensible default
+ //
+ //
+
+ // pixmap needed for this NetNode
+ virtual const QString pixmapName() = 0;
+
+ // description for this NetNode
+ virtual const QString nodeDescription() = 0;
+
+ // create a blank instance of a net node
+ virtual ANetNodeInstance * createInstance( void ) = 0;
+
+ // return feature this NetNode provides
+ virtual const char * provides( void ) = 0;
+ virtual const char ** needs( void ) = 0;
protected :
@@ -133,4 +173,5 @@ private :
virtual void setSpecificAttribute( QString & , QString & ) = 0;
virtual void saveSpecificAttribute( QTextStream & ) = 0;
+ int Done;
};
@@ -144,25 +185,15 @@ public:
virtual ~ANetNodeInstance( void ) { }
- virtual RuntimeInfo * runtime( void ) = 0;
-
- void setConnection( NodeCollection * NC )
- { Connection = NC; }
- NodeCollection * connection( void )
- { return Connection; }
-
- // create edit widget under parent
- virtual QWidget * edit( QWidget * parent ) = 0;
- // is given data acceptable
- virtual QString acceptable( void ) = 0;
+ inline int done( void )
+ { return Done; }
+ inline void setDone( int D )
+ { Done = D; }
// return data was modified
- void setModified( bool M )
+ inline void setModified( bool M )
{ IsModified = M; }
- bool isModified( void )
+ inline bool isModified( void )
{ return IsModified; }
- // get data from GUI and store in node
- virtual void commit( void ) = 0;
-
// get next node
ANetNodeInstance * nextNode();
@@ -179,36 +210,92 @@ public:
// return true if node isntance is NEW and not loaded
- void setNew( bool IsN )
+ inline void setNew( bool IsN )
{ IsNew = IsN; }
- bool isNew( void )
+ inline bool isNew( void )
{ return IsNew; }
// return description for this instance
- QString & description( void )
+ inline QString & description( void )
{ return Description; }
- void setDescription( const QString & S )
+ inline void setDescription( const QString & S )
{ Description = S; }
// pixmap for this instance -> from NetNode
- const QString pixmapName( void )
+ inline const QString pixmapName( void )
{ return NodeType->pixmapName(); }
- const char * provides( void )
+ inline const char * provides( void )
{ return NodeType->provides(); }
- const char ** needs( void )
+ inline const char ** needs( void )
{ return NodeType->needs(); }
- // returns node specific data -> only useful for 'buddy'
- virtual void * data( void ) = 0;
+ inline void setConnection( NodeCollection * NC )
+ { Connection = NC; }
+ inline NodeCollection * connection( void )
+ { return Connection; }
+
+ //
+ //
+ // Virtual methods with sensible defaults
+ //
+ //
- // return TRUE if this node has data to be inserted in systemfile
- // with name S
- virtual bool hasDataFor( const QString & S ) = 0;
- // generate data specific for a profile and for the system file S
- // called only IF data was needed
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr ) = 0;
+
+ // open proper file identified by S
+ virtual QFile * openFile( const QString & )
+ { return 0; }
+
+ // check if this node (or sub nodes) have data for this file
+ virtual bool hasDataForFile( const QString & S )
+ { return nodeClass()->hasDataForFile( S ); }
+
+ // generate code specific for this node but embedded
+ // in the section of the parent
+ // this is called within the code of the parent
+ virtual short generateFileEmbedded( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr )
+ { ANetNodeInstance * NNI = nextNode();
+ return (NNI) ? NNI->generateFileEmbedded( ID, Path, TS, DevNr ) : 1;
+ }
+
+ // generate code specific for this node
+ // (or find the first node that does)
+ virtual short generateFile( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr )
+ { ANetNodeInstance * NNI = nextNode();
+ return (NNI) ? NNI->generateFile( ID, Path, TS, DevNr ) : 1;
+ }
+
+ // return true if this node instance is triggered by this trigger
+ // could be delegated to deeper instances
+ virtual bool triggeredBy( const QString & )
+ { return 0; }
+
+ //
+ //
+ // Pure virtual functions
+ //
+ //
+
+ // return runtime information for this node
+ virtual RuntimeInfo * runtime( void ) = 0;
+
+ // create edit widget under parent
+ virtual QWidget * edit( QWidget * parent ) = 0;
+
+ // is given data acceptable
+ virtual QString acceptable( void ) = 0;
+
+ // get data from GUI and store in node
+ virtual void commit( void ) = 0;
+
+ // returns node specific data -> only useful for 'buddy'
+ virtual void * data( void ) = 0;
protected :
@@ -223,4 +310,5 @@ protected :
bool IsModified;
bool IsNew;
+ int Done;
static long InstanceCounter;
@@ -283,26 +371,31 @@ public :
~NodeCollection( void );
- int number( void )
+ inline int done( void )
+ { return Done; }
+ inline void setDone( int D )
+ { Done = D; }
+
+ inline int number( void )
{ return Number; }
- void setNumber( int i )
+ inline void setNumber( int i )
{ Number = i; }
- bool isNew( void )
+ inline bool isNew( void )
{ return IsNew; }
- void setNew( bool N )
+ inline void setNew( bool N )
{ IsNew = N ; }
- bool isModified( void )
+ inline bool isModified( void )
{ return IsModified; }
- void setModified( bool N )
+ inline void setModified( bool N )
{ IsModified = N ; }
- bool handlesInterface( const QString & S ) {
+ inline bool handlesInterface( const QString & S ) {
return getToplevel()->runtime()->handlesInterface( S );
}
- InterfaceInfo * assignedInterface( void ) {
+ inline InterfaceInfo * assignedInterface( void ) {
return getToplevel()->runtime()->assignedInterface();
}
- AsDevice * device() {
+ inline AsDevice * device() {
return getToplevel()->runtime()->device();
}
@@ -310,5 +403,5 @@ public :
bool triggersVPN();
- State_t state( bool Update = 0 )
+ inline State_t state( bool Update = 0 )
{ Log(( "%s state %d(=%d?)\n", Name.latin1(), CurrentState,
Unchecked ));
@@ -326,13 +419,13 @@ public :
QPixmap devicePixmap( void );
QPixmap statePixmap( State_t S );
- QPixmap statePixmap( bool Update = 0 )
+ inline QPixmap statePixmap( bool Update = 0 )
{ return statePixmap( state(Update) ); }
QString stateName( State_t );
- QString stateName( bool Update = 0 )
+ inline QString stateName( bool Update = 0 )
{ return stateName( state(Update) ); }
- bool setState( Action_t A, bool Force =0 )
+ inline bool setState( Action_t A, bool Force =0 )
{ return getToplevel()->runtime()->setState( this, A, Force ); }
- bool canSetState( Action_t A )
+ inline bool canSetState( Action_t A )
{ return getToplevel()->runtime()->canSetState( CurrentState, A ); }
@@ -349,17 +442,33 @@ public :
ANetNodeInstance * findByName( const QString & S );
- const QString & name()
+ inline const QString & name()
{ return Name; }
const QString & description( void );
- void setName( const QString & N)
+ inline void setName( const QString & N)
{ Name = N; }
- State_t currentState( void )
+ inline State_t currentState( void )
{ return CurrentState; }
- void setCurrentState( State_t S )
+ inline void setCurrentState( State_t S )
{ CurrentState = S; }
+ // return TRUE if this node can have data to be inserted in
+ // file identified by S
+ bool hasDataForFile( const QString & S );
+ ANetNodeInstance * firstWithDataForFile( const QString & S );
+
+ // generate items for this file -> toplevel call
+ short generateFile( const QString & FID, // identification of file
+ const QString & FName, // effective filename of file
+ QTextStream & TS, // stream to file
+ long DN // device number
+ )
+ { return getToplevel()->generateFile( FID, FName, TS, DN ); }
+
+ bool triggeredBy( const QString & Trigger )
+ { return getToplevel()->triggeredBy( Trigger ); }
+
private :
@@ -379,4 +488,5 @@ private :
int Index;
bool IsModified;
+ int Done;
};
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp
index 71e84cd..7ece817 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.cpp
+++ b/noncore/settings/networksettings2/networksettings2/resources.cpp
@@ -78,5 +78,5 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
// define system files
- addSystemFile( new SystemFile( "interfaces", "./interfaces" ) );
+ addSystemFile( "interfaces", "/tmp/interfaces", 1 );
// get access to the system
@@ -89,5 +89,14 @@ TheNSResources::~TheNSResources( void ) {
}
-void TheNSResources::busy( bool B ) {
+void TheNSResources::addSystemFile( const QString & ID,
+ const QString & P,
+ bool KDI ) {
+ if( ! SystemFiles.find( ID ) ) {
+ // new system file
+ SystemFiles.insert( ID, new SystemFile( ID, P, KDI ) );
+ } // else existed
+}
+
+void TheNSResources::busy( bool ) {
/*
if( B ) {
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h
index 55d2f29..16355ba 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.h
+++ b/noncore/settings/networksettings2/networksettings2/resources.h
@@ -67,6 +67,7 @@ public :
Name2SystemFile_t & systemFiles( void )
{ return SystemFiles; }
- void addSystemFile( SystemFile * SF )
- { SystemFiles.insert( SF->name(), SF ); }
+ void addSystemFile( const QString & ID,
+ const QString & P,
+ bool KDI );
ANetNodeInstance * createNodeInstance( const QString & S )
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp
index a579396..271e73d 100644
--- a/noncore/settings/networksettings2/networksettings2/system.cpp
+++ b/noncore/settings/networksettings2/networksettings2/system.cpp
@@ -391,6 +391,9 @@ void VLog( char * Format, ... ) {
if( logf == (FILE *)0 ) {
- // logf = fopen( "/tmp/ns2log", "a" );
+ if( getenv("NS2STDERR") ) {
logf = stderr;
+ } else {
+ logf = fopen( "/tmp/ns2log", "a" );
+ }
if( ! logf ) {
fprintf( stderr, "Cannot open logfile /tmp/ns2log %d\n",
@@ -412,6 +415,15 @@ void LogClose( void ) {
if( (long)logf > 1 ) {
fprintf( logf, "____ CLOSE LOGFILE ____\n");
+ if( logf != stderr ) {
fclose( logf );
+ }
logf = 0;
}
}
+
+QString removeSpaces( const QString & X ) {
+ QStringList SL;
+
+ SL = QStringList::split( " ", X );
+ return SL.join( "_" );
+}
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
index b3fc1a5..2b40834 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
@@ -12,5 +12,7 @@
QString TemplDir;
-SystemFile::SystemFile( const QString & N, const QString & P ){
+SystemFile::SystemFile( const QString & N,
+ const QString & P,
+ bool KDI ){
Name = N;
Path = P;
@@ -58,4 +60,6 @@ SystemFile::SystemFile( const QString & N, const QString & P ){
hasPostDeviceSection = ( FI.exists() && FI.isReadable() );
}
+
+ KnowsDeviceInstances = KDI;
}
@@ -97,9 +101,9 @@ bool SystemFile::preSection( void ) {
QFile Fl( TemplDir + Name + "/presection" );
if( ! Fl.open( IO_ReadOnly ) )
- return 1; // error
+ return 0; // error
// copy file to this file
F->writeBlock( Fl.readAll() );
}
- return 0;
+ return 1;
}
@@ -108,9 +112,9 @@ bool SystemFile::postSection( void ) {
QFile Fl( TemplDir + Name + "/postsection" );
if( ! Fl.open( IO_ReadOnly ) )
- return 1; // error
+ return 0; // error
// copy file to this file
F->writeBlock( Fl.readAll() );
}
- return 0;
+ return 1;
}
@@ -119,5 +123,5 @@ bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) {
QFile Fl( TemplDir + Name + "/prenodesection" );
if( ! Fl.open( IO_ReadOnly ) )
- return 1; // error
+ return 0; // error
QTextStream TX( &Fl );
QString Out;
@@ -130,5 +134,5 @@ bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) {
}
}
- return 0;
+ return 1;
}
@@ -137,5 +141,5 @@ bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) {
QFile Fl( TemplDir + Name + "/postnodesection" );
if( ! Fl.open( IO_ReadOnly ) )
- return 1; // error
+ return 0; // error
QTextStream TX( &Fl );
QString Out;
@@ -148,5 +152,5 @@ bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) {
}
}
- return 0;
+ return 1;
}
@@ -155,5 +159,5 @@ bool SystemFile::preDeviceSection( ANetNode * NN ) {
QFile Fl( TemplDir + Name + "/predevicesection" );
if( ! Fl.open( IO_ReadOnly ) )
- return 1; // error
+ return 0; // error
QTextStream TX( &Fl );
QString Out;
@@ -165,5 +169,5 @@ bool SystemFile::preDeviceSection( ANetNode * NN ) {
}
}
- return 0;
+ return 1;
}
@@ -172,5 +176,5 @@ bool SystemFile::postDeviceSection( ANetNode * NN ) {
QFile Fl( TemplDir + Name + "/postdevicesection" );
if( ! Fl.open( IO_ReadOnly ) )
- return 1; // error
+ return 0; // error
QTextStream TX( &Fl );
QString Out;
@@ -182,4 +186,4 @@ bool SystemFile::postDeviceSection( ANetNode * NN ) {
}
}
- return 0;
+ return 1;
}
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.h b/noncore/settings/networksettings2/networksettings2/systemfile.h
index f57dab0..ceed605 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.h
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.h
@@ -12,9 +12,15 @@ class SystemFile : public QTextStream {
public :
- SystemFile( const QString & Name, const QString & Path );
+ SystemFile( const QString & Name,
+ const QString & Path,
+ bool KnowsDevicesInstances );
~SystemFile( void );
- const QString & name( void )
+ const QString & name( void ) const
{ return Name; }
+ const QString & path( void ) const
+ { return Path; }
+ bool knowsDeviceInstances( void ) const
+ { return KnowsDeviceInstances; }
bool open( void );
@@ -39,4 +45,5 @@ private :
bool hasPreDeviceSection;
bool hasPostDeviceSection;
+ bool KnowsDeviceInstances;
};
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index 3b17548..d709c0a 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -21,5 +21,4 @@ NetworkSettingsData::NetworkSettingsData( void ) {
// load settings
- Force = 0;
IsModified = 0;
loadSettings();
@@ -219,66 +218,20 @@ QString NetworkSettingsData::saveSettings( void ) {
}
-QString NetworkSettingsData::generateSettings( bool ForceReq ) {
- bool ForceIt;
+QString NetworkSettingsData::generateSettings( void ) {
QString S = "";
-
- // include own force flag
- ForceIt = (Force) ? 1 : ForceReq;
-
- if( ! ForceIt && ! isModified() )
- return S;
-
- // regenerate system files
- Log( ( "Generating settings from %s\n", CfgFile.latin1() ));
-
- { Name2SystemFile_t & SFM = NSResources->systemFiles();
+ Name2SystemFile_t & SFM = NSResources->systemFiles();
Name2Connection_t & M = NSResources->connections();
NodeCollection * NC;
ANetNodeInstance * NNI;
+ ANetNodeInstance * FirstWithData;
SystemFile * SF;
AsDevice * CurDev;
- ANetNode * CurDevNN;
- bool needToRegenerate = ForceIt;
+ ANetNode * NN, * CurDevNN = 0;
+ long NoOfDevs;
+ long DevCtStart;
+ bool needToGenerate;
- //
- // check if we need to generate at least one of the system files
- //
- if( ! ForceIt ) {
- for( QDictIterator<SystemFile> sfit(SFM);
- sfit.current();
- ++sfit ) {
- SF = sfit.current();
-
- // check if there are nodes that are modified and require
- // data for this system file
-
- // for all connections
- for( QDictIterator<NodeCollection> ncit(M);
- ncit.current();
- ++ncit ) {
- NC = ncit.current();
-
- if( NC->isModified() ) {
- // does this connection 'touch' this system file ?
- for( QListIterator<ANetNodeInstance> cncit(*NC);
- cncit.current();
- ++cncit ) {
- NNI = cncit.current();
- if( ( NNI->nodeClass()->hasDataFor( SF->name() ) ||
- NNI->hasDataFor( SF->name() )
- ) &&
- NNI->isModified() ) {
- needToRegenerate = 1;
- break;
- }
- }
- }
- if( needToRegenerate )
- break;
- }
- if( needToRegenerate )
- break;
- }
- }
+ // regenerate system files
+ Log( ( "Generating settings from %s\n", CfgFile.latin1() ));
//
@@ -289,17 +242,30 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
for( QDictIterator<ANetNodeInstance> NNIIt(NNIs);
NNIIt.current();
- ++NNIIt
- ){
+ ++NNIIt ) {
// for all nodes find those that are modified
NNI = NNIIt.current();
- if( ForceIt || NNI->isModified() ) {
- if( NNI->nodeClass()->generateProperFilesFor( NNI ) ) {
+ { // get list of proper files for this nodeclass (if any)
+ QStringList * PF = NNI->nodeClass()->properFiles();
+
+ if( PF ) {
+ for ( QStringList::Iterator it = PF->begin();
+ it != PF->end();
+ ++it ) {
+ QFile * F = NNI->openFile( (*it) );
+ if( F ) {
+ QTextStream TS( F );
+ if( NNI->generateFile( (*it), F->name(), TS, -1 ) == 2 ) {
// problem generating
S = qApp->translate( "NetworkSettings",
"<p>Cannot generate files proper to \"%1\"</p>" ).
arg(NNI->nodeClass()->name()) ;
+ delete F;
return S;
}
+ delete F;
+ }
+ }
+ }
}
}
@@ -314,69 +280,224 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
SF = sfit.current();
- Log( ( "Generating %s\n", SF->name().latin1() ));
- SF->open();
+ // reset all
+ for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() );
+ nnit.current();
+ ++nnit ) {
+ nnit.current()->NetNode->setDone(0);
+ }
- do { // so we can break;
+ for( QDictIterator<ANetNodeInstance> nniit(
+ NSResources->netNodeInstances() );
+ nniit.current();
+ ++nniit ) {
+ nniit.current()->setDone(0);
+ }
- // global presection for this system file
- if( SF->preSection() ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in preSection for file \"%1\"</p>" ).
- arg( SF->name() );
- return S;
+ for( QDictIterator<NodeCollection> ncit(M);
+ ncit.current();
+ ++ncit ) {
+ ncit.current()->setDone(0);
}
- // find all netnodes and figure out if
- // for that node there are instances
- for( QDictIterator<NetNode_t> nnit(
- NSResources->netNodes() );
- nnit.current();
+ Log( ( "Generating %s\n", SF->name().latin1() ));
+
+ needToGenerate = 0;
+
+ // are there netnodes that have instances and need
+ // to write data in this system file ?
+ for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() );
+ ! needToGenerate && nnit.current();
++nnit ) {
- CurDevNN = nnit.current()->NetNode;
+ NN = nnit.current()->NetNode;
+
+ if( NN->hasDataForFile( SF->name() ) ) {
+ // netnode can have data
- // are there instances for this netnode ?
- NNI = 0;
+ // are there instances of this node ?
for( QDictIterator<ANetNodeInstance> nniit(
NSResources->netNodeInstances() );
- nniit.current();
+ ! needToGenerate && nniit.current();
++nniit ) {
- if( nniit.current()->nodeClass() == CurDevNN ) {
- NNI = nniit.current();
+ if( nniit.current()->nodeClass() == NN ) {
+ // yes
+ Log(("Node %s has data\n",
+ nniit.current()->name() ));
+ needToGenerate = 1;
break;
}
}
+ }
+ }
- if( ! NNI )
- // no instances -> next netnode type
+ if( ! needToGenerate ) {
+ // no instances found that might need to write data
+ // in this systemfile
+ Log(("No nodes for systemfile %s\n", SF->name().latin1() ));
continue;
+ }
+
+ // ok generate this system file
+ SF->open();
- // has this node data for this system file ?
- if( (CurDev = NNI->runtime()->asDevice() ) ) {
- // generate start for this nodetype for all possible devices of this type
- for( int i = 0; i < CurDevNN->instanceCount(); i ++ ) {
- S = generateSystemFileNode( *SF, CurDev, NNI, i );
- if( ! S.isEmpty() )
+ // global presection for this system file
+ if( ! SF->preSection() ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in section \"Preamble\" for file \"%1\"</p>" ).
+ arg( SF->name() );
return S;
}
- } else {
- S = generateSystemFileNode( *SF, 0, NNI, -1 );
- if( ! S.isEmpty() )
+
+ // find connections that want to write to this file
+ for( QDictIterator<NodeCollection> ncit(M);
+ ncit.current();
+ ++ncit ) {
+
+ NC = ncit.current();
+
+ if( NC->done() ) {
+ // already done
+ continue;
+ }
+
+ if( ! NC->hasDataForFile( SF->name() ) ) {
+ // no data
+ continue;
+ }
+
+ Log(("Generating %s for connection %s\n",
+ SF->name().latin1(), NC->name().latin1() ));
+ // find highest item that wants to write data to this file
+ FirstWithData = NC->firstWithDataForFile( SF->name() );
+
+ // find device on which this connection works
+ CurDev = NC->device();
+ // class of that node
+ CurDevNN = CurDev->netNode()->nodeClass();
+
+ Log(( "%s is done %d\n",
+ FirstWithData->nodeClass()->name(),
+ FirstWithData->nodeClass()->done() ));
+
+ if( ! FirstWithData->nodeClass()->done() ) {
+ // generate fixed part
+ if( ! SF->preDeviceSection( CurDevNN ) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in section \"Pre-Device\" for file \"%1\"</p>" ).
+ arg( SF->name() );
return S;
}
+
+ if( FirstWithData->nodeClass()->generateFile(
+ SF->name(), SF->path(), *SF, -1 ) == 2 ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ).
+ arg( SF->name() ).
+ arg( CurDevNN->name() );
+ return S;
+ }
+ FirstWithData->nodeClass()->setDone( 1 );
+ }
+
+ NoOfDevs = 0;
+ DevCtStart = -1;
+
+ if( SF->knowsDeviceInstances() ) {
+ DevCtStart = 0;
+ NoOfDevs = CurDevNN->instanceCount();
}
- if( SF->postSection() ) {
+ Log(( "Node %s is done %d\n",
+ CurDev->netNode()->nodeClass()->name(),
+ CurDev->netNode()->nodeClass()->done() ));
+
+ if( ! CurDev->netNode()->nodeClass()->done() ) {
+ // first time this device is handled
+ // generate common device specific part
+ for( int i = DevCtStart; i < NoOfDevs ; i ++ ) {
+
+ if( FirstWithData->nodeClass()->generateFile(
+ SF->name(), SF->path(), *SF, CurDev->netNode(), i ) == 2 ) {
S = qApp->translate( "NetworkSettings",
- "<p>Error in postSection for file \"%1\"</p>" ).
+ "<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ).
+ arg( SF->name() ).
+ arg( CurDevNN->name() );
+ return S;
+ }
+ }
+ CurDev->netNode()->nodeClass()->setDone( 1 );
+ }
+
+ // generate profile specific info
+ // for all nodeconnections that work on the same device
+ for( QDictIterator<NodeCollection> ncit2(M);
+ ncit2.current();
+ ++ncit2 ) {
+
+ if( ncit2.current()->device() != CurDev ) {
+ // different device
+ continue;
+ }
+
+ Log(("Connection %s of same family\n", ncit2.current()->name().latin1() ));
+ // generate
+ NNI = ncit2.current()->firstWithDataForFile( SF->name() );
+ for( int i = DevCtStart; i < NoOfDevs ; i ++ ) {
+ if( ! SF->preNodeSection( NNI, i ) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
+ arg( SF->name() ).
+ arg( CurDevNN->name() );
+ return S;
+ }
+
+ switch( NNI->generateFile(
+ SF->name(), SF->path(), *SF, i ) ) {
+ case 0 :
+ (*SF) << endl;
+ break;
+ case 1 :
+ break;
+ case 2 :
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in section \"Node\" for file \"%1\" and node \"%2\"</p>" ).
+ arg( SF->name() ).
+ arg( CurDevNN->name() );
+ return S;
+ }
+
+ if( ! SF->postNodeSection( NNI, i ) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
+ arg( SF->name() ).
+ arg( CurDevNN->name() );
+ return S;
+ }
+ }
+
+ ncit2.current()->setDone( 1 );
+
+ }
+ }
+
+ if( ! SF->postDeviceSection( CurDevNN ) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in section \"Post-Device\" for file \"%1\" and node \"%2\"</p>" ).
+ arg( SF->name() ).
+ arg( CurDevNN->name() );
+ return S;
+ }
+
+
+ if( ! SF->postSection() ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in section \"Closure\" for file \"%1\"</p>" ).
arg( SF->name() );
return S;
}
- } while( 0 );
+ // end of file
SF->close();
}
- }
- Force = 0;
return S;
}
@@ -464,7 +585,5 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
bool NetworkSettingsData::regenerate( void ) {
- QString S;
- // load situation
- S = generateSettings( TRUE );
+ QString S = generateSettings();
if( ! S.isEmpty() ) {
fprintf( stdout, "%s\n", S.latin1() );
@@ -473,101 +592,2 @@ bool NetworkSettingsData::regenerate( void ) {
return 0;
}
-
-QString NetworkSettingsData::generateSystemFileNode(
- SystemFile &SF,
- AsDevice * CurDev,
- ANetNodeInstance * DevNNI,
- long DevInstNr ) {
-
- QString S="";
- ANetNode * CurDevNN = DevNNI->nodeClass();
- Name2Connection_t & M = NSResources->connections();
-
- if( SF.preDeviceSection( CurDevNN ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in \"Pre-Device Part\" for file \"%1\" and nodetype \"%2\"</p>" ).
- arg( SF.name() ).
- arg( CurDevNN->name() );
- return S;
- }
-
- if( CurDevNN->hasDataFor( SF.name() ) ) {
- if( CurDevNN->generateDeviceDataForCommonFile( SF, DevInstNr ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in \"Device Part\" for file \"%1\" and node \"%2\"</p>" ).
- arg( SF.name() ).
- arg( CurDevNN->name() );
- return S;
- }
- }
-
- // now generate profile specific data for all
- // connections working on a device of the current
- // netnode type
- for( QDictIterator<NodeCollection> ncit(M);
- ncit.current();
- ++ncit ) {
- NodeCollection * NC = ncit.current();
-
- // currenly only those connections that work on
- // the current device (or on no device if no current)
- AsDevice * Dev = NC->device();
-
- if( CurDev ) {
- if( CurDevNN != Dev->netNode()->nodeClass() ) {
- // other device type -> later
- continue;
- }
- } else {
- if( Dev ) {
- // other
- continue;
- }
- }
-
- // generate 'entry'
- if( SF.preNodeSection( DevNNI, DevInstNr ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
- arg( SF.name() ).
- arg( CurDevNN->name() );
- return S;
- }
-
- // ask all nodes in connection
- for( QListIterator<ANetNodeInstance> cncit(*NC);
- cncit.current();
- ++cncit ) {
- ANetNodeInstance * NNI = cncit.current();
-
- if( NNI->hasDataFor( SF.name() ) ) {
- if( NNI->generateDataForCommonFile(SF,DevInstNr) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in \"Node Part\" for file \"%1\" and node \"%2\"</p>" ).
- arg( SF.name() ).
- arg( NNI->nodeClass()->name() );
- return S;
- }
- }
- }
-
- if( SF.postNodeSection( DevNNI, DevInstNr ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
- arg( SF.name() ).
- arg( CurDevNN->name() );
- return S;
- }
- SF << endl;
- }
-
- if( SF.postDeviceSection( CurDevNN ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in \"Post-Device Part\" for file \"%1\" and node \"%2\"</p>" ).
- arg( SF.name() ).
- arg( CurDevNN->name() );
- return S;
- }
-
- return S;
-}
diff --git a/noncore/settings/networksettings2/nsdata.h b/noncore/settings/networksettings2/nsdata.h
index 57eb722..507185e 100644
--- a/noncore/settings/networksettings2/nsdata.h
+++ b/noncore/settings/networksettings2/nsdata.h
@@ -14,5 +14,5 @@ public :
QString saveSettings( void );
- QString generateSettings( bool Force = FALSE );
+ QString generateSettings( void );
bool isModified( void )
@@ -26,16 +26,7 @@ public :
bool regenerate( void );
- void forceGeneration( bool m )
- { Force = m; }
-
private :
- QString NetworkSettingsData::generateSystemFileNode(
- SystemFile & SF,
- AsDevice * CurDev,
- ANetNodeInstance * DevNNI,
- long DevInstNr );
bool IsModified;
- bool Force;
// collect strings in config file nobody wants
diff --git a/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui b/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui
index 826843a..0c5f4c8 100644
--- a/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui
+++ b/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui
@@ -12,5 +12,5 @@
<x>0</x>
<y>0</y>
- <width>249</width>
+ <width>245</width>
<height>209</height>
</rect>
@@ -58,9 +58,9 @@
<property stdset="1">
<name>margin</name>
- <number>0</number>
+ <number>3</number>
</property>
<property stdset="1">
<name>spacing</name>
- <number>0</number>
+ <number>2</number>
</property>
<widget>
@@ -192,14 +192,53 @@
</widget>
<widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout3</cstring>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QRadioButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Pap_RB</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Pap</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QRadioButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Chap_RB</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Chap</string>
+ </property>
+ </widget>
+ <widget>
<class>QRadioButton</class>
<property stdset="1">
<name>name</name>
- <cstring>PapChap_RB</cstring>
+ <cstring>EAP_RB</cstring>
</property>
<property stdset="1">
<name>text</name>
- <string>Pap/Chap/EAP</string>
+ <string>EAP</string>
</property>
</widget>
+ </hbox>
+ </widget>
<widget>
<class>QLayoutWidget</class>
@@ -276,7 +315,7 @@
<property stdset="1">
<name>spacing</name>
- <number>1</number>
+ <number>2</number>
</property>
- <widget row="2" column="0" >
+ <widget row="1" column="0" >
<class>QLabel</class>
<property stdset="1">
@@ -289,5 +328,5 @@
</property>
</widget>
- <widget row="3" column="0" >
+ <widget row="2" column="0" >
<class>QLabel</class>
<property stdset="1">
@@ -300,52 +339,23 @@
</property>
</widget>
- <widget row="0" column="1" >
- <class>QComboBox</class>
- <item>
- <property>
- <name>text</name>
- <string>PAP</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>CHAP</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>EAP</string>
- </property>
- </item>
- <property stdset="1">
- <name>name</name>
- <cstring>AuthMethod_CB</cstring>
- </property>
- </widget>
- <widget row="1" column="0" >
- <class>QLabel</class>
+ <widget row="1" column="1" >
+ <class>QLineEdit</class>
<property stdset="1">
<name>name</name>
- <cstring>TextLabel1</cstring>
+ <cstring>Server_LE</cstring>
</property>
<property stdset="1">
<name>text</name>
- <string>Client</string>
+ <string>*</string>
</property>
</widget>
- <widget row="0" column="0" >
- <class>QLabel</class>
+ <widget row="2" column="1" >
+ <class>QLineEdit</class>
<property stdset="1">
<name>name</name>
- <cstring>TextLabel1_4</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Method</string>
+ <cstring>Secret_LE</cstring>
</property>
</widget>
- <widget row="1" column="1" rowspan="1" colspan="2" >
+ <widget row="0" column="1" >
<class>QLineEdit</class>
<property stdset="1">
@@ -358,43 +368,15 @@
</property>
</widget>
- <widget row="2" column="1" rowspan="1" colspan="2" >
- <class>QLineEdit</class>
+ <widget row="0" column="0" >
+ <class>QLabel</class>
<property stdset="1">
<name>name</name>
- <cstring>Server_LE</cstring>
+ <cstring>TextLabel1</cstring>
</property>
<property stdset="1">
<name>text</name>
- <string>*</string>
- </property>
- </widget>
- <widget row="3" column="1" rowspan="1" colspan="2" >
- <class>QLineEdit</class>
- <property stdset="1">
- <name>name</name>
- <cstring>Secret_LE</cstring>
+ <string>Client</string>
</property>
</widget>
- <spacer row="0" column="2" >
- <property>
- <name>name</name>
- <cstring>Spacer7</cstring>
- </property>
- <property stdset="1">
- <name>orientation</name>
- <enum>Horizontal</enum>
- </property>
- <property stdset="1">
- <name>sizeType</name>
- <enum>Expanding</enum>
- </property>
- <property>
- <name>sizeHint</name>
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
</grid>
</widget>
@@ -418,5 +400,5 @@
<connections>
<connection>
- <sender>PapChap_RB</sender>
+ <sender>Pap_RB</sender>
<signal>toggled(bool)</signal>
<receiver>GroupBox3</receiver>
@@ -429,4 +411,16 @@
<slot>setEnabled(bool)</slot>
</connection>
+ <connection>
+ <sender>Chap_RB</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>GroupBox3</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>EAP_RB</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>GroupBox3</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
</connections>
</UI>
diff --git a/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp
index f305cc4..450d560 100644
--- a/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp
+++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp
@@ -10,4 +10,11 @@ PPPAuthEdit::PPPAuthEdit( QWidget * Parent ) : PPPAuthGUI( Parent ){
}
+bool PPPAuthEdit::PAP_Checked( void ) {
+ return ( Pap_RB->isChecked() ||
+ Chap_RB->isChecked() ||
+ EAP_RB->isChecked()
+ );
+}
+
QString PPPAuthEdit::acceptable( void ) {
if( Login_RB->isChecked() ) {
@@ -20,5 +27,5 @@ QString PPPAuthEdit::acceptable( void ) {
if( PasswordExpect_LE->text().isEmpty() )
return tr("Password expect missing");
- } else if( PapChap_RB->isChecked() ) {
+ } else if( PAP_Checked() ) {
if( Client_LE->text().isEmpty() )
return tr("Pap/Chap/EAP client id missing");
@@ -35,5 +42,5 @@ bool PPPAuthEdit::commit( PPPData_t & D ) {
if( ( D.Auth.Mode == 0 && ! Login_RB->isChecked() ) ||
- ( D.Auth.Mode == 1 && ! PapChap_RB->isChecked() ) ||
+ ( D.Auth.Mode == 1 && ! PAP_Checked() ) ||
( D.Auth.Mode == 2 && ! Terminal_RB->isChecked() ) ) {
// mode modifed
@@ -41,6 +48,5 @@ bool PPPAuthEdit::commit( PPPData_t & D ) {
D.Auth.Mode = ( Login_RB->isChecked() ) ?
0 :
- ( ( PapChap_RB->isChecked() ) ?
- 1 : 2 );
+ ( PAP_Checked() ) ? 1 : 2;
}
@@ -50,9 +56,15 @@ bool PPPAuthEdit::commit( PPPData_t & D ) {
TXTM( D.Auth.Password.Expect, PasswordExpect_LE, SM );
TXTM( D.Auth.Password.Send, PasswordSend_LE, SM );
- } else if( PapChap_RB->isChecked() ) {
+ } else if( PAP_Checked() ) {
TXTM( D.Auth.Client, Client_LE, SM );
TXTM( D.Auth.Server, Server_LE, SM );
TXTM( D.Auth.Secret, Secret_LE, SM );
- CIM( D.Auth.PCEMode, AuthMethod_CB, SM );
+ if( Pap_RB->isChecked() ) {
+ D.Auth.PCEMode = 0;
+ } else if( Chap_RB->isChecked() ) {
+ D.Auth.PCEMode = 1;
+ } else if( EAP_RB->isChecked() ) {
+ D.Auth.PCEMode = 2;
+ }
}
return SM;
@@ -63,11 +75,21 @@ void PPPAuthEdit::showData( PPPData_t & D ) {
switch( D.Auth.Mode ) {
case 0 :
- Login_RB->isChecked();
+ Login_RB->setChecked( TRUE );
+ break;
+ case 1 :
+ switch( D.Auth.PCEMode ) {
+ case 0 :
+ Pap_RB->setChecked( TRUE );
break;
case 1 :
- PapChap_RB->isChecked();
+ Chap_RB->setChecked( TRUE );
break;
case 2 :
- Terminal_RB->isChecked();
+ EAP_RB->setChecked( TRUE );
+ break;
+ }
+ break;
+ case 2 :
+ Terminal_RB->setChecked( TRUE );
break;
}
@@ -81,5 +103,3 @@ void PPPAuthEdit::showData( PPPData_t & D ) {
Server_LE->setText( D.Auth.Server );
Secret_LE->setText( D.Auth.Secret );
-
- AuthMethod_CB->setCurrentItem( D.Auth.PCEMode );
}
diff --git a/noncore/settings/networksettings2/ppp/PPPAuthedit.h b/noncore/settings/networksettings2/ppp/PPPAuthedit.h
index cbd540e..2392569 100644
--- a/noncore/settings/networksettings2/ppp/PPPAuthedit.h
+++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.h
@@ -10,4 +10,6 @@ public :
bool commit( PPPData_t & Data );
void showData( PPPData_t & Data );
+ bool PAP_Checked( void );
+
private :
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
index b7edf87..ff4465c 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
@@ -1,5 +1,9 @@
+#include <qfile.h>
+#include <qtextstream.h>
#include "ppp_NN.h"
#include "ppp_NNI.h"
+QStringList * PPPNetNode::ProperFiles = 0;
+
static const char * PPPNeeds[] =
{ "line",
@@ -12,4 +16,15 @@ static const char * PPPNeeds[] =
*/
PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) {
+
+ // proper files : will leak
+ ProperFiles =new QStringList;
+ *ProperFiles << "peers";
+ *ProperFiles << "chatscript";
+
+ // system files
+ NSResources->addSystemFile(
+ "pap-secrets", "/tmp/pap-secrets", 0 );
+ NSResources->addSystemFile(
+ "chap-secrets", "/tmp/chap-secrets", 0 );
}
@@ -40,13 +55,15 @@ const char * PPPNetNode::provides( void ) {
}
-bool PPPNetNode::generateProperFilesFor(
- ANetNodeInstance * ) {
- return 0;
+QStringList * PPPNetNode::properFiles( void ) {
+ return ProperFiles;
+
}
-bool PPPNetNode::generateDeviceDataForCommonFile(
- SystemFile & ,
- long ) {
- return 0;
+// need to generate :
+// /etc/ppp/pap-secrets
+// /etc/ppp/pap-secrets
+bool PPPNetNode::hasDataForFile( const QString & S ) {
+ return S == "pap-secrets" ||
+ S == "chap-secrets" ;
}
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
@@ -18,18 +18,13 @@ public:
{ return "Devices/ppp"; }
- virtual const QString nodeDescription() ;
+ virtual bool hasDataForFile( const QString & S );
+ virtual const QString nodeDescription() ;
virtual ANetNodeInstance * createInstance( void );
-
virtual const char ** needs( void );
virtual const char * provides( void );
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
- virtual bool hasDataFor( const QString & )
- { return 0; }
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr );
-
virtual QString genNic( long NicNr );
+ virtual QStringList * properFiles( void );
private:
@@ -37,4 +32,6 @@ private:
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
+
+ static QStringList * ProperFiles;
};
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
index d0fd31c..ba639de 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
@@ -1,2 +1,4 @@
+#include <qfile.h>
+#include <qfileinfo.h>
#include "PPPedit.h"
#include "ppp_NNI.h"
@@ -114,8 +116,106 @@ void APPP::commit( void ) {
}
-bool APPP::generateDataForCommonFile(
- SystemFile & ,
- long) {
- return 1;
+QFile * APPP::openFile( const QString & ID ) {
+ QFile * F = 0;
+ QString S;
+
+ if( ID == "peers" ) {
+ S = removeSpaces( QString("/tmp/") + connection()->name() );
+
+ F = new QFile( S );
+
+ if( ! F->open( IO_WriteOnly ) ) {
+ Log(("Cannot open file %s\n", S.latin1() ));
+ return 0;
}
+ } else if ( ID == "chatscripts" ) {
+ S = removeSpaces( QString("/tmp/") + connection()->name() + ".chat" );
+ F = new QFile( S );
+ if( ! F->open( IO_WriteOnly ) ) {
+ Log(("Cannot open file %s\n", S.latin1() ));
+ return 0;
+ }
+ }
+ if( F ) {
+ Log(("Generate proper file %s = %s\n",
+ ID.latin1(), F->name().latin1()));
+ }
+ return F;
+}
+
+short APPP::generateFile( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr ) {
+ short rvl, rvd;
+
+ rvl = 1;
+ rvd = 1;
+
+ if( ID == "pap-secrets" ) {
+ Log(("Generate PPP for %s\n", ID.latin1() ));
+ if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) {
+ TS << "# secrets for "
+ << connection()->name().latin1()
+ << endl;
+ TS << Data.Auth.Client
+ << " "
+ << Data.Auth.Server
+ << " "
+ << Data.Auth.Secret
+ << endl;
+ rvl = 0;
+ rvd = connection()->getToplevel()->generateFileEmbedded(
+ ID, Path, TS, DevNr );
+ }
+ } else if( ID == "chap-secrets" ) {
+ Log(("Generate PPP for %s\n", ID.latin1() ));
+ if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) {
+ // used for both EAP and Chap
+ TS << "# secrets for "
+ << connection()->name().latin1()
+ << endl;
+ TS << Data.Auth.Client
+ << " "
+ << Data.Auth.Server
+ << " "
+ << Data.Auth.Secret
+ << endl;
+
+ rvl = 0;
+ rvd = connection()->getToplevel()->generateFileEmbedded(
+ ID, Path, TS, DevNr );
+ }
+ } else if ( ID == "peers" ) {
+ QFileInfo FI(Path);
+ Log(("Generate PPP for %s\n", ID.latin1() ));
+
+ TS << "connect \"/usr/sbin/chat -v -f /etc/ppp/"
+ << FI.baseName()
+ << ".chat\""
+ << endl;
+
+ if( Data.IP.GWIsDefault ) {
+ TS << "defaultroute"
+ << endl;
+ }
+
+ TS << "linkname "
+ << removeSpaces( ID.latin1() )
+ << endl;
+
+ // insert other data here
+ rvl = 0;
+ rvd = connection()->getToplevel()->generateFileEmbedded(
+ ID, Path, TS, DevNr );
+ } else if ( ID == "chatscripts" ) {
+ Log(("Generate PPP for %s\n", ID.latin1() ));
+ rvl = 0;
+ rvd = connection()->getToplevel()->generateFileEmbedded(
+ ID, Path, TS, DevNr );
+ }
+
+ return (rvd == 2 || rvl == 2 ) ? 2 :
+ (rvd == 0 || rvl == 0 ) ? 0 : 1;
+}
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.h b/noncore/settings/networksettings2/ppp/ppp_NNI.h
index 989c2f0..0bf8fa9 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NNI.h
+++ b/noncore/settings/networksettings2/ppp/ppp_NNI.h
@@ -8,4 +8,5 @@
class PPPNetNode;
class PPPEdit;
+class QTextStream;
class APPP : public ANetNodeInstance {
@@ -15,22 +16,24 @@ public :
APPP( PPPNetNode * PNN );
- QWidget * edit( QWidget * parent );
- QString acceptable( void );
- void commit( void );
-
RuntimeInfo * runtime( void )
- { if( RT == 0 )
+ { if( RT == 0 ) {
RT = new PPPRun( this, Data );
+ }
return RT->runtimeInfo();
}
+ QWidget * edit( QWidget * parent );
+ QString acceptable( void );
+ void commit( void );
+
virtual void * data( void )
{ return (void *)&Data; }
- virtual bool hasDataFor( const QString & )
- { return 0; }
+ virtual QFile * openFile( const QString & ID );
+ short generateFile( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr );
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr );
protected :
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp
index 59c34a3..945b48d 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NN.cpp
@@ -10,5 +10,5 @@ static const char * ProfileNeeds[] =
* Constructor, find all of the possible interfaces
*/
-ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular profile")) {
+ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) {
}
@@ -39,15 +39,4 @@ const char * ProfileNetNode::provides( void ) {
}
-bool ProfileNetNode::generateProperFilesFor(
- ANetNodeInstance * ) {
- return 0;
-}
-
-bool ProfileNetNode::generateDeviceDataForCommonFile(
- SystemFile & ,
- long ) {
- return 0;
-}
-
void ProfileNetNode::setSpecificAttribute( QString & , QString & ) {
}
diff --git a/noncore/settings/networksettings2/profile/profile_NN.h b/noncore/settings/networksettings2/profile/profile_NN.h
index e602bd7..1f1ee2c 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.h
+++ b/noncore/settings/networksettings2/profile/profile_NN.h
@@ -19,16 +19,8 @@ public:
virtual const QString nodeDescription() ;
-
virtual ANetNodeInstance * createInstance( void );
-
virtual const char ** needs( void );
virtual const char * provides( void );
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
- virtual bool hasDataFor( const QString & )
- { return 0; }
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr);
-
private:
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.cpp b/noncore/settings/networksettings2/profile/profile_NNI.cpp
index cb52b2a..f0f0b97 100644
--- a/noncore/settings/networksettings2/profile/profile_NNI.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NNI.cpp
@@ -51,8 +51,27 @@ void AProfile::commit( void ) {
}
-bool AProfile::generateDataForCommonFile(
- SystemFile & ,
- long) {
- return 1;
+short AProfile::generateFileEmbedded( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr ) {
+
+ short rvl, rvd;
+
+ rvl = 1;
+
+ if( ID == "interfaces" ) {
+ Log(("Generate Profile for %s\n", ID.latin1() ));
+ if( Data.TriggerVPN ) {
+ // this profile triggers VPN -> insert trigger
+ TS << " up networksettings2 --triggervpn"
+ << endl;
+ rvl = 0;
+ }
}
+ rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr );
+ return (rvd == 2 || rvl == 2 ) ? 2 :
+ (rvd == 0 || rvl == 0 ) ? 0 : 1;
+}
+
+
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.h b/noncore/settings/networksettings2/profile/profile_NNI.h
index 2c2db7f..957f4af 100644
--- a/noncore/settings/networksettings2/profile/profile_NNI.h
+++ b/noncore/settings/networksettings2/profile/profile_NNI.h
@@ -15,24 +15,23 @@ public :
AProfile( ProfileNetNode * PNN );
+ RuntimeInfo * runtime( void )
+ { return
+ ( RT ) ? RT : ( RT = new ProfileRun( this, Data ) );
+ }
+
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
- const QString & description( void )
- { return Data.Description; }
- RuntimeInfo * runtime( void )
- { if( RT == 0 )
- RT = new ProfileRun( this, Data );
- return RT;
- }
-
virtual void * data( void )
{ return (void *)&Data; }
- virtual bool hasDataFor( const QString & )
- { return 0; }
+ virtual short generateFileEmbedded( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr );
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr);
+ const QString & description( void )
+ { return Data.Description; }
protected :
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp
index c10a09c..14c479a 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NN.cpp
@@ -38,27 +38,4 @@ const char * USBNetNode::provides( void ) {
}
-bool USBNetNode::generateProperFilesFor(
- ANetNodeInstance * ) {
- return 0;
-}
-
-bool USBNetNode::hasDataFor( const QString & S ) {
- return (S== "interfaces");
-}
-
-bool USBNetNode::generateDeviceDataForCommonFile(
- SystemFile & S ,
- long DevNr ) {
- QString NIC = genNic( DevNr );
-
- if( S.name() == "interfaces" ) {
- // generate mapping stanza for this interface
- S << "# check if " << NIC << " can be brought UP" << endl;
- S << "mapping " << NIC << endl;
- S << " script networksettings2-request" << endl << endl;
- }
- return 0;
-}
-
QString USBNetNode::genNic( long ) {
return QString( "usbf" );
diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h
index fea89f0..73da15a 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.h
+++ b/noncore/settings/networksettings2/usb/usb_NN.h
@@ -19,15 +19,8 @@ public:
virtual const QString nodeDescription() ;
-
virtual ANetNodeInstance * createInstance( void );
-
virtual const char ** needs( void );
virtual const char * provides( void );
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
- virtual bool hasDataFor( const QString & S);
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr );
-
virtual QString genNic( long nr );
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.cpp b/noncore/settings/networksettings2/usb/usb_NNI.cpp
index e90204c..50c6e8d 100644
--- a/noncore/settings/networksettings2/usb/usb_NNI.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NNI.cpp
@@ -33,14 +33,18 @@ void AUSB::commit( void ) {
}
-bool AUSB::hasDataFor( const QString & S ) {
- return (S== "interfaces");
-}
+short AUSB::generateFileEmbedded( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr ) {
-bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) {
QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
+ short rvl, rvd;
+
+ rvl = 1;
- if( S.name() == "interfaces" ) {
+ if( ID == "interfaces" ) {
+ Log(("Generate USB for %s\n", ID.latin1() ));
// generate mapping stanza for this interface
- S << " pre-up "
+ TS << " pre-up "
<< QPEApplication::qpeDir()
<< "bin/setmacaddress.sh "
@@ -48,5 +52,10 @@ bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) {
<< " || true"
<< endl;
+ rvl = 0;
}
- return 0;
+ rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr );
+
+ return (rvd == 2 || rvl == 2 ) ? 2 :
+ (rvd == 0 || rvl == 0 ) ? 0 : 1;
+
}
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.h b/noncore/settings/networksettings2/usb/usb_NNI.h
index d2ee217..fcdfd91 100644
--- a/noncore/settings/networksettings2/usb/usb_NNI.h
+++ b/noncore/settings/networksettings2/usb/usb_NNI.h
@@ -15,20 +15,20 @@ public :
AUSB( USBNetNode * PNN );
+ RuntimeInfo * runtime( void )
+ { return
+ ( RT ) ? RT : ( RT = new USBRun( this, Data ) );
+ }
+
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
- RuntimeInfo * runtime( void )
- { if( RT == 0 )
- RT = new USBRun( this, Data );
- return RT;
- }
-
virtual void * data( void )
{ return (void *)&Data; }
- virtual bool hasDataFor( const QString & S);
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr );
+ virtual short generateFileEmbedded( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr );
protected :
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
index 6c7b308..9d3b6e7 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
@@ -3,6 +3,5 @@
static const char * VPNNeeds[] =
- { "connection",
- 0
+ { 0
};
@@ -39,15 +38,4 @@ const char * VPNNetNode::provides( void ) {
}
-bool VPNNetNode::generateProperFilesFor(
- ANetNodeInstance * ) {
- return 0;
-}
-
-bool VPNNetNode::generateDeviceDataForCommonFile(
- SystemFile & ,
- long ) {
- return 0;
-}
-
void VPNNetNode::setSpecificAttribute( QString & , QString & ) {
}
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.h b/noncore/settings/networksettings2/vpn/vpn_NN.h
index 5b6632e..3c7b5e0 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.h
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.h
@@ -19,16 +19,8 @@ public:
virtual const QString nodeDescription() ;
-
virtual ANetNodeInstance * createInstance( void );
-
virtual const char ** needs( void );
virtual const char * provides( void );
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
- virtual bool hasDataFor( const QString & )
- { return 0; }
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr );
-
private:
diff --git a/noncore/settings/networksettings2/vpn/vpn_NNI.cpp b/noncore/settings/networksettings2/vpn/vpn_NNI.cpp
index ee999e8..6c20aeb 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NNI.cpp
+++ b/noncore/settings/networksettings2/vpn/vpn_NNI.cpp
@@ -29,8 +29,2 @@ void AVPN::commit( void ) {
}
-bool AVPN::generateDataForCommonFile(
- SystemFile & ,
- long) {
- return 1;
-}
-
diff --git a/noncore/settings/networksettings2/vpn/vpn_NNI.h b/noncore/settings/networksettings2/vpn/vpn_NNI.h
index c3eb016..aee5891 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NNI.h
+++ b/noncore/settings/networksettings2/vpn/vpn_NNI.h
@@ -15,21 +15,17 @@ public :
AVPN( VPNNetNode * PNN );
+ RuntimeInfo * runtime( void )
+ { return
+ ( RT ) ? RT : ( RT = new VPNRun( this, Data ) );
+ }
+
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
- RuntimeInfo * runtime( void )
- { if( RT == 0 )
- RT = new VPNRun( this, Data );
- return RT;
- }
-
virtual void * data( void )
{ return (void *)&Data; }
- virtual bool hasDataFor( const QString & )
- { return 0; }
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr );
+
protected :
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
index ce8a734..e4c3f60 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp
+++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
@@ -39,27 +39,4 @@ const char * WLanNetNode::provides( void ) {
}
-bool WLanNetNode::generateProperFilesFor(
- ANetNodeInstance * ) {
- return 0;
-}
-
-bool WLanNetNode::hasDataFor( const QString & S ) {
- return S == "interfaces";
-}
-
-bool WLanNetNode::generateDeviceDataForCommonFile(
- SystemFile & S,
- long DevNr ) {
- QString NIC = genNic( DevNr );
-
- if( S.name() == "interfaces" ) {
- // generate mapping stanza for this interface
- S << "# check if " << NIC << " can be brought UP" << endl;
- S << "mapping " << NIC << endl;
- S << " script networksettings2-request" << endl << endl;
- }
- return 0;
-}
-
QString WLanNetNode::genNic( long nr ) {
QString S;
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.h b/noncore/settings/networksettings2/wlan/wlan_NN.h
index b5ff3fd..c13c05c 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NN.h
+++ b/noncore/settings/networksettings2/wlan/wlan_NN.h
@@ -19,19 +19,10 @@ public:
virtual const QString nodeDescription() ;
-
virtual ANetNodeInstance * createInstance( void );
-
virtual const char ** needs( void );
virtual const char * provides( void );
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
-
- virtual bool hasDataFor( const QString & S );
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr );
-
virtual long instanceCount( void )
{ return InstanceCount; }
-
virtual QString genNic( long );
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
index 61969f2..0e4fc4c 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
+++ b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
@@ -80,9 +80,16 @@ void AWLan::commit( void ) {
}
-bool AWLan::generateDataForCommonFile(
- SystemFile & S,
- long ) {
+short AWLan::generateFileEmbedded( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr ) {
- S << " wireless_essid \""
+ short rvl, rvd;
+
+ rvl = 1;
+
+ if( ID == "interfaces" ) {
+ Log(("Generate WLanNNI for %s\n", ID.latin1() ));
+ TS << " wireless_essid \""
<< Data.ESSID
<< "\""
@@ -94,10 +101,10 @@ bool AWLan::generateDataForCommonFile(
if( gethostname(Buf, sizeof(Buf) ) == 0 ) {
Buf[99] = '\0'; // just to make sure
- S << " wireless_nick "
+ TS << " wireless_nick "
<< Buf
<< endl;
}
} else {
- S << " wireless_nick \""
+ TS << " wireless_nick \""
<< Data.NodeName
<< "\""
@@ -106,8 +113,7 @@ bool AWLan::generateDataForCommonFile(
}
- char * M;
+ char * M = "Auto";
switch ( Data.Mode ) {
case 0 :
- M = "Auto";
break;
case 1 :
@@ -119,5 +125,5 @@ bool AWLan::generateDataForCommonFile(
}
- S << " wireless_mode "
+ TS << " wireless_mode "
<< M
<< endl;
@@ -125,5 +131,5 @@ bool AWLan::generateDataForCommonFile(
for( int i = 0; i < 4; i ++ ) {
if( ! Data.Key[i].isEmpty() ) {
- S << " wireless_key"
+ TS << " wireless_key"
<< i
<< " "
@@ -132,9 +138,14 @@ bool AWLan::generateDataForCommonFile(
}
}
- S << " wireless_keymode "
+ TS << " wireless_keymode "
<< ((Data.AcceptNonEncrypted) ? "open" : "restricted")
<< endl;
}
- return 0;
+ rvl = 0;
+ }
+ rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr);
+
+ return (rvd == 2 || rvl == 2 ) ? 2 :
+ (rvd == 0 || rvl == 0 ) ? 0 : 1;
}
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.h b/noncore/settings/networksettings2/wlan/wlan_NNI.h
index 2211c47..a9be65f 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NNI.h
+++ b/noncore/settings/networksettings2/wlan/wlan_NNI.h
@@ -15,21 +15,21 @@ public :
AWLan( WLanNetNode * PNN );
+ RuntimeInfo * runtime( void )
+ { return
+ ( RT ) ? RT : ( RT = new WLanRun( this, Data ) );
+ }
+
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
- RuntimeInfo * runtime( void )
- { if( RT == 0 )
- RT = new WLanRun( this, Data );
- return RT;
- }
-
virtual void * data( void )
{ return (void *)&Data; }
- virtual bool hasDataFor( const QString & )
- { return 1; }
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr );
+ virtual short generateFileEmbedded( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr );
+
protected :