summaryrefslogtreecommitdiff
authorwimpie <wimpie>2005-01-11 15:35:46 (UTC)
committer wimpie <wimpie>2005-01-11 15:35:46 (UTC)
commit4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9 (patch) (side-by-side diff)
tree0e8adcc616a1d20b637aad3de568dcb45af05f71
parent32e8aa951218c0bd6118ee04bb22ef83b3b7ec2e (diff)
downloadopie-4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9.zip
opie-4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9.tar.gz
opie-4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9.tar.bz2
vpn should now work IF only the vpn plugin would do something.
shortened logical interface names (busybox only supports 10 characters and then ONLY if you recompile it with mappings enabled) Other small fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/activateprofileGUI.ui29
-rw-r--r--noncore/settings/networksettings2/activatevpn.cpp5
-rw-r--r--noncore/settings/networksettings2/activatevpn.h2
-rw-r--r--noncore/settings/networksettings2/main.cpp48
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.cpp11
-rw-r--r--noncore/settings/networksettings2/network/networkrun.cpp9
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp2
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.h2
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp30
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.h8
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.cpp1
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp66
-rw-r--r--noncore/settings/networksettings2/nsdata.h8
-rw-r--r--noncore/settings/networksettings2/profile/profile_NNI.cpp7
14 files changed, 174 insertions, 54 deletions
diff --git a/noncore/settings/networksettings2/activateprofileGUI.ui b/noncore/settings/networksettings2/activateprofileGUI.ui
index 12ab051..861ce96 100644
--- a/noncore/settings/networksettings2/activateprofileGUI.ui
+++ b/noncore/settings/networksettings2/activateprofileGUI.ui
@@ -13,3 +13,3 @@
<y>0</y>
- <width>231</width>
+ <width>219</width>
<height>121</height>
@@ -42,2 +42,5 @@
</property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
<hbox>
@@ -49,3 +52,3 @@
<name>spacing</name>
- <number>6</number>
+ <number>0</number>
</property>
@@ -58,2 +61,9 @@
<property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
<name>text</name>
@@ -69,2 +79,9 @@
<property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
<name>text</name>
@@ -84,2 +101,10 @@
</widget>
+<connections>
+ <connection>
+ <sender>Profiles_LB</sender>
+ <signal>doubleClicked(QListBoxItem*)</signal>
+ <receiver>ActivateProfileGUI</receiver>
+ <slot>accept()</slot>
+ </connection>
+</connections>
</UI>
diff --git a/noncore/settings/networksettings2/activatevpn.cpp b/noncore/settings/networksettings2/activatevpn.cpp
index b75e623..768a031 100644
--- a/noncore/settings/networksettings2/activatevpn.cpp
+++ b/noncore/settings/networksettings2/activatevpn.cpp
@@ -20,3 +20,3 @@ MyCheckListItem::MyCheckListItem( NodeCollection * N, QListView * V ):
-ActivateVPN::ActivateVPN( void ) :
+ActivateVPN::ActivateVPN( const QString & I ) :
ActivateVPNGUI( 0, 0, TRUE ), NSD() {
@@ -27,2 +27,3 @@ ActivateVPN::ActivateVPN( void ) :
+ // find all connections that want to be triggered by this interface
for( QDictIterator<NodeCollection> it(NSResources->connections());
@@ -30,3 +31,3 @@ ActivateVPN::ActivateVPN( void ) :
++it ) {
- if( it.current()->triggeredBy( "vpn" ) ) {
+ if( it.current()->triggeredBy( I ) ) {
CI = new MyCheckListItem( it.current(), VPN_LV );
diff --git a/noncore/settings/networksettings2/activatevpn.h b/noncore/settings/networksettings2/activatevpn.h
index 5794757..49a940b 100644
--- a/noncore/settings/networksettings2/activatevpn.h
+++ b/noncore/settings/networksettings2/activatevpn.h
@@ -9,3 +9,3 @@ public :
- ActivateVPN( void );
+ ActivateVPN( const QString & Interface );
~ActivateVPN( void );
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp
index 973b4b7..2243826 100644
--- a/noncore/settings/networksettings2/main.cpp
+++ b/noncore/settings/networksettings2/main.cpp
@@ -25,6 +25,8 @@ OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> )
#define ACT_PROMPT 3
-// used by interfaces to trigger VPN
-#define ACT_VPN 4
+// used by interfaces to trigger VPN prompting
+#define ACT_TRIGGERVPN 4
// activate opietooth
#define ACT_OT 5
+// prompt for VPN networks
+#define ACT_PROMPTVPN 6
@@ -58,3 +60,7 @@ int main( int argc, char * argv[] ) {
} else if( strcmp( argv[i], "--triggervpn" ) == 0 ) {
- Action = ACT_VPN;
+ GuiType = QApplication::Tty;
+ Action = ACT_TRIGGERVPN;
+ rmv = 1;
+ } else if( strcmp( argv[i], "--promptvpn" ) == 0 ) {
+ Action = ACT_PROMPTVPN;
rmv = 1;
@@ -97,11 +103,20 @@ int main( int argc, char * argv[] ) {
if( NS.canStart( argv[1] ) ) {
+ QStringList SL;
+ SL << QPEApplication::qpeDir() + "bin/networksettings2"
+ << "--prompt"
+ << argv[1];
+ // exec synchronous -> blocks
+ NSResources->system().execAsUser( SL, 1 );
+ }
+ }
+ break;
+ case ACT_TRIGGERVPN :
+ { NetworkSettingsData NS;
+ if( NS.couldBeTriggered( argv[1] ) ) {
+ // there are VPNS that can be triggered
QStringList S;
- S << QPEApplication::qpeDir() + "/bin/networksettings2";
- S << "networksettings2";
- S << "--prompt";
+ S << QPEApplication::qpeDir() + "bin/networksettings2";
+ S << "--promptvpn";
S << argv[1];
NSResources->system().execAsUser( S );
- Log(("FAILED %s-cNN-allowed\n", argv[1] ));
- // if we come here , failed
- printf( "%s-cNN-disallowed", argv[1] );
}
@@ -119,8 +134,8 @@ int main( int argc, char * argv[] ) {
if( AP.exec() == QDialog::Accepted ) {
- Log(("%s-c%ld-allowed\n",
- argv[1], AP.selectedProfile() ));
- printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() );
+ Log(("allow profile %ld for %s\n",
+ AP.selectedProfile(), argv[1] ));
+ printf( "A%ld%s\n", AP.selectedProfile(), argv[1] );
} else {
- Log(("%s-c%NN-disallowed\n", argv[1] ));
- printf( "%s-cNN-disallowed", argv[1] );
+ Log(("disallow %s\n", argv[1] ));
+ printf( "D-%s\n", argv[1] );
}
@@ -128,4 +143,5 @@ int main( int argc, char * argv[] ) {
break;
- case ACT_VPN :
- { ActivateVPN AVPN;
+ case ACT_PROMPTVPN :
+ { ActivateVPN AVPN( argv[1] );
+ Log(("Trigger vpns on interface %s\n", argv[1] ));
AVPN.exec();
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp
index 78e6545..34dac54 100644
--- a/noncore/settings/networksettings2/network/network_NNI.cpp
+++ b/noncore/settings/networksettings2/network/network_NNI.cpp
@@ -118,6 +118,6 @@ short ANetwork::generateFile( SystemFile &SF,
SF << "iface "
- << NIC
- << "-c"
+ << "A"
<< connection()->number()
- << "-allowed inet dhcp"
+ << NIC
+ << " inet dhcp"
<< endl;
@@ -141,5 +141,6 @@ short ANetwork::generateFile( SystemFile &SF,
SF << "iface "
- << NIC << "-c"
+ << "A"
<< connection()->number()
- << "-allowed inet static"
+ << NIC
+ << " inet static"
<< endl;
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp
index 2c93d9d..74467ad 100644
--- a/noncore/settings/networksettings2/network/networkrun.cpp
+++ b/noncore/settings/networksettings2/network/networkrun.cpp
@@ -8,3 +8,3 @@ State_t NetworkRun::detectState( void ) {
- Log(( "Interface %p : %d\n", II, (II) ? II->IsUp : 0 ));
+ Log(( "Interface %p %p : %d\n", II, nodeCollection(), (II) ? II->IsUp : 0 ));
if( II && II->IsUp ) {
@@ -40,5 +40,6 @@ QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
- SL << QString().sprintf( "%s=%s-c%d-allowed",
- II->Name.latin1(), II->Name.latin1(),
- nodeCollection()->number() );
+ SL << QString().sprintf( "%s=A%ld%s",
+ II->Name.latin1(),
+ nodeCollection()->number(),
+ II->Name.latin1() );
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp
index 3479abb..b81dcaa 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.cpp
+++ b/noncore/settings/networksettings2/networksettings2/resources.cpp
@@ -249,2 +249,4 @@ void TheNSResources::addConnection( NodeCollection * NC, bool Dangling ) {
ANetNodeInstance * NNI;
+ Log(( "Add Connection %s, Dangling %d\n",
+ NC->name().latin1(), Dangling ));
if( Dangling ) {
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h
index b27cda1..51c4250 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.h
+++ b/noncore/settings/networksettings2/networksettings2/resources.h
@@ -112,3 +112,3 @@ public :
Name2Connection_t & danglingConnections( void )
- { return ConnectionsMap; }
+ { return DanglingConnectionsMap; }
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp
index f027d35..a290f08 100644
--- a/noncore/settings/networksettings2/networksettings2/system.cpp
+++ b/noncore/settings/networksettings2/networksettings2/system.cpp
@@ -65,3 +65,3 @@ int System::runAsRoot( QStringList & S, MyProcess * Prc ) {
if( S.count() == 0 ) {
- // loophole to start shell
+ // close loophole to start shell
return 8888;
@@ -121,3 +121,3 @@ int System::runAsRoot( QStringList & S, MyProcess * Prc ) {
-int System::execAsUser( QStringList & SL ) {
+int System::execAsUser( QStringList & SL, bool Synchronous ) {
MyProcess * P = new MyProcess();
@@ -126,3 +126,4 @@ int System::execAsUser( QStringList & SL ) {
- if( strcmp( usr, "root" ) == 0 ) {
+ if( usr == 0 ||
+ strcmp( usr, "root" ) == 0 ) {
// find user running qpe
@@ -155,7 +156,12 @@ int System::execAsUser( QStringList & SL ) {
- int rv = ( P->process().start( OProcess::DontCare,
- OProcess::NoCommunication ) );
+ P->setEchoMode( Synchronous );
+
+ bool rv = P->process().start(
+ (Synchronous) ? OProcess::Block :
+ OProcess::DontCare,
+ (Synchronous) ? OProcess::AllOutput :
+ OProcess::NoCommunication );
delete P;
- if( rv ) {
+ if( ! rv ) {
// if we come here, the exec was not successfull
@@ -164,3 +170,3 @@ int System::execAsUser( QStringList & SL ) {
- return ! rv;
+ return rv;
}
@@ -543,2 +549,7 @@ MyProcess::~MyProcess() {
void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) {
+ if( EchoMode ) {
+ write( 1, Buf, len );
+ return;
+ }
+
char * LB = (char *)alloca( len + 1 );
@@ -564,2 +575,7 @@ void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) {
void MyProcess::SLOT_Stderr( Opie::Core::OProcess * , char * Buf, int len ) {
+ if( EchoMode ) {
+ write( 2, Buf, len );
+ return;
+ }
+
char * LB = (char *)alloca( len + 1 );
diff --git a/noncore/settings/networksettings2/networksettings2/system.h b/noncore/settings/networksettings2/networksettings2/system.h
index f7a7274..ebee0d5 100644
--- a/noncore/settings/networksettings2/networksettings2/system.h
+++ b/noncore/settings/networksettings2/networksettings2/system.h
@@ -31,2 +31,6 @@ public :
+ inline void setEchoMode( bool M ) {
+ EchoMode = M;
+ }
+
public slots :
@@ -48,2 +52,4 @@ private :
OProcess * P;
+ // output all output to my output
+ bool EchoMode;
};
@@ -106,3 +112,3 @@ public :
// exec command as user
- int execAsUser( QStringList & Cmd );
+ int execAsUser( QStringList & Cmd, bool Synchronous = 0 );
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
index 1b1988e..0314765 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
@@ -138,3 +138,2 @@ bool SystemFile::close( void ) {
if( ! InAppend ) {
- odebug << "Rename " << OldP << " to " << Path << oendl;
return ( rename( OldP.latin1(), Path.latin1() ) >= 0 );
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index d76353a..39031ed 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -63,2 +63,4 @@ NetworkSettingsData::NetworkSettingsData( void ) {
NSResources->system().findInterface( interfacename ) );
+ Log(( "Assign interface %p\n",
+ NC->assignedInterface() ));
} else {
@@ -645,3 +647,4 @@ QString NetworkSettingsData::generateSettings( void ) {
-QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) {
+QList<NodeCollection> NetworkSettingsData::collectPossible(
+ const QString & Interface ) {
// collect connections that can work on top of this interface
@@ -658,6 +661,7 @@ QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interfa
if( NC->handlesInterface( Interface ) && // if different Intf.
- NC->state() != Disabled && // if not enabled
+ NC->state() != Disabled && // if enabled
NC->state() != IsUp // if already used
) {
- Log( ( "Append %s for %s\n", NC->name().latin1(), Interface));
+ Log( ( "Append %s for %s\n",
+ NC->name().latin1(), Interface.latin1() ));
PossibleConnections.append( NC );
@@ -675,3 +679,3 @@ QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interfa
-bool NetworkSettingsData::canStart( const char * Interface ) {
+bool NetworkSettingsData::canStart( const QString & Interface ) {
// load situation
@@ -683,3 +687,3 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
Log( ( "for %s : Possiblilies %d\n",
- Interface, PossibleConnections.count() ));
+ Interface.latin1(), PossibleConnections.count() ));
switch( PossibleConnections.count() ) {
@@ -708,4 +712,4 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
// could not bring device Online -> try other alters
- Log(( "%s-c%d-disallowed : %s\n",
- Interface, NC->number(), S.latin1() ));
+ Log(( "disallow %ld for %s : %s\n",
+ NC->number(), Interface.latin1(), S.latin1() ));
break;
@@ -718,4 +722,4 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
// device is ready -> done
- Log(( "%s-c%d-allowed\n", Interface, NC->number() ));
- printf( "%s-c%d-allowed\n", Interface, NC->number() );
+ Log(( "allow %ld for %s\n", NC->number(), Interface.latin1()));
+ printf( "A%ld%s\n", NC->number(), Interface.latin1() );
return 0;
@@ -725,4 +729,4 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
// if we come here no alternatives are possible
- Log(( "%s-cnn-disallowed\n", Interface ));
- printf( "%s-cnn-disallowed\n", Interface );
+ Log(( "disallow %s\n", Interface.latin1()));
+ printf( "D-%s\n", Interface.latin1() );
return 0;
@@ -743 +747,41 @@ bool NetworkSettingsData::isModified( void ) {
}
+
+bool NetworkSettingsData::couldBeTriggered( const QString & Interface ) {
+ // load situation
+ QList<NodeCollection> PossibleTriggered;
+
+ PossibleTriggered = collectTriggered( Interface );
+
+ Log( ( "for %s : Possiblilies %d\n",
+ Interface.latin1(), PossibleTriggered.count() ));
+
+ return ( PossibleTriggered.count() ) ? 1 : 0;
+}
+
+QList<NodeCollection> NetworkSettingsData::collectTriggered(
+ const QString & Interface ) {
+
+ // collect connections that could be triggered by this interface
+ NodeCollection * NC;
+ QList<NodeCollection> PossibleTriggered;
+
+ // for all connections
+ Name2Connection_t & M = NSResources->connections();
+
+ for( QDictIterator<NodeCollection> 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 a0ae7d1..5791c1e 100644
--- a/noncore/settings/networksettings2/nsdata.h
+++ b/noncore/settings/networksettings2/nsdata.h
@@ -21,5 +21,8 @@ public :
- QList<NodeCollection> collectPossible( const char * Interface );
+ QList<NodeCollection> collectPossible( const QString & Interface );
// return TRUE if we need gui to decide
- bool canStart( const char * Interface );
+ bool canStart( const QString & Interface );
+ // return TRUE if there are vpns that could be triggered
+ // by this interface
+ bool couldBeTriggered( const QString & Interface );
@@ -27,2 +30,3 @@ private :
+ QList<NodeCollection> collectTriggered( const QString &Interface );
bool ForceModified;
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.cpp b/noncore/settings/networksettings2/profile/profile_NNI.cpp
index a1e1254..fc2d809 100644
--- a/noncore/settings/networksettings2/profile/profile_NNI.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NNI.cpp
@@ -1 +1,2 @@
+#include <qpe/qpeapplication.h>
#include <opie2/odebug.h>
@@ -64,3 +65,7 @@ short AProfile::generateFileEmbedded( SystemFile & SF,
// this profile triggers VPN -> insert trigger
- SF << " up networksettings2 --triggervpn"
+ SF << " up "
+ << QPEApplication::qpeDir()
+ << "bin/networksettings2 --triggervpn "
+ << runtime()->device()->netNode()->nodeClass()->genNic( DevNr )
+ << " || true"
<< endl;