summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/usb
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/usb') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.cpp24
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.h8
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.cpp25
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.h5
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp6
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.h4
6 files changed, 31 insertions, 41 deletions
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp
index be4a2bc..30c72db 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NN.cpp
@@ -33,35 +33,39 @@ const char ** USBNetNode::needs( void ) {
return USBNeeds;
}
const char * USBNetNode::provides( void ) {
return "device";
}
bool USBNetNode::generateProperFilesFor(
ANetNodeInstance * ) {
return 1;
}
-bool USBNetNode::hasDataFor( const QString & S, bool ) {
+bool USBNetNode::hasDataFor( const QString & S ) {
return (S== "interfaces");
}
-bool USBNetNode::generateDataForCommonFile(
+bool USBNetNode::generateDeviceDataForCommonFile(
SystemFile & S ,
- long DevNr,
- ANetNodeInstance * NNI) {
- return ((AUSB *)NNI)->generateDataForCommonFile(S, DevNr);
+ 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;
}
-bool USBNetNode::generateDeviceDataForCommonFile(
- SystemFile & S ,
- long DevNr,
- ANetNodeInstance * NNI) {
- return ((AUSB *)NNI)->generateDeviceDataForCommonFile(S, DevNr);
+QString USBNetNode::genNic( long ) {
+ return QString( "usbf" );
}
extern "C" {
void create_plugin( QList<ANetNode> & PNN ) {
PNN.append( new USBNetNode() );
}
}
diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h
index 8ff5289..ba22b1c 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.h
+++ b/noncore/settings/networksettings2/usb/usb_NN.h
@@ -19,28 +19,28 @@ public:
virtual const QString nodeName()
{ return tr("USB Cable Connect"); }
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, bool DeviceSpec );
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ virtual bool hasDataFor( const QString & S);
virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ SystemFile & SF, long DevNr );
+
+ virtual QString genNic( long nr );
private:
};
extern "C"
{
void create_plugin( QList<ANetNode> & PNN );
};
#endif
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.cpp b/noncore/settings/networksettings2/usb/usb_NNI.cpp
index 6fcd6d5..e90204c 100644
--- a/noncore/settings/networksettings2/usb/usb_NNI.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NNI.cpp
@@ -23,35 +23,30 @@ QWidget * AUSB::edit( QWidget * parent ) {
}
QString AUSB::acceptable( void ) {
return ( GUI ) ? GUI->acceptable( ) : QString();
}
void AUSB::commit( void ) {
if( GUI && GUI->commit( Data ) ) {
setModified( 1 );
}
}
-bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) {
- AsDevice * Dev = runtime()->device();
- QString NIC = Dev->genNic( DevNr );
-
- if( S.name() == "interfaces" ) {
- // generate mapping stanza for this interface
- S << " pre-up " << QPEApplication::qpeDir() << "bin/setmacaddress.sh " << NIC << " || true" << endl;
- }
- return 0;
+bool AUSB::hasDataFor( const QString & S ) {
+ return (S== "interfaces");
}
-bool AUSB::generateDeviceDataForCommonFile( SystemFile & S, long DevNr ) {
- AsDevice * Dev = runtime()->device();
- QString NIC = Dev->genNic( DevNr );
+bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) {
+ QString NIC = runtime()->device()->netNode()->nodeClass()->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;
+ S << " pre-up "
+ << QPEApplication::qpeDir()
+ << "bin/setmacaddress.sh "
+ << NIC
+ << " || true"
+ << endl;
}
return 0;
}
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.h b/noncore/settings/networksettings2/usb/usb_NNI.h
index 5dead36..d2ee217 100644
--- a/noncore/settings/networksettings2/usb/usb_NNI.h
+++ b/noncore/settings/networksettings2/usb/usb_NNI.h
@@ -18,26 +18,27 @@ public :
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; }
- bool generateDataForCommonFile( SystemFile & S, long DevNr );
- bool generateDeviceDataForCommonFile( SystemFile & S, long DevNr );
+ virtual bool hasDataFor( const QString & S);
+ virtual bool generateDataForCommonFile(
+ SystemFile & SF, long DevNr );
protected :
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
private :
USBEdit * GUI;
USBData Data;
USBRun * RT;
};
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp
index 3007e79..4ce6721 100644
--- a/noncore/settings/networksettings2/usb/usbrun.cpp
+++ b/noncore/settings/networksettings2/usb/usbrun.cpp
@@ -165,18 +165,12 @@ InterfaceInfo * USBRun::getInterface( void ) {
// free
best = Run;
}
}
}
return best; // can be 0
}
bool USBRun::handlesInterface( const QString & S ) {
return Pat.match( S ) >= 0;
}
-QString USBRun::genNic( long nr ) {
- QString S;
- S.sprintf( "usbf" );
- return S;
-}
-
diff --git a/noncore/settings/networksettings2/usb/usbrun.h b/noncore/settings/networksettings2/usb/usbrun.h
index 60f9fe8..6c6e4e4 100644
--- a/noncore/settings/networksettings2/usb/usbrun.h
+++ b/noncore/settings/networksettings2/usb/usbrun.h
@@ -6,28 +6,24 @@
#include "usbdata.h"
class USBRun : public AsDevice {
public :
USBRun( ANetNodeInstance * NNI,
USBData & Data ) :
AsDevice( NNI ),
Pat( "usb[0-9abcdef]" )
{ }
- virtual long count( void )
- { return 1; }
- virtual QString genNic( long nr );
-
virtual AsDevice * device( void )
{ return (AsDevice *)this; }
virtual AsDevice * asDevice( void )
{ return (AsDevice *)this; }
protected :
void detectState( NodeCollection * );
bool setState( NodeCollection * , Action_t A );
bool canSetState( State_t , Action_t A );
bool handlesInterface( const QString & I );