summaryrefslogtreecommitdiff
authorwimpie <wimpie>2004-08-09 02:31:25 (UTC)
committer wimpie <wimpie>2004-08-09 02:31:25 (UTC)
commit0784cfdbd261c43856b45be6ab7439841e69b858 (patch) (side-by-side diff)
treef6a27d6b2e1e6d8dcc908b2ef5836cd320ddfab1
parent5e10278e748608766245ff9f59a54d1ae8ff6f7e (diff)
downloadopie-0784cfdbd261c43856b45be6ab7439841e69b858.zip
opie-0784cfdbd261c43856b45be6ab7439841e69b858.tar.gz
opie-0784cfdbd261c43856b45be6ab7439841e69b858.tar.bz2
Many changes :
bluetooth and usb seems to work added preliminary support for VPN on top of any network This version is still very much crippled yet is does DO some things
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth.pro1
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp25
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h5
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.cpp28
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp249
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h23
-rw-r--r--noncore/settings/networksettings2/lancard/lancardedit.cpp4
-rw-r--r--noncore/settings/networksettings2/main.cpp7
-rw-r--r--noncore/settings/networksettings2/network/networkrun.cpp26
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp34
-rw-r--r--noncore/settings/networksettings2/networksettings.h2
-rw-r--r--noncore/settings/networksettings2/networksettings2/Utils.h8
-rw-r--r--noncore/settings/networksettings2/networksettings2/asfullsetup.h2
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.cpp6
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h20
-rw-r--r--noncore/settings/networksettings2/networksettings2/networksettings2.pro2
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp256
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.h7
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp108
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.h11
-rw-r--r--noncore/settings/networksettings2/networksettingsGUI.ui76
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp25
-rw-r--r--noncore/settings/networksettings2/profile/profileGUI.ui162
-rw-r--r--noncore/settings/networksettings2/profile/profile_NNI.cpp4
-rw-r--r--noncore/settings/networksettings2/profile/profiledata.h1
-rw-r--r--noncore/settings/networksettings2/profile/profileedit.cpp2
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.cpp6
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.h4
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp14
29 files changed, 818 insertions, 300 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth.pro b/noncore/settings/networksettings2/bluetooth/bluetooth.pro
index 180bda9..2e1e138 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetooth.pro
+++ b/noncore/settings/networksettings2/bluetooth/bluetooth.pro
@@ -12,2 +12,3 @@ SOURCES = bluetooth_NN.cpp \
bluetoothBNEPedit.cpp \
+ bluetoothBNEPrun.cpp \
bluetoothRFCOMMedit.cpp
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp
index 73312c6..d8420b9 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp
@@ -4,11 +4,24 @@
-ABluetoothBNEP::ABluetoothBNEP( BluetoothBNEPNetNode * PNN ) : ANetNodeInstance( PNN ) {
+ABluetoothBNEP::ABluetoothBNEP( BluetoothBNEPNetNode * PNN ) :
+ ANetNodeInstance( PNN ), Data() {
GUI = 0;
RT = 0;
+ Data.AllowAll = 1;
}
-void ABluetoothBNEP::setSpecificAttribute( QString & , QString & ) {
+void ABluetoothBNEP::setSpecificAttribute( QString & S, QString & A ) {
+ if( S == "bdaddress" ) {
+ Data.BDAddress << A;
+ } else if ( S == "allowall" ) {
+ Data.AllowAll = 1;
+ }
}
-void ABluetoothBNEP::saveSpecificAttribute( QTextStream & ) {
+void ABluetoothBNEP::saveSpecificAttribute( QTextStream & TS ) {
+ TS << "allowall=" << Data.AllowAll << endl;
+ for ( QStringList::Iterator it = Data.BDAddress.begin();
+ it != Data.BDAddress.end();
+ ++it ) {
+ TS << "bdaddress=" << (*it) << endl;
+ }
}
@@ -16,5 +29,5 @@ void ABluetoothBNEP::saveSpecificAttribute( QTextStream & ) {
QWidget * ABluetoothBNEP::edit( QWidget * parent ) {
- GUI = new BluetoothBNEPEdit( parent );
- GUI->showData( Data );
- return GUI;
+ GUI = new BluetoothBNEPEdit( parent );
+ GUI->showData( Data );
+ return GUI;
}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h
index 037b7b1..03c6903 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h
@@ -3,4 +3,7 @@
+#include <qstringlist.h>
+
typedef struct BluetoothBNEPData {
- long x;
+ bool AllowAll;
+ QStringList BDAddress;
} BluetoothBNEPData_t;
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.cpp
index 9a3156b..195dbae 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.cpp
@@ -1,2 +1,4 @@
#include <qtopia/qcopenvelope_qws.h>
+#include <qlistview.h>
+#include <qcheckbox.h>
@@ -11,2 +13,7 @@ BluetoothBNEPEdit::BluetoothBNEPEdit( QWidget * Parent ) : BluetoothBNEPGUI( Par
QString BluetoothBNEPEdit::acceptable( void ) {
+ if( ( ! AnyPAN_CB->isChecked() ) &&
+ BTPANServers_LV->firstChild() == 0 ) {
+ return tr("<p>No bluetooth device addresses specified</p>");
+ }
+
return QString();
@@ -14,7 +21,22 @@ QString BluetoothBNEPEdit::acceptable( void ) {
-bool BluetoothBNEPEdit::commit( BluetoothBNEPData & ) {
- return 0;
+bool BluetoothBNEPEdit::commit( BluetoothBNEPData & Data ) {
+ QListViewItem * it = BTPANServers_LV->firstChild();
+ Data.BDAddress.clear();
+ while( it ) {
+ Data.BDAddress << it->text(0);
+ it = it->nextSibling();
+ }
+ return 0;
}
-void BluetoothBNEPEdit::showData( BluetoothBNEPData & ) {
+void BluetoothBNEPEdit::showData( BluetoothBNEPData & Data ) {
+ QListViewItem * lvit;
+ BTPANServers_LV->clear();
+
+ for ( QStringList::Iterator it = Data.BDAddress.begin();
+ it != Data.BDAddress.end();
+ ++it ) {
+ lvit = new QListViewItem(BTPANServers_LV);
+ lvit->setText( 0, (*it) );
+ }
}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp
new file mode 100644
index 0000000..24e4b7b
--- a/dev/null
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp
@@ -0,0 +1,249 @@
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qtextstream.h>
+#include <resources.h>
+#include "bluetoothBNEPrun.h"
+
+QDict<QString> * BluetoothBNEPRun::PANConnections = 0;
+
+void BluetoothBNEPRun::detectState( NodeCollection * NC ) {
+ // unavailable : no card found
+ // available : card found and assigned to us or free
+ // up : card found and assigned to us and up
+ QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
+ System & Sys = NSResources->system();
+ InterfaceInfo * Run;
+ QFile F( S );
+
+ Log(("Detecting for %s\n", NC->name().latin1() ));
+
+ if( F.open( IO_ReadOnly ) ) {
+ // could open file -> read interface and assign
+ QString X;
+ bool accepted = 0;
+ QTextStream TS(&F);
+ X = TS.readLine();
+ Log(("%s exists : %s\n", S.latin1(), X.latin1() ));
+ // find interface
+ if( handlesInterface( X ) ) {
+
+ Log(("Handles interface %s, PANC %p\n", X.latin1(), PANConnections ));
+ if( PANConnections == 0 ) {
+ // load connections that are active
+ // format : bnep0 00:60:57:02:71:A2 PANU
+ FILE * OutputOfCmd = popen( "pand --show", "r" ) ;
+
+ PANConnections = new QDict<QString>;
+
+ if( OutputOfCmd ) {
+ char ch;
+ // could fork
+ // read all data
+ QString Line = "";
+ while( 1 ) {
+ if( fread( &ch, 1, 1, OutputOfCmd ) < 1 ) {
+ // eof
+ break;
+ }
+ if( ch == '\n' || ch == '\r' ) {
+ if( ! Line.isEmpty() ) {
+ if( Line.startsWith( "bnep" ) ) {
+ QStringList SL = QStringList::split( " ", Line );
+ Log(("Detected PAN %s %s\n",
+ SL[0].latin1(), SL[1].latin1() ));
+ PANConnections->insert( SL[0], new QString(SL[1]));
+ }
+ Line="";
+ }
+ } else {
+ Line += ch;
+ }
+ }
+ }
+
+ pclose( OutputOfCmd );
+ }
+
+ // check if this runtime allows connection to node
+ if( ! Data.AllowAll ) {
+ // has addresses
+ for ( QStringList::Iterator it = Data.BDAddress.begin();
+ ! accepted && it != Data.BDAddress.end();
+ ++ it ) {
+ for( QDictIterator<QString> it2( *(PANConnections) );
+ it2.current();
+ ++ it2 ) {
+ if( X == it2.currentKey() &&
+ (*it) == *(it2.current())
+ ) {
+ // found
+ Log(("%s accepts connections to %s\n",
+ NC->name().latin1(),
+ it2.current()->latin1() ));
+ accepted = 1;
+ break;
+ }
+ }
+ }
+ } else {
+ Log(("%s accepts any connection\n", NC->name().latin1() ));
+ // accept any
+ accepted = 1;
+ }
+
+ if( accepted ) {
+ // matches and is allowed for this node
+ for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
+ It.current();
+ ++It ) {
+ Run = It.current();
+ if( X == Run->Name ) {
+ Log(("%s Assigned %p\n", NC->name().latin1(), Run ));
+ Run->assignNode( netNode() );
+ assignInterface( Run );
+ NC->setCurrentState( IsUp );
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ Log(("Assigned %p\n", assignedInterface() ));
+ if( ( Run = assignedInterface() ) ) {
+ // we already have an interface assigned -> still present ?
+ if( ! Run->IsUp ) {
+ // usb is still free -> keep assignment
+ NC->setCurrentState( Available );
+ return;
+ } // else interface is up but NOT us -> some other profile
+ }
+
+ // nothing (valid) assigned to us
+ assignInterface( 0 );
+
+ // find possible interface
+ for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
+ It.current();
+ ++It ) {
+ Run = It.current();
+
+ 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 &&
+ ! Run->IsUp
+ ) {
+ Log(("Released(OFF)\n" ));
+ // proper type, and Not UP -> free
+ NC->setCurrentState( Off );
+ return;
+ }
+ }
+ // no free found
+ Log(("None available\n" ));
+
+ NC->setCurrentState( Unavailable );
+}
+
+bool BluetoothBNEPRun::setState( NodeCollection * NC, Action_t A, bool ) {
+
+ // we only handle activate and deactivate
+ switch( A ) {
+ case Activate :
+ {
+ if( NC->currentState() != Off ) {
+ return 0;
+ }
+ InterfaceInfo * N = getInterface();
+ if( ! N ) {
+ // no interface available
+ NC->setCurrentState( Unavailable );
+ return 0;
+ }
+ // because we were OFF the interface
+ // we get back is NOT assigned
+ N->assignNode( netNode() );
+ assignInterface( N );
+ Log(("Assing %p\n", N ));
+ NC->setCurrentState( Available );
+ return 1;
+ }
+ case Deactivate :
+ if( NC->currentState() == IsUp ) {
+ // bring down first
+ if( ! connection()->setState( Down ) )
+ // could not ...
+ return 0;
+ } else if( NC->currentState() != Available ) {
+ return 1;
+ }
+ assignedInterface()->assignNode( 0 ); // release
+ assignInterface( 0 );
+ NC->setCurrentState( Off );
+ return 1;
+ default :
+ // FT
+ break;
+ }
+ return 0;
+}
+
+bool BluetoothBNEPRun::canSetState( State_t Curr , Action_t A ) {
+ // we only handle up down activate and deactivate
+ switch( A ) {
+ case Activate :
+ { // at least available
+ if( Curr == Available ) {
+ return 1;
+ }
+ // or we can make one available
+ InterfaceInfo * N = getInterface();
+ if( ! N || N->assignedNode() != 0 ) {
+ // non available or assigned
+ return 0;
+ }
+ return 1;
+ }
+ case Deactivate :
+ return ( Curr >= Available );
+ default :
+ // FT
+ break;
+ }
+ return 0;
+}
+
+// get interface that is free or assigned to us
+InterfaceInfo * BluetoothBNEPRun::getInterface( void ) {
+
+ System & S = NSResources->system();
+ InterfaceInfo * best = 0, * Run;
+
+ for( QDictIterator<InterfaceInfo> It(S.interfaces());
+ It.current();
+ ++It ) {
+ Run = It.current();
+ if( handlesInterface( Run->Name ) &&
+ Run->CardType == ARPHRD_ETHER
+ ) {
+ // this is a bluetooth card
+ if( Run->assignedNode() == netNode() ) {
+ // assigned to us
+ return Run;
+ } else if( Run->assignedNode() == 0 ) {
+ // free
+ best = Run;
+ }
+ }
+ }
+ return best; // can be 0
+}
+
+bool BluetoothBNEPRun::handlesInterface( const QString & S ) {
+ return Pat.match( S ) >= 0;
+}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
index c168429..ce03cbb 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
@@ -8,3 +8,6 @@ public :
BluetoothBNEPRun( ANetNodeInstance * NNI,
- BluetoothBNEPData & Data ) : AsDevice( NNI )
+ BluetoothBNEPData & D ) :
+ AsDevice( NNI ),
+ Data( D),
+ Pat( "bnep[0-6]" )
{ }
@@ -19,13 +22,13 @@ protected :
- void detectState( NodeCollection * )
- { }
-
- bool setState( NodeCollection * , Action_t, bool )
- { return 0; }
+ void detectState( NodeCollection * );
+ bool setState( NodeCollection * , Action_t, bool );
+ bool canSetState( State_t , Action_t );
+ bool handlesInterface( const QString & );
- bool canSetState( State_t , Action_t )
- { return 0; }
+private :
- bool handlesInterface( const QString & )
- { return 0; }
+ InterfaceInfo * getInterface( void );
+ BluetoothBNEPData & Data;
+ static QDict<QString> * PANConnections;
+ QRegExp Pat;
};
diff --git a/noncore/settings/networksettings2/lancard/lancardedit.cpp b/noncore/settings/networksettings2/lancard/lancardedit.cpp
index ffe9bf6..c00d7aa 100644
--- a/noncore/settings/networksettings2/lancard/lancardedit.cpp
+++ b/noncore/settings/networksettings2/lancard/lancardedit.cpp
@@ -116,5 +116,5 @@ void LanCardEdit::SLOT_ScanCards( void ) {
++It ) {
- fprintf( stderr, "TEST %s %s\n",
+ Log(( "TEST %s %s\n",
It.current()->Name.latin1(),
- It.current()->MACAddress.latin1() );
+ It.current()->MACAddress.latin1() ));
if( R.match( It.current()->Name ) >= 0 &&
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp
index 30d1270..6c969fc 100644
--- a/noncore/settings/networksettings2/main.cpp
+++ b/noncore/settings/networksettings2/main.cpp
@@ -80,4 +80,6 @@ int main( int argc, char * argv[] ) {
{ NetworkSettingsData NS;
+ Log(("ACT_REQUEST\n"));
if( NS.canStart( argv[1] ) ) {
QString S;
+ Log(("NEED FOR PROMPT\n" ));
S.sprintf( QPEApplication::qpeDir()+
@@ -97,2 +99,3 @@ int main( int argc, char * argv[] ) {
{ NetworkSettingsData NS;
+ Log(("REGEN\n" ));
// regen returns 0 if OK
@@ -103,2 +106,3 @@ int main( int argc, char * argv[] ) {
{ ActivateProfile AP(argv[1]);
+ Log(("PROMPT\n" ));
if( AP.exec() == QDialog::Accepted ) {
@@ -112,2 +116,3 @@ int main( int argc, char * argv[] ) {
{ QWidget * W = new NetworkSettings(0);
+ Log(("GUI\n" ));
TheApp->setMainWidget( W );
@@ -125,2 +130,4 @@ int main( int argc, char * argv[] ) {
+ LogClose();
+
return rv;
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp
index 41e1c53..3e24c5f 100644
--- a/noncore/settings/networksettings2/network/networkrun.cpp
+++ b/noncore/settings/networksettings2/network/networkrun.cpp
@@ -15,2 +15,3 @@ void NetworkRun::detectState( NodeCollection * NC ) {
+ Log(( "%s not ! UP or ava\n", NC->name().latin1() ));
// has no interface -> delegate
@@ -36,8 +37,19 @@ bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) {
} else if( A == Down ) {
- if( NC->currentState() == IsUp || Force ) {
- QString S;
- S.sprintf( "ifdown %s=%s-c%d-allowed",
- II->Name.latin1(), II->Name.latin1(),
- connection()->number() );
- NSResources->system().runAsRoot( S );
+ QString S;
+ if( Force ) {
+ Log(("Force mode %d\n", Force ));
+ for( int i = 0;
+ i < RI->netNode()->nodeClass()->instanceCount();
+ i ++ ) {
+ S.sprintf( "ifdown %s",
+ RI->netNode()->nodeClass()->genNic( i ).latin1() );
+ NSResources->system().runAsRoot( S );
+ }
+ } else {
+ if( NC->currentState() == IsUp ) {
+ S.sprintf( "ifdown %s=%s-c%d-allowed",
+ II->Name.latin1(), II->Name.latin1(),
+ connection()->number() );
+ NSResources->system().runAsRoot( S );
+ }
}
@@ -46,3 +58,3 @@ bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) {
// delegate
- return RI->setState( NC, A );
+ return RI->setState( NC, A, Force );
}
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index b36c7a0..6ee4106 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -1,2 +1,3 @@
#include <stdio.h>
+#include <unistd.h>
@@ -63,2 +64,6 @@ NetworkSettings::NetworkSettings( QWidget *parent,
+ connect( &(NSResources->system()),
+ SIGNAL( lineFromCommand(const QString &) ),
+ this, SLOT( SLOT_CmdMessage(const QString &) ) );
+
UpdateTimer->start( 5000 );
@@ -93,2 +98,8 @@ NetworkSettings::~NetworkSettings() {
+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 ) {
@@ -136,2 +147,5 @@ void NetworkSettings::SLOT_RefreshStates( void ) {
+void NetworkSettings::SLOT_NoLongerBusy( void ) {
+ NSResources->busy( FALSE );
+}
void NetworkSettings::SLOT_AddNode( void ) {
@@ -174,2 +188,4 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
UpdateTimer->stop();
+ NSResources->busy( TRUE );
+ QTimer::singleShot( 1000, this, SLOT( SLOT_NoLongerBusy() ));
// we need to retry
@@ -208,3 +224,3 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
NSResources->addConnection( NC );
- NC->setNumber( NC->maxConnectionNumber()+1 );
+ NC->setNumber( NSResources->assignConnectionNumber() );
Profiles_LB->insertItem( NC->devicePixmap(), NC->name() );
@@ -259,2 +275,3 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
OnOn = 1;
+ Connect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) );
DisabledOn = 0;
@@ -263,2 +280,3 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
OnOn = ConnectOn = 1;
+ Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) );
DisabledOn = 0;
@@ -267,2 +285,6 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
+ if( ! OnOn ) {
+ Connect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) );
+ }
+
// set button state
@@ -277,3 +299,3 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
if( NC->description().isEmpty() ) {
- Description_LBL->setText( tr( "No description" ) );
+ Description_LBL->setText( tr( "<<No description>>" ) );
} else {
@@ -282,4 +304,3 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
- Profile_GB->setTitle( LBI->text() );
- State_LBL->setText( NC->stateName() );
+ Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() );
}
@@ -416,2 +437,3 @@ void NetworkSettings::SLOT_Connect( void ) {
void NetworkSettings::SLOT_Disconnect( void ) {
+ QString S;
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
@@ -424,3 +446,7 @@ void NetworkSettings::SLOT_Disconnect( void ) {
+ Log(( "Force interface %s down\n", NC->name().latin1() ));
NC->setState( Down, 1 );
+ // remove 'up' file to make sure
+ S.sprintf( "/tmp/Profile-%d.up", NC->number() );
+ unlink( S.latin1() );
}
diff --git a/noncore/settings/networksettings2/networksettings.h b/noncore/settings/networksettings2/networksettings.h
index 97852af..8ffde06 100644
--- a/noncore/settings/networksettings2/networksettings.h
+++ b/noncore/settings/networksettings2/networksettings.h
@@ -30,2 +30,3 @@ public slots :
+ void SLOT_NoLongerBusy( void );
void SLOT_AddNode( void );
@@ -44,2 +45,3 @@ public slots :
void SLOT_ToMessages( void );
+ void SLOT_CmdMessage( const QString & S );
diff --git a/noncore/settings/networksettings2/networksettings2/Utils.h b/noncore/settings/networksettings2/networksettings2/Utils.h
new file mode 100644
index 0000000..63ef51c
--- a/dev/null
+++ b/noncore/settings/networksettings2/networksettings2/Utils.h
@@ -0,0 +1,8 @@
+#ifndef __UTILS_H
+#define __UTILS_H
+
+#define Log(x) VLog x
+extern void VLog( char * Format, ... );
+extern void LogClose( void );
+
+#endif
diff --git a/noncore/settings/networksettings2/networksettings2/asfullsetup.h b/noncore/settings/networksettings2/networksettings2/asfullsetup.h
index e358a83..072de9a 100644
--- a/noncore/settings/networksettings2/networksettings2/asfullsetup.h
+++ b/noncore/settings/networksettings2/networksettings2/asfullsetup.h
@@ -16,2 +16,4 @@ public :
virtual const QString & description( void ) = 0;
+ virtual bool triggersVPN( void )
+ { return 0; }
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp
index 1182543..8c80e0b 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.cpp
+++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp
@@ -105,4 +105,2 @@ ANetNodeInstance * ANetNodeInstance::nextNode( void ) {
-long NodeCollection::MaxNr = -1;
-
NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() {
@@ -148,2 +146,3 @@ NodeCollection::NodeCollection( QTextStream & TS ) :
} else if( A == "number" ) {
+ Log(( "read number %s\n", N.latin1() ));
setNumber( N.toLong() );
@@ -297,2 +296,5 @@ void NodeCollection::reassign( void ) {
+bool NodeCollection::triggersVPN() {
+ return getToplevel()->runtime()->asFullSetup()->triggersVPN();
+}
//
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index 5e36062..ca35c27 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -10,2 +10,4 @@
+#include <Utils.h>
+
// difference feature interfaces
@@ -285,3 +287,3 @@ public :
void setNumber( int i )
- { Number = i; if( MaxNr < i ) MaxNr = i; }
+ { Number = i; }
bool isNew( void )
@@ -307,4 +309,11 @@ public :
+ bool triggersVPN();
+
State_t state( bool Update = 0 )
- { if( CurrentState == Unchecked || Update ) {
+ { Log(( "%s state %d(=%d?)\n", Name.latin1(), CurrentState,
+ Unchecked ));
+ if( CurrentState == Unchecked || Update ) {
+ Log(( "TL %p TLR %p\n",
+ getToplevel(),
+ getToplevel()->runtime() ));
// need to get current state
@@ -354,8 +363,2 @@ public :
- long maxConnectionNumber( void )
- { return MaxNr; }
-
- static void resetMaxNr( void )
- { MaxNr = -1; }
-
private :
@@ -365,3 +368,2 @@ private :
- static long MaxNr;
long Number;
diff --git a/noncore/settings/networksettings2/networksettings2/networksettings2.pro b/noncore/settings/networksettings2/networksettings2/networksettings2.pro
index f97c93b..16a946b 100644
--- a/noncore/settings/networksettings2/networksettings2/networksettings2.pro
+++ b/noncore/settings/networksettings2/networksettings2/networksettings2.pro
@@ -22,3 +22,3 @@ INCLUDEPATH += $(OPIEDIR)/include ../networksettings2
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe -lopiecore2
+LIBS += -lqpe -lopiecore2 -lopieui2
INTERFACES =
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp
index c95ac7f..71e84cd 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.cpp
+++ b/noncore/settings/networksettings2/networksettings2/resources.cpp
@@ -25,2 +25,4 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
+ detectCurrentUser();
+
// load available netnodes
@@ -82,3 +84,2 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
- detectCurrentUser();
}
@@ -89,2 +90,13 @@ TheNSResources::~TheNSResources( void ) {
+void TheNSResources::busy( bool B ) {
+/*
+ if( B ) {
+ ShowWait->show();
+ qApp->process
+ } else {
+ ShowWait->hide();
+ }
+*/
+}
+
/**
@@ -96,2 +108,3 @@ void TheNSResources::findAvailableNetNodes(const QString &path){
+ Log(("Locate plugins in %s\n", path.latin1() ));
QDir d(path);
@@ -129,2 +142,23 @@ void TheNSResources::findAvailableNetNodes(const QString &path){
+// used to find unique connection number
+int TheNSResources::assignConnectionNumber( void ) {
+ bool found = 1;
+ for( int trial = 0; ; trial ++ ) {
+ found = 1;
+ for( QDictIterator<NodeCollection> it(ConnectionsMap);
+ it.current();
+ ++it ) {
+ if( it.current()->number() == trial ) {
+ found = 0;
+ break;
+ }
+ }
+
+ if( found ) {
+ Log(("Assign profile number %d\n", trial ));
+ return trial;
+ }
+ }
+}
+
/**
@@ -169,3 +203,2 @@ bool TheNSResources::loadNetNode(
// store mapping
- printf( "Store %s\n", NN->NetNode->name() );
AllNodeTypes.insert( NN->NetNode->name(), NN );
@@ -177,6 +210,8 @@ bool TheNSResources::loadNetNode(
QPixmap TheNSResources::getPixmap( const QString & QS ) {
+ QPixmap P;
QString S("networksettings2/");
S += QS;
- fprintf( stderr, "%s\n", S.latin1() );
- return Resource::loadPixmap( S );
+ Log(("%s\n", S.latin1() ));
+ P = Resource::loadPixmap( S );
+ return ( P.isNull() ) ? QPixmap() : P;
}
@@ -227,2 +262,3 @@ NodeCollection * TheNSResources::findConnection( const QString & S ) {
+/*
void TheNSResources::renumberConnections( void ) {
@@ -241,2 +277,3 @@ void TheNSResources::renumberConnections( void ) {
}
+*/
@@ -265,23 +302,25 @@ void TheNSResources::detectCurrentUser( void ) {
- // open proc dir and find all dirs in it
- { QRegExp R("[0-9]+");
- QDir ProcDir( "/proc" );
- QString QPELoc = QPEApplication::qpeDir() + "bin/qpe";
- 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 linke
- S = FI.readLink();
- if( S == QPELoc ) {
- // found running qpe
- QPEEnvFile.sprintf( ProcDir.path()+ "/" + (*it) + "/environ" );
- break;
+ 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;
+ }
}
@@ -289,21 +328,6 @@ void TheNSResources::detectCurrentUser( void ) {
}
- }
- if( QPEEnvFile.isEmpty() ) {
- // could not find qpe
- fprintf( stderr, "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 ) {
- fprintf( stderr, "Could not open %s : %d\n",
- QPEEnvFile.latin1(), errno );
+ if( QPEEnvFile.isEmpty() ) {
+ // could not find qpe
+ Log(("Could not find qpe\n" ));
return;
@@ -311,59 +335,109 @@ void TheNSResources::detectCurrentUser( void ) {
- while( (rd = read( fd, TB, sizeof(TB) ) ) > 0 ) {
- Buf = (char *)realloc( Buf, BufSize+rd );
- memcpy( Buf+BufSize, TB, rd );
- BufSize += rd;
- }
+ // 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;
+ }
- char * Data = Buf;
- char * DataEnd = Data+BufSize-1;
-
- // get env items out of list
- while( Data < DataEnd ) {
- if( strncmp( Data, "LOGNAME=", 8 ) == 0 ) {
- CurrentUser.UserName = Data+8;
- CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
- CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
- strdup( Data );
- } else if( strncmp( Data, "HOME=", 5 ) == 0 ) {
- CurrentUser.HomeDir = Data+5;
- CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
- CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
- strdup( Data );
- } else {
- EnvVar_t * Run = EV;
- while( Run->Name ) {
- if( strncmp( Data, Run->Name, Run->Len ) == 0 ) {
- CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
- CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
- strdup( Data );
- break;
+ 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 ) {
+ if( strncmp( Data, "LOGNAME=", 8 ) == 0 ) {
+ CurrentUser.UserName = Data+8;
+ CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
+ CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
+ strdup( Data );
+ } else if( strncmp( Data, "HOME=", 5 ) == 0 ) {
+ CurrentUser.HomeDir = Data+5;
+ CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
+ CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
+ strdup( Data );
+ } else {
+ EnvVar_t * Run = EV;
+ while( Run->Name ) {
+ if( strncmp( Data, Run->Name, Run->Len ) == 0 ) {
+ CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
+ CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
+ strdup( Data );
+ // put OPIEDIR in env
+ if( strcmp( Run->Name, "OPIEDIR=" ) == 0 ) {
+ putenv( CurrentUser.EnvList[CurrentUser.EnvList.size()-1] );
+
+ }
+ break;
+ }
+ Run ++;
}
- Run ++;
}
- }
- Data += strlen( Data )+1;
- }
+ Data += strlen( Data )+1;
+ }
- free( Buf );
+ free( Buf );
- if( ! CurrentUser.UserName.isEmpty() ) {
- // find user info
- struct passwd pwd;
- struct passwd * pwdres;
+ 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 ) {
- fprintf( stderr, "Could not determine user %s : %d\n",
- CurrentUser.UserName.latin1(), errno );
- return;
+ 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;
}
- CurrentUser.Uid = pwd.pw_uid;
- CurrentUser.Gid = pwd.pw_gid;
- } else{
- CurrentUser.Uid =
- CurrentUser.Gid = -1;
}
+
+ } else {
+ CurrentUser.UserName = getenv( "LOGNAME" );
+ CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
+ CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
+ strdup( CurrentUser.UserName );
+
+ CurrentUser.HomeDir = getenv( "HOME" );
+ CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
+ CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
+ strdup( CurrentUser.HomeDir );
+
+ CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
+ CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("USER");
+ CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
+ CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("LD_LIBRARY_PATH");
+
+ CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
+ CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("PATH");
+
+ CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
+ CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("QTDIR");
+
+ CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
+ CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("OPIEDIR");
+ CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
+ CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("SHELL");
+
+ CurrentUser.Uid = getuid();
+ CurrentUser.Gid = getgid();
}
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h
index 3d6a44f..55d2f29 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.h
+++ b/noncore/settings/networksettings2/networksettings2/resources.h
@@ -48,2 +48,5 @@ public :
+ // give busy feedback
+ void busy( bool B );
+
System & system()
@@ -51,2 +54,3 @@ public :
+ int assignConnectionNumber(void);
QPixmap getPixmap( const QString & Name );
@@ -90,3 +94,2 @@ public :
- void renumberConnections( void );
void addConnection( NodeCollection * NC );
@@ -121,3 +124,3 @@ private :
- CurrentQPEUser CurrentUser;
+ CurrentQPEUser CurrentUser;
};
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp
index 2133d34..a579396 100644
--- a/noncore/settings/networksettings2/networksettings2/system.cpp
+++ b/noncore/settings/networksettings2/networksettings2/system.cpp
@@ -10,2 +10,3 @@
#include <stdlib.h>
+#include <stdio.h>
#include <fcntl.h>
@@ -19,2 +20,3 @@
#include <qtextstream.h>
+#include <qapplication.h>
@@ -37,3 +39,3 @@ static char Dig2Hex[] = {
-System::System( void ) : ProbedInterfaces() {
+System::System( void ) : QObject(), ProbedInterfaces() {
probeInterfaces();
@@ -49,3 +51,3 @@ int System::runAsRoot( const QString & S ) {
char * usr = getenv("USER");
- int rv;
+ char ch;
@@ -60,18 +62,43 @@ int System::runAsRoot( const QString & S ) {
- fprintf( stderr, "Executing %s\n", MyS.latin1() );
-
- rv = system( MyS.latin1() ) ;
- switch( rv ) {
- case -1 :
- // cannot fork
- return 1;
- case 127 :
- // cannot start shell
- return 2;
- default :
- if( WEXITSTATUS(rv) != 0 ) {
- // error in command
- return 3;
+ Log(("Executing %s\n", MyS.latin1() ));
+
+ emit lineFromCommand( tr("Command : ") + MyS );
+ emit lineFromCommand( "---------------" );
+ Log(( "Command : %s\n", MyS.latin1() ) );
+ MyS += " 2>&1 ";
+ OutputOfCmd = popen( MyS.latin1(), "r" ) ;
+ if( ! OutputOfCmd ) {
+ // cannot fork
+ return 1;
+ }
+
+ // read all data
+ QString Line = "";
+ while( 1 ) {
+ if( fread( &ch, 1, 1, OutputOfCmd ) < 1 )
+ // eof
+ break;
+ if( ch == '\n' || ch == '\r' ) {
+ if( ! Line.isEmpty() ) {
+ Log(( "read cmd output : **%s**\n", Line.latin1() ) );
+ emit lineFromCommand( Line );
+ Line = "";
+ qApp->processEvents();
}
+ } else {
+ Line += ch;
+ }
+ }
+
+ if( ! Line.isEmpty() ) {
+ emit lineFromCommand( Line );
+ Log(( "read cmd output : **%s**\n", Line.latin1() ) );
+ }
+ Log(( "End of command\n", Line.latin1() ) );
+
+ if( pclose( OutputOfCmd ) < 0 ) {
+ // error in command
+ return 3;
}
+
// all is fine
@@ -200,3 +227,3 @@ void System::probeInterfaces( void ) {
// new nic
- fprintf( stderr, "NEWNIC %s\n", NicName.latin1());
+ Log(("NEWNIC %s\n", NicName.latin1()));
IFI = new InterfaceInfo;
@@ -227,4 +254,4 @@ void System::probeInterfaces( void ) {
if( ioctl(sockfd, SIOCGIFHWADDR, &ifrs) >= 0 ) {
- fprintf( stderr, "%s = %d\n", IFI->Name.latin1(),
- ifrs.ifr_hwaddr.sa_family );
+ Log(("%s = %d\n", IFI->Name.latin1(),
+ ifrs.ifr_hwaddr.sa_family ));
@@ -295,3 +322,3 @@ void System::probeInterfaces( void ) {
} else // else already probed before -> just update
- fprintf( stderr, "OLDNIC %s\n", NicName.latin1());
+ Log(("OLDNIC %s\n", NicName.latin1()));
@@ -325,3 +352,3 @@ void System::probeInterfaces( void ) {
}
- fprintf( stderr, "NIC %s UP %d\n", NicName.latin1(), IFI->IsUp );
+ Log(("NIC %s UP %d\n", NicName.latin1(), IFI->IsUp ));
}
@@ -334,3 +361,3 @@ void System::execAsUser( QString & Cmd, char * argv[] ) {
// if we come here, the exec was not successfull
- fprintf( stderr, "User not known \n" );
+ Log(("User not known \n" ));
return;
@@ -353,3 +380,38 @@ void System::execAsUser( QString & Cmd, char * argv[] ) {
// if we come here, the exec was not successfull
- fprintf( stderr, "Could not exec : %d\n", errno );
+ Log(("Could not exec : %d\n", errno ));
+}
+
+#include <stdarg.h>
+static FILE * logf = 0;
+
+void VLog( char * Format, ... ) {
+ va_list l;
+
+ va_start(l, Format );
+
+ if( logf == (FILE *)0 ) {
+ // logf = fopen( "/tmp/ns2log", "a" );
+ logf = stderr;
+ if( ! logf ) {
+ fprintf( stderr, "Cannot open logfile /tmp/ns2log %d\n",
+ errno );
+ logf = (FILE *)1;
+ } else {
+ fprintf( logf, "____ OPEN LOGFILE ____\n");
+ }
+ }
+
+ if( (long)logf > 1 ) {
+ vfprintf( logf, Format, l );
+ }
+ va_end( l );
+
+}
+
+void LogClose( void ) {
+ if( (long)logf > 1 ) {
+ fprintf( logf, "____ CLOSE LOGFILE ____\n");
+ fclose( logf );
+ logf = 0;
+ }
}
diff --git a/noncore/settings/networksettings2/networksettings2/system.h b/noncore/settings/networksettings2/networksettings2/system.h
index 96ee9bd..33af391 100644
--- a/noncore/settings/networksettings2/networksettings2/system.h
+++ b/noncore/settings/networksettings2/networksettings2/system.h
@@ -6,2 +6,4 @@
#include <qdict.h>
+#include <qobject.h>
+#include <stdio.h>
@@ -49,3 +51,5 @@ public :
-class System {
+class System : public QObject {
+
+ Q_OBJECT
@@ -73,2 +77,6 @@ public :
+signals :
+
+ void lineFromCommand( const QString & S );
+
private :
@@ -76,2 +84,3 @@ private :
QDict<InterfaceInfo> ProbedInterfaces;
+ FILE * OutputOfCmd;
QFile * ProcDevNet;
diff --git a/noncore/settings/networksettings2/networksettingsGUI.ui b/noncore/settings/networksettings2/networksettingsGUI.ui
index 7ef2f64..6ed29f3 100644
--- a/noncore/settings/networksettings2/networksettingsGUI.ui
+++ b/noncore/settings/networksettings2/networksettingsGUI.ui
@@ -13,3 +13,3 @@
<y>0</y>
- <width>160</width>
+ <width>144</width>
<height>260</height>
@@ -30,3 +30,3 @@
<name>margin</name>
- <number>0</number>
+ <number>2</number>
</property>
@@ -304,66 +304,2 @@
<widget>
- <class>QLayoutWidget</class>
- <property stdset="1">
- <name>name</name>
- <cstring>Layout3</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>TextLabel2_2</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>State</string>
- </property>
- </widget>
- <widget>
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>State_LBL</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>State</string>
- </property>
- <property stdset="1">
- <name>indent</name>
- <number>0</number>
- </property>
- </widget>
- <spacer>
- <property>
- <name>name</name>
- <cstring>Spacer6_2</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>
- </hbox>
- </widget>
- <widget>
<class>QLabel</class>
@@ -487,3 +423,3 @@
<name>name</name>
- <cstring>Mesages_LB</cstring>
+ <cstring>Messages_LB</cstring>
</property>
@@ -616,2 +552,8 @@
</connection>
+ <connection>
+ <sender>Disconnect_TB</sender>
+ <signal>clicked()</signal>
+ <receiver>NetworkSettingsGUI</receiver>
+ <slot>SLOT_Disconnect()</slot>
+ </connection>
<slot access="public">SLOT_AddNode()</slot>
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index bb37f10..3b17548 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -19,3 +19,3 @@ NetworkSettingsData::NetworkSettingsData( void ) {
NSResources->currentUser().HomeDir.latin1() );
- fprintf( stderr, "Cfg from %s\n", CfgFile.latin1() );
+ Log(( "Cfg from %s\n", CfgFile.latin1() ));
@@ -81,3 +81,3 @@ void NetworkSettingsData::loadSettings( void ) {
NN = NSResources->findNetNode( S );
- fprintf( stderr, "Node %s : %p\n", S.latin1(), NN );
+ Log( ( "Node %s : %p\n", S.latin1(), NN ) );
} else {
@@ -85,3 +85,3 @@ void NetworkSettingsData::loadSettings( void ) {
NNI = NSResources->createNodeInstance( S );
- fprintf( stderr, "NodeInstance %s : %p\n", S.latin1(), NNI );
+ Log( ( "NodeInstance %s : %p\n", S.latin1(), NNI ));
}
@@ -153,3 +153,3 @@ QString NetworkSettingsData::saveSettings( void ) {
- printf( "Saving settings to %s\n", CfgFile.latin1() );
+ Log( ( "Saving settings to %s\n", CfgFile.latin1() ));
if( ! F.open( IO_WriteOnly | IO_Truncate ) ) {
@@ -231,3 +231,3 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
// regenerate system files
- fprintf( stderr, "Generating settings from %s\n", CfgFile.latin1() );
+ Log( ( "Generating settings from %s\n", CfgFile.latin1() ));
@@ -283,10 +283,2 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
- // we cannot renumber with a FORCE request since
- // we probably are NOT going to save the config
- // e.g. when using --regen option
- if( ! ForceReq && needToRegenerate ) {
- NSResources->renumberConnections();
- setModified(1);
- }
-
//
@@ -323,3 +315,3 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
- fprintf( stderr, "Generating %s\n", SF->name().latin1() );
+ Log( ( "Generating %s\n", SF->name().latin1() ));
SF->open();
@@ -407,3 +399,3 @@ QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interfa
) {
- fprintf( stderr, "Append %s for %s\n", NC->name().latin1(), Interface);
+ Log( ( "Append %s for %s\n", NC->name().latin1(), Interface));
PossibleConnections.append( NC );
@@ -428,4 +420,3 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
- fprintf( stderr, "Possiblilies %d\n",
- PossibleConnections.count() );
+ Log( ( "Possiblilies %d\n", PossibleConnections.count() ));
switch( PossibleConnections.count() ) {
diff --git a/noncore/settings/networksettings2/profile/profileGUI.ui b/noncore/settings/networksettings2/profile/profileGUI.ui
index 365704b..5bf9a9c 100644
--- a/noncore/settings/networksettings2/profile/profileGUI.ui
+++ b/noncore/settings/networksettings2/profile/profileGUI.ui
@@ -13,4 +13,4 @@
<y>0</y>
- <width>225</width>
- <height>301</height>
+ <width>276</width>
+ <height>231</height>
</rect>
@@ -61,3 +61,3 @@
<name>margin</name>
- <number>2</number>
+ <number>1</number>
</property>
@@ -65,50 +65,120 @@
<name>spacing</name>
- <number>0</number>
+ <number>2</number>
</property>
<widget>
- <class>QCheckBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>Automatic_CB</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Start automatically</string>
- </property>
- </widget>
- <widget>
- <class>QCheckBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>Confirm_CB</cstring>
- </property>
- <property stdset="1">
- <name>enabled</name>
- <bool>true</bool>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Confirm before start</string>
- </property>
- <property>
- <name>layoutMargin</name>
- </property>
- </widget>
- <widget>
- <class>QCheckBox</class>
+ <class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
- <cstring>Disabled_CB</cstring>
- </property>
- <property stdset="1">
- <name>enabled</name>
- <bool>true</bool>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Disabled</string>
- </property>
- <property>
- <name>layoutMargin</name>
+ <cstring>Layout8</cstring>
</property>
+ <grid>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget row="0" column="0" rowspan="2" colspan="1" >
+ <class>QGroupBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>GroupBox1</cstring>
+ </property>
+ <property stdset="1">
+ <name>title</name>
+ <string>Start</string>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Automatic_CB</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Automatically</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Confirm_CB</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Ask</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ </widget>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Disabled_CB</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Disabled</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget row="0" column="1" >
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TriggersVPN_CB</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Trigger VPN</string>
+ </property>
+ </widget>
+ <spacer row="1" column="1" >
+ <property>
+ <name>name</name>
+ <cstring>Spacer8</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Vertical</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>
+ </grid>
</widget>
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.cpp b/noncore/settings/networksettings2/profile/profile_NNI.cpp
index 5b54aa4..cb52b2a 100644
--- a/noncore/settings/networksettings2/profile/profile_NNI.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NNI.cpp
@@ -9,2 +9,3 @@ AProfile::AProfile( ProfileNetNode * PNN ) : ANetNodeInstance( PNN ) {
Data.Disabled = 0;
+ Data.TriggerVPN = 0;
GUI = 0;
@@ -21,2 +22,4 @@ void AProfile::setSpecificAttribute( QString & Attr, QString & Value ) {
Data.Disabled = (Value=="yes");
+ } else if ( Attr == "triggervpn" ) {
+ Data.TriggerVPN = (Value=="yes");
} else if ( Attr == "description" ) {
@@ -30,2 +33,3 @@ void AProfile::saveSpecificAttribute( QTextStream & TS ) {
TS << "disabled=" << ((Data.Disabled) ? "yes" : "no") << endl;
+ TS << "triggervpn=" << ((Data.TriggerVPN) ? "yes" : "no") << endl;
TS << "description=" << Data.Description << endl;
diff --git a/noncore/settings/networksettings2/profile/profiledata.h b/noncore/settings/networksettings2/profile/profiledata.h
index b4168e2..246d50c 100644
--- a/noncore/settings/networksettings2/profile/profiledata.h
+++ b/noncore/settings/networksettings2/profile/profiledata.h
@@ -12,2 +12,3 @@ typedef struct ProfileData {
bool Disabled;
+ bool TriggerVPN;
} ProfileData_t;
diff --git a/noncore/settings/networksettings2/profile/profileedit.cpp b/noncore/settings/networksettings2/profile/profileedit.cpp
index c9fb650..87e503e 100644
--- a/noncore/settings/networksettings2/profile/profileedit.cpp
+++ b/noncore/settings/networksettings2/profile/profileedit.cpp
@@ -60,2 +60,3 @@ void ProfileEdit::showData( ProfileData_t & Data ) {
Automatic_CB->setChecked( Data.Automatic );
+ TriggersVPN_CB->setChecked( Data.TriggerVPN );
Confirm_CB->setChecked( Data.Confirm );
@@ -70,2 +71,3 @@ bool ProfileEdit::commit( ProfileData_t & Data ) {
CBM( Data.Automatic, Automatic_CB, SM );
+ CBM( Data.TriggerVPN, TriggersVPN_CB, SM );
CBM( Data.Disabled, Disabled_CB, SM );
diff --git a/noncore/settings/networksettings2/profile/profilerun.cpp b/noncore/settings/networksettings2/profile/profilerun.cpp
index 79bb93e..1a5b15b 100644
--- a/noncore/settings/networksettings2/profile/profilerun.cpp
+++ b/noncore/settings/networksettings2/profile/profilerun.cpp
@@ -6,4 +6,6 @@ void ProfileRun::detectState( NodeCollection * NC ) {
if( Data->Disabled ) {
+ Log(( "%s disabled\n", NC->name().latin1() ));
NC->setCurrentState( Disabled );
} else {
+ Log(( "%s not disabled\n", NC->name().latin1() ));
// find next item in connection
@@ -14,3 +16,3 @@ void ProfileRun::detectState( NodeCollection * NC ) {
-bool ProfileRun::setState( NodeCollection * NC, Action_t A, bool ) {
+bool ProfileRun::setState( NodeCollection * NC, Action_t A, bool F ) {
ANetNodeInstance * NNNI;
@@ -43,3 +45,3 @@ bool ProfileRun::setState( NodeCollection * NC, Action_t A, bool ) {
}
- return NNNI->runtime()->setState(NC, A);
+ return NNNI->runtime()->setState(NC, A, F );
}
diff --git a/noncore/settings/networksettings2/profile/profilerun.h b/noncore/settings/networksettings2/profile/profilerun.h
index c8ea063..400b56c 100644
--- a/noncore/settings/networksettings2/profile/profilerun.h
+++ b/noncore/settings/networksettings2/profile/profilerun.h
@@ -25,2 +25,6 @@ public :
{ return (AsFullSetup *)this; }
+
+ virtual bool triggersVPN( void )
+ { return Data->TriggerVPN; }
+
private :
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp
index beacd7b..b8ac8a8 100644
--- a/noncore/settings/networksettings2/usb/usbrun.cpp
+++ b/noncore/settings/networksettings2/usb/usbrun.cpp
@@ -14,2 +14,3 @@ void USBRun::detectState( NodeCollection * NC ) {
QFile F( S );
+ Log(("Detecting for %s\n", NC->name().latin1() ));
@@ -20,2 +21,3 @@ void USBRun::detectState( NodeCollection * NC ) {
X = TS.readLine();
+ Log(("%s exists\n", S.latin1() ));
// find interface
@@ -36,3 +38,3 @@ void USBRun::detectState( NodeCollection * NC ) {
- fprintf( stderr, "Assigned %p\n", assignedInterface() );
+ Log(("Assigned %p\n", assignedInterface() ));
if( ( Run = assignedInterface() ) ) {
@@ -55,3 +57,3 @@ void USBRun::detectState( NodeCollection * NC ) {
- fprintf( stderr, "%s %d %d=%d %d\n",
+ Log(("%s %d %d=%d %d\n",
Run->Name.latin1(),
@@ -59,3 +61,3 @@ void USBRun::detectState( NodeCollection * NC ) {
Run->CardType, ARPHRD_ETHER,
- ! Run->IsUp );
+ ! Run->IsUp ));
@@ -65,3 +67,3 @@ void USBRun::detectState( NodeCollection * NC ) {
) {
- fprintf( stderr, "Released(OFF)\n" );
+ Log(("Released(OFF)\n" ));
// proper type, and Not UP -> free
@@ -72,3 +74,3 @@ void USBRun::detectState( NodeCollection * NC ) {
// no free found
- fprintf( stderr, "UNA\n" );
+ Log(("UNA\n" ));
@@ -96,3 +98,3 @@ bool USBRun::setState( NodeCollection * NC, Action_t A, bool ) {
assignInterface( N );
- fprintf( stderr, "Assing %p\n", N );
+ Log(("Assing %p\n", N ));
NC->setCurrentState( Available );