author | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
commit | a9c188235c97e07b0eb96b13adbcdfd4bad64767 (patch) (side-by-side diff) | |
tree | 13f6ae5c499dc0c1d1bd4b763a1973a0fa8635cf /noncore/settings/networksettings2/network | |
parent | 48b6cd5966ec6cc0b968edf10ba1a1ad96ef165f (diff) | |
download | opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.zip opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.gz opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.bz2 |
CONTROL files : changed version string
NS2 many changes and first release of OT2
Diffstat (limited to 'noncore/settings/networksettings2/network') (more/less context) (ignore whitespace changes)
10 files changed, 105 insertions, 128 deletions
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index b5c41bf..23b3d44 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp @@ -1,3 +1,4 @@ #include <qpe/qpeapplication.h> -#include <asdevice.h> +#include <resources.h> +#include <netnode.h> #include "network_NN.h" @@ -10,2 +11,7 @@ static const char * NetworkNeeds[] = +static const char * NetworkProvides[] = + { "connection", + 0 + }; + /** @@ -14,2 +20,5 @@ static const char * NetworkNeeds[] = NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) { + + NSResources->addSystemFile( + "interfaces", "/etc/network/interfaces", 1 ); } @@ -34,9 +43,7 @@ ANetNodeInstance * NetworkNetNode::createInstance( void ) { -bool NetworkNetNode::hasDataForFile( const QString & S ) { - return S == "interfaces"; +bool NetworkNetNode::hasDataForFile( SystemFile & S ) { + return S.name() == "interfaces"; } -short NetworkNetNode::generateFile( const QString & ID, - const QString & , - QTextStream & TS, +short NetworkNetNode::generateFile( SystemFile & SF, ANetNodeInstance * NNI, @@ -44,8 +51,13 @@ short NetworkNetNode::generateFile( const QString & ID, + if( DevNr < 0 ) { + // generate device specific but common part + return 1; + } + QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); - if( ID == "interfaces" ) { - Log(("Generate entry for %s in %s\n", NIC.latin1(), ID.latin1() )); + if( SF.name() == "interfaces" ) { + Log(("Generate entry for %s in %s\n", NIC.latin1(), SF.name().latin1() )); // generate mapping stanza for this interface - TS << "# check if " + SF << "# check if " << NIC @@ -53,8 +65,8 @@ short NetworkNetNode::generateFile( const QString & ID, << endl; - TS << "mapping " + SF << "mapping " << NIC << endl; - TS << " script " + SF << " script " << QPEApplication::qpeDir() - << "/bin/networksettings2-request" + << "bin/networksettings2-request" << endl @@ -70,4 +82,4 @@ const char ** NetworkNetNode::needs( void ) { -const char * NetworkNetNode::provides( void ) { - return "connection"; +const char ** NetworkNetNode::provides( void ) { + return NetworkProvides; } diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h index 745d1a7..b063d4c 100644 --- a/noncore/settings/networksettings2/network/network_NN.h +++ b/noncore/settings/networksettings2/network/network_NN.h @@ -16,7 +16,5 @@ public: - virtual bool hasDataForFile( const QString & S ); + virtual bool hasDataForFile( SystemFile & S ); - virtual short generateFile( const QString & ID, - const QString & Path, - QTextStream & TS, + virtual short generateFile( SystemFile & TS, ANetNodeInstance * NNI, @@ -29,3 +27,3 @@ public: virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp index 324c6e2..78e6545 100644 --- a/noncore/settings/networksettings2/network/network_NNI.cpp +++ b/noncore/settings/networksettings2/network/network_NNI.cpp @@ -1,3 +1,3 @@ #include <system.h> -#include <asdevice.h> +#include <netnode.h> #include "networkedit.h" @@ -101,11 +101,9 @@ void ANetwork::commit( void ) { -bool ANetwork::hasDataForFile( const QString & S ) { - return S == "interfaces"; +bool ANetwork::hasDataForFile( SystemFile & S ) { + return S.name() == "interfaces"; } -short ANetwork::generateFile( const QString & ID, - const QString & Path, - QTextStream &TS, - long DevNr - ) { +short ANetwork::generateFile( SystemFile &SF, + long DevNr + ) { @@ -115,7 +113,7 @@ short ANetwork::generateFile( const QString & ID, rvl = 1; - if( ID == "interfaces" ) { - Log(("Generate Network for %s\n", ID.latin1() )); + if( SF.name() == "interfaces" ) { + Log(("Generate Network for %s\n", SF.name().latin1() )); // we can safely call from here since device item is deeper if( Data.UseDHCP ) { - TS << "iface " + SF << "iface " << NIC @@ -125,3 +123,3 @@ short ANetwork::generateFile( const QString & ID, << endl; - TS << " up echo \"" + SF << " up echo \"" << NIC @@ -132,3 +130,3 @@ short ANetwork::generateFile( const QString & ID, if( Data.SendHostname ) { - TS << " hostname " + SF << " hostname " << Data.Hostname @@ -137,3 +135,3 @@ short ANetwork::generateFile( const QString & ID, - TS << " down rm -f /tmp/profile-" + SF << " down rm -f /tmp/profile-" << connection()->number() @@ -142,3 +140,3 @@ short ANetwork::generateFile( const QString & ID, } else { - TS << "iface " + SF << "iface " << NIC << "-c" @@ -147,3 +145,3 @@ short ANetwork::generateFile( const QString & ID, << endl; - TS << " up echo \"" + SF << " up echo \"" << NIC @@ -153,3 +151,3 @@ short ANetwork::generateFile( const QString & ID, << endl; - TS << " down rm -f /tmp/profile-" + SF << " down rm -f /tmp/profile-" << connection()->number() @@ -157,9 +155,9 @@ short ANetwork::generateFile( const QString & ID, << endl; - TS << " address " + SF << " address " << Data.IPAddress << endl; - TS << " broadcast " + SF << " broadcast " << Data.Broadcast << endl; - TS << " netmask " + SF << " netmask " << Data.NetMask @@ -177,3 +175,3 @@ short ANetwork::generateFile( const QString & ID, arg( ipal[3].toShort() & nmal[3].toShort() ); - TS << " network " + SF << " network " << NW @@ -185,3 +183,3 @@ short ANetwork::generateFile( const QString & ID, ++it ) { - TS << " pre-up " + SF << " pre-up " << (*it) @@ -192,3 +190,3 @@ short ANetwork::generateFile( const QString & ID, ++it ) { - TS << " up " + SF << " up " << (*it) @@ -199,3 +197,3 @@ short ANetwork::generateFile( const QString & ID, ++it ) { - TS << " down " + SF << " down " << (*it) @@ -206,3 +204,3 @@ short ANetwork::generateFile( const QString & ID, ++it ) { - TS << " post-down " + SF << " post-down " << (*it) @@ -214,3 +212,3 @@ short ANetwork::generateFile( const QString & ID, // embed other info in it - rvd = connection()->getToplevel()->generateFileEmbedded( ID, Path, TS, DevNr ); + rvd = connection()->getToplevel()->generateFileEmbedded( SF, DevNr ); diff --git a/noncore/settings/networksettings2/network/network_NNI.h b/noncore/settings/networksettings2/network/network_NNI.h index 5e42503..71c276a 100644 --- a/noncore/settings/networksettings2/network/network_NNI.h +++ b/noncore/settings/networksettings2/network/network_NNI.h @@ -29,7 +29,5 @@ public : - virtual bool hasDataForFile( const QString & S ); - virtual short generateFile( const QString & ID, - const QString & Path, - QTextStream &TS, - long DevNr ); + virtual bool hasDataForFile( SystemFile & SF ); + virtual short generateFile( SystemFile &TS, + long DevNr ); @@ -43,3 +41,3 @@ private : NetworkEdit * GUI; - NetworkData_t Data; + NetworkData Data; NetworkRun * RT; diff --git a/noncore/settings/networksettings2/network/networkdata.h b/noncore/settings/networksettings2/network/networkdata.h index 2c5da37..1df9dc4 100644 --- a/noncore/settings/networksettings2/network/networkdata.h +++ b/noncore/settings/networksettings2/network/networkdata.h @@ -5,3 +5,4 @@ #include <qstringlist.h> -typedef struct NetworkData { +class NetworkData { +public : bool UseDHCP; @@ -19,3 +20,3 @@ typedef struct NetworkData { QStringList PostDown_SL; -} NetworkData_t; +} ; diff --git a/noncore/settings/networksettings2/network/networkedit.cpp b/noncore/settings/networksettings2/network/networkedit.cpp index 05110d9..d13cb66 100644 --- a/noncore/settings/networksettings2/network/networkedit.cpp +++ b/noncore/settings/networksettings2/network/networkedit.cpp @@ -67,3 +67,3 @@ QString NetworkEdit::acceptable( void ) { -bool NetworkEdit::commit( NetworkData_t & Data ) { +bool NetworkEdit::commit( NetworkData & Data ) { bool SM = 0; @@ -87,3 +87,3 @@ bool NetworkEdit::commit( NetworkData_t & Data ) { -void NetworkEdit::showData( NetworkData_t & Data ) { +void NetworkEdit::showData( NetworkData & Data ) { DHCP_CB->setChecked( Data.UseDHCP ); diff --git a/noncore/settings/networksettings2/network/networkedit.h b/noncore/settings/networksettings2/network/networkedit.h index adc20e0..45635c8 100644 --- a/noncore/settings/networksettings2/network/networkedit.h +++ b/noncore/settings/networksettings2/network/networkedit.h @@ -11,4 +11,4 @@ public : QString acceptable( void ); - bool commit( NetworkData_t & Data ); - void showData( NetworkData_t & Data ); + bool commit( NetworkData & Data ); + void showData( NetworkData & Data ); diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp index 3e24c5f..c17aa7f 100644 --- a/noncore/settings/networksettings2/network/networkrun.cpp +++ b/noncore/settings/networksettings2/network/networkrun.cpp @@ -1,26 +1,24 @@ #include <system.h> -#include <asdevice.h> +#include <netnode.h> +#include <resources.h> #include "networkrun.h" -void NetworkRun::detectState( NodeCollection * NC ) { - RuntimeInfo * RI = netNode()->nextNode()->runtime(); - AsDevice * Next = RI->asDevice(); - InterfaceInfo * II = Next->assignedInterface(); +State_t NetworkRun::detectState( void ) { + InterfaceInfo * II = nodeCollection()->assignedInterface(); - if( II ) { + Log(( "Interface %p : %d\n", II, (II) ? II->IsUp : 0 )); + if( II && II->IsUp ) { // device has assigned interface - NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); - return; + return IsUp; } - Log(( "%s not ! UP or ava\n", NC->name().latin1() )); - // has no interface -> delegate - RI->detectState( NC ); + // had no interface or interface is no longer up -> release + nodeCollection()->assignInterface( 0 ); + + return Unknown; } -bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) { +QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) { // we handle UP and DOWN - RuntimeInfo * RI = netNode()->nextNode()->runtime(); - AsDevice * Next = RI->asDevice(); - InterfaceInfo * II = Next->assignedInterface(); + InterfaceInfo * II = NC->assignedInterface(); @@ -28,51 +26,26 @@ bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) { // we can bring UP if lower level is available - if( NC->currentState() == Available || Force ) { - QString S; - S.sprintf( "ifup %s=%s-c%d-allowed", - II->Name.latin1(), II->Name.latin1(), - connection()->number() ); - NSResources->system().runAsRoot( S ); + QStringList SL; + SL << "ifup" + << QString().sprintf( "%s=%s-c%d-allowed", + II->Name.latin1(), II->Name.latin1(), + nodeCollection()->number() ); + if( ! NSResources->system().runAsRoot( SL ) ) { + return QString("Cannot call %1").arg(SL.join(" ")); } - return 1; - } else if( A == Down ) { - QString S; - if( Force ) { - Log(("Force mode %d\n", Force )); - for( int i = 0; - i < RI->netNode()->nodeClass()->instanceCount(); - i ++ ) { - S.sprintf( "ifdown %s", - RI->netNode()->nodeClass()->genNic( i ).latin1() ); - NSResources->system().runAsRoot( S ); + return QString(); + } + + if( A == Down ) { + QStringList SL; + if( II ) { + SL << "ifdown" + << II->Name.latin1(); + if( ! NSResources->system().runAsRoot( SL ) ) { + return QString( "Cannot call %1" ).arg( SL.join( " " )); } } else { - if( NC->currentState() == IsUp ) { - S.sprintf( "ifdown %s=%s-c%d-allowed", - II->Name.latin1(), II->Name.latin1(), - connection()->number() ); - NSResources->system().runAsRoot( S ); - } + Log(( "no interface assigned." )); } - return 1; - } - // delegate - return RI->setState( NC, A, Force ); -} - -bool NetworkRun::canSetState( State_t Curr, Action_t A ) { - // we handle UP and DOWN - RuntimeInfo * RI = netNode()->nextNode()->runtime(); - - if( A == Up ) { - return ( Curr == Available ); - } else if( A == Down ) { - return ( Curr == IsUp ); } - // delegate - return RI->canSetState( Curr, A ); -} - -bool NetworkRun::handlesInterface( const QString & S ) { - // donno -> pass deeper - return netNode()->nextNode()->runtime()->handlesInterface(S); + return QString(); } diff --git a/noncore/settings/networksettings2/network/networkrun.h b/noncore/settings/networksettings2/network/networkrun.h index 522a912..78a1694 100644 --- a/noncore/settings/networksettings2/network/networkrun.h +++ b/noncore/settings/networksettings2/network/networkrun.h @@ -1,5 +1,5 @@ -#include <asconnection.h> +#include <netnode.h> #include "networkdata.h" -class NetworkRun : public AsConnection { +class NetworkRun : public RuntimeInfo { @@ -8,16 +8,13 @@ public : NetworkRun( ANetNodeInstance * NNI, - NetworkData & Data ) : AsConnection( NNI ) + NetworkData & Data ) : RuntimeInfo( NNI ) { } - virtual AsConnection * asConnection( void ) - { return (AsConnection *)this; } + virtual RuntimeInfo * connection( void ) + { return this; } -protected : - - void detectState( NodeCollection * ); - bool setState( NodeCollection * ,Action_t A, bool ); - bool canSetState( State_t , Action_t A ); + State_t detectState( void ); - bool handlesInterface( const QString & I ); +protected : + QString setMyState( NodeCollection * , Action_t, bool ); }; diff --git a/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control b/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control index 3dbb808..7b1056b 100644 --- a/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control +++ b/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control @@ -1,2 +1,2 @@ -Package: opie-networksettingsplugin2-network +Package: opie-networksettings2plugin-network Files: plugins/networksettings2/libnetwork.so* |