summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h3
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h5
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h3
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp24
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth_NN.h16
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.cpp14
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.h7
-rw-r--r--noncore/settings/networksettings2/cable/cable_NNI.cpp7
-rw-r--r--noncore/settings/networksettings2/cable/cable_NNI.h5
-rw-r--r--noncore/settings/networksettings2/editconnection.cpp15
-rw-r--r--noncore/settings/networksettings2/irda/irda_NN.cpp14
-rw-r--r--noncore/settings/networksettings2/irda/irda_NN.h7
-rw-r--r--noncore/settings/networksettings2/irda/irda_NNI.cpp7
-rw-r--r--noncore/settings/networksettings2/irda/irda_NNI.h5
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.cpp29
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.h11
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NNI.cpp15
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NNI.h6
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.h5
-rw-r--r--noncore/settings/networksettings2/modem/modem_NN.cpp14
-rw-r--r--noncore/settings/networksettings2/modem/modem_NN.h7
-rw-r--r--noncore/settings/networksettings2/modem/modem_NNI.cpp6
-rw-r--r--noncore/settings/networksettings2/modem/modem_NNI.h5
-rw-r--r--noncore/settings/networksettings2/network/network_NN.cpp17
-rw-r--r--noncore/settings/networksettings2/network/network_NN.h7
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.cpp7
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.h4
-rw-r--r--noncore/settings/networksettings2/network/networkrun.cpp1
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp4
-rw-r--r--noncore/settings/networksettings2/networksettings2/asdevice.h6
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.cpp2
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h50
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.cpp14
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.h4
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp303
-rw-r--r--noncore/settings/networksettings2/nsdata.h5
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.cpp17
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.h9
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.cpp6
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.h5
-rw-r--r--noncore/settings/networksettings2/ppp/ppprun.h2
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.cpp14
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.h7
-rw-r--r--noncore/settings/networksettings2/profile/profile_NNI.cpp6
-rw-r--r--noncore/settings/networksettings2/profile/profile_NNI.h6
-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
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.cpp14
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.h7
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NNI.cpp6
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NNI.h4
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.cpp29
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.h12
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NNI.cpp16
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NNI.h6
-rw-r--r--noncore/settings/networksettings2/wlan/wlanrun.h4
60 files changed, 413 insertions, 483 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h
index a21f574..bb3e7e7 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h
@@ -1,43 +1,46 @@
#ifndef BLUETOOTHBNEP_H
#define BLUETOOTHBNEP_H
#include <netnode.h>
#include "bluetoothBNEPdata.h"
#include "bluetoothBNEPrun.h"
class BluetoothBNEPNetNode;
class BluetoothBNEPEdit;
class ABluetoothBNEP : public ANetNodeInstance {
public :
ABluetoothBNEP( BluetoothBNEPNetNode * PNN );
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
RuntimeInfo * runtime( void )
{ if( RT == 0 )
RT = new BluetoothBNEPRun( this, Data );
return RT;
}
virtual void * data( void )
{ return (void *)&Data; }
+ virtual bool hasDataFor( const QString & S );
+ virtual bool generateDataForCommonFile( SystemFile & SF, long );
+
protected :
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
private :
BluetoothBNEPEdit * GUI;
BluetoothBNEPData Data;
BluetoothBNEPRun * RT;
};
#endif
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
index 347da0c..4a773cd 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
@@ -1,36 +1,31 @@
#include <asdevice.h>
#include "bluetoothBNEPdata.h"
class BluetoothBNEPRun : public AsDevice {
public :
BluetoothBNEPRun( ANetNodeInstance * NNI,
BluetoothBNEPData & Data ) : AsDevice( NNI )
{ }
- virtual long count( void )
- { return 3; }
- virtual QString genNic( long nr )
- { QString S; return S.sprintf( "bnep%ld", nr ); }
-
virtual AsDevice * asDevice( void )
{ return (AsDevice *)this; }
virtual AsDevice * device( void )
{ return asDevice(); }
protected :
void detectState( NodeCollection * )
{ }
bool setState( NodeCollection * , Action_t )
{ return 0; }
bool canSetState( State_t , Action_t )
{ return 0; }
bool handlesInterface( const QString & )
{ return 0; }
};
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h
index 57ff95e..97bd29c 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h
@@ -1,42 +1,45 @@
#ifndef BLUETOOTHRFCOMM_H
#define BLUETOOTHRFCOMM_H
#include <netnode.h>
#include "bluetoothRFCOMMdata.h"
#include "bluetoothRFCOMMrun.h"
class BluetoothRFCOMMNetNode;
class BluetoothRFCOMMEdit;
class ABluetoothRFCOMM : public ANetNodeInstance {
public :
ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN );
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
RuntimeInfo * runtime( void )
{ if( RT == 0 )
RT = new BluetoothRFCOMMRun( this, Data );
return RT;
}
virtual void * data( void )
{ return (void *)&Data; }
+ virtual bool hasDataFor( const QString & S );
+ virtual bool generateDataForCommonFile( SystemFile & SF, long );
+
protected :
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
private :
BluetoothRFCOMMEdit * GUI;
BluetoothRFCOMMData Data;
BluetoothRFCOMMRun * RT;
};
#endif
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
index 47272c4..3d1aa69 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
@@ -1,127 +1,123 @@
#include "bluetooth_NN.h"
#include "bluetoothBNEP_NNI.h"
#include "bluetoothRFCOMM_NNI.h"
//
//
// BLUETOOTH PAN/NAP node
//
//
static const char * BluetoothBNEPNeeds[] =
{ 0
};
/**
* Constructor, find all of the possible interfaces
*/
BluetoothBNEPNetNode::BluetoothBNEPNetNode() : ANetNode() {
}
/**
* Delete any interfaces that we own.
*/
BluetoothBNEPNetNode::~BluetoothBNEPNetNode(){
}
const QString BluetoothBNEPNetNode::nodeDescription(){
return tr("\
<p>Sets up a bluetooth link using the bluetooth Network profile.</p>\
<p>Use this to connect two computing devices.</p>\
"
);
}
ANetNodeInstance * BluetoothBNEPNetNode::createInstance( void ) {
return new ABluetoothBNEP( this );
}
const char ** BluetoothBNEPNetNode::needs( void ) {
return BluetoothBNEPNeeds;
}
const char * BluetoothBNEPNetNode::provides( void ) {
return "device";
}
bool BluetoothBNEPNetNode::generateProperFilesFor(
ANetNodeInstance * ) {
return 1;
}
-bool BluetoothBNEPNetNode::hasDataFor( const QString & S, bool DS ) {
- return DS && S == "interfaces";
+bool BluetoothBNEPNetNode::hasDataFor( const QString & S ) {
+ return S == "interfaces";
}
-bool BluetoothBNEPNetNode::generateDataForCommonFile(
+bool BluetoothBNEPNetNode::generateDeviceDataForCommonFile(
SystemFile & ,
- long ,
- ANetNodeInstance * ) {
+ long ) {
return 1;
}
-bool BluetoothBNEPNetNode::generateDeviceDataForCommonFile(
- SystemFile & ,
- long ,
- ANetNodeInstance * ) {
- return 1;
+QString BluetoothBNEPNetNode::genNic( long nr ) {
+ QString S;
+ return S.sprintf( "bnep%ld", nr );
}
//
//
// BLUETOOTH PAN/NAP node
//
//
static const char * BluetoothRFCOMMNeeds[] =
{ 0
};
BluetoothRFCOMMNetNode::BluetoothRFCOMMNetNode() : ANetNode() {
}
BluetoothRFCOMMNetNode::~BluetoothRFCOMMNetNode(){
}
const QString BluetoothRFCOMMNetNode::nodeDescription(){
return tr("\
<p>Sets up a bluetooth link using the bluetooth serial profile.</p>\
<p>Use this to connect to a GSM.</p>\
"
);
}
ANetNodeInstance * BluetoothRFCOMMNetNode::createInstance( void ) {
return new ABluetoothRFCOMM( this );
}
const char ** BluetoothRFCOMMNetNode::needs( void ) {
return BluetoothRFCOMMNeeds;
}
const char * BluetoothRFCOMMNetNode::provides( void ) {
return "line";
}
bool BluetoothRFCOMMNetNode::generateProperFilesFor(
ANetNodeInstance * ) {
return 0;
}
-bool BluetoothRFCOMMNetNode::hasDataFor( const QString &, bool ) {
+bool BluetoothRFCOMMNetNode::hasDataFor( const QString & ) {
return 0;
}
-bool BluetoothRFCOMMNetNode::generateDataForCommonFile(
+bool BluetoothRFCOMMNetNode::generateDeviceDataForCommonFile(
SystemFile & ,
- long,
- ANetNodeInstance * ) {
+ long ) {
return 0;
}
extern "C" {
void create_plugin( QList<ANetNode> & PNN ) {
PNN.append( new BluetoothBNEPNetNode() );
PNN.append( new BluetoothRFCOMMNetNode() );
}
}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
index d72b0d4..5cd6c52 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
@@ -1,79 +1,79 @@
#ifndef BLUETOOTH_NETNODE_H
#define BLUETOOTH_NETNODE_H
#include "netnode.h"
class ABluetoothBNEP;
class BluetoothBNEPNetNode : public ANetNode {
Q_OBJECT
public:
BluetoothBNEPNetNode();
virtual ~BluetoothBNEPNetNode();
virtual const QString pixmapName()
{ return "Devices/bluetooth"; }
virtual const QString nodeName()
{ return tr("Bluetooth PAN/NAP"); }
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 DS );
- 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 & , long DevNr );
+
+ virtual long instanceCount( void )
+ { return 7; }
+ virtual QString genNic( long );
private:
};
class BluetoothRFCOMMNetNode : public ANetNode {
Q_OBJECT
public:
BluetoothRFCOMMNetNode();
virtual ~BluetoothRFCOMMNetNode();
virtual const QString pixmapName()
{ return "Devices/bluetooth"; }
virtual const QString nodeName()
{ return tr("Bluetooth serial link"); }
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 );
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long, ANetNodeInstance * NNI );
+ virtual bool hasDataFor( const QString & S );
virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long, ANetNodeInstance * NNI );
+ SystemFile & , long );
private:
};
extern "C"
{
void create_plugin( QList<ANetNode> & PNN );
};
#endif
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp
index 6f62772..a6be4d5 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NN.cpp
@@ -1,66 +1,54 @@
#include "cable_NN.h"
#include "cable_NNI.h"
static const char * CableNeeds[] =
{ 0
};
/**
* Constructor, find all of the possible interfaces
*/
CableNetNode::CableNetNode() : ANetNode() {
}
/**
* 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 1;
}
-bool CableNetNode::hasDataFor( const QString &, bool ) {
- return 0;
-}
-
-bool CableNetNode::generateDataForCommonFile(
- SystemFile & ,
- long ,
- ANetNodeInstance * ) {
- return 1;
-}
-
bool CableNetNode::generateDeviceDataForCommonFile(
SystemFile & ,
- long ,
- ANetNodeInstance * ) {
+ long ) {
return 1;
}
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 3875af6..83b98e0 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.h
+++ b/noncore/settings/networksettings2/cable/cable_NN.h
@@ -1,46 +1,45 @@
#ifndef CABLE_NETNODE_H
#define CABLE_NETNODE_H
#include "netnode.h"
class ACable;
class CableNetNode : public ANetNode {
Q_OBJECT
public:
CableNetNode();
virtual ~CableNetNode();
virtual const QString pixmapName()
{ return "Devices/cable"; }
virtual const QString nodeName()
{ return tr("Cable Connection"); }
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 DS );
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ virtual bool hasDataFor( const QString & )
+ { return 0; }
virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ SystemFile & SF, long DevNr);
private:
};
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 d26afd1..ca21135 100644
--- a/noncore/settings/networksettings2/cable/cable_NNI.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NNI.cpp
@@ -1,66 +1,73 @@
#include "cableedit.h"
#include "cable_NNI.h"
#include "cable_NN.h"
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;
}
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 0654a5d..bf3e292 100644
--- a/noncore/settings/networksettings2/cable/cable_NNI.h
+++ b/noncore/settings/networksettings2/cable/cable_NNI.h
@@ -1,43 +1,48 @@
#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 );
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 );
+
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/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp
index ce13573..4bbe502 100644
--- a/noncore/settings/networksettings2/editconnection.cpp
+++ b/noncore/settings/networksettings2/editconnection.cpp
@@ -11,336 +11,331 @@
#include <qcheckbox.h>
#include <qlabel.h>
#include "editconnection.h"
#include "resources.h"
#include "netnode.h"
//
//
// THESE TO GIVE BETTER FEEDBACK ABOUT DISABLED ITEMS
//
//
class MyQCheckListItem : public QCheckListItem
{
public:
MyQCheckListItem( QListView *parent, const QString & S, Type T ) :
QCheckListItem( parent, S, T ) { }
MyQCheckListItem( QCheckListItem *parent, const QString & S, Type T ) :
QCheckListItem( parent, S, T ) { }
MyQCheckListItem( QListViewItem *parent, const QString & S, Type T ) :
QCheckListItem( parent, S, T ) { }
virtual void paintCell( QPainter *p, const QColorGroup &cg,
int column, int width, int alignment );
};
void MyQCheckListItem::paintCell( QPainter *p, const QColorGroup &cg,
int column, int width, int alignment )
{
QColorGroup _cg( cg );
QColor c = _cg.text();
if ( ! isSelectable() )
_cg.setColor( QColorGroup::Text, Qt::lightGray );
QCheckListItem::paintCell( p, _cg, column, width, alignment );
_cg.setColor( QColorGroup::Text, c );
}
class MyQListViewItem : public QListViewItem
{
public:
MyQListViewItem( QListView *parent, const QString & S ) :
QListViewItem( parent, S ) { }
MyQListViewItem( QListViewItem *parent, const QString & S ) :
QListViewItem( parent, S ) { }
virtual void paintCell( QPainter *p, const QColorGroup &cg,
int column, int width, int alignment );
};
void MyQListViewItem::paintCell( QPainter *p, const QColorGroup &cg,
int column, int width, int alignment )
{
QColorGroup _cg( cg );
QColor c = _cg.text();
if ( ! isSelectable() )
_cg.setColor( QColorGroup::Text, Qt::lightGray );
QListViewItem::paintCell( p, _cg, column, width, alignment );
_cg.setColor( QColorGroup::Text, c );
}
//
//
// REAL GUI
//
//
bool EditConnection::AutoCollapse = 1;
EditConnection::EditConnection( QWidget* parent ) :
EditConnectionGUI( parent, 0, TRUE ), TmpCollection() {
Tab_TB->setTabEnabled( Setup_FRM, FALSE );
Setup_FRM->setEnabled( FALSE );
TmpIsValid = 0;
SelectedNodes = 0;
AutoCollapse_CB->setChecked( AutoCollapse );
Mapping = new QPtrDict<ANetNode>;
Mapping->setAutoDelete( FALSE );
Nodes_LV->header()->hide();
// popluate tree with all NetNodes
buildFullTree();
}
NodeCollection * EditConnection::getTmpCollection( void ) {
if( TmpIsValid )
// content is stil OK
return &(TmpCollection);
// reset collection -> delete all NEW NetNodes
- { ANetNodeInstance * NNI;
for( QListIterator<ANetNodeInstance> it(TmpCollection);
it.current();
++it ) {
if( it.current()->isNew() ) {
delete it.current();
}
}
TmpCollection.clear();
- }
// update content
QListViewItem * it = Nodes_LV->firstChild();
ANetNode * NN;
// start iter
ANetNodeInstance * NNI =
(SelectedNodes) ? SelectedNodes->first() : 0 ;
TmpCollection.setModified( 0 );
while ( it ) {
NN = (*Mapping)[it];
if( NN == 0 ) {
// child is controller -> has sub radio
// check if one radio is selected
it = it->firstChild();
while( it ) {
if( ((QCheckListItem *)it)->isOn() ) {
// this radio is selected -> go deeper
if( SelectedNodes == 0 ||
NNI == 0 ||
- NNI->netNode()->nodeName() != it->text(0) ) {
+ NNI->nodeClass()->nodeName() != it->text(0) ) {
// new item not in previous collection
ANetNodeInstance * NNI = (*Mapping)[it]->createInstance();
NNI->initialize();
// this node type not in collection
TmpCollection.append( NNI );
// master collection changed because new item in it
TmpCollection.setModified( 1 );
// no more valid items in old list
NNI = 0;
} else {
// already in list -> copy pointer
TmpCollection.append( NNI );
NNI = SelectedNodes->next();
}
it = it->firstChild();
// do not bother to check other items
break;
}
it = it->nextSibling();
}
} else {
// check children
it = it->firstChild();
}
}
TmpIsValid = 1;
return &(TmpCollection);
}
// pass a connection NodeCollection to be edited
void EditConnection::setConnection( NodeCollection * NC ) {
ANetNodeInstance * NNI;
ANetNode * NN;
SelectedNodes = NC;
Name_LE->setText( NC->name() );
NNI = NC->first();
// show configure tabl
Tab_TB->setCurrentPage( 1 );
// valid colledction
Tab_TB->setTabEnabled( Setup_FRM, FALSE );
Setup_FRM->setEnabled( FALSE );
// select items in collection
QListViewItem * it = Nodes_LV->firstChild();
bool Found;
TmpIsValid = 0;
while ( it ) {
// listitem corresponds to netnode
NN = (*Mapping)[it];
if( NN == 0 ) {
// child is controller -> has sub radio
QString Ctr = it->text(0);
// check if one radio is selected
it = it->firstChild();
Found = 0;
while( it ) {
- if( NNI && NNI->netNode()->nodeName() == it->text(0) ) {
+ if( NNI && NNI->nodeClass()->nodeName() == it->text(0) ) {
// this radio is part of the collection
((QCheckListItem *)it)->setOn( 1 );
- updateGUI( it, NNI->netNode() );
+ updateGUI( it, NNI->nodeClass() );
// check its children
Found = 1;
it = it->firstChild();
NNI = SelectedNodes->next();
// do not bother to check other items
break;
}
it = it->nextSibling();
}
if( ! Found ) {
// this means that this level is NOT present in collection
// probably INCOMPATIBEL collection OR Missing plugin
QMessageBox::warning(
0,
tr( "Error presentig Connection" ),
tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ).
arg(Ctr) );
return;
}
} else {
// automatic item -> check children
it = it->firstChild();
}
}
}
// get result of editing (either new OR updated collection
NodeCollection * EditConnection::connection( void ) {
if( SelectedNodes == 0 ) {
// new collection
SelectedNodes = new NodeCollection;
}
// clean out old entries
SelectedNodes->clear();
// transfer
- { ANetNodeInstance * NNI;
-
for( QListIterator<ANetNodeInstance> it(TmpCollection);
it.current();
++it ) {
SelectedNodes->append( it.current() );
}
- }
if( TmpCollection.isModified() )
SelectedNodes->setModified( 1 );
if( SelectedNodes->name() != Name_LE->text() ) {
SelectedNodes->setName( Name_LE->text() );
SelectedNodes->setModified( 1 );
}
return SelectedNodes;
}
// Build device tree -> start
void EditConnection::buildFullTree( void ) {
ANetNode * NN;
// toplevel item
MyQCheckListItem * TheTop = new MyQCheckListItem(
Nodes_LV,
NSResources->netNode2Name("fullsetup"),
QCheckListItem::Controller );
TheTop->setOpen( TRUE );
Description_LBL->setText(
NSResources->netNode2Description( "fullsetup" ) );
Nodes_LV->setSelected( TheTop, TRUE );
// find all Nodes that care toplevel nodes -> ie provide
// TCP/IP Connection
for( QDictIterator<NetNode_t> Iter(NSResources->netNodes());
Iter.current();
++Iter ) {
NN = Iter.current()->NetNode;
if( ! NN->isToplevel() ) {
continue;
}
MyQCheckListItem * it = new MyQCheckListItem( TheTop,
NN->nodeName(),
QCheckListItem::RadioButton );
it->setPixmap( 0, NSResources->getPixmap( "Devices/commprofile" ) );
// remember that this node maps to this listitem
Mapping->insert( it, NN );
buildSubTree( it, NN );
}
}
// Build device tree -> help function
void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) {
ANetNode::NetNodeList & NNL = NN->alternatives();
if( NNL.size() > 1 ) {
// this node has alternatives -> needs radio buttons
it = new MyQCheckListItem(
it,
NSResources->netNode2Name(NNL[0]->provides()),
QCheckListItem::Controller );
it->setSelectable( FALSE );
}
for ( unsigned int i=0; i < NNL.size(); i++ ) {
QListViewItem * CI;
if( NNL.size() > 1 ) {
// generate radio buttons
CI = new MyQCheckListItem(
(QCheckListItem *)it,
NNL[i]->nodeName(), QCheckListItem::RadioButton );
// remember that this node maps to this listitem
CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) );
Mapping->insert( CI, NNL[i] );
CI->setSelectable( FALSE );
} else {
// Single item
CI = new MyQListViewItem( it, NNL[i]->nodeName() );
// remember that this node maps to this listitem
Mapping->insert( CI, NNL[i] );
CI->setSelectable( FALSE );
CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) );
}
buildSubTree( CI, NNL[i] );
}
}
// Clicked ok OK button
void EditConnection::accept( void ) {
if( ! haveCompleteConfig( 0 ) || Name_LE->text().isEmpty() ) {
QMessageBox::warning(
0,
tr( "Closing Connection Setup" ),
tr( "Definition not complete or no name" ) );
return;
}
// check if all devices have acceptable input
getTmpCollection();
@@ -355,194 +350,194 @@ void EditConnection::accept( void ) {
S = NNI->acceptable();
if( ! S.isEmpty() ) {
QMessageBox::warning(
0,
tr( "Cannot save" ),
S );
return;
}
NNI->commit();
if( NNI->isModified() ) {
TmpCollection.setModified( 1 );
// commit the data
}
}
}
QDialog::accept();
}
// triggered by CB
void EditConnection::SLOT_AutoCollapse( bool b ) {
AutoCollapse = b;
}
// clicked on node in tree -> update GUI
void EditConnection::SLOT_SelectNode( QListViewItem * it ) {
ANetNode * NN;
if( it == 0 || it->depth() == 0 ) {
Description_LBL->setText(
NSResources->netNode2Description( "fullsetup" ) );
// topevel or no selection
return;
}
// store conversion from lvitem to node
NN = (*Mapping)[ it ];
if( ! NN ) {
// intermediate node
NN = (*Mapping)[ it->firstChild() ];
if( NN ) {
// figure out type of this node -> produce mesage
Description_LBL->setText( NSResources->netNode2Description(NN->provides()) );
} else {
Description_LBL->setText( "" );
}
return;
}
Description_LBL->setText( NN->nodeDescription() );
if( ! it->isSelectable() ) {
return;
}
if( ! ((QCheckListItem *)it)->isOn() ) {
// clicked on line but NOT on Check or Radio item
return;
}
// item has really changed -> update
TmpIsValid = 0;
updateGUI( it, NN );
}
// cliecked on TAB to go to setup
void EditConnection::SLOT_AlterTab( const QString & S ) {
if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) {
// switched to setup -> update CB and populate ws with
// forms for devices
if( ! TmpIsValid ) {
getTmpCollection();
// clear CB and Ws
{ QWidget * W;
int i = 0;
Devices_CB->clear();
while( ( W = Setup_WS->widget( i ) ) ) {
Setup_WS->removeWidget( W );
i ++;
}
}
// update CB
// and populate WidgetStack
{ ANetNodeInstance * NNI;
QListIterator<ANetNodeInstance> it(TmpCollection);
int i = 0;
QWidget * W;
for ( ; it.current(); ++it ) {
NNI = it.current();
Devices_CB->insertItem(
- NSResources->getPixmap( NNI->netNode()->pixmapName() ),
- NNI->netNode()->nodeName()
+ NSResources->getPixmap( NNI->nodeClass()->pixmapName() ),
+ NNI->nodeClass()->nodeName()
);
// add edit widget
W = NNI->edit( Setup_WS );
if( ! W) {
W = new QLabel( Setup_WS,
tr("No configuration required"));
}
Setup_WS->addWidget( W , i );
i ++;
}
}
Setup_WS->raiseWidget( 0 );
} // still valid
}
}
// update visual feedback of selection state
void EditConnection::updateGUI( QListViewItem * it, ANetNode * NN ) {
bool HCC = haveCompleteConfig( it );
Tab_TB->setTabEnabled( Setup_FRM, HCC );
Setup_FRM->setEnabled( HCC );
// disable children of all siblings at same level
QListViewItem * Sbl = it->parent()->firstChild();
while( Sbl ) {
if ( Sbl != it ) {
disableTree( Sbl->firstChild(), FALSE );
Sbl->setSelectable( TRUE );
if( AutoCollapse )
Sbl->setOpen( FALSE );
}
Sbl = Sbl->nextSibling();
}
// enable selected path (as deep as it goes
it->setOpen( TRUE );
enablePath( it->firstChild(),
(it->depth()==1) ?
1 : // toplevel always alternatives
(NN->alternatives().size() > 1) );
}
void EditConnection::disableTree( QListViewItem * it, bool Mode ) {
while( it ) {
// disable sbl's chidren
it->setSelectable( Mode );
if( AutoCollapse )
it->setOpen( Mode );
disableTree( it->firstChild(), Mode );
it = it->nextSibling();
}
}
// pah : ParentHasAlternatives
void EditConnection::enablePath( QListViewItem * it, bool pha ) {
while( it ) {
ANetNode * NN;
NN = (*Mapping)[it];
if( NN ) {
if( pha ) {
bool doOn = ((QCheckListItem *)it)->isOn();
// we are a checklistitem for sure
it->setSelectable( TRUE );
if( AutoCollapse && ! doOn )
it->setOpen( doOn );
if( doOn ) {
// selected alternative
enablePath( it->firstChild(),
NN->alternatives().size() > 1);
} else {
// non-selected alternative
disableTree( it->firstChild(), FALSE);
}
} else {
// we are single subitem
it->setSelectable( TRUE );
it->setOpen( TRUE );
enablePath( it->firstChild(),
NN->alternatives().size() > 1);
}
} else {
// controller node
it->setSelectable( TRUE );
it->setOpen( TRUE );
enablePath( it->firstChild(), pha );
}
it = it->nextSibling();
}
}
// do we have a complete configuration (all needs are provided for ?)
bool EditConnection::haveCompleteConfig( QListViewItem * it ) {
if( it == 0 || ((QCheckListItem *)it)->isOn() ) {
// check children
diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp
index 4347191..96327a5 100644
--- a/noncore/settings/networksettings2/irda/irda_NN.cpp
+++ b/noncore/settings/networksettings2/irda/irda_NN.cpp
@@ -1,66 +1,54 @@
#include "irda_NN.h"
#include "irda_NNI.h"
static const char * IRDANeeds[] =
{ 0
};
/**
* Constructor, find all of the possible interfaces
*/
IRDANetNode::IRDANetNode() : ANetNode() {
}
/**
* Delete any interfaces that we own.
*/
IRDANetNode::~IRDANetNode(){
}
const QString IRDANetNode::nodeDescription(){
return tr("\
<p>Sets up a infra red serial link.</p>\
"
);
}
ANetNodeInstance * IRDANetNode::createInstance( void ) {
return new AIRDA( this );
}
const char ** IRDANetNode::needs( void ) {
return IRDANeeds;
}
const char * IRDANetNode::provides( void ) {
return "line";
}
bool IRDANetNode::generateProperFilesFor(
ANetNodeInstance * ) {
return 1;
}
-bool IRDANetNode::hasDataFor( const QString &, bool ) {
- return 0;
-}
-
-bool IRDANetNode::generateDataForCommonFile(
- SystemFile & ,
- long ,
- ANetNodeInstance * ) {
- return 1;
-}
-
bool IRDANetNode::generateDeviceDataForCommonFile(
SystemFile & ,
- long ,
- ANetNodeInstance * ) {
+ long ) {
return 1;
}
extern "C" {
void create_plugin( QList<ANetNode> & PNN ) {
PNN.append( new IRDANetNode() );
}
}
diff --git a/noncore/settings/networksettings2/irda/irda_NN.h b/noncore/settings/networksettings2/irda/irda_NN.h
index a772f69..a5b6cc5 100644
--- a/noncore/settings/networksettings2/irda/irda_NN.h
+++ b/noncore/settings/networksettings2/irda/irda_NN.h
@@ -1,46 +1,45 @@
#ifndef IRDA_NETNODE_H
#define IRDA_NETNODE_H
#include "netnode.h"
class AIRDA;
class IRDANetNode : public ANetNode {
Q_OBJECT
public:
IRDANetNode();
virtual ~IRDANetNode();
virtual const QString pixmapName()
{ return "Devices/irda"; }
virtual const QString nodeName()
{ return tr("Infrared link"); }
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 DS );
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ virtual bool hasDataFor( const QString & )
+ { return 0; }
virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ SystemFile & SF, long DevNr );
private:
};
extern "C"
{
void create_plugin( QList<ANetNode> & PNN );
};
#endif
diff --git a/noncore/settings/networksettings2/irda/irda_NNI.cpp b/noncore/settings/networksettings2/irda/irda_NNI.cpp
index 78d6ff9..f00a1d5 100644
--- a/noncore/settings/networksettings2/irda/irda_NNI.cpp
+++ b/noncore/settings/networksettings2/irda/irda_NNI.cpp
@@ -1,30 +1,37 @@
#include "irdaedit.h"
#include "irda_NNI.h"
#include "irda_NN.h"
AIRDA::AIRDA( IRDANetNode * PNN ) : ANetNodeInstance( PNN ) {
GUI = 0;
RT = 0;
}
void AIRDA::setSpecificAttribute( QString & , QString & ) {
}
void AIRDA::saveSpecificAttribute( QTextStream & ) {
}
QWidget * AIRDA::edit( QWidget * parent ) {
GUI = new IRDAEdit( parent );
GUI->showData( Data );
return GUI;
}
QString AIRDA::acceptable( void ) {
return ( GUI ) ? GUI->acceptable( ) : QString();
}
void AIRDA::commit( void ) {
if( GUI && GUI->commit( Data ) )
setModified( 1 );
}
+
+bool AIRDA::generateDataForCommonFile(
+ SystemFile & ,
+ long ) {
+ return 1;
+}
+
diff --git a/noncore/settings/networksettings2/irda/irda_NNI.h b/noncore/settings/networksettings2/irda/irda_NNI.h
index c2d6875..210d87d 100644
--- a/noncore/settings/networksettings2/irda/irda_NNI.h
+++ b/noncore/settings/networksettings2/irda/irda_NNI.h
@@ -1,43 +1,48 @@
#ifndef IRDA_H
#define IRDA_H
#include <netnode.h>
#include "irdadata.h"
#include "irdarun.h"
class IRDANetNode;
class IRDAEdit;
class AIRDA : public ANetNodeInstance {
public :
AIRDA( IRDANetNode * PNN );
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
RuntimeInfo * runtime( void )
{ if( RT == 0 )
RT = new IRDARun( 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 );
+
protected :
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
private :
IRDAEdit * GUI;
IRDAData Data;
IRDARun * RT;
};
#endif
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
index 7d36918..480ddf9 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
@@ -1,67 +1,72 @@
#include "lancard_NN.h"
#include "lancard_NNI.h"
static const char * LanCardNeeds[] =
{ 0 };
/**
* Constructor, find all of the possible interfaces
*/
LanCardNetNode::LanCardNetNode() : ANetNode() {
}
/**
* Delete any interfaces that we own.
*/
LanCardNetNode::~LanCardNetNode(){
}
const QString LanCardNetNode::nodeDescription(){
return tr("\
<p>Sets up a wired regular LAN card.</p>\
<p>Use this to set up 10/100/1000 MBit LAN cards.</p>\
"
);
}
ANetNodeInstance * LanCardNetNode::createInstance( void ) {
return new ALanCard( this );
}
const char ** LanCardNetNode::needs( void ) {
return LanCardNeeds;
}
const char * LanCardNetNode::provides( void ) {
return "device";
}
bool LanCardNetNode::generateProperFilesFor(
ANetNodeInstance * ) {
return 1;
}
-bool LanCardNetNode::hasDataFor( const QString & S, bool DS ) {
- return DS && S == "interfaces";
-}
-
-bool LanCardNetNode::generateDataForCommonFile(
- SystemFile & ,
- long ,
- ANetNodeInstance * ) {
- return 1;
+bool LanCardNetNode::hasDataFor( const QString & S ) {
+ return S == "interfaces";
}
bool LanCardNetNode::generateDeviceDataForCommonFile(
SystemFile & S ,
- long DevNr ,
- ANetNodeInstance * NNI ) {
- return ((ALanCard *)NNI)->generateDeviceDataForCommonFile(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;
+}
+
+QString LanCardNetNode::genNic( long nr ) {
+ QString S;
+ return S.sprintf( "eth%ld", nr );
}
extern "C" {
void create_plugin( QList<ANetNode> & PNN ) {
PNN.append( new LanCardNetNode() );
}
}
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h
index 9690c76..dcdd0da 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.h
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.h
@@ -1,46 +1,49 @@
#ifndef LANCARD_NETNODE_H
#define LANCARD_NETNODE_H
#include "netnode.h"
class ALanCard;
class LanCardNetNode : public ANetNode{
Q_OBJECT
public:
LanCardNetNode();
virtual ~LanCardNetNode();
virtual const QString pixmapName()
{ return "Devices/card"; }
virtual const QString nodeName()
{ return tr("LAN card"); }
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 DS );
- 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 long instanceCount( void )
+ { return 2; }
+
+ virtual QString genNic( long );
private:
};
extern "C"
{
void create_plugin( QList<ANetNode> & PNN );
};
#endif
diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
index a6401db..5962d52 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
@@ -1,58 +1,51 @@
#include "lancardedit.h"
#include "lancard_NNI.h"
#include "lancard_NN.h"
ALanCard::ALanCard( LanCardNetNode * PNN ) : ANetNodeInstance( PNN ) {
Data.AnyLanCard = 1;
Data.HWAddresses.clear();
GUI = 0;
RT = 0;
}
void ALanCard::setSpecificAttribute( QString & A, QString & V ) {
if( A == "matchanycard" ) {
Data.AnyLanCard = (V == "yes" );
} else if( A == "match" ) {
Data.HWAddresses.append( V );
}
}
void ALanCard::saveSpecificAttribute( QTextStream & TS) {
TS << "matchanycard=" <<
((Data.AnyLanCard) ? "yes" : "no") << endl;
for( QStringList::Iterator it = Data.HWAddresses.begin();
it != Data.HWAddresses.end(); ++it ) {
TS << "match=" << quote( *it ) << endl;
}
}
QWidget * ALanCard::edit( QWidget * parent ) {
GUI = new LanCardEdit( parent );
GUI->showData( Data );
return GUI;
}
QString ALanCard::acceptable( void ) {
return ( GUI ) ? GUI->acceptable( ) : QString();
}
void ALanCard::commit( void ) {
if( GUI && GUI->commit( Data ) )
setModified( 1 );
}
-bool ALanCard::generateDeviceDataForCommonFile( SystemFile & S, long DevNr ) {
- AsDevice * Dev = runtime()->device();
- QString NIC = Dev->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 ALanCard::generateDataForCommonFile(
+ SystemFile & ,
+ long ) {
+ return 1;
}
diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.h b/noncore/settings/networksettings2/lancard/lancard_NNI.h
index 16f5f56..4e91523 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NNI.h
+++ b/noncore/settings/networksettings2/lancard/lancard_NNI.h
@@ -1,45 +1,47 @@
#ifndef LANCARD_H
#define LANCARD_H
#include <netnode.h>
#include "lancarddata.h"
#include "lancardrun.h"
class LanCardNetNode;
class LanCardEdit;
class ALanCard : public ANetNodeInstance {
public :
ALanCard( LanCardNetNode * PNN );
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
RuntimeInfo * runtime( void )
{ if( RT == 0 )
RT = new LanCardRun( this, Data );
return RT;
}
virtual void * data( void )
{ return (void *)&Data; }
- bool generateDeviceDataForCommonFile( SystemFile & S, long DevNr );
-
+ virtual bool hasDataFor( const QString & )
+ { return 0; }
+ virtual bool generateDataForCommonFile(
+ SystemFile & S, long DevNr );
protected :
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
private :
LanCardEdit * GUI;
LanCardData Data;
LanCardRun * RT;
};
#endif
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.h b/noncore/settings/networksettings2/lancard/lancardrun.h
index 8dbd1b1..499b417 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.h
+++ b/noncore/settings/networksettings2/lancard/lancardrun.h
@@ -1,42 +1,37 @@
#ifndef LANCARDRUN_H
#define LANCARDRUN_H
#include <asdevice.h>
#include <qregexp.h>
#include "lancarddata.h"
class LanCardRun : public AsDevice {
public :
LanCardRun( ANetNodeInstance * NNI,
LanCardData & Data ) : AsDevice( NNI ),
Pat( "eth[0-9]" )
{ }
- virtual long count( void )
- { return 2; }
- virtual QString genNic( long nr )
- { QString S; return S.sprintf( "eth%ld", nr ); }
-
virtual AsDevice * device( void )
{ return (AsDevice *)this; }
virtual AsDevice * asDevice( void )
{ return (AsDevice *)this; }
protected :
void detectState( NodeCollection * NC );
bool setState( NodeCollection * NC, Action_t A );
bool canSetState( State_t Curr, Action_t A );
bool handlesInterface( const QString & I );
private :
InterfaceInfo * getInterface( void );
QRegExp Pat;
};
#endif
diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp
index 2807963..65b06ee 100644
--- a/noncore/settings/networksettings2/modem/modem_NN.cpp
+++ b/noncore/settings/networksettings2/modem/modem_NN.cpp
@@ -1,67 +1,55 @@
#include "modem_NN.h"
#include "modem_NNI.h"
static const char * ModemNeeds[] =
{ "line"
};
/**
* Constructor, find all of the possible interfaces
*/
ModemNetNode::ModemNetNode() : ANetNode() {
}
/**
* Delete any interfaces that we own.
*/
ModemNetNode::~ModemNetNode(){
}
const QString ModemNetNode::nodeDescription(){
return tr("\
<p>Sets up a dialing procedures.</p>\
<p>Use this to dial up over modems, ISDN, GSM, ...</p>\
"
);
}
ANetNodeInstance * ModemNetNode::createInstance( void ) {
return new AModem( this );
}
const char ** ModemNetNode::needs( void ) {
return ModemNeeds;
}
const char * ModemNetNode::provides( void ) {
return "line";
}
bool ModemNetNode::generateProperFilesFor(
ANetNodeInstance * ) {
return 1;
}
-bool ModemNetNode::hasDataFor( const QString &, bool ) {
- return 0;
-}
-
-bool ModemNetNode::generateDataForCommonFile(
- SystemFile & ,
- long ,
- ANetNodeInstance * ) {
- return 1;
-}
-
bool ModemNetNode::generateDeviceDataForCommonFile(
SystemFile & ,
- long ,
- ANetNodeInstance * ) {
+ long ) {
return 1;
}
extern "C" {
void create_plugin( QList<ANetNode> & PNN ) {
PNN.append( new ModemNetNode() );
}
}
diff --git a/noncore/settings/networksettings2/modem/modem_NN.h b/noncore/settings/networksettings2/modem/modem_NN.h
index bd921c6..49244b2 100644
--- a/noncore/settings/networksettings2/modem/modem_NN.h
+++ b/noncore/settings/networksettings2/modem/modem_NN.h
@@ -1,46 +1,45 @@
#ifndef MODEM_NETNODE_H
#define MODEM_NETNODE_H
#include "netnode.h"
class AModem;
class ModemNetNode : public ANetNode{
Q_OBJECT
public:
ModemNetNode();
virtual ~ModemNetNode();
virtual const QString pixmapName()
{ return "Devices/modem"; }
virtual const QString nodeName()
{ return tr("Dialup modem"); }
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 DS );
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ virtual bool hasDataFor( const QString & )
+ { return 0; }
virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ SystemFile & SF, long DevNr );
private:
};
extern "C"
{
void create_plugin( QList<ANetNode> & PNN );
};
#endif
diff --git a/noncore/settings/networksettings2/modem/modem_NNI.cpp b/noncore/settings/networksettings2/modem/modem_NNI.cpp
index 91df22b..6c76b56 100644
--- a/noncore/settings/networksettings2/modem/modem_NNI.cpp
+++ b/noncore/settings/networksettings2/modem/modem_NNI.cpp
@@ -1,31 +1,37 @@
#include "modemedit.h"
#include "modem_NNI.h"
#include "modem_NN.h"
AModem::AModem( ModemNetNode * PNN ) : ANetNodeInstance( PNN ) {
GUI = 0;
RT = 0;
}
void AModem::setSpecificAttribute( QString & , QString & ) {
}
void AModem::saveSpecificAttribute( QTextStream & ) {
}
QWidget * AModem::edit( QWidget * parent ) {
GUI = new ModemEdit( parent );
GUI->showData( Data );
return GUI;
}
QString AModem::acceptable( void ) {
return ( GUI ) ? GUI->acceptable( ) : QString();
}
void AModem::commit( void ) {
if( GUI && GUI->commit( Data ) )
setModified( 1 );
}
+bool AModem::generateDataForCommonFile(
+ SystemFile & ,
+ long ) {
+ return 1;
+}
+
diff --git a/noncore/settings/networksettings2/modem/modem_NNI.h b/noncore/settings/networksettings2/modem/modem_NNI.h
index 7543e7d..a623704 100644
--- a/noncore/settings/networksettings2/modem/modem_NNI.h
+++ b/noncore/settings/networksettings2/modem/modem_NNI.h
@@ -1,43 +1,48 @@
#ifndef Modem_H
#define Modem_H
#include <netnode.h>
#include "modemdata.h"
#include "modemrun.h"
class ModemNetNode;
class ModemEdit;
class AModem : public ANetNodeInstance {
public :
AModem( ModemNetNode * PNN );
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
RuntimeInfo * runtime( void )
{ if( RT == 0 )
RT = new ModemRun( 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 );
+
protected :
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
private :
ModemEdit * GUI;
ModemData Data;
ModemRun * RT;
};
#endif
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp
index a6b15c6..4a77e6a 100644
--- a/noncore/settings/networksettings2/network/network_NN.cpp
+++ b/noncore/settings/networksettings2/network/network_NN.cpp
@@ -1,71 +1,56 @@
#include "network_NN.h"
#include "network_NNI.h"
static const char * NetworkNeeds[] =
{ "device",
0
};
/**
* Constructor, find all of the possible interfaces
*/
NetworkNetNode::NetworkNetNode() : ANetNode() {
}
/**
* 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 );
}
const char ** NetworkNetNode::needs( void ) {
return NetworkNeeds;
}
const char * NetworkNetNode::provides( void ) {
return "connection";
}
bool NetworkNetNode::generateProperFilesFor(
ANetNodeInstance * ) {
return 1;
}
-bool NetworkNetNode::hasDataFor( const QString & S, bool DS ) {
- if( ! DS && S == "interfaces" ) {
- return 1;
- }
- return 0;
-}
-
-bool NetworkNetNode::generateDataForCommonFile(
- SystemFile & S,
- long DevNr,
- ANetNodeInstance * NNI ) {
- return ((ANetwork *)NNI)->generateDataForCommonFile(S, DevNr);
-}
-
bool NetworkNetNode::generateDeviceDataForCommonFile(
SystemFile & ,
- long ,
- ANetNodeInstance * ) {
+ long ) {
return 1;
}
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 62a3f10..59f0526 100644
--- a/noncore/settings/networksettings2/network/network_NN.h
+++ b/noncore/settings/networksettings2/network/network_NN.h
@@ -1,46 +1,45 @@
#ifndef NETWORK_NETNODE_H
#define NETWORK_NETNODE_H
#include "netnode.h"
class ANetwork;
class NetworkNetNode : public ANetNode{
Q_OBJECT
public:
NetworkNetNode();
virtual ~NetworkNetNode();
virtual const QString pixmapName()
{ return "Devices/tcpip"; }
virtual const QString nodeName()
{ return tr("IP Configuration"); }
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 DS );
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ virtual bool hasDataFor( const QString & )
+ { return 0; }
virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ SystemFile & SF, long DevNr );
private:
};
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 eac2d66..054385a 100644
--- a/noncore/settings/networksettings2/network/network_NNI.cpp
+++ b/noncore/settings/networksettings2/network/network_NNI.cpp
@@ -6,160 +6,163 @@
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::hasDataFor( const QString & S ) {
+ return S == "interfaces";
+}
+
bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) {
- AsDevice * Dev = runtime()->device();
- QString NIC = Dev->genNic( DevNr );
+ QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
if( S.name() == "interfaces" ) {
// we can safely call from here since device item is deeper
if( Data.UseDHCP ) {
S << "iface " << NIC << "-c" << connection()->number() <<
"-allowed inet dhcp" << endl;
S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() <<
".up" << Data.IPAddress << endl;
if( Data.SendHostname ) {
S << " hostname "<< Data.Hostname << endl;
}
S << " down rm -f /tmp/profile-" << connection()->number() <<
".up" << Data.IPAddress << endl;
} else {
S << "iface " << NIC << "-c" << connection()->number() <<
"-allowed inet static" << endl;
S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() <<
".up" << Data.IPAddress << endl;
S << " down rm -f /tmp/profile-" << connection()->number() <<
".up" << Data.IPAddress << endl;
S << " address " << Data.IPAddress << endl;
S << " broadcast " << Data.Broadcast << endl;
S << " 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() );
S << " network " << NW << endl;
}
}
for ( QStringList::Iterator it = Data.PreUp_SL.begin();
it != Data.PreUp_SL.end();
++it ) {
S << " pre-up " << (*it) << endl;
}
for ( QStringList::Iterator it = Data.PostUp_SL.begin();
it != Data.PostUp_SL.end();
++it ) {
S << " up " << (*it) << endl;
}
for ( QStringList::Iterator it = Data.PreDown_SL.begin();
it != Data.PreDown_SL.end();
++it ) {
S << " down " << (*it) << endl;
}
for ( QStringList::Iterator it = Data.PostDown_SL.begin();
it != Data.PostDown_SL.end();
++it ) {
S << " post-down " << (*it) << endl;
}
}
return 0;
}
diff --git a/noncore/settings/networksettings2/network/network_NNI.h b/noncore/settings/networksettings2/network/network_NNI.h
index b98ff6e..0058793 100644
--- a/noncore/settings/networksettings2/network/network_NNI.h
+++ b/noncore/settings/networksettings2/network/network_NNI.h
@@ -1,45 +1,47 @@
#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 );
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
RuntimeInfo * runtime( void )
{ if( RT == 0 )
RT = new NetworkRun( this, Data );
return RT;
}
virtual void * data( void )
{ return (void *)&Data; }
- bool generateDataForCommonFile( 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 :
NetworkEdit * GUI;
NetworkData_t Data;
NetworkRun * RT;
};
#endif
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp
index f34fdbf..ddb9a5f 100644
--- a/noncore/settings/networksettings2/network/networkrun.cpp
+++ b/noncore/settings/networksettings2/network/networkrun.cpp
@@ -1,65 +1,66 @@
#include <system.h>
#include <asdevice.h>
#include "networkrun.h"
void NetworkRun::detectState( NodeCollection * NC ) {
RuntimeInfo * RI = netNode()->nextNode()->runtime();
AsDevice * Next = RI->asDevice();
InterfaceInfo * II = Next->assignedInterface();
if( II ) {
// device has assigned interface
NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) );
+ return;
}
// has no interface -> delegate
RI->detectState( NC );
}
bool NetworkRun::setState( NodeCollection * NC, Action_t A ) {
// we handle UP and DOWN
RuntimeInfo * RI = netNode()->nextNode()->runtime();
AsDevice * Next = RI->asDevice();
InterfaceInfo * II = Next->assignedInterface();
if( A == Up ) {
// we can bring UP if lower level is available
if( NC->currentState() == Available ) {
QString S;
S.sprintf( "ifup %s=%s-c%d-allowed",
II->Name.latin1(), II->Name.latin1(),
connection()->number() );
NSResources->system().execute( S );
}
return 1;
} else if( A == Down ) {
if( NC->currentState() == IsUp ) {
QString S;
S.sprintf( "ifdown %s=%s-c%d-allowed",
II->Name.latin1(), II->Name.latin1(),
connection()->number() );
NSResources->system().execute( S );
}
return 1;
}
// delegate
return RI->setState( NC, A );
}
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);
}
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index c3e6572..3ddcbde 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -1,282 +1,282 @@
#include <stdio.h>
#include <qpe/qpeapplication.h>
#include <qlistbox.h>
#include <qgroupbox.h>
#include <qtimer.h>
#include <qlistbox.h>
#include <qmessagebox.h>
#include <qlabel.h>
#include <qiconview.h>
#include <qtimer.h>
#include <qpe/qpeapplication.h>
#include <qtoolbutton.h>
#include <asdevice.h>
#include "networksettings.h"
#include "netnode.h"
#include "editconnection.h"
NetworkSettings::NetworkSettings( QWidget *parent,
const char *name,
WFlags fl ) : NetworkSettingsGUI(parent,name,fl),
NSD() {
UpdateTimer = new QTimer( this );
// set pixmaps
Add_TB->setPixmap( NSResources->getPixmap( "add" ) );
Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) );
CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) );
Enable_TB->setPixmap( NSResources->getPixmap( "disabled" ) );
GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) );
Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) );
On_TB->setPixmap( NSResources->getPixmap( "off" ) );
// populate main Listbox
Profiles_LB->clear();
{ Name2Connection_t & M = NSResources->connections();
NodeCollection * NC;
// for all connections
for( QDictIterator<NodeCollection> it(M);
it.current();
++it ) {
NC = it.current();
Profiles_LB->insertItem( NC->devicePixmap(),
NC->name() );
}
}
if( Profiles_LB->count() ) {
Profiles_LB->setSelected( 0, TRUE );
}
// if no profiles -> auto popup editing
if( NSResources->connections().count() == 0 ) {
QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) );
}
UpdateTimer->start( 5000 );
connect( UpdateTimer, SIGNAL( timeout() ),
this, SLOT( SLOT_RefreshStates() ) );
/* Add QCopChannel */
connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) );
}
NetworkSettings::~NetworkSettings() {
QString S;
S = NSD.generateSettings();
if( ! S.isEmpty() ) {
QMessageBox::warning(
0,
- tr( "Generating system configuration" ),
+ tr( "In System Config" ),
S
);
}
S = NSD.saveSettings();
if( ! S.isEmpty() ) {
// problem saving
QMessageBox::warning(
0,
tr( "Saving setup" ), S );
}
}
void NetworkSettings::SLOT_RefreshStates( void ) {
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember
if( LBI ) {
NodeCollection * NC;
NSResources->system().probeInterfaces();
// update current selection only
NC = NSResources->findConnection( LBI->text() );
if( NC ) {
State_t OldS = NC->state();
State_t NewS = NC->state(1);
if( OldS != NewS ) {
updateProfileState( LBI );
}
}
}
/* -> LATER !!
bool is;
NodeCollection * NC;
for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) {
NC = NSResources->findConnection( Profiles_LB->text(i) );
if( NC ) {
State_t OldS = NC->state();
State_t NewS = NC->state(1);
if( OldS != NewS ) {
is = Profiles_LB->isSelected(i);
Profiles_LB->changeItem( NC->statePixmap(NewS),
NC->name(),
i );
if( is ) {
Profiles_LB->setSelected( i, TRUE );
}
}
}
}
if( ci >= 0 )
Profiles_LB->setCurrentItem( ci );
*/
}
void NetworkSettings::SLOT_AddNode( void ) {
SLOT_EditNode( 0 );
}
void NetworkSettings::SLOT_DeleteNode( void ) {
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
if ( ! LBI )
return;
if( QMessageBox::warning(
0,
tr( "Removing profile" ),
tr( "Remove selected profile ?" ),
1, 0 ) == 1 ) {
NSResources->removeConnection( LBI->text() );
delete LBI;
setModified( 1 );
NSD.forceGeneration(1);
}
}
void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
QString OldName = "";
EditConnection EC( this );
if( LBI ) {
NodeCollection * NC = NSResources->findConnection( LBI->text() );
if( ! NC ) {
return;
}
OldName = NC->name();
EC.setConnection( NC );
}
EC.showMaximized();
// disable refresh timer
UpdateTimer->stop();
// we need to retry
while( 1 ) {
if( EC.exec() == QDialog::Accepted ) {
// toplevel item -> store
NodeCollection * NC = EC.connection();
if( NC->isModified() ) {
setModified( 1 );
if( LBI ) {
if( NC->name() != OldName ) {
// find if new name is free
NodeCollection * LCN = NSResources->findConnection(
NC->name() );
if( LCN ) {
QMessageBox::warning(
0,
- tr( "Generating system configuration" ),
+ tr( "In System Config" ),
tr( "Name %1 already exists" ).arg(NC->name())
);
continue; // restart exec
} // else new name
// new name -> remove item
NSResources->removeConnection( OldName );
NSResources->addConnection( NC );
} // else not changed
// must add it here since change will trigger event
Profiles_LB->changeItem( NC->devicePixmap(),
NC->name(),
Profiles_LB->index( LBI )
);
} else {
// new item
int ci = Profiles_LB->count();
NSResources->addConnection( NC );
NC->setNumber( NC->maxConnectionNumber()+1 );
Profiles_LB->insertItem( NC->devicePixmap(), NC->name() );
Profiles_LB->setSelected( ci, TRUE );
}
updateProfileState( LBI );
}
} else {
// cancelled : reset connection
if( LBI ) {
NodeCollection * NC = NSResources->findConnection( LBI->text() );
NC->reassign();
}
}
break;
}
// reenable
UpdateTimer->start( 5000 );
}
void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
if( LBI == 0 )
return;
NodeCollection * NC = NSResources->findConnection( LBI->text() );
// is button possible
bool EnabledPossible, OnPossible, ConnectPossible;
// is button On or Off
bool DisabledOn, OnOn, ConnectOn;
EnabledPossible = OnPossible = ConnectPossible = 1;
DisabledOn = 1;
OnOn = ConnectOn = 0;
switch( NC->state() ) {
case Unknown :
// cannot occur here
break;
case Unchecked :
case Unavailable :
// cannot do anything but recheck
EnabledPossible = OnPossible = ConnectPossible = 0;
break;
case Disabled :
OnPossible = ConnectPossible = 0;
break;
case Off :
DisabledOn = 0;
break;
case Available :
OnOn = 1;
DisabledOn = 0;
break;
case IsUp :
OnOn = ConnectOn = 1;
DisabledOn = 0;
break;
}
// set button state
Enable_TB->setEnabled( EnabledPossible );
On_TB->setEnabled( OnPossible );
Connect_TB->setEnabled( ConnectPossible );
Enable_TB->setOn( DisabledOn );
On_TB->setOn( OnOn );
Connect_TB->setOn( ConnectOn );
if( NC->description().isEmpty() ) {
Description_LBL->setText( tr( "No description" ) );
} else {
Description_LBL->setText( NC->description() );
}
CurProfile_GB->setTitle( LBI->text() );
State_LBL->setText( NC->stateName() );
}
diff --git a/noncore/settings/networksettings2/networksettings2/asdevice.h b/noncore/settings/networksettings2/networksettings2/asdevice.h
index 058fc4c..19241c1 100644
--- a/noncore/settings/networksettings2/networksettings2/asdevice.h
+++ b/noncore/settings/networksettings2/networksettings2/asdevice.h
@@ -1,37 +1,31 @@
#ifndef ASDEVICE_H
#define ASDEVICE_H
#include "system.h"
#include "netnode.h"
// pure virtual (component oriented) interface of any
// plugin that offers a device
class AsDevice : public RuntimeInfo {
public :
AsDevice( ANetNodeInstance * NNI ) :
RuntimeInfo( NNI ) {
AssignedInterface = 0;
}
// return the interface assigned to this device
// e.g eth0, wlan, ...
InterfaceInfo * assignedInterface( void )
{ return AssignedInterface; }
virtual void assignInterface( InterfaceInfo * NI )
{ AssignedInterface = NI; }
- // number of device to configure for this Device type
- virtual long count( void )
- { return 1; }
- // generate NIC name of device number ...
- virtual QString genNic( long NicNr ) = 0;
-
private :
InterfaceInfo * AssignedInterface;
};
#endif
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp
index f040c99..fcc6044 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.cpp
+++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp
@@ -84,193 +84,193 @@ ANetNodeInstance * ANetNodeInstance::nextNode( void ) {
//
//
//
//
long NodeCollection::MaxNr = -1;
NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() {
IsModified = 0;
Index = -1;
Name="";
IsNew = 1;
CurrentState = Unchecked;
}
NodeCollection::NodeCollection( QTextStream & TS ) :
QList<ANetNodeInstance>() {
long idx;
bool InError = 0;
QString S, A, N;
IsModified = 0;
Index = -1;
Name="";
IsNew = 0;
CurrentState = Unchecked;
do {
S = TS.readLine();
if( S.isEmpty() ) {
if( InError ) {
// remove all nodes
clear();
}
// empty line
break;
}
idx = S.find('=');
S.stripWhiteSpace();
A = S.left( idx );
A.lower();
N = S.mid( idx+1, S.length() );
N.stripWhiteSpace();
N = deQuote( N );
if( A == "name" ) {
Name = N;
} else if( A == "number" ) {
setNumber( N.toLong() );
} else if( A == "node" ) {
ANetNodeInstance * NNI = NSResources->findNodeInstance( N );
if( NNI && ! InError ) {
append( NSResources->findNodeInstance( N ) );
} else {
// could not find a node type -> collection invalid
InError = 1;
}
}
} while( 1 );
}
NodeCollection::~NodeCollection( void ) {
}
const QString & NodeCollection::description( void ) {
ANetNodeInstance * NNI = getToplevel();
return (NNI) ? NNI->runtime()->asFullSetup()->description() : Name;
}
void NodeCollection::append( ANetNodeInstance * NNI ) {
NNI->setConnection( this );
QList<ANetNodeInstance>::append( NNI );
}
void NodeCollection::save( QTextStream & TS ) {
TS << "name=" << quote( Name ) << endl;
TS << "number=" << number() << endl;
ANetNodeInstance * NNI;
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
NNI = it.current();
TS << "node=" << quote( NNI->nodeName() ) << endl;
}
TS << endl;
IsNew = 0;
}
ANetNodeInstance * NodeCollection::getToplevel( void ) {
ANetNodeInstance * NNI = 0;
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
NNI = it.current();
- if( NNI->netNode()->isToplevel() )
+ if( NNI->nodeClass()->isToplevel() )
break;
}
return NNI;
}
ANetNodeInstance * NodeCollection::findByName( const QString & S ) {
ANetNodeInstance * NNI = 0;
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
NNI = it.current();
if( NNI->name() == S )
break;
}
return NNI;
}
ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) {
ANetNodeInstance * NNNI;
if( ! NNI )
getToplevel();
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
NNNI = it.current();
if( NNNI == NNI ) {
++it;
return it.current();
}
}
return 0; // no more next
}
int NodeCollection::compareItems( QCollection::Item I1,
QCollection::Item I2 ) {
ANetNodeInstance * NNI1, * NNI2;
NNI1 = (ANetNodeInstance *)I1;
NNI2 = (ANetNodeInstance *)I2;
return NNI1->nodeName().compare( NNI2->nodeName() );
}
static char * State2PixmapTbl[] = {
"NULL", // Unchecked : no pixmap
"check", // Unknown
"delete", // unavailable
"disabled", // disabled
"off", // off
"disconnected", // available
"connected" // up
};
QPixmap NodeCollection::devicePixmap( void ) {
return NSResources->getPixmap(
device()->netNode()->pixmapName()+"-large" );
}
QPixmap NodeCollection::statePixmap( State_t S) {
return NSResources->getPixmap( State2PixmapTbl[S] );
}
QString NodeCollection::stateName( State_t S) {
switch( S ) {
case Unknown :
return qApp->translate( "networksettings2", "Unknown");
case Unavailable :
return qApp->translate( "networksettings2", "Unavailable");
case Disabled :
return qApp->translate( "networksettings2", "Disabled");
case Off :
return qApp->translate( "networksettings2", "Off");
case Available :
return qApp->translate( "networksettings2", "Available");
case IsUp :
return qApp->translate( "networksettings2", "IsUp");
case Unchecked : /* FT */
default :
break;
}
return QString("");
}
void NodeCollection::reassign( void ) {
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
it.current()->setConnection( this );
}
}
InterfaceInfo * RuntimeInfo::assignedInterface( void ) {
return netNode()->nextNode()->runtime()->assignedInterface();
}
AsDevice * RuntimeInfo::device( void ) {
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index f4a5e30..9681c6e 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -2,446 +2,464 @@
#define NETNODE_H
#include <qtextstream.h>
#include <qlist.h>
#include <qdict.h>
#include <qpixmap.h>
#include <qobject.h>
#include <time.h>
// difference feature interfaces
class AsDevice;
class AsLine;
class AsConnection;
class AsFullSetup;
// needed for plugin creation function
#include <qlist.h>
class ANetNode;
class ANetNodeInstance;
class NodeCollection;
class QTextStream;
class RuntimeInfo;
class InterfaceInfo;
extern QString & deQuote( QString & X );
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
} 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
} Action_t;
class ANetNode : public QObject{
public:
typedef QArray<ANetNode *> NetNodeList;
ANetNode(){};
virtual ~ANetNode(){};
// pixmap needed for this NetNode
virtual const QString pixmapName() = 0;
// name of this NetNode
virtual const QString nodeName() = 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, bool DeviceSpecific ) = 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, ANetNodeInstance * NNI ) = 0;
+ 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, ANetNodeInstance * NNI ) = 0;
+ 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; }
+
// compiled references to 'needed' NetNodes -> needs list
void setAlternatives( NetNodeList * Alt )
{ Alternatives = Alt; }
NetNodeList & alternatives( void )
{ return *Alternatives; }
protected :
NetNodeList * Alternatives;
private :
};
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 * netNode( void )
+ 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
void setNew( bool IsN )
{ IsNew = IsN; }
bool isNew( void )
{ return IsNew; }
// return logical name of this instance
QString & nodeName( void )
{ return NodeName; }
void setNodeName( const QString & S )
{ NodeName = S; }
// return description for this instance
QString & description( void )
{ return Description; }
void setDescription( const QString & S )
{ Description = S; }
// pixmap for this instance -> from NetNode
const QString pixmapName( void )
{ return NodeType->pixmapName(); }
const char * provides( void )
{ return NodeType->provides(); }
const char ** needs( void )
{ return NodeType->needs(); }
// returns node specific data -> only useful for 'buddy'
virtual void * data( void ) = 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 a profile and for the system file S
+ // called only IF data was needed
+ virtual bool generateDataForCommonFile(
+ SystemFile & SF, long DevNr ) = 0;
+
protected :
virtual void setSpecificAttribute( QString & , QString & ) = 0;
virtual void saveSpecificAttribute( QTextStream & ) = 0;
ANetNode * NodeType;
// connection to which this node belongs to
NodeCollection * Connection;
QString NodeName;
QString Description;
bool IsModified;
bool IsNew;
static long InstanceCounter;
};
class RuntimeInfo : public QObject {
Q_OBJECT
public :
RuntimeInfo( ANetNodeInstance * TheNNI )
{ NNI = TheNNI; }
// downcast implemented by specify runtime classes
- AsDevice * asDevice( void )
+ virtual AsDevice * asDevice( void )
{ return 0; }
- AsConnection * asConnection( void )
+ virtual AsConnection * asConnection( void )
{ return 0; }
- AsLine * asLine( void )
+ virtual AsLine * asLine( void )
{ return 0; }
- AsFullSetup * asFullSetup( void )
+ virtual AsFullSetup * asFullSetup( void )
{ return 0; }
// does this node handles this interface e.g.eth0
// recurse deeper if this node cannot answer that question
virtual bool handlesInterface( const QString & )
{ return 0; }
virtual InterfaceInfo * assignedInterface( void );
virtual AsDevice * device( void );
ANetNodeInstance * netNode()
{ return NNI; }
NodeCollection * connection()
{ return NNI->connection(); }
virtual void detectState( NodeCollection * NC ) = 0;
virtual bool setState( NodeCollection * NC, Action_t A ) = 0;
virtual bool canSetState( State_t Curr, Action_t A ) = 0;
signals :
// sent by device if state changes
void stateChanged( State_t S, ANetNodeInstance * NNI );
protected :
// connection this runtime info belongs to
ANetNodeInstance * NNI;
};
class NodeCollection : public QList<ANetNodeInstance> {
public :
NodeCollection( void );
NodeCollection( QTextStream & TS );
~NodeCollection( void );
int number( void )
{ return Number; }
void setNumber( int i )
{ Number = i; if( MaxNr < i ) MaxNr = i; }
bool isNew( void )
{ return IsNew; }
void setNew( bool N )
{ IsNew = N ; }
bool isModified( void )
{ return IsModified; }
void setModified( bool N )
{ IsModified = N ; }
bool handlesInterface( const QString & S ) {
return getToplevel()->runtime()->handlesInterface( S );
}
InterfaceInfo * assignedInterface( void ) {
return getToplevel()->runtime()->assignedInterface();
}
AsDevice * device() {
return getToplevel()->runtime()->device();
}
State_t state( bool Update = 0 )
{ if( CurrentState == Unchecked || Update ) {
// need to get current state
getToplevel()->runtime()->detectState( this );
}
return CurrentState;
}
// get the ixmap for this device
QPixmap devicePixmap( void );
QPixmap statePixmap( State_t S );
QPixmap statePixmap( bool Update = 0 )
{ return statePixmap( state(Update) ); }
QString stateName( State_t );
QString stateName( bool Update = 0 )
{ return stateName( state(Update) ); }
bool setState( Action_t A )
{ return getToplevel()->runtime()->setState( this, A ); }
bool canSetState( Action_t A )
{ return getToplevel()->runtime()->canSetState( CurrentState, A ); }
void save( QTextStream & TS );
void append( ANetNodeInstance * NNI );
// makes sure that all items in the connection point to
// that connectoin
void reassign( void );
ANetNodeInstance * getToplevel( void );
ANetNodeInstance * findNext( ANetNodeInstance * NNI );
ANetNodeInstance * findByName( const QString & S );
const QString & name()
{ return Name; }
const QString & description( void );
void setName( const QString & N)
{ Name = N; }
State_t currentState( void )
{ return CurrentState; }
void setCurrentState( State_t S )
{ CurrentState = S; }
long maxConnectionNumber( void )
{ return MaxNr; }
static void resetMaxNr( void )
{ MaxNr = -1; }
private :
int compareItems ( QCollection::Item item1,
QCollection::Item item2 );
static long MaxNr;
long Number;
// state of this connection
State_t CurrentState;
QString Name;
// true if this collection was just created (and not
// loaded from file
bool IsNew;
// index in listbox
int Index;
bool IsModified;
};
//
// special node that is used to remember entries for plugins
// that seem missing. This way we never loose data
//
class FakeNetNode : public ANetNode {
public:
FakeNetNode( ) { };
virtual ~FakeNetNode(){};
const QString pixmapName()
{ return QString(""); }
const QString nodeName()
{ return QString("Fake node" ); }
const QString nodeDescription()
{ return QString("Fake node" ); }
ANetNodeInstance * createInstance( void );
const char * provides( void )
{ return ""; }
virtual const char ** needs( void )
{ return 0; }
virtual bool generateProperFilesFor( ANetNodeInstance * )
{ return 0; }
- virtual bool hasDataFor( const QString &, bool DS )
+ virtual bool hasDataFor( const QString & )
{ return 0; }
- virtual bool generateDataForCommonFile(
- SystemFile & , long , ANetNodeInstance * )
- {return 1; }
virtual bool generateDeviceDataForCommonFile(
- SystemFile & , long , ANetNodeInstance * )
+ SystemFile & , long )
{return 1; }
private :
};
class FakeNetNodeInstance : public ANetNodeInstance {
public:
FakeNetNodeInstance( ANetNode * NN ) :
ANetNodeInstance( NN ), ValAttrPairs() { }
virtual ~FakeNetNodeInstance( void ) { }
virtual RuntimeInfo * runtime( void )
{ return 0; }
// create edit widget under parent
virtual QWidget * edit( QWidget * )
{ return 0; }
// is given data acceptable
virtual QString acceptable( void )
{ return QString(""); }
// get data from GUI and store in node
virtual void commit( void ) {}
// get next node
ANetNodeInstance * nextNode()
{ return 0; }
// return NetNode this is an instance of
// intialize am instance of a net node
void initialize( void ){}
// returns node specific data -> only useful for 'buddy'
virtual void * data( void )
{ return 0; }
+ virtual bool hasDataFor( const QString & )
+ { return 0; }
+
+ virtual bool generateDataForCommonFile( SystemFile & , long )
+ { return 1; }
+
protected :
virtual void setSpecificAttribute( QString & , QString & );
virtual void saveSpecificAttribute( QTextStream & );
QDict<QString> ValAttrPairs;
};
extern FakeNetNode * FakeNode;
#endif
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
index 394ff52..62bb6af 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
@@ -31,157 +31,155 @@ SystemFile::SystemFile( const QString & N, const QString & P ){
hasPostSection =
hasPreNodeSection =
hasPostNodeSection =
hasPreDeviceSection =
hasPostDeviceSection = 0;
return;
}
}
// have found location
S = TemplDir + Name + "/presection";
FI.setFile( S );
hasPreSection = ( FI.exists() && FI.isReadable() );
S = TemplDir + Name + "/postsection";
FI.setFile( S );
hasPostSection = ( FI.exists() && FI.isReadable() );
S = TemplDir + Name + "/prenodesection";
FI.setFile( S );
hasPreNodeSection = ( FI.exists() && FI.isReadable() );
S = TemplDir + Name + "/postnodesection";
FI.setFile( S );
hasPostNodeSection = ( FI.exists() && FI.isReadable() );
S = TemplDir + Name + "/predevicesection";
FI.setFile( S );
hasPreDeviceSection = ( FI.exists() && FI.isReadable() );
S = TemplDir + Name + "/postdevicesection";
FI.setFile( S );
hasPostDeviceSection = ( FI.exists() && FI.isReadable() );
}
}
SystemFile::~SystemFile( void ) {
if( F )
delete F;
}
bool SystemFile::open( void ) {
if( F ) {
F->close();
delete F;
}
F = new QFile( Path + "bup" );
if( ! F->open( IO_WriteOnly ) ) {
return 0;
}
setDevice( F );
return 1;
}
bool SystemFile::close( void ) {
if( ! F ) {
return 1 ;
}
QString OldP = Path + "bup";
F->close();
delete F;
F = 0;
return ( rename( OldP.latin1(), Path.latin1() ) >= 0 );
}
bool SystemFile::preSection( void ) {
if( hasPreSection ) {
QFile Fl( TemplDir + Name + "/presection" );
if( ! Fl.open( IO_ReadOnly ) )
return 1; // error
// copy file to this file
F->writeBlock( Fl.readAll() );
}
return 0;
}
bool SystemFile::postSection( void ) {
if( hasPostSection ) {
QFile Fl( TemplDir + Name + "/postsection" );
if( ! Fl.open( IO_ReadOnly ) )
return 1; // error
// copy file to this file
F->writeBlock( Fl.readAll() );
}
return 0;
}
bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) {
if( hasPreNodeSection ) {
QFile Fl( TemplDir + Name + "/prenodesection" );
if( ! Fl.open( IO_ReadOnly ) )
return 1; // error
QTextStream TX( &Fl );
QString Out;
QString S = TX.readLine();
while( ! TX.eof() ) {
Out = S.
- arg(NNI->netNode()->nodeName());
+ arg(NNI->nodeClass()->nodeName());
(*this) << Out << endl;
S = TX.readLine();
}
}
return 0;
}
-bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long DevNr ) {
+bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) {
if( hasPostNodeSection ) {
QFile Fl( TemplDir + Name + "/postnodesection" );
if( ! Fl.open( IO_ReadOnly ) )
return 1; // error
QTextStream TX( &Fl );
QString Out;
QString S = TX.readLine();
while( ! TX.eof() ) {
Out = S.
arg(NNI->nodeName());
(*this) << Out << endl;
S = TX.readLine();
}
}
return 0;
}
-bool SystemFile::preDeviceSection( ANetNodeInstance * NNI, long ) {
+bool SystemFile::preDeviceSection( ANetNode * NN ) {
if( hasPreDeviceSection ) {
QFile Fl( TemplDir + Name + "/predevicesection" );
if( ! Fl.open( IO_ReadOnly ) )
return 1; // error
QTextStream TX( &Fl );
QString Out;
QString S = TX.readLine();
while( ! TX.eof() ) {
- Out = S.
- arg(NNI->netNode()->nodeName());
+ Out = S.arg(NN->nodeName());
(*this) << Out << endl;
S = TX.readLine();
}
}
return 0;
}
-bool SystemFile::postDeviceSection( ANetNodeInstance * NNI, long DevNr ) {
+bool SystemFile::postDeviceSection( ANetNode * NN ) {
if( hasPostDeviceSection ) {
QFile Fl( TemplDir + Name + "/postdevicesection" );
if( ! Fl.open( IO_ReadOnly ) )
return 1; // error
QTextStream TX( &Fl );
QString Out;
QString S = TX.readLine();
while( ! TX.eof() ) {
- Out = S.
- arg(NNI->nodeName());
+ Out = S.arg(NN->nodeName());
(*this) << Out << endl;
S = TX.readLine();
}
}
return 0;
}
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.h b/noncore/settings/networksettings2/networksettings2/systemfile.h
index 35e0dfc..f57dab0 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.h
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.h
@@ -1,43 +1,43 @@
#ifndef __SYSTEMFILE__H
#define __SYSTEMFILE__H
#include <qstring.h>
#include <qtextstream.h>
class QFile;
class ANetNodeInstance;
class SystemFile : public QTextStream {
public :
SystemFile( const QString & Name, const QString & Path );
~SystemFile( void );
const QString & name( void )
{ return Name; }
bool open( void );
bool close( void );
bool preSection( void );
bool postSection( void );
bool preNodeSection( ANetNodeInstance * NNI, long DevNr );
bool postNodeSection( ANetNodeInstance * NNI, long DevNr );
- bool preDeviceSection( ANetNodeInstance * NNI, long DevNr );
- bool postDeviceSection( ANetNodeInstance * NNI, long DevNr );
+ bool preDeviceSection( ANetNode * NN );
+ bool postDeviceSection( ANetNode * NN );
private :
QString Name;
QString Path;
QFile * F;
bool hasPreSection;
bool hasPostSection;
bool hasPreNodeSection;
bool hasPostNodeSection;
bool hasPreDeviceSection;
bool hasPostDeviceSection;
};
#endif
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index 6541596..eb63e02 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -36,556 +36,505 @@ void NetworkSettingsData::loadSettings( void ) {
QFile F( CfgFile );
QTextStream TS( &F );
do {
if( ! F.open(IO_ReadOnly) )
break;
/* load the file ->
FORMAT :
[NETNODETYPE]
Entries ...
<EMPTYLINE>
[connection]
Name=Name
Node=Name
<EMPTYLINE>
*/
while( ! TS.atEnd() ) {
S = TS.readLine();
if ( S.isEmpty() || S[0] != '[' )
continue;
S = S.mid( 1, S.length()-2 );
if( ! NSResources ) {
continue;
}
if( S == "connection" ) {
// load connections -> collections of nodes
NodeCollection * NC = new NodeCollection( TS );
NSResources->addConnection( NC );
} else {
// load nodes
NNI = NSResources->createNodeInstance( S );
if( ! NNI ) {
printf( "SKIPPING %s\n", S.latin1() );
}
do {
S = TS.readLine();
if( S.isEmpty() ) {
// empty line
break;
}
// node found ?
if( NNI ) {
idx = S.find( '=' );
if( idx > 0 ) {
Attr = S.left( idx );
Value = S.mid( idx+1, S.length() );
} else {
Value="";
Attr = S;
}
Value.stripWhiteSpace();
Attr.stripWhiteSpace();
Attr.lower();
// dequote Attr
Value = deQuote(Value);
// set the attribute
NNI->setAttribute( Attr, Value );
}
} while( 1 );
if( NNI ) {
// loading from file -> exists
NNI->setNew( FALSE );
NSResources->addNodeInstance( NNI );
}
}
}
} while( 0 );
}
QString NetworkSettingsData::saveSettings( void ) {
QString ErrS = "";
if( ! isModified() )
return ErrS;
QString S;
QFile F( CfgFile + ".bup" );
printf( "Saving settings to %s\n", CfgFile.latin1() );
if( ! F.open( IO_WriteOnly | IO_Truncate ) ) {
ErrS = qApp->translate( "NetworkSettings",
- "<p>Could not save setup to %1 !</p>" ).
+ "<p>Could not save setup to \"%1\" !</p>" ).
arg(CfgFile);
// problem
return ErrS;
}
QTextStream TS( &F );
{ Name2Connection_t & M = NSResources->connections();
ANetNodeInstance * NNI;
// for all connections
for( QDictIterator<NodeCollection> it(M);
it.current();
++it ) {
// all nodes in those connections
for( QListIterator<ANetNodeInstance> nit(*(it.current()));
nit.current();
++nit ) {
// header
NNI = nit.current();
- TS << '[' <<NNI->netNode()->nodeName() << ']' << endl;
+ TS << '[' <<NNI->nodeClass()->nodeName() << ']' << endl;
NNI->saveAttributes( TS );
TS << endl;
}
TS << "[connection]" << endl;
it.current()->save(TS);
}
}
QDir D(".");
D.rename( CfgFile + ".bup", CfgFile );
//
// proper files AND system files regenerated
//
setModified( 0 );
return ErrS;
}
QString NetworkSettingsData::generateSettings( bool ForceReq ) {
bool ForceIt;
QString S = "";
// include own force flag
ForceIt = (Force) ? 1 : ForceReq;
if( ! ForceIt && ! isModified() )
return S;
// regenerate system files
- printf( "Generating settings from %s\n", CfgFile.latin1() );
+ fprintf( stderr, "Generating settings from %s\n", CfgFile.latin1() );
{ Name2SystemFile_t & SFM = NSResources->systemFiles();
Name2Connection_t & M = NSResources->connections();
NodeCollection * NC;
ANetNodeInstance * NNI;
SystemFile * SF;
AsDevice * CurDev;
+ ANetNode * CurDevNN;
bool needToRegenerate = ForceIt;
//
// check if we need to generate at least one of the system files
//
if( ! ForceIt ) {
for( QDictIterator<SystemFile> sfit(SFM);
sfit.current();
++sfit ) {
SF = sfit.current();
// check if there are nodes that are modified and require
// data for this system file
// for all connections
for( QDictIterator<NodeCollection> ncit(M);
ncit.current();
++ncit ) {
NC = ncit.current();
if( NC->isModified() ) {
// does this connection 'touch' this system file ?
for( QListIterator<ANetNodeInstance> cncit(*NC);
cncit.current();
++cncit ) {
NNI = cncit.current();
- if( ( NNI->netNode()->hasDataFor( SF->name(), 1 ) ||
- NNI->netNode()->hasDataFor( SF->name(), 0 )
+ if( ( NNI->nodeClass()->hasDataFor( SF->name() ) ||
+ NNI->hasDataFor( SF->name() )
) &&
NNI->isModified() ) {
needToRegenerate = 1;
break;
}
}
}
if( needToRegenerate )
break;
}
if( needToRegenerate )
break;
}
}
// we cannot renumber with a FORCE request since
// we probably are NOT going to save the config
// e.g. when using --regen option
if( ! ForceReq && needToRegenerate ) {
NSResources->renumberConnections();
setModified(1);
}
//
// generate files proper to each netnodeinstance
//
{ Name2Instance_t & NNIs = NSResources->netNodeInstances();
for( QDictIterator<ANetNodeInstance> NNIIt(NNIs);
NNIIt.current();
++NNIIt
){
// for all nodes find those that are modified
NNI = NNIIt.current();
if( ForceIt || NNI->isModified() ) {
- if( ! NNI->netNode()->generateProperFilesFor( NNI ) ) {
+ if( ! NNI->nodeClass()->generateProperFilesFor( NNI ) ) {
// problem generating
S = qApp->translate( "NetworkSettings",
- "<p>Cannot generate files proper to %1</p>" ).
- arg(NNI->netNode()->nodeName()) ;
+ "<p>Cannot generate files proper to \"%1\"</p>" ).
+ arg(NNI->nodeClass()->nodeName()) ;
return S;
}
}
}
}
//
// generate all system files
//
for( QDictIterator<SystemFile> sfit(SFM);
sfit.current();
++sfit ) {
SF = sfit.current();
- printf( "Generating %s\n", SF->name().latin1() );
+ fprintf( stderr, "Generating %s\n", SF->name().latin1() );
SF->open();
do { // so we can break;
// global presection for this system file
if( SF->preSection() ) {
S = qApp->translate( "NetworkSettings",
- "<p>Error in preSection for file %1</p>" ).
+ "<p>Error in preSection for file \"%1\"</p>" ).
arg( SF->name() );
return S;
}
// find all netnodes and figure out if
// for that node there are instances
for( QDictIterator<NetNode_t> nnit(
NSResources->netNodes() );
nnit.current();
++nnit ) {
- ANetNode * NN;
- NN = nnit.current()->NetNode;
+ CurDevNN = nnit.current()->NetNode;
- // are there instances ?
+ // are there instances for this netnode ?
NNI = 0;
for( QDictIterator<ANetNodeInstance> nniit(
NSResources->netNodeInstances() );
nniit.current();
++nniit ) {
- if( nniit.current()->netNode() == NN ) {
+ if( nniit.current()->nodeClass() == CurDevNN ) {
NNI = nniit.current();
break;
}
}
if( ! NNI )
- // no instances
+ // no instances -> next netnode type
continue;
// has this node data for this system file ?
if( (CurDev = NNI->runtime()->asDevice() ) ) {
// generate start for this nodetype for all possible devices of this type
- for( int i = 0; i < CurDev->count(); i ++ ) {
- if( SF->preDeviceSection( NNI, i ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in preDeviceSection for file %1 and node %2</p>" ).
- arg( SF->name() ).
- arg( NN->nodeName() );
- return S;
- }
-
- if( ! NN->hasDataFor( SF->name(), 1 ) ) {
- if( NN->generateDeviceDataForCommonFile( *SF, i, NNI ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in node part for file %1 and node %2</p>" ).
- arg( SF->name() ).
- arg( NN->nodeName() );
- return S;
- }
- }
- }
- } else {
- // just request this once
- if( SF->preDeviceSection( NNI, -1 ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in preDeviceSection for file %1 and node %2</p>" ).
- arg( SF->name() ).
- arg( NN->nodeName() );
- return S;
- }
-
- if( ! NN->hasDataFor( SF->name(), 1 ) ) {
- if( NN->generateDeviceDataForCommonFile( *SF, -1, NNI ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in node part for file %1 and node %2</p>" ).
- arg( SF->name() ).
- arg( NN->nodeName() );
- return S;
- }
- }
- }
-
- // now generate profile specific data for all
- // connections working on a device of the current
- // netnode type
- for( QDictIterator<NodeCollection> ncit(M);
- ncit.current();
- ++ncit ) {
- NC = ncit.current();
-
- NNI = NC->getToplevel();
-
- // no output needed
- if( ! NNI->netNode()->hasDataFor( SF->name(), 0 ) )
- continue;
-
- // get the netnode that serves as the device for this
- // connection
- AsDevice * Dev = NC->device();
-
- if( CurDev ) {
- if( CurDev != Dev ) {
- // other device -> later
- continue;
- }
-
- // generate 'entry' for every combination of device and profile
- // each node delegates to deeper level
- for( int i = 0; i < CurDev->count(); i ++ ) {
- if( SF->preNodeSection( NNI, i ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in preNodeSection for file %1 and node %2</p>" ).
- arg( SF->name() ).
- arg( NNI->netNode()->nodeName() );
+ for( int i = 0; i < CurDevNN->instanceCount(); i ++ ) {
+ S = generateSystemFileNode( *SF, CurDev, NNI, i );
+ if( ! S.isEmpty() )
return S;
}
-
- // ask all nodes in connection
-
- for( QListIterator<ANetNodeInstance> cncit(*NC);
- cncit.current();
- ++cncit ) {
- NNI = cncit.current();
-
- if( NNI->netNode()->hasDataFor( SF->name(), 0 ) ) {
- if( NNI->netNode()->generateDataForCommonFile(*SF,i,NNI) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in node part for file %1 and node %2</p>" ).
- arg( SF->name() ).
- arg( NNI->netNode()->nodeName() );
- return S;
- }
- }
- }
-
- if( SF->postNodeSection( NNI, i ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in postNodeSection for file %1 and node %2</p>" ).
- arg( SF->name() ).
- arg( NNI->netNode()->nodeName() );
- return S;
- }
- }
-
} else {
- if( Dev ) {
- // other
- continue;
- }
-
- // one entry to generate
- if( SF->preNodeSection( NNI, -1 ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in preNodeSection for file %1 and node %2</p>" ).
- arg( SF->name() ).
- arg( NNI->netNode()->nodeName() );
- return S;
- }
-
- if( NNI->netNode()->generateDataForCommonFile(*SF,-1,NNI) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in node part for file %1 and node %2</p>" ).
- arg( SF->name() ).
- arg( NNI->netNode()->nodeName() );
- return S;
- }
-
- if( SF->postNodeSection( NNI, -1 ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in postNodeSection for file %1 and node %2</p>" ).
- arg( SF->name() ).
- arg( NNI->netNode()->nodeName() );
+ S = generateSystemFileNode( *SF, 0, NNI, -1 );
+ if( ! S.isEmpty() )
return S;
}
}
- // generated some data
- if( SF->postNodeSection( NNI, -1 ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in postNodeSection for file %1 and node %2</p>" ).
- arg( SF->name() ).
- arg( NNI->netNode()->nodeName() );
- return S;
- }
- *SF << endl;
- }
-
- if( CurDev ) {
- // generate 'entry' for every combination of device and profile
- // each node delegates to deeper level
- for( int i = 0; i < CurDev->count(); i ++ ) {
- if( SF->postDeviceSection( NNI, i ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in postDeviceSection for file %1 and node %2</p>" ).
- arg( SF->name() ).
- arg( NNI->netNode()->nodeName() );
- return S;
- }
- }
- } else {
- if( SF->postDeviceSection( NNI, -1 ) ) {
- S = qApp->translate( "NetworkSettings",
- "<p>Error in postDeviceSection for file %1 and node %2</p>" ).
- arg( SF->name() ).
- arg( NNI->netNode()->nodeName() );
- return S;
- }
- }
- }
-
if( SF->postSection() ) {
S = qApp->translate( "NetworkSettings",
- "<p>Error in postSection for file %1</p>" ).
+ "<p>Error in postSection for file \"%1\"</p>" ).
arg( SF->name() );
return S;
}
} while( 0 );
SF->close();
}
}
Force = 0;
return S;
}
QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) {
// collect connections that can work on top of this interface
NodeCollection * NC;
QList<NodeCollection> PossibleConnections;
Name2Connection_t & M = NSResources->connections();
// for all connections
for( QDictIterator<NodeCollection> it(M);
it.current();
++it ) {
NC = it.current();
// check if this profile handles the requested interface
if( NC->handlesInterface( Interface ) && // if different Intf.
NC->state() != Disabled && // if not enabled
NC->state() != IsUp // if already used
) {
PossibleConnections.append( NC );
}
}
return PossibleConnections;
}
/*
Called by the system to see if interface can be brought UP
if allowed, echo Interface-allowed else Interface-disallowed
*/
void NetworkSettingsData::canStart( const char * Interface ) {
// load situation
NodeCollection * NC = 0;
QList<NodeCollection> PossibleConnections;
PossibleConnections = collectPossible( Interface );
switch( PossibleConnections.count() ) {
case 0 : // no connections
break;
case 1 : // one connection
NC = PossibleConnections.first();
break;
default : // need to ask user ?
// are we connected to a server
// system( "su %d networksettings2 --prompt %s\n",
// "", Interface );
break;
}
if( NC ) {
switch( NC->state() ) {
case Unchecked :
case Unknown :
case Unavailable :
case Disabled :
// this profile does not allow interface to be UP
// -> try others
break;
case Off :
// try to UP the device
if( ! NC->setState( Activate ) ) {
// cannot bring device Online -> try other alters
break;
}
// FT
case Available :
case IsUp : // also called for 'ifdown'
// device is ready -> done
printf( "%s-c%d-allowed\n", Interface, NC->number() );
return;
}
} else {
// if we come here no alternatives are possible
printf( "%s-cnn-disallowed\n", Interface );
}
}
/*
Called by the system to regenerate config files
*/
bool NetworkSettingsData::regenerate( void ) {
QString S;
// load situation
S = generateSettings( TRUE );
if( ! S.isEmpty() ) {
fprintf( stdout, "%s\n", S.latin1() );
return 1;
}
return 0;
}
+QString NetworkSettingsData::generateSystemFileNode(
+ SystemFile &SF,
+ AsDevice * CurDev,
+ ANetNodeInstance * DevNNI,
+ long DevInstNr ) {
+
+ QString S="";
+ ANetNode * CurDevNN = DevNNI->nodeClass();
+ Name2Connection_t & M = NSResources->connections();
+
+ if( SF.preDeviceSection( CurDevNN ) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in preDeviceSection for file \"%1\" and nodetype \"%2\"</p>" ).
+ arg( SF.name() ).
+ arg( CurDevNN->nodeName() );
+ return S;
+ }
+
+ if( CurDevNN->hasDataFor( SF.name() ) ) {
+ if( CurDevNN->generateDeviceDataForCommonFile( SF, DevInstNr ) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in node Device part for file \"%1\" and node \"%2\"</p>" ).
+ arg( SF.name() ).
+ arg( CurDevNN->nodeName() );
+ return S;
+ }
+ }
+
+ if( CurDev )
+ fprintf( stderr, "Cur %s\n", CurDevNN->nodeName().latin1() );
+ else
+ fprintf( stderr, "Cur NO\n" );
+
+ // now generate profile specific data for all
+ // connections working on a device of the current
+ // netnode type
+ for( QDictIterator<NodeCollection> ncit(M);
+ ncit.current();
+ ++ncit ) {
+ NodeCollection * NC = ncit.current();
+
+ // currenly only those connections that work on
+ // the current device (or on no device if no current)
+ AsDevice * Dev = NC->device();
+
+ fprintf( stderr, "%s\n", Dev->netNode()->nodeName().latin1() );
+ if( CurDev ) {
+ if( CurDevNN != Dev->netNode()->nodeClass() ) {
+ // other device type -> later
+ fprintf( stderr, "Other Dev type\n" );
+ continue;
+ }
+ } else {
+ if( Dev ) {
+ // other
+ continue;
+ }
+ }
+
+ // generate 'entry'
+ if( SF.preNodeSection( DevNNI, DevInstNr ) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in preNodeSection for file \"%1\" and node \"%2\"</p>" ).
+ arg( SF.name() ).
+ arg( CurDevNN->nodeName() );
+ return S;
+ }
+
+ // ask all nodes in connection
+ for( QListIterator<ANetNodeInstance> cncit(*NC);
+ cncit.current();
+ ++cncit ) {
+ ANetNodeInstance * NNI = cncit.current();
+
+ if( NNI->hasDataFor( SF.name() ) ) {
+ if( NNI->generateDataForCommonFile(SF,DevInstNr) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in node part for file \"%1\" and node \"%2\"</p>" ).
+ arg( SF.name() ).
+ arg( NNI->nodeClass()->nodeName() );
+ return S;
+ }
+ }
+ }
+
+ if( SF.postNodeSection( DevNNI, DevInstNr ) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in postNodeSection for file \"%1\" and node \"%2\"</p>" ).
+ arg( SF.name() ).
+ arg( CurDevNN->nodeName() );
+ return S;
+ }
+ SF << endl;
+ }
+
+ if( SF.postDeviceSection( CurDevNN ) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Error in postDeviceSection for file \"%1\" and node \"%2\"</p>" ).
+ arg( SF.name() ).
+ arg( CurDevNN->nodeName() );
+ return S;
+ }
+
+ return S;
+}
diff --git a/noncore/settings/networksettings2/nsdata.h b/noncore/settings/networksettings2/nsdata.h
index 55f8c71..b54df24 100644
--- a/noncore/settings/networksettings2/nsdata.h
+++ b/noncore/settings/networksettings2/nsdata.h
@@ -1,37 +1,42 @@
#ifndef __NSDATA_H
#define __NSDATA_H
#include "netnode.h"
class NetworkSettingsData {
public :
NetworkSettingsData( void );
~NetworkSettingsData( void );
void loadSettings( void );
QString saveSettings( void );
QString generateSettings( bool Force = FALSE );
bool isModified( void )
{ return IsModified; }
void setModified( bool m )
{ IsModified = m; }
QList<NodeCollection> collectPossible( const char * Interface );
void canStart( const char * Interface );
bool regenerate( void );
void forceGeneration( bool m )
{ Force = m; }
private :
+ QString NetworkSettingsData::generateSystemFileNode(
+ SystemFile & SF,
+ AsDevice * CurDev,
+ ANetNodeInstance * DevNNI,
+ long DevInstNr );
bool IsModified;
bool Force;
};
#endif
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
index 51d17ec..b3f70c5 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
@@ -1,69 +1,62 @@
#include "ppp_NN.h"
#include "ppp_NNI.h"
static const char * PPPNeeds[] =
{ "line",
"modem",
0
};
/**
* Constructor, find all of the possible interfaces
*/
PPPNetNode::PPPNetNode() : ANetNode() {
}
/**
* Delete any interfaces that we own.
*/
PPPNetNode::~PPPNetNode(){
}
const QString PPPNetNode::nodeDescription(){
return tr("\
<p>Sets up IP using PPP.</p>\
<p>Use this for dialup devices or serial setups</p>\
"
);
}
ANetNodeInstance * PPPNetNode::createInstance( void ) {
return new APPP( this );
}
const char ** PPPNetNode::needs( void ) {
return PPPNeeds;
}
const char * PPPNetNode::provides( void ) {
return "connection";
}
bool PPPNetNode::generateProperFilesFor(
ANetNodeInstance * ) {
return 1;
}
-bool PPPNetNode::hasDataFor( const QString &, bool ) {
- return 0;
-}
-
-bool PPPNetNode::generateDataForCommonFile(
+bool PPPNetNode::generateDeviceDataForCommonFile(
SystemFile & ,
- long,
- ANetNodeInstance * ) {
+ long ) {
return 1;
}
-bool PPPNetNode::generateDeviceDataForCommonFile(
- SystemFile & ,
- long ,
- ANetNodeInstance * ) {
- return 1;
+QString PPPNetNode::genNic( long NicNr ) {
+ QString S;
+ return S.sprintf( "ppp%ld", NicNr );
}
extern "C" {
void create_plugin( QList<ANetNode> & PNN ) {
PNN.append( new PPPNetNode() );
}
}
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.h b/noncore/settings/networksettings2/ppp/ppp_NN.h
index 8d56e7f..c33f281 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.h
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.h
@@ -1,46 +1,47 @@
#ifndef PPP_NETNODE_H
#define PPP_NETNODE_H
#include "netnode.h"
class APPP;
class PPPNetNode : public ANetNode{
Q_OBJECT
public:
PPPNetNode();
virtual ~PPPNetNode();
virtual const QString pixmapName()
{ return "Devices/ppp"; }
virtual const QString nodeName()
{ return tr("PPP Connection"); }
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 DS );
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ virtual bool hasDataFor( const QString & )
+ { return 0; }
virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ SystemFile & SF, long DevNr );
+
+ virtual QString genNic( long NicNr );
private:
};
extern "C"
{
void create_plugin( QList<ANetNode> & PNN );
};
#endif
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
index d09ecf9..d0fd31c 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
@@ -20,96 +20,102 @@ APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) {
Data.IP.GWAutomatic = 1;
Data.IP.GWAddress = "";
Data.IP.GWIsDefault = 1;
GUI = 0;
RT = 0;
}
void APPP::setSpecificAttribute( QString & A, QString & V ) {
if( A.startsWith( "dns" ) ) {
if( A == "dnsserverassigned" ) {
Data.DNS.ServerAssigned = (V == "yes");
} else if( A == "dnsdomainname" ) {
Data.DNS.DomainName = V;
} else if( A == "dnsserver" ) {
Data.DNS.Servers.resize( Data.DNS.Servers.size()+1 );
Data.DNS.Servers[Data.DNS.Servers.size()-1] =
new QString( V );
}
} else if( A.startsWith( "auth" ) ) {
if( A == "authmode" ) {
Data.Auth.Mode = V.toShort();
} else if( A == "authloginexpect" ) {
Data.Auth.Login.Expect = V;
} else if( A == "authloginsend" ) {
Data.Auth.Login.Send = V;
} else if( A == "authpasswordexpect" ) {
Data.Auth.Password.Expect = V;
} else if( A == "authpasswordsend" ) {
Data.Auth.Password.Send = V;
} else if( A == "authpcemode" ) {
Data.Auth.PCEMode = V.toShort();
} else if( A == "authclient" ) {
Data.Auth.Client = V;
} else if( A == "authserver" ) {
Data.Auth.Server = V;
} else if( A == "authsecret" ) {
Data.Auth.Secret = V;
}
} else if( A.startsWith( "ip" ) ) {
if( A == "ipautomatic" ) {
Data.IP.IPAutomatic = (V == "yes");
} else if( A == "gwautomatic" ) {
Data.IP.GWAutomatic = (V == "yes");
} else if( A == "gwisdefault" ) {
Data.IP.GWIsDefault = (V == "yes");
} else if( A == "ipaddress" ) {
Data.IP.IPAddress = V;
} else if( A == "ipsubmask" ) {
Data.IP.IPSubMask = V;
} else if( A == "gwaddress" ) {
Data.IP.GWAddress = V;
}
}
}
void APPP::saveSpecificAttribute( QTextStream & TS ) {
TS << "dnsserverassigned=" <<
( ( Data.DNS.ServerAssigned ) ? "yes" : "no" ) << endl;
TS << "dnsdomainname=" << Data.DNS.DomainName << endl;
for( unsigned int i = 0; i < Data.DNS.Servers.size(); i ++ ) {
TS << "dnsserver=" << *(Data.DNS.Servers[i]) << endl;
}
TS << "authmode=" << Data.Auth.Mode << endl;
TS << "authloginexpect=" << quote( Data.Auth.Login.Expect ) << endl;
TS << "authloginsend=" << quote( Data.Auth.Login.Send ) << endl;
TS << "authpasswordexpect=" << quote( Data.Auth.Password.Expect ) << endl;
TS << "authpasswordsend=" << quote( Data.Auth.Password.Send ) << endl;
TS << "authpcemode=" << Data.Auth.PCEMode << endl;
TS << "authclient=" << Data.Auth.Client << endl;
TS << "authserver=" << Data.Auth.Server << endl;
TS << "authsecret=" << quote( Data.Auth.Secret ) << endl;
TS << "ipautomatic=" << ( ( Data.IP.IPAutomatic ) ? "yes" : "no" ) << endl;
TS << "gwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl;
TS << "gwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl;
TS << "ipaddress=" << Data.IP.IPAddress << endl;
TS << "ipsubmask=" << Data.IP.IPSubMask << endl;
TS << "gwaddress=" << Data.IP.GWAddress << endl;
}
QWidget * APPP::edit( QWidget * parent ) {
GUI = new PPPEdit( parent );
GUI->showData( Data );
return GUI;
}
QString APPP::acceptable( void ) {
return ( GUI ) ? GUI->acceptable( ) : QString();
}
void APPP::commit( void ) {
if( GUI && GUI->commit( Data ) ) {
setModified( 1 );
}
}
+bool APPP::generateDataForCommonFile(
+ SystemFile & ,
+ long) {
+ return 1;
+}
+
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.h b/noncore/settings/networksettings2/ppp/ppp_NNI.h
index a17721a..989c2f0 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NNI.h
+++ b/noncore/settings/networksettings2/ppp/ppp_NNI.h
@@ -1,43 +1,48 @@
#ifndef PPP_H
#define PPP_H
#include <netnode.h>
#include "pppdata.h"
#include "ppprun.h"
class PPPNetNode;
class PPPEdit;
class APPP : public ANetNodeInstance {
public :
APPP( PPPNetNode * PNN );
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
RuntimeInfo * runtime( void )
{ if( RT == 0 )
RT = new PPPRun( this, Data );
return RT->runtimeInfo();
}
virtual void * data( void )
{ return (void *)&Data; }
+ virtual bool hasDataFor( const QString & )
+ { return 0; }
+
+ virtual bool generateDataForCommonFile(
+ SystemFile & SF, long DevNr );
protected :
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
private :
PPPEdit * GUI;
PPPData Data;
PPPRun * RT;
};
#endif
diff --git a/noncore/settings/networksettings2/ppp/ppprun.h b/noncore/settings/networksettings2/ppp/ppprun.h
index 765aff2..af51fbe 100644
--- a/noncore/settings/networksettings2/ppp/ppprun.h
+++ b/noncore/settings/networksettings2/ppp/ppprun.h
@@ -1,49 +1,47 @@
#ifndef PPPRUN_H
#define PPPRUN_H
#include <qregexp.h>
#include <asconnection.h>
#include <asdevice.h>
#include "pppdata.h"
class PPPRun : public AsConnection, public AsDevice {
public :
PPPRun( ANetNodeInstance * NNI,
PPPData & Data );
- virtual QString genNic( long NicNr )
- { QString S; return S.sprintf( "ppp%ld", NicNr ); }
virtual AsDevice * asDevice( void )
{ return (AsDevice *)this; }
virtual AsConnection * asConnection( void )
{ return (AsConnection *)this; }
virtual AsDevice * device( void )
{ return (AsDevice *)this; }
virtual RuntimeInfo * runtimeInfo( void )
{ return ( AsConnection *)this; }
protected :
void detectState( NodeCollection * NC );
bool setState( NodeCollection * NC, Action_t A );
bool canSetState( State_t S, Action_t A )
{ return AsDevice::connection()->findNext(
AsDevice::netNode() )->runtime()->canSetState( S,A ); }
bool handlesInterface( const QString & I );
private :
bool isMyPPPDRunning( void );
bool isMyPPPUp( void );
PPPData_t * D;
QRegExp Pat;
};
#endif
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp
index fcf1ca6..7609cdc 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NN.cpp
@@ -1,68 +1,56 @@
#include "profile_NN.h"
#include "profile_NNI.h"
static const char * ProfileNeeds[] =
{ "connection",
0
};
/**
* Constructor, find all of the possible interfaces
*/
ProfileNetNode::ProfileNetNode() : ANetNode() {
}
/**
* Delete any interfaces that we own.
*/
ProfileNetNode::~ProfileNetNode(){
}
const QString ProfileNetNode::nodeDescription(){
return tr("\
<p>Define use of an IP connection.</p>\
<p>Configure if and when this connection needs to be established</p>\
"
);
}
ANetNodeInstance * ProfileNetNode::createInstance( void ) {
return new AProfile( this );
}
const char ** ProfileNetNode::needs( void ) {
return ProfileNeeds;
}
const char * ProfileNetNode::provides( void ) {
return "fullsetup";
}
bool ProfileNetNode::generateProperFilesFor(
ANetNodeInstance * ) {
return 1;
}
-bool ProfileNetNode::hasDataFor( const QString &, bool ) {
- return 0;
-}
-
-bool ProfileNetNode::generateDataForCommonFile(
- SystemFile & ,
- long,
- ANetNodeInstance * ) {
- return 1;
-}
-
bool ProfileNetNode::generateDeviceDataForCommonFile(
SystemFile & ,
- long ,
- ANetNodeInstance * ) {
+ long ) {
return 1;
}
extern "C" {
void create_plugin( QList<ANetNode> & PNN ) {
PNN.append( new ProfileNetNode() );
}
}
diff --git a/noncore/settings/networksettings2/profile/profile_NN.h b/noncore/settings/networksettings2/profile/profile_NN.h
index b64a6dd..f7c2b22 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.h
+++ b/noncore/settings/networksettings2/profile/profile_NN.h
@@ -1,46 +1,45 @@
#ifndef PROFILE_NETNODE_H
#define PROFILE_NETNODE_H
#include "netnode.h"
class AProfile;
class ProfileNetNode : public ANetNode{
Q_OBJECT
public:
ProfileNetNode();
virtual ~ProfileNetNode();
virtual const QString pixmapName()
{ return "Devices/commprofile"; }
virtual const QString nodeName()
{ return tr("Regular profile"); }
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 DS );
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ virtual bool hasDataFor( const QString & )
+ { return 0; }
virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ SystemFile & SF, long DevNr);
private:
};
extern "C"
{
void create_plugin( QList<ANetNode> & PNN );
};
#endif
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.cpp b/noncore/settings/networksettings2/profile/profile_NNI.cpp
index bc0118e..5b54aa4 100644
--- a/noncore/settings/networksettings2/profile/profile_NNI.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NNI.cpp
@@ -1,48 +1,54 @@
#include "profileedit.h"
#include "profile_NNI.h"
#include "profile_NN.h"
AProfile::AProfile( ProfileNetNode * PNN ) : ANetNodeInstance( PNN ) {
Data.Automatic = 1;
Data.Confirm = 0;
Data.Description = "";
Data.Disabled = 0;
GUI = 0;
RT = 0;
}
void AProfile::setSpecificAttribute( QString & Attr, QString & Value ) {
if ( Attr == "automatic" ) {
Data.Automatic = (Value=="yes");
} else if ( Attr == "preconfirm" ) {
Data.Confirm = (Value=="yes");
} else if ( Attr == "disabled" ) {
Data.Disabled = (Value=="yes");
} else if ( Attr == "description" ) {
Data.Description = Value;
}
}
void AProfile::saveSpecificAttribute( QTextStream & TS ) {
TS << "automatic=" << ((Data.Automatic) ? "yes" : "no") << endl;
TS << "preconfirm=" << ((Data.Confirm) ? "yes" : "no") << endl;
TS << "disabled=" << ((Data.Disabled) ? "yes" : "no") << endl;
TS << "description=" << Data.Description << endl;
}
QWidget * AProfile::edit( QWidget * parent ) {
GUI = new ProfileEdit( parent, this );
GUI->showData( Data );
return GUI;
}
QString AProfile::acceptable( void ) {
return ( GUI ) ? GUI->acceptable( ) : QString();
}
void AProfile::commit( void ) {
if( GUI && GUI->commit( Data ) )
setModified( 1 );
}
+bool AProfile::generateDataForCommonFile(
+ SystemFile & ,
+ long) {
+ return 1;
+}
+
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.h b/noncore/settings/networksettings2/profile/profile_NNI.h
index dfeb178..2c2db7f 100644
--- a/noncore/settings/networksettings2/profile/profile_NNI.h
+++ b/noncore/settings/networksettings2/profile/profile_NNI.h
@@ -1,45 +1,51 @@
#ifndef PROFILE_H
#define PROFILE_H
#include <netnode.h>
#include "profiledata.h"
#include "profilerun.h"
class ProfileNetNode;
class ProfileEdit;
class AProfile : public ANetNodeInstance {
public :
AProfile( ProfileNetNode * PNN );
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
const QString & description( void )
{ return Data.Description; }
RuntimeInfo * runtime( void )
{ if( RT == 0 )
RT = new ProfileRun( 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);
+
protected :
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
private :
ProfileEdit * GUI;
ProfileData Data;
ProfileRun * RT;
};
#endif
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
@@ -1,67 +1,71 @@
#include "usb_NN.h"
#include "usb_NNI.h"
static const char * USBNeeds[] =
{ 0
};
/**
* Constructor, find all of the possible interfaces
*/
USBNetNode::USBNetNode() : ANetNode() {
}
/**
* Delete any interfaces that we own.
*/
USBNetNode::~USBNetNode(){
}
const QString USBNetNode::nodeDescription(){
return tr("\
<p>Configure Ethernet over USB.</p>\
<p>Use this for a computer to computer USB cable connection</p>\
"
);
}
ANetNodeInstance * USBNetNode::createInstance( void ) {
return new AUSB( this );
}
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
@@ -1,46 +1,46 @@
#ifndef USB_NETNODE_H
#define USB_NETNODE_H
#include "netnode.h"
class AUSB;
class USBNetNode : public ANetNode{
Q_OBJECT
public:
USBNetNode();
virtual ~USBNetNode();
virtual const QString pixmapName()
{ return "Devices/usb"; }
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
@@ -1,57 +1,52 @@
#include <qpe/qpeapplication.h>
#include "usbedit.h"
#include "usb_NNI.h"
#include "usb_NN.h"
AUSB::AUSB( USBNetNode * PNN ) : ANetNodeInstance( PNN ) {
GUI = 0;
RT = 0;
}
void AUSB::setSpecificAttribute( QString & , QString & ) {
}
void AUSB::saveSpecificAttribute( QTextStream & ) {
}
QWidget * AUSB::edit( QWidget * parent ) {
GUI = new USBEdit( parent );
GUI->showData( Data );
return GUI;
}
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
@@ -1,45 +1,46 @@
#ifndef USB_H
#define USB_H
#include <netnode.h>
#include "usbdata.h"
#include "usbrun.h"
class USBNetNode;
class USBEdit;
class AUSB : public ANetNodeInstance {
public :
AUSB( USBNetNode * PNN );
QWidget * edit( QWidget * parent );
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;
};
#endif
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
@@ -81,102 +81,96 @@ bool USBRun::setState( NodeCollection * NC, Action_t A ) {
switch( A ) {
case Activate :
{
if( NC->currentState() != Off ) {
return 0;
}
InterfaceInfo * N = getInterface();
if( ! N ) {
// no interface available
NC->setCurrentState( Unavailable );
return 0;
}
// because we were OFF the interface
// we get back is NOT assigned
N->assignNode( netNode() );
assignInterface( N );
fprintf( stderr, "Assing %p\n", N );
NC->setCurrentState( Available );
return 1;
}
case Deactivate :
if( NC->currentState() == IsUp ) {
// bring down first
if( ! connection()->setState( Down ) )
// could not ...
return 0;
} else if( NC->currentState() != Available ) {
return 1;
}
assignedInterface()->assignNode( 0 ); // release
assignInterface( 0 );
NC->setCurrentState( Off );
return 1;
default :
// FT
break;
}
return 0;
}
bool USBRun::canSetState( State_t Curr, Action_t A ) {
// we only handle up down activate and deactivate
switch( A ) {
case Activate :
{ // at least available
if( Curr == Available ) {
return 1;
}
// or we can make one available
InterfaceInfo * N = getInterface();
if( ! N || N->assignedNode() != 0 ) {
// non available or assigned
return 0;
}
return 1;
}
case Deactivate :
return ( Curr >= Available );
default :
// FT
break;
}
return 0;
}
// get interface that is free or assigned to us
InterfaceInfo * USBRun::getInterface( void ) {
System & S = NSResources->system();
InterfaceInfo * best = 0, * Run;
QRegExp R( "usb[0-9abcdef]" );
for( QDictIterator<InterfaceInfo> It(S.interfaces());
It.current();
++It ) {
Run = It.current();
if( handlesInterface( Run->Name ) &&
Run->CardType == ARPHRD_ETHER
) {
// this is a USB card
if( Run->assignedNode() == netNode() ) {
// assigned to us
return Run;
} else if( Run->assignedNode() == 0 ) {
// 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
@@ -1,41 +1,37 @@
#ifndef USBRUN_H
#define USBRUN_H
#include <asdevice.h>
#include <qregexp.h>
#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 );
private :
InterfaceInfo * getInterface( void );
QRegExp Pat;
};
#endif
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
index f570fb2..d9aa892 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
@@ -1,68 +1,56 @@
#include "vpn_NN.h"
#include "vpn_NNI.h"
static const char * VPNNeeds[] =
{ "connection",
0
};
/**
* Constructor, find all of the possible interfaces
*/
VPNNetNode::VPNNetNode() : ANetNode() {
}
/**
* Delete any interfaces that we own.
*/
VPNNetNode::~VPNNetNode(){
}
const QString VPNNetNode::nodeDescription(){
return tr("\
<p>Configure private IP connection.</p>\
<p>Defines Secure tunnels over non secure IP sessions</p>\
"
);
}
ANetNodeInstance * VPNNetNode::createInstance( void ) {
return new AVPN( this );
}
const char ** VPNNetNode::needs( void ) {
return VPNNeeds;
}
const char * VPNNetNode::provides( void ) {
return "connection";
}
bool VPNNetNode::generateProperFilesFor(
ANetNodeInstance * ) {
return 1;
}
-bool VPNNetNode::hasDataFor( const QString &, bool ) {
- return 0;
-}
-
-bool VPNNetNode::generateDataForCommonFile(
- SystemFile & ,
- long,
- ANetNodeInstance * ) {
- return 1;
-}
-
bool VPNNetNode::generateDeviceDataForCommonFile(
SystemFile & ,
- long ,
- ANetNodeInstance * ) {
+ long ) {
return 1;
}
extern "C" {
void create_plugin( QList<ANetNode> & PNN ) {
PNN.append( new VPNNetNode() );
}
}
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.h b/noncore/settings/networksettings2/vpn/vpn_NN.h
index cdb5117..7ce8e3a 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.h
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.h
@@ -1,46 +1,45 @@
#ifndef VPN_NETNODE_H
#define VPN_NETNODE_H
#include "netnode.h"
class AVPN;
class VPNNetNode : public ANetNode{
Q_OBJECT
public:
VPNNetNode();
virtual ~VPNNetNode();
virtual const QString pixmapName()
{ return "Devices/vpn"; }
virtual const QString nodeName()
{ return tr("VPN Connection"); }
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 DS );
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ virtual bool hasDataFor( const QString & )
+ { return 0; }
virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr, ANetNodeInstance * NNI );
+ SystemFile & SF, long DevNr );
private:
};
extern "C"
{
void create_plugin( QList<ANetNode> & PNN );
};
#endif
diff --git a/noncore/settings/networksettings2/vpn/vpn_NNI.cpp b/noncore/settings/networksettings2/vpn/vpn_NNI.cpp
index 6c20aeb..ee999e8 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NNI.cpp
+++ b/noncore/settings/networksettings2/vpn/vpn_NNI.cpp
@@ -1,30 +1,36 @@
#include "vpnedit.h"
#include "vpn_NNI.h"
#include "vpn_NN.h"
AVPN::AVPN( VPNNetNode * PNN ) : ANetNodeInstance( PNN ) {
GUI = 0;
RT = 0;
}
void AVPN::setSpecificAttribute( QString & , QString & ) {
}
void AVPN::saveSpecificAttribute( QTextStream & ) {
}
QWidget * AVPN::edit( QWidget * parent ) {
GUI = new VPNEdit( parent );
GUI->showData( Data );
return GUI;
}
QString AVPN::acceptable( void ) {
return ( GUI ) ? GUI->acceptable( ) : QString();
}
void AVPN::commit( void ) {
if( GUI && GUI->commit( Data ) )
setModified( 1 );
}
+bool AVPN::generateDataForCommonFile(
+ SystemFile & ,
+ long) {
+ return 1;
+}
+
diff --git a/noncore/settings/networksettings2/vpn/vpn_NNI.h b/noncore/settings/networksettings2/vpn/vpn_NNI.h
index 31ce0d6..c3eb016 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NNI.h
+++ b/noncore/settings/networksettings2/vpn/vpn_NNI.h
@@ -1,43 +1,47 @@
#ifndef VPN_H
#define VPN_H
#include <netnode.h>
#include "vpndata.h"
#include "vpnrun.h"
class VPNNetNode;
class VPNEdit;
class AVPN : public ANetNodeInstance {
public :
AVPN( VPNNetNode * PNN );
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
RuntimeInfo * runtime( void )
{ if( RT == 0 )
RT = new VPNRun( 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 );
protected :
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
private :
VPNEdit * GUI;
VPNData Data;
VPNRun * RT;
};
#endif
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
index e1e20c0..4e59ac1 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp
+++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
@@ -1,67 +1,72 @@
#include "wlan_NN.h"
#include "wlan_NNI.h"
static const char * WLanNeeds[] =
{ 0
};
/**
* Constructor, find all of the possible interfaces
*/
WLanNetNode::WLanNetNode() : ANetNode() {
}
/**
* Delete any interfaces that we own.
*/
WLanNetNode::~WLanNetNode(){
}
const QString WLanNetNode::nodeDescription(){
return tr("\
<p>Configure Wi/Fi or WLan network cards.</p>\
<p>Defines Wireless options for those cards</p>\
"
);
}
ANetNodeInstance * WLanNetNode::createInstance( void ) {
return new AWLan( this );
}
const char ** WLanNetNode::needs( void ) {
return WLanNeeds;
}
const char * WLanNetNode::provides( void ) {
return "device";
}
bool WLanNetNode::generateProperFilesFor(
ANetNodeInstance * ) {
return 1;
}
-bool WLanNetNode::hasDataFor( const QString & S, bool DS ) {
- return DS && S == "interfaces";
-}
-
-bool WLanNetNode::generateDataForCommonFile(
- SystemFile &,
- long ,
- ANetNodeInstance * ) {
- return 1;
+bool WLanNetNode::hasDataFor( const QString & S ) {
+ return S == "interfaces";
}
bool WLanNetNode::generateDeviceDataForCommonFile(
SystemFile & S,
- long DevNr,
- ANetNodeInstance * NNI ) {
- return ((AWLan *)NNI)->generateDeviceDataForCommonFile(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;
+}
+
+QString WLanNetNode::genNic( long nr ) {
+ QString S;
+ return S.sprintf( "wlan%ld", nr );
}
extern "C" {
void create_plugin( QList<ANetNode> & PNN ) {
PNN.append( new WLanNetNode() );
}
}
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.h b/noncore/settings/networksettings2/wlan/wlan_NN.h
index 9111995..f27e71c 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NN.h
+++ b/noncore/settings/networksettings2/wlan/wlan_NN.h
@@ -1,46 +1,50 @@
#ifndef WLAN_NETNODE_H
#define WLAN_NETNODE_H
#include "netnode.h"
class AWLan;
class WLanNetNode : public ANetNode{
Q_OBJECT
public:
WLanNetNode();
virtual ~WLanNetNode();
virtual const QString pixmapName()
{ return "Devices/wlan"; }
virtual const QString nodeName()
{ return tr("WLan Device"); }
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 DS );
- 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 long instanceCount( void )
+ { return 2; }
+
+ virtual QString genNic( long );
private:
};
extern "C"
{
void create_plugin( QList<ANetNode> & PNN );
};
#endif
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
index 8b948e0..78e756c 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
+++ b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
@@ -1,42 +1,36 @@
#include "wlanedit.h"
#include "wlan_NNI.h"
#include "wlan_NN.h"
AWLan::AWLan( WLanNetNode * PNN ) : ANetNodeInstance( PNN ) {
GUI = 0;
RT = 0;
}
void AWLan::setSpecificAttribute( QString & , QString & ) {
}
void AWLan::saveSpecificAttribute( QTextStream & ) {
}
QWidget * AWLan::edit( QWidget * parent ) {
GUI = new WLanEdit( parent );
GUI->showData( Data );
return GUI;
}
QString AWLan::acceptable( void ) {
return ( GUI ) ? GUI->acceptable( ) : QString();
}
void AWLan::commit( void ) {
if( GUI && GUI->commit( Data ) )
setModified( 1 );
}
-bool AWLan::generateDeviceDataForCommonFile( SystemFile & S, long DevNr ) {
- AsDevice * Dev = runtime()->device();
- QString NIC = Dev->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 AWLan::generateDataForCommonFile(
+ SystemFile &,
+ long ) {
+ return 1;
}
+
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.h b/noncore/settings/networksettings2/wlan/wlan_NNI.h
index e464c84..d861d13 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NNI.h
+++ b/noncore/settings/networksettings2/wlan/wlan_NNI.h
@@ -1,45 +1,47 @@
#ifndef WLAN_H
#define WLAN_H
#include <netnode.h>
#include "wlandata.h"
#include "wlanrun.h"
class WLanNetNode;
class WLanEdit;
class AWLan : public ANetNodeInstance {
public :
AWLan( WLanNetNode * PNN );
QWidget * edit( QWidget * parent );
QString acceptable( void );
void commit( void );
RuntimeInfo * runtime( void )
{ if( RT == 0 )
RT = new WLanRun( this, Data );
return RT;
}
virtual void * data( void )
{ return (void *)&Data; }
- bool generateDeviceDataForCommonFile( SystemFile & S, long DevNr );
-
+ virtual bool hasDataFor( const QString & )
+ { return 0; }
+ virtual bool generateDataForCommonFile(
+ SystemFile & SF, long DevNr );
protected :
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
private :
WLanEdit * GUI;
WLanData Data;
WLanRun * RT;
};
#endif
diff --git a/noncore/settings/networksettings2/wlan/wlanrun.h b/noncore/settings/networksettings2/wlan/wlanrun.h
index b853262..f46bcb7 100644
--- a/noncore/settings/networksettings2/wlan/wlanrun.h
+++ b/noncore/settings/networksettings2/wlan/wlanrun.h
@@ -1,44 +1,40 @@
#ifndef WLANRUN_H
#define WLANRUN_H
#include <qregexp.h>
#include <asdevice.h>
#include "wlandata.h"
class WLanRun : public AsDevice {
public :
WLanRun( ANetNodeInstance * NNI, WLanData & Data ) :
AsDevice( NNI ),
Pat( "wlan[0-9]" )
{ }
- virtual long count( void )
- { return 2; }
- virtual QString genNic( long nr )
- { QString S; return S.sprintf( "wlan%ld", nr ); }
virtual AsDevice * device( void )
{ return (AsDevice *)this; }
virtual AsDevice * asDevice( void )
{ return (AsDevice *)this; }
protected :
void detectState( NodeCollection * )
{ }
bool setState( NodeCollection *, Action_t )
{ return 0; }
bool canSetState( State_t, Action_t )
{ return 0; }
bool handlesInterface( const QString & I );
private :
QRegExp Pat;
};
#endif