Diffstat (limited to 'noncore/settings/networksettings2/cable') (more/less context) (ignore whitespace changes)
6 files changed, 51 insertions, 50 deletions
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp index b8c690b..38568df 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.cpp +++ b/noncore/settings/networksettings2/cable/cable_NN.cpp @@ -31,27 +31,16 @@ ANetNodeInstance * CableNetNode::createInstance( void ) { const char ** CableNetNode::needs( void ) { return CableNeeds; } const char * CableNetNode::provides( void ) { return "line"; } -bool CableNetNode::generateProperFilesFor( - ANetNodeInstance * ) { - return 0; -} - -bool CableNetNode::generateDeviceDataForCommonFile( - SystemFile & , - long ) { - return 0; -} - void CableNetNode::setSpecificAttribute( QString & , QString & ) { } void CableNetNode::saveSpecificAttribute( QTextStream & ) { } extern "C" { void create_plugin( QList<ANetNode> & PNN ) { diff --git a/noncore/settings/networksettings2/cable/cable_NN.h b/noncore/settings/networksettings2/cable/cable_NN.h index c48037a..5cc2b2d 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.h +++ b/noncore/settings/networksettings2/cable/cable_NN.h @@ -2,38 +2,30 @@ #define CABLE_NETNODE_H #include "netnode.h" class ACable; class CableNetNode : public ANetNode { - Q_OBJECT + Q_OBJECT public: - CableNetNode(); - virtual ~CableNetNode(); + CableNetNode(); + virtual ~CableNetNode(); - virtual const QString pixmapName() - { return "Devices/cable"; } + virtual const QString pixmapName() + { return "Devices/cable"; } - 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 & ) - { 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: virtual void setSpecificAttribute( QString & Attr, QString & Value ); virtual void saveSpecificAttribute( QTextStream & TS ); }; extern "C" diff --git a/noncore/settings/networksettings2/cable/cable_NNI.cpp b/noncore/settings/networksettings2/cable/cable_NNI.cpp index ca21135..4bd9421 100644 --- a/noncore/settings/networksettings2/cable/cable_NNI.cpp +++ b/noncore/settings/networksettings2/cable/cable_NNI.cpp @@ -44,30 +44,46 @@ void ACable::saveSpecificAttribute( QTextStream & TS ) { TS << "databits=" << Data.DataBits << endl; TS << "stopbits=" << Data.StopBits << endl; TS << "hardwarecontrol=" << ((Data.HardwareControl) ? "yes" : "no") << endl; TS << "softwarecontrol=" << ((Data.SoftwareControl) ? "yes" : "no") << endl; } +short ACable::generateFileEmbedded( const QString & ID, + const QString & Path, + QTextStream & TS, + long DevNr ) { + short rvl, rvd; + + rvl = 1; + if( ID == "peers" ) { + TS << Data.Device + << endl; + TS << Data.Speed + << endl; + TS << "lock " + << Data.LockFile + << endl; + rvl = 0; + } + + rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); + return (rvd == 2 || rvl == 2 ) ? 2 : + (rvd == 0 || rvl == 0 ) ? 0 : 1; +} + QWidget * ACable::edit( QWidget * parent ) { GUI = new CableEdit( parent ); GUI->showData( Data ); return GUI; } QString ACable::acceptable( void ) { return ( GUI ) ? GUI->acceptable( ) : QString(); } void ACable::commit( void ) { if( GUI && GUI->commit( Data ) ) { setModified( 1 ); } } - -bool ACable::generateDataForCommonFile( - SystemFile & , - long ) { - return 1; -} - diff --git a/noncore/settings/networksettings2/cable/cable_NNI.h b/noncore/settings/networksettings2/cable/cable_NNI.h index bf3e292..d06cbbe 100644 --- a/noncore/settings/networksettings2/cable/cable_NNI.h +++ b/noncore/settings/networksettings2/cable/cable_NNI.h @@ -9,34 +9,32 @@ class CableNetNode; class CableEdit; class ACable : public ANetNodeInstance { public : ACable( CableNetNode * PNN ); + RuntimeInfo * runtime( void ) + { return + ( RT ) ? RT : ( RT = new CableRun( this, Data ) ); + } + QWidget * edit( QWidget * parent ); QString acceptable( void ); void commit( void ); - RuntimeInfo * runtime( void ) - { if( RT == 0 ) - RT = new CableRun( this, Data ); - return RT; - } - virtual void * data( void ) { return (void *)&Data; } - virtual bool hasDataFor( const QString & ) - { return 0; } - virtual bool generateDataForCommonFile( - SystemFile & SF, long DevNr ); - + short generateFileEmbedded( const QString & ID, + const QString & Path, + QTextStream & TS, + long DevNr ); protected : virtual void setSpecificAttribute( QString & Attr, QString & Value ); virtual void saveSpecificAttribute( QTextStream & TS ); private : CableEdit * GUI; diff --git a/noncore/settings/networksettings2/cable/cablerun.cpp b/noncore/settings/networksettings2/cable/cablerun.cpp index 5e99237..85660f6 100644 --- a/noncore/settings/networksettings2/cable/cablerun.cpp +++ b/noncore/settings/networksettings2/cable/cablerun.cpp @@ -1,15 +1,15 @@ #include <fcntl.h> #include <unistd.h> #include "cablerun.h" void CableRun::detectState( NodeCollection * NC ) { - int fd = open( D->Device.latin1(), O_RDWR ); + int fd = open( Data->Device.latin1(), O_RDWR ); if( fd < 0 ) { NC->setCurrentState( Unavailable ); } close( fd ); NC->setCurrentState( Available ); } @@ -19,8 +19,12 @@ bool CableRun::setState( NodeCollection * NC, Action_t A, bool ) { return (NC->currentState() == Available); } return 1; } bool CableRun::canSetState( State_t , Action_t ) { return 1; } + +QString CableRun::deviceFile( void ) { + return Data->Device; +} diff --git a/noncore/settings/networksettings2/cable/cablerun.h b/noncore/settings/networksettings2/cable/cablerun.h index c5b59d5..20608f6 100644 --- a/noncore/settings/networksettings2/cable/cablerun.h +++ b/noncore/settings/networksettings2/cable/cablerun.h @@ -1,24 +1,26 @@ #include <asline.h> #include "cabledata.h" class CableRun : public AsLine { public : CableRun( ANetNodeInstance * NNI, - CableData & Data ) : AsLine( NNI ) - { D = &Data; } + CableData_t & D ) : AsLine( NNI ) + { Data = &D; } virtual AsLine * asLine( void ) { return (AsLine *)this; } + virtual QString deviceFile( void ); + protected : void detectState( NodeCollection * NC ); bool setState( NodeCollection * NC, Action_t A, bool Force ); bool canSetState( State_t Curr, Action_t A ); private : - CableData_t * D; + CableData_t * Data; }; |