Diffstat (limited to 'noncore/settings/networksettings2/network') (more/less context) (ignore whitespace changes)
4 files changed, 132 insertions, 82 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,3 +1,4 @@ +#include <asdevice.h> #include "network_NN.h" #include "network_NNI.h" @@ -30,23 +31,42 @@ ANetNodeInstance * NetworkNetNode::createInstance( void ) { return new ANetwork( this ); } -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 ); + + 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::generateProperFilesFor( - ANetNodeInstance * ) { - return 0; +const char ** NetworkNetNode::needs( void ) { + return NetworkNeeds; } -bool NetworkNetNode::generateDeviceDataForCommonFile( - SystemFile & , - long ) { - return 0; +const char * NetworkNetNode::provides( void ) { + return "connection"; } void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h index 6548c32..745d1a7 100644 --- a/noncore/settings/networksettings2/network/network_NN.h +++ b/noncore/settings/networksettings2/network/network_NN.h @@ -7,28 +7,27 @@ class ANetwork; class NetworkNetNode : public ANetNode{ - Q_OBJECT + Q_OBJECT public: - NetworkNetNode(); - virtual ~NetworkNetNode(); + NetworkNetNode(); + virtual ~NetworkNetNode(); - virtual const QString pixmapName() - { return "Devices/tcpip"; } + virtual bool hasDataForFile( const QString & S ); - virtual const QString nodeDescription() ; + virtual short generateFile( const QString & ID, + const QString & Path, + QTextStream & TS, + ANetNodeInstance * NNI, + long DevNr ); + virtual const QString pixmapName() + { return "Devices/tcpip"; } - 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 const QString nodeDescription() ; + virtual ANetNodeInstance * createInstance( void ); + virtual const char ** needs( void ); + virtual const char * provides( void ); 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 @@ -99,57 +99,71 @@ void ANetwork::commit( void ) { setModified( 1 ); } -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 " - << NIC - << "-c" - << connection()->number() - << "-allowed inet dhcp" - << endl; - S << " up echo \"" - << NIC - << "\" > /tmp/profile-" - << connection()->number() - << ".up" - << endl; + TS << "iface " + << NIC + << "-c" + << connection()->number() + << "-allowed inet dhcp" + << endl; + TS << " up echo \"" + << NIC + << "\" > /tmp/profile-" + << connection()->number() + << ".up" + << endl; if( Data.SendHostname ) { - S << " hostname " - << Data.Hostname - << endl; + TS << " hostname " + << Data.Hostname + << endl; } - S << " down rm -f /tmp/profile-" - << connection()->number() - << ".up" - << endl; + TS << " down rm -f /tmp/profile-" + << connection()->number() + << ".up" + << endl; } else { - S << "iface " - << NIC << "-c" - << connection()->number() - << "-allowed inet static" - << endl; - S << " up echo \"" - << NIC - << "\" > /tmp/profile-" - << connection()->number() - << ".up" - << endl; - S << " 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 << "iface " + << NIC << "-c" + << connection()->number() + << "-allowed inet static" + << endl; + TS << " up echo \"" + << NIC + << "\" > /tmp/profile-" + << connection()->number() + << ".up" + << endl; + TS << " down rm -f /tmp/profile-" + << connection()->number() + << ".up" + << endl; + TS << " address " + << Data.IPAddress + << endl; + TS << " broadcast " + << Data.Broadcast + << endl; + TS << " netmask " + << Data.NetMask + << endl; // derive network address = IPAddress & netmask { QString NW; @@ -161,29 +175,45 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { arg( ipal[1].toShort() & nmal[1].toShort() ). arg( ipal[2].toShort() & nmal[2].toShort() ). arg( ipal[3].toShort() & nmal[3].toShort() ); - S << " network " << NW << endl; + TS << " network " + << NW + << endl; } } for ( QStringList::Iterator it = Data.PreUp_SL.begin(); 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 @@ -15,22 +15,23 @@ 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 : |