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 @@ -1,60 +1,49 @@ #include "cable_NN.h" #include "cable_NNI.h" static const char * CableNeeds[] = { 0 }; /** * Constructor, find all of the possible interfaces */ CableNetNode::CableNetNode() : ANetNode(tr("Cable Connection")) { } /** * Delete any interfaces that we own. */ CableNetNode::~CableNetNode(){ } const QString CableNetNode::nodeDescription(){ return tr("\ <p>Sets up a wired serial or parallel.</p>\ " ); } ANetNodeInstance * CableNetNode::createInstance( void ) { return new ACable( this ); } 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 ) { PNN.append( new CableNetNode() ); } } 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 @@ -1,44 +1,36 @@ #ifndef CABLE_NETNODE_H #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" { void create_plugin( QList<ANetNode> & PNN ); }; #endif 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 @@ -4,70 +4,86 @@ ACable::ACable( CableNetNode * PNN ) : ANetNodeInstance( PNN ) { // default values Data.Device = "/dev/ttyS0"; Data.LockFile = "/var/Lock"; Data.Speed = 115200; Data.DataBits = 8; Data.Parity = 0; Data.StopBits = 1; Data.HardwareControl = 0; Data.SoftwareControl = 0; GUI = 0; RT = 0; } void ACable::setSpecificAttribute( QString & A, QString & V) { if( A == "device" ) { Data.Device = V; } else if ( A == "lockfile" ) { Data.LockFile = V; } else if ( A == "speed" ) { Data.Speed = V.toLong(); } else if ( A == "parity" ) { Data.Parity = V.toShort(); } else if ( A == "databits" ) { Data.DataBits = V.toShort(); } else if ( A == "stopbits" ) { Data.StopBits = V.toShort(); } else if ( A == "hardwarecontrol" ) { Data.HardwareControl = ( V == "yes" ); } else if ( A == "softwarecontrol" ) { Data.SoftwareControl = ( V == "yes" ); } } void ACable::saveSpecificAttribute( QTextStream & TS ) { TS << "device=" << quote( Data.Device ) << endl; TS << "lockfile=" << quote( Data.LockFile ) << endl; TS << "speed=" << Data.Speed << endl; TS << "parity=" << Data.Parity << endl; 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 @@ -1,48 +1,46 @@ #ifndef CABLE_H #define CABLE_H #include <netnode.h> #include "cabledata.h" #include "cablerun.h" 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; CableData_t Data; CableRun * RT; }; #endif 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,26 +1,30 @@ #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 ); } bool CableRun::setState( NodeCollection * NC, Action_t A, bool ) { if( A == Activate ) { detectState(NC); 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; }; |