Diffstat (limited to 'noncore/settings/networksettings2/network') (more/less context) (show whitespace changes)
4 files changed, 97 insertions, 47 deletions
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 +1,2 @@ +#include <asdevice.h> #include "network_NN.h" @@ -32,19 +33,38 @@ 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 @@ -16,2 +16,9 @@ public: + 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() @@ -20,5 +27,3 @@ public: virtual const QString nodeDescription() ; - virtual ANetNodeInstance * createInstance( void ); - virtual const char ** needs( void ); @@ -26,8 +31,2 @@ public: - 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 @@ -101,3 +101,3 @@ void ANetwork::commit( void ) { -bool ANetwork::hasDataFor( const QString & S ) { +bool ANetwork::hasDataForFile( const QString & S ) { return S == "interfaces"; @@ -105,9 +105,17 @@ bool ANetwork::hasDataFor( const QString & S ) { -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 @@ -117,3 +125,3 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { << endl; - S << " up echo \"" + TS << " up echo \"" << NIC @@ -124,3 +132,3 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { if( Data.SendHostname ) { - S << " hostname " + TS << " hostname " << Data.Hostname @@ -129,3 +137,3 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { - S << " down rm -f /tmp/profile-" + TS << " down rm -f /tmp/profile-" << connection()->number() @@ -134,3 +142,3 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { } else { - S << "iface " + TS << "iface " << NIC << "-c" @@ -139,3 +147,3 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { << endl; - S << " up echo \"" + TS << " up echo \"" << NIC @@ -145,3 +153,3 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { << endl; - S << " down rm -f /tmp/profile-" + TS << " down rm -f /tmp/profile-" << connection()->number() @@ -149,5 +157,11 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { << 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; @@ -163,3 +177,5 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { arg( ipal[3].toShort() & nmal[3].toShort() ); - S << " network " << NW << endl; + TS << " network " + << NW + << endl; } @@ -169,3 +185,5 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { ++it ) { - S << " pre-up " << (*it) << endl; + TS << " pre-up " + << (*it) + << endl; } @@ -174,3 +192,5 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { ++it ) { - S << " up " << (*it) << endl; + TS << " up " + << (*it) + << endl; } @@ -179,3 +199,5 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { ++it ) { - S << " down " << (*it) << endl; + TS << " down " + << (*it) + << endl; } @@ -184,6 +206,14 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { ++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 @@ -17,2 +17,7 @@ public : + RuntimeInfo * runtime( void ) + { return + ( RT ) ? RT : ( RT = new NetworkRun( this, Data ) ); + } + QWidget * edit( QWidget * parent ); @@ -21,8 +26,2 @@ public : - RuntimeInfo * runtime( void ) - { if( RT == 0 ) - RT = new NetworkRun( this, Data ); - return RT; - } - virtual void * data( void ) @@ -30,5 +29,7 @@ public : - 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 ); |