summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp6
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth_NN.h6
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.h3
-rw-r--r--noncore/settings/networksettings2/editconnection.cpp12
-rw-r--r--noncore/settings/networksettings2/irda/irda_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/irda/irda_NN.h3
-rw-r--r--noncore/settings/networksettings2/lancard/lancardGUI.ui92
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.cpp11
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.h8
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NNI.cpp2
-rw-r--r--noncore/settings/networksettings2/lancard/lancardedit.cpp195
-rw-r--r--noncore/settings/networksettings2/lancard/lancardedit.h12
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.cpp34
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.h6
-rw-r--r--noncore/settings/networksettings2/modem/modem_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/modem/modem_NN.h3
-rw-r--r--noncore/settings/networksettings2/network/networkGUI.ui131
-rw-r--r--noncore/settings/networksettings2/network/network_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/network/network_NN.h3
-rw-r--r--noncore/settings/networksettings2/network/networkedit.cpp66
-rw-r--r--noncore/settings/networksettings2/network/networkedit.h8
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.cpp12
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h13
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp8
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.h2
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.cpp8
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp49
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.h3
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.h3
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.h3
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.h3
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.h3
38 files changed, 554 insertions, 172 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
index 4579e37..1d0a0f7 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
@@ -2,33 +2,34 @@
#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() {
+BluetoothBNEPNetNode::BluetoothBNEPNetNode() :
+ ANetNode(tr("Bluetooth PAN/NAP")) {
InstanceCount = 7; // default
}
/**
* 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>\
"
);
}
@@ -75,33 +76,34 @@ void BluetoothBNEPNetNode::setSpecificAttribute( QString & A, QString & V ) {
void BluetoothBNEPNetNode::saveSpecificAttribute( QTextStream & TS) {
TS << "interfacecount="
<< InstanceCount
<< endl;
}
//
//
// BLUETOOTH RFCOMM
//
//
static const char * BluetoothRFCOMMNeeds[] =
{ 0
};
-BluetoothRFCOMMNetNode::BluetoothRFCOMMNetNode() : ANetNode() {
+BluetoothRFCOMMNetNode::BluetoothRFCOMMNetNode() :
+ ANetNode( tr("Bluetooth serial link") ) {
}
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 );
}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
index 882d2e3..2e5e1d2 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
@@ -4,35 +4,32 @@
#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 );
virtual bool generateDeviceDataForCommonFile(
SystemFile & , long DevNr );
virtual long instanceCount( void )
{ return InstanceCount; }
virtual QString genNic( long );
@@ -45,35 +42,32 @@ private:
long InstanceCount;
};
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 );
virtual bool generateDeviceDataForCommonFile(
SystemFile & , long );
private:
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp
index dd41c1f..e95b4f6 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NN.cpp
@@ -1,27 +1,27 @@
#include "cable_NN.h"
#include "cable_NNI.h"
static const char * CableNeeds[] =
{ 0
};
/**
* Constructor, find all of the possible interfaces
*/
-CableNetNode::CableNetNode() : ANetNode() {
+CableNetNode::CableNetNode() : ANetNode(tr("Cable Connection")) {
}
/**
* Delete any interfaces that we own.
*/
CableNetNode::~CableNetNode(){
}
const QString CableNetNode::nodeDescription(){
return tr("\
<p>Sets up a wired serial or parallel.</p>\
"
);
}
ANetNodeInstance * CableNetNode::createInstance( void ) {
diff --git a/noncore/settings/networksettings2/cable/cable_NN.h b/noncore/settings/networksettings2/cable/cable_NN.h
index b37f31a..c48037a 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.h
+++ b/noncore/settings/networksettings2/cable/cable_NN.h
@@ -4,35 +4,32 @@
#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 & )
{ return 0; }
virtual bool generateDeviceDataForCommonFile(
SystemFile & SF, long DevNr);
private:
virtual void setSpecificAttribute( QString & Attr, QString & Value );
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp
index 4bbe502..77826d1 100644
--- a/noncore/settings/networksettings2/editconnection.cpp
+++ b/noncore/settings/networksettings2/editconnection.cpp
@@ -120,33 +120,33 @@ NodeCollection * EditConnection::getTmpCollection( void ) {
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->nodeClass()->nodeName() != it->text(0) ) {
+ it->text(0) != NNI->nodeClass()->name() ) {
// 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
@@ -183,33 +183,33 @@ void EditConnection::setConnection( NodeCollection * NC ) {
// 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->nodeClass()->nodeName() == it->text(0) ) {
+ if( NNI && it->text(0) == NNI->nodeClass()->name() ) {
// this radio is part of the collection
((QCheckListItem *)it)->setOn( 1 );
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(
@@ -269,68 +269,68 @@ void EditConnection::buildFullTree( void ) {
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(),
+ NN->name(),
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 );
+ NNL[i]->name(), 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() );
+ CI = new MyQListViewItem( it, NNL[i]->name() );
// 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" ) );
@@ -431,33 +431,33 @@ void EditConnection::SLOT_AlterTab( const QString & S ) {
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->nodeClass()->pixmapName() ),
- NNI->nodeClass()->nodeName()
+ NNI->nodeClass()->name()
);
// 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
}
}
diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp
index 49b7707..f2fda5c 100644
--- a/noncore/settings/networksettings2/irda/irda_NN.cpp
+++ b/noncore/settings/networksettings2/irda/irda_NN.cpp
@@ -1,27 +1,27 @@
#include "irda_NN.h"
#include "irda_NNI.h"
static const char * IRDANeeds[] =
{ 0
};
/**
* Constructor, find all of the possible interfaces
*/
-IRDANetNode::IRDANetNode() : ANetNode() {
+IRDANetNode::IRDANetNode() : ANetNode(tr("Infrared link")) {
}
/**
* 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 ) {
diff --git a/noncore/settings/networksettings2/irda/irda_NN.h b/noncore/settings/networksettings2/irda/irda_NN.h
index 2dcef74..fa6408d 100644
--- a/noncore/settings/networksettings2/irda/irda_NN.h
+++ b/noncore/settings/networksettings2/irda/irda_NN.h
@@ -4,35 +4,32 @@
#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 & )
{ return 0; }
virtual bool generateDeviceDataForCommonFile(
SystemFile & SF, long DevNr );
private:
virtual void setSpecificAttribute( QString & Attr, QString & Value );
diff --git a/noncore/settings/networksettings2/lancard/lancardGUI.ui b/noncore/settings/networksettings2/lancard/lancardGUI.ui
index 8d94816..c407175 100644
--- a/noncore/settings/networksettings2/lancard/lancardGUI.ui
+++ b/noncore/settings/networksettings2/lancard/lancardGUI.ui
@@ -1,30 +1,30 @@
<!DOCTYPE UI><UI>
<class>LanCardGUI</class>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Lancard_FRM</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>362</width>
+ <width>354</width>
<height>359</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>LAN card</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
@@ -56,74 +56,134 @@
<cstring>GroupBox1</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
</property>
<property stdset="1">
<name>title</name>
<string>Select Card</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
- <number>11</number>
+ <number>5</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QListView</class>
<column>
<property>
<name>text</name>
- <string>Name</string>
- </property>
- <property>
- <name>clickable</name>
- <bool>true</bool>
- </property>
- <property>
- <name>resizeable</name>
- <bool>true</bool>
- </property>
- </column>
- <column>
- <property>
- <name>text</name>
<string>MACAddress</string>
</property>
<property>
<name>clickable</name>
<bool>true</bool>
</property>
<property>
<name>resizeable</name>
<bool>true</bool>
</property>
</column>
<property stdset="1">
<name>name</name>
<cstring>LanCards_LV</cstring>
</property>
<property stdset="1">
<name>allColumnsShowFocus</name>
<bool>true</bool>
</property>
</widget>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout2</cstring>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>RemoveUnknown_BUT</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Remove Unknown</string>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer1</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>RescanCards_BUT</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Rescan</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
</vbox>
</widget>
</vbox>
</widget>
<connections>
<connection>
<sender>AnyCard_CB</sender>
<signal>toggled(bool)</signal>
<receiver>GroupBox1</receiver>
<slot>setDisabled(bool)</slot>
</connection>
+ <connection>
+ <sender>RescanCards_BUT</sender>
+ <signal>clicked()</signal>
+ <receiver>Lancard_FRM</receiver>
+ <slot>SLOT_ScanCards()</slot>
+ </connection>
+ <connection>
+ <sender>RemoveUnknown_BUT</sender>
+ <signal>clicked()</signal>
+ <receiver>Lancard_FRM</receiver>
+ <slot>SLOT_RemoveUnknown()</slot>
+ </connection>
+ <slot access="public">SLOT_ScanCards()</slot>
+ <slot access="public">SLOT_RemoveUnknown()</slot>
</connections>
</UI>
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
index ba1c1f8..a4afab1 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
@@ -1,26 +1,26 @@
#include "lancard_NN.h"
#include "lancard_NNI.h"
static const char * LanCardNeeds[] =
{ 0 };
/**
* Constructor, find all of the possible interfaces
*/
-LanCardNetNode::LanCardNetNode() : ANetNode() {
+LanCardNetNode::LanCardNetNode() : ANetNode(tr("LAN card")), NICMACAddresses() {
InstanceCount = 2;
}
/**
* 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>\
"
);
}
@@ -56,30 +56,39 @@ bool LanCardNetNode::generateDeviceDataForCommonFile(
// 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 );
}
void LanCardNetNode::setSpecificAttribute( QString & A, QString & V ) {
if( A == "interfacecount" ) {
InstanceCount = V.toLong();
+ } else if ( A == "macaddress" ) {
+ NICMACAddresses.append( V );
}
}
void LanCardNetNode::saveSpecificAttribute( QTextStream & TS) {
TS << "interfacecount="
<< InstanceCount
<< endl;
+ for( QStringList::Iterator it = NICMACAddresses.begin();
+ it != NICMACAddresses.end();
+ ++it ) {
+ TS << "macaddress="
+ << (*it)
+ << endl;
+ }
}
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 5f2b25d..d58823c 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.h
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.h
@@ -1,55 +1,57 @@
#ifndef LANCARD_NETNODE_H
#define LANCARD_NETNODE_H
+#include <qstringlist.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 );
virtual bool generateDeviceDataForCommonFile(
SystemFile & SF, long DevNr );
virtual long instanceCount( void )
{ return InstanceCount; }
virtual QString genNic( long );
+ virtual QStringList & addressesOfNIC( void )
+ { return NICMACAddresses; }
private:
virtual void setSpecificAttribute( QString & Attr, QString & Value );
virtual void saveSpecificAttribute( QTextStream & TS );
// number of interfaces for this device
long InstanceCount;
+ QStringList NICMACAddresses;
+
};
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 5962d52..99c033e 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
@@ -17,33 +17,33 @@ void ALanCard::setSpecificAttribute( QString & A, QString & V ) {
} 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 );
+ GUI->showData( this );
return GUI;
}
QString ALanCard::acceptable( void ) {
return ( GUI ) ? GUI->acceptable( ) : QString();
}
void ALanCard::commit( void ) {
if( GUI && GUI->commit( Data ) )
setModified( 1 );
}
bool ALanCard::generateDataForCommonFile(
SystemFile & ,
long ) {
return 1;
diff --git a/noncore/settings/networksettings2/lancard/lancardedit.cpp b/noncore/settings/networksettings2/lancard/lancardedit.cpp
index fa7f6dc..ffe9bf6 100644
--- a/noncore/settings/networksettings2/lancard/lancardedit.cpp
+++ b/noncore/settings/networksettings2/lancard/lancardedit.cpp
@@ -1,95 +1,208 @@
#include <GUIUtils.h>
#include <resources.h>
+#include <qarray.h>
#include <qlistview.h>
#include <qcheckbox.h>
#include <qheader.h>
#include <qregexp.h>
+
#include "lancardedit.h"
+#include "lancard_NN.h"
+#include "lancard_NNI.h"
LanCardEdit::LanCardEdit( QWidget * Parent ) : LanCardGUI( Parent ){
- System & S = NSResources->system();
- QRegExp R( "eth[0-9]" );
- QCheckListItem * CLI;
-
LanCards_LV->header()->hide();
- // populate with all lancards in system
- for( QDictIterator<InterfaceInfo> It(S.interfaces());
- It.current();
- ++It ) {
- if( R.match( It.current()->Name ) >= 0 &&
- It.current()->CardType == ARPHRD_ETHER
- ) {
- CLI = new QCheckListItem( LanCards_LV, It.current()->Name,
- QCheckListItem::CheckBox );
- CLI->setText( 1, It.current()->MACAddress );
- }
- }
}
QString LanCardEdit::acceptable( void ) {
return QString();
}
-
bool LanCardEdit::commit( LanCardData & Data ) {
bool SM = 0;
CBM( Data.AnyLanCard, AnyCard_CB, SM );
if( ! Data.AnyLanCard ) {
- // collect set of lancards that match
+ // take copy for orig list
+ QStringList NewList( Data.HWAddresses );
+
+ // update HWAddresses to new state
+ // remove item also from NewList
int idx;
QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild();
while( CLI ) {
- idx = Data.HWAddresses.findIndex(CLI->text(1));
+ idx = Data.HWAddresses.findIndex(CLI->text(0));
if( CLI->isOn() ) {
if( idx < 0 ) {
// should be in list
- Data.HWAddresses.append( CLI->text(1) );
+ Data.HWAddresses.append( CLI->text(0) );
SM = 1;
}
} else {
// should not be in list
if( idx >= 0 ) {
- Data.HWAddresses.remove( Data.HWAddresses.at(idx) );
+ NewList.remove( CLI->text(0) );
+ Data.HWAddresses.remove( CLI->text(0) );
SM = 1;
}
}
CLI = (QCheckListItem *)CLI->nextSibling();
}
+
+ // if newlist still contains items. it were items
+ // that were checked but no longer are present in the system
+ SM |= ( NewList.count() > 0 ) ;
}
- return SM || ContainedObsoleteMAC ;
+ return SM;
}
-void LanCardEdit::showData( LanCardData & Data ) {
+void LanCardEdit::showData( ALanCard * LC ) {
+ NNI = LC;
+ LanCardData & Data = *((LanCardData *)LC->data());
+
AnyCard_CB->setChecked( Data.AnyLanCard );
+ // load all cards
+ populateList();
+
+ // set checks
QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild();
+ while( CLI ) {
+ CLI->setOn( Data.HWAddresses.findIndex(CLI->text(0)) >= 0 );
+ CLI = (QCheckListItem *)CLI->nextSibling();
+ }
+}
- ContainedObsoleteMAC = 0;
- // remove obsolete address
- for( QStringList::Iterator it=Data.HWAddresses.begin();
- it != Data.HWAddresses.end();
- ) {
- CLI = (QCheckListItem *)LanCards_LV->firstChild();
- while( CLI ) {
- if( CLI->text(1) == (*it) )
- // still valid
+// load all known cards in list
+void LanCardEdit::populateList( void ) {
+ LanCardNetNode *NN = (LanCardNetNode *)NNI->nodeClass();
+ QCheckListItem * CLI;
+ bool Found;
+
+ LanCards_LV->clear();
+
+ for( QStringList::Iterator it = NN->addressesOfNIC().begin();
+ it != NN->addressesOfNIC().end();
+ ++it ) {
+ CLI = new QCheckListItem( LanCards_LV, (*it), QCheckListItem::CheckBox );
+
+ // check interfaces and see if this card is present
+ Found = 0;
+ for( QDictIterator<InterfaceInfo> NIt(NSResources->system().interfaces());
+ NIt.current();
+ ++NIt ) {
+ if( NIt.current()->MACAddress == (*it) ) {
+ Found = 1;
break;
- CLI = (QCheckListItem *)CLI->nextSibling();
+ }
}
- if( CLI == 0 ) {
- // address not found -> remove
- ContainedObsoleteMAC = 1;
- Data.HWAddresses.remove( it );
- } else {
- ++ it;
+
+ CLI->setPixmap( 0, NSResources->getPixmap(
+ (Found) ? "add" : "remove" ) );
+ }
+}
+
+// rescan system for new cards
+void LanCardEdit::SLOT_ScanCards( void ) {
+ LanCardNetNode *NN = (LanCardNetNode *)NNI->nodeClass();
+
+ // add any NIC that is new and matches our interfacename
+ System & S = NSResources->system();
+ QRegExp R( "eth[0-9]" );
+ // populate with all lancards in system
+ for( QDictIterator<InterfaceInfo> It(S.interfaces());
+ It.current();
+ ++It ) {
+ fprintf( stderr, "TEST %s %s\n",
+ It.current()->Name.latin1(),
+ It.current()->MACAddress.latin1() );
+ if( R.match( It.current()->Name ) >= 0 &&
+ ( It.current()->CardType == ARPHRD_ETHER
+#ifdef ARPHRD_IEEE1394
+ || It.current()->CardType == ARPHRD_IEEE1394
+#endif
+ )
+ ) {
+ // old item ?
+ QCheckListItem * CLI =
+ (QCheckListItem *)LanCards_LV->firstChild();
+ while( CLI ) {
+ if( CLI->text(0) == It.current()->MACAddress ) {
+ break;
+ }
+ CLI = (QCheckListItem *)CLI->nextSibling();
+ }
+
+ if( ! CLI ) {
+ // new item
+ CLI = new QCheckListItem( LanCards_LV,
+ It.current()->MACAddress,
+ QCheckListItem::CheckBox );
+ }
+
+ // mark present
+ CLI->setPixmap( 0, NSResources->getPixmap(
+ "add" ) );
+
+ if( NN->addressesOfNIC().findIndex( It.current()->MACAddress) < 0 ) {
+ // new
+ NN->addressesOfNIC().append( It.current()->MACAddress );
+ }
}
}
- // set checks
+}
+
+// remove all cards that are not present -> flagged with 'remove'
+// and unchecked
+void LanCardEdit::SLOT_RemoveUnknown( void ) {
+ QArray<QCheckListItem *> AllItems;
+
+ LanCardNetNode *NN = (LanCardNetNode *)NNI->nodeClass();
+
+ QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild();
while( CLI ) {
- CLI->setOn( Data.HWAddresses.findIndex(CLI->text(1)) >= 0 );
+ AllItems.resize( AllItems.size()+1 );
+ AllItems[ AllItems.size()-1 ] = CLI;
CLI = (QCheckListItem *)CLI->nextSibling();
}
+
+ // force update of system
+ System & S = NSResources->system();
+ S.probeInterfaces();
+
+ // add any NIC that is new and matches our interfacename
+ QRegExp R( "eth[0-9]" );
+
+
+ for( QDictIterator<InterfaceInfo> It(S.interfaces());
+ It.current();
+ ++It ) {
+ if( R.match( It.current()->Name ) >= 0 &&
+ ( It.current()->CardType == ARPHRD_ETHER
+#ifdef ARPHRD_IEEE1394
+ || It.current()->CardType == ARPHRD_IEEE1394
+#endif
+ )
+ ) {
+
+ for ( unsigned i = 0; i< AllItems.size(); i++ ) {
+ if( AllItems[i] &&
+ AllItems[i]->text(0) == It.current()->MACAddress ) {
+ AllItems[i] = 0;
+ break;
+ }
+ }
+ }
+ }
+
+ // AllItems now contains all cards NOT present
+ // remove all items non null and not ON
+ for ( unsigned i = 0; i< AllItems.size(); i++ ) {
+ if( AllItems[i] && ! AllItems[i]->isOn() ) {
+ NN->addressesOfNIC().remove( AllItems[i]->text(0) );
+ delete AllItems[i];
+ }
+ }
}
diff --git a/noncore/settings/networksettings2/lancard/lancardedit.h b/noncore/settings/networksettings2/lancard/lancardedit.h
index 8def789..282db1f 100644
--- a/noncore/settings/networksettings2/lancard/lancardedit.h
+++ b/noncore/settings/networksettings2/lancard/lancardedit.h
@@ -1,16 +1,24 @@
#include "lancarddata.h"
#include "lancardGUI.h"
+class ALanCard;
+
class LanCardEdit : public LanCardGUI {
public :
LanCardEdit( QWidget * parent );
QString acceptable( void );
bool commit( LanCardData & Data );
- void showData( LanCardData & Data );
+ void showData( ALanCard * NNI );
+
+public slots :
+
+ void SLOT_ScanCards( void );
+ void SLOT_RemoveUnknown( void );
private :
- bool ContainedObsoleteMAC;
+ void populateList( void );
+ ALanCard * NNI;
};
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.cpp b/noncore/settings/networksettings2/lancard/lancardrun.cpp
index 951756d..2e4fc43 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.cpp
+++ b/noncore/settings/networksettings2/lancard/lancardrun.cpp
@@ -1,18 +1,19 @@
#include <qfile.h>
#include <qtextstream.h>
+#include <qstringlist.h>
#include <resources.h>
#include "lancardrun.h"
void LanCardRun::detectState( NodeCollection * NC ) {
// unavailable : no card found
// available : card found and assigned to us or free
// up : card found and assigned to us and up
QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
System & Sys = NSResources->system();
InterfaceInfo * Run;
QFile F( S );
if( F.open( IO_ReadOnly ) ) {
@@ -40,34 +41,38 @@ void LanCardRun::detectState( NodeCollection * NC ) {
// we already have an interface assigned -> still present ?
if( ! Run->IsUp ) {
// usb is still free -> keep assignment
NC->setCurrentState( Available );
return;
} // else interface is up but NOT us -> some other profile
}
// nothing (valid) assigned to us
assignInterface( 0 );
// find possible interface
for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
It.current();
++It ) {
Run = It.current();
- if( handlesInterface( Run->Name ) &&
- Run->CardType == ARPHRD_ETHER &&
+ if( handlesInterface( *Run ) &&
+ ( Run->CardType == ARPHRD_ETHER
+#ifdef ARPHRD_IEEE1394
+ || Run->CardType == ARPHRD_IEEE1394
+#endif
+ ) &&
! Run->IsUp
) {
// proper type, and Not UP -> free
NC->setCurrentState( Off );
return;
}
}
// no free found
NC->setCurrentState( Unavailable );
}
bool LanCardRun::setState( NodeCollection * NC, Action_t A ) {
// we only handle activate and deactivate
@@ -132,35 +137,56 @@ bool LanCardRun::canSetState( State_t Curr, Action_t A ) {
// FT
break;
}
return 0;
}
// get interface that is free or assigned to us
InterfaceInfo * LanCardRun::getInterface( void ) {
System & S = NSResources->system();
InterfaceInfo * best = 0, * Run;
for( QDictIterator<InterfaceInfo> It(S.interfaces());
It.current();
++It ) {
Run = It.current();
- if( handlesInterface( Run->Name ) &&
- Run->CardType == ARPHRD_ETHER
+ if( handlesInterface( *Run ) &&
+ ( Run->CardType == ARPHRD_ETHER
+#ifdef ARPHRD_IEEE1394
+ || Run->CardType == ARPHRD_IEEE1394
+#endif
+ )
) {
// this is a LAN card
if( Run->assignedNode() == netNode() ) {
// assigned to us
return Run;
} else if( Run->assignedNode() == 0 ) {
// free
best = Run;
}
}
}
return best; // can be 0
}
bool LanCardRun::handlesInterface( const QString & S ) {
+ InterfaceInfo * II;
+ II = NSResources->system().interface( S );
+ if( ( II = NSResources->system().interface( S ) ) ) {
+ return handlesInterface( *II );
+ }
return Pat.match( S ) >= 0;
}
+
+bool LanCardRun::handlesInterface( const InterfaceInfo & II ) {
+ if( Pat.match( II.Name ) < 0 )
+ return 0;
+
+ if( Data->AnyLanCard ) {
+ return 1;
+ }
+
+ // must also match hardware address
+ return ( Data->HWAddresses.findIndex( II.MACAddress ) >= 0 );
+}
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.h b/noncore/settings/networksettings2/lancard/lancardrun.h
index 499b417..e8a535a 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.h
+++ b/noncore/settings/networksettings2/lancard/lancardrun.h
@@ -1,37 +1,39 @@
#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 ),
+ LanCardData & D ) : AsDevice( NNI ),
Pat( "eth[0-9]" )
- { }
+ { Data = &D; }
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 );
+ bool handlesInterface( const InterfaceInfo & II );
private :
InterfaceInfo * getInterface( void );
QRegExp Pat;
+ LanCardData * Data;
};
#endif
diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp
index 1cc8524..9d70d7a 100644
--- a/noncore/settings/networksettings2/modem/modem_NN.cpp
+++ b/noncore/settings/networksettings2/modem/modem_NN.cpp
@@ -1,27 +1,27 @@
#include "modem_NN.h"
#include "modem_NNI.h"
static const char * ModemNeeds[] =
{ "line"
};
/**
* Constructor, find all of the possible interfaces
*/
-ModemNetNode::ModemNetNode() : ANetNode() {
+ModemNetNode::ModemNetNode() : ANetNode(tr("Dialup modem")) {
}
/**
* 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>\
"
);
}
diff --git a/noncore/settings/networksettings2/modem/modem_NN.h b/noncore/settings/networksettings2/modem/modem_NN.h
index 849f928..2f496dd 100644
--- a/noncore/settings/networksettings2/modem/modem_NN.h
+++ b/noncore/settings/networksettings2/modem/modem_NN.h
@@ -4,35 +4,32 @@
#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 & )
{ return 0; }
virtual bool generateDeviceDataForCommonFile(
SystemFile & SF, long DevNr );
private:
virtual void setSpecificAttribute( QString & Attr, QString & Value );
diff --git a/noncore/settings/networksettings2/network/networkGUI.ui b/noncore/settings/networksettings2/network/networkGUI.ui
index 9115ec0..5f71f82 100644
--- a/noncore/settings/networksettings2/network/networkGUI.ui
+++ b/noncore/settings/networksettings2/network/networkGUI.ui
@@ -1,57 +1,57 @@
<!DOCTYPE UI><UI>
<class>NetworkGUI</class>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>NetworkGUI</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>293</width>
+ <width>289</width>
<height>254</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Interface Configuration</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>0</number>
</property>
<widget>
<class>QTabWidget</class>
<property stdset="1">
<name>name</name>
- <cstring>TabWidget11</cstring>
+ <cstring>MainTab_TAB</cstring>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>Setup</string>
@@ -470,33 +470,33 @@
</property>
<property stdset="1">
<name>spacing</name>
<number>2</number>
</property>
<widget>
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>Command_LE</cstring>
</property>
</widget>
<widget>
<class>QTabWidget</class>
<property stdset="1">
<name>name</name>
- <cstring>Tab_TB</cstring>
+ <cstring>Tab_TAB</cstring>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>Pre-Up</string>
@@ -1045,27 +1045,152 @@
<signal>toggled(bool)</signal>
<receiver>Frame27</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>DHCP_CB</sender>
<signal>toggled(bool)</signal>
<receiver>TextLabel2_2</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>SendHostname_CB</sender>
<signal>toggled(bool)</signal>
<receiver>Hostname_LE</receiver>
<slot>setEnabled(bool)</slot>
</connection>
+ <connection>
+ <sender>AddPreUp_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Add()</slot>
+ </connection>
+ <connection>
+ <sender>DeletePreUp_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Remove()</slot>
+ </connection>
+ <connection>
+ <sender>UpPreUp_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Up()</slot>
+ </connection>
+ <connection>
+ <sender>DownPreUp_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Down()</slot>
+ </connection>
+ <connection>
+ <sender>AddPostUp_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Add()</slot>
+ </connection>
+ <connection>
+ <sender>DeletePostUp_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Remove()</slot>
+ </connection>
+ <connection>
+ <sender>UpPostUp_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Up()</slot>
+ </connection>
+ <connection>
+ <sender>DownPostUp_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Down()</slot>
+ </connection>
+ <connection>
+ <sender>AddPreDown_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Add()</slot>
+ </connection>
+ <connection>
+ <sender>DeletePreDown_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Remove()</slot>
+ </connection>
+ <connection>
+ <sender>UpPreDown_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Up()</slot>
+ </connection>
+ <connection>
+ <sender>DownPreDown_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Down()</slot>
+ </connection>
+ <connection>
+ <sender>AddPostDown_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Add()</slot>
+ </connection>
+ <connection>
+ <sender>DeletePostDown_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Remove()</slot>
+ </connection>
+ <connection>
+ <sender>UpPostDown_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Up()</slot>
+ </connection>
+ <connection>
+ <sender>DownPostDown_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_Down()</slot>
+ </connection>
+ <connection>
+ <sender>PreUp_LB</sender>
+ <signal>doubleClicked(QListBoxItem*)</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_ShowCommand( QListBoxItem *)</slot>
+ </connection>
+ <connection>
+ <sender>PreDown_LB</sender>
+ <signal>doubleClicked(QListBoxItem*)</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_ShowCommand( QListBoxItem *)</slot>
+ </connection>
+ <connection>
+ <sender>PostDown_LB</sender>
+ <signal>doubleClicked(QListBoxItem*)</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_ShowCommand( QListBoxItem *)</slot>
+ </connection>
+ <connection>
+ <sender>PostUp_LB</sender>
+ <signal>doubleClicked(QListBoxItem*)</signal>
+ <receiver>NetworkGUI</receiver>
+ <slot>SLOT_ShowCommand( QListBoxItem *)</slot>
+ </connection>
+ <slot access="public">SLOT_Add()</slot>
+ <slot access="public">SLOT_Down()</slot>
<slot access="public">SLOT_NetmaskModified( const QString &amp; )</slot>
+ <slot access="public">SLOT_Remove()</slot>
+ <slot access="public">SLOT_Up()</slot>
+ <slot access="public">SLOT_ShowCommand( QListBoxItem *)</slot>
</connections>
<tabstops>
<tabstop>DHCP_CB</tabstop>
<tabstop>IPAddress_LE</tabstop>
<tabstop>SubnetMask_LE</tabstop>
<tabstop>Gateway_LE</tabstop>
<tabstop>DNS1_LE</tabstop>
<tabstop>DNS2_LE</tabstop>
</tabstops>
</UI>
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp
index d27d54a..b5989df 100644
--- a/noncore/settings/networksettings2/network/network_NN.cpp
+++ b/noncore/settings/networksettings2/network/network_NN.cpp
@@ -1,28 +1,28 @@
#include "network_NN.h"
#include "network_NNI.h"
static const char * NetworkNeeds[] =
{ "device",
0
};
/**
* Constructor, find all of the possible interfaces
*/
-NetworkNetNode::NetworkNetNode() : ANetNode() {
+NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) {
}
/**
* 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>\
"
);
}
diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h
index 0f87e1b..6548c32 100644
--- a/noncore/settings/networksettings2/network/network_NN.h
+++ b/noncore/settings/networksettings2/network/network_NN.h
@@ -4,35 +4,32 @@
#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 & )
{ return 0; }
virtual bool generateDeviceDataForCommonFile(
SystemFile & SF, long DevNr );
private:
virtual void setSpecificAttribute( QString & Attr, QString & Value );
diff --git a/noncore/settings/networksettings2/network/networkedit.cpp b/noncore/settings/networksettings2/network/networkedit.cpp
index 182213b..05110d9 100644
--- a/noncore/settings/networksettings2/network/networkedit.cpp
+++ b/noncore/settings/networksettings2/network/networkedit.cpp
@@ -1,18 +1,19 @@
#include <qtoolbutton.h>
#include <qcheckbox.h>
+#include <qtabwidget.h>
#include <qlineedit.h>
#include <qlistbox.h>
#include <GUIUtils.h>
#include <resources.h>
#include "networkedit.h"
NetworkEdit::NetworkEdit( QWidget * Parent ) : NetworkGUI( Parent ){
AddPreDown_TB->setPixmap( NSResources->getPixmap( "add" ) );
AddPreUp_TB->setPixmap( NSResources->getPixmap( "add" ) );
AddPostDown_TB->setPixmap( NSResources->getPixmap( "add" ) );
AddPostUp_TB->setPixmap( NSResources->getPixmap( "add" ) );
DeletePreDown_TB->setPixmap( NSResources->getPixmap( "remove" ) );
DeletePreUp_TB->setPixmap( NSResources->getPixmap( "remove" ) );
DeletePostDown_TB->setPixmap( NSResources->getPixmap( "remove" ) );
@@ -97,33 +98,39 @@ void NetworkEdit::showData( NetworkData_t & Data ) {
populateList( Data.PreUp_SL, PreUp_LB );
populateList( Data.PostUp_SL, PostUp_LB );
populateList( Data.PreDown_SL, PreDown_LB );
populateList( Data.PostDown_SL, PostDown_LB );
}
bool NetworkEdit::updateList( QStringList & SL, QListBox * LB ) {
bool Changed;
QStringList NewSL;
// collect new list
for( unsigned int i = 0; i < LB->count() ; i ++ ) {
NewSL.append( LB->text(i) );
}
- // check if at least ONE item in new list is NEW
+ if( NewSL.count() != SL.count() ) {
+ // less or more items
+ SL= NewSL;
+ return 1;
+ }
+
+ // Same size -> same content ?
Changed = 0;
for ( QStringList::Iterator it = NewSL.begin();
it != NewSL.end();
++it ) {
if( SL.findIndex( (*it) ) < 0 ) {
// new or modified item
Changed = 1;
SL = NewSL;
break;
}
}
return Changed;
}
void NetworkEdit::populateList( QStringList & SL, QListBox * LB ) {
LB->clear();
@@ -145,16 +152,73 @@ void NetworkEdit::SLOT_NetmaskModified( const QString & ) {
return;
// if all ones
// broadcast = (IPAddress | ~netmask )
{ QString NW;
QStringList ipal = QStringList::split( '.', IP );
QStringList nmal = QStringList::split( '.', SN );
NW = QString( "%1.%2.%3.%4" ).
arg( ipal[0].toShort() | ( ~ nmal[0].toShort() & 0x00ff) ).
arg( ipal[1].toShort() | ( ~ nmal[1].toShort() & 0x00ff) ).
arg( ipal[2].toShort() | ( ~ nmal[2].toShort() & 0x00ff) ).
arg( ipal[3].toShort() | ( ~ nmal[3].toShort() & 0x00ff) );
Broadcast_LE->setText( NW );
}
}
+
+QListBox * NetworkEdit::getActiveLB( void ) {
+ switch( Tab_TAB->currentPageIndex() ) {
+ case 0 :
+ return PreUp_LB;
+ case 1 :
+ return PostUp_LB;
+ case 2 :
+ return PreDown_LB;
+ }
+ return PostDown_LB;
+}
+
+void NetworkEdit::SLOT_Add( void ) {
+ if( Command_LE->text().isEmpty() )
+ return;
+ QListBox * LB = getActiveLB();
+
+ LB->insertItem( Command_LE->text() );
+}
+
+void NetworkEdit::SLOT_Remove( void ) {
+ QListBox * LB = getActiveLB();
+ int i;
+
+ if( ( i = LB->currentItem() ) >= 0 ) {
+ LB->removeItem( i );
+ }
+}
+
+void NetworkEdit::SLOT_Up( void ) {
+ QListBox * LB = getActiveLB();
+ int i;
+
+ if( ( i = LB->currentItem() ) > 0 ) {
+ QListBoxItem * LBI = LB->item(i);
+ LB->takeItem( LBI );
+ LB->insertItem( LBI, --i );
+ LB->setCurrentItem( i );
+ }
+}
+
+void NetworkEdit::SLOT_Down( void ) {
+ QListBox * LB = getActiveLB();
+ int i;
+
+ if( ( i = LB->currentItem() ) >= 0 && (unsigned)(i+1) != LB->count() ) {
+ QListBoxItem * LBI = LB->item(i);
+ LB->takeItem( LBI );
+ LB->insertItem( LBI, ++i );
+ LB->setCurrentItem( i );
+ }
+}
+
+void NetworkEdit::SLOT_ShowCommand( QListBoxItem * It ) {
+ Command_LE->setText( It->text() );
+}
diff --git a/noncore/settings/networksettings2/network/networkedit.h b/noncore/settings/networksettings2/network/networkedit.h
index 9ed4e84..adc20e0 100644
--- a/noncore/settings/networksettings2/network/networkedit.h
+++ b/noncore/settings/networksettings2/network/networkedit.h
@@ -1,21 +1,29 @@
#include "networkdata.h"
#include "networkGUI.h"
+class QListBox;
+
class NetworkEdit : public NetworkGUI {
public :
NetworkEdit( QWidget * parent );
QString acceptable( void );
bool commit( NetworkData_t & Data );
void showData( NetworkData_t & Data );
public slots :
void SLOT_NetmaskModified( const QString & S );
+ void SLOT_ShowCommand( QListBoxItem * LBI );
+ void SLOT_Add( void );
+ void SLOT_Remove( void );
+ void SLOT_Up( void );
+ void SLOT_Down( void );
private :
+ QListBox * getActiveLB( void );
bool updateList( QStringList &SL, QListBox * LB );
void populateList( QStringList &SL, QListBox * LB );
};
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp
index 3691e5a..417fba8 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.cpp
+++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp
@@ -61,46 +61,46 @@ void ANetNode::setAttribute( QString & Attr, QString & Value ){
}
//
//
// ANETNODEINSTANCE
//
//
long ANetNodeInstance::InstanceCounter = -1;
void ANetNodeInstance::initialize( void ) {
if( InstanceCounter == -1 )
InstanceCounter = time(0);
// set name
QString N;
N.sprintf( "-%ld", InstanceCounter++ );
- N.prepend( NodeType->nodeName() );
- setNodeName( N );
+ N.prepend( NodeType->name() );
+ setName( N.latin1() );
}
void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){
if( Attr == "name" ) {
- NodeName = Value;
+ setName( Value.latin1() );
} else {
setSpecificAttribute( Attr, Value );
}
}
void ANetNodeInstance::saveAttributes( QTextStream & TS ) {
- TS << "name=" << quote( NodeName ) << endl;
+ TS << "name=" << name() << endl;
saveSpecificAttribute( TS );
}
ANetNodeInstance * ANetNodeInstance::nextNode( void ) {
return connection()->findNext( this );
}
//
//
// NODECOLLECTION
//
//
long NodeCollection::MaxNr = -1;
NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() {
@@ -167,33 +167,33 @@ const QString & NodeCollection::description( void ) {
}
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 << "node=" << NNI->name() << 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->nodeClass()->isToplevel() )
break;
}
return NNI;
}
@@ -220,33 +220,33 @@ ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) {
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() );
+ return strcmp( NNI1->name(), NNI2->name() );
}
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" );
}
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index 6ec9ef6..27d54f8 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -59,41 +59,38 @@ typedef enum Action {
// 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(){};
+ ANetNode( const char * Name ) : QObject( 0, Name ) {}
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 ) = 0;
// generate data specific for the device for the system file S
@@ -171,37 +168,32 @@ public:
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(); }
@@ -212,63 +204,64 @@ public:
// 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
virtual AsDevice * asDevice( void )
{ return 0; }
virtual AsConnection * asConnection( void )
{ return 0; }
virtual AsLine * asLine( void )
{ return 0; }
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 bool handlesInterface( const InterfaceInfo & )
+ { 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 );
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp
index e6ce2b7..4b7a62f 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.cpp
+++ b/noncore/settings/networksettings2/networksettings2/resources.cpp
@@ -154,81 +154,81 @@ bool TheNSResources::loadNetNode(
return 0;
}
ANetNode * NNP;
for( QListIterator<ANetNode> it(PNN);
it.current();
++it ) {
NetNode_t * NN;
NNP = it.current();
NN = new NetNode_t;
NN->NetNode = NNP;
NN->TheLibrary = lib;
NN->NodeCountInLib = PNN.count();
// store mapping
- AllNodeTypes.insert( NN->NetNode->nodeName(), NN );
+ printf( "Store %s\n", NN->NetNode->name() );
+ AllNodeTypes.insert( NN->NetNode->name(), NN );
}
return 1;
}
QPixmap TheNSResources::getPixmap( const QString & QS ) {
QString S("networksettings2/");
S += QS;
- printf( " pixmap %s\n", S.latin1() );
return Resource::loadPixmap( QString("networksettings2/")+QS );
}
QString TheNSResources::tr( const char * s ) {
return qApp->translate( "resource", s );
}
const QString & TheNSResources::netNode2Name( const char * s ) {
return NodeTypeNameMap[s];
}
const QString & TheNSResources::netNode2Description( const char * s ) {
return NodeTypeDescriptionMap[s];
}
void TheNSResources::addConnection( NodeCollection * NC ) {
ANetNodeInstance * NNI;
ConnectionsMap.insert( NC->name(), NC );
// add (new) nodes to NodeList
for( QListIterator<ANetNodeInstance> it(*NC);
it.current();
++it ) {
NNI = it.current();
- if( findNodeInstance( NNI->nodeName() ) == 0 ) {
+ if( findNodeInstance( NNI->name() ) == 0 ) {
// new item
addNodeInstance( NNI );
}
}
}
void TheNSResources::removeConnection( const QString & N ) {
NodeCollection * NC = findConnection( N );
if( ! NC )
return;
// delete netnodes in this connection
ANetNodeInstance * NNI;
for( NNI = NC->first(); NNI != 0; NNI = NC->next() ) {
- removeNodeInstance( NNI->nodeName() );
+ removeNodeInstance( NNI->name() );
}
ConnectionsMap.remove( N );
}
NodeCollection * TheNSResources::findConnection( const QString & S ) {
return ConnectionsMap[ S ];
}
void TheNSResources::renumberConnections( void ) {
Name2Connection_t & M = NSResources->connections();
NodeCollection * NC;
// for all connections
NodeCollection::resetMaxNr();
for( QDictIterator<NodeCollection> it(M);
it.current();
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h
index 7050f10..3d6a44f 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.h
+++ b/noncore/settings/networksettings2/networksettings2/resources.h
@@ -66,33 +66,33 @@ public :
{ SystemFiles.insert( SF->name(), SF ); }
ANetNodeInstance * createNodeInstance( const QString & S )
{ ANetNodeInstance * NNI = 0;
NetNode_t * NNT = AllNodeTypes[S];
if( ! NNT ) {
return 0;
}
NNI = NNT->NetNode->createInstance();
NNI->initialize();
return NNI;
}
Name2Instance_t & netNodeInstances( void )
{ return AllNodes; }
void addNodeInstance( ANetNodeInstance * I )
- { AllNodes.insert( I->nodeName(), I ); }
+ { AllNodes.insert( I->name(), I ); }
void removeNodeInstance( const QString & N )
{ AllNodes.remove( N );}
ANetNodeInstance * findNodeInstance( const QString & S )
{ return (AllNodes.find(S)!=0) ? AllNodes[S] : 0; }
const QString & netNode2Name( const char * Type );
const QString & netNode2Description( const char * Type );
void renumberConnections( void );
void addConnection( NodeCollection * NC );
void removeConnection( const QString & N );
NodeCollection * findConnection( const QString & N );
Name2Connection_t & connections( void )
{ return ConnectionsMap; }
CurrentQPEUser & currentUser( void )
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
index 62bb6af..b3fc1a5 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
@@ -111,75 +111,75 @@ bool SystemFile::postSection( void ) {
// 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->nodeClass()->nodeName());
+ arg(NNI->nodeClass()->name());
(*this) << Out << endl;
S = TX.readLine();
}
}
return 0;
}
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());
+ arg(NNI->name());
(*this) << Out << endl;
S = TX.readLine();
}
}
return 0;
}
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(NN->nodeName());
+ Out = S.arg(NN->name());
(*this) << Out << endl;
S = TX.readLine();
}
}
return 0;
}
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(NN->nodeName());
+ Out = S.arg(NN->name());
(*this) << Out << endl;
S = TX.readLine();
}
}
return 0;
}
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index 13979ce..64b83f7 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -2,33 +2,33 @@
#include <qpe/qpeapplication.h>
#include <qtextstream.h>
#include <qdir.h>
#include <qfile.h>
#include <qfileinfo.h>
#include "nsdata.h"
#include <asdevice.h>
#include <resources.h>
static QString CfgFile;
NetworkSettingsData::NetworkSettingsData( void ) {
// init global resources structure
new TheNSResources();
- CfgFile.sprintf( "%s/NETCONFIG",
+ CfgFile.sprintf( "%s/Settings/NS2.conf",
NSResources->currentUser().HomeDir.latin1() );
fprintf( stderr, "Cfg from %s\n", CfgFile.latin1() );
// load settings
Force = 0;
IsModified = 0;
loadSettings();
}
// saving is done by caller
NetworkSettingsData::~NetworkSettingsData( void ) {
delete NSResources;
}
void NetworkSettingsData::loadSettings( void ) {
QString Line, S;
@@ -62,80 +62,87 @@ void NetworkSettingsData::loadSettings( void ) {
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 {
ANetNode * NN = 0;
ANetNodeInstance* NNI = 0;
if( S.startsWith( "nodetype " ) ) {
- S = S.mid( 9, S.length()-9-1 );
- fprintf( stderr, "Node %s\n", S.latin1() );
+ S = S.mid( 9, S.length()-9 );
+ S = deQuote(S);
// try to find netnode
NN = NSResources->findNetNode( S );
+ fprintf( stderr, "Node %s : %p\n", S.latin1(), NN );
} else {
// try to find instance
NNI = NSResources->createNodeInstance( S );
+ fprintf( stderr, "NodeInstance %s : %p\n", S.latin1(), NNI );
+ }
+
+ if( NN == 0 && NNI == 0 ) {
+ LeftOvers.append( Line );
}
do {
- S = TS.readLine();
+ S = Line = TS.readLine();
if( NN || NNI ) {
if( S.isEmpty() ) {
// empty line
break;
}
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);
if( NN ) {
// set the attribute
- NNI->setAttribute( Attr, Value );
+ NN->setAttribute( Attr, Value );
} else {
// set the attribute
NNI->setAttribute( Attr, Value );
}
} else {
LeftOvers.append( Line );
// add empty line too as delimiter
if( S.isEmpty() ) {
// empty line
break;
}
}
} while( 1 );
+
if( NNI ) {
// loading from file -> exists
NNI->setNew( FALSE );
NSResources->addNodeInstance( NNI );
}
}
}
} while( 0 );
}
QString NetworkSettingsData::saveSettings( void ) {
QString ErrS = "";
if( ! isModified() )
@@ -153,53 +160,57 @@ QString NetworkSettingsData::saveSettings( void ) {
return ErrS;
}
QTextStream TS( &F );
// save leftovers
for ( QStringList::Iterator it = LeftOvers.begin();
it != LeftOvers.end(); ++it ) {
TS << (*it) << endl;
}
// save global configs
for( QDictIterator<NetNode_t> it( NSResources->netNodes() );
it.current();
++it ) {
TS << "[nodetype "
- << it.current()->NetNode->name()
+ << quote( QString( it.current()->NetNode->name() ) )
<< "]"
<< endl;
it.current()->NetNode->saveAttributes( TS );
+ TS << endl;
}
{ 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->nodeClass()->nodeName() << ']' << endl;
+ TS << '['
+ << QString(NNI->nodeClass()->name())
+ << ']'
+ << 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
//
@@ -282,33 +293,33 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
// 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->nodeClass()->generateProperFilesFor( NNI ) ) {
// problem generating
S = qApp->translate( "NetworkSettings",
"<p>Cannot generate files proper to \"%1\"</p>" ).
- arg(NNI->nodeClass()->nodeName()) ;
+ arg(NNI->nodeClass()->name()) ;
return S;
}
}
}
}
//
// generate all system files
//
for( QDictIterator<SystemFile> sfit(SFM);
sfit.current();
++sfit ) {
SF = sfit.current();
fprintf( stderr, "Generating %s\n", SF->name().latin1() );
SF->open();
@@ -377,38 +388,37 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
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
- fprintf( stderr, "check %s\n", NC->name().latin1() );
if( NC->handlesInterface( Interface ) && // if different Intf.
NC->state() != Disabled && // if not enabled
NC->state() != IsUp // if already used
) {
- fprintf( stderr, "Append %s\n", NC->name().latin1() );
+ fprintf( stderr, "Append %s for %s\n", NC->name().latin1(), Interface);
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
*/
bool NetworkSettingsData::canStart( const char * Interface ) {
// load situation
NodeCollection * NC = 0;
@@ -473,107 +483,100 @@ bool NetworkSettingsData::regenerate( void ) {
}
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() );
+ arg( CurDevNN->name() );
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() );
+ arg( CurDevNN->name() );
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() );
+ arg( CurDevNN->name() );
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() );
+ arg( NNI->nodeClass()->name() );
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() );
+ arg( CurDevNN->name() );
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() );
+ arg( CurDevNN->name() );
return S;
}
return S;
}
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
index 0bf415b..208c7c2 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
@@ -1,29 +1,29 @@
#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() {
+PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) {
}
/**
* 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>\
"
);
}
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.h b/noncore/settings/networksettings2/ppp/ppp_NN.h
index fbbbbe1..b1483c4 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.h
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.h
@@ -4,35 +4,32 @@
#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 & )
{ return 0; }
virtual bool generateDeviceDataForCommonFile(
SystemFile & SF, long DevNr );
virtual QString genNic( long NicNr );
private:
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp
index 0f71dc7..d06b7ef 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NN.cpp
@@ -1,28 +1,28 @@
#include "profile_NN.h"
#include "profile_NNI.h"
static const char * ProfileNeeds[] =
{ "connection",
0
};
/**
* Constructor, find all of the possible interfaces
*/
-ProfileNetNode::ProfileNetNode() : ANetNode() {
+ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular profile")) {
}
/**
* 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>\
"
);
}
diff --git a/noncore/settings/networksettings2/profile/profile_NN.h b/noncore/settings/networksettings2/profile/profile_NN.h
index 1313ab2..e602bd7 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.h
+++ b/noncore/settings/networksettings2/profile/profile_NN.h
@@ -4,35 +4,32 @@
#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 & )
{ return 0; }
virtual bool generateDeviceDataForCommonFile(
SystemFile & SF, long DevNr);
private:
virtual void setSpecificAttribute( QString & Attr, QString & Value );
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp
index d5971cf..9101490 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NN.cpp
@@ -1,27 +1,27 @@
#include "usb_NN.h"
#include "usb_NNI.h"
static const char * USBNeeds[] =
{ 0
};
/**
* Constructor, find all of the possible interfaces
*/
-USBNetNode::USBNetNode() : ANetNode() {
+USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) {
}
/**
* 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>\
"
);
}
diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h
index 0b83ea6..fea89f0 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.h
+++ b/noncore/settings/networksettings2/usb/usb_NN.h
@@ -4,35 +4,32 @@
#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);
virtual bool generateDeviceDataForCommonFile(
SystemFile & SF, long DevNr );
virtual QString genNic( long nr );
private:
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
index 307e9dd..bfc30f9 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
@@ -1,28 +1,28 @@
#include "vpn_NN.h"
#include "vpn_NNI.h"
static const char * VPNNeeds[] =
{ "connection",
0
};
/**
* Constructor, find all of the possible interfaces
*/
-VPNNetNode::VPNNetNode() : ANetNode() {
+VPNNetNode::VPNNetNode() : ANetNode(tr("VPN Connection")) {
}
/**
* 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>\
"
);
}
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.h b/noncore/settings/networksettings2/vpn/vpn_NN.h
index 1cd3fcc..5b6632e 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.h
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.h
@@ -4,35 +4,32 @@
#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 & )
{ return 0; }
virtual bool generateDeviceDataForCommonFile(
SystemFile & SF, long DevNr );
private:
virtual void setSpecificAttribute( QString & Attr, QString & Value );
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
index e0c4db2..7a2c1a7 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp
+++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
@@ -1,27 +1,27 @@
#include "wlan_NN.h"
#include "wlan_NNI.h"
static const char * WLanNeeds[] =
{ 0
};
/**
* Constructor, find all of the possible interfaces
*/
-WLanNetNode::WLanNetNode() : ANetNode() {
+WLanNetNode::WLanNetNode() : ANetNode(tr("WLan Device")) {
InstanceCount = 2;
}
/**
* 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>\
"
);
}
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.h b/noncore/settings/networksettings2/wlan/wlan_NN.h
index e93a89a..b5ff3fd 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NN.h
+++ b/noncore/settings/networksettings2/wlan/wlan_NN.h
@@ -4,35 +4,32 @@
#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 );
virtual bool generateDeviceDataForCommonFile(
SystemFile & SF, long DevNr );
virtual long instanceCount( void )
{ return InstanceCount; }