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,85 +1,97 @@ #include <qpe/qpeapplication.h> -#include <asdevice.h> +#include <resources.h> +#include <netnode.h> #include "network_NN.h" #include "network_NNI.h" static const char * NetworkNeeds[] = { "device", 0 }; +static const char * NetworkProvides[] = + { "connection", + 0 + }; + /** * Constructor, find all of the possible interfaces */ NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) { + + NSResources->addSystemFile( + "interfaces", "/etc/network/interfaces", 1 ); } /** * Delete any interfaces that we own. */ NetworkNetNode::~NetworkNetNode(){ } const QString NetworkNetNode::nodeDescription(){ return tr("\ <p>Sets up TCP/IP options.</p>\ <p>Use this to configure the TCP/IP protocol</p>\ " ); } ANetNodeInstance * NetworkNetNode::createInstance( void ) { return new ANetwork( this ); } -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, long DevNr ) { + 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 << " can be brought UP" << endl; - TS << "mapping " + SF << "mapping " << NIC << endl; - TS << " script " + SF << " script " << QPEApplication::qpeDir() - << "/bin/networksettings2-request" + << "bin/networksettings2-request" << endl << endl; return 0; } return 1; } const char ** NetworkNetNode::needs( void ) { return NetworkNeeds; } -const char * NetworkNetNode::provides( void ) { - return "connection"; +const char ** NetworkNetNode::provides( void ) { + return NetworkProvides; } void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { } void NetworkNetNode::saveSpecificAttribute( QTextStream & ) { } extern "C" { void create_plugin( QList<ANetNode> & PNN ) { PNN.append( new NetworkNetNode() ); } } 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 @@ -1,43 +1,41 @@ #ifndef NETWORK_NETNODE_H #define NETWORK_NETNODE_H #include "netnode.h" class ANetwork; class NetworkNetNode : public ANetNode{ Q_OBJECT public: NetworkNetNode(); virtual ~NetworkNetNode(); - 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, 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 const char ** provides( void ); private: virtual void setSpecificAttribute( QString & Attr, QString & Value ); virtual void saveSpecificAttribute( QTextStream & TS ); }; extern "C" { void create_plugin( QList<ANetNode> & PNN ); }; #endif 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,219 +1,217 @@ #include <system.h> -#include <asdevice.h> +#include <netnode.h> #include "networkedit.h" #include "network_NNI.h" #include "network_NN.h" ANetwork::ANetwork( NetworkNetNode * PNN ) : ANetNodeInstance( PNN ) { Data.UseDHCP = 1; Data.IPAddress = ""; Data.NetMask = ""; Data.Broadcast = ""; Data.Gateway = ""; Data.DNS1 = ""; Data.DNS2 = ""; Data.SendHostname = 0; Data.Hostname = ""; Data.PreUp_SL.clear(); Data.PreDown_SL.clear(); Data.PostUp_SL.clear(); Data.PostDown_SL.clear(); GUI = 0; RT = 0; } void ANetwork::setSpecificAttribute( QString & A, QString & V ) { if( A == "usedhcp" ) { Data.UseDHCP = (V == "yes"); } else if( A == "sendhostname" ) { Data.SendHostname = (V=="yes"); } else if( A == "hostname" ) { Data.Hostname = V; } else if( A == "ipaddress" ) { Data.IPAddress = V; } else if( A == "netmask" ) { Data.NetMask = V; } else if( A == "broadcast" ) { Data.Broadcast = V; } else if( A == "gateway" ) { Data.Gateway = V; } else if( A == "dns1" ) { Data.DNS1 = V; } else if( A == "dns2" ) { Data.DNS2 = V; } else if( A == "preup" ) { Data.PreUp_SL.append( V ); } else if( A == "predown" ) { Data.PreDown_SL.append( V ); } else if( A == "postup" ) { Data.PostUp_SL.append( V ); } else if( A == "postdown" ) { Data.PostDown_SL.append( V ); } } void ANetwork::saveSpecificAttribute( QTextStream & TS ) { TS << "usedhcp=" << ((Data.UseDHCP) ? "yes" : "no") << endl; TS << "sendhostname=" << ((Data.SendHostname) ? "yes" : "no") << endl; TS << "hostname=" << Data.Hostname << endl; TS << "ipaddress=" << Data.IPAddress << endl; TS << "netmask=" << Data.NetMask << endl; TS << "broadcast=" << Data.Broadcast << endl; TS << "gateway=" << Data.Gateway << endl; TS << "dns1=" << Data.DNS1 << endl; TS << "dns2=" << Data.DNS2 << endl; for ( QStringList::Iterator it = Data.PreUp_SL.begin(); it != Data.PreUp_SL.end(); ++it ) { TS << "preup=" << quote(*it) << endl; } for ( QStringList::Iterator it = Data.PreDown_SL.begin(); it != Data.PreDown_SL.end(); ++it ) { TS << "predown=" << quote(*it) << endl; } for ( QStringList::Iterator it = Data.PostUp_SL.begin(); it != Data.PostUp_SL.end(); ++it ) { TS << "postup=" << quote(*it) << endl; } for ( QStringList::Iterator it = Data.PostDown_SL.begin(); it != Data.PostDown_SL.end(); ++it ) { TS << "postdown=" << quote(*it) << endl; } } QWidget * ANetwork::edit( QWidget * parent ) { GUI = new NetworkEdit( parent ); GUI->showData( Data ); return GUI; } QString ANetwork::acceptable( void ) { return ( GUI ) ? GUI->acceptable( ) : QString(); } void ANetwork::commit( void ) { if( GUI && GUI->commit( Data ) ) setModified( 1 ); } -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 + ) { short rvl, rvd ; QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); 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 << "-c" << connection()->number() << "-allowed inet dhcp" << endl; - TS << " up echo \"" + SF << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << ".up" << endl; if( Data.SendHostname ) { - TS << " hostname " + SF << " hostname " << Data.Hostname << endl; } - TS << " down rm -f /tmp/profile-" + SF << " down rm -f /tmp/profile-" << connection()->number() << ".up" << endl; } else { - TS << "iface " + SF << "iface " << NIC << "-c" << connection()->number() << "-allowed inet static" << endl; - TS << " up echo \"" + SF << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << ".up" << endl; - TS << " down rm -f /tmp/profile-" + SF << " down rm -f /tmp/profile-" << connection()->number() << ".up" << endl; - TS << " address " + SF << " address " << Data.IPAddress << endl; - TS << " broadcast " + SF << " broadcast " << Data.Broadcast << endl; - TS << " netmask " + SF << " netmask " << Data.NetMask << endl; // derive network address = IPAddress & netmask { QString NW; QStringList ipal = QStringList::split( '.', Data.IPAddress ); QStringList nmal = QStringList::split( '.', Data.NetMask ); NW = QString( "%1.%2.%3.%4" ). arg( ipal[0].toShort() & nmal[0].toShort() ). arg( ipal[1].toShort() & nmal[1].toShort() ). arg( ipal[2].toShort() & nmal[2].toShort() ). arg( ipal[3].toShort() & nmal[3].toShort() ); - TS << " network " + SF << " network " << NW << endl; } } for ( QStringList::Iterator it = Data.PreUp_SL.begin(); it != Data.PreUp_SL.end(); ++it ) { - TS << " pre-up " + SF << " pre-up " << (*it) << endl; } for ( QStringList::Iterator it = Data.PostUp_SL.begin(); it != Data.PostUp_SL.end(); ++it ) { - TS << " up " + SF << " up " << (*it) << endl; } for ( QStringList::Iterator it = Data.PreDown_SL.begin(); it != Data.PreDown_SL.end(); ++it ) { - TS << " down " + SF << " down " << (*it) << endl; } for ( QStringList::Iterator it = Data.PostDown_SL.begin(); it != Data.PostDown_SL.end(); ++it ) { - TS << " post-down " + SF << " post-down " << (*it) << endl; } rvl = 0; } // embed other info in it - rvd = connection()->getToplevel()->generateFileEmbedded( ID, Path, TS, DevNr ); + rvd = connection()->getToplevel()->generateFileEmbedded( SF, 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 5e42503..71c276a 100644 --- a/noncore/settings/networksettings2/network/network_NNI.h +++ b/noncore/settings/networksettings2/network/network_NNI.h @@ -1,48 +1,46 @@ #ifndef NETWORK_H #define NETWORK_H #include <netnode.h> #include "networkdata.h" #include "networkrun.h" class NetworkNetNode; class NetworkEdit; class SystemFile; class ANetwork : public ANetNodeInstance{ 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 ); virtual void * data( void ) { return (void *)&Data; } - 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 ); protected : virtual void setSpecificAttribute( QString & Attr, QString & Value ); virtual void saveSpecificAttribute( QTextStream & TS ); private : NetworkEdit * GUI; - NetworkData_t Data; + NetworkData Data; NetworkRun * RT; }; #endif 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 @@ -1,22 +1,23 @@ #ifndef NETWORK_DATA_H #define NETWORK_DATA_H #include <qstring.h> #include <qstringlist.h> -typedef struct NetworkData { +class NetworkData { +public : bool UseDHCP; QString Hostname; bool SendHostname; QString IPAddress; QString NetMask; QString Gateway; QString Broadcast; QString DNS1; QString DNS2; QStringList PreUp_SL; QStringList PostUp_SL; QStringList PreDown_SL; QStringList PostDown_SL; -} NetworkData_t; +} ; #endif 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 @@ -1,184 +1,184 @@ #include <qtoolbutton.h> #include <qcheckbox.h> #include <qtabwidget.h> #include <qlineedit.h> #include <qlistbox.h> #include <GUIUtils.h> #include <resources.h> #include "networkedit.h" NetworkEdit::NetworkEdit( QWidget * Parent ) : NetworkGUI( Parent ){ AddPreDown_TB->setPixmap( NSResources->getPixmap( "add" ) ); AddPreUp_TB->setPixmap( NSResources->getPixmap( "add" ) ); AddPostDown_TB->setPixmap( NSResources->getPixmap( "add" ) ); AddPostUp_TB->setPixmap( NSResources->getPixmap( "add" ) ); DeletePreDown_TB->setPixmap( NSResources->getPixmap( "remove" ) ); DeletePreUp_TB->setPixmap( NSResources->getPixmap( "remove" ) ); DeletePostDown_TB->setPixmap( NSResources->getPixmap( "remove" ) ); DeletePostUp_TB->setPixmap( NSResources->getPixmap( "remove" ) ); UpPreDown_TB->setPixmap( NSResources->getPixmap( "up" ) ); UpPreUp_TB->setPixmap( NSResources->getPixmap( "up" ) ); UpPostDown_TB->setPixmap( NSResources->getPixmap( "up" ) ); UpPostUp_TB->setPixmap( NSResources->getPixmap( "up" ) ); DownPreDown_TB->setPixmap( NSResources->getPixmap( "down" ) ); DownPreUp_TB->setPixmap( NSResources->getPixmap( "down" ) ); DownPostDown_TB->setPixmap( NSResources->getPixmap( "down" ) ); DownPostUp_TB->setPixmap( NSResources->getPixmap( "down" ) ); } QString NetworkEdit::acceptable( void ) { if( DHCP_CB->isChecked() ) { if( SendHostname_CB->isChecked() ) if( Hostname_LE->text().isEmpty() ) return tr("Hostname needed"); return QString(); } if( IPAddress_LE->text().isEmpty() ) return tr("IPAddress needed"); if( Broadcast_LE->text().isEmpty() ) return tr("Broadcast needed"); if( SubnetMask_LE->text().isEmpty() ) return tr("Subnet mask needed"); // valid IP ? if( ! validIP( IPAddress_LE->text() ) ) return tr("IPAddress not valid"); if( ! validIP( SubnetMask_LE->text() ) ) return tr("Subnet mask not valid"); if( ! validIP( Broadcast_LE->text() ) ) return tr("Broadcast address not valid"); if( Gateway_LE->text().isEmpty() || ! validIP( Gateway_LE->text() ) ) return tr("Gateway address not valid"); if( ! DNS1_LE->text().isEmpty() && ! validIP( DNS1_LE->text() ) ) return tr("DNS1 address not valid"); if( ! DNS2_LE->text().isEmpty() && ! validIP( DNS2_LE->text() ) ) return tr("DNS2 address not valid"); return QString(); } -bool NetworkEdit::commit( NetworkData_t & Data ) { +bool NetworkEdit::commit( NetworkData & Data ) { bool SM = 0; CBM( Data.UseDHCP, DHCP_CB, SM ); TXTM( Data.IPAddress, IPAddress_LE, SM ); CBM( Data.SendHostname, SendHostname_CB, SM ); TXTM( Data.Hostname, Hostname_LE, SM ); TXTM( Data.Gateway, Gateway_LE, SM ); TXTM( Data.Broadcast, Broadcast_LE, SM ); TXTM( Data.NetMask, SubnetMask_LE, SM ); TXTM( Data.DNS1, DNS1_LE, SM ); TXTM( Data.DNS2, DNS2_LE, SM ); SM |= updateList( Data.PreUp_SL, PreUp_LB ); SM |= updateList( Data.PostUp_SL, PostUp_LB ); SM |= updateList( Data.PreDown_SL, PreDown_LB ); SM |= updateList( Data.PostDown_SL, PostDown_LB ); return SM; } -void NetworkEdit::showData( NetworkData_t & Data ) { +void NetworkEdit::showData( NetworkData & Data ) { DHCP_CB->setChecked( Data.UseDHCP ); SendHostname_CB->setChecked( Data.SendHostname ); Hostname_LE->setText( Data.Hostname ); IPAddress_LE->setText( Data.IPAddress ); Gateway_LE->setText( Data.Gateway ); SubnetMask_LE->setText( Data.NetMask ); Broadcast_LE->setText( Data.Broadcast ); DNS1_LE->setText( Data.DNS1 ); DNS2_LE->setText( Data.DNS2 ); populateList( Data.PreUp_SL, PreUp_LB ); populateList( Data.PostUp_SL, PostUp_LB ); populateList( Data.PreDown_SL, PreDown_LB ); populateList( Data.PostDown_SL, PostDown_LB ); } bool NetworkEdit::updateList( QStringList & SL, QListBox * LB ) { bool Changed; QStringList NewSL; // collect new list for( unsigned int i = 0; i < LB->count() ; i ++ ) { NewSL.append( LB->text(i) ); } if( NewSL.count() != SL.count() ) { // less or more items SL= NewSL; return 1; } // Same size -> same content ? Changed = 0; for ( QStringList::Iterator it = NewSL.begin(); it != NewSL.end(); ++it ) { if( SL.findIndex( (*it) ) < 0 ) { // new or modified item Changed = 1; SL = NewSL; break; } } return Changed; } void NetworkEdit::populateList( QStringList & SL, QListBox * LB ) { LB->clear(); for ( QStringList::Iterator it = SL.begin(); it != SL.end(); ++it ) { LB->insertItem( (*it) ); } } void NetworkEdit::SLOT_NetmaskModified( const QString & ) { QString IP, SN; IP = IPAddress_LE->text(); SN = SubnetMask_LE->text(); if( IP.isEmpty() || SN.isEmpty() ) return; if( ! validIP(IP) || ! validIP( SN ) ) return; // if all ones // broadcast = (IPAddress | ~netmask ) { QString NW; QStringList ipal = QStringList::split( '.', IP ); QStringList nmal = QStringList::split( '.', SN ); NW = QString( "%1.%2.%3.%4" ). arg( ipal[0].toShort() | ( ~ nmal[0].toShort() & 0x00ff) ). arg( ipal[1].toShort() | ( ~ nmal[1].toShort() & 0x00ff) ). arg( ipal[2].toShort() | ( ~ nmal[2].toShort() & 0x00ff) ). arg( ipal[3].toShort() | ( ~ nmal[3].toShort() & 0x00ff) ); Broadcast_LE->setText( NW ); } } QListBox * NetworkEdit::getActiveLB( void ) { switch( Tab_TAB->currentPageIndex() ) { case 0 : return PreUp_LB; case 1 : return PostUp_LB; case 2 : return PreDown_LB; } return PostDown_LB; } void NetworkEdit::SLOT_Add( void ) { if( Command_LE->text().isEmpty() ) return; QListBox * LB = getActiveLB(); 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 @@ -1,29 +1,29 @@ #include "networkdata.h" #include "networkGUI.h" class QListBox; class NetworkEdit : public NetworkGUI { public : NetworkEdit( QWidget * parent ); QString acceptable( void ); - bool commit( NetworkData_t & Data ); - void showData( NetworkData_t & Data ); + bool commit( NetworkData & Data ); + void showData( NetworkData & Data ); public slots : void SLOT_NetmaskModified( const QString & S ); void SLOT_ShowCommand( QListBoxItem * LBI ); void SLOT_Add( void ); void SLOT_Remove( void ); void SLOT_Up( void ); void SLOT_Down( void ); private : QListBox * getActiveLB( void ); bool updateList( QStringList &SL, QListBox * LB ); void populateList( QStringList &SL, QListBox * LB ); }; 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,78 +1,51 @@ #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(); if( A == Up ) { // 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,23 +1,20 @@ -#include <asconnection.h> +#include <netnode.h> #include "networkdata.h" -class NetworkRun : public AsConnection { +class NetworkRun : public RuntimeInfo { 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,9 +1,9 @@ -Package: opie-networksettingsplugin2-network +Package: opie-networksettings2plugin-network Files: plugins/networksettings2/libnetwork.so* Priority: optional Section: opie/settings Maintainer: Wim Delvaux <wimpie@handhelds.org> Architecture: arm Depends: opie-networksettings2, libopiecore2, libopienet2 Description: Generate TCPIP Network settings plugin Version: $QPE_VERSION$EXTRAVERSION |