summaryrefslogtreecommitdiff
authorwimpie <wimpie>2005-01-11 21:42:31 (UTC)
committer wimpie <wimpie>2005-01-11 21:42:31 (UTC)
commit96678694f8952f60d0a895cede2b621404b4bfb8 (patch) (side-by-side diff)
tree7138e554e5ba200b8f9ca8b51c89b47531dc34f2
parentf89120a7a1a3d0bf9c0805456490906ca914e560 (diff)
downloadopie-96678694f8952f60d0a895cede2b621404b4bfb8.zip
opie-96678694f8952f60d0a895cede2b621404b4bfb8.tar.gz
opie-96678694f8952f60d0a895cede2b621404b4bfb8.tar.bz2
Major rename of NodeCollection to NetworkSetup
this commit is broken (missing symbols)
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/activateprofile.cpp2
-rw-r--r--noncore/settings/networksettings2/activateprofile.h2
-rw-r--r--noncore/settings/networksettings2/activatevpn.cpp10
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp40
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h4
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp12
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h4
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/cable/cablerun.cpp2
-rw-r--r--noncore/settings/networksettings2/cable/cablerun.h2
-rw-r--r--noncore/settings/networksettings2/editconnection.cpp54
-rw-r--r--noncore/settings/networksettings2/editconnection.h14
-rw-r--r--noncore/settings/networksettings2/editconnectionGUI.ui12
-rw-r--r--noncore/settings/networksettings2/gprs/GPRS_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/gprs/GPRS_NNI.cpp18
-rw-r--r--noncore/settings/networksettings2/gprs/GPRSrun.cpp4
-rw-r--r--noncore/settings/networksettings2/gprs/GPRSrun.h2
-rw-r--r--noncore/settings/networksettings2/irda/irdarun.h2
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.cpp8
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.h2
-rw-r--r--noncore/settings/networksettings2/modem/modemrun.h2
-rw-r--r--noncore/settings/networksettings2/network/network_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.cpp14
-rw-r--r--noncore/settings/networksettings2/network/networkrun.cpp9
-rw-r--r--noncore/settings/networksettings2/network/networkrun.h2
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp54
-rw-r--r--noncore/settings/networksettings2/networksettings2/asconnection.h6
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.cpp59
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h69
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp64
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.h28
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp4
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.h8
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp108
-rw-r--r--noncore/settings/networksettings2/nsdata.h4
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDriver.cpp4
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDriver.h4
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTGateway.cpp20
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTGateway.h12
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTInquiry.h2
-rw-r--r--noncore/settings/networksettings2/ppp/PPPDialingedit.cpp5
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.cpp4
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.cpp16
-rw-r--r--noncore/settings/networksettings2/ppp/ppprun.cpp4
-rw-r--r--noncore/settings/networksettings2/ppp/ppprun.h2
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.cpp8
-rw-r--r--noncore/settings/networksettings2/profile/profiledata.h2
-rw-r--r--noncore/settings/networksettings2/profile/profileedit.cpp8
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.cpp6
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.h2
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.cpp2
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp8
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.h2
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.cpp6
-rw-r--r--noncore/settings/networksettings2/vpn/vpnrun.h2
-rw-r--r--noncore/settings/networksettings2/wlan/wlanedit.cpp2
-rw-r--r--noncore/settings/networksettings2/wlan/wlanrun.cpp8
-rw-r--r--noncore/settings/networksettings2/wlan/wlanrun.h2
58 files changed, 391 insertions, 371 deletions
diff --git a/noncore/settings/networksettings2/activateprofile.cpp b/noncore/settings/networksettings2/activateprofile.cpp
index e4064e3..fe98fc4 100644
--- a/noncore/settings/networksettings2/activateprofile.cpp
+++ b/noncore/settings/networksettings2/activateprofile.cpp
@@ -1,31 +1,31 @@
#include <qlistbox.h>
#include <qlabel.h>
#include "activateprofile.h"
ActivateProfile::ActivateProfile( const char * Interface ) :
ActivateProfileGUI( 0, 0, TRUE ), NSD() {
Possible = NSD.collectPossible( Interface );
DeviceName_LBL->setText( Interface );
Profiles_LB->clear();
- for( NodeCollection * NC = Possible.first();
+ for( NetworkSetup * NC = Possible.first();
NC;
NC = Possible.next() ) {
Profiles_LB->insertItem( NC->devicePixmap(),
NC->name() );
}
}
ActivateProfile::~ActivateProfile( void ) {
}
long ActivateProfile::selectedProfile( void ) {
for( unsigned int i = 0 ; i < Profiles_LB->count(); i ++ ) {
if( Profiles_LB->isSelected(i) ) {
return Possible.at(i)->number();
}
}
return -1;
}
diff --git a/noncore/settings/networksettings2/activateprofile.h b/noncore/settings/networksettings2/activateprofile.h
index dedeb51..385c665 100644
--- a/noncore/settings/networksettings2/activateprofile.h
+++ b/noncore/settings/networksettings2/activateprofile.h
@@ -1,19 +1,19 @@
#include "activateprofileGUI.h"
#include "nsdata.h"
class ActivateProfile : public ActivateProfileGUI {
Q_OBJECT
public :
ActivateProfile( const char * interface );
~ActivateProfile( void );
long selectedProfile( void );
private :
NetworkSettingsData NSD;
- QList<NodeCollection> Possible;
+ QList<NetworkSetup> Possible;
};
diff --git a/noncore/settings/networksettings2/activatevpn.cpp b/noncore/settings/networksettings2/activatevpn.cpp
index 768a031..35a881b 100644
--- a/noncore/settings/networksettings2/activatevpn.cpp
+++ b/noncore/settings/networksettings2/activatevpn.cpp
@@ -1,48 +1,48 @@
#include <qlistview.h>
#include <qheader.h>
#include <resources.h>
#include "activatevpn.h"
class MyCheckListItem : public QCheckListItem {
public :
- MyCheckListItem( NodeCollection * N, QListView * V );
+ MyCheckListItem( NetworkSetup * N, QListView * V );
- NodeCollection * NC;
+ NetworkSetup * NC;
};
-MyCheckListItem::MyCheckListItem( NodeCollection * N, QListView * V ):
+MyCheckListItem::MyCheckListItem( NetworkSetup * N, QListView * V ):
QCheckListItem( V, N->name() ) {
NC = N;
}
ActivateVPN::ActivateVPN( const QString & I ) :
ActivateVPNGUI( 0, 0, TRUE ), NSD() {
QCheckListItem * CI;
VPN_LV->clear();
VPN_LV->header()->hide();
- // find all connections that want to be triggered by this interface
- for( QDictIterator<NodeCollection> it(NSResources->connections());
+ // find all NetworkSetups that want to be triggered by this interface
+ for( QDictIterator<NetworkSetup> it(NSResources->networkSetups());
it.current();
++it ) {
if( it.current()->triggeredBy( I ) ) {
CI = new MyCheckListItem( it.current(), VPN_LV );
}
}
}
ActivateVPN::~ActivateVPN( void ) {
}
void ActivateVPN::SLOT_ChangedVPNSetting( QListViewItem * I ) {
MyCheckListItem * MI = (MyCheckListItem *)I;
printf( "%s : %d\n",
MI->text(0).latin1(),
MI->isOn() );
}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp
index 5c937a1..5c71a0a 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp
@@ -1,165 +1,165 @@
#include <qfile.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#include <resources.h>
#include "bluetoothBNEPrun.h"
using Opietooth2::OTGateway;
-using Opietooth2::OTPANConnection;
-using Opietooth2::PANConnectionVector;
+using Opietooth2::OTPANNetworkSetup;
+using Opietooth2::PANNetworkSetupVector;
BluetoothBNEPRun::BluetoothBNEPRun( ANetNodeInstance * NNI,
BluetoothBNEPData & D ) :
RuntimeInfo( NNI ),
Data( D),
Pat( "bnep[0-6]" ) {
OT = 0;
}
BluetoothBNEPRun::~BluetoothBNEPRun( void ) {
if( OT ) {
OTGateway::releaseOTGateway();
}
}
State_t BluetoothBNEPRun::detectState( void ) {
/*
need to detect
- 1. for any PAN connection that is found if that
+ 1. for any PAN NetworkSetup that is found if that
PAN is connected.
if it is connected it is not available (since we do
not manage IP settings and we are called to detect
- the state we knwo that we do not have an UP connection)
+ the state we knwo that we do not have an UP NetworkSetup)
- 2. if it not connected and we allow any connection we
- are available or if that PAN connection is to a device
+ 2. if it not connected and we allow any NetworkSetup we
+ are available or if that PAN NetworkSetup is to a device
with a correct address
3. if it is not connected and the address do not match or
we do not accept any address, we are Unavailable but
- not DOWN. I.e a new connection could perhaps be created
+ not DOWN. I.e a new NetworkSetup could perhaps be created
*/
if( ! OT ) {
OT = OTGateway::getOTGateway();
}
if( ! OT->isEnabled() ) {
return Unavailable;
}
- // if there is a PAN connection that is UP but not
+ // if there is a PAN NetworkSetup that is UP but not
// yet configured (no ifup) the we are available
- return ( hasFreePANConnection() ) ? Available : Unknown;
+ return ( hasFreePANNetworkSetup() ) ? Available : Unknown;
}
-QString BluetoothBNEPRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
+QString BluetoothBNEPRun::setMyState( NetworkSetup * NC, Action_t A, bool ) {
if( A == Activate ) {
- if( hasFreePANConnection( 1 ) ) {
+ if( hasFreePANNetworkSetup( 1 ) ) {
// we have now an assignedinterface
} else {
return QString("TODO : Start PAND");
}
Log(( "Assigned interface" ));
NC->setCurrentState( Available );
return QString();
}
if( A == Deactivate ) {
// nothing to do
NC->setCurrentState( Off );
return QString();
}
return QString();
}
bool BluetoothBNEPRun::handlesInterface( const QString & S ) {
return Pat.match( S ) >= 0;
}
bool BluetoothBNEPRun::handlesInterface( InterfaceInfo * I ) {
return handlesInterface( I->Name );
}
-bool BluetoothBNEPRun::hasFreePANConnection( bool Grab ) {
+bool BluetoothBNEPRun::hasFreePANNetworkSetup( bool Grab ) {
if( ! OT ) {
OT = OTGateway::getOTGateway();
}
- // load PAN connections
- OTPANConnection * C;
+ // load PAN NetworkSetups
+ OTPANNetworkSetup * C;
InterfaceInfo * Run;
InterfaceInfo * Candidate = 0; // reuse this interface
- PANConnectionVector Conns = OT->getPANConnections();
+ PANNetworkSetupVector Conns = OT->getPANNetworkSetups();
System & Sys = NSResources->system();
bool IsValid;
for( unsigned int i = 0;
i < Conns.count();
i ++ ) {
C = Conns[i];
if( Data.AllowAll ) {
// we allow all
IsValid = 1;
} else {
- // is this PAN connection connecting to a Peer
+ // is this PAN NetworkSetup connecting to a Peer
// we allow ?
IsValid = 0;
for ( QStringList::Iterator it = Data.BDAddress.begin();
it != Data.BDAddress.end();
++ it ) {
if( C->ConnectedTo == (*it) ) {
- // this is a connection we could accept
+ // this is a NetworkSetup we could accept
IsValid = 1;
break;
}
}
}
if( ! IsValid ) {
Log(("%s to %s not acceptable\n",
C->Device.latin1(),
C->ConnectedTo.latin1() ));
// don't bother checking this address
// it is not acceptable
continue;
}
- // is this PAN connection available to us ?
+ // is this PAN NetworkSetup available to us ?
Run = Sys.findInterface( C->Device );
if( Run && Run->IsUp ) {
- // this PAN connection is up
+ // this PAN NetworkSetup is up
Log(("%s acceptable but unavailable\n",
C->Device.latin1() ));
// find others
continue;
}
// we at least have a possible interface
if( ! Candidate ) {
Candidate = Run;
}
}
if( Candidate ) {
if ( Grab ) {
- netNode()->connection()->assignInterface( Candidate );
+ netNode()->networkSetup()->assignInterface( Candidate );
}
return 1;
}
// no free PAN
return 0;
}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
index 8551a2e..7346a8d 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
@@ -1,34 +1,34 @@
#include <netnode.h>
#include "bluetoothBNEPdata.h"
#include <OTGateway.h>
class BluetoothBNEPRun : public RuntimeInfo {
public :
BluetoothBNEPRun( ANetNodeInstance * NNI,
BluetoothBNEPData & D );
virtual ~BluetoothBNEPRun( void );
// i am a device
virtual RuntimeInfo * device( void )
{ return this; }
bool handlesInterface( const QString & );
bool handlesInterface( InterfaceInfo * );
State_t detectState( void );
protected :
- QString setMyState( NodeCollection * , Action_t, bool );
+ QString setMyState( NetworkSetup * , Action_t, bool );
private :
- bool hasFreePANConnection( bool Grab = 0 );
+ bool hasFreePANNetworkSetup( bool Grab = 0 );
BluetoothBNEPData & Data;
Opietooth2::OTGateway * OT;
QRegExp Pat;
};
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp
index 3df7f5c..cd7bb4a 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp
@@ -1,164 +1,164 @@
#include <qapplication.h>
#include <resources.h>
#include <OTDevice.h>
#include <OTGateway.h>
#include "bluetoothRFCOMMrun.h"
using Opietooth2::OTGateway;
using Opietooth2::OTDevice;
using Opietooth2::OTDeviceAddress;
BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) {
if( OT ) {
OTGateway::releaseOTGateway();
}
}
State_t BluetoothRFCOMMRun::detectState( void ) {
if( ! OT ) {
OT = OTGateway::getOTGateway();
}
- if( deviceNrOfConnection() >= 0 ) {
+ if( deviceNrOfNetworkSetup() >= 0 ) {
return Available;
}
odebug << "Bluetooth "
<< OT->isEnabled()
<< oendl;
return ( OT->isEnabled() ) ? Off : Unavailable;
}
-QString BluetoothRFCOMMRun::setMyState( NodeCollection *,
+QString BluetoothRFCOMMRun::setMyState( NetworkSetup *,
Action_t A,
bool ) {
if( OT ) {
OTGateway::getOTGateway();
}
if( A == Activate ) {
// from OFF to Available
RFCOMMChannel * Ch = getChannel( );
System & Sys = NSResources->system();
if( Ch ) {
// connect to this peer
DeviceNr = OT->getFreeRFCommDevice();
QStringList S;
S << "rfcomm"
<< "bind"
<< QString().setNum( DeviceNr )
<< Ch->BDAddress
<< QString().setNum( Ch->Channel );
if( Sys.runAsRoot( S ) ) {
return QString( "Error starting %1").arg(S.join(" "));
}
// here rfcomm should be running -> we will detect state later
return QString();
} else {
Log(( "No channel selected -> cancel\n" ));
return QString( "No channel selected. Operation cancelled" );
}
}
if( A == Deactivate ) {
if( DeviceNr >= 0 ) {
if( OT->releaseRFCommDevice( DeviceNr ) ) {
- return QString( "Cannot release RFCOMM connection" );
+ return QString( "Cannot release RFCOMM NetworkSetup" );
}
DeviceNr = -1;
}
}
return QString();
}
#include <qlistbox.h>
#include <qframe.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qdialog.h>
RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) {
if( Data->Devices.count() == 1 ) {
// only one device -> return channel
return Data->Devices[0];
}
RFCOMMChannel * Ch = 0;
QDialog * Dlg = new QDialog( qApp->mainWidget(), 0, TRUE );
QVBoxLayout * V = new QVBoxLayout( Dlg );
QLabel * L = new QLabel(
qApp->translate( "BluetoothRFCOMMRun",
"Select device to connect to"),
Dlg );
QListBox * LB = new QListBox( Dlg );
for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) {
LB->insertItem( QString( "%1 (%2 Chnl %3)" ).
arg( Data->Devices[i]->Name ).
arg( Data->Devices[i]->BDAddress ).
arg( Data->Devices[i]->Channel ) );
}
V->addWidget( L );
V->addWidget( LB );
Dlg->resize( 100, 100 );
Dlg->move( 20,
(qApp->desktop()->height()-100)/2 );
if( Dlg->exec() == QDialog::Accepted ) {
unsigned int i = 0;
for( i = 0; i < Data->Devices.count(); i ++ ) {
if( LB->isSelected(i) ) {
odebug << "Selected " << Data->Devices[i]->Name << oendl;
Ch = Data->Devices[i];
break;
}
}
}
delete Dlg;
return Ch;
}
QString BluetoothRFCOMMRun::deviceFile( void ) {
- if( deviceNrOfConnection() >= 0 ) {
+ if( deviceNrOfNetworkSetup() >= 0 ) {
OTDevice * OTD = OT->getOTDevice();
- // there is a connection
+ // there is a NetworkSetup
return OTD->getRFCommDevicePattern().arg(DeviceNr);
}
return QString();
}
-int BluetoothRFCOMMRun::deviceNrOfConnection( void ) {
+int BluetoothRFCOMMRun::deviceNrOfNetworkSetup( void ) {
if( ! OT ) {
OT = OTGateway::getOTGateway();
}
DeviceNr = -1;
for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) {
odebug << "Check for rfcomm on "
<< Data->Devices[i]->BDAddress
<< " "
<< Data->Devices[i]->Channel
<< oendl;
if( ( DeviceNr = OT->connectedToRFCommChannel(
OTDeviceAddress( Data->Devices[i]->BDAddress ),
Data->Devices[i]->Channel ) ) >= 0 ) {
odebug << "Up "
<< oendl;
break;
}
}
return DeviceNr;
}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
index 5a31a94..32986d3 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
@@ -1,32 +1,32 @@
#include <netnode.h>
#include "bluetoothRFCOMMdata.h"
#include <OTGateway.h>
class BluetoothRFCOMMRun : public RuntimeInfo {
public :
BluetoothRFCOMMRun( ANetNodeInstance * NNI,
BluetoothRFCOMMData & D ) : RuntimeInfo( NNI )
{ DeviceNr = -1; Data = &D; OT = 0; }
virtual ~BluetoothRFCOMMRun( void );
virtual RuntimeInfo * line( void )
{ return this; }
virtual QString deviceFile( void );
State_t detectState( void );
protected :
- QString setMyState( NodeCollection * , Action_t, bool );
+ QString setMyState( NetworkSetup * , Action_t, bool );
private :
- int deviceNrOfConnection( void );
+ int deviceNrOfNetworkSetup( void );
RFCOMMChannel * getChannel( void );
BluetoothRFCOMMData * Data;
Opietooth2::OTGateway * OT;
int DeviceNr; // cached from detection
};
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp
index 58237a1..3f34bb2 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NN.cpp
@@ -1,52 +1,52 @@
#include "cable_NN.h"
#include "cable_NNI.h"
#include "netnodeinterface.h"
static const char * CableNeeds[] =
{ 0
};
static const char * CableProvides[] =
{ "line",
0
};
/**
* Constructor, find all of the possible interfaces
*/
-CableNetNode::CableNetNode() : ANetNode(tr("Cable Connection")) {
+CableNetNode::CableNetNode() : ANetNode(tr("Cable NetworkSetup")) {
}
/**
* 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 CableProvides;
}
void CableNetNode::setSpecificAttribute( QString & , QString & ) {
}
void CableNetNode::saveSpecificAttribute( QTextStream & ) {
}
OPIE_NS2_PLUGIN( NetNodeInterface_T<CableNetNode> )
diff --git a/noncore/settings/networksettings2/cable/cablerun.cpp b/noncore/settings/networksettings2/cable/cablerun.cpp
index 7a8deb9..edbeb89 100644
--- a/noncore/settings/networksettings2/cable/cablerun.cpp
+++ b/noncore/settings/networksettings2/cable/cablerun.cpp
@@ -1,22 +1,22 @@
#include <fcntl.h>
#include <unistd.h>
#include "cablerun.h"
State_t CableRun::detectState( void ) {
int fd = open( Data->Device.latin1(), O_RDWR );
if( fd < 0 ) {
return Unavailable;
}
close( fd );
return Available;
}
-QString CableRun::setMyState( NodeCollection *, Action_t , bool ) {
+QString CableRun::setMyState( NetworkSetup *, Action_t , bool ) {
return QString();
}
QString CableRun::deviceFile( void ) {
return Data->Device;
}
diff --git a/noncore/settings/networksettings2/cable/cablerun.h b/noncore/settings/networksettings2/cable/cablerun.h
index 41aea01..6a457c4 100644
--- a/noncore/settings/networksettings2/cable/cablerun.h
+++ b/noncore/settings/networksettings2/cable/cablerun.h
@@ -1,26 +1,26 @@
#include <netnode.h>
#include "cabledata.h"
class CableRun : public RuntimeInfo {
public :
CableRun( ANetNodeInstance * NNI,
CableData & D ) : RuntimeInfo( NNI )
{ Data = &D; }
virtual RuntimeInfo * line( void )
{ return this; }
virtual QString deviceFile( void );
State_t detectState( void );
protected :
- QString setMyState( NodeCollection * , Action_t, bool );
+ QString setMyState( NetworkSetup * , Action_t, bool );
private :
CableData * Data;
};
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp
index 717d9e9..6ab2dd6 100644
--- a/noncore/settings/networksettings2/editconnection.cpp
+++ b/noncore/settings/networksettings2/editconnection.cpp
@@ -1,629 +1,631 @@
#include <opie2/odebug.h>
#include <qlistview.h>
#include <qwidgetstack.h>
#include <qframe.h>
#include <qcombobox.h>
#include <qtabwidget.h>
#include <qmessagebox.h>
#include <qpushbutton.h>
#include <qlineedit.h>
#include <qheader.h>
#include <qpainter.h>
#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 ) { }
MyQCheckListItem( QListView *parent, const QString & S ) :
QCheckListItem( parent, S, QCheckListItem::Controller ) { }
MyQCheckListItem( QCheckListItem *parent, const QString & S ) :
QCheckListItem( parent, S, QCheckListItem::Controller ) { }
MyQCheckListItem( QListViewItem *parent, const QString & S ) :
QCheckListItem( parent, S, QCheckListItem::Controller ) { }
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;
+bool EditNetworkSetup::AutoCollapse = 1;
-EditConnection::EditConnection( QWidget* parent ) :
- EditConnectionGUI( parent, 0, TRUE ), TmpCollection() {
+EditNetworkSetup::EditNetworkSetup( QWidget* parent ) :
+ EditNetworkSetupGUI( 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 ) {
+NetworkSetup * EditNetworkSetup::getTmpCollection( void ) {
if( TmpIsValid )
// content is stil OK
return &(TmpCollection);
// reset collection -> delete all NEW NetNodes
for( QListIterator<ANetNodeInstance> it(TmpCollection);
it.current();
++it ) {
if( it.current()->isNew() ) {
delete it.current();
}
}
+
TmpCollection.clear();
+ TmpCollection.copyFrom( *SelectedNodes );
// update content
QListViewItem * it = Nodes_LV->firstChild();
ANetNode * NN;
// start iter (if there is a collection)
/*
a node collection is sorted from the toplevel
node to the deepest node
*/
ANetNodeInstance * NNI =
(SelectedNodes) ? SelectedNodes->first() : 0 ;
TmpCollection.setModified( 0 );
// the listview always starts with the toplevel
// hierarchy. This is always a controller item
while ( it ) {
NN = (*Mapping)[it];
if( NN == 0 ) {
// this item is a controller ->
// has radio items as children ->
// find selected one
it = it->firstChild();
while( it ) {
if( ((QCheckListItem *)it)->isOn() ) {
// this radio is selected -> go deeper
break;
}
it = it->nextSibling();
}
if( ! it ) {
TmpIsValid = 0;
return 0;
}
// it now contains selected radio
NN = (*Mapping)[it];
}
// NN here contains the netnode of the
// current item -> this node needs to
// be stored in the collection
if( NNI == 0 ||
it->text(0) != NNI->nodeClass()->name() ) {
// new item not in previous collection
ANetNodeInstance * NNI = NN->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();
}
// go deeper to next level
// this level is can be a new controller
// or an item
it = it->firstChild();
}
TmpIsValid = 1;
return &(TmpCollection);
}
-// pass a connection NodeCollection to be edited
-void EditConnection::setConnection( NodeCollection * NC ) {
+// pass a NetworkSetup NetworkSetup to be edited
+void EditNetworkSetup::setNetworkSetup( NetworkSetup * 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 ) {
NN = (*Mapping)[it];
if( NN == 0 ) {
// this item is a controller ->
// has radio items as children ->
// find selected one
it = it->firstChild();
Found = 0;
while( it ) {
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(
0,
- tr( "Error presentig Connection" ),
- tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ).
+ tr( "Error presentig NetworkSetup" ),
+ tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ).
arg(NNI->nodeClass()->name()) );
return;
}
// it now contains selected radio
NN = (*Mapping)[it];
} else {
// automatic selection
if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) {
// should exist and be the same
if( NNI ) {
QMessageBox::warning(
0,
- tr( "Error presentig Connection" ),
- tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ).
+ tr( "Error presentig NetworkSetup" ),
+ tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ).
arg(NNI->nodeClass()->name()) );
} else {
QMessageBox::warning(
0,
- tr( "Error presentig Connection" ),
- tr( "<p>Missing connection\"<i>%1</i>\"</p>" ).
+ tr( "Error presentig NetworkSetup" ),
+ tr( "<p>Missing NetworkSetup\"<i>%1</i>\"</p>" ).
arg(it->text(0)) );
}
return;
}
it = it->firstChild();
}
}
}
// get result of editing (either new OR updated collection
-NodeCollection * EditConnection::connection( void ) {
+NetworkSetup * EditNetworkSetup::networkSetup( void ) {
if( SelectedNodes == 0 ) {
// new collection
- SelectedNodes = new NodeCollection;
+ SelectedNodes = new NetworkSetup;
}
// clean out old entries
SelectedNodes->clear();
// transfer
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 ) {
+void EditNetworkSetup::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 are toplevel nodes -> ie provide
- // TCP/IP Connection
+ // TCP/IP NetworkSetup
for( QDictIterator<ANetNode> Iter(NSResources->netNodes());
Iter.current();
++Iter ) {
NN = Iter.current();
if( ! NN->isToplevel() ) {
continue;
}
MyQCheckListItem * it = new MyQCheckListItem( TheTop,
NN->name(),
QCheckListItem::RadioButton );
it->setPixmap( 0,
NSResources->getPixmap( NN->pixmapName() )
);
// 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 ) {
+void EditNetworkSetup::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(NN->needs()[0]),
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]->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]->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 ) {
+void EditNetworkSetup::accept( void ) {
if( ! haveCompleteConfig( 0 ) || Name_LE->text().isEmpty() ) {
QMessageBox::warning(
0,
- tr( "Closing Connection Setup" ),
+ tr( "Closing NetworkSetup Setup" ),
tr( "Definition not complete or no name" ) );
return;
}
// check if all devices have acceptable input
getTmpCollection();
{ ANetNodeInstance * NNI;
QString S;
for( QListIterator<ANetNodeInstance> it(TmpCollection);
it.current();
++it ) {
NNI = it.current();
// widget must show its own problems
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 ) {
+void EditNetworkSetup::SLOT_AutoCollapse( bool b ) {
AutoCollapse = b;
}
// clicked on node in tree -> update GUI
-void EditConnection::SLOT_SelectNode( QListViewItem * it ) {
+void EditNetworkSetup::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->parent() ];
if( NN ) {
// figure out type of this node -> produce mesage
Description_LBL->setText( NSResources->netNode2Description(
NN->needs()[0]) );
} 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 ) {
+void EditNetworkSetup::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->nodeClass()->pixmapName() ),
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
}
}
// update visual feedback of selection state
-void EditConnection::updateGUI( QListViewItem * it, ANetNode * NN ) {
+void EditNetworkSetup::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 ) {
+void EditNetworkSetup::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 ) {
+void EditNetworkSetup::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 ) {
+bool EditNetworkSetup::haveCompleteConfig( QListViewItem * it ) {
// check if all below this level is selected
it = ( it ) ?it : Nodes_LV->firstChild();
ANetNode *NN;
bool Found;
while ( it ) {
NN = (*Mapping)[it];
if( NN == 0 ) {
// this item is a controller ->
// has radio items as children ->
// find selected one
it = it->firstChild();
Found = 0;
while( it ) {
if( ((QCheckListItem *)it)->isOn() ) {
Found = 1;
// go deeper
it = it->firstChild();
break;
}
it = it->nextSibling();
}
if( ! Found ) {
return 0; // no not complete -> a radio should have been chkd
}
// it now contains selected radio
NN = (*Mapping)[it];
} else {
// automatic selection
it = it->firstChild();
}
}
return 1;
}
diff --git a/noncore/settings/networksettings2/editconnection.h b/noncore/settings/networksettings2/editconnection.h
index e8d7a2c..c2fc643 100644
--- a/noncore/settings/networksettings2/editconnection.h
+++ b/noncore/settings/networksettings2/editconnection.h
@@ -1,49 +1,49 @@
#include "editconnectionGUI.h"
#include <qptrdict.h>
#include <qvector.h>
#include "netnode.h"
class ANetNodeInstance;
class ANetNode;
class QListViewItem;
class NetNodeLVI;
class QCloseEvent;
-class EditConnection : public EditConnectionGUI {
+class EditNetworkSetup : public EditNetworkSetupGUI {
Q_OBJECT
public :
- EditConnection( QWidget * P );
+ EditNetworkSetup( QWidget * P );
ANetNodeInstance * netNodeInstance( void );
- void setConnection( NodeCollection * NC );
- NodeCollection * connection( void );
+ void setNetworkSetup( NetworkSetup * NC );
+ NetworkSetup * networkSetup( void );
public slots :
void SLOT_AutoCollapse( bool );
void SLOT_SelectNode( QListViewItem * it );
void SLOT_AlterTab( const QString & S );
virtual void accept( void );
private :
- NodeCollection * getTmpCollection( void );
+ NetworkSetup * getTmpCollection( void );
void updateGUI( QListViewItem * it, ANetNode * NN );
void buildFullTree( void );
void buildSubTree( QListViewItem * Parent, ANetNode * NN );
void disableTree( QListViewItem * it, bool Mode);
void enablePath( QListViewItem * it, bool pha);
bool haveCompleteConfig( QListViewItem * it );
QPtrDict<ANetNode> * Mapping;
- NodeCollection * SelectedNodes;
+ NetworkSetup * SelectedNodes;
bool TmpIsValid;
- NodeCollection TmpCollection;
+ NetworkSetup TmpCollection;
static bool AutoCollapse;
};
diff --git a/noncore/settings/networksettings2/editconnectionGUI.ui b/noncore/settings/networksettings2/editconnectionGUI.ui
index dfb2596..5e50490 100644
--- a/noncore/settings/networksettings2/editconnectionGUI.ui
+++ b/noncore/settings/networksettings2/editconnectionGUI.ui
@@ -1,406 +1,406 @@
<!DOCTYPE UI><UI>
-<class>EditConnectionGUI</class>
+<class>EditNetworkSetupGUI</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
- <cstring>EditConnectionGUI</cstring>
+ <cstring>EditNetworkSetupGUI</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
<width>427</width>
<height>523</height>
</rect>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>minimumSize</name>
<size>
<width>0</width>
<height>70</height>
</size>
</property>
<property stdset="1">
<name>caption</name>
<string>Edit profile</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>2</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>2</number>
</property>
<widget>
<class>QTabWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Tab_TB</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>Device Tree</string>
</attribute>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>2</number>
</property>
<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>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>Header_LBL</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>1</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>MShape</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>MShadow</enum>
</property>
<property stdset="1">
<name>text</name>
- <string>Connection profile</string>
+ <string>NetworkSetup profile</string>
</property>
<property stdset="1">
<name>alignment</name>
<set>AlignVCenter|AlignLeft</set>
</property>
<property>
<name>vAlign</name>
</property>
</widget>
<widget>
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>Name_LE</cstring>
</property>
</widget>
</hbox>
</widget>
<widget>
<class>QListView</class>
<column>
<property>
<name>text</name>
<string>Column 1</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>Nodes_LV</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>minimumSize</name>
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property stdset="1">
<name>maximumSize</name>
<size>
<width>32767</width>
<height>32767</height>
</size>
</property>
<property stdset="1">
<name>rootIsDecorated</name>
<bool>true</bool>
</property>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout4</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<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>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>AutoCollapse_CB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Auto collapse</string>
</property>
<property stdset="1">
<name>checked</name>
<bool>true</bool>
</property>
</widget>
</hbox>
</widget>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>Description_LBL</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>5</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Box</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Raised</enum>
</property>
<property stdset="1">
<name>text</name>
<string></string>
</property>
<property stdset="1">
<name>alignment</name>
<set>AlignTop|AlignLeft</set>
</property>
<property>
<name>vAlign</name>
</property>
</widget>
</vbox>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>Setup</string>
</attribute>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>0</number>
</property>
<widget>
<class>QFrame</class>
<property stdset="1">
<name>name</name>
<cstring>Setup_FRM</cstring>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>NoFrame</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Plain</enum>
</property>
<property stdset="1">
<name>lineWidth</name>
<number>0</number>
</property>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>midLineWidth</name>
<number>0</number>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>2</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>4</number>
</property>
<widget>
<class>QComboBox</class>
<property stdset="1">
<name>name</name>
<cstring>Devices_CB</cstring>
</property>
</widget>
<widget>
<class>QWidgetStack</class>
<property stdset="1">
<name>name</name>
<cstring>Setup_WS</cstring>
</property>
</widget>
</vbox>
</widget>
</vbox>
</widget>
</widget>
</vbox>
</widget>
<customwidgets>
<customwidget>
<class>QWidgetStack</class>
<header location="global">qwidgetstack.h</header>
<sizehint>
<width>-1</width>
<height>-1</height>
</sizehint>
<container>0</container>
<sizepolicy>
<hordata>7</hordata>
<verdata>7</verdata>
</sizepolicy>
<pixmap>image0</pixmap>
<slot access="public">raiseWidget( int )</slot>
</customwidget>
</customwidgets>
<images>
<image>
<name>image0</name>
<data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
</image>
</images>
<connections>
<connection>
<sender>Nodes_LV</sender>
<signal>clicked(QListViewItem*)</signal>
- <receiver>EditConnectionGUI</receiver>
+ <receiver>EditNetworkSetupGUI</receiver>
<slot>SLOT_SelectNode( QListViewItem *)</slot>
</connection>
<connection>
<sender>AutoCollapse_CB</sender>
<signal>toggled(bool)</signal>
- <receiver>EditConnectionGUI</receiver>
+ <receiver>EditNetworkSetupGUI</receiver>
<slot>SLOT_AutoCollapse( bool)</slot>
</connection>
<connection>
<sender>Devices_CB</sender>
<signal>activated(int)</signal>
<receiver>Setup_WS</receiver>
<slot>raiseWidget( int )</slot>
</connection>
<connection>
<sender>Tab_TB</sender>
<signal>selected(const QString&amp;)</signal>
- <receiver>EditConnectionGUI</receiver>
+ <receiver>EditNetworkSetupGUI</receiver>
<slot>SLOT_AlterTab( const QString &amp; )</slot>
</connection>
<slot access="public">SLOT_AlterTab( const QString &amp; )</slot>
<slot access="public">SLOT_AutoCollapse( bool)</slot>
<slot access="public">SLOT_SelectNode( QListViewItem *)</slot>
</connections>
</UI>
diff --git a/noncore/settings/networksettings2/gprs/GPRS_NN.cpp b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp
index e9553a6..374cf5a 100644
--- a/noncore/settings/networksettings2/gprs/GPRS_NN.cpp
+++ b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp
@@ -1,78 +1,78 @@
#include <resources.h>
#include <qpe/qpeapplication.h>
#include <netnode.h>
#include "GPRS_NN.h"
#include "GPRS_NNI.h"
#include "netnodeinterface.h"
static const char * GPRSNeeds[] =
{ "GPRS",
0
};
static const char * GPRSProvides[] =
- { "connection",
+ { "NetworkSetup",
0
};
/**
* Constructor, find all of the possible interfaces
*/
GPRSNetNode::GPRSNetNode() : ANetNode(tr("GPRS capable device")) {
NSResources->addSystemFile(
"pap-secrets", "/etc/ppp/pap-secrets", 0 );
}
/**
* Delete any interfaces that we own.
*/
GPRSNetNode::~GPRSNetNode(){
}
const QString GPRSNetNode::nodeDescription(){
return tr("\
<p>provides access to a GPRS capable device.</p>\
"
);
}
ANetNodeInstance * GPRSNetNode::createInstance( void ) {
return new AGPRSDevice( this );
}
bool GPRSNetNode::hasDataForFile( SystemFile & S ) {
return S.name() == "pap-secrets";
}
short GPRSNetNode::generateFile( SystemFile & ,
ANetNodeInstance * ,
long ) {
return 0;
}
const char ** GPRSNetNode::needs( void ) {
return GPRSNeeds;
}
const char ** GPRSNetNode::provides( void ) {
return GPRSProvides;
}
void GPRSNetNode::setSpecificAttribute( QString & , QString & ) {
}
void GPRSNetNode::saveSpecificAttribute( QTextStream & ) {
}
QStringList GPRSNetNode::properFiles( void ) {
QStringList SL;
SL << "peers";
SL << "chatscripts";
SL << "extra";
return SL;
}
OPIE_NS2_PLUGIN( NetNodeInterface_T<GPRSNetNode> )
diff --git a/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp b/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp
index 2f61cba..bf8cc59 100644
--- a/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp
+++ b/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp
@@ -1,231 +1,231 @@
#include <system.h>
#include <netnode.h>
#include "GPRSedit.h"
#include "GPRS_NNI.h"
#include "GPRS_NN.h"
AGPRSDevice::AGPRSDevice( GPRSNetNode * PNN ) : ANetNodeInstance( PNN ) {
Data.APN = "";
Data.User = "";
Data.Password = "";
Data.DefaultGateway = 1;
Data.SetIfSet = 0;
Data.Debug = 0;
Data.Routing.setAutoDelete( TRUE );
GUI = 0;
RT = 0;
}
void AGPRSDevice::setSpecificAttribute( QString & A, QString & V ) {
if( A == "apn" ) {
Data.APN = V;
} else if( A == "user" ) {
Data.User = V;
} else if( A == "password" ) {
Data.Password = V;
} else if( A == "dns2" ) {
Data.DNS2 = V;
} else if( A == "dns1" ) {
Data.DNS1 = V;
} else if( A == "defaultgateway" ) {
Data.DefaultGateway = (V=="yes");
} else if( A == "setifset" ) {
Data.SetIfSet = (V == "yes");
} else if( A == "routes" ) {
Data.Routing.resize( V.toULong() );
} else if( A.startsWith( "route" ) ) {
QStringList SL = QStringList::split( "/", V );
GPRSRoutingEntry * E = new GPRSRoutingEntry;
E->Address = SL[0];
E->Mask = SL[1].toULong();
Data.Routing.insert( A.mid(5).toULong(), E );
} else if( A == "debug" ) {
Data.Debug = V.toShort();
}
}
void AGPRSDevice::saveSpecificAttribute( QTextStream & TS ) {
TS << "apn=" << Data.APN << endl;
TS << "user=" << Data.User << endl;
TS << "password=" << Data.Password << endl;
TS << "dns1=" << Data.DNS1 << endl;
TS << "dns2=" << Data.DNS2 << endl;
TS << "defaultgateway=" << ( (Data.DefaultGateway) ? "yes" : "no" ) << endl;
TS << "setifset=" << ((Data.SetIfSet) ? "yes" : "no") << endl;
TS << "debug=" << Data.Debug << endl;
TS << "routes=" << Data.Routing.count() << oendl;
for( unsigned int i = 0; i < Data.Routing.count(); i ++ ) {
TS << "route" << i << "="
<< Data.Routing[i]->Address
<< "/"
<< Data.Routing[i]->Mask
<< oendl;
}
}
QWidget * AGPRSDevice::edit( QWidget * parent ) {
GUI = new GPRSEdit( parent );
GUI->showData( Data );
return GUI;
}
QString AGPRSDevice::acceptable( void ) {
return ( GUI ) ? GUI->acceptable( ) : QString();
}
void AGPRSDevice::commit( void ) {
if( GUI && GUI->commit( Data ) )
setModified( 1 );
}
bool AGPRSDevice::hasDataForFile( SystemFile & S ) {
return S.name() == "pap-secrets" ||
S.name() == "peers" ||
S.name() == "extra" ||
S.name() == "chatscripts" ;
}
short AGPRSDevice::generateFile( SystemFile & SF,
long
) {
if( SF.name() == "pap-secrets" ) {
SF << Data.User
<< " * "
<< Data.Password
<< " *"
<< endl;
return 0;
} else if( SF.name() == "chatscripts" ) {
SF << "SAY \"Starting\\n\"" << oendl;
SF << "ECHO OFF" << oendl;
SF << "ABORT BUSY" << oendl;
SF << "ABORT ERROR" << oendl;
SF << "ABORT VOICE" << oendl;
SF << "ABORT \"NO CARRIER\"" << oendl;
SF << "ABORT \"NO DIALTONE\"" << oendl;
SF << "\"\" AT" << oendl;
SF << "OK AT+CGATT=1" << oendl;
SF << "OK AT+CGDCONT=1,\"IP\",\""
<< Data.APN
<< "\""
<< oendl;
SF << "OK ATD*99***1#\\n" << oendl;
SF << "TIMEOUT 10" << oendl;
SF << "CONNECT \"\"" << oendl;
SF << "SAY \"READY\\n\"" << oendl;
return 0;
} else if( SF.name() == "peers" ) {
SF << "noauth" << oendl;
SF << "user " << Data.User << oendl;
SF << "connect \"/usr/sbin/chat -s -v -f /etc/chatscripts/"
- << removeSpaces( connection()->name() )
+ << removeSpaces( networkSetup()->name() )
<< "\""
<< oendl;
SF << "ipcp-accept-local" << oendl;
SF << "ipcp-accept-remote" << oendl;
if( Data.DefaultGateway ) {
SF << "defaultroute" << oendl;
if( Data.SetIfSet ) {
SF << "replacedefaultroute" << oendl;
}
}
if( Data.Debug ) {
SF << "logfile /tmp/"
- << removeSpaces( connection()->name() )
+ << removeSpaces( networkSetup()->name() )
<< oendl;
for( int i = 0; i < Data.Debug; i ++ ) {
SF << "debug" << oendl;
}
}
SF << "nocrtscts" << oendl;
SF << "local" << oendl;
SF << "lcp-echo-interval 0" << oendl;
SF << "lcp-echo-failure 0" << oendl;
SF << "usepeerdns" << oendl;
- SF << "linkname " << removeSpaces( connection()->name() ) << oendl;
+ SF << "linkname " << removeSpaces( networkSetup()->name() ) << oendl;
SF << "nopersist" << oendl;
- SF << "ipparam " << removeSpaces( connection()->name() ) <<oendl;
+ SF << "ipparam " << removeSpaces( networkSetup()->name() ) <<oendl;
SF << "maxfail 1" << oendl;
return 0;
} else if( SF.name() == "extra" ) {
unsigned long Bits;
// generate 'fixed' settings
for( unsigned int i = 0 ;
i < Data.Routing.count();
i ++ ) {
if( Data.Routing[i]->Mask == 32 ) {
Bits = 0xffffffff;
} else {
Bits = ~ ((1 << ((32-Data.Routing[i]->Mask))) - 1);
}
SF << "route add -net "
<< Data.Routing[i]->Address
<< " netmask "
<< ((Bits&0xff000000)>>24)
<< "."
<< ((Bits&0x00ff0000)>>16)
<< "."
<< ((Bits&0x0000ff00)>>8)
<< "."
<< ((Bits&0x000000ff))
<< " gw $PPP_REMOTE"
<< oendl;
SF << "route del -net "
<< Data.Routing[i]->Address
<< " netmask "
<< ((Bits&0xff000000)>>24)
<< "."
<< ((Bits&0x00ff0000)>>16)
<< "."
<< ((Bits&0x0000ff00)>>8)
<< "."
<< ((Bits&0x000000ff))
<< " gw $PPP_REMOTE"
<< oendl;
}
if( ! Data.DNS1.isEmpty() ) {
SF << "nameserver "
<< Data.DNS1
<< " # profile "
- << removeSpaces( connection()->name() )
+ << removeSpaces( networkSetup()->name() )
<<oendl;
}
if( ! Data.DNS2.isEmpty() ) {
SF << "nameserver "
<< Data.DNS2
<< " # profile "
- << removeSpaces( connection()->name() )
+ << removeSpaces( networkSetup()->name() )
<<oendl;
}
}
return 1;
}
bool AGPRSDevice::openFile( SystemFile & SF ) {
if( SF.name() == "peers" ) {
SF.setPath(
QString( "/etc/ppp/peers/" ) +
- removeSpaces( connection()->name() )
+ removeSpaces( networkSetup()->name() )
);
return 1;
} else if ( SF.name() == "chatscripts" ) {
SF.setPath(
QString( "/etc/chatscripts/" ) +
- removeSpaces( connection()->name() )
+ removeSpaces( networkSetup()->name() )
);
return 1;
} else if ( SF.name() == "extra" ) {
SF.setPath(
QString( "/etc/ppp/" ) +
- removeSpaces( connection()->name() ) + ".fixed"
+ removeSpaces( networkSetup()->name() ) + ".fixed"
);
return 1;
}
return 0;
}
diff --git a/noncore/settings/networksettings2/gprs/GPRSrun.cpp b/noncore/settings/networksettings2/gprs/GPRSrun.cpp
index cccc71a..fd61f3a 100644
--- a/noncore/settings/networksettings2/gprs/GPRSrun.cpp
+++ b/noncore/settings/networksettings2/gprs/GPRSrun.cpp
@@ -1,105 +1,105 @@
#include <sys/types.h>
#include <signal.h>
#include <errno.h>
#include <qdir.h>
#include <system.h>
#include <resources.h>
#include <netnode.h>
#include "GPRSrun.h"
State_t GPRSRun::detectState( void ) {
// is pppd still running ?
// is rfcomm still active
- NodeCollection * NC = nodeCollection();
+ NetworkSetup * NC = networkSetup();
InterfaceInfo * I = NC->assignedInterface();
QDir D("/var/run");
if( I ) {
// has some pppx attached
return ( I->IsUp ) ? IsUp : Available;
}
// check ppp itself and figure out interface
odebug << "Check for ppp " << NC->name() << oendl;
if( D.exists( QString("ppp-")+removeSpaces(NC->name())+".pid") ) {
// get pid and check if pppd is still running
QFile F( D.path()+"/ppp-"+removeSpaces(NC->name())+".pid");
odebug << "PPP PID " << F.name() << oendl;
if( F.open( IO_ReadOnly ) ) {
QTextStream TS(&F);
QString X = TS.readLine();
PPPPid = X.toULong();
int rv;
rv = ::kill( PPPPid, 0 );
if( rv == 0 ||
( rv < 0 && errno == EPERM )
) {
// pppd is still up
X = TS.readLine();
I = NSResources->system().findInterface(X);
odebug << "ppp running : IFace " << X << " = " << (long)I << oendl;
if( I ) {
NC->assignInterface( I );
return (I->IsUp) ? IsUp : Available;
}
return Available;
} else {
// pppd is down
PPPPid = 0;
}
} // else pppd is down
}
NC->assignInterface( 0 );
return Unknown;
}
-QString GPRSRun::setMyState( NodeCollection * NC, Action_t A , bool ) {
+QString GPRSRun::setMyState( NetworkSetup * NC, Action_t A , bool ) {
if( A == Up ) {
// start ppp on deviceFile
QStringList SL;
SL << "pon"
<< removeSpaces( NC->name() )
<< NC->device()->deviceFile();
if( ! NSResources->system().execAsUser( SL ) ) {
return QString("Cannot start pppd for %1").arg(NC->name());
}
} else if ( A == Down ) {
if( PPPPid == 0 ) {
detectState();
}
if( PPPPid ) {
QStringList SL;
SL << "poff"
<< removeSpaces( NC->name() );
if( ! NSResources->system().execAsUser( SL ) ) {
return QString("Cannot terminate pppd for %1").arg(NC->name());
}
NC->assignInterface( 0 );
odebug << "ppp stopped " << oendl;
PPPPid = 0;
}
}
return QString();
}
bool GPRSRun::handlesInterface( const QString & S ) {
return Pat.match( S ) >= 0;
}
bool GPRSRun::handlesInterface( InterfaceInfo * I ) {
return handlesInterface( I->Name );
}
diff --git a/noncore/settings/networksettings2/gprs/GPRSrun.h b/noncore/settings/networksettings2/gprs/GPRSrun.h
index 817f8a9..c3c2015 100644
--- a/noncore/settings/networksettings2/gprs/GPRSrun.h
+++ b/noncore/settings/networksettings2/gprs/GPRSrun.h
@@ -1,34 +1,34 @@
#include <netnode.h>
#include <qregexp.h>
#include "GPRSdata.h"
class GPRSRun : public RuntimeInfo {
public :
GPRSRun( ANetNodeInstance * NNI,
GPRSData & D ) : RuntimeInfo( NNI ),
Pat( "ppp[0-9]" ) {
PPPPid = 0;
}
bool handlesInterface( const QString & I );
bool handlesInterface( InterfaceInfo * );
virtual RuntimeInfo * device( void )
{ return this; }
virtual RuntimeInfo * connection( void )
{ return this; }
State_t detectState( void );
protected :
- QString setMyState( NodeCollection * , Action_t, bool );
+ QString setMyState( NetworkSetup * , Action_t, bool );
private :
QRegExp Pat;
size_t PPPPid;
};
diff --git a/noncore/settings/networksettings2/irda/irdarun.h b/noncore/settings/networksettings2/irda/irdarun.h
index d3b714b..e5ba79a 100644
--- a/noncore/settings/networksettings2/irda/irdarun.h
+++ b/noncore/settings/networksettings2/irda/irdarun.h
@@ -1,25 +1,25 @@
#include <netnode.h>
#include "irdadata.h"
class IRDARun : public RuntimeInfo {
public :
IRDARun( ANetNodeInstance * NNI,
IRDAData & Data ) : RuntimeInfo( NNI )
{ }
virtual RuntimeInfo * line( void )
{ return this; }
virtual QString deviceFile( void )
{ return QString( "/dev/irda" ); }
State_t detectState( void )
{ return Unknown; }
protected :
- QString setMyState( NodeCollection * , Action_t, bool )
+ QString setMyState( NetworkSetup * , Action_t, bool )
{ return QString(); }
};
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.cpp b/noncore/settings/networksettings2/lancard/lancardrun.cpp
index 8157dce..8a71aa9 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.cpp
+++ b/noncore/settings/networksettings2/lancard/lancardrun.cpp
@@ -1,148 +1,148 @@
#include <qfile.h>
#include <qtextstream.h>
#include <qstringlist.h>
#include <resources.h>
#include "lancardrun.h"
State_t LanCardRun::detectState( void ) {
// unavailable : no card found
// available : card found and assigned to us or free
// up : card found and assigned to us and up
- NodeCollection * NC = nodeCollection();
+ NetworkSetup * NC = networkSetup();
QString S = QString( "/tmp/profile-%1.up" ).
arg( NC->number());
System & Sys = NSResources->system();
InterfaceInfo * Run;
QFile F( S );
if( F.open( IO_ReadOnly ) ) {
// could open file -> read interface and assign
QString X;
QTextStream TS(&F);
X = TS.readLine();
// find interface
if( handlesInterface( X ) ) {
for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
It.current();
++It ) {
Run = It.current();
if( X == Run->Name ) {
NC->assignInterface( Run );
return (Run->IsUp) ? IsUp : Available;
}
}
}
}
if( ( Run = NC->assignedInterface() ) ) {
// we already have an interface assigned -> still present ?
if( ! Run->IsUp ) {
// usb is still free -> keep assignment
return Available;
} // else interface is up but NOT us -> some other profile
}
// nothing (valid) assigned to us
NC->assignInterface( 0 );
// find possible interface
for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
It.current();
++It ) {
Run = It.current();
if( handlesInterface( *Run ) &&
( Run->CardType == ARPHRD_ETHER
#ifdef ARPHRD_IEEE1394
|| Run->CardType == ARPHRD_IEEE1394
#endif
) &&
! Run->IsUp
) {
// proper type, and Not UP -> free
return Off;
}
}
// no free found
return Unavailable;
}
-QString LanCardRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
+QString LanCardRun::setMyState( NetworkSetup * NC, Action_t A, bool ) {
if( A == Activate ) {
InterfaceInfo * N = getInterface();
if( ! N ) {
// no interface available
NC->setCurrentState( Unavailable );
return tr("No interface found");
}
// because we were OFF the interface
// we get back is NOT assigned
NC->assignInterface( N );
NC->setCurrentState( Available );
return QString();
}
if( A == Deactivate ) {
NC->assignInterface( 0 );
NC->setCurrentState( Off );
}
return QString();
}
// 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 ) &&
( Run->CardType == ARPHRD_ETHER
#ifdef ARPHRD_IEEE1394
|| Run->CardType == ARPHRD_IEEE1394
#endif
)
) {
// this is a LAN card
- if( Run->assignedConnection() == netNode()->connection() ) {
+ if( Run->assignedToNetworkSetup() == netNode()->networkSetup() ) {
// assigned to us
return Run;
- } else if( Run->assignedConnection() == 0 ) {
+ } else if( Run->assignedToNetworkSetup() == 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 57ef3fb..dfd3d62 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.h
+++ b/noncore/settings/networksettings2/lancard/lancardrun.h
@@ -1,37 +1,37 @@
#ifndef LANCARDRUN_H
#define LANCARDRUN_H
#include <netnode.h>
#include <qregexp.h>
#include "lancarddata.h"
class LanCardRun : public RuntimeInfo {
public :
LanCardRun( ANetNodeInstance * NNI,
LanCardData & D ) : RuntimeInfo( NNI ),
Pat( "eth[0-9]" ) {
Data = &D;
}
virtual RuntimeInfo * device( void )
{ return this; }
bool handlesInterface( const QString & I );
bool handlesInterface( const InterfaceInfo & II );
State_t detectState( void );
protected :
- QString setMyState( NodeCollection * , Action_t, bool );
+ QString setMyState( NetworkSetup * , Action_t, bool );
private :
InterfaceInfo * getInterface( void );
QRegExp Pat;
LanCardData * Data;
};
#endif
diff --git a/noncore/settings/networksettings2/modem/modemrun.h b/noncore/settings/networksettings2/modem/modemrun.h
index eb3a193..df6b370 100644
--- a/noncore/settings/networksettings2/modem/modemrun.h
+++ b/noncore/settings/networksettings2/modem/modemrun.h
@@ -1,25 +1,25 @@
#include <netnode.h>
#include "modemdata.h"
class ModemRun : public RuntimeInfo {
public :
ModemRun( ANetNodeInstance * NNI,
ModemData & Data ) : RuntimeInfo ( NNI )
{ }
virtual RuntimeInfo * line( void )
{ return this; }
virtual QString deviceFile( void )
{ return QString("/dev/modem"); }
State_t detectState( void )
{ return Unknown;}
protected :
- QString setMyState( NodeCollection * , Action_t, bool )
+ QString setMyState( NetworkSetup * , Action_t, bool )
{ return QString(); }
};
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp
index 2fa31bd..80a7fac 100644
--- a/noncore/settings/networksettings2/network/network_NN.cpp
+++ b/noncore/settings/networksettings2/network/network_NN.cpp
@@ -1,95 +1,95 @@
#include <qpe/qpeapplication.h>
#include <resources.h>
#include <netnode.h>
#include "network_NN.h"
#include "network_NNI.h"
#include "netnodeinterface.h"
static const char * NetworkNeeds[] =
{ "device",
0
};
static const char * NetworkProvides[] =
- { "connection",
+ { "NetworkSetup",
0
};
/**
* Constructor, find all of the possible interfaces
*/
NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) {
NSResources->addSystemFile(
"interfaces", "/etc/network/interfaces", 1 );
}
/**
* 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 );
}
bool NetworkNetNode::hasDataForFile( SystemFile & S ) {
return S.name() == "interfaces";
}
short NetworkNetNode::generateFile( SystemFile & SF,
ANetNodeInstance * NNI,
long DevNr ) {
if( DevNr < 0 ) {
// generate device specific but common part
return 1;
}
QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
if( SF.name() == "interfaces" ) {
Log(("Generate entry for %s in %s\n", NIC.latin1(), SF.name().latin1() ));
// generate mapping stanza for this interface
SF << "# check if "
<< NIC
<< " can be brought UP"
<< endl;
SF << "mapping "
<< NIC
<< endl;
SF << " script "
<< QPEApplication::qpeDir()
<< "bin/networksettings2-request"
<< endl
<< endl;
return 0;
}
return 1;
}
const char ** NetworkNetNode::needs( void ) {
return NetworkNeeds;
}
const char ** NetworkNetNode::provides( void ) {
return NetworkProvides;
}
void NetworkNetNode::setSpecificAttribute( QString & , QString & ) {
}
void NetworkNetNode::saveSpecificAttribute( QTextStream & ) {
}
OPIE_NS2_PLUGIN( NetNodeInterface_T<NetworkNetNode> )
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp
index 34dac54..c183d5e 100644
--- a/noncore/settings/networksettings2/network/network_NNI.cpp
+++ b/noncore/settings/networksettings2/network/network_NNI.cpp
@@ -1,218 +1,218 @@
#include <system.h>
#include <netnode.h>
#include "networkedit.h"
#include "network_NNI.h"
#include "network_NN.h"
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::hasDataForFile( SystemFile & S ) {
return S.name() == "interfaces";
}
short ANetwork::generateFile( SystemFile &SF,
long DevNr
) {
short rvl, rvd ;
QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
rvl = 1;
if( SF.name() == "interfaces" ) {
Log(("Generate Network for %s\n", SF.name().latin1() ));
// we can safely call from here since device item is deeper
if( Data.UseDHCP ) {
SF << "iface "
<< "A"
- << connection()->number()
+ << networkSetup()->number()
<< NIC
<< " inet dhcp"
<< endl;
SF << " up echo \""
<< NIC
<< "\" > /tmp/profile-"
- << connection()->number()
+ << networkSetup()->number()
<< ".up"
<< endl;
if( Data.SendHostname ) {
SF << " hostname "
<< Data.Hostname
<< endl;
}
SF << " down rm -f /tmp/profile-"
- << connection()->number()
+ << networkSetup()->number()
<< ".up"
<< endl;
} else {
SF << "iface "
<< "A"
- << connection()->number()
+ << networkSetup()->number()
<< NIC
<< " inet static"
<< endl;
SF << " up echo \""
<< NIC
<< "\" > /tmp/profile-"
- << connection()->number()
+ << networkSetup()->number()
<< ".up"
<< endl;
SF << " down rm -f /tmp/profile-"
- << connection()->number()
+ << networkSetup()->number()
<< ".up"
<< endl;
SF << " address "
<< Data.IPAddress
<< endl;
SF << " broadcast "
<< Data.Broadcast
<< endl;
SF << " 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() );
SF << " network "
<< NW
<< endl;
}
}
for ( QStringList::Iterator it = Data.PreUp_SL.begin();
it != Data.PreUp_SL.end();
++it ) {
SF << " pre-up "
<< (*it)
<< endl;
}
for ( QStringList::Iterator it = Data.PostUp_SL.begin();
it != Data.PostUp_SL.end();
++it ) {
SF << " up "
<< (*it)
<< endl;
}
for ( QStringList::Iterator it = Data.PreDown_SL.begin();
it != Data.PreDown_SL.end();
++it ) {
SF << " down "
<< (*it)
<< endl;
}
for ( QStringList::Iterator it = Data.PostDown_SL.begin();
it != Data.PostDown_SL.end();
++it ) {
SF << " post-down "
<< (*it)
<< endl;
}
rvl = 0;
}
// embed other info in it
- rvd = connection()->getToplevel()->generateFileEmbedded( SF, DevNr );
+ rvd = networkSetup()->getToplevel()->generateFileEmbedded( SF, DevNr );
return (rvd == 2 || rvl == 2 ) ? 2 :
(rvd == 0 || rvl == 0 ) ? 0 : 1;
}
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp
index 74467ad..7039a36 100644
--- a/noncore/settings/networksettings2/network/networkrun.cpp
+++ b/noncore/settings/networksettings2/network/networkrun.cpp
@@ -1,51 +1,50 @@
#include <system.h>
#include <netnode.h>
#include <resources.h>
#include "networkrun.h"
State_t NetworkRun::detectState( void ) {
- InterfaceInfo * II = nodeCollection()->assignedInterface();
+ InterfaceInfo * II = networkSetup()->assignedInterface();
- Log(( "Interface %p %p : %d\n", II, nodeCollection(), (II) ? II->IsUp : 0 ));
if( II && II->IsUp ) {
// device has assigned interface
return IsUp;
}
// had no interface or interface is no longer up -> release
- nodeCollection()->assignInterface( 0 );
+ networkSetup()->assignInterface( 0 );
return Unknown;
}
-QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
+QString NetworkRun::setMyState( NetworkSetup * NC, Action_t A, bool ) {
// we handle UP and DOWN
InterfaceInfo * II = NC->assignedInterface();
if( ! II ) {
Log(( "no interface assigned." ));
return QString();
}
QStringList SL;
if( A == Up ) {
// we can bring UP if lower level is available
SL << "ifup";
} else if( A == Down ) {
SL << "ifdown";
} else {
return QString();
}
SL << QString().sprintf( "%s=A%ld%s",
II->Name.latin1(),
- nodeCollection()->number(),
+ networkSetup()->number(),
II->Name.latin1() );
if( ! NSResources->system().runAsRoot( SL ) ) {
return QString("Cannot call %1").arg(SL.join(" "));
}
return QString();
}
diff --git a/noncore/settings/networksettings2/network/networkrun.h b/noncore/settings/networksettings2/network/networkrun.h
index 78a1694..ac186e7 100644
--- a/noncore/settings/networksettings2/network/networkrun.h
+++ b/noncore/settings/networksettings2/network/networkrun.h
@@ -1,20 +1,20 @@
#include <netnode.h>
#include "networkdata.h"
class NetworkRun : public RuntimeInfo {
public :
NetworkRun( ANetNodeInstance * NNI,
NetworkData & Data ) : RuntimeInfo( NNI )
{ }
virtual RuntimeInfo * connection( void )
{ return this; }
State_t detectState( void );
protected :
- QString setMyState( NodeCollection * , Action_t, bool );
+ QString setMyState( NetworkSetup * , Action_t, bool );
};
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index 78b6cce..80dcb3d 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -1,510 +1,510 @@
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <opie2/odebug.h>
#include <opie2/oledbox.h>
#include <qpe/qpeapplication.h>
#include <qlistbox.h>
#include <qlayout.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 <qevent.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" ) );
GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) );
Disable_TB->setPixmap( NSResources->getPixmap( "disabled" ) );
Up_TB->setPixmap( NSResources->getPixmap( "more" ) );
Down_TB->setPixmap( NSResources->getPixmap( "less" ) );
QVBoxLayout* V = new QVBoxLayout( LED_Frm );
QHBoxLayout * H = new QHBoxLayout( 0 );
V->addStretch(1);
V->addLayout( H );
Leds[0] = new Opie::Ui::OLedBox( red, LED_Frm );
H->addWidget( Leds[0], 0, Qt::AlignVCenter );
Leds[1] = new Opie::Ui::OLedBox( red, LED_Frm );
H->addWidget( Leds[1], 0, Qt::AlignVCenter );
Leds[2] = new Opie::Ui::OLedBox( red, LED_Frm );
H->addWidget( Leds[2], 0, Qt::AlignVCenter );
V->addStretch(1);
SLOT_ToProfile();
// populate main Listbox
Profiles_LB->clear();
QPEApplication::setStylusOperation(
Profiles_LB->viewport(), QPEApplication::RightOnHold );
connect( Profiles_LB,
SIGNAL(rightButtonPressed(QListBoxItem*,const QPoint&)),
this, SLOT(SLOT_EditNode(QListBoxItem*)) );
- { Name2Connection_t & M = NSResources->connections();
- NodeCollection * NC;
- // for all connections
- for( QDictIterator<NodeCollection> it(M);
+ { Name2NetworkSetup_t & M = NSResources->networkSetups();
+ NetworkSetup * NC;
+ // for all NetworkSetups
+ for( QDictIterator<NetworkSetup> 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 ) {
+ if( NSResources->networkSetups().count() == 0 ) {
QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) );
}
connect( &(NSResources->system()),
SIGNAL( stdoutLine(const QString &) ),
this, SLOT( SLOT_CmdMessage(const QString &) ) );
connect( &(NSResources->system()),
SIGNAL( stderrLine(const QString &) ),
this, SLOT( SLOT_CmdMessage(const QString &) ) );
connect( &(NSResources->system()),
SIGNAL( processEvent(const QString &) ),
this, SLOT( SLOT_CmdMessage(const QString &) ) );
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;
if( NSD.isModified() ) {
S = NSD.saveSettings();
if( ! S.isEmpty() ) {
S.insert( 0, "<p>" );
S.append( "</p>" );
// problem saving
QMessageBox::warning(
0,
tr( "Saving setup" ), S );
}
SLOT_GenerateConfig();
NSD.setModified( 0 );
}
}
void NetworkSettings::SLOT_CmdMessage( const QString & S ) {
Messages_LB->insertItem( S );
Messages_LB->setCurrentItem( Messages_LB->count()-1 );
Messages_LB->ensureCurrentVisible();
}
void NetworkSettings::SLOT_RefreshStates( void ) {
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember
if( LBI ) {
- NodeCollection * NC;
+ NetworkSetup * NC;
NSResources->system().probeInterfaces();
// update current selection only
- NC = NSResources->findConnection( LBI->text() );
+ NC = NSResources->findNetworkSetup( 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;
+ NetworkSetup * NC;
for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) {
- NC = NSResources->findConnection( Profiles_LB->text(i) );
+ NC = NSResources->findNetworkSetup( 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() );
+ NSResources->removeNetworkSetup( LBI->text() );
delete LBI;
NSD.setModified( 1 );
}
}
void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
QString OldName = "";
- EditConnection EC( this );
+ EditNetworkSetup EC( this );
if( LBI ) {
- NodeCollection * NC = NSResources->findConnection( LBI->text() );
+ NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() );
if( ! NC ) {
return;
}
OldName = NC->name();
- EC.setConnection( NC );
+ EC.setNetworkSetup( 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();
+ NetworkSetup * NC = EC.networkSetup();
if( NC->isModified() ) {
if( LBI ) {
if( NC->name() != OldName ) {
// find if new name is free
- NodeCollection * LCN = NSResources->findConnection(
+ NetworkSetup * LCN = NSResources->findNetworkSetup(
NC->name() );
if( LCN ) {
QMessageBox::warning(
0,
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, 0 );
+ NSResources->removeNetworkSetup( OldName );
+ NSResources->addNetworkSetup( NC, 0 );
} // 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, 0 );
- NC->setNumber( NSResources->assignConnectionNumber() );
+ NSResources->addNetworkSetup( NC, 0 );
+ NC->setNumber( NSResources->assignNetworkSetupNumber() );
Profiles_LB->insertItem( NC->devicePixmap(), NC->name() );
Profiles_LB->setSelected( ci, TRUE );
}
updateProfileState( LBI );
}
} else {
- // cancelled : reset connection
+ // cancelled : reset NetworkSetup
if( LBI ) {
- NodeCollection * NC = NSResources->findConnection( LBI->text() );
+ NetworkSetup * NC = NSResources->findNetworkSetup( 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() );
+ NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() );
if( NC->description().isEmpty() ) {
Description_LBL->setText( tr( "<<No description>>" ) );
} else {
Description_LBL->setText( NC->description() );
}
Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() );
bool FrmActive = 1;
bool IsEnabled = 1;
int leds = 0;
switch( NC->state() ) {
case Disabled : // no further work
IsEnabled = 0;
FrmActive = 0;
break;
case Unknown :
case Unchecked :
case Unavailable :
FrmActive = 0;
break;
case Off :
leds = 1;
break;
case Available :
leds = 2;
break;
case IsUp :
leds = 3;
break;
}
Disable_TB->setOn( ! IsEnabled );
LED_Frm->setEnabled( FrmActive );
for( int i = 0 ; i < leds; i ++ ) {
Leds[i]->setColor( red );
Leds[i]->setOn( true );
}
for( int i = leds ; i < 3; i ++ ) {
Leds[i]->setColor( red );
Leds[i]->setOn( false );
}
Up_TB->setEnabled( leds < 3 && leds != 0 );
Down_TB->setEnabled( leds > 0 );
}
void NetworkSettings::SLOT_CheckState( void ) {
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
if ( ! LBI )
return;
updateProfileState( LBI );
}
void NetworkSettings::updateProfileState( QListBoxItem * LBI ) {
if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) {
SLOT_ShowNode( LBI );
}
}
void NetworkSettings::SLOT_GenerateConfig( void ) {
QString S = NSD.generateSettings();
if( ! S.isEmpty() ) {
S.insert( 0, "<p>" );
S.append( "</p>" );
QMessageBox::warning(
0,
tr( "Generate config" ),
S);
}
}
void NetworkSettings::SLOT_Disable( bool T ) {
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
QString Msg;
if ( ! LBI )
return;
- NodeCollection * NC = NSResources->findConnection( LBI->text() );
+ NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() );
Log(( "Prepare to %sable\n", (T) ? "en" : "dis" ));
Msg = NC->setState( (T) ? Disable : Enable );
if( ! Msg.isEmpty() ) {
Msg.insert( 0, "<p>" );
Msg.append( "</p>" );
QMessageBox::warning(
0,
tr( "Activating profile" ),
Msg );
return;
}
// reload new state
NC->state( true );
updateProfileState( LBI );
}
void NetworkSettings::SLOT_Up( void ) {
// bring more up
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
QString Msg;
int led = -1;
if ( ! LBI )
return;
- NodeCollection * NC =
- NSResources->findConnection( LBI->text() );
+ NetworkSetup * NC =
+ NSResources->findNetworkSetup( LBI->text() );
switch( NC->state() ) {
case Disabled : // cannot modify this state
case Unknown : // cannot modify this state
case Unchecked : // cannot modify this state
case Unavailable : // cannot modify this state
case IsUp : // highest UP state
return;
case Off : // -> activate
led = 1;
Down_TB->setEnabled( true );
Log(( "Activate interface %s\n", NC->name().latin1() ));
Msg = NC->setState( Activate );
break;
case Available : // -> up
led = 2;
Log(( "Bring up interface %s\n", NC->name().latin1() ));
Msg = NC->setState( Up );
if( Msg.isEmpty() ) {
Up_TB->setEnabled( false );
}
break;
}
if( ! Msg.isEmpty() ) {
Msg.insert( 0, "<p>" );
Msg.append( "</p>" );
QMessageBox::warning(
0,
tr( "Increase availability" ),
Msg );
return;
}
updateProfileState( LBI );
// set color of led we should change
if( led > 0 ) {
Leds[led]->setColor( blue );
Leds[led]->setOn( true );
}
}
void NetworkSettings::SLOT_Down( void ) {
// bring more down
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
int led = -1;
QString Msg;
if ( ! LBI )
return;
- NodeCollection * NC =
- NSResources->findConnection( LBI->text() );
+ NetworkSetup * NC =
+ NSResources->findNetworkSetup( LBI->text() );
switch( NC->state() ) {
case Disabled : // cannot modify this state
case Unknown : // cannot modify this state
case Unchecked : // cannot modify this state
case Unavailable : // cannot modify this state
case Off : // highest DOWN state
break;
case Available : // -> down
led = 0;
Log(( "Deactivate interface %s\n", NC->name().latin1() ));
Msg = NC->setState( Deactivate );
Down_TB->setEnabled( false );
break;
case IsUp : // highest UP state
led = 1;
Up_TB->setEnabled( true );
Log(( "Bring down interface %s\n", NC->name().latin1() ));
Msg = NC->setState( Down, 1 );
if( Msg.isEmpty() ) {
// remove 'up' file to make sure
unlink ( QString().sprintf( "/tmp/Profile-%d.up", NC->number() ).latin1() );;
}
break;
}
if( ! Msg.isEmpty() ) {
Msg.insert( 0, "<p>" );
Msg.append( "</p>" );
QMessageBox::warning(
0,
tr( "Decrease availability" ),
Msg );
return;
}
updateProfileState( LBI );
// set color of led we should change
if( led >= 0 ) {
Leds[led]->setColor( blue );
}
}
void NetworkSettings::SLOT_ToMessages( void ) {
Profiles_LB->hide();
Profile_GB->hide();
Messages_GB->show();
}
void NetworkSettings::SLOT_ToProfile( void ) {
Profiles_LB->show();
Profile_GB->show();
Messages_GB->hide();
}
void NetworkSettings::SLOT_QCopMessage(const QCString &msg, const QByteArray &data) {
QDataStream stream( data, IO_ReadOnly );
if( msg == "raise" ) {
raise();
return;
} /* if ( msg == "someMessage(int,int,int)" ) {
int a,b,c;
stream >> a >> b >> c;
...
} */
}
diff --git a/noncore/settings/networksettings2/networksettings2/asconnection.h b/noncore/settings/networksettings2/networksettings2/asconnection.h
index 1ed7e74..eeb0939 100644
--- a/noncore/settings/networksettings2/networksettings2/asconnection.h
+++ b/noncore/settings/networksettings2/networksettings2/asconnection.h
@@ -1,18 +1,18 @@
#ifndef ASCONNECTION_H
#define ASCONNECTION_H
#include <resources.h>
// pure virtual (component oriented) interface of any
-// plugin that offers a connection
-class AsConnection : public RuntimeInfo {
+// plugin that offers a networkSetup
+class AsNetworkSetup : public RuntimeInfo {
public :
- AsConnection( ANetNodeInstance * NNI ) :
+ AsNetworkSetup( ANetNodeInstance * NNI ) :
RuntimeInfo( NNI ) {
}
};
#endif
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp
index f00e0b3..0ab0e5b 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.cpp
+++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp
@@ -1,519 +1,528 @@
#include <time.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpainter.h>
#include <qbitmap.h>
#include <qtextstream.h>
#include <qpixmap.h>
#include "resources.h"
#include "netnode.h"
static char * ActionName[] = {
"Disable",
"Enable",
"Activate",
"Deactivate",
"Up",
"Down"
};
static char * StateName[] = {
"Unchecked",
"Unknown",
"Unavailable",
"Disabled",
"Off",
"Available",
"IsUp"
};
QString & deQuote( QString & X ) {
if( X[0] == '"' ) {
// remove end and trailing "" and \x -> x
QChar R;
long idx;
idx = X.length()-1;
X = X.mid( 1, idx );
idx = 0;
while( ( idx = X.find( '\\', idx ) ) >= 0 ) {
R = X.at( idx + 1 );
X.replace( idx, 2, &R, 1 );
}
X = X.left( X.length()-1 );
}
return X;
}
QString quote( QString X ) {
if( X.find( QRegExp( "[ \n\"\\\t]" ) ) >= 0 ) {
// need to quote this
QString OutString = "\"";
X.replace( QRegExp("\""), "\\\"" );
X.replace( QRegExp("\\"), "\\\\" );
X.replace( QRegExp(" "), "\\ " );
OutString += X;
OutString += "\"";
X = OutString;
}
return X;
}
//
//
// ANETNODE
//
//
void ANetNode::saveAttributes( QTextStream & TS ) {
saveSpecificAttribute( TS );
}
void ANetNode::setAttribute( QString & Attr, QString & Value ){
setSpecificAttribute( Attr, Value );
}
bool ANetNode::isToplevel( void ) {
const char ** P = provides();
while( *P ) {
if( strcmp( *P, "fullsetup") == 0 )
return 1;
P ++;
}
return 0;
}
bool ANetNode::openFile( SystemFile & SF,
ANetNodeInstance * NNI ) {
return (NNI ) ? NNI->openFile( SF ) : 0 ;
}
//
//
// 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->name() );
setName( N.latin1() );
}
void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){
if( Attr == "__name" ) {
setName( Value.latin1() );
} else {
setSpecificAttribute( Attr, Value );
}
}
void ANetNodeInstance::saveAttributes( QTextStream & TS ) {
TS << "__name=" << name() << endl;
saveSpecificAttribute( TS );
}
ANetNodeInstance * ANetNodeInstance::nextNode( void ) {
- return connection()->findNext( this );
+ return networkSetup()->findNext( this );
}
//
//
// NODECOLLECTION
//
//
-NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() {
+NetworkSetup::NetworkSetup( void ) : QList<ANetNodeInstance>() {
IsModified = 0;
Index = -1;
Name="";
IsNew = 1;
CurrentState = Unchecked;
AssignedInterface = 0;
Number = -1;
Done = 0;
}
-NodeCollection::NodeCollection( QTextStream & TS, bool & Dangling ) :
+NetworkSetup::NetworkSetup( QTextStream & TS, bool & Dangling ) :
QList<ANetNodeInstance>() {
long idx;
QString S, A, N;
Number = -1;
Done = 0;
IsModified = 0;
Index = -1;
Name="";
IsNew = 0;
AssignedInterface = 0;
CurrentState = Unchecked;
Dangling = 0; // by default node collection is ok
do {
S = TS.readLine();
if( S.isEmpty() ) {
// 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 );
Log(( "Find node %s : %p\n", N.latin1(), NNI ));
if( NNI ) {
append( NNI );
} else {
// could not find a node type -> collection invalid
- Log(( "Node %s missing -> connection dangling\n",
+ Log(( "Node %s missing -> NetworkSetup dangling\n",
N.latin1() ));
// create placeholder for this dangling NNI
NNI = new ErrorNNI( N );
Dangling = 1;
}
}
} while( 1 );
Log(( "Profile number %s : %d nodes\n",
Name.latin1(), count() ));
}
-NodeCollection::~NodeCollection( void ) {
+NetworkSetup::~NetworkSetup( void ) {
}
-const QString & NodeCollection::description( void ) {
+const QString & NetworkSetup::description( void ) {
ANetNodeInstance * NNI = getToplevel();
return (NNI) ? NNI->runtime()->description() : Name;
}
-void NodeCollection::append( ANetNodeInstance * NNI ) {
- NNI->setConnection( this );
+void NetworkSetup::append( ANetNodeInstance * NNI ) {
+ NNI->setNetworkSetup( this );
QList<ANetNodeInstance>::append( NNI );
}
-void NodeCollection::save( QTextStream & TS ) {
+void NetworkSetup::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=" << NNI->name() << endl;
}
TS << endl;
IsNew = 0;
}
-ANetNodeInstance * NodeCollection::getToplevel( void ) {
+ANetNodeInstance * NetworkSetup::getToplevel( void ) {
ANetNodeInstance * NNI = 0;
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
NNI = it.current();
if( NNI->nodeClass()->isToplevel() ) {
return NNI;
}
}
return 0;
}
-ANetNodeInstance * NodeCollection::findByName( const QString & S ) {
+ANetNodeInstance * NetworkSetup::findByName( const QString & S ) {
ANetNodeInstance * NNI = 0;
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
NNI = it.current();
if( NNI->name() == S ) {
return NNI;
}
}
return 0;
}
-ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) {
+ANetNodeInstance * NetworkSetup::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,
+int NetworkSetup::compareItems( QCollection::Item I1,
QCollection::Item I2 ) {
ANetNodeInstance * NNI1, * NNI2;
NNI1 = (ANetNodeInstance *)I1;
NNI2 = (ANetNodeInstance *)I2;
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 ) {
+QPixmap NetworkSetup::devicePixmap( void ) {
QPixmap pm = NSResources->getPixmap(
getToplevel()->nextNode()->pixmapName()+"-large");
QPixmap Mini = NSResources->getPixmap(
device()->netNode()->pixmapName() );
if( pm.isNull() || Mini.isNull() )
return Resource::loadPixmap("Unknown");
QPainter painter( &pm );
painter.drawPixmap( pm.width()-Mini.width(),
pm.height()-Mini.height(),
Mini );
pm.setMask( pm.createHeuristicMask( TRUE ) );
return pm;
}
-QPixmap NodeCollection::statePixmap( State_t S) {
+QPixmap NetworkSetup::statePixmap( State_t S) {
return NSResources->getPixmap( State2PixmapTbl[S] );
}
-QString NodeCollection::stateName( State_t S) {
+QString NetworkSetup::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", "Inactive");
case Available :
return qApp->translate( "networksettings2", "Available");
case IsUp :
return qApp->translate( "networksettings2", "Up");
case Unchecked : /* FT */
default :
break;
}
return QString("");
}
-void NodeCollection::reassign( void ) {
+void NetworkSetup::reassign( void ) {
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
- it.current()->setConnection( this );
+ it.current()->setNetworkSetup( this );
}
}
-const QStringList & NodeCollection::triggers() {
+const QStringList & NetworkSetup::triggers() {
return getToplevel()->runtime()->triggers();
}
-bool NodeCollection::hasDataForFile( SystemFile & S ) {
+bool NetworkSetup::hasDataForFile( SystemFile & S ) {
return ( firstWithDataForFile( S ) != 0 );
}
-ANetNodeInstance * NodeCollection::firstWithDataForFile( SystemFile & S ) {
+ANetNodeInstance * NetworkSetup::firstWithDataForFile( SystemFile & S ) {
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
if( it.current()->hasDataForFile( S ) ) {
return it.current();
}
}
return 0;
}
-State_t NodeCollection::state( bool Update ) {
+State_t NetworkSetup::state( bool Update ) {
State_t NodeState;
if( CurrentState == Unchecked || Update ) {
// collect states of all nodes until with get the 'higest'
// state possible
- Log(( "Connection %s state %s\n",
+ Log(( "NetworkSetup %s state %s\n",
Name.latin1(), StateName[CurrentState] ));
CurrentState = Unknown;
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
Log(( "-> Detect %s\n", it.current()->name() ));
NodeState = it.current()->runtime()->detectState();
Log(( " state %s\n", StateName[NodeState] ));
if( NodeState == Disabled ||
NodeState == IsUp ) {
// max
CurrentState = NodeState;
break;
}
if( NodeState > CurrentState ) {
// higher
CurrentState = NodeState;
}
}
}
return CurrentState;
}
-QString NodeCollection::setState( Action_t A, bool Force ) {
+QString NetworkSetup::setState( Action_t A, bool Force ) {
QString msg;
Action_t Actions[10];
int NoOfActions = 0;
// get current state
state( Force );
switch( A ) {
case Disable :
if( CurrentState < Disabled ) {
// disabled
CurrentState = Disabled;
return QString();
}
if( CurrentState == IsUp ) {
Actions[NoOfActions++] = Down;
Actions[NoOfActions++] = Deactivate;
} else if( CurrentState == Available ) {
Actions[NoOfActions++] = Deactivate;
}
Actions[NoOfActions++] = Disable;
break;
case Enable :
// always possible -> detected state is new state
Actions[NoOfActions++] = Enable;
break;
case Activate :
if( ! Force ) {
if( CurrentState >= Available ) {
// already available
return QString();
}
if( CurrentState != Off ) {
return qApp->translate( "System",
"State should be off" );
}
}
Actions[NoOfActions++] = Activate;
break;
case Deactivate :
if( ! Force ) {
if( CurrentState < Off ) {
// already inactive
return QString();
}
}
if( CurrentState == IsUp ) {
Actions[NoOfActions++] = Down;
}
Actions[NoOfActions++] = Deactivate;
break;
case Up :
if( ! Force ) {
if( CurrentState == IsUp ) {
return QString();
}
if( CurrentState < Off ) {
return qApp->translate( "System",
"State should at least be off" );
}
}
if( CurrentState == Off ) {
Actions[NoOfActions++] = Activate;
}
Actions[NoOfActions++] = Up;
break;
case Down :
if( ! Force ) {
if( CurrentState < Available ) {
// OK
return QString();
}
}
Actions[NoOfActions++] = Down;
break;
}
// send actions to all nodes
Log(( "Action %s requires %d steps\n",
ActionName[A], NoOfActions ));
for( int i = 0 ; i < NoOfActions; i ++ ) {
// setState recurses through the tree depth first
msg = getToplevel()->runtime()->setState( this, Actions[i], Force );
if( ! msg.isEmpty() ) {
return msg;
}
}
return QString();
}
+void NetworkSetup::copyFrom( const NetworkSetup & N ) {
+ Number = N.Number;
+ CurrentState = N.CurrentState;
+ Name = N.Name;
+ IsNew = N.IsNew;
+ Index = N.Index;
+ AssignedInterface = N.AssignedInterface;
+}
+
//
//
// RuntimeInfo
//
//
-QString RuntimeInfo::setState( NodeCollection * NC,
+QString RuntimeInfo::setState( NetworkSetup * NC,
Action_t A,
bool Force ) {
QString M;
RuntimeInfo * Deeper = nextNode();
if( Deeper ) {
// first go deeper
M = Deeper->setState( NC, A, Force );
if( ! M.isEmpty() )
return M;
}
// set my own state
Log (( "-> Act upon %s\n", netNode()->name() ));
M = setMyState( NC, A, Force );
Log (( " result %s\n", M.latin1() ));
return M;
}
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index 151d546..8aebdc0 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -1,638 +1,641 @@
#ifndef NETNODE_H
#define NETNODE_H
#include <qtextstream.h>
#include <qlist.h>
#include <qdict.h>
#include <qpixmap.h>
#include <qstringlist.h>
#include <qobject.h>
#include <time.h>
#include <Utils.h>
#include <system.h>
// difference feature interfaces
class AsDevice;
class AsLine;
-class AsConnection;
+class AsNetworkSetup;
class AsFullSetup;
// needed for plugin creation function
#include <qlist.h>
class ANetNode;
class ANetNodeInstance;
-class NodeCollection;
+class NetworkSetup;
class QTextStream;
class RuntimeInfo;
class InterfaceInfo;
class NSResources;
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
+ // if networkSetup cannot be established e.g. because
// the hardware is not available
Unavailable = 2,
- // if the connection cannot be establishec but NOT
+ // if the networkSetup 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
+ // if networkSetup 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
+ // if networkSetup is available to be used (i.e. the
// devices if fully ready to be used
Available = 5,
- // if connection is being used
+ // if networkSetup is being used
IsUp = 6
} State_t;
typedef enum Action {
// to make the device unavailable functionally -> to disabled
Disable = 0,
// to make the device available functionally -> to off
Enable = 1,
// bring the hardware up -> to Available
Activate = 2,
// bring the hardware down -> to off
Deactivate = 3,
- // bring the connection up -> to IsUp
+ // bring the networkSetup up -> to IsUp
Up = 4,
- // bring the connection down -> to Available
+ // bring the networkSetup down -> to Available
Down = 5
} Action_t;
class ANetNode : public QObject {
public:
typedef QArray<ANetNode *> NetNodeList;
ANetNode( const char * Name ) : QObject( 0, Name ) {}
virtual ~ANetNode(){};
//
//
// standard methods with sensible default
//
//
inline int done( void )
{ return Done; }
inline void setDone( int D )
{ Done = D; }
- // does this Node provide a Connection
+ // does this Node provide a NetworkSetup
bool isToplevel( void );
// set the value of an attribute
void setAttribute( QString & Attr, QString & Value ) ;
void saveAttributes( QTextStream & TS ) ;
// compiled references to 'needed' NetNodes -> needs list
inline void setAlternatives( NetNodeList * Alt )
{ Alternatives = Alt; }
inline NetNodeList & alternatives( void )
{ return *Alternatives; }
//
//
// Virtual methods with sensible default
//
//
// do instances of this noce class have data for this file
virtual bool hasDataForFile( SystemFile & )
{ return 0; }
// open proper file SF identified by S
// this method is called by NS2.
//
// overrule this ONLY if this proper file is a common file
// for all NNI of this node class and the data generated
// by each of the NNI needs to be put in one file
//
// if this is the case the file should be (re)opened in append
// return 0 if file cannot be opened
virtual bool openFile( SystemFile &SF,
ANetNodeInstance * NNI );
// generate instance independent stuff
// 0 : data output, 1 no data, 2 error
virtual short generatePreamble( SystemFile & )
{ return 1; }
// generate instance independent stuff
// 0 : data output, 1 no data, 2 error
virtual short generatePostamble( SystemFile & )
{ return 1; }
// generate instance dependent but instance common stuff
// 0 : data output, 1 no data, 2 error
virtual short generateFile( SystemFile &,
ANetNodeInstance * ,
long )
{ return 1; }
// generate NIC name based on instance nr
// only relevant if node instances are devices
virtual QString genNic( long )
{ return QString(""); }
// max number of instances for this node type
// only relevant if node instances are devices
virtual long instanceCount( void )
{ return 1; }
// return ID list for each file generated specially for
// this node type
virtual QStringList properFiles( void )
{ return QStringList(); }
//
//
// pure virtual methods with sensible default
//
//
// pixmap needed for this NetNode
virtual const QString pixmapName() = 0;
// description for this NetNode
virtual const QString nodeDescription() = 0;
// create a blank instance of a net node
virtual ANetNodeInstance * createInstance( void ) = 0;
// return features this NetNode provides
virtual const char ** provides( void ) = 0;
// return features this NetNode needs
virtual const char ** needs( void ) = 0;
protected :
NetNodeList * Alternatives;
private :
virtual void setSpecificAttribute( QString & , QString & ) = 0;
virtual void saveSpecificAttribute( QTextStream & ) = 0;
int Done;
};
class ANetNodeInstance : public QObject {
public:
ANetNodeInstance( ANetNode * NN ) : QObject()
{ IsModified=0; NodeType = NN; IsNew = TRUE; }
virtual ~ANetNodeInstance( void ) { }
inline int done( void )
{ return Done; }
inline void setDone( int D )
{ Done = D; }
// return data was modified
inline void setModified( bool M )
{ IsModified = M; }
inline bool isModified( void )
{ return IsModified; }
// get next node
ANetNodeInstance * nextNode();
// return NetNode this is an instance of
ANetNode * nodeClass( void )
{ return NodeType; }
// intialize am instance of a net node
void initialize( void );
// set the value of an attribute
void setAttribute( QString & Attr, QString & Value ) ;
void saveAttributes( QTextStream & TS ) ;
// return true if node isntance is NEW and not loaded
inline void setNew( bool IsN )
{ IsNew = IsN; }
inline bool isNew( void )
{ return IsNew; }
// return description for this instance
inline QString & description( void )
{ return Description; }
inline void setDescription( const QString & S )
{ Description = S; }
// pixmap for this instance -> from NetNode
inline const QString pixmapName( void )
{ return NodeType->pixmapName(); }
inline const char ** provides( void )
{ return NodeType->provides(); }
inline const char ** needs( void )
{ return NodeType->needs(); }
- inline void setConnection( NodeCollection * NC )
- { Connection = NC; }
- inline NodeCollection * connection( void )
- { return Connection; }
+ inline void setNetworkSetup( NetworkSetup * NC )
+ { TheNetworkSetup = NC; }
+ inline NetworkSetup * networkSetup( void )
+ { return TheNetworkSetup; }
//
//
// Virtual methods with sensible defaults
//
//
// open proper file identified by S
virtual bool openFile( SystemFile & )
{ return 0; }
// check if this node (or sub nodes) have data for this file
virtual bool hasDataForFile( SystemFile & S )
{ return nodeClass()->hasDataForFile( S ); }
// generate code specific for this node but embedded
// in the section of the parent
// this is called within the code of the parent
virtual short generateFileEmbedded( SystemFile & SF,
long DevNr )
{ ANetNodeInstance * NNI = nextNode();
return (NNI) ? NNI->generateFileEmbedded( SF, DevNr ) : 1;
}
// generate code specific for this node
// (or find the first node that does)
virtual short generateFile( SystemFile & SF,
long DevNr )
{ ANetNodeInstance * NNI = nextNode();
return (NNI) ? NNI->generateFile( SF, DevNr ) : 1;
}
// return true if this node instance is triggered by this trigger
// could be delegated to deeper instances
virtual bool triggeredBy( const QString & )
{ return 0; }
//
//
// Pure virtual functions
//
//
// return runtime information for this node
virtual RuntimeInfo * runtime( void ) = 0;
// create edit widget under parent
virtual QWidget * edit( QWidget * parent ) = 0;
// is given data acceptable
virtual QString acceptable( void ) = 0;
// get data from GUI and store in node
virtual void commit( void ) = 0;
// returns node specific data -> only useful for 'buddy'
virtual void * data( void ) = 0;
protected :
virtual void setSpecificAttribute( QString & , QString & ) = 0;
virtual void saveSpecificAttribute( QTextStream & ) = 0;
ANetNode * NodeType;
- // connection to which this node belongs to
- NodeCollection * Connection;
+ // networkSetup to which this node belongs to
+ NetworkSetup * TheNetworkSetup;
QString Description;
bool IsModified;
// true if this nodeinstance was just created (and not
// loaded from file
bool IsNew;
int Done;
static long InstanceCounter;
};
class ErrorNNI: public ANetNodeInstance {
public:
ErrorNNI( const QString & _Name ) : ANetNodeInstance( 0 ) {
setName( _Name.latin1() );
}
RuntimeInfo * runtime( void ) {
return 0;
}
// create edit widget under parent
QWidget * edit( QWidget * parent ) {
return 0;
}
// is given data acceptable
QString acceptable( void ) {
return QString();
}
// get data from GUI and store in node
void commit( void ) {
}
// returns node specific data -> only useful for 'buddy'
void * data( void ) {
return 0;
}
protected :
void setSpecificAttribute( QString & , QString & ) {
}
void saveSpecificAttribute( QTextStream & ) {
}
};
class RuntimeInfo : public QObject {
Q_OBJECT
public :
RuntimeInfo( ANetNodeInstance * TheNNI )
{ NNI = TheNNI; }
//
//
- // methods to be overloaded by connection capable
+ // methods to be overloaded by networkSetup capable
// runtimes
//
//
//
//
// methods to be overloaded by device capable
// runtimes
//
//
// does this node handles this interface e.g.eth0
// recurse deeper if this node cannot answer that question
virtual bool handlesInterface( const QString & S ) {
RuntimeInfo * RI = device();
if( RI ) {
return RI->handlesInterface( S );
}
return 0;
}
bool handlesInterface( const InterfaceInfo & I ) {
RuntimeInfo * RI = device();
if( RI ) {
return RI->handlesInterface( I );
}
return 0;
}
//
//
// methods to be overloaded by full setup capable
// runtimes
//
//
// return description for this full setup
virtual const QString & description( void ) {
return fullSetup()->description( );
}
// return triggers that should fire when this
// setup is brought up
virtual const QStringList & triggers( void ) {
return fullSetup()->triggers( );
}
//
//
// methods to be overloaded by line capable
// runtimes
//
//
// return the device file ('/dev/xxx') created
// by this line capable runtime
virtual QString deviceFile( void ) {
RuntimeInfo * RI = line();
if( RI ) {
return RI->deviceFile();
}
return QString();
}
//
//
// runtime interface
//
//
// return the node that offers device capability
virtual RuntimeInfo * device( void )
{ RuntimeInfo * RI = nextNode();
return (RI) ? RI->device() : 0;
}
// return the node that offers connection capability
virtual RuntimeInfo * connection( void )
{ RuntimeInfo * RI = nextNode();
return (RI) ? RI->connection() : 0;
}
// return the node that offers line capability
virtual RuntimeInfo * line( void )
{ RuntimeInfo * RI = nextNode();
return (RI) ? RI->line() : 0;
}
// return the node that offers full setup capability
virtual RuntimeInfo * fullSetup( void )
{ RuntimeInfo * RI = nextNode();
return (RI) ? RI->fullSetup() : 0;
}
inline ANetNodeInstance * netNode()
{ return NNI; }
- inline NodeCollection * nodeCollection()
- { return NNI->connection(); }
+ inline NetworkSetup * networkSetup()
+ { return NNI->networkSetup(); }
virtual State_t detectState( void ) = 0;
// public API to set the state
- virtual QString setState( NodeCollection * NC,
+ virtual QString setState( NetworkSetup * NC,
Action_t A,
bool Force = 0 );
inline RuntimeInfo * nextNode( void ) {
ANetNodeInstance * NNI = netNode()->nextNode();
return (NNI) ? NNI->runtime() : 0;
}
signals :
// sent by device if state changes
void stateChanged( State_t S, ANetNodeInstance * NNI );
protected :
// set state of this node (private API)
- virtual QString setMyState( NodeCollection * NC,
+ virtual QString setMyState( NetworkSetup * NC,
Action_t A,
bool Force = 0 ) = 0;
- // connection this runtime info belongs to
+ // networkSetup this runtime info belongs to
ANetNodeInstance * NNI;
};
-class NodeCollection : public QList<ANetNodeInstance> {
+class NetworkSetup : public QList<ANetNodeInstance> {
public :
- NodeCollection( void );
- NodeCollection( QTextStream & TS, bool & Dangling );
- ~NodeCollection( void );
+ NetworkSetup( void );
+ NetworkSetup( QTextStream & TS, bool & Dangling );
+ ~NetworkSetup( void );
+
+ // copy settings from NC to this
+ void copyFrom( const NetworkSetup & NC );
inline int done( void )
{ return Done; }
inline void setDone( int D )
{ Done = D; }
inline int number( void )
{ return Number; }
inline void setNumber( int i )
{ Number = i; }
inline bool isNew( void )
{ return IsNew; }
inline void setNew( bool N )
{ IsNew = N ; }
inline bool isModified( void )
{ return IsModified; }
inline void setModified( bool N )
{ IsModified = N ; }
inline bool handlesInterface( const QString & S ) {
return getToplevel()->runtime()->handlesInterface( S );
}
// return the interface in the OS that is assigned to
// this device
inline InterfaceInfo * assignedInterface( void ) {
return AssignedInterface;
}
// assign the interface to this device
inline void assignInterface( InterfaceInfo * NI ) {
- if( NI == 0 ) {
+ // cleanup previous
if( AssignedInterface ) {
- AssignedInterface->assignConnection( 0 );
+ AssignedInterface->assignToNetworkSetup( 0 );
}
+ if( NI ) {
+ // assign new
+ NI->assignToNetworkSetup( this );
}
AssignedInterface = NI;
- if( AssignedInterface ) {
- AssignedInterface->assignConnection( this );
- }
}
inline RuntimeInfo * device() {
return getToplevel()->runtime()->device();
}
const QStringList & triggers();
State_t state( bool Update = 0 );
// get the ixmap for this device
QPixmap devicePixmap( void );
QPixmap statePixmap( State_t S );
inline QPixmap statePixmap( bool Update = 0 )
{ return statePixmap( state(Update) ); }
QString stateName( State_t );
inline QString stateName( bool Update = 0 )
{ return stateName( state(Update) ); }
QString setState( Action_t A, bool Force = 0 );
void save( QTextStream & TS );
void append( ANetNodeInstance * NNI );
- // makes sure that all items in the connection point to
+ // makes sure that all items in the networkSetup point to
// that connectoin
void reassign( void );
ANetNodeInstance * getToplevel( void );
ANetNodeInstance * findNext( ANetNodeInstance * NNI );
ANetNodeInstance * findByName( const QString & S );
inline const QString & name()
{ return Name; }
const QString & description( void );
inline void setName( const QString & N)
{ Name = N; }
inline State_t currentState( void )
{ return CurrentState; }
inline void setCurrentState( State_t S )
{ CurrentState = S; }
// return TRUE if this node can have data to be inserted in
// file identified by S
bool hasDataForFile( SystemFile & S );
ANetNodeInstance * firstWithDataForFile( SystemFile & );
// generate items for this file -> toplevel call
short generateFile( SystemFile & SF,
long DN // device number
)
{ return getToplevel()->generateFile( SF, DN ); }
bool triggeredBy( const QString & Trigger )
{ return getToplevel()->triggeredBy( Trigger ); }
private :
int compareItems ( QCollection::Item item1,
QCollection::Item item2 );
long Number;
- // state of this connection
+ // state of this networkSetup
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;
int Done;
InterfaceInfo * AssignedInterface;
};
#endif
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp
index b81dcaa..0e72c25 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.cpp
+++ b/noncore/settings/networksettings2/networksettings2/resources.cpp
@@ -1,481 +1,481 @@
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
#include <qpixmap.h>
#include <qdir.h>
#include <qmessagebox.h>
#include <qpe/qlibrary.h>
#include <qpe/qpeapplication.h>
#include <opie2/odebug.h>
#include <opie2/opluginloader.h>
#include <qtopia/resource.h>
#include "netnode.h"
#include "resources.h"
#include "netnodeinterface.h"
#define PLUGINDIR "plugins/networksettings2"
#define ICONDIR "/pics/networksettings2/"
// single resources instance
TheNSResources * _NSResources = 0;
TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
- ConnectionsMap(), DanglingConnectionsMap() {
+ NetworkSetupsMap(), DanglingNetworkSetupsMap() {
_NSResources = this;
detectCurrentUser();
// load available netnodes
Plugins = 0;
findAvailableNetNodes();
// compile provides and needs lists
{ const char ** NeedsRun;
QDictIterator<ANetNode> OuterIt( AllNodeTypes );
bool Done;
for ( ; OuterIt.current(); ++OuterIt ) {
// find needs list
ANetNode::NetNodeList * NNLP = new ANetNode::NetNodeList;
ANetNode::NetNodeList & NNL = *(NNLP);
// must iterate this way to avoid duplication pointers
for ( QDictIterator<ANetNode> InnerIt( AllNodeTypes );
InnerIt.current(); ++InnerIt ) {
if( InnerIt.current() == OuterIt.current() )
// avoid recursive
continue;
const char ** Provides = InnerIt.current()->provides();
NeedsRun = OuterIt.current()->needs();
for( ; *NeedsRun; NeedsRun ++ ) {
const char ** PRun;
PRun = Provides;
for( ; *PRun; PRun ++ ) {
if( strcmp( *PRun, *NeedsRun ) == 0 ) {
// inner provides what outer needs
NNL.resize( NNL.size() + 1 );
NNL[NNL.size()-1] = InnerIt.current();
Done = 1; // break from 2 loops
break;
}
}
}
}
OuterIt.current()->setAlternatives( NNLP );
}
}
// define built in Node types to Description map
addNodeType( "device", tr( "Network Device" ),
tr( "<p>Devices that can handle IP packets</p>" ) );
addNodeType( "line", tr( "Character device" ),
tr( "<p>Devices that can handle single bytes</p>" ) );
- addNodeType( "connection", tr( "IP Connection" ),
- tr( "<p>Nodes that provide working IP connections</p>" ) );
- addNodeType( "fullsetup", tr( "Connection Profile" ),
- tr( "<p>Fully configured connection profile</p>" ) );
- addNodeType( "GPRS", tr( "Connection to GPRS device" ),
- tr( "<p>Connection to a GPRS capable device</p>" ) );
+ addNodeType( "NetworkSetup", tr( "IP NetworkSetup" ),
+ tr( "<p>Nodes that provide working IP NetworkSetups</p>" ) );
+ addNodeType( "fullsetup", tr( "NetworkSetup Profile" ),
+ tr( "<p>Fully configured NetworkSetup profile</p>" ) );
+ addNodeType( "GPRS", tr( "NetworkSetup to GPRS device" ),
+ tr( "<p>NetworkSetup to a GPRS capable device</p>" ) );
// get access to the system
TheSystem = new System();
}
TheNSResources::~TheNSResources( void ) {
if( Plugins ) {
delete Plugins;
delete PluginManager;
}
delete TheSystem;
}
void TheNSResources::addNodeType( const QString & ID,
const QString & Name,
const QString & Descr ) {
if( NodeTypeNameMap[ID].isEmpty() ) {
NodeTypeNameMap.insert( ID, Name );
NodeTypeDescriptionMap.insert( ID, Descr );
}
}
void TheNSResources::addSystemFile( const QString & ID,
const QString & P,
bool KDI ) {
if( ! SystemFiles.find( ID ) ) {
// new system file
SystemFiles.insert( ID, new SystemFile( ID, P, KDI ) );
} // else existed
}
void TheNSResources::busy( bool ) {
/*
if( B ) {
ShowWait->show();
qApp->process
} else {
ShowWait->hide();
}
*/
}
void TheNSResources::findAvailableNetNodes( void ){
Plugins = new OPluginLoader( "networksettings2" );
Plugins->setAutoDelete( true );
PluginManager = new OPluginManager( Plugins );
PluginManager->load();
if( Plugins->isInSafeMode() ) {
QMessageBox::information(
0,
tr( "Today Error"),
tr( "<qt>The plugin '%1' caused Today to crash."
" It could be that the plugin is not properly"
" installed.<br>Today tries to continue loading"
" plugins.</qt>" )
.arg( PluginManager->crashedPlugin().name()));
}
// Get All Plugins
OPluginLoader::List allplugins = Plugins->filtered();
QString lang = ::getenv("LANG");
for( OPluginLoader::List::Iterator it = allplugins.begin();
it != allplugins.end();
++it ) {
// check if this plugin supports the proper interface
NetNodeInterface * interface =
Plugins->load<NetNodeInterface>( *it, IID_NetworkSettings2 );
if( ! interface ) {
Log(( "Plugin %s from %s does not support proper interface\n",
(*it).name().latin1(), (*it).path().latin1() ));
continue;
}
// add the nodes in this plugin to the dictionary
{ QList<ANetNode> PNN;
interface->create_plugin( PNN );
if( PNN.isEmpty() ) {
Log(( "Plugin %s from %s does offer any nodes\n",
(*it).name().latin1(), (*it).path().latin1() ));
delete interface;
continue;
}
// merge this node with global node
for( QListIterator<ANetNode> it(PNN);
it.current();
++it ) {
AllNodeTypes.insert( it.current()->name(), it.current() );
}
}
// load the translation
QTranslator *trans = new QTranslator(qApp);
QString fn = QPEApplication::qpeDir()+
"/i18n/"+lang+"/"+ (*it).name() + ".qm";
if( trans->load( fn ) )
qApp->installTranslator( trans );
else
delete trans;
}
}
-// used to find unique connection number
-int TheNSResources::assignConnectionNumber( void ) {
+// used to find unique NetworkSetup number
+int TheNSResources::assignNetworkSetupNumber( void ) {
bool found = 1;
for( int trial = 0; ; trial ++ ) {
found = 1;
- for( QDictIterator<NodeCollection> it(ConnectionsMap);
+ for( QDictIterator<NetworkSetup> it(NetworkSetupsMap);
it.current();
++it ) {
if( it.current()->number() == trial ) {
found = 0;
break;
}
}
if( found ) {
Log(("Assign profile number %d\n", trial ));
return trial;
}
}
}
QPixmap TheNSResources::getPixmap( const QString & QS ) {
QPixmap P;
QString S("networksettings2/");
S += QS;
P = Resource::loadPixmap( S );
if( P.isNull() ) {
Log(( "Cannot load %s\n", S.latin1() ));
}
return ( P.isNull() ) ? QPixmap() : P;
}
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, bool Dangling ) {
+void TheNSResources::addNetworkSetup( NetworkSetup * NC, bool Dangling ) {
ANetNodeInstance * NNI;
- Log(( "Add Connection %s, Dangling %d\n",
+ Log(( "Add NetworkSetup %s, Dangling %d\n",
NC->name().latin1(), Dangling ));
if( Dangling ) {
- DanglingConnectionsMap.insert( NC->name(), NC );
+ DanglingNetworkSetupsMap.insert( NC->name(), NC );
} else {
- ConnectionsMap.insert( NC->name(), NC );
+ NetworkSetupsMap.insert( NC->name(), NC );
}
// add (new) nodes to NodeList
for( QListIterator<ANetNodeInstance> it(*NC);
it.current();
++it ) {
NNI = it.current();
if( findNodeInstance( NNI->name() ) == 0 ) {
// new item
addNodeInstance( NNI );
}
}
}
-void TheNSResources::removeConnection( const QString & N ) {
- NodeCollection * NC = findConnection( N );
+void TheNSResources::removeNetworkSetup( const QString & N ) {
+ NetworkSetup * NC = findNetworkSetup( N );
if( ! NC )
return;
- // delete netnodes in this connection
+ // delete netnodes in this NetworkSetup
ANetNodeInstance * NNI;
for( NNI = NC->first(); NNI != 0; NNI = NC->next() ) {
removeNodeInstance( NNI->name() );
}
- if( ConnectionsMap.find( N ) ) {
- ConnectionsMap.remove( N );
+ if( NetworkSetupsMap.find( N ) ) {
+ NetworkSetupsMap.remove( N );
} else {
- DanglingConnectionsMap.remove( N );
+ DanglingNetworkSetupsMap.remove( N );
}
}
-// dangling connections are filtered out
-NodeCollection * TheNSResources::findConnection( const QString & S ) {
- return ConnectionsMap[ S ];
+// dangling NetworkSetups are filtered out
+NetworkSetup * TheNSResources::findNetworkSetup( const QString & S ) {
+ return NetworkSetupsMap[ S ];
}
-NodeCollection * TheNSResources::getConnection( int nr ) {
- for( QDictIterator<NodeCollection> it(ConnectionsMap);
+NetworkSetup * TheNSResources::getNetworkSetup( int nr ) {
+ for( QDictIterator<NetworkSetup> it(NetworkSetupsMap);
it.current();
++it ) {
if( it.current()->number() == nr ) {
return it.current();
}
}
return 0;
}
/*
-void TheNSResources::renumberConnections( void ) {
- Name2Connection_t & M = NSResources->connections();
- NodeCollection * NC;
+void TheNSResources::renumberNetworkSetups( void ) {
+ Name2NetworkSetup_t & M = NSResources->NetworkSetups();
+ NetworkSetup * NC;
- // for all connections
- NodeCollection::resetMaxNr();
- for( QDictIterator<NodeCollection> it(M);
+ // for all NetworkSetups
+ NetworkSetup::resetMaxNr();
+ for( QDictIterator<NetworkSetup> it(M);
it.current();
++it ) {
NC = it.current();
- NC->setNumber( NC->maxConnectionNumber()+1 );
+ NC->setNumber( NC->maxNetworkSetupNumber()+1 );
NC->setModified( 1 );
}
}
*/
typedef struct EnvVars {
char * Name;
int Len;
} EnvVar_t;
#define AnEV(x) x, sizeof(x)-1
static EnvVar_t EV[] = {
AnEV( "HOME" ),
AnEV( "LOGNAME" ),
AnEV( "USER" ),
AnEV( "LD_LIBRARY_PATH" ),
AnEV( "PATH" ),
AnEV( "QTDIR" ),
AnEV( "OPIEDIR" ),
AnEV( "SHELL" ),
{ NULL, 0 }
};
void TheNSResources::detectCurrentUser( void ) {
// find current running qpe
QString QPEEnvFile = "";
CurrentUser.UserName = "";
CurrentUser.HomeDir = "";
if( getenv( "OPIEDIR" ) == 0 ) {
// nothing known
{ // open proc dir and find all dirs in it
QRegExp R("[0-9]+");
QDir ProcDir( "/proc" );
QFileInfo FI;
QStringList EL = ProcDir.entryList( QDir::Dirs );
// print it out
for ( QStringList::Iterator it = EL.begin();
it != EL.end();
++it ) {
if( R.match( (*it) ) >= 0 ) {
QString S = ProcDir.path()+"/"+ (*it);
S.append( "/exe" );
FI.setFile( S );
// get the link
S = FI.readLink();
if( S.right( 8 ) == "/bin/qpe" ) {
// found running qpe
QPEEnvFile.sprintf( ProcDir.path()+ "/" + (*it) + "/environ" );
break;
}
}
}
}
if( QPEEnvFile.isEmpty() ) {
// could not find qpe
Log(("Could not find qpe\n" ));
return;
}
// FI now contains path ProcDir to the cmd dir
{ char * Buf = 0;
char TB[1024];
long BufSize = 0;
int fd;
int rd;
fd = open( QPEEnvFile.latin1(), O_RDONLY );
if( fd < 0 ) {
Log(("Could not open %s : %d\n",
QPEEnvFile.latin1(), errno ));
return;
}
while( (rd = read( fd, TB, sizeof(TB) ) ) > 0 ) {
Buf = (char *)realloc( Buf, BufSize+rd );
memcpy( Buf+BufSize, TB, rd );
BufSize += rd;
}
char * Data = Buf;
char * DataEnd = Data+BufSize-1;
// get env items out of list
while( Data < DataEnd ) {
EnvVar_t * Run = EV;
while( Run->Name ) {
if( strncmp( Data, Run->Name, Run->Len ) == 0 &&
Data[Run->Len] == '='
) {
CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
strdup( Data );
if( strcmp( Run->Name, "OPIEDIR" ) == 0 ) {
// put OPIEDIR in env
putenv( CurrentUser.EnvList[CurrentUser.EnvList.size()-1] );
} else if( strcmp( Run->Name, "HOME" ) == 0 ) {
CurrentUser.HomeDir = Data+5;
} else if( strcmp( Run->Name, "LOGNAME" ) == 0 ) {
CurrentUser.UserName = Data+8;
}
break;
}
Run ++;
}
Data += strlen( Data )+1;
}
free( Buf );
if( ! CurrentUser.UserName.isEmpty() ) {
// find user info
struct passwd pwd;
struct passwd * pwdres;
if( getpwnam_r( CurrentUser.UserName.latin1(),
&pwd, TB, sizeof(TB), &pwdres ) ||
pwdres == 0 ) {
Log(("Could not determine user %s : %d\n",
CurrentUser.UserName.latin1(), errno ));
return;
}
CurrentUser.Uid = pwd.pw_uid;
CurrentUser.Gid = pwd.pw_gid;
} else{
CurrentUser.Uid =
CurrentUser.Gid = -1;
}
}
} else {
char * X;
QString S;
EnvVar_t * Run = EV;
while( Run->Name ) {
if( ( X = getenv( Run->Name ) ) ) {
Log(( "Env : %s = %s\n", Run->Name, X ));
S.sprintf( "%s=%s", Run->Name, X );
CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
strdup( S.latin1() );
if( strcmp( Run->Name, "LOGNAME" ) == 0 ) {
CurrentUser.UserName = X;
} else if( strcmp( Run->Name, "HOME" ) == 0 ) {
CurrentUser.HomeDir = X;
} // regulare env var
} else {
Log(("Could not determine %s\n", Run->Name ));
}
Run ++;
}
CurrentUser.Uid = getuid();
CurrentUser.Gid = getgid();
}
}
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h
index 51c4250..f7393d3 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.h
+++ b/noncore/settings/networksettings2/networksettings2/resources.h
@@ -1,153 +1,153 @@
#ifndef __RESOURCES__H
#define __RESOURCES__H
#include <qstring.h>
#include <qdict.h>
#include <qmap.h>
#include <qlist.h>
#include "netnode.h"
#include "systemfile.h"
#include "system.h"
class QLibrary;
class QPixmap;
class ANetNode;
class ANetNodeInstance;
namespace Opie {
namespace Core {
class OPluginLoader;
class OPluginManager;
}
}
typedef void (*GetNetNodeListFt_t)(QList<ANetNode>& PNN );
class CurrentQPEUser {
public :
CurrentQPEUser() : UserName(), HomeDir(), EnvList() {}
inline bool known( void )
{ return ! HomeDir.isEmpty() && ! UserName.isEmpty(); }
QString UserName;
QString HomeDir;
int Uid;
int Gid;
QArray<char *> EnvList;
};
typedef QDict<ANetNode> Name2NetNode_t;
typedef QDict<ANetNodeInstance > Name2Instance_t;
-typedef QDict<NodeCollection> Name2Connection_t;
+typedef QDict<NetworkSetup> Name2NetworkSetup_t;
typedef QDict<SystemFile> Name2SystemFile_t;
class TheNSResources {
public :
TheNSResources( void );
~TheNSResources( );
// give busy feedback
void busy( bool B );
System & system()
{ return *TheSystem; }
- int assignConnectionNumber(void);
+ int assignNetworkSetupNumber(void);
QPixmap getPixmap( const QString & Name );
Name2NetNode_t & netNodes( void )
{ return AllNodeTypes; }
bool netNodeExists( const QString & X )
{ return AllNodeTypes.find(X)!=0; }
ANetNode * findNetNode( const QString & N )
{ return AllNodeTypes.find(N);
}
// define new plugin (=node)
void addNodeType( const QString & ID,
const QString & LongName,
const QString & Description );
Name2SystemFile_t & systemFiles( void )
{ return SystemFiles; }
void addSystemFile( const QString & ID,
const QString & P,
bool KDI );
ANetNodeInstance * createNodeInstance( const QString & S )
{ ANetNode * NN = findNetNode( S );
Log(( "Find node type %s : %p\n", S.latin1(), NN ));
if( NN == 0 )
// type of this instance not found
return 0;
ANetNodeInstance * NNI = NN->createInstance();
NNI->initialize();
return NNI;
}
Name2Instance_t & netNodeInstances( void )
{ return AllNodes; }
void addNodeInstance( ANetNodeInstance * I )
{ AllNodes.insert( I->name(), I ); }
void removeNodeInstance( const QString & N )
{ AllNodes.remove( N );}
ANetNodeInstance * findNodeInstance( const QString & S )
{ return AllNodes[S]; }
const QString & netNode2Name( const char * Type );
const QString & netNode2Description( const char * Type );
- void addConnection( NodeCollection * NC, bool Dangling );
- void removeConnection( const QString & N );
- NodeCollection * findConnection( const QString & N );
- NodeCollection * getConnection( int nr );
- Name2Connection_t & connections( void )
- { return ConnectionsMap; }
- Name2Connection_t & danglingConnections( void )
- { return DanglingConnectionsMap; }
+ void addNetworkSetup( NetworkSetup * NC, bool Dangling );
+ void removeNetworkSetup( const QString & N );
+ NetworkSetup * findNetworkSetup( const QString & N );
+ NetworkSetup * getNetworkSetup( int nr );
+ Name2NetworkSetup_t & networkSetups( void )
+ { return NetworkSetupsMap; }
+ Name2NetworkSetup_t & danglingNetworkSetups( void )
+ { return DanglingNetworkSetupsMap; }
inline bool userKnown( void )
{ return CurrentUser.known(); }
CurrentQPEUser & currentUser( void )
{ return CurrentUser; }
private :
void detectCurrentUser( void );
QString tr( const char * path );
void findAvailableNetNodes( void );
QMap< QString, QString> NodeTypeNameMap;
QMap< QString, QString> NodeTypeDescriptionMap;
- // list of connections that are valid
- Name2Connection_t ConnectionsMap;
- // list of connection configurations that are not valid
+ // list of networkSetups that are valid
+ Name2NetworkSetup_t NetworkSetupsMap;
+ // list of networkSetup configurations that are not valid
// e.g. because plugins are missing
- Name2Connection_t DanglingConnectionsMap;
+ Name2NetworkSetup_t DanglingNetworkSetupsMap;
System * TheSystem;
Name2SystemFile_t SystemFiles;
// all node type classes
Name2NetNode_t AllNodeTypes;
// all nodes
Name2Instance_t AllNodes;
CurrentQPEUser CurrentUser;
Opie::Core::OPluginLoader * Plugins;
Opie::Core::OPluginManager * PluginManager;
};
extern TheNSResources * _NSResources;
#define NSResources _NSResources
#endif
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp
index a290f08..33cc5bd 100644
--- a/noncore/settings/networksettings2/networksettings2/system.cpp
+++ b/noncore/settings/networksettings2/networksettings2/system.cpp
@@ -200,404 +200,404 @@ void System::refreshStatistics( InterfaceInfo & I ) {
int loc = -1;
int version;
procTs.readLine();
line = procTs.readLine();
// get version
if( line.find("compressed") )
version = 3;
else if( line.find( "bytes" ) )
version = 2;
else
version = 1;
while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) {
if( (loc = line.find(":") ) == -1) {
continue;
}
if( I.Name != line.left(loc) )
continue;
// tokenize
SL = QStringList::split( ' ', line, FALSE );
// update data
switch( version ) {
case 1 :
I.RcvBytes = SL[1];
I.RcvErrors = SL[3];
I.RcvDropped = SL[4];
I.SndBytes = SL[6];
I.SndErrors = SL[8];
I.SndDropped = SL[9];
I.Collisions = SL[11];
break;
case 2 :
I.RcvBytes = SL[1];
I.RcvErrors = SL[3];
I.RcvDropped = SL[4];
I.SndBytes = SL[7];
I.SndErrors = SL[9];
I.SndDropped = SL[10];
I.Collisions = SL[12];
break;
case 3 :
I.RcvBytes = SL[1];
I.RcvErrors = SL[3];
I.RcvDropped = SL[4];
I.SndBytes = SL[9];
I.SndErrors = SL[11];
I.SndDropped = SL[12];
I.Collisions = SL[14];
break;
}
break;
}
}
//
// THIS UPDATES THE LIST -> INTERFACES ARE NOT DELETED BUT
// FLAGGED AS ! 'IsUp' IF NO LONGER PRESENT
//
void System::probeInterfaces( void ) {
// probe interfaces
int sockfd;
// get list of all interfaces
struct ifreq ifrs;
InterfaceInfo * IFI;
// flag all as 'down'
for( QDictIterator<InterfaceInfo> it( ProbedInterfaces );
it.current();
++it ) {
it.current()->IsUp = 0;
}
sockfd = socket(PF_INET, SOCK_DGRAM, 0);
if(sockfd == -1) {
odebug << "Cannot open INET socket "
<< errno
<< " "
<< strerror( errno )
<< oendl;
return;
}
// read interfaces from /proc/dev/net
// SIOCGIFCONF does not return ALL interfaces ???!?
ProcDevNet = new QFile(PROCNETDEV);
if( ! ProcDevNet->open(IO_ReadOnly) ) {
odebug << "Cannot open "
<< PROCNETDEV
<< " "
<< errno
<< " "
<< strerror( errno )
<< oendl;
delete ProcDevNet;
ProcDevNet =0;
::close( sockfd );
return;
}
QString line;
QString NicName;
QTextStream procTs(ProcDevNet);
int loc = -1;
procTs.readLine(); // eat a line
procTs.readLine(); // eat a line
while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) {
if((loc = line.find(":")) == -1) {
continue;
}
NicName = line.left(loc);
// set name for ioctl
strcpy( ifrs.ifr_name, NicName.latin1() );
if ( ! ( IFI = ProbedInterfaces.find( NicName ) ) ) {
// new nic
Log(("New NIC found : %s\n", NicName.latin1()));
IFI = new InterfaceInfo;
IFI->Name = line.left(loc);
IFI->Collection = 0;
ProbedInterfaces.insert( IFI->Name, IFI );
// get dynamic info
if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) {
IFI->IsPointToPoint = ((ifrs.ifr_flags & IFF_POINTOPOINT) == IFF_POINTOPOINT);
} else {
IFI->IsPointToPoint = 0;
}
// settings that never change
IFI->DstAddress = "";
if( IFI->IsPointToPoint ) {
if( ioctl(sockfd, SIOCGIFDSTADDR, &ifrs) >= 0 ) {
IFI->DstAddress =
inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_dstaddr)->sin_addr);
}
}
IFI->CardType = 999999;
IFI->MACAddress = "";
if( ioctl(sockfd, SIOCGIFHWADDR, &ifrs) >= 0 ) {
Log(("Family for NIC %s : %d\n", IFI->Name.latin1(),
ifrs.ifr_hwaddr.sa_family ));
IFI->CardType = ifrs.ifr_hwaddr.sa_family;
switch( ifrs.ifr_hwaddr.sa_family ) {
case ARPHRD_ETHER : // regular MAC address
// valid address -> convert to regular ::: format
// length = 6 bytes = 12 DIGITS -> 6 :
IFI->MACAddress.sprintf(
"%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",
HN( ifrs.ifr_hwaddr.sa_data[0] ),
LN( ifrs.ifr_hwaddr.sa_data[0] ),
HN( ifrs.ifr_hwaddr.sa_data[1] ),
LN( ifrs.ifr_hwaddr.sa_data[1] ),
HN( ifrs.ifr_hwaddr.sa_data[2] ),
LN( ifrs.ifr_hwaddr.sa_data[2] ),
HN( ifrs.ifr_hwaddr.sa_data[3] ),
LN( ifrs.ifr_hwaddr.sa_data[3] ),
HN( ifrs.ifr_hwaddr.sa_data[4] ),
LN( ifrs.ifr_hwaddr.sa_data[4] ),
HN( ifrs.ifr_hwaddr.sa_data[5] ),
LN( ifrs.ifr_hwaddr.sa_data[5] )
);
break;
#ifdef ARPHRD_IEEE1394
case ARPHRD_IEEE1394 : // Firewire Eth address
IFI->MACAddress.sprintf(
"%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-00-00",
HN( ifrs.ifr_hwaddr.sa_data[0] ),
LN( ifrs.ifr_hwaddr.sa_data[0] ),
HN( ifrs.ifr_hwaddr.sa_data[1] ),
LN( ifrs.ifr_hwaddr.sa_data[1] ),
HN( ifrs.ifr_hwaddr.sa_data[2] ),
LN( ifrs.ifr_hwaddr.sa_data[2] ),
HN( ifrs.ifr_hwaddr.sa_data[3] ),
LN( ifrs.ifr_hwaddr.sa_data[3] ),
HN( ifrs.ifr_hwaddr.sa_data[4] ),
LN( ifrs.ifr_hwaddr.sa_data[4] ),
HN( ifrs.ifr_hwaddr.sa_data[5] ),
LN( ifrs.ifr_hwaddr.sa_data[5] ),
HN( ifrs.ifr_hwaddr.sa_data[6] ),
LN( ifrs.ifr_hwaddr.sa_data[6] ),
HN( ifrs.ifr_hwaddr.sa_data[7] ),
LN( ifrs.ifr_hwaddr.sa_data[7] ),
HN( ifrs.ifr_hwaddr.sa_data[8] ),
LN( ifrs.ifr_hwaddr.sa_data[8] ),
HN( ifrs.ifr_hwaddr.sa_data[9] ),
LN( ifrs.ifr_hwaddr.sa_data[9] ),
HN( ifrs.ifr_hwaddr.sa_data[10] ),
LN( ifrs.ifr_hwaddr.sa_data[10] ),
HN( ifrs.ifr_hwaddr.sa_data[11] ),
LN( ifrs.ifr_hwaddr.sa_data[11] ),
HN( ifrs.ifr_hwaddr.sa_data[12] ),
LN( ifrs.ifr_hwaddr.sa_data[12] ),
HN( ifrs.ifr_hwaddr.sa_data[13] ),
LN( ifrs.ifr_hwaddr.sa_data[13] )
);
break;
#endif
case ARPHRD_PPP : // PPP
break;
case ARPHRD_IEEE80211 : // WLAN
break;
case ARPHRD_IRDA : // IRDA
break;
}
}
} else // else already probed before -> just update
Log(("Redetected NIC %s\n", NicName.latin1()));
// get dynamic info
if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) {
IFI->IsUp = ((ifrs.ifr_flags & IFF_UP) == IFF_UP);
IFI->HasMulticast = ((ifrs.ifr_flags & IFF_MULTICAST) == IFF_MULTICAST);
} else {
IFI->IsUp = 0;
IFI->HasMulticast = 0;
}
if( ioctl(sockfd, SIOCGIFADDR, &ifrs) >= 0 ) {
IFI->Address =
inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_addr)->sin_addr);
} else {
IFI->Address = "";
IFI->IsUp = 0;
}
if( ioctl(sockfd, SIOCGIFBRDADDR, &ifrs) >= 0 ) {
IFI->BCastAddress =
inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_broadaddr)->sin_addr);
} else {
IFI->BCastAddress = "";
}
if( ioctl(sockfd, SIOCGIFNETMASK, &ifrs) >= 0 ) {
IFI->Netmask =
inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_netmask)->sin_addr);
} else {
IFI->Netmask = "";
}
Log(("NIC %s UP ? %d\n", NicName.latin1(), IFI->IsUp ));
}
::close( sockfd );
}
InterfaceInfo * System::findInterface( const QString & N ) {
InterfaceInfo * Run;
- // has PAN connection UP interface ?
+ // has PAN NetworkSetup UP interface ?
for( QDictIterator<InterfaceInfo> It(ProbedInterfaces);
It.current();
++It ) {
Run = It.current();
if( N == Run->Name ) {
- // this PAN connection is up
+ // this PAN NetworkSetup is up
return Run;
}
}
return 0;
}
#include <stdarg.h>
static FILE * logf = 0;
void VLog( char * Format, ... ) {
va_list l;
va_start(l, Format );
if( logf == (FILE *)0 ) {
QString S = getenv("NS2LOG");
if( S == "stderr" ) {
logf = stderr;
} else if( S.isEmpty() ) {
logf = fopen( "/tmp/ns2log", "a" );
} else {
logf = fopen( S, "a" );
}
if( ! logf ) {
fprintf( stderr, "Cannot open logfile %s : %d\n",
S.latin1(), errno );
logf = (FILE *)1;
} else {
fprintf( logf, "____ OPEN LOGFILE ____\n");
}
}
if( (unsigned long)logf > 1 ) {
vfprintf( logf, Format, l );
}
va_end( l );
fflush( logf );
}
void LogClose( void ) {
if( (long)logf > 1 ) {
fprintf( logf, "____ CLOSE LOGFILE ____\n");
if( logf != stderr ) {
fclose( logf );
}
logf = 0;
}
}
QString removeSpaces( const QString & X ) {
QString Y;
Y = X.simplifyWhiteSpace();
Y.replace( QRegExp(" "), "_" );
odebug << X << " **" << Y << "**" << oendl;
return Y;
}
//
//
//
//
//
MyProcess::MyProcess() : QObject(), StdoutBuffer(), StderrBuffer() {
P = new OProcess();
connect( P,
SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int ) ),
this,
SLOT( SLOT_Stdout(Opie::Core::OProcess*,char*,int) ) );
connect( P,
SIGNAL( receivedStderr(Opie::Core::OProcess*, char*, int ) ),
this,
SLOT( SLOT_Stderr(Opie::Core::OProcess*,char*,int) ) );
connect( P,
SIGNAL( processExited(Opie::Core::OProcess*) ),
this,
SLOT( SLOT_ProcessExited(Opie::Core::OProcess*) ) );
}
MyProcess::~MyProcess() {
delete P;
}
void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) {
if( EchoMode ) {
write( 1, Buf, len );
return;
}
char * LB = (char *)alloca( len + 1 );
memcpy( LB, Buf, len );
LB[len] = '\0';
// now input is zero terminated
StdoutBuffer += LB;
odebug << "Received " << len << " bytes on stdout" << oendl;
// see if we have some lines (allow empty lines)
QStringList SL = QStringList::split( "\n", StdoutBuffer, TRUE );
for( unsigned int i = 0; i < SL.count()-1; i ++ ) {
Log(( "Stdout : \"%s\"\n", SL[i].latin1() ) );
emit stdoutLine( SL[i] );
}
// last line is rest
StdoutBuffer = SL[ SL.count()-1 ];
}
void MyProcess::SLOT_Stderr( Opie::Core::OProcess * , char * Buf, int len ) {
if( EchoMode ) {
write( 2, Buf, len );
return;
}
char * LB = (char *)alloca( len + 1 );
memcpy( LB, Buf, len );
LB[len] = '\0';
// now input is zero terminated
StderrBuffer += LB;
odebug << "Received " << len << " bytes on stderr" << oendl;
// see if we have some lines (allow empty lines)
QStringList SL = QStringList::split( "\n", StderrBuffer, TRUE );
for( unsigned int i = 0; i < SL.count()-1; i ++ ) {
Log(( "Stderr : \"%s\"\n", SL[i].latin1() ) );
emit stderrLine( SL[i] );
}
// last line is rest
StderrBuffer = SL[ SL.count()-1 ];
}
void MyProcess::SLOT_ProcessExited( Opie::Core::OProcess * ) {
emit processExited( this );
}
diff --git a/noncore/settings/networksettings2/networksettings2/system.h b/noncore/settings/networksettings2/networksettings2/system.h
index ebee0d5..794b868 100644
--- a/noncore/settings/networksettings2/networksettings2/system.h
+++ b/noncore/settings/networksettings2/networksettings2/system.h
@@ -1,140 +1,140 @@
#ifndef __SYSTEM__H
#define __SYSTEM__H
#include <qstring.h>
#include <opie2/oprocess.h>
using namespace Opie::Core;
// for hardware types
#include <net/if_arp.h>
#include <qdict.h>
#include <qobject.h>
#include <stdio.h>
-class NodeCollection;
+class NetworkSetup;
class ANetNodeInstance;
class QFile;
class MyProcess : public QObject {
Q_OBJECT
public :
MyProcess();
~MyProcess();
inline OProcess & process()
{ return *P; }
inline void setEchoMode( bool M ) {
EchoMode = M;
}
public slots :
void SLOT_Stdout( Opie::Core::OProcess * P, char *, int );
void SLOT_Stderr( Opie::Core::OProcess * P, char *, int );
void SLOT_ProcessExited( Opie::Core::OProcess * P);
signals :
void stdoutLine( const QString & );
void stderrLine( const QString & );
void processExited( MyProcess * );
private :
QString StdoutBuffer;
QString StderrBuffer;
OProcess * P;
// output all output to my output
bool EchoMode;
};
class InterfaceInfo {
public :
InterfaceInfo() :
Name(),
MACAddress(),
BCastAddress(),
Netmask(),
DstAddress() {
}
- NodeCollection * assignedConnection()
+ NetworkSetup * assignedToNetworkSetup()
{ return Collection; }
- void assignConnection( NodeCollection * NNI )
+ void assignToNetworkSetup( NetworkSetup * NNI )
{ Collection = NNI; }
- NodeCollection * Collection; // connection taking care of me
+ NetworkSetup * Collection; // networkSetup taking care of me
QString Name; // name of interface
int CardType; // type of card
QString MACAddress; // MAC address
QString Address; // IP Address
QString BCastAddress; // Broadcast Address
QString Netmask; // Netmask
QString DstAddress; // Peer address (if P-t-P)
bool IsUp; // interface is UP
bool HasMulticast; // Supports Multicast
bool IsPointToPoint; // IsPointToPoint card
QString RcvBytes;
QString SndBytes;
QString RcvErrors;
QString SndErrors;
QString RcvDropped;
QString SndDropped;
QString Collisions;
};
class System : public QObject {
Q_OBJECT
public :
System( void );
~System( void );
QDict<InterfaceInfo> & interfaces( void );
InterfaceInfo * interface( const QString& N )
{ return interfaces()[N]; }
// exec command as root
int runAsRoot( QStringList & S, MyProcess * Prc = 0 );
// exec command as user
int execAsUser( QStringList & Cmd, bool Synchronous = 0 );
// refresh stats for this interface
void refreshStatistics( InterfaceInfo & );
// reloads interfaces
void probeInterfaces( void );
InterfaceInfo * findInterface( const QString & DevName );
private slots :
void SLOT_ProcessExited( MyProcess * );
signals :
void stdoutLine( const QString & );
void stderrLine( const QString & );
void processEvent( const QString & );
private :
QDict<InterfaceInfo> ProbedInterfaces;
FILE * OutputOfCmd;
QFile * ProcDevNet;
};
#endif
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index 39031ed..b4622fc 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -1,787 +1,787 @@
#include <stdlib.h>
#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
#include <qtextstream.h>
#include <qdir.h>
#include <qfile.h>
#include <qfileinfo.h>
#include "nsdata.h"
#include <netnode.h>
#include <resources.h>
static QString CfgFile;
NetworkSettingsData::NetworkSettingsData( void ) {
// init global resources structure
new TheNSResources();
if( ! NSResources->userKnown() ) {
Log(( "Cannot detect qpe user HOME=\"%s\" USER=\"%s\"\n",
NSResources->currentUser().HomeDir.latin1(),
NSResources->currentUser().UserName.latin1() ));
return;
}
CfgFile.sprintf( "%s/Settings/NS2.conf",
NSResources->currentUser().HomeDir.latin1() );
Log(( "Cfg from %s\n", CfgFile.latin1() ));
// load settings
loadSettings();
// assign interfaces by scanning /tmp/profile-%s.Up files
{ QDir D( "/tmp" );
QFile * F = new QFile;
int profilenr;
QString interfacename;
QTextStream TS ( F );
QStringList SL = D.entryList( "profile-*.up");
Log(( "System reports %d interfaces. Found %d up\n",
NSResources->system().interfaces().count(),
SL.count() ));
for ( QStringList::Iterator it = SL.begin();
it != SL.end();
++it ) {
profilenr = atol( (*it).mid( 8 ).latin1() );
// read the interface store int 'up'
F->setName( D.path() + "/" + (*it) );
if( F->open( IO_ReadOnly ) ) {
- NodeCollection * NC;
+ NetworkSetup * NC;
interfacename = TS.readLine();
F->close();
Log(( "Assign interface %s to Profile nr %d\n",
interfacename.latin1(), profilenr ));
- NC = NSResources->getConnection( profilenr );
+ NC = NSResources->getNetworkSetup( profilenr );
if( NC ) {
NC->assignInterface(
NSResources->system().findInterface( interfacename ) );
Log(( "Assign interface %p\n",
NC->assignedInterface() ));
} else {
Log(( "Profile nr %d no longer defined\n",
profilenr ));
}
}
}
}
}
// saving is done by caller
NetworkSettingsData::~NetworkSettingsData( void ) {
delete NSResources;
}
void NetworkSettingsData::loadSettings( void ) {
QString Line, S;
QString Attr, Value;
long idx;
QFile F( CfgFile );
QTextStream TS( &F );
ForceModified = 0;
do {
if( ! F.open(IO_ReadOnly) )
break;
/* load the file ->
FORMAT :
[NETNODETYPE]
Entries ...
<EMPTYLINE>
- [connection]
+ [NetworkSetup]
Name=Name
Node=Name
<EMPTYLINE>
*/
while( ! TS.atEnd() ) {
S = Line = 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
+ if( S == "NetworkSetup" ) {
+ // load NetworkSetups -> collections of nodes
bool Dangling;
- NodeCollection * NC = new NodeCollection( TS, Dangling );
- NSResources->addConnection( NC, Dangling );
+ NetworkSetup * NC = new NetworkSetup( TS, Dangling );
+ NSResources->addNetworkSetup( NC, Dangling );
} else {
ANetNode * NN = 0;
ANetNodeInstance* NNI = 0;
if( S.startsWith( "nodetype " ) ) {
S = S.mid( 9, S.length()-9 );
S = deQuote(S);
// try to find netnode
NN = NSResources->findNetNode( S );
} else {
// try to find instance
NNI = NSResources->createNodeInstance( S );
}
if( NN == 0 && NNI == 0 ) {
LeftOvers.append( Line );
do {
Line = TS.readLine();
// store even delimiter
LeftOvers.append( Line );
} while ( ! Line.isEmpty() );
//next section
continue;
}
// read entries of this section
do {
S = Line = TS.readLine();
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
NN->setAttribute( Attr, Value );
} else {
// set the attribute
NNI->setAttribute( Attr, Value );
}
} while( 1 );
if( NNI ) {
// loading from file -> exists
Log( ( "NodeInstance %s : %p\n", NNI->name(), NNI ));
NNI->setNew( FALSE );
NSResources->addNodeInstance( NNI );
}
if( NN ) {
Log( ( "Node %s : %p\n", NN->name(), NN ) );
}
}
}
} while( 0 );
}
QString NetworkSettingsData::saveSettings( void ) {
QString ErrS = "";
if( ! isModified() )
return ErrS;
QString S;
QFile F( CfgFile + ".bup" );
Log( ( "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>" ).
arg(CfgFile);
// problem
return ErrS;
}
QTextStream TS( &F );
// save global configs
for( QDictIterator<ANetNode> it( NSResources->netNodes() );
it.current();
++it ) {
TS << "[nodetype "
<< quote( QString( it.current()->name() ) )
<< "]"
<< endl;
it.current()->saveAttributes( TS );
TS << endl;
}
// save leftovers
for ( QStringList::Iterator it = LeftOvers.begin();
it != LeftOvers.end(); ++it ) {
TS << (*it) << endl;
}
// save all netnode instances
{ ANetNodeInstance * NNI;
for( QDictIterator<ANetNodeInstance> nit(
NSResources->netNodeInstances());
nit.current();
++nit ) {
// header
NNI = nit.current();
TS << '['
<< QString(NNI->nodeClass()->name())
<< ']'
<< endl;
NNI->saveAttributes( TS );
TS << endl;
}
}
- // good connections
- { Name2Connection_t & M = NSResources->connections();
+ // good NetworkSetups
+ { Name2NetworkSetup_t & M = NSResources->networkSetups();
- // for all connections
- for( QDictIterator<NodeCollection> it(M);
+ // for all NetworkSetups
+ for( QDictIterator<NetworkSetup> it(M);
it.current();
++it ) {
- TS << "[connection]" << endl;
+ TS << "[NetworkSetup]" << endl;
it.current()->save(TS);
}
}
- // save dangling connections
- { Name2Connection_t & M = NSResources->danglingConnections();
+ // save dangling NetworkSetups
+ { Name2NetworkSetup_t & M = NSResources->danglingNetworkSetups();
- // for all connections
- for( QDictIterator<NodeCollection> it(M);
+ // for all NetworkSetups
+ for( QDictIterator<NetworkSetup> it(M);
it.current();
++it ) {
- TS << "[connection]" << endl;
+ TS << "[NetworkSetup]" << endl;
it.current()->save(TS);
}
}
QDir D(".");
D.rename( CfgFile + ".bup", CfgFile );
//
// proper files AND system files regenerated
//
- for( QDictIterator<NodeCollection> it(NSResources->connections());
+ for( QDictIterator<NetworkSetup> it(NSResources->networkSetups());
it.current();
++it ) {
it.current()->setModified( 0 );
}
return ErrS;
}
QString NetworkSettingsData::generateSettings( void ) {
QString S = "";
Name2SystemFile_t & SFM = NSResources->systemFiles();
- Name2Connection_t & M = NSResources->connections();
- NodeCollection * NC;
+ Name2NetworkSetup_t & M = NSResources->networkSetups();
+ NetworkSetup * NC;
ANetNodeInstance * NNI;
ANetNodeInstance * FirstWithData;
RuntimeInfo * CurDev;
ANetNode * NN, * CurDevNN = 0;
long NoOfDevs;
long DevCtStart;
bool needToGenerate;
// regenerate system files
Log( ( "Generating settings from %s\n", CfgFile.latin1() ));
for( QDictIterator<ANetNode> nnit( NSResources->netNodes() );
nnit.current();
++nnit ) {
bool FirstItem = 1;
bool Generated = 0;
CurDevNN = nnit.current();
{ QStringList SL;
SL = CurDevNN->properFiles();
for ( QStringList::Iterator it = SL.begin();
it != SL.end();
++it ) {
Generated = 0;
FirstItem = 1;
// iterate over NNI's of this class
for( QDictIterator<ANetNodeInstance> nniit(
NSResources->netNodeInstances() );
nniit.current();
++nniit ) {
if( nniit.current()->nodeClass() != CurDevNN )
// different class
continue;
// open proper file
{ SystemFile SF( (*it) );
if( ! CurDevNN->openFile( SF, nniit.current()) ) {
// cannot open
S = qApp->translate( "NetworkSettings",
"<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
arg( (*it) ).arg( CurDevNN->name() );
return S;
}
if( ! SF.open() ) {
S = qApp->translate( "NetworkSettings",
"<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
arg( (*it) ).arg( CurDevNN->name() );
return S;
}
// preamble on first
if( FirstItem ) {
if( CurDevNN->generatePreamble( SF ) == 2 ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in section \"preamble\" for proper file \"%1\" and node \"%2\"</p>" ).
arg( (*it) ).
arg( CurDevNN->name() );
return S;
}
}
FirstItem = 0;
Generated = 1;
// item specific
if( nniit.current()->generateFile( SF, -1 ) == 2 ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in section for node \"%1\" for proper file \"%2\" and node class \"%3\"</p>" ).
arg( nniit.current()->name() ).
arg( (*it) ).
arg( CurDevNN->name() );
return S;
}
}
}
if( Generated ) {
SystemFile SF( (*it) );
if( CurDevNN->openFile( SF, 0 ) &&
! SF.path().isEmpty()
) {
if( ! SF.open() ) {
S = qApp->translate( "NetworkSettings",
"<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
arg( (*it) ).arg( CurDevNN->name() );
return S;
}
if( CurDevNN->generatePostamble( SF ) == 2 ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in section \"postamble\" for proper file \"%1\" and node \"%2\"</p>" ).
arg( (*it) ).
arg( CurDevNN->name() );
return S;
}
} // no postamble
}
}
}
}
//
// generate all registered files
//
for( QDictIterator<SystemFile> sfit(SFM);
sfit.current();
++sfit ) {
SystemFile * SF;
SF = sfit.current();
// reset all
for( QDictIterator<ANetNode> nnit( NSResources->netNodes() );
nnit.current();
++nnit ) {
nnit.current()->setDone(0);
}
for( QDictIterator<ANetNodeInstance> nniit(
NSResources->netNodeInstances() );
nniit.current();
++nniit ) {
nniit.current()->setDone(0);
}
- for( QDictIterator<NodeCollection> ncit(M);
+ for( QDictIterator<NetworkSetup> ncit(M);
ncit.current();
++ncit ) {
ncit.current()->setDone(0);
}
Log( ( "Generating system file %s\n", SF->name().latin1() ));
needToGenerate = 0;
// are there netnodes that have instances and need
// to write data in this system file ?
for( QDictIterator<ANetNode> nnit( NSResources->netNodes() );
! needToGenerate && nnit.current();
++nnit ) {
NN = nnit.current();
if( NN->hasDataForFile( *SF ) ) {
// netnode can have data
// are there instances of this node ?
for( QDictIterator<ANetNodeInstance> nniit(
NSResources->netNodeInstances() );
! needToGenerate && nniit.current();
++nniit ) {
if( nniit.current()->nodeClass() == NN ) {
// yes
Log(("Node %s has data\n",
nniit.current()->name() ));
needToGenerate = 1;
break;
}
}
}
}
if( ! needToGenerate ) {
// no instances found that might need to write data
// in this systemfile
Log(("No nodes for systemfile %s\n", SF->name().latin1() ));
continue;
}
// ok generate this system file
if( ! SF->open() ) {
S = qApp->translate( "NetworkSettings",
"<p>Cannot open system file \"%1\"</p>" ).
arg( SF->name() );
return S;
}
// global presection for this system file
if( ! SF->preSection() ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in section \"Preamble\" for file \"%1\"</p>" ).
arg( SF->name() );
return S;
}
- // find connections that want to write to this file
- for( QDictIterator<NodeCollection> ncit(M);
+ // find NetworkSetups that want to write to this file
+ for( QDictIterator<NetworkSetup> ncit(M);
ncit.current();
++ncit ) {
NC = ncit.current();
if( NC->done() ) {
// already done
continue;
}
if( ! NC->hasDataForFile( *SF ) ) {
// no data
continue;
}
- Log(("Generating %s for connection %s\n",
+ Log(("Generating %s for NetworkSetup %s\n",
SF->name().latin1(), NC->name().latin1() ));
// find highest item that wants to write data to this file
FirstWithData = NC->firstWithDataForFile( *SF );
- // find device on which this connection works
+ // find device on which this NetworkSetup works
CurDev = NC->device();
// class of that node
CurDevNN = CurDev->netNode()->nodeClass();
if( ! FirstWithData->nodeClass()->done() ) {
// generate fixed part
if( ! SF->preDeviceSection( CurDevNN ) ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in section \"Pre-Device\" for file \"%1\"</p>" ).
arg( SF->name() );
return S;
}
if( FirstWithData->nodeClass()->generateFile(
*SF,
FirstWithData,
-2 ) == 2 ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ).
arg( SF->name() ).
arg( CurDevNN->name() );
return S;
}
FirstWithData->nodeClass()->setDone( 1 );
Log(( "Systemfile %s for node instance %s is done\n",
SF->name().latin1(),
FirstWithData->name() ));
}
NoOfDevs = 0;
DevCtStart = -1;
if( SF->knowsDeviceInstances() ) {
DevCtStart = 0;
NoOfDevs = CurDevNN->instanceCount();
}
if( ! CurDev->netNode()->nodeClass()->done() ) {
// first time this device is handled
// generate common device specific part
for( int i = DevCtStart; i < NoOfDevs ; i ++ ) {
if( FirstWithData->nodeClass()->generateFile(
*SF, CurDev->netNode(), i ) == 2 ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ).
arg( SF->name() ).
arg( CurDevNN->name() );
return S;
}
}
CurDev->netNode()->nodeClass()->setDone( 1 );
Log(( "Systemfile %s for Nodeclass %s is done\n",
SF->name().latin1(),
CurDev->netNode()->nodeClass()->name()
));
}
// generate profile specific info
- // for all nodeconnections that work on the same device
- for( QDictIterator<NodeCollection> ncit2(M);
+ // for all nodeNetworkSetups that work on the same device
+ for( QDictIterator<NetworkSetup> ncit2(M);
ncit2.current();
++ncit2 ) {
if( ncit2.current()->device() != CurDev ) {
// different device
continue;
}
- Log(("Connection %s of family %s\n",
+ Log(("NetworkSetup %s of family %s\n",
ncit2.current()->name().latin1(),
CurDev->name() ));
// generate
NNI = ncit2.current()->firstWithDataForFile( *SF );
for( int i = DevCtStart; i < NoOfDevs ; i ++ ) {
if( ! SF->preNodeSection( NNI, i ) ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
arg( SF->name() ).
arg( CurDevNN->name() );
return S;
}
switch( NNI->generateFile( *SF, i ) ) {
case 0 :
(*SF) << endl;
break;
case 1 :
break;
case 2 :
S = qApp->translate( "NetworkSettings",
"<p>Error in section \"Node\" for file \"%1\" and node \"%2\"</p>" ).
arg( SF->name() ).
arg( CurDevNN->name() );
return S;
}
if( ! SF->postNodeSection( NNI, i ) ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
arg( SF->name() ).
arg( CurDevNN->name() );
return S;
}
}
ncit2.current()->setDone( 1 );
}
}
if( ! SF->postDeviceSection( CurDevNN ) ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in section \"Post-Device\" for file \"%1\" and node \"%2\"</p>" ).
arg( SF->name() ).
arg( CurDevNN->name() );
return S;
}
if( ! SF->postSection() ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in section \"Closure\" for file \"%1\"</p>" ).
arg( SF->name() );
return S;
}
// end of file
SF->close();
}
return S;
}
-QList<NodeCollection> NetworkSettingsData::collectPossible(
+QList<NetworkSetup> NetworkSettingsData::collectPossible(
const QString & Interface ) {
- // collect connections that can work on top of this interface
- NodeCollection * NC;
- QList<NodeCollection> PossibleConnections;
- Name2Connection_t & M = NSResources->connections();
+ // collect NetworkSetups that can work on top of this interface
+ NetworkSetup * NC;
+ QList<NetworkSetup> PossibleNetworkSetups;
+ Name2NetworkSetup_t & M = NSResources->networkSetups();
- // for all connections
- for( QDictIterator<NodeCollection> it(M);
+ // for all NetworkSetups
+ for( QDictIterator<NetworkSetup> 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 enabled
NC->state() != IsUp // if already used
) {
Log( ( "Append %s for %s\n",
NC->name().latin1(), Interface.latin1() ));
- PossibleConnections.append( NC );
+ PossibleNetworkSetups.append( NC );
}
}
- return PossibleConnections;
+ return PossibleNetworkSetups;
}
/*
Called by the system to see if interface can be brought UP
if allowed, echo Interface-allowed else Interface-disallowed
*/
bool NetworkSettingsData::canStart( const QString & Interface ) {
// load situation
- NodeCollection * NC = 0;
- QList<NodeCollection> PossibleConnections;
+ NetworkSetup * NC = 0;
+ QList<NetworkSetup> PossibleNetworkSetups;
- PossibleConnections = collectPossible( Interface );
+ PossibleNetworkSetups = collectPossible( Interface );
Log( ( "for %s : Possiblilies %d\n",
- Interface.latin1(), PossibleConnections.count() ));
- switch( PossibleConnections.count() ) {
- case 0 : // no connections
+ Interface.latin1(), PossibleNetworkSetups.count() ));
+ switch( PossibleNetworkSetups.count() ) {
+ case 0 : // no NetworkSetups
break;
- case 1 : // one connection
- NC = PossibleConnections.first();
+ case 1 : // one NetworkSetup
+ NC = PossibleNetworkSetups.first();
break;
default : // need to ask user ?
return 1;
}
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
{ QString S= NC->setState( Activate );
if( ! S.isEmpty() ) {
// could not bring device Online -> try other alters
Log(( "disallow %ld for %s : %s\n",
NC->number(), Interface.latin1(), S.latin1() ));
break;
}
// interface assigned
}
// FT
case Available :
case IsUp : // also called for 'ifdown'
// device is ready -> done
Log(( "allow %ld for %s\n", NC->number(), Interface.latin1()));
printf( "A%ld%s\n", NC->number(), Interface.latin1() );
return 0;
}
}
// if we come here no alternatives are possible
Log(( "disallow %s\n", Interface.latin1()));
printf( "D-%s\n", Interface.latin1() );
return 0;
}
bool NetworkSettingsData::isModified( void ) {
if( ForceModified )
return 1;
- for( QDictIterator<NodeCollection> it(NSResources->connections());
+ for( QDictIterator<NetworkSetup> it(NSResources->networkSetups());
it.current();
++it ) {
if( it.current()->isModified() ) {
return 1;
}
}
return 0;
}
bool NetworkSettingsData::couldBeTriggered( const QString & Interface ) {
// load situation
- QList<NodeCollection> PossibleTriggered;
+ QList<NetworkSetup> PossibleTriggered;
PossibleTriggered = collectTriggered( Interface );
Log( ( "for %s : Possiblilies %d\n",
Interface.latin1(), PossibleTriggered.count() ));
return ( PossibleTriggered.count() ) ? 1 : 0;
}
-QList<NodeCollection> NetworkSettingsData::collectTriggered(
+QList<NetworkSetup> NetworkSettingsData::collectTriggered(
const QString & Interface ) {
- // collect connections that could be triggered by this interface
- NodeCollection * NC;
- QList<NodeCollection> PossibleTriggered;
+ // collect NetworkSetups that could be triggered by this interface
+ NetworkSetup * NC;
+ QList<NetworkSetup> PossibleTriggered;
- // for all connections
- Name2Connection_t & M = NSResources->connections();
+ // for all NetworkSetups
+ Name2NetworkSetup_t & M = NSResources->networkSetups();
- for( QDictIterator<NodeCollection> it(M);
+ for( QDictIterator<NetworkSetup> it(M);
it.current();
++it ) {
NC = it.current();
// check if this profile handles the requested interface
if( NC->triggeredBy( Interface ) && // if different Intf.
NC->state() != Disabled && // if enabled
NC->state() != IsUp // if already used
) {
Log( ( "Append %s for %s\n",
NC->name().latin1(), Interface.latin1() ));
PossibleTriggered.append( NC );
}
}
return PossibleTriggered;
}
diff --git a/noncore/settings/networksettings2/nsdata.h b/noncore/settings/networksettings2/nsdata.h
index 5791c1e..b9c216d 100644
--- a/noncore/settings/networksettings2/nsdata.h
+++ b/noncore/settings/networksettings2/nsdata.h
@@ -1,38 +1,38 @@
#ifndef __NSDATA_H
#define __NSDATA_H
#include <netnode.h>
class NetworkSettingsData {
public :
NetworkSettingsData( void );
~NetworkSettingsData( void );
void loadSettings( void );
QString saveSettings( void );
QString generateSettings( void );
bool isModified( void );
inline void setModified( bool M )
{ ForceModified = M; }
- QList<NodeCollection> collectPossible( const QString & Interface );
+ QList<NetworkSetup> collectPossible( const QString & Interface );
// return TRUE if we need gui to decide
bool canStart( const QString & Interface );
// return TRUE if there are vpns that could be triggered
// by this interface
bool couldBeTriggered( const QString & Interface );
private :
- QList<NodeCollection> collectTriggered( const QString &Interface );
+ QList<NetworkSetup> collectTriggered( const QString &Interface );
bool ForceModified;
// collect strings in config file nobody wants
QStringList LeftOvers;
};
#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTDriver.cpp b/noncore/settings/networksettings2/opietooth2/OTDriver.cpp
index a7ee662..cfd0491 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDriver.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTDriver.cpp
@@ -460,285 +460,285 @@ void OTDriver::setScanMode(bool iscan, bool pscan) {
}
void OTDriver::changeDevName(const char* name) {
if( ! open() ) {
return;
}
if (hci_write_local_name(fd(), name, 1000) < 0) {
emit error( tr( "Can't change local name on %1. %2 : %3" ).
arg( devname() ).
arg( errno ).
arg( strerror(errno) ) );
}
}
void OTDriver::changeAuthentication(bool _auth) {
struct hci_dev_req dr;
if( ! open() ) {
return;
}
dr.dev_id = devId();
dr.dev_opt = _auth?AUTH_ENABLED:AUTH_DISABLED;
if (ioctl(fd(),HCISETAUTH,(unsigned long)&dr) < 0) {
if( errno != EALREADY ) {
emit error( tr( "Can't change authentication on %1. %2 : %3" ).
arg( devname() ).
arg( errno ).
arg( strerror(errno) ) );
}
return;
}
reinit();
}
void OTDriver::changeEncryption(bool _encrypt) {
struct hci_dev_req dr;
if( ! open() ) {
return;
}
dr.dev_id = devId();
dr.dev_opt = _encrypt?ENCRYPT_P2P:ENCRYPT_DISABLED;
if (ioctl(fd(),HCISETENCRYPT,(unsigned long)&dr) < 0) {
if( errno != EALREADY ) {
emit error( tr( "Can't change encryption on %1. %2 : %3" ).
arg( devname() ).
arg( errno ).
arg( strerror(errno) ) );
}
return;
}
reinit();
}
void OTDriver::changeClass ( unsigned char service,
unsigned char major,
unsigned char minor ) {
unsigned long cod = 0;
cod = (service << 16) |
(major << 8) |
(minor ) ;
if( ! open() ) {
return;
}
if ( hci_write_class_of_dev(fd(),cod,1000) < 0 ) {
emit error( tr( "Can't change class informations for %1. %2 : %3" ).
arg( devname() ).
arg( errno ).
arg( strerror(errno) ) );
return;
}
}
void OTDriver::getClass( QString & service,
QString & device ) {
unsigned char cls[3];
if( ! open() ) {
return;
}
if ( hci_read_class_of_dev(fd(),cls,1000) < 0 ) {
emit error( tr( "Can't read class information for %1. %2 : %3" ).
arg( devname() ).
arg( errno ).
arg( strerror(errno) ) );
return;
}
if( cls[2] ) {
int first = 1;
for ( unsigned int s = 0; s < sizeof(*services); s++) {
if (cls[2] & (1 << s)) {
if( !first )
service += ", ";
service += services[s];
first = 0;
}
}
} else {
service = "unspecified";
}
MainClassMap_t * MCM = MainClasses;
int major = cls[1] & 0x1f;
int minor = cls[0] >> 2;
if( (unsigned)(cls[1] & 0x1f) > sizeof(*major_devices)) {
device = tr("Invalid Device Class");
return;
}
device = major_devices[cls[1] & 0x1f];
while( MCM->Major != -1 ) {
if( major == MCM->Major ) {
// this class
ClassMap_t * CM = MCM->Map;
if( MCM->Map ) {
while( CM->Minor != -1 ) {
if( minor == CM->Minor ) {
break;
}
CM ++;
}
device = CM->Description;
} else {
// special case
if( major == 3 ) {
/* lan access */
if( minor == 0 ) {
device = "Uncategorized";
} else {
switch( minor / 8 ) {
case 0:
device = "Fully available";
break;
case 1:
device = "1-17% utilized";
break;
case 2:
device = "17-33% utilized";
break;
case 3:
device = "33-50% utilized";
break;
case 4:
device = "50-67% utilized";
break;
case 5:
device = "67-83% utilized";
break;
case 6:
device = "83-99% utilized";
break;
case 7:
device = "No service available";
break;
}
}
} else if( major == 6 ) { /* imaging */
if (minor & 4)
device = "Display";
if (minor & 8)
device = "Camera";
if (minor & 16)
device = "Scanner";
if (minor & 32)
device = "Printer";
}
}
break;
}
MCM ++;
}
if( MCM->Major == -1 ) {
device = "Unknown (reserved) minor device class";
}
}
QString OTDriver::strType() {
return QString( hci_dtypetostr(Type) );
}
void OTDriver::setFeatures( unsigned char * _f) {
Features = lmp_featurestostr(_f, NULL, 255);
}
void OTDriver::setManufacturer(int compid) {
Manufacturer = bt_compidtostr(compid);
}
OTHCISocket * OTDriver::openSocket( void ) {
if( ! Socket ) {
odebug << "Open HCI socket to " << devname() << oendl;
Socket = new OTHCISocket( this );
}
return Socket;
}
void OTDriver::closeSocket( void ) {
if( Socket ) {
odebug << "Close HCI socket to " << devname() << oendl;
delete Socket;
Socket = 0;
}
}
QString OTDriver::getPeerName( const OTDeviceAddress & PAddr ) {
QString S;
char name[100 ];
if( ! open() ) {
return QString("N/A");
}
if( hci_read_remote_name( fd(),
&(PAddr.getBDAddr()),
sizeof(name),
name,
100000 ) < 0 ) {
return QString( "N/A" );
}
return QString( name );
}
long OTDriver::getLinkQuality( const OTDeviceAddress & Addr ) {
struct hci_conn_info_req *cr;
struct hci_request rq;
read_rssi_rp rp;
uint16_t handle;
if( ! open() ) {
return 0;
}
cr = (struct hci_conn_info_req *)malloc(
sizeof(*cr) + sizeof(struct hci_conn_info));
if (!cr)
return 0;
bacpy( &(cr->bdaddr), &(Addr.getBDAddr()) );
cr->type = ACL_LINK;
if (ioctl( fd(), HCIGETCONNINFO, (unsigned long) cr) < 0) {
- odebug << "Get connection info failed" << oendl;
+ odebug << "Get NetworkSetup info failed" << oendl;
free(cr);
return 0;
}
handle = htobs(cr->conn_info->handle);
free(cr);
memset(&rq, 0, sizeof(rq));
rq.ogf = OGF_STATUS_PARAM;
rq.ocf = OCF_READ_RSSI;
rq.cparam = &handle;
rq.clen = 2;
rq.rparam = &rp;
rq.rlen = GET_LINK_QUALITY_RP_SIZE;
if (hci_send_req( fd(), &rq, 100) < 0) {
- odebug << "Get connection info failed" << oendl;
+ odebug << "Get NetworkSetup info failed" << oendl;
return 0;
}
if( rp.status ) {
odebug << QString().sprintf("HCI get_link_quality cmd failed (0x%2.2X)", rp.status) << oendl;
return 0;
}
return rp.rssi+50;
}
diff --git a/noncore/settings/networksettings2/opietooth2/OTDriver.h b/noncore/settings/networksettings2/opietooth2/OTDriver.h
index b54ffdf..899fab4 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDriver.h
+++ b/noncore/settings/networksettings2/opietooth2/OTDriver.h
@@ -1,232 +1,232 @@
/***************************************************************************
* Copyright (C) 2003 by Mattia Merzi *
* ottobit@ferrara.linux.it *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef OTDRIVER_H
#define OTDRIVER_H
/*
- * This class handles the connection with the BlueZ libraries, implements
+ * This class handles the networkSetup with the BlueZ libraries, implements
* most of the bluetooth-related functions and owns the KBTDevice class
* that is a single local bluetooth device representation.
* It is used as a Singleton pattern thru the getDefaultConnector() method.
*
*/
#include <qobject.h>
#include <opie2/odebug.h>
#include <bluezlib.h>
#include <OTDeviceAddress.h>
namespace Opietooth2 {
class OTGateway;
class OTHCISocket;
class OTDeviceAddress;
class OTPeer;
/*
* This is the representation of a
* Bluetooth device for the local
* machine.
*/
class OTDriver : public QObject {
Q_OBJECT
public:
OTDriver( OTGateway * Ot, struct hci_dev_info* di);
~OTDriver();
inline OTGateway * gateway() const
{ return OT; }
/*
* Initializes the device using the passed hci_dev_info
* struct, contining the basic information in order to
* talk with the pyisical device.
*/
void init(struct hci_dev_info* di);
/*
* Open the device and obtains a file descriptor to id
* return if open
*/
bool open();
OTHCISocket * openSocket();
void closeSocket();
/*
* Return true if the device is opened.
*/
int isOpen()
{ return Fd != -1; };
/*
* Calls the ioctl(HCIDEVRESET) in order to
* reset the device.
*/
int reset();
// set Up if true and not yet up
void setUp( bool Mode );
/*
* Turn the device up and the reinitializes the device.
* If the device is already up, nothing is done.
*/
void bringUp();
/*
* Turn the device down and the reinitializes the device.
* If the device is already down, nothing is done.
*/
void bringDown();
// is the device UP now
bool isUp() const
{ return IsUp; }
// get current state
// return 1 if UP, 0 if DOWN, -1 if ERROR
int currentState();
/*
* Returns the name of the device. If the device is
* down, the device id is returned.
*/
QString name();
int devId() const
{ return Dev_id; };
/*
* Returns the string representation of the device id,
* with the same format of the hciconfig tool.
*/
QString devname()
{ return Dev; };
/*
* Returns the file descriptor for the local
- * connection to this device
+ * networkSetup to this device
*/
int fd() const
{ return Fd; };
void setfd(int _fd)
{ Fd = _fd; };
void setType(int _type)
{ Type = _type; };
int type() const
{ return Type; };
QString strType();
int iscan() const
{ return Iscan; }
void setIScan(int _iscan)
{ Iscan = _iscan; }
int pscan() const
{ return Pscan; }
void setPScan(int _pscan)
{ Pscan = _pscan; }
int authentication() const
{ return Auth; }
void setAuthentication(int _auth)
{ Auth = _auth; }
int encryption() const
{ return Encrypt; }
void setEncryption(int _encrypt)
{ Encrypt = _encrypt; }
void setDevId(int _dev_id)
{ Dev_id = _dev_id; };
void setDev(char* _dev)
{ Dev = _dev; };
void setFlags( unsigned long flags);
const OTDeviceAddress & address()
{ return Address; }
void setFeatures( unsigned char * _f);
QString features()
{ return Features; }
void setManufacturer(int compid);
QString manufacturer()
{ return Manufacturer; }
QString revision();
void setScanMode(bool iscan, bool pscan);
void setClass(unsigned long cls);
void changeDevName(const char* name);
void changeEncryption(bool _encryption);
void changeAuthentication(bool _auth);
void getClass( QString & service,
QString & device );
void changeClass( unsigned char service,
unsigned char major,
unsigned char minor);
QString getPeerName( const OTDeviceAddress & PAddr );
// address must be connected to this driver
long getLinkQuality( const OTDeviceAddress & Address );
signals :
void error( const QString & );
void stateChange( OTDriver * , bool );
void driverDisappeared( OTDriver * );
private slots :
/*
* Reinitializes the device, obtaining a fresh
* hci_dev_info structure.
*/
void reinit();
void SLOT_CloseFd();
private:
QString getRevEricsson();
QString getRevCsr(unsigned short rev);
QString Name;
QString Dev;
QString Revision;
QString Manufacturer;
OTDeviceAddress Address;
QString Features;
QTimer * AutoClose;
int Dev_id,Fd,Type;
bool IsUp;
int Iscan,Pscan,Auth,Encrypt;
// socket bound to this device
OTHCISocket * Socket;
// backpointer to opietooth system
OTGateway * OT;
};
}
#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp
index 1b61a2e..7fc8719 100644
--- a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp
@@ -1,774 +1,774 @@
#include <qmessagebox.h>
#include <qfile.h>
#include <qdir.h>
#include <qtextstream.h>
#include <qpixmap.h>
#include <qvector.h>
#include <qpe/resource.h>
#include <opie2/odebug.h>
#include <bluezlib.h>
#include <OTDevice.h>
#include <OTDriver.h>
#include <OTInquiry.h>
#include <OTDriverList.h>
#include <OTDeviceAddress.h>
#include <OTGateway.h>
using namespace Opietooth2;
// single instance
OTGateway * OTGateway::SingleGateway = 0;
int OTGateway::UseCount = 0;
OTGateway * OTGateway::getOTGateway( void ) {
if(SingleGateway == 0 ) {
SingleGateway = new OTGateway();
}
UseCount ++;
return SingleGateway;
}
void OTGateway::releaseOTGateway( void ) {
UseCount --;
if( UseCount == 0 ) {
delete SingleGateway;
SingleGateway = 0;
}
}
// open bluetooth system
OTGateway::OTGateway( void ) : QObject( 0, "OTGateway" ),
AllDrivers( this ),
AllPeers() {
ErrorConnectCount = 0;
TheOTDevice = 0;
Scanning = 0;
AllPeersModified = 0;
AllPeers.setAutoDelete( TRUE );
if ( ( HciCtl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) {
SLOT_ShowError( tr( "error opening hci socket" ) );
return;
}
// load all known devices
updateDrivers();
// load all peers we have ever seen
loadKnownPeers();
- // iterate over drivers and find active connections
+ // iterate over drivers and find active NetworkSetups
// adding/updating peers
- loadActiveConnections();
+ loadActiveNetworkSetups();
// check every 4 seconds the state of BT
timerEvent(0);
RefreshTimer = -1;
setRefreshTimer( 4000 );
// load known link keys
readLinkKeys();
}
// close bluetooth system
OTGateway::~OTGateway( void ) {
if( AllPeersModified ) {
saveKnownPeers();
}
if( Scanning )
delete Scanning;
if( TheOTDevice )
delete TheOTDevice;
if( HciCtl >= 0 ) {
::close( HciCtl );
}
}
void OTGateway::setRefreshTimer( int T ) {
if( RefreshTimer != -1 ) {
killTimer( RefreshTimer );
}
if( T == 0 )
T = 4000;
RefreshTimer = startTimer( T );
}
OTDevice * OTGateway::getOTDevice( ) {
if( TheOTDevice == 0 ) {
// load bluetooth device and check state
TheOTDevice = new OTDevice( this );
connect( TheOTDevice,
SIGNAL( isEnabled( int, bool ) ),
this,
SLOT( SLOT_Enabled( int, bool ) ) );
connect( TheOTDevice,
SIGNAL( error( const QString & ) ),
this,
SLOT( SLOT_ShowError( const QString & ) ) );
}
return TheOTDevice;
}
// start bluetooth (if stopped)
// return TRUE if started
void OTGateway::SLOT_SetEnabled( bool Mode ) {
if( Mode ) {
SLOT_Enable();
return;
}
SLOT_Disable();
}
void OTGateway::SLOT_Enable() {
getOTDevice()->attach();
}
void OTGateway::SLOT_Disable() {
getOTDevice()->detach();
}
bool OTGateway::needsEnabling() {
return getOTDevice()->needsAttach();
}
bool OTGateway::isEnabled() {
if( getOTDevice()->deviceNr() >= 0 &&
AllDrivers.count() != 0 &&
driver( getOTDevice()->deviceNr() )->isUp() )
return TRUE;
// else check system
return getOTDevice()->isAttached();
}
void OTGateway::SLOT_ShowError( const QString & S ) {
odebug << S << oendl;
if( ErrorConnectCount > 0 ) {
// pass error
emit error( QString( "<p>" ) + S + "</p>" );
return;
}
QMessageBox::warning( 0,
tr("OTGateway error"),
S );
}
void OTGateway::connectNotify( const char * S ) {
if( S && strcmp( S, "error(const QString&)" ) == 0 ) {
ErrorConnectCount ++;
}
}
void OTGateway::disconnectNotify( const char * S ) {
if( S && strcmp( S, "error(const QString&)" ) == 0 ) {
ErrorConnectCount --;
}
}
void OTGateway::timerEvent( QTimerEvent * ) {
OTDriver * D;
unsigned int oldc = AllDrivers.count();
bool old;
AllDrivers.update();
if( oldc != AllDrivers.count() ) {
updateDrivers();
} else {
for( unsigned int i = 0;
i < AllDrivers.count();
i ++ ) {
D = AllDrivers[i];
old = D->isUp();
if( D->currentState() >= 0 ) {
if( old != D->isUp() ) {
emit stateChange( D, D->isUp() );
}
} else {
// if one driver is unable to provide info
// we refresh all devices
updateDrivers();
return;
}
}
}
}
void OTGateway::SLOT_Enabled( int id, bool Up ) {
odebug << "device " << id << " state " << Up << oendl;
if( Up ) {
// device is up -> detect it
updateDrivers();
if( (unsigned)id >= AllDrivers.count() ) {
// to make sure that the driver really IS detected
AllDrivers[id]->bringUp();
}
} // if DOWN device already down
emit deviceEnabled( Up );
}
void OTGateway::updateDrivers( void ) {
OTDriver * D;
AllDrivers.update();
odebug << "updated drivers. now " << AllDrivers.count() << oendl;
// connect signals for each driver
for( unsigned int i = 0;
i < AllDrivers.count();
i ++ ) {
D = AllDrivers[i];
connect( D,
SIGNAL( error( const QString & ) ),
this,
SLOT( SLOT_ShowError( const QString & ) )
);
connect( D,
SIGNAL( stateChange( OTDriver *, bool ) ),
this,
SIGNAL( stateChange( OTDriver *, bool ) )
);
connect( D,
SIGNAL( driverDisappeared( OTDriver * ) ),
this,
SLOT( SLOT_DriverDisappeared( OTDriver * ) )
);
}
// verify main device too
if( TheOTDevice )
TheOTDevice->checkAttach();
// set to default scanning hardware
setScanWith( 0 );
emit driverListChanged();
}
void OTGateway::SLOT_DriverDisappeared( OTDriver * D ) {
odebug << "Driver " << D->devname() << " when offline" << oendl;
updateDrivers();
}
void OTGateway::scanNeighbourhood( OTDriver * D ) {
if( Scanning ) {
stopScanOfNeighbourhood();
}
if( D ) {
setScanWith( D );
}
Scanning = new OTInquiry( scanWith() );
connect( Scanning,
SIGNAL( peerFound( OTPeer *, bool )),
this,
SLOT( SLOT_PeerDetected( OTPeer *, bool ) )
);
connect( Scanning,
SIGNAL( finished()),
this,
SLOT( SLOT_FinishedDetecting() )
);
// start scanning
Scanning->inquire( 30.0 );
}
OTPeer* OTGateway::findPeer( const OTDeviceAddress & Addr ) {
for( unsigned int i = 0 ; i < AllPeers.count(); i ++ ) {
if( AllPeers[i]->address() == Addr ) {
return AllPeers[i];
}
}
return 0;
}
OTDriver* OTGateway::findDriver( const OTDeviceAddress & Addr ) {
for( unsigned int i = 0 ; i < AllDrivers.count(); i ++ ) {
if( AllDrivers[i]->address() == Addr ) {
return AllDrivers[i];
}
}
return 0;
}
void OTGateway::SLOT_PeerDetected( OTPeer * P, bool IsNew ) {
if( IsNew ) {
// new peer
odebug << "New peer " << P->name() << oendl;
addPeer( P );
}
emit detectedPeer( P, IsNew );
}
void OTGateway::addPeer( OTPeer * P ) {
AllPeers.resize( AllPeers.size()+1);
AllPeers.insert( AllPeers.size()-1, P );
AllPeersModified = 1;
}
void OTGateway::removePeer( OTPeer * P ) {
int i = AllPeers.find( P );
if( i ) {
AllPeers.remove( i );
AllPeersModified = 1;
}
}
void OTGateway::stopScanOfNeighbourhood( void ) {
if( Scanning ) {
delete Scanning;
Scanning = 0;
}
}
void OTGateway::SLOT_FinishedDetecting() {
stopScanOfNeighbourhood();
emit finishedDetecting();
}
const char * OTGateway::deviceTypeToName( int cls ) {
switch ( (cls & 0x001F00) >> 8) {
case 0x00:
return "misc";
case 0x01:
return "computer";
case 0x02:
return "phone";
case 0x03:
return "lan";
case 0x04:
return "av";
case 0x05:
return "peripheral";
case 0x06:
return "imaging";
case 0x07:
default :
break;
}
return "unknown";
}
-PANConnectionVector OTGateway::getPANConnections( void ) {
- PANConnectionVector V;
+PANNetworkSetupVector OTGateway::getPANNetworkSetups( void ) {
+ PANNetworkSetupVector V;
struct bnep_connlist_req req;
struct bnep_conninfo ci[48];
V.setAutoDelete(TRUE);
int ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP);
if (ctl < 0) {
odebug << "Failed to open control socket" << oendl;
return V;
}
req.cnum = 48;
req.ci = ci;
if (ioctl(ctl, BNEPGETCONNLIST, &req)) {
- odebug << "Failed to get connection list" << oendl;
+ odebug << "Failed to get NetworkSetup list" << oendl;
::close( ctl );
return V;
}
for ( unsigned i=0; i < req.cnum; i++) {
V.resize( V.size() + 1 );
if( ci[i].role == BNEP_SVC_PANU ) {
// we are the client
- V.insert( V.size()-1, new OTPANConnection(
+ V.insert( V.size()-1, new OTPANNetworkSetup(
ci[i].device,
batostr((bdaddr_t *) ci[i].dst)
) );
}
}
::close( ctl );
return V;
}
struct link_key {
bdaddr_t sba;
bdaddr_t dba;
uint8_t key[16];
uint8_t type;
time_t time;
};
void OTGateway::readLinkKeys( void ) {
struct link_key k;
int rv;
AllKeys.truncate(0);
QFile F( "/etc/bluetooth/link_key" );
if( ! F.open( IO_ReadOnly ) ) {
emit error( tr("Cannot open link_key file") );
return;
}
while( 1 ) {
rv = F.readBlock( (char *)&k, sizeof( k ) );
if( rv == 0 )
// EOF
break;
if( rv < 0 ) {
emit error( tr("Read error in link key file") );
}
AllKeys.resize( AllKeys.size()+1 );
AllKeys[ AllKeys.size()-1 ].From.setBDAddr( k.sba );
AllKeys[ AllKeys.size()-1 ].To.setBDAddr( k.dba );
}
}
bool OTGateway::removeLinkKey( unsigned int Index ) {
OTLinkKey & LK = AllKeys[Index];
struct link_key k;
int rv;
QFile F( "/etc/bluetooth/link_key" );
QFile OutF( "/etc/bluetooth/newlink_key" );
if( ! F.open( IO_ReadOnly ) ) {
emit error( tr("Cannot open link_key file") );
return 0;
}
if( ! OutF.open( IO_WriteOnly | IO_Truncate ) ) {
emit error( tr("Cannot open temporary link_key file") );
return 0;
}
while( 1 ) {
rv = F.readBlock( (char *)&k, sizeof( k ) );
if( rv == 0 )
// EOF
break;
if( rv < 0 ) {
emit error( tr("Read error in link key file") );
return 0;
}
if( LK.from() != OTDeviceAddress( k.sba ) ||
LK.to() != OTDeviceAddress( k.dba ) ) {
// copy
OutF.writeBlock( (char *)&k, sizeof( k ) );
} // else remove this key
}
// rename files
QDir D( "/etc/bluetooth" );
D.remove( "link_key" );
D.rename( "newlink_key", "link_key" );
// restart hcid
system( "/etc/init.d/hcid stop" );
system( "/etc/init.d/hcid start" );
// remove from table
if( Index < (AllKeys.size()-1) ) {
// collapse array
AllKeys[Index] = AllKeys[AllKeys.size()-1];
}
// remove last element
AllKeys.resize( AllKeys.size()-1 );
return 1;
}
#define MAXCONNECTIONS 10
-void OTGateway::loadActiveConnections( void ) {
+void OTGateway::loadActiveNetworkSetups( void ) {
struct hci_conn_list_req *cl;
struct hci_conn_info *ci;
OTDeviceAddress Addr;
OTPeer * P;
if (!(cl = (struct hci_conn_list_req *)malloc(
MAXCONNECTIONS * sizeof(*ci) + sizeof(*cl)))) {
emit error( tr("Can't allocate memory") );
return;
}
memset( cl, 0, MAXCONNECTIONS * sizeof(*ci) + sizeof(*cl) );
for( unsigned int i = 0;
i < AllDrivers.count();
i ++ ) {
if( ! AllDrivers[i]->isUp() ) {
continue;
}
- // driver is up -> check connections
+ // driver is up -> check NetworkSetups
cl->dev_id = AllDrivers[i]->devId();
cl->conn_num = MAXCONNECTIONS;
ci = cl->conn_info;
if (ioctl( getSocket(), HCIGETCONNLIST, (void *) cl)) {
- emit error( tr("Can't get connection list") );
+ emit error( tr("Can't get NetworkSetup list") );
break;
}
for ( int k = 0; k < cl->conn_num; k++, ci++) {
if( ci->state != BT_CONNECTED ) {
// not yet connected
continue;
}
Addr.setBDAddr( ci->bdaddr );
P = findPeer( Addr );
if( ! P ) {
// peer not yet known -> add
P = new OTPeer( this );
addPeer( P );
P->setAddress( Addr );
// infoQueue.push_back(info);
P->setName( AllDrivers[i]->getPeerName( Addr ) );
}
P->setState( OTPeer::Peer_Up );
P->setConnectedTo( AllDrivers[i] );
}
}
free( cl );
}
void OTGateway::loadKnownPeers( void ) {
QDir SaveDir = QDir::home();
if( ! SaveDir.exists( "Settings" ) ) {
return;
}
SaveDir.cd( "Settings" );
if( ! SaveDir.exists( "opietooth" ) ) {
return;
}
SaveDir.cd( "opietooth" );
QFile F( SaveDir.path() + "/SeenDevices.conf" );
if( F.open( IO_ReadOnly ) ) {
QTextStream TS(&F);
long count;
count = TS.readLine().toLong();
while( count > 0 ) {
addPeer( new OTPeer( TS, this ) );
count --;
}
}
AllPeersModified = 0;
}
void OTGateway::saveKnownPeers( void ) {
QDir SaveDir = QDir::home();
if( ! SaveDir.exists( "Settings" ) ) {
SaveDir.mkdir( "Settings" );
}
SaveDir.cd( "Settings" );
if( ! SaveDir.exists( "opietooth" ) ) {
SaveDir.mkdir( "opietooth" );
}
SaveDir.cd( "opietooth" );
QFile F( SaveDir.path() + "/SeenDevices.conf" );
if( F.open( IO_WriteOnly | IO_Truncate ) ) {
QTextStream TS(&F);
QString S;
TS << AllPeers.count() << endl;
for( unsigned int i = 0;
i < AllPeers.count();
i ++ ) {
AllPeers[i]->save( TS );
}
AllPeersModified = 0;
}
AllPeersModified = 0;
}
int OTGateway::connectedToRFCommChannel( const OTDeviceAddress & Addr,
int channel ) {
int s;
if( (s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_RFCOMM)) < 0 ) {
emit error( tr("Can't open RFCOMM control socket") );
return 0;
}
// get all rfcomm devices
{ struct rfcomm_dev_list_req *dl;
struct rfcomm_dev_info *di, *dr;
int i;
dl = (struct rfcomm_dev_list_req *)alloca(
sizeof(*dl) + RFCOMM_MAX_DEV * sizeof(*di));
memset( dl, 0, sizeof(*dl) + RFCOMM_MAX_DEV * sizeof(*di) );
dl->dev_num = RFCOMM_MAX_DEV;
di = dl->dev_info;
if( ::ioctl(s, RFCOMMGETDEVLIST, (void *) dl) < 0) {
emit error( tr("Can't get device list") );
::close( s );
return 0;
}
dr = di;
for (i = 0; i < dl->dev_num; i++, dr++) {
// connected to Peer
if( Addr == OTDeviceAddress( dr->dst ) &&
channel == dr->channel &&
( dr->state != 0 )
) {
// return device ID
return dr->id;
}
}
}
// no device
return -1;
}
static int byID( struct rfcomm_dev_info * d1,
struct rfcomm_dev_info * d2 ) {
return d1->id - d2->id;
}
int OTGateway::getFreeRFCommDevice( void ) {
int s;
if( (s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_RFCOMM)) < 0 ) {
emit error( tr("Can't open RFCOMM control socket") );
return 0;
}
// get all rfcomm devices
{ struct rfcomm_dev_list_req *dl;
struct rfcomm_dev_info *di, *dr;
int i;
dl = (struct rfcomm_dev_list_req *)alloca(
sizeof(*dl) + RFCOMM_MAX_DEV * sizeof(*di));
dl->dev_num = RFCOMM_MAX_DEV;
di = dl->dev_info;
if( ::ioctl(s, RFCOMMGETDEVLIST, (void *) dl) < 0) {
emit error( tr("Can't get device list") );
::close( s );
return 0;
}
// s
if( dl->dev_num ) {
qsort( di, sizeof(struct rfcomm_dev_info),
dl->dev_num, (int(*)(const void*,const void*))byID );
int id = 0;
dr = di;
// find lowest free device number
for (i = 0; i < dl->dev_num; i++, dr++) {
if( id != dr->id ) {
return id;
}
id ++;
}
return id;
} else {
return 0;
}
}
}
int OTGateway::releaseRFCommDevice( int devnr ) {
int s;
if( (s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_RFCOMM)) < 0 ) {
emit error( tr("Can't open RFCOMM control socket") );
return 0;
}
// get all rfcomm devices
{ struct rfcomm_dev_list_req *dl;
struct rfcomm_dev_info *di, *dr;
int i;
dl = (struct rfcomm_dev_list_req *)alloca(
sizeof(*dl) + RFCOMM_MAX_DEV * sizeof(*di));
memset( dl, 0, sizeof(*dl) + RFCOMM_MAX_DEV * sizeof(*di) );
dl->dev_num = RFCOMM_MAX_DEV;
di = dl->dev_info;
if( ::ioctl(s, RFCOMMGETDEVLIST, (void *) dl) < 0) {
emit error( tr("Can't get device list") );
::close( s );
return 0;
}
dr = di;
for (i = 0; i < dl->dev_num; i++, dr++) {
if( dr->id == devnr ) {
- // still in connection list
+ // still in NetworkSetup list
struct rfcomm_dev_req req;
int err;
memset(&req, 0, sizeof(req));
req.dev_id = devnr;
if ((err = ioctl(s, RFCOMMRELEASEDEV, &req)) < 0 ) {
return err;
}
return 0;
}
}
}
// no device -> nothing to release eiterh
return 0;
}
diff --git a/noncore/settings/networksettings2/opietooth2/OTGateway.h b/noncore/settings/networksettings2/opietooth2/OTGateway.h
index 11c6b30..d0e42db 100644
--- a/noncore/settings/networksettings2/opietooth2/OTGateway.h
+++ b/noncore/settings/networksettings2/opietooth2/OTGateway.h
@@ -1,200 +1,200 @@
#ifndef OTGATEWAY_H
#define OTGATEWAY_H
#include <qobject.h>
#include <qvector.h>
#include <qmap.h>
#include <OTDriverList.h>
#include <OTInquiry.h>
class QPixmap;
namespace Opietooth2 {
class OTDriverList;
class OTDriver;
class OTDevice;
class OTPeer;
class OTInquiry;
-class OTPANConnection;
+class OTPANNetworkSetup;
class OTLinkKey;
typedef QVector<OTPeer> PeerVector;
-typedef QVector<OTPANConnection> PANConnectionVector;
+typedef QVector<OTPANNetworkSetup> PANNetworkSetupVector;
typedef QArray<OTLinkKey> LinkKeyArray;
class OTLinkKey {
public :
OTLinkKey( const OTDeviceAddress & F,
const OTDeviceAddress & T ) {
From = F;
To = T;
}
const OTDeviceAddress & to()
{ return To; }
const OTDeviceAddress & from()
{ return From; }
OTDeviceAddress From;
OTDeviceAddress To;
};
-class OTPANConnection {
+class OTPANNetworkSetup {
public :
- OTPANConnection( const QString & Dev, const QString & CT ) {
+ OTPANNetworkSetup( const QString & Dev, const QString & CT ) {
Device = Dev;
ConnectedTo = CT;
}
QString Device;
QString ConnectedTo;
};
class OTGateway : public QObject {
Q_OBJECT
public :
// single instance
static OTGateway * getOTGateway( void );
static void releaseOTGateway( void );
// convert device type as class to name for that class
static const char * deviceTypeToName( int Cls );
// open bluetooth system
OTGateway( void );
// close bluetooth system
~OTGateway( void );
// get access to system device
OTDevice * getOTDevice();
// return true if this device needs enabling of bluetooth
bool needsEnabling();
// return true if system is running
bool isEnabled();
void setRefreshTimer( int MilleSecs );
// return socket to HCI raw layer
inline int getSocket()
{ return HciCtl; }
OTDriverList & getDriverList()
{ return AllDrivers; }
OTDriver * driver( int nr )
{ return AllDrivers.count() == 0 ? 0 : AllDrivers[nr]; }
void updateDrivers();
- PANConnectionVector getPANConnections();
+ PANNetworkSetupVector getPANNetworkSetups();
// scan neighbourhood using device
void scanNeighbourhood( OTDriver * D = 0 );
void stopScanOfNeighbourhood(void );
void setScanWith( OTDriver * D = 0 )
{ ScanWith = (D) ? D :
(AllDrivers.count() ) ? AllDrivers[0] : 0; }
OTDriver * scanWith( void )
{ return ScanWith; }
// get list of all detected peers
inline const PeerVector & peers( void )
{ return AllPeers; }
// ping peer to see if it is up
bool isPeerUp( const OTDeviceAddress & PAddr,
int timeoutInSec = 1,
int timeoutInUSec = 0,
int retry = 1 );
OTPeer * findPeer( const OTDeviceAddress & Addr );
void removePeer( OTPeer * P );
void addPeer( OTPeer * P );
OTDriver * findDriver( const OTDeviceAddress & Addr );
inline const LinkKeyArray & getLinkKeys() const
{ return AllKeys; }
bool removeLinkKey( unsigned int index );
// return device number if we are connected over any device
// to the channel
// else returns -1
int connectedToRFCommChannel( const OTDeviceAddress & Addr, int channel );
int getFreeRFCommDevice( void );
// return 0 if properly released
int releaseRFCommDevice( int DevNr );
public slots :
// start bluetooth system
void SLOT_SetEnabled( bool );
void SLOT_Enable();
void SLOT_Disable();
// show error
void SLOT_ShowError( const QString & );
void SLOT_Enabled( int, bool );
void SLOT_DriverDisappeared( OTDriver * );
void SLOT_PeerDetected( OTPeer *, bool );
void SLOT_FinishedDetecting();
signals :
// any error
void error( const QString & );
// signal state of bluetooth driver
void stateChange( OTDriver * D, bool State );
// sent when list of drivers changees
void driverListChanged();
// sent when bluetooth on device is enabled
void deviceEnabled( bool );
// sent when a (new if bool = TRUE) peer is detected
void detectedPeer( OTPeer *, bool );
// end of detection process
void finishedDetecting();
protected :
void connectNotify( const char * Signal );
void disconnectNotify( const char * Signal );
void timerEvent( QTimerEvent * );
private :
- void loadActiveConnections( void );
+ void loadActiveNetworkSetups( void );
void loadKnownPeers( void );
void saveKnownPeers( void );
bool isConnectedTo( int devid,
const OTDeviceAddress & Address );
void readLinkKeys();
static OTGateway * SingleGateway;
static int UseCount;
OTDriver * ScanWith;
OTDriverList AllDrivers;
OTDevice * TheOTDevice;
int HciCtl;
int ErrorConnectCount;
int RefreshTimer;
OTInquiry * Scanning;
bool AllPeersModified;
PeerVector AllPeers;
LinkKeyArray AllKeys;
};
}
#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTInquiry.h b/noncore/settings/networksettings2/opietooth2/OTInquiry.h
index f7bdeec..559af7a 100644
--- a/noncore/settings/networksettings2/opietooth2/OTInquiry.h
+++ b/noncore/settings/networksettings2/opietooth2/OTInquiry.h
@@ -1,178 +1,178 @@
//-*-c++-*-
/***************************************************************************
* Copyright (C) 2003 by Fred Schaettgen *
* kdebluetooth@schaettgen.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef OTINQUIRY_H
#define OTINQUIRY_H
#include <qstring.h>
#include <qobject.h>
#include <qguardedptr.h>
#include <qtimer.h>
#include <OTPeer.h>
// #include <set>
// #include <deque>
namespace Opietooth2 {
class QSocket;
class QDateTime;
class OTDriver;
class OTHCISocket;
/** Scans for nearby bluetooth devices.
* This class provides an asynchronous interface to the
* inquriy HCI command. To scan for other devices, connect
* to the signals neighbourFound() and finished() and call
* inquiry(). Inquiry results are signalled as soon as they arrive,
* so the information can be displayed before the whole inquiry
* process is finished.
- * Still no connections should be set up before
+ * Still no networkSetups should be set up before
* the finished() signal was sent (hmm, is this always true..?)
*/
class OTInquiry : public QObject {
Q_OBJECT
public:
/** Constructor.
@param owner The owning parent object
*/
OTInquiry( OTDriver* Drv );
/** Destructor. */
virtual ~OTInquiry();
// General/Unlimited Inquiry Access Code
static const int GIAC = 0x9E8B33;
// Limited Dedicated Inquiry Access Code
static const int LIAC = 0x9E8B00;
/** Starts the inquiry.
if you start inquiry several times without calling clear(),
you will receive each result only once.
@param timeout duration of the inquiry in seconds.
It will be rounded to the next multiple of 1.28 sec,
with a maximum of 61.44 sec.
@param lap
*/
bool inquire( double timeout = 8.0,
int numResponses = 0,
int lap = GIAC);
void stopInquiring( );
/** Enters periodic inquiry mode.
An inquiry will be started at a random time in the intervall
between minduration and maxduration.
@param minduration minimum time between two inquiries. Rounded to
a multiple of 1.28, (3.84 <= d <= 83884.8)
@param maxduration maximum time between two inquiries. Rounded to
a multiple of 1.28, (3.84 <= d <= 83884.8)
@param timeout duration of the inquiry in seconds.
It will be rounded to the next multiple of 1.28 sec,
with a maximum of 61.44 sec.
@param numResponses Number of responses after which the inquiry
will be stopped. 0 means no limit.
@param lap
*/
/*
void inquirePeriodically( double minduration,
double maxduration,
double timeout = 8.0,
int numResponses = 0,
int lap = LIAC
);
*/
/** checks if there the inquiry is running currently
@return true if there is an inquiry running
which was started by this object.
@todo possibility to check for "foreign" inquiries. Deal with
the fact that we can receive foreign inquiry results.
*/
bool isInquiring();
/** This function returns true after after an inquiry was
started, results were received and the inquiry ended successfully.
This can be the case without calling inquiry() at all, because
results of inquiries started by other programs are also processed.
*/
bool isFinished();
/** Resets the list of received results and sets
isInquiryComplete() to false.
*/
void reset();
inline OTDriver * driver() const
{ return Driver; }
protected:
/** Called when a new neighbour was found. The default
implementation emits the neighbourFound signal.
@param bdaddr the address found.
*/
virtual void onPeerFound( OTPeer * Peer, bool );
enum ErrorCode {
InquiryFinishedTimeout = 0x0100
};
signals :
void peerFound( OTPeer *, bool );
/** Emitted after an inquiry has finished successfully.
If the inquiry was canceled, no finished signals is emitted.
This signal can be emitted without having called inquiry, since
other processes may have started an inquiry.
*/
void finished();
/** Emitted instead of finished if an error occured after
calling inquiry() or periodicInquiryMode()
@param code error code.
@param message Error message
*/
void error( QString message );
private:
// std::set<DeviceAddress> addrCache;
// double currentTimeout;
// QByteArray* buf;
// QSocket* hciSocket;
QGuardedPtr<OTHCISocket> Socket;
OTDriver * Driver;
//QDateTime *startTime;
QTimer *InquiryTimeoutTimer;
// std::deque<InquiryInfo> infoQueue;
bool SuccessfullyStarted;
bool SuccessfullyEnded;
private slots:
void slotInquiryTimeout();
void slotHCIEvent(unsigned char eventCode, QByteArray buf);
};
}
#endif
diff --git a/noncore/settings/networksettings2/ppp/PPPDialingedit.cpp b/noncore/settings/networksettings2/ppp/PPPDialingedit.cpp
index 9264ceb..2b03c73 100644
--- a/noncore/settings/networksettings2/ppp/PPPDialingedit.cpp
+++ b/noncore/settings/networksettings2/ppp/PPPDialingedit.cpp
@@ -1,25 +1,24 @@
#include <stdio.h>
#include <qcombobox.h>
#include <qmessagebox.h>
#include <qradiobutton.h>
#include <qlineedit.h>
#include <GUIUtils.h>
#include "PPPDialingedit.h"
PPPDialingEdit::PPPDialingEdit( QWidget * Parent ) :
PPPDialingGUI( Parent ){
// populate widget stack
}
QString PPPDialingEdit::acceptable( void ) {
return QString();
}
-bool PPPDialingEdit::commit( PPPData & D ) {
- bool SM;
- return SM;
+bool PPPDialingEdit::commit( PPPData & ) {
+ return true;
}
void PPPDialingEdit::showData( PPPData & D ) {
}
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
index 8c15e9c..884168c 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
@@ -1,83 +1,83 @@
#include <qfile.h>
#include <resources.h>
#include <qtextstream.h>
#include "ppp_NN.h"
#include "ppp_NNI.h"
#include "netnodeinterface.h"
QStringList * PPPNetNode::ProperFiles = 0;
static const char * PPPNeeds[] =
{ "modem",
0
};
static const char * PPPProvides[] =
- { "connection",
+ { "NetworkSetup",
0
};
/**
* Constructor, find all of the possible interfaces
*/
-PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) {
+PPPNetNode::PPPNetNode() : ANetNode(tr("PPP NetworkSetup")) {
NSResources->addSystemFile(
"pap-secrets", "/etc/ppp/pap-secrets", 0 );
NSResources->addSystemFile(
"chap-secrets", "/etc/ppp/chap-secrets", 0 );
}
/**
* 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 PPPProvides;
}
QStringList PPPNetNode::properFiles( void ) {
QStringList SL;
SL << "peers" << "chatscripts";
return SL;
}
// need to generate :
// /etc/ppp/pap-secrets
// /etc/ppp/pap-secrets
bool PPPNetNode::hasDataForFile( SystemFile & S ) {
return S.name() == "pap-secrets" ||
S.name() == "chap-secrets" ;
}
QString PPPNetNode::genNic( long NicNr ) {
QString S;
return S.sprintf( "ppp%ld", NicNr );
}
void PPPNetNode::setSpecificAttribute( QString & , QString & ) {
}
void PPPNetNode::saveSpecificAttribute( QTextStream & ) {
}
OPIE_NS2_PLUGIN( NetNodeInterface_T<PPPNetNode> )
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
index 9e3bb64..7286d96 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
@@ -1,235 +1,235 @@
#include <qfile.h>
#include <qfileinfo.h>
#include "PPPedit.h"
#include "ppp_NNI.h"
#include "ppp_NN.h"
APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) {
Data.DNS.ServerAssigned = 1;
Data.DNS.DomainName = "";
Data.Auth.Mode = 0;
Data.Auth.Login.Expect = "ogin:";
Data.Auth.Password.Expect = "assword:";
Data.Auth.PCEMode = 0;
Data.Auth.Client = "*";
Data.Auth.Server = "*";
Data.Auth.Secret = "";
Data.IP.LocalAddress = "10.0.0.1";
Data.IP.RemoteAddress = "10.0.0.2";
Data.IP.LocalOverrule = 1;
Data.IP.RemoteOverrule = 1;
Data.IP.GWAutomatic = 1;
Data.IP.GWAddress = "";
Data.IP.GWIsDefault = 1;
Data.IP.GWIfNotSet = 1;
Data.Run.PreConnect = "";
Data.Run.PostConnect = "";
Data.Run.PreDisconnect = "";
Data.Run.PostDisconnect = "";
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 == "iplocaloverrule" ) {
Data.IP.LocalOverrule = (V == "yes");
} else if( A == "ipremoteoverrule" ) {
Data.IP.RemoteOverrule = (V == "yes");
} else if( A == "ipgwautomatic" ) {
Data.IP.GWAutomatic = (V == "yes");
} else if( A == "ipgwisdefault" ) {
Data.IP.GWIsDefault = (V == "yes");
} else if( A == "ipgwifnotset" ) {
Data.IP.GWIfNotSet = (V == "yes");
} else if( A == "iplocaladdress" ) {
Data.IP.LocalAddress = V;
} else if( A == "ipremoteaddress" ) {
Data.IP.RemoteAddress = V;
} else if( A == "ipgwaddress" ) {
Data.IP.GWAddress = V;
}
} else if( A.startsWith( "run" ) ) {
if( A == "runpreconnect" ) {
Data.Run.PreConnect = V;
} else if( A == "runpostconnect" ) {
Data.Run.PostConnect = V;
} else if( A == "runpredisconnect" ) {
Data.Run.PreDisconnect = V;
} else if( A == "runpostdisconnect" ) {
Data.Run.PostDisconnect = 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 << "ipgwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl;
TS << "ipgwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl;
TS << "ipgwifnotset=" << ( ( Data.IP.GWIfNotSet ) ? "yes" : "no" ) << endl;
TS << "iplocaloverrule=" << ( ( Data.IP.LocalOverrule ) ? "yes" : "no" ) << endl;
TS << "ipremoteoverrule=" << ( ( Data.IP.RemoteOverrule ) ? "yes" : "no" ) << endl;
TS << "iplocaladdress=" << Data.IP.LocalAddress << endl;
TS << "ipremoteaddress=" << Data.IP.RemoteAddress << endl;
TS << "ipgwaddress=" << Data.IP.GWAddress << endl;
TS << "runpreconnect=" << Data.Run.PreConnect << endl;
TS << "runpostconnect=" << Data.Run.PostConnect << endl;
TS << "runpredisconnect=" << Data.Run.PreDisconnect << endl;
TS << "runpostdisconnect=" << Data.Run.PostDisconnect << 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::openFile( SystemFile & SF ) {
if( SF.name() == "peers" ) {
SF.setPath( removeSpaces(
- QString( "/tmp/ppp/peers/" ) + connection()->name() ) );
+ QString( "/tmp/ppp/peers/" ) + networkSetup()->name() ) );
return 1;
} else if ( SF.name() == "chatscripts" ) {
SF.setPath( removeSpaces(
- QString( "/tmp/chatscripts/" ) + connection()->name() ) );
+ QString( "/tmp/chatscripts/" ) + networkSetup()->name() ) );
return 1;
}
return 0;
}
short APPP::generateFile( SystemFile & SF, long DevNr ) {
short rvl, rvd;
rvl = 1;
rvd = 1;
if( SF.name() == "pap-secrets" ) {
Log(("Generate PPP for %s\n", SF.name().latin1() ));
if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) {
SF << "# secrets for "
- << connection()->name().latin1()
+ << networkSetup()->name().latin1()
<< endl;
SF << Data.Auth.Client
<< " "
<< Data.Auth.Server
<< " "
<< Data.Auth.Secret
<< endl;
rvl = 0;
- rvd = connection()->getToplevel()->generateFileEmbedded(
+ rvd = networkSetup()->getToplevel()->generateFileEmbedded(
SF, DevNr );
}
} else if( SF.name() == "chap-secrets" ) {
Log(("Generate PPP for %s\n", SF.name().latin1() ));
if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) {
// used for both EAP and Chap
SF << "# secrets for "
- << connection()->name().latin1()
+ << networkSetup()->name().latin1()
<< endl;
SF << Data.Auth.Client
<< " "
<< Data.Auth.Server
<< " "
<< Data.Auth.Secret
<< endl;
rvl = 0;
- rvd = connection()->getToplevel()->generateFileEmbedded(
+ rvd = networkSetup()->getToplevel()->generateFileEmbedded(
SF, DevNr );
}
} else if ( SF.name() == "peers" ) {
QFileInfo FI(SF.path());
Log(("Generate PPP for %s\n", SF.name().latin1() ));
SF << "connect \"/usr/sbin/chat -v -f /etc/chatscripts/"
<< FI.baseName()
<< "\""
<< endl;
if( Data.IP.GWIsDefault ) {
SF << "defaultroute"
<< endl;
}
SF << "linkname "
<< removeSpaces( SF.name().latin1() )
<< endl;
// insert other data here
rvl = 0;
- rvd = connection()->getToplevel()->generateFileEmbedded(
+ rvd = networkSetup()->getToplevel()->generateFileEmbedded(
SF, DevNr );
} else if ( SF.name() == "chatscripts" ) {
Log(("Generate PPP for %s\n", SF.name().latin1() ));
rvl = 0;
- rvd = connection()->getToplevel()->generateFileEmbedded(
+ rvd = networkSetup()->getToplevel()->generateFileEmbedded(
SF, DevNr );
}
return (rvd == 2 || rvl == 2 ) ? 2 :
(rvd == 0 || rvl == 0 ) ? 0 : 1;
}
diff --git a/noncore/settings/networksettings2/ppp/ppprun.cpp b/noncore/settings/networksettings2/ppp/ppprun.cpp
index 8403e6d..f548483 100644
--- a/noncore/settings/networksettings2/ppp/ppprun.cpp
+++ b/noncore/settings/networksettings2/ppp/ppprun.cpp
@@ -1,52 +1,52 @@
#include <resources.h>
#include "ppprun.h"
PPPRun::PPPRun( ANetNodeInstance * NNI, PPPData & Data ) :
RuntimeInfo( NNI ), Pat( "eth[0-9]" ) {
D = &Data;
}
State_t PPPRun::detectState( void ) {
if( isMyPPPDRunning( ) ) {
return ( isMyPPPUp() ) ? IsUp : Available;
}
return Off;
}
-QString PPPRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
+QString PPPRun::setMyState( NetworkSetup * , Action_t , bool ) {
return QString();
}
bool PPPRun::isMyPPPDRunning( void ) {
return 0;
}
bool PPPRun::isMyPPPUp( void ) {
System & S = NSResources->system();
InterfaceInfo * Run;
QRegExp R( "ppp[0-9]" );
for( QDictIterator<InterfaceInfo> It(S.interfaces());
It.current();
++It ) {
Run = It.current();
if( R.match( Run->Name ) >= 0 &&
Run->IsPointToPoint
) {
// this is a LAN card
- if( Run->assignedConnection() == netNode()->connection() ) {
+ if( Run->assignedToNetworkSetup() == netNode()->networkSetup() ) {
// assigned to us
return 1;
}
}
}
return 0;
}
bool PPPRun::handlesInterface( const QString & S ) {
return Pat.match( S ) >= 0;
}
bool PPPRun::handlesInterface( InterfaceInfo * I ) {
return handlesInterface( I->Name );
}
diff --git a/noncore/settings/networksettings2/ppp/ppprun.h b/noncore/settings/networksettings2/ppp/ppprun.h
index 2990a96..9535382 100644
--- a/noncore/settings/networksettings2/ppp/ppprun.h
+++ b/noncore/settings/networksettings2/ppp/ppprun.h
@@ -1,37 +1,37 @@
#ifndef PPPRUN_H
#define PPPRUN_H
#include <qregexp.h>
#include <netnode.h>
#include "pppdata.h"
class PPPRun : public RuntimeInfo {
public :
PPPRun( ANetNodeInstance * NNI,
PPPData & Data );
bool handlesInterface( const QString & I );
bool handlesInterface( InterfaceInfo * );
State_t detectState( void );
virtual RuntimeInfo * device( void )
{ return this; }
virtual RuntimeInfo * connection( void )
{ return this; }
protected :
- QString setMyState( NodeCollection * , Action_t, bool );
+ QString setMyState( NetworkSetup * , Action_t, bool );
private :
bool isMyPPPDRunning( void );
bool isMyPPPUp( void );
PPPData * D;
QRegExp Pat;
};
#endif
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp
index 1e6912e..007f4a5 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NN.cpp
@@ -1,58 +1,58 @@
#include <resources.h>
#include "profile_NN.h"
#include "profile_NNI.h"
#include "netnodeinterface.h"
static const char * ProfileNeeds[] =
- { "connection",
+ { "NetworkSetup",
0
};
static const char * ProfileProvides[] =
{ "fullsetup",
0
};
/**
* Constructor, find all of the possible interfaces
*/
-ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) {
+ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular NetworkSetup profile")) {
NSResources->addSystemFile(
"interfaces", "/etc/network/interfaces", 1 );
}
/**
* 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>\
+<p>Define use of an IP NetworkSetup.</p>\
+<p>Configure if and when this NetworkSetup 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 ProfileProvides;
}
void ProfileNetNode::setSpecificAttribute( QString & , QString & ) {
}
void ProfileNetNode::saveSpecificAttribute( QTextStream & ) {
}
OPIE_NS2_PLUGIN( NetNodeInterface_T<ProfileNetNode> )
diff --git a/noncore/settings/networksettings2/profile/profiledata.h b/noncore/settings/networksettings2/profile/profiledata.h
index c9577e5..2f7060d 100644
--- a/noncore/settings/networksettings2/profile/profiledata.h
+++ b/noncore/settings/networksettings2/profile/profiledata.h
@@ -1,17 +1,17 @@
#ifndef PROFILE_DATA_H
#define PROFILE_DATA_H
#include <qstring.h>
class ProfileData {
public :
QString Description;
// start up automatically
bool Automatic;
// if started up automatically, ask user for confirmation
bool Confirm;
- // Do not bring this connection up
+ // Do not bring this networkSetup up
bool Disabled;
bool TriggerVPN;
} ;
#endif
diff --git a/noncore/settings/networksettings2/profile/profileedit.cpp b/noncore/settings/networksettings2/profile/profileedit.cpp
index 88aab15..ad943fe 100644
--- a/noncore/settings/networksettings2/profile/profileedit.cpp
+++ b/noncore/settings/networksettings2/profile/profileedit.cpp
@@ -1,98 +1,102 @@
#include <qlabel.h>
#include <qframe.h>
#include <qcheckbox.h>
#include <qmultilineedit.h>
#include <qcheckbox.h>
#include <GUIUtils.h>
#include <netnode.h>
#include <resources.h>
#include "profileedit.h"
ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) :
ProfileGUI( Parent ), RefreshTimer(this) {
InterfaceInfo * II;
+ II = TNNI->networkSetup()->assignedInterface();
+ Log(( "Interface %p %p %p: %d\n", II,
+ TNNI, TNNI->networkSetup(), (II) ? II->IsUp : 0 ));
+
NNI = TNNI;
Dev = NNI->runtime()->device();
- if( ( II = NNI->connection()->assignedInterface() ) ) {
+ if( ( II = NNI->networkSetup()->assignedInterface() ) ) {
Refresh_CB->setEnabled( TRUE );
Snd_GB->setEnabled( TRUE );
Rcv_GB->setEnabled( TRUE );
Collisions_FRM->setEnabled( TRUE );
// show current content
SLOT_Refresh();
// fill in static data
InterfaceName_LBL->setText( II->Name );
IPAddress_LBL->setText( II->Address );
SubnetMask_LBL->setText( II->Netmask );
Broadcast_LBL->setText( II->BCastAddress );
MACAddress_LBL->setText( II->MACAddress );
if( II->IsPointToPoint ) {
PointToPoint_LBL->setText( II->DstAddress );
}
QString S;
InterfaceName_LBL->setText( II->Name );
if( II->HasMulticast ) {
S += "Multicast";
}
if( ! S.isEmpty() ) {
S.prepend( " : " );
}
InterfaceOptions_LBL->setText( S );
connect( &RefreshTimer, SIGNAL( timeout() ),
this, SLOT( SLOT_Refresh() ) );
}
}
QString ProfileEdit::acceptable( void ) {
return QString();
}
void ProfileEdit::showData( ProfileData & Data ) {
Description_LE->setText( Data.Description );
Automatic_CB->setChecked( Data.Automatic );
TriggersVPN_CB->setChecked( Data.TriggerVPN );
Confirm_CB->setChecked( Data.Confirm );
Disabled_CB->setChecked( Data.Disabled );
}
bool ProfileEdit::commit( ProfileData & Data ) {
bool SM = 0;
TXTM( Data.Description, Description_LE, SM );
CBM( Data.Automatic, Automatic_CB, SM );
CBM( Data.TriggerVPN, TriggersVPN_CB, SM );
CBM( Data.Disabled, Disabled_CB, SM );
CBM( Data.Confirm, Confirm_CB, SM );
return SM;
}
void ProfileEdit::SLOT_Refresh( void ) {
- InterfaceInfo * II = NNI->connection()->assignedInterface();
+ InterfaceInfo * II = NNI->networkSetup()->assignedInterface();
NSResources->system().refreshStatistics( *II );
RcvBytes_LBL->setText( II->RcvBytes );
SndBytes_LBL->setText( II->SndBytes );
RcvErrors_LBL->setText( II->RcvErrors );
SndErrors_LBL->setText( II->SndErrors );
RcvDropped_LBL->setText( II->RcvDropped );
SndDropped_LBL->setText( II->SndDropped );
Collisions_LBL->setText( II->Collisions );
}
void ProfileEdit::SLOT_AutoRefresh( bool ar ) {
if( ar ) {
RefreshTimer.start( 1000 );
SLOT_Refresh();
} else {
RefreshTimer.stop();
}
}
diff --git a/noncore/settings/networksettings2/profile/profilerun.cpp b/noncore/settings/networksettings2/profile/profilerun.cpp
index acb67bd..48011ea 100644
--- a/noncore/settings/networksettings2/profile/profilerun.cpp
+++ b/noncore/settings/networksettings2/profile/profilerun.cpp
@@ -1,27 +1,31 @@
#include <resources.h>
#include "profilerun.h"
State_t ProfileRun::detectState( void ) {
+ InterfaceInfo * II = networkSetup()->assignedInterface();
+
+ Log(( "Interface %p %p %p: %d\n", II,
+ netNode(), netNode()->networkSetup(), (II) ? II->IsUp : 0 ));
if( Data->Disabled ) {
return Disabled;
}
return Unknown;
}
-QString ProfileRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
+QString ProfileRun::setMyState( NetworkSetup * NC, Action_t A, bool ) {
odebug << "Profile " << Data->Disabled << oendl;
if( A == Disable ) {
if( ! Data->Disabled ) {
Data->Disabled = 1;
NC->setModified( 1 );
}
} else if( A == Enable ) {
if( Data->Disabled ) {
Data->Disabled = 0;
NC->setModified( 1 );
}
}
return QString();
}
diff --git a/noncore/settings/networksettings2/profile/profilerun.h b/noncore/settings/networksettings2/profile/profilerun.h
index 2d48b15..9470c0f 100644
--- a/noncore/settings/networksettings2/profile/profilerun.h
+++ b/noncore/settings/networksettings2/profile/profilerun.h
@@ -1,33 +1,33 @@
#ifndef PROFILERUN_H
#define PROFILERUN_H
#include <netnode.h>
#include "profiledata.h"
class ProfileRun : public RuntimeInfo {
public :
ProfileRun( ANetNodeInstance * NNI, ProfileData & D ) :
RuntimeInfo( NNI )
{ Data = &D; }
virtual RuntimeInfo * fullSetup( void )
{ return this; }
virtual const QString & description( void )
{ return Data->Description; }
virtual bool triggersVPN( void )
{ return Data->TriggerVPN; }
State_t detectState( void );
protected :
- QString setMyState( NodeCollection * , Action_t, bool );
+ QString setMyState( NetworkSetup * , Action_t, bool );
private :
ProfileData * Data;
};
#endif
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp
index 6d90ae0..6e2597c 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NN.cpp
@@ -1,60 +1,60 @@
#include <resources.h>
#include "usb_NN.h"
#include "usb_NNI.h"
#include "netnodeinterface.h"
static const char * USBNeeds[] =
{ 0
};
static const char * USBProvides[] =
{ "device",
0
};
/**
* Constructor, find all of the possible interfaces
*/
USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) {
NSResources->addSystemFile(
"interfaces", "/etc/network/interfaces", 1 );
}
/**
* 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>\
+<p>Use this for a computer to computer USB cable NetworkSetup</p>\
"
);
}
ANetNodeInstance * USBNetNode::createInstance( void ) {
return new AUSB( this );
}
const char ** USBNetNode::needs( void ) {
return USBNeeds;
}
const char ** USBNetNode::provides( void ) {
return USBProvides;
}
QString USBNetNode::genNic( long ) {
return QString( "usbf" );
}
void USBNetNode::setSpecificAttribute( QString & , QString & ) {
}
void USBNetNode::saveSpecificAttribute( QTextStream & ) {
}
OPIE_NS2_PLUGIN( NetNodeInterface_T<USBNetNode> )
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp
index 763644e..4082f7f 100644
--- a/noncore/settings/networksettings2/usb/usbrun.cpp
+++ b/noncore/settings/networksettings2/usb/usbrun.cpp
@@ -1,120 +1,120 @@
#include <qfile.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#include <resources.h>
#include "usbrun.h"
State_t USBRun::detectState( void ) {
// unavailable : no card found
// available : card found and assigned to us or free
// up : card found and assigned to us and up
- NodeCollection * NC = nodeCollection();
+ NetworkSetup * NC = networkSetup();
QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
System & Sys = NSResources->system();
InterfaceInfo * Run;
QFile F( S );
Log(("Detecting for %s\n", NC->name().latin1() ));
if( F.open( IO_ReadOnly ) ) {
// could open file -> read interface and assign
QString X;
QTextStream TS(&F);
X = TS.readLine();
Log(("%s exists\n", S.latin1() ));
// find interface
if( handlesInterface( X ) ) {
for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
It.current();
++It ) {
Run = It.current();
if( X == Run->Name ) {
NC->assignInterface( Run );
return (Run->IsUp) ? IsUp : Available;
}
}
}
}
Log(("Assigned %p\n", NC->assignedInterface() ));
if( ( Run = NC->assignedInterface() ) ) {
// we already have an interface assigned -> still present ?
if( ! Run->IsUp ) {
// usb is still free -> keep assignment
return Available;
} // else interface is up but NOT us -> some other profile
}
// nothing (valid) assigned to us
NC->assignInterface( 0 );
// find possible interface
if( getInterface() ) {
// proper type, and Not UP -> free
// usb cables are currently always available when requested
// until we can detect if we are plugged in
return Available;
}
return Unavailable;
}
-QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
+QString USBRun::setMyState( NetworkSetup * NC, Action_t, bool ) {
InterfaceInfo * I = getInterface();
if( ! I ) {
return QString("No usb device available");
}
Log(( "Grabbed USB interface %s\n", I->Name.latin1() ));
// grab this interface
NC->assignInterface( I );
return QString();
}
// get interface that is free or assigned to us
InterfaceInfo * USBRun::getInterface( void ) {
System & S = NSResources->system();
InterfaceInfo * best = 0, * Run;
for( QDictIterator<InterfaceInfo> It(S.interfaces());
It.current();
++It ) {
Run = It.current();
Log(("%s %d %d=%d %d\n",
Run->Name.latin1(),
handlesInterface( Run->Name ),
Run->CardType, ARPHRD_ETHER,
! Run->IsUp ));
if( handlesInterface( Run->Name ) &&
Run->CardType == ARPHRD_ETHER
) {
// this is a USB card
- if( Run->assignedConnection() == netNode()->connection() ) {
+ if( Run->assignedToNetworkSetup() == netNode()->networkSetup() ) {
// assigned to us
return Run;
} else if( ! Run->IsUp &&
- Run->assignedConnection() == 0 ) {
+ Run->assignedToNetworkSetup() == 0 ) {
// free
best = Run;
} // UP or not assigned to us
}
}
return best; // can be 0
}
bool USBRun::handlesInterface( const QString & S ) {
return Pat.match( S ) >= 0;
}
bool USBRun::handlesInterface( InterfaceInfo * I ) {
return handlesInterface( I->Name );
}
diff --git a/noncore/settings/networksettings2/usb/usbrun.h b/noncore/settings/networksettings2/usb/usbrun.h
index 6ce4fa2..0872f3d 100644
--- a/noncore/settings/networksettings2/usb/usbrun.h
+++ b/noncore/settings/networksettings2/usb/usbrun.h
@@ -1,36 +1,36 @@
#ifndef USBRUN_H
#define USBRUN_H
#include <netnode.h>
#include <qregexp.h>
#include "usbdata.h"
class USBRun : public RuntimeInfo {
public :
USBRun( ANetNodeInstance * NNI,
USBData & Data ) :
RuntimeInfo( NNI ),
Pat( "usb[0-9abcdef]" ) {
}
virtual RuntimeInfo * device( void )
{ return this; }
bool handlesInterface( const QString & I );
bool handlesInterface( InterfaceInfo * );
State_t detectState( void );
protected :
- QString setMyState( NodeCollection * , Action_t, bool );
+ QString setMyState( NetworkSetup * , Action_t, bool );
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 96e9df2..7c2e77b 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
@@ -1,52 +1,52 @@
#include "vpn_NN.h"
#include "vpn_NNI.h"
#include "netnodeinterface.h"
static const char * VPNNeeds[] =
{ 0
};
static const char * VPNProvides[] =
- { "connection",
+ { "NetworkSetup",
0
};
/**
* Constructor, find all of the possible interfaces
*/
-VPNNetNode::VPNNetNode() : ANetNode(tr("VPN Connection")) {
+VPNNetNode::VPNNetNode() : ANetNode(tr("VPN NetworkSetup")) {
}
/**
* Delete any interfaces that we own.
*/
VPNNetNode::~VPNNetNode(){
}
const QString VPNNetNode::nodeDescription(){
return tr("\
-<p>Configure private IP connection.</p>\
+<p>Configure private IP NetworkSetup.</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 VPNProvides;
}
void VPNNetNode::setSpecificAttribute( QString & , QString & ) {
}
void VPNNetNode::saveSpecificAttribute( QTextStream & ) {
}
OPIE_NS2_PLUGIN( NetNodeInterface_T<VPNNetNode> )
diff --git a/noncore/settings/networksettings2/vpn/vpnrun.h b/noncore/settings/networksettings2/vpn/vpnrun.h
index 9a55625..e40aa87 100644
--- a/noncore/settings/networksettings2/vpn/vpnrun.h
+++ b/noncore/settings/networksettings2/vpn/vpnrun.h
@@ -1,27 +1,27 @@
#ifndef VPNRUN_H
#define VPNRUN_H
#include <netnode.h>
#include "vpndata.h"
class VPNRun : public RuntimeInfo {
public :
VPNRun( ANetNodeInstance * NNI, VPNData & Data ) :
RuntimeInfo( NNI )
{ }
virtual RuntimeInfo * connection( void )
{ return this; }
State_t detectState( void )
{ return Unknown; }
protected :
- QString setMyState( NodeCollection * , Action_t, bool )
+ QString setMyState( NetworkSetup * , Action_t, bool )
{ return QString(); }
};
#endif
diff --git a/noncore/settings/networksettings2/wlan/wlanedit.cpp b/noncore/settings/networksettings2/wlan/wlanedit.cpp
index 74174bf..73c0c7c 100644
--- a/noncore/settings/networksettings2/wlan/wlanedit.cpp
+++ b/noncore/settings/networksettings2/wlan/wlanedit.cpp
@@ -1,115 +1,115 @@
#include <qlineedit.h>
#include <qprogressbar.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qregexp.h>
#include <qcheckbox.h>
#include <GUIUtils.h>
#include <resources.h>
#include <wextensions.h>
#include "wlanedit.h"
#include "wlan_NN.h"
#include "wlan_NNI.h"
WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * TNNI ) :
WLanGUI( Parent ), RefreshTimer(this){
InterfaceInfo * II;
NNI = TNNI;
Dev = NNI->runtime()->device();
WE = 0;
- if( ( II = NNI->connection()->assignedInterface() ) ) {
+ if( ( II = NNI->networkSetup()->assignedInterface() ) ) {
// show data
WE = new WExtensions( II->Name );
if( WE->doesHaveWirelessExtensions() ) {
QString S;
Station_LBL->setText( WE->station() );
ESSID_LBL->setText( WE->essid() );
Mode_LBL->setText( WE->mode() );
S.setNum( WE->frequency() );
Frequency_LBL->setText( S );
S.setNum( WE->channel() );
Channel_LBL->setText( S );
S.setNum( WE->rate() );
Rate_LBL->setText( S );
AP_LBL->setText( WE->ap() );
SLOT_Refresh();
connect( &RefreshTimer, SIGNAL( timeout() ),
this, SLOT( SLOT_Refresh() ) );
}
}
}
WLanEdit::~WLanEdit( void ) {
if( WE )
delete WE;
}
QString WLanEdit::acceptable( void ) {
if( ESSID_LE->text().isEmpty() ) {
return QString("ESSID is mandatory");
}
if( SpecifyAP_CB->isChecked() &&
APMac_LE->text().isEmpty() ) {
return QString("APMac must have value");
}
return QString();
}
void WLanEdit::showData( WLanData & Data ) {
Mode_CB->setCurrentItem( Data.Mode );
ESSID_LE->setText( Data.ESSID );
NodeName_LE->setText( Data.NodeName );
SpecifyAP_CB->setChecked( Data.SpecificAP );
APMac_LE->setText( Data.APMac );
EnableWEP_CB->setChecked( Data.Encrypted );
AcceptNonEncrypted_CB->setChecked( Data.AcceptNonEncrypted );
Key1_LE->setText( Data.Key[0] );
Key2_LE->setText( Data.Key[1] );
Key3_LE->setText( Data.Key[2] );
Key4_LE->setText( Data.Key[3] );
}
bool WLanEdit::commit( WLanData & Data ) {
bool SM = 0;
TXTM( Data.ESSID, ESSID_LE, SM );
TXTM( Data.NodeName, NodeName_LE, SM );
TXTM( Data.APMac, APMac_LE, SM );
TXTM( Data.Key[0], Key1_LE, SM );
TXTM( Data.Key[1], Key2_LE, SM );
TXTM( Data.Key[2], Key3_LE, SM );
TXTM( Data.Key[3], Key4_LE, SM );
CBM( Data.SpecificAP, SpecifyAP_CB, SM );
CBM( Data.Encrypted, EnableWEP_CB, SM );
CBM( Data.AcceptNonEncrypted, AcceptNonEncrypted_CB, SM );
CIM( Data.Mode, Mode_CB, SM );
return 0;
}
void WLanEdit::SLOT_Refresh( void ) {
if( WE ) {
int signal, noise, quality;
WE->stats( signal, noise, quality);
Signal_PB->setProgress( signal );
Noise_PB->setProgress( noise );
Quality_PB->setProgress( quality );
}
}
void WLanEdit::SLOT_AutoRefresh( bool ar ) {
if( ar ) {
RefreshTimer.start( 1000 );
SLOT_Refresh();
} else {
RefreshTimer.stop();
}
}
diff --git a/noncore/settings/networksettings2/wlan/wlanrun.cpp b/noncore/settings/networksettings2/wlan/wlanrun.cpp
index b15a560..a0c5884 100644
--- a/noncore/settings/networksettings2/wlan/wlanrun.cpp
+++ b/noncore/settings/networksettings2/wlan/wlanrun.cpp
@@ -1,120 +1,120 @@
#include <qfile.h>
#include <qtextstream.h>
#include <qstringlist.h>
#include <resources.h>
#include "wlanrun.h"
State_t WLanRun::detectState( void ) {
// unavailable : no card found
// available : card found and assigned to us or free
// up : card found and assigned to us and up
- NodeCollection * NC = nodeCollection();
+ NetworkSetup * NC = networkSetup();
QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
System & Sys = NSResources->system();
InterfaceInfo * Run;
QFile F( S );
if( F.open( IO_ReadOnly ) ) {
// could open file -> read interface and assign
QString X;
QTextStream TS(&F);
X = TS.readLine();
// find interface
if( handlesInterface( X ) ) {
for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
It.current();
++It ) {
Run = It.current();
if( X == Run->Name ) {
NC->assignInterface( Run );
return (Run->IsUp) ? IsUp : Available;
}
}
}
}
if( ( Run = NC->assignedInterface() ) ) {
// we already have an interface assigned -> still present ?
if( ! Run->IsUp ) {
// usb is still free -> keep assignment
return Available;
} // else interface is up but NOT us -> some other profile
}
// nothing (valid) assigned to us
NC->assignInterface( 0 );
// find possible interface
for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
It.current();
++It ) {
Run = It.current();
if( handlesInterface( *Run ) &&
( Run->CardType == ARPHRD_ETHER
#ifdef ARPHRD_IEEE1394
|| Run->CardType == ARPHRD_IEEE1394
#endif
) &&
! Run->IsUp
) {
// proper type, and Not UP -> free
return Off;
}
}
return Unavailable;
}
-QString WLanRun::setMyState( NodeCollection * , Action_t , bool ) {
+QString WLanRun::setMyState( NetworkSetup * , Action_t , bool ) {
// we only handle activate and deactivate
return QString();
}
// get interface that is free or assigned to us
InterfaceInfo * WLanRun::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 ) &&
( Run->CardType == ARPHRD_ETHER
#ifdef ARPHRD_IEEE1394
|| Run->CardType == ARPHRD_IEEE1394
#endif
)
) {
// this is a LAN card
- if( Run->assignedConnection() == netNode()->connection() ) {
+ if( Run->assignedToNetworkSetup() == netNode()->networkSetup() ) {
// assigned to us
return Run;
- } else if( Run->assignedConnection() == 0 ) {
+ } else if( Run->assignedToNetworkSetup() == 0 ) {
// free
best = Run;
}
}
}
return best; // can be 0
}
bool WLanRun::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 WLanRun::handlesInterface( const InterfaceInfo & II ) {
return ( Pat.match( II.Name ) < 0 );
}
diff --git a/noncore/settings/networksettings2/wlan/wlanrun.h b/noncore/settings/networksettings2/wlan/wlanrun.h
index fd325d4..e3e7735 100644
--- a/noncore/settings/networksettings2/wlan/wlanrun.h
+++ b/noncore/settings/networksettings2/wlan/wlanrun.h
@@ -1,36 +1,36 @@
#ifndef WLANRUN_H
#define WLANRUN_H
#include <qregexp.h>
#include <netnode.h>
#include "wlandata.h"
class WLanRun : public RuntimeInfo {
public :
WLanRun( ANetNodeInstance * NNI, WLanData & Data ) :
RuntimeInfo( NNI ),
Pat( "wlan[0-9]" ) {
}
virtual RuntimeInfo * device( void )
{ return this; }
bool handlesInterface( const QString & I );
bool handlesInterface( const InterfaceInfo & II );
State_t detectState( void );
protected :
- QString setMyState( NodeCollection * , Action_t, bool );
+ QString setMyState( NetworkSetup * , Action_t, bool );
private :
InterfaceInfo * getInterface( void );
QRegExp Pat;
WLanData * Data;
};
#endif