author | wimpie <wimpie> | 2005-01-11 15:35:46 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-11 15:35:46 (UTC) |
commit | 4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9 (patch) (unidiff) | |
tree | 0e8adcc616a1d20b637aad3de568dcb45af05f71 /noncore | |
parent | 32e8aa951218c0bd6118ee04bb22ef83b3b7ec2e (diff) | |
download | opie-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
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 | |||
@@ -12,5 +12,5 @@ | |||
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>231</width> | 14 | <width>219</width> |
15 | <height>121</height> | 15 | <height>121</height> |
16 | </rect> | 16 | </rect> |
@@ -41,4 +41,7 @@ | |||
41 | <cstring>Layout2</cstring> | 41 | <cstring>Layout2</cstring> |
42 | </property> | 42 | </property> |
43 | <property> | ||
44 | <name>layoutSpacing</name> | ||
45 | </property> | ||
43 | <hbox> | 46 | <hbox> |
44 | <property stdset="1"> | 47 | <property stdset="1"> |
@@ -48,5 +51,5 @@ | |||
48 | <property stdset="1"> | 51 | <property stdset="1"> |
49 | <name>spacing</name> | 52 | <name>spacing</name> |
50 | <number>6</number> | 53 | <number>0</number> |
51 | </property> | 54 | </property> |
52 | <widget> | 55 | <widget> |
@@ -57,4 +60,11 @@ | |||
57 | </property> | 60 | </property> |
58 | <property stdset="1"> | 61 | <property stdset="1"> |
62 | <name>sizePolicy</name> | ||
63 | <sizepolicy> | ||
64 | <hsizetype>0</hsizetype> | ||
65 | <vsizetype>1</vsizetype> | ||
66 | </sizepolicy> | ||
67 | </property> | ||
68 | <property stdset="1"> | ||
59 | <name>text</name> | 69 | <name>text</name> |
60 | <string>Select profile to activate for </string> | 70 | <string>Select profile to activate for </string> |
@@ -68,4 +78,11 @@ | |||
68 | </property> | 78 | </property> |
69 | <property stdset="1"> | 79 | <property stdset="1"> |
80 | <name>sizePolicy</name> | ||
81 | <sizepolicy> | ||
82 | <hsizetype>7</hsizetype> | ||
83 | <vsizetype>1</vsizetype> | ||
84 | </sizepolicy> | ||
85 | </property> | ||
86 | <property stdset="1"> | ||
70 | <name>text</name> | 87 | <name>text</name> |
71 | <string>TextLabel2</string> | 88 | <string>TextLabel2</string> |
@@ -83,3 +100,11 @@ | |||
83 | </vbox> | 100 | </vbox> |
84 | </widget> | 101 | </widget> |
102 | <connections> | ||
103 | <connection> | ||
104 | <sender>Profiles_LB</sender> | ||
105 | <signal>doubleClicked(QListBoxItem*)</signal> | ||
106 | <receiver>ActivateProfileGUI</receiver> | ||
107 | <slot>accept()</slot> | ||
108 | </connection> | ||
109 | </connections> | ||
85 | </UI> | 110 | </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 | |||
@@ -19,5 +19,5 @@ MyCheckListItem::MyCheckListItem( NodeCollection * N, QListView * V ): | |||
19 | } | 19 | } |
20 | 20 | ||
21 | ActivateVPN::ActivateVPN( void ) : | 21 | ActivateVPN::ActivateVPN( const QString & I ) : |
22 | ActivateVPNGUI( 0, 0, TRUE ), NSD() { | 22 | ActivateVPNGUI( 0, 0, TRUE ), NSD() { |
23 | 23 | ||
@@ -26,8 +26,9 @@ ActivateVPN::ActivateVPN( void ) : | |||
26 | VPN_LV->header()->hide(); | 26 | VPN_LV->header()->hide(); |
27 | 27 | ||
28 | // find all connections that want to be triggered by this interface | ||
28 | for( QDictIterator<NodeCollection> it(NSResources->connections()); | 29 | for( QDictIterator<NodeCollection> it(NSResources->connections()); |
29 | it.current(); | 30 | it.current(); |
30 | ++it ) { | 31 | ++it ) { |
31 | if( it.current()->triggeredBy( "vpn" ) ) { | 32 | if( it.current()->triggeredBy( I ) ) { |
32 | CI = new MyCheckListItem( it.current(), VPN_LV ); | 33 | CI = new MyCheckListItem( it.current(), VPN_LV ); |
33 | } | 34 | } |
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 | |||
@@ -8,5 +8,5 @@ class ActivateVPN : public ActivateVPNGUI { | |||
8 | public : | 8 | public : |
9 | 9 | ||
10 | ActivateVPN( void ); | 10 | ActivateVPN( const QString & Interface ); |
11 | ~ActivateVPN( void ); | 11 | ~ActivateVPN( void ); |
12 | 12 | ||
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 | |||
@@ -24,8 +24,10 @@ OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) | |||
24 | // used by interfaces to request user prompt | 24 | // used by interfaces to request user prompt |
25 | #define ACT_PROMPT 3 | 25 | #define ACT_PROMPT 3 |
26 | // used by interfaces to trigger VPN | 26 | // used by interfaces to trigger VPN prompting |
27 | #define ACT_VPN 4 | 27 | #define ACT_TRIGGERVPN 4 |
28 | // activate opietooth | 28 | // activate opietooth |
29 | #define ACT_OT 5 | 29 | #define ACT_OT 5 |
30 | // prompt for VPN networks | ||
31 | #define ACT_PROMPTVPN 6 | ||
30 | 32 | ||
31 | // include Opietooth GUI | 33 | // include Opietooth GUI |
@@ -57,5 +59,9 @@ int main( int argc, char * argv[] ) { | |||
57 | rmv = 1; | 59 | rmv = 1; |
58 | } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) { | 60 | } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) { |
59 | Action = ACT_VPN; | 61 | GuiType = QApplication::Tty; |
62 | Action = ACT_TRIGGERVPN; | ||
63 | rmv = 1; | ||
64 | } else if( strcmp( argv[i], "--promptvpn" ) == 0 ) { | ||
65 | Action = ACT_PROMPTVPN; | ||
60 | rmv = 1; | 66 | rmv = 1; |
61 | } else if( strcmp( argv[i], "--opietooth" ) == 0 ) { | 67 | } else if( strcmp( argv[i], "--opietooth" ) == 0 ) { |
@@ -96,13 +102,22 @@ int main( int argc, char * argv[] ) { | |||
96 | { NetworkSettingsData NS; | 102 | { NetworkSettingsData NS; |
97 | if( NS.canStart( argv[1] ) ) { | 103 | if( NS.canStart( argv[1] ) ) { |
104 | QStringList SL; | ||
105 | SL << QPEApplication::qpeDir() + "bin/networksettings2" | ||
106 | << "--prompt" | ||
107 | << argv[1]; | ||
108 | // exec synchronous -> blocks | ||
109 | NSResources->system().execAsUser( SL, 1 ); | ||
110 | } | ||
111 | } | ||
112 | break; | ||
113 | case ACT_TRIGGERVPN : | ||
114 | { NetworkSettingsData NS; | ||
115 | if( NS.couldBeTriggered( argv[1] ) ) { | ||
116 | // there are VPNS that can be triggered | ||
98 | QStringList S; | 117 | QStringList S; |
99 | S << QPEApplication::qpeDir() + "/bin/networksettings2"; | 118 | S << QPEApplication::qpeDir() + "bin/networksettings2"; |
100 | S << "networksettings2"; | 119 | S << "--promptvpn"; |
101 | S << "--prompt"; | ||
102 | S << argv[1]; | 120 | S << argv[1]; |
103 | NSResources->system().execAsUser( S ); | 121 | NSResources->system().execAsUser( S ); |
104 | Log(("FAILED %s-cNN-allowed\n", argv[1] )); | ||
105 | // if we come here , failed | ||
106 | printf( "%s-cNN-disallowed", argv[1] ); | ||
107 | } | 122 | } |
108 | } | 123 | } |
@@ -118,15 +133,16 @@ int main( int argc, char * argv[] ) { | |||
118 | { ActivateProfile AP(argv[1]); | 133 | { ActivateProfile AP(argv[1]); |
119 | if( AP.exec() == QDialog::Accepted ) { | 134 | if( AP.exec() == QDialog::Accepted ) { |
120 | Log(("%s-c%ld-allowed\n", | 135 | Log(("allow profile %ld for %s\n", |
121 | argv[1], AP.selectedProfile() )); | 136 | AP.selectedProfile(), argv[1] )); |
122 | printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); | 137 | printf( "A%ld%s\n", AP.selectedProfile(), argv[1] ); |
123 | } else { | 138 | } else { |
124 | Log(("%s-c%NN-disallowed\n", argv[1] )); | 139 | Log(("disallow %s\n", argv[1] )); |
125 | printf( "%s-cNN-disallowed", argv[1] ); | 140 | printf( "D-%s\n", argv[1] ); |
126 | } | 141 | } |
127 | } | 142 | } |
128 | break; | 143 | break; |
129 | case ACT_VPN : | 144 | case ACT_PROMPTVPN : |
130 | { ActivateVPN AVPN; | 145 | { ActivateVPN AVPN( argv[1] ); |
146 | Log(("Trigger vpns on interface %s\n", argv[1] )); | ||
131 | AVPN.exec(); | 147 | AVPN.exec(); |
132 | } | 148 | } |
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 | |||
@@ -117,8 +117,8 @@ short ANetwork::generateFile( SystemFile &SF, | |||
117 | if( Data.UseDHCP ) { | 117 | if( Data.UseDHCP ) { |
118 | SF << "iface " | 118 | SF << "iface " |
119 | << NIC | 119 | << "A" |
120 | << "-c" | ||
121 | << connection()->number() | 120 | << connection()->number() |
122 | << "-allowed inet dhcp" | 121 | << NIC |
122 | << " inet dhcp" | ||
123 | << endl; | 123 | << endl; |
124 | SF << " up echo \"" | 124 | SF << " up echo \"" |
@@ -140,7 +140,8 @@ short ANetwork::generateFile( SystemFile &SF, | |||
140 | } else { | 140 | } else { |
141 | SF << "iface " | 141 | SF << "iface " |
142 | << NIC << "-c" | 142 | << "A" |
143 | << connection()->number() | 143 | << connection()->number() |
144 | << "-allowed inet static" | 144 | << NIC |
145 | << " inet static" | ||
145 | << endl; | 146 | << endl; |
146 | SF << " up echo \"" | 147 | SF << " up echo \"" |
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 | |||
@@ -7,5 +7,5 @@ State_t NetworkRun::detectState( void ) { | |||
7 | InterfaceInfo * II = nodeCollection()->assignedInterface(); | 7 | InterfaceInfo * II = nodeCollection()->assignedInterface(); |
8 | 8 | ||
9 | Log(( "Interface %p : %d\n", II, (II) ? II->IsUp : 0 )); | 9 | Log(( "Interface %p %p : %d\n", II, nodeCollection(), (II) ? II->IsUp : 0 )); |
10 | if( II && II->IsUp ) { | 10 | if( II && II->IsUp ) { |
11 | // device has assigned interface | 11 | // device has assigned interface |
@@ -39,7 +39,8 @@ QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) { | |||
39 | } | 39 | } |
40 | 40 | ||
41 | SL << QString().sprintf( "%s=%s-c%d-allowed", | 41 | SL << QString().sprintf( "%s=A%ld%s", |
42 | II->Name.latin1(), II->Name.latin1(), | 42 | II->Name.latin1(), |
43 | nodeCollection()->number() ); | 43 | nodeCollection()->number(), |
44 | II->Name.latin1() ); | ||
44 | 45 | ||
45 | if( ! NSResources->system().runAsRoot( SL ) ) { | 46 | if( ! NSResources->system().runAsRoot( SL ) ) { |
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 | |||
@@ -248,4 +248,6 @@ const QString & TheNSResources::netNode2Description( const char * s ) { | |||
248 | void TheNSResources::addConnection( NodeCollection * NC, bool Dangling ) { | 248 | void TheNSResources::addConnection( NodeCollection * NC, bool Dangling ) { |
249 | ANetNodeInstance * NNI; | 249 | ANetNodeInstance * NNI; |
250 | Log(( "Add Connection %s, Dangling %d\n", | ||
251 | NC->name().latin1(), Dangling )); | ||
250 | if( Dangling ) { | 252 | if( Dangling ) { |
251 | DanglingConnectionsMap.insert( NC->name(), NC ); | 253 | DanglingConnectionsMap.insert( NC->name(), NC ); |
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 | |||
@@ -111,5 +111,5 @@ public : | |||
111 | { return ConnectionsMap; } | 111 | { return ConnectionsMap; } |
112 | Name2Connection_t & danglingConnections( void ) | 112 | Name2Connection_t & danglingConnections( void ) |
113 | { return ConnectionsMap; } | 113 | { return DanglingConnectionsMap; } |
114 | 114 | ||
115 | inline bool userKnown( void ) | 115 | inline bool userKnown( void ) |
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 | |||
@@ -64,5 +64,5 @@ int System::runAsRoot( QStringList & S, MyProcess * Prc ) { | |||
64 | 64 | ||
65 | if( S.count() == 0 ) { | 65 | if( S.count() == 0 ) { |
66 | // loophole to start shell | 66 | // close loophole to start shell |
67 | return 8888; | 67 | return 8888; |
68 | } | 68 | } |
@@ -120,10 +120,11 @@ int System::runAsRoot( QStringList & S, MyProcess * Prc ) { | |||
120 | } | 120 | } |
121 | 121 | ||
122 | int System::execAsUser( QStringList & SL ) { | 122 | int System::execAsUser( QStringList & SL, bool Synchronous ) { |
123 | MyProcess * P = new MyProcess(); | 123 | MyProcess * P = new MyProcess(); |
124 | CurrentQPEUser CU = NSResources->currentUser(); | 124 | CurrentQPEUser CU = NSResources->currentUser(); |
125 | char * usr = getenv("USER"); | 125 | char * usr = getenv("USER"); |
126 | 126 | ||
127 | if( strcmp( usr, "root" ) == 0 ) { | 127 | if( usr == 0 || |
128 | strcmp( usr, "root" ) == 0 ) { | ||
128 | // find user running qpe | 129 | // find user running qpe |
129 | if( CU.UserName.isEmpty() ) { | 130 | if( CU.UserName.isEmpty() ) { |
@@ -154,14 +155,19 @@ int System::execAsUser( QStringList & SL ) { | |||
154 | SL.join( " " ).latin1() )); | 155 | SL.join( " " ).latin1() )); |
155 | 156 | ||
156 | int rv = ( P->process().start( OProcess::DontCare, | 157 | P->setEchoMode( Synchronous ); |
157 | OProcess::NoCommunication ) ); | 158 | |
159 | bool rv = P->process().start( | ||
160 | (Synchronous) ? OProcess::Block : | ||
161 | OProcess::DontCare, | ||
162 | (Synchronous) ? OProcess::AllOutput : | ||
163 | OProcess::NoCommunication ); | ||
158 | delete P; | 164 | delete P; |
159 | 165 | ||
160 | if( rv ) { | 166 | if( ! rv ) { |
161 | // if we come here, the exec was not successfull | 167 | // if we come here, the exec was not successfull |
162 | Log(("Could not exec : %d\n", errno )); | 168 | Log(("Could not exec : %d\n", errno )); |
163 | } | 169 | } |
164 | 170 | ||
165 | return ! rv; | 171 | return rv; |
166 | } | 172 | } |
167 | 173 | ||
@@ -542,4 +548,9 @@ MyProcess::~MyProcess() { | |||
542 | 548 | ||
543 | void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) { | 549 | void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) { |
550 | if( EchoMode ) { | ||
551 | write( 1, Buf, len ); | ||
552 | return; | ||
553 | } | ||
554 | |||
544 | char * LB = (char *)alloca( len + 1 ); | 555 | char * LB = (char *)alloca( len + 1 ); |
545 | memcpy( LB, Buf, len ); | 556 | memcpy( LB, Buf, len ); |
@@ -563,4 +574,9 @@ void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) { | |||
563 | 574 | ||
564 | void MyProcess::SLOT_Stderr( Opie::Core::OProcess * , char * Buf, int len ) { | 575 | void MyProcess::SLOT_Stderr( Opie::Core::OProcess * , char * Buf, int len ) { |
576 | if( EchoMode ) { | ||
577 | write( 2, Buf, len ); | ||
578 | return; | ||
579 | } | ||
580 | |||
565 | char * LB = (char *)alloca( len + 1 ); | 581 | char * LB = (char *)alloca( len + 1 ); |
566 | memcpy( LB, Buf, len ); | 582 | memcpy( LB, Buf, len ); |
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 | |||
@@ -30,4 +30,8 @@ public : | |||
30 | { return *P; } | 30 | { return *P; } |
31 | 31 | ||
32 | inline void setEchoMode( bool M ) { | ||
33 | EchoMode = M; | ||
34 | } | ||
35 | |||
32 | public slots : | 36 | public slots : |
33 | 37 | ||
@@ -47,4 +51,6 @@ private : | |||
47 | QString StderrBuffer; | 51 | QString StderrBuffer; |
48 | OProcess * P; | 52 | OProcess * P; |
53 | // output all output to my output | ||
54 | bool EchoMode; | ||
49 | }; | 55 | }; |
50 | 56 | ||
@@ -105,5 +111,5 @@ public : | |||
105 | 111 | ||
106 | // exec command as user | 112 | // exec command as user |
107 | int execAsUser( QStringList & Cmd ); | 113 | int execAsUser( QStringList & Cmd, bool Synchronous = 0 ); |
108 | 114 | ||
109 | // refresh stats for this interface | 115 | // refresh stats for this interface |
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 | |||
@@ -137,5 +137,4 @@ bool SystemFile::close( void ) { | |||
137 | 137 | ||
138 | if( ! InAppend ) { | 138 | if( ! InAppend ) { |
139 | odebug << "Rename " << OldP << " to " << Path << oendl; | ||
140 | return ( rename( OldP.latin1(), Path.latin1() ) >= 0 ); | 139 | return ( rename( OldP.latin1(), Path.latin1() ) >= 0 ); |
141 | } | 140 | } |
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 | |||
@@ -62,4 +62,6 @@ NetworkSettingsData::NetworkSettingsData( void ) { | |||
62 | NC->assignInterface( | 62 | NC->assignInterface( |
63 | NSResources->system().findInterface( interfacename ) ); | 63 | NSResources->system().findInterface( interfacename ) ); |
64 | Log(( "Assign interface %p\n", | ||
65 | NC->assignedInterface() )); | ||
64 | } else { | 66 | } else { |
65 | Log(( "Profile nr %d no longer defined\n", | 67 | Log(( "Profile nr %d no longer defined\n", |
@@ -644,5 +646,6 @@ QString NetworkSettingsData::generateSettings( void ) { | |||
644 | } | 646 | } |
645 | 647 | ||
646 | QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) { | 648 | QList<NodeCollection> NetworkSettingsData::collectPossible( |
649 | const QString & Interface ) { | ||
647 | // collect connections that can work on top of this interface | 650 | // collect connections that can work on top of this interface |
648 | NodeCollection * NC; | 651 | NodeCollection * NC; |
@@ -657,8 +660,9 @@ QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interfa | |||
657 | // check if this profile handles the requested interface | 660 | // check if this profile handles the requested interface |
658 | if( NC->handlesInterface( Interface ) && // if different Intf. | 661 | if( NC->handlesInterface( Interface ) && // if different Intf. |
659 | NC->state() != Disabled && // if not enabled | 662 | NC->state() != Disabled && // if enabled |
660 | NC->state() != IsUp // if already used | 663 | NC->state() != IsUp // if already used |
661 | ) { | 664 | ) { |
662 | Log( ( "Append %s for %s\n", NC->name().latin1(), Interface)); | 665 | Log( ( "Append %s for %s\n", |
666 | NC->name().latin1(), Interface.latin1() )); | ||
663 | PossibleConnections.append( NC ); | 667 | PossibleConnections.append( NC ); |
664 | } | 668 | } |
@@ -674,5 +678,5 @@ QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interfa | |||
674 | */ | 678 | */ |
675 | 679 | ||
676 | bool NetworkSettingsData::canStart( const char * Interface ) { | 680 | bool NetworkSettingsData::canStart( const QString & Interface ) { |
677 | // load situation | 681 | // load situation |
678 | NodeCollection * NC = 0; | 682 | NodeCollection * NC = 0; |
@@ -682,5 +686,5 @@ bool NetworkSettingsData::canStart( const char * Interface ) { | |||
682 | 686 | ||
683 | Log( ( "for %s : Possiblilies %d\n", | 687 | Log( ( "for %s : Possiblilies %d\n", |
684 | Interface, PossibleConnections.count() )); | 688 | Interface.latin1(), PossibleConnections.count() )); |
685 | switch( PossibleConnections.count() ) { | 689 | switch( PossibleConnections.count() ) { |
686 | case 0 : // no connections | 690 | case 0 : // no connections |
@@ -707,6 +711,6 @@ bool NetworkSettingsData::canStart( const char * Interface ) { | |||
707 | if( ! S.isEmpty() ) { | 711 | if( ! S.isEmpty() ) { |
708 | // could not bring device Online -> try other alters | 712 | // could not bring device Online -> try other alters |
709 | Log(( "%s-c%d-disallowed : %s\n", | 713 | Log(( "disallow %ld for %s : %s\n", |
710 | Interface, NC->number(), S.latin1() )); | 714 | NC->number(), Interface.latin1(), S.latin1() )); |
711 | break; | 715 | break; |
712 | } | 716 | } |
@@ -717,6 +721,6 @@ bool NetworkSettingsData::canStart( const char * Interface ) { | |||
717 | case IsUp : // also called for 'ifdown' | 721 | case IsUp : // also called for 'ifdown' |
718 | // device is ready -> done | 722 | // device is ready -> done |
719 | Log(( "%s-c%d-allowed\n", Interface, NC->number() )); | 723 | Log(( "allow %ld for %s\n", NC->number(), Interface.latin1())); |
720 | printf( "%s-c%d-allowed\n", Interface, NC->number() ); | 724 | printf( "A%ld%s\n", NC->number(), Interface.latin1() ); |
721 | return 0; | 725 | return 0; |
722 | } | 726 | } |
@@ -724,6 +728,6 @@ bool NetworkSettingsData::canStart( const char * Interface ) { | |||
724 | 728 | ||
725 | // if we come here no alternatives are possible | 729 | // if we come here no alternatives are possible |
726 | Log(( "%s-cnn-disallowed\n", Interface )); | 730 | Log(( "disallow %s\n", Interface.latin1())); |
727 | printf( "%s-cnn-disallowed\n", Interface ); | 731 | printf( "D-%s\n", Interface.latin1() ); |
728 | return 0; | 732 | return 0; |
729 | } | 733 | } |
@@ -742,2 +746,42 @@ bool NetworkSettingsData::isModified( void ) { | |||
742 | return 0; | 746 | return 0; |
743 | } | 747 | } |
748 | |||
749 | bool NetworkSettingsData::couldBeTriggered( const QString & Interface ) { | ||
750 | // load situation | ||
751 | QList<NodeCollection> PossibleTriggered; | ||
752 | |||
753 | PossibleTriggered = collectTriggered( Interface ); | ||
754 | |||
755 | Log( ( "for %s : Possiblilies %d\n", | ||
756 | Interface.latin1(), PossibleTriggered.count() )); | ||
757 | |||
758 | return ( PossibleTriggered.count() ) ? 1 : 0; | ||
759 | } | ||
760 | |||
761 | QList<NodeCollection> NetworkSettingsData::collectTriggered( | ||
762 | const QString & Interface ) { | ||
763 | |||
764 | // collect connections that could be triggered by this interface | ||
765 | NodeCollection * NC; | ||
766 | QList<NodeCollection> PossibleTriggered; | ||
767 | |||
768 | // for all connections | ||
769 | Name2Connection_t & M = NSResources->connections(); | ||
770 | |||
771 | for( QDictIterator<NodeCollection> it(M); | ||
772 | it.current(); | ||
773 | ++it ) { | ||
774 | NC = it.current(); | ||
775 | // check if this profile handles the requested interface | ||
776 | if( NC->triggeredBy( Interface ) && // if different Intf. | ||
777 | NC->state() != Disabled && // if enabled | ||
778 | NC->state() != IsUp // if already used | ||
779 | ) { | ||
780 | Log( ( "Append %s for %s\n", | ||
781 | NC->name().latin1(), Interface.latin1() )); | ||
782 | PossibleTriggered.append( NC ); | ||
783 | } | ||
784 | } | ||
785 | return PossibleTriggered; | ||
786 | } | ||
787 | |||
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 | |||
@@ -20,10 +20,14 @@ public : | |||
20 | { ForceModified = M; } | 20 | { ForceModified = M; } |
21 | 21 | ||
22 | QList<NodeCollection> collectPossible( const char * Interface ); | 22 | QList<NodeCollection> collectPossible( const QString & Interface ); |
23 | // return TRUE if we need gui to decide | 23 | // return TRUE if we need gui to decide |
24 | bool canStart( const char * Interface ); | 24 | bool canStart( const QString & Interface ); |
25 | // return TRUE if there are vpns that could be triggered | ||
26 | // by this interface | ||
27 | bool couldBeTriggered( const QString & Interface ); | ||
25 | 28 | ||
26 | private : | 29 | private : |
27 | 30 | ||
31 | QList<NodeCollection> collectTriggered( const QString &Interface ); | ||
28 | bool ForceModified; | 32 | bool ForceModified; |
29 | 33 | ||
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,2 +1,3 @@ | |||
1 | #include <qpe/qpeapplication.h> | ||
1 | #include <opie2/odebug.h> | 2 | #include <opie2/odebug.h> |
2 | #include "profileedit.h" | 3 | #include "profileedit.h" |
@@ -63,5 +64,9 @@ short AProfile::generateFileEmbedded( SystemFile & SF, | |||
63 | if( Data.TriggerVPN ) { | 64 | if( Data.TriggerVPN ) { |
64 | // this profile triggers VPN -> insert trigger | 65 | // this profile triggers VPN -> insert trigger |
65 | SF << " up networksettings2 --triggervpn" | 66 | SF << " up " |
67 | << QPEApplication::qpeDir() | ||
68 | << "bin/networksettings2 --triggervpn " | ||
69 | << runtime()->device()->netNode()->nodeClass()->genNic( DevNr ) | ||
70 | << " || true" | ||
66 | << endl; | 71 | << endl; |
67 | rvl = 0; | 72 | rvl = 0; |