summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/networksettings2
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/networksettings2') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings2/Utils.h1
-rw-r--r--noncore/settings/networksettings2/networksettings2/asline.h2
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.cpp23
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h460
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp13
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.h5
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp18
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.cpp30
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.h11
9 files changed, 364 insertions, 199 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/Utils.h b/noncore/settings/networksettings2/networksettings2/Utils.h
index 63ef51c..739476e 100644
--- a/noncore/settings/networksettings2/networksettings2/Utils.h
+++ b/noncore/settings/networksettings2/networksettings2/Utils.h
@@ -4,5 +4,6 @@
#define Log(x) VLog x
extern void VLog( char * Format, ... );
extern void LogClose( void );
+extern QString removeSpaces( const QString & X );
#endif
diff --git a/noncore/settings/networksettings2/networksettings2/asline.h b/noncore/settings/networksettings2/networksettings2/asline.h
index 6bd93ec..ee4de38 100644
--- a/noncore/settings/networksettings2/networksettings2/asline.h
+++ b/noncore/settings/networksettings2/networksettings2/asline.h
@@ -13,6 +13,8 @@ public :
RuntimeInfo( NNI ) {
}
+ virtual QString deviceFile( void ) = 0;
+
};
#endif
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp
index 8c80e0b..4a2440a 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.cpp
+++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp
@@ -144,7 +144,7 @@ NodeCollection::NodeCollection( QTextStream & TS ) :
if( A == "name" ) {
Name = N;
} else if( A == "number" ) {
- Log(( "read number %s\n", N.latin1() ));
+ Log(( "Profile number %s\n", N.latin1() ));
setNumber( N.toLong() );
} else if( A == "node" ) {
ANetNodeInstance * NNI = NSResources->findNodeInstance( N );
@@ -295,8 +295,27 @@ void NodeCollection::reassign( void ) {
}
bool NodeCollection::triggersVPN() {
- return getToplevel()->runtime()->asFullSetup()->triggersVPN();
+ return getToplevel()->runtime()->asFullSetup()->triggersVPN();
}
+
+bool NodeCollection::hasDataForFile( const QString & S ) {
+ return ( firstWithDataForFile( S ) != 0 );
+}
+
+ANetNodeInstance * NodeCollection::firstWithDataForFile( const QString & S ) {
+ for( QListIterator<ANetNodeInstance> it(*this);
+ it.current();
+ ++it ) {
+ if( it.current()->hasDataForFile( S ) ) {
+ Log(( "Node %s has data for %s\n",
+ it.current()->nodeClass()->name(),
+ S.latin1() ));
+ return it.current();
+ }
+ }
+ return 0;
+}
+
//
//
// RUNTIMEINFO
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index ca35c27..d3d7b34 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -5,6 +5,7 @@
#include <qlist.h>
#include <qdict.h>
#include <qpixmap.h>
+#include <qstringlist.h>
#include <qobject.h>
#include <time.h>
@@ -32,106 +33,146 @@ extern QString quote( QString X );
#include "systemfile.h"
typedef enum State {
- // if we have not yet detected the state of the device
- Unchecked = 0,
- // if we cannot determine the state
- Unknown = 1,
- // if connection cannot be established e.g. because
- // the hardware is not available
- Unavailable = 2,
- // if the connection cannot be establishec but NOT
- // because it is physically impossible but because
- // it has been disabled for FUNCTIONAL reasons
- Disabled = 3,
- // if connection is available to is currently down
- // i.e. the corresponding hardware is not activated
- Off = 4,
- // if connection is available to be used (i.e. the
- // devices if fully ready to be used
- Available = 5,
- // if connection is being used
- IsUp = 6
+ // if we have not yet detected the state of the device
+ Unchecked = 0,
+ // if we cannot determine the state
+ Unknown = 1,
+ // if connection cannot be established e.g. because
+ // the hardware is not available
+ Unavailable = 2,
+ // if the connection cannot be establishec but NOT
+ // because it is physically impossible but because
+ // it has been disabled for FUNCTIONAL reasons
+ Disabled = 3,
+ // if connection is available to is currently down
+ // i.e. the corresponding hardware is not activated
+ Off = 4,
+ // if connection is available to be used (i.e. the
+ // devices if fully ready to be used
+ Available = 5,
+ // if connection is being used
+ IsUp = 6
} State_t;
typedef enum Action {
- // to make the device unavailable functionally
- Disable = 0,
- // to make the device available functionally
- Enable = 1,
- // bring the hardware up
- Activate = 2,
- // bring the hardware down
- Deactivate = 3,
- // bring the connection up
- Up = 4,
- // bring the connection down
- Down = 5
+ // to make the device unavailable functionally
+ Disable = 0,
+ // to make the device available functionally
+ Enable = 1,
+ // bring the hardware up
+ Activate = 2,
+ // bring the hardware down
+ Deactivate = 3,
+ // bring the connection up
+ Up = 4,
+ // bring the connection down
+ Down = 5
} Action_t;
class ANetNode : public QObject{
public:
- typedef QArray<ANetNode *> NetNodeList;
-
- ANetNode( const char * Name ) : QObject( 0, Name ) {}
- virtual ~ANetNode(){};
-
- // pixmap needed for this NetNode
- virtual const QString pixmapName() = 0;
-
- // description for this NetNode
- virtual const QString nodeDescription() = 0;
-
- // create a blank instance of a net node
- virtual ANetNodeInstance * createInstance( void ) = 0;
-
- // return feature this NetNode provides
- virtual const char * provides( void ) = 0;
- virtual const char ** needs( void ) = 0;
-
- // generate files specific for this node (if any)
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0;
- // return TRUE if this node has data to be inserted in systemfile
- // with name S
- virtual bool hasDataFor( const QString & S ) = 0;
- // generate data specific for the device for the system file S
- // called only IF data was needed
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr ) = 0;
-
- // does this Node provide a Connection
- bool isToplevel( void )
- { return strcmp( provides(), "fullsetup") == 0 ; }
-
- // generate NIC name based on instance nr
- // only relevant if node instances are devices
- virtual QString genNic( long )
- { return QString(""); }
-
- // max number of instances for this node type
- // only relevant if node instances are devices
- virtual long instanceCount( void )
- { return 1; }
-
- // set the value of an attribute
- void setAttribute( QString & Attr, QString & Value ) ;
- void saveAttributes( QTextStream & TS ) ;
-
- // compiled references to 'needed' NetNodes -> needs list
- void setAlternatives( NetNodeList * Alt )
- { Alternatives = Alt; }
- NetNodeList & alternatives( void )
- { return *Alternatives; }
+ typedef QArray<ANetNode *> NetNodeList;
+
+ ANetNode( const char * Name ) : QObject( 0, Name ) {}
+ virtual ~ANetNode(){};
+
+ //
+ //
+ // standard methods with sensible default
+ //
+ //
+
+ inline int done( void )
+ { return Done; }
+ inline void setDone( int D )
+ { Done = D; }
+
+ // does this Node provide a Connection
+ inline bool isToplevel( void )
+ { return strcmp( provides(), "fullsetup") == 0 ; }
+
+ // set the value of an attribute
+ void setAttribute( QString & Attr, QString & Value ) ;
+ void saveAttributes( QTextStream & TS ) ;
+
+ // compiled references to 'needed' NetNodes -> needs list
+ inline void setAlternatives( NetNodeList * Alt )
+ { Alternatives = Alt; }
+ inline NetNodeList & alternatives( void )
+ { return *Alternatives; }
+
+ //
+ //
+ // Virtual methods with sensible default
+ //
+ //
+
+ // do instances of this noce class have data for this file
+ virtual bool hasDataForFile( const QString & )
+ { return 0; }
+
+ // generate instance independent stuff
+ // 0 : data output, 1 no data, 2 error
+ virtual short generateFile( const QString & ,
+ const QString & ,
+ QTextStream & ,
+ long )
+ { return 1; }
+
+ // generate instance dependent but profile common stuff
+ // 0 : data output, 1 no data, 2 error
+ virtual short generateFile( const QString & ,
+ const QString & ,
+ QTextStream & ,
+ ANetNodeInstance * ,
+ long )
+ { return 1; }
+
+
+ // generate NIC name based on instance nr
+ // only relevant if node instances are devices
+ virtual QString genNic( long )
+ { return QString(""); }
+
+ // max number of instances for this node type
+ // only relevant if node instances are devices
+ virtual long instanceCount( void )
+ { return 1; }
+
+ // return list of files that are specific for this node class
+ virtual QStringList * properFiles( void )
+ { return 0; }
+
+ //
+ //
+ // pure virtual methods with sensible default
+ //
+ //
+
+ // pixmap needed for this NetNode
+ virtual const QString pixmapName() = 0;
+
+ // description for this NetNode
+ virtual const QString nodeDescription() = 0;
+
+ // create a blank instance of a net node
+ virtual ANetNodeInstance * createInstance( void ) = 0;
+
+ // return feature this NetNode provides
+ virtual const char * provides( void ) = 0;
+ virtual const char ** needs( void ) = 0;
protected :
- NetNodeList * Alternatives;
+ NetNodeList * Alternatives;
private :
- virtual void setSpecificAttribute( QString & , QString & ) = 0;
- virtual void saveSpecificAttribute( QTextStream & ) = 0;
+ virtual void setSpecificAttribute( QString & , QString & ) = 0;
+ virtual void saveSpecificAttribute( QTextStream & ) = 0;
+ int Done;
};
@@ -139,91 +180,138 @@ class ANetNodeInstance : public QObject {
public:
- ANetNodeInstance( ANetNode * NN ) : QObject()
- { IsModified=0; NodeType = NN; IsNew = TRUE; }
- virtual ~ANetNodeInstance( void ) { }
-
- virtual RuntimeInfo * runtime( void ) = 0;
-
- void setConnection( NodeCollection * NC )
- { Connection = NC; }
- NodeCollection * connection( void )
- { return Connection; }
-
- // create edit widget under parent
- virtual QWidget * edit( QWidget * parent ) = 0;
- // is given data acceptable
- virtual QString acceptable( void ) = 0;
-
- // return data was modified
- void setModified( bool M )
- { IsModified = M; }
- bool isModified( void )
- { return IsModified; }
-
- // get data from GUI and store in node
- virtual void commit( void ) = 0;
-
- // get next node
- ANetNodeInstance * nextNode();
- // return NetNode this is an instance of
- ANetNode * nodeClass( void )
- { return NodeType; }
-
- // intialize am instance of a net node
- void initialize( void );
-
- // set the value of an attribute
- void setAttribute( QString & Attr, QString & Value ) ;
- void saveAttributes( QTextStream & TS ) ;
+ ANetNodeInstance( ANetNode * NN ) : QObject()
+ { IsModified=0; NodeType = NN; IsNew = TRUE; }
+ virtual ~ANetNodeInstance( void ) { }
+
+ inline int done( void )
+ { return Done; }
+ inline void setDone( int D )
+ { Done = D; }
+
+ // return data was modified
+ inline void setModified( bool M )
+ { IsModified = M; }
+ inline bool isModified( void )
+ { return IsModified; }
+
+ // get next node
+ ANetNodeInstance * nextNode();
+ // return NetNode this is an instance of
+ ANetNode * nodeClass( void )
+ { return NodeType; }
+
+ // intialize am instance of a net node
+ void initialize( void );
+
+ // set the value of an attribute
+ void setAttribute( QString & Attr, QString & Value ) ;
+ void saveAttributes( QTextStream & TS ) ;
+
+ // return true if node isntance is NEW and not loaded
+ inline void setNew( bool IsN )
+ { IsNew = IsN; }
+ inline bool isNew( void )
+ { return IsNew; }
+
+ // return description for this instance
+ inline QString & description( void )
+ { return Description; }
+ inline void setDescription( const QString & S )
+ { Description = S; }
+
+ // pixmap for this instance -> from NetNode
+ inline const QString pixmapName( void )
+ { return NodeType->pixmapName(); }
+
+ inline const char * provides( void )
+ { return NodeType->provides(); }
+
+ inline const char ** needs( void )
+ { return NodeType->needs(); }
+
+ inline void setConnection( NodeCollection * NC )
+ { Connection = NC; }
+ inline NodeCollection * connection( void )
+ { return Connection; }
+
+ //
+ //
+ // Virtual methods with sensible defaults
+ //
+ //
+
+
+
+ // open proper file identified by S
+ virtual QFile * openFile( const QString & )
+ { return 0; }
+
+ // check if this node (or sub nodes) have data for this file
+ virtual bool hasDataForFile( const QString & S )
+ { return nodeClass()->hasDataForFile( S ); }
+
+ // generate code specific for this node but embedded
+ // in the section of the parent
+ // this is called within the code of the parent
+ virtual short generateFileEmbedded( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr )
+ { ANetNodeInstance * NNI = nextNode();
+ return (NNI) ? NNI->generateFileEmbedded( ID, Path, TS, DevNr ) : 1;
+ }
- // return true if node isntance is NEW and not loaded
- void setNew( bool IsN )
- { IsNew = IsN; }
- bool isNew( void )
- { return IsNew; }
+ // generate code specific for this node
+ // (or find the first node that does)
+ virtual short generateFile( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr )
+ { ANetNodeInstance * NNI = nextNode();
+ return (NNI) ? NNI->generateFile( ID, Path, TS, DevNr ) : 1;
+ }
- // return description for this instance
- QString & description( void )
- { return Description; }
- void setDescription( const QString & S )
- { Description = S; }
+ // return true if this node instance is triggered by this trigger
+ // could be delegated to deeper instances
+ virtual bool triggeredBy( const QString & )
+ { return 0; }
- // pixmap for this instance -> from NetNode
- const QString pixmapName( void )
- { return NodeType->pixmapName(); }
+ //
+ //
+ // Pure virtual functions
+ //
+ //
- const char * provides( void )
- { return NodeType->provides(); }
+ // return runtime information for this node
+ virtual RuntimeInfo * runtime( void ) = 0;
- const char ** needs( void )
- { return NodeType->needs(); }
+ // create edit widget under parent
+ virtual QWidget * edit( QWidget * parent ) = 0;
- // returns node specific data -> only useful for 'buddy'
- virtual void * data( void ) = 0;
+ // is given data acceptable
+ virtual QString acceptable( void ) = 0;
- // return TRUE if this node has data to be inserted in systemfile
- // with name S
- virtual bool hasDataFor( const QString & S ) = 0;
+ // get data from GUI and store in node
+ virtual void commit( void ) = 0;
- // generate data specific for a profile and for the system file S
- // called only IF data was needed
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr ) = 0;
+ // returns node specific data -> only useful for 'buddy'
+ virtual void * data( void ) = 0;
protected :
- virtual void setSpecificAttribute( QString & , QString & ) = 0;
- virtual void saveSpecificAttribute( QTextStream & ) = 0;
+ virtual void setSpecificAttribute( QString & , QString & ) = 0;
+ virtual void saveSpecificAttribute( QTextStream & ) = 0;
- ANetNode * NodeType;
- // connection to which this node belongs to
- NodeCollection * Connection;
- QString Description;
- bool IsModified;
- bool IsNew;
+ ANetNode * NodeType;
+ // connection to which this node belongs to
+ NodeCollection * Connection;
+ QString Description;
+ bool IsModified;
+ bool IsNew;
+ int Done;
- static long InstanceCounter;
+ static long InstanceCounter;
};
class RuntimeInfo : public QObject {
@@ -282,34 +370,39 @@ public :
NodeCollection( QTextStream & TS );
~NodeCollection( void );
- int number( void )
+ inline int done( void )
+ { return Done; }
+ inline void setDone( int D )
+ { Done = D; }
+
+ inline int number( void )
{ return Number; }
- void setNumber( int i )
+ inline void setNumber( int i )
{ Number = i; }
- bool isNew( void )
+ inline bool isNew( void )
{ return IsNew; }
- void setNew( bool N )
+ inline void setNew( bool N )
{ IsNew = N ; }
- bool isModified( void )
+ inline bool isModified( void )
{ return IsModified; }
- void setModified( bool N )
+ inline void setModified( bool N )
{ IsModified = N ; }
- bool handlesInterface( const QString & S ) {
+ inline bool handlesInterface( const QString & S ) {
return getToplevel()->runtime()->handlesInterface( S );
}
- InterfaceInfo * assignedInterface( void ) {
+ inline InterfaceInfo * assignedInterface( void ) {
return getToplevel()->runtime()->assignedInterface();
}
- AsDevice * device() {
+ inline AsDevice * device() {
return getToplevel()->runtime()->device();
}
bool triggersVPN();
- State_t state( bool Update = 0 )
+ inline State_t state( bool Update = 0 )
{ Log(( "%s state %d(=%d?)\n", Name.latin1(), CurrentState,
Unchecked ));
if( CurrentState == Unchecked || Update ) {
@@ -325,15 +418,15 @@ public :
// get the ixmap for this device
QPixmap devicePixmap( void );
QPixmap statePixmap( State_t S );
- QPixmap statePixmap( bool Update = 0 )
+ inline QPixmap statePixmap( bool Update = 0 )
{ return statePixmap( state(Update) ); }
QString stateName( State_t );
- QString stateName( bool Update = 0 )
+ inline QString stateName( bool Update = 0 )
{ return stateName( state(Update) ); }
- bool setState( Action_t A, bool Force =0 )
+ inline bool setState( Action_t A, bool Force =0 )
{ return getToplevel()->runtime()->setState( this, A, Force ); }
- bool canSetState( Action_t A )
+ inline bool canSetState( Action_t A )
{ return getToplevel()->runtime()->canSetState( CurrentState, A ); }
void save( QTextStream & TS );
@@ -348,19 +441,35 @@ public :
ANetNodeInstance * findNext( ANetNodeInstance * NNI );
ANetNodeInstance * findByName( const QString & S );
- const QString & name()
+ inline const QString & name()
{ return Name; }
const QString & description( void );
- void setName( const QString & N)
+ inline void setName( const QString & N)
{ Name = N; }
- State_t currentState( void )
+ inline State_t currentState( void )
{ return CurrentState; }
- void setCurrentState( State_t S )
+ inline void setCurrentState( State_t S )
{ CurrentState = S; }
+ // return TRUE if this node can have data to be inserted in
+ // file identified by S
+ bool hasDataForFile( const QString & S );
+ ANetNodeInstance * firstWithDataForFile( const QString & S );
+
+ // generate items for this file -> toplevel call
+ short generateFile( const QString & FID, // identification of file
+ const QString & FName, // effective filename of file
+ QTextStream & TS, // stream to file
+ long DN // device number
+ )
+ { return getToplevel()->generateFile( FID, FName, TS, DN ); }
+
+ bool triggeredBy( const QString & Trigger )
+ { return getToplevel()->triggeredBy( Trigger ); }
+
private :
int compareItems ( QCollection::Item item1,
@@ -378,6 +487,7 @@ private :
// index in listbox
int Index;
bool IsModified;
+ int Done;
};
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp
index 71e84cd..7ece817 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.cpp
+++ b/noncore/settings/networksettings2/networksettings2/resources.cpp
@@ -77,7 +77,7 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
tr( "<p>Fully configured connection profile</p>" ) );
// define system files
- addSystemFile( new SystemFile( "interfaces", "./interfaces" ) );
+ addSystemFile( "interfaces", "/tmp/interfaces", 1 );
// get access to the system
TheSystem = new System();
@@ -88,7 +88,16 @@ TheNSResources::~TheNSResources( void ) {
delete TheSystem;
}
-void TheNSResources::busy( bool B ) {
+void TheNSResources::addSystemFile( const QString & ID,
+ const QString & P,
+ bool KDI ) {
+ if( ! SystemFiles.find( ID ) ) {
+ // new system file
+ SystemFiles.insert( ID, new SystemFile( ID, P, KDI ) );
+ } // else existed
+}
+
+void TheNSResources::busy( bool ) {
/*
if( B ) {
ShowWait->show();
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h
index 55d2f29..16355ba 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.h
+++ b/noncore/settings/networksettings2/networksettings2/resources.h
@@ -66,8 +66,9 @@ public :
Name2SystemFile_t & systemFiles( void )
{ return SystemFiles; }
- void addSystemFile( SystemFile * SF )
- { SystemFiles.insert( SF->name(), SF ); }
+ void addSystemFile( const QString & ID,
+ const QString & P,
+ bool KDI );
ANetNodeInstance * createNodeInstance( const QString & S )
{ ANetNodeInstance * NNI = 0;
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp
index a579396..271e73d 100644
--- a/noncore/settings/networksettings2/networksettings2/system.cpp
+++ b/noncore/settings/networksettings2/networksettings2/system.cpp
@@ -390,8 +390,11 @@ void VLog( char * Format, ... ) {
va_start(l, Format );
if( logf == (FILE *)0 ) {
- // logf = fopen( "/tmp/ns2log", "a" );
- logf = stderr;
+ if( getenv("NS2STDERR") ) {
+ logf = stderr;
+ } else {
+ logf = fopen( "/tmp/ns2log", "a" );
+ }
if( ! logf ) {
fprintf( stderr, "Cannot open logfile /tmp/ns2log %d\n",
errno );
@@ -411,7 +414,16 @@ void VLog( char * Format, ... ) {
void LogClose( void ) {
if( (long)logf > 1 ) {
fprintf( logf, "____ CLOSE LOGFILE ____\n");
- fclose( logf );
+ if( logf != stderr ) {
+ fclose( logf );
+ }
logf = 0;
}
}
+
+QString removeSpaces( const QString & X ) {
+ QStringList SL;
+
+ SL = QStringList::split( " ", X );
+ return SL.join( "_" );
+}
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
index b3fc1a5..2b40834 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
@@ -11,7 +11,9 @@
#define TEMPLATEDIR "networktemplates/"
QString TemplDir;
-SystemFile::SystemFile( const QString & N, const QString & P ){
+SystemFile::SystemFile( const QString & N,
+ const QString & P,
+ bool KDI ){
Name = N;
Path = P;
F = 0;
@@ -57,6 +59,8 @@ SystemFile::SystemFile( const QString & N, const QString & P ){
FI.setFile( S );
hasPostDeviceSection = ( FI.exists() && FI.isReadable() );
}
+
+ KnowsDeviceInstances = KDI;
}
SystemFile::~SystemFile( void ) {
@@ -96,29 +100,29 @@ bool SystemFile::preSection( void ) {
if( hasPreSection ) {
QFile Fl( TemplDir + Name + "/presection" );
if( ! Fl.open( IO_ReadOnly ) )
- return 1; // error
+ return 0; // error
// copy file to this file
F->writeBlock( Fl.readAll() );
}
- return 0;
+ return 1;
}
bool SystemFile::postSection( void ) {
if( hasPostSection ) {
QFile Fl( TemplDir + Name + "/postsection" );
if( ! Fl.open( IO_ReadOnly ) )
- return 1; // error
+ return 0; // error
// copy file to this file
F->writeBlock( Fl.readAll() );
}
- return 0;
+ return 1;
}
bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) {
if( hasPreNodeSection ) {
QFile Fl( TemplDir + Name + "/prenodesection" );
if( ! Fl.open( IO_ReadOnly ) )
- return 1; // error
+ return 0; // error
QTextStream TX( &Fl );
QString Out;
QString S = TX.readLine();
@@ -129,14 +133,14 @@ bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) {
S = TX.readLine();
}
}
- return 0;
+ return 1;
}
bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) {
if( hasPostNodeSection ) {
QFile Fl( TemplDir + Name + "/postnodesection" );
if( ! Fl.open( IO_ReadOnly ) )
- return 1; // error
+ return 0; // error
QTextStream TX( &Fl );
QString Out;
QString S = TX.readLine();
@@ -147,14 +151,14 @@ bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) {
S = TX.readLine();
}
}
- return 0;
+ return 1;
}
bool SystemFile::preDeviceSection( ANetNode * NN ) {
if( hasPreDeviceSection ) {
QFile Fl( TemplDir + Name + "/predevicesection" );
if( ! Fl.open( IO_ReadOnly ) )
- return 1; // error
+ return 0; // error
QTextStream TX( &Fl );
QString Out;
QString S = TX.readLine();
@@ -164,14 +168,14 @@ bool SystemFile::preDeviceSection( ANetNode * NN ) {
S = TX.readLine();
}
}
- return 0;
+ return 1;
}
bool SystemFile::postDeviceSection( ANetNode * NN ) {
if( hasPostDeviceSection ) {
QFile Fl( TemplDir + Name + "/postdevicesection" );
if( ! Fl.open( IO_ReadOnly ) )
- return 1; // error
+ return 0; // error
QTextStream TX( &Fl );
QString Out;
QString S = TX.readLine();
@@ -181,5 +185,5 @@ bool SystemFile::postDeviceSection( ANetNode * NN ) {
S = TX.readLine();
}
}
- return 0;
+ return 1;
}
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.h b/noncore/settings/networksettings2/networksettings2/systemfile.h
index f57dab0..ceed605 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.h
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.h
@@ -11,11 +11,17 @@ class SystemFile : public QTextStream {
public :
- SystemFile( const QString & Name, const QString & Path );
+ SystemFile( const QString & Name,
+ const QString & Path,
+ bool KnowsDevicesInstances );
~SystemFile( void );
- const QString & name( void )
+ const QString & name( void ) const
{ return Name; }
+ const QString & path( void ) const
+ { return Path; }
+ bool knowsDeviceInstances( void ) const
+ { return KnowsDeviceInstances; }
bool open( void );
bool close( void );
@@ -38,6 +44,7 @@ private :
bool hasPostNodeSection;
bool hasPreDeviceSection;
bool hasPostDeviceSection;
+ bool KnowsDeviceInstances;
};
#endif