summaryrefslogtreecommitdiff
authorwimpie <wimpie>2005-01-11 15:35:46 (UTC)
committer wimpie <wimpie>2005-01-11 15:35:46 (UTC)
commit4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9 (patch) (unidiff)
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
@@ -1,85 +1,110 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>ActivateProfileGUI</class> 2<class>ActivateProfileGUI</class>
3<widget> 3<widget>
4 <class>QDialog</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>ActivateProfileGUI</cstring> 7 <cstring>ActivateProfileGUI</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
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>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Activate Network</string> 20 <string>Activate Network</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <property> 25 <property>
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
27 </property> 27 </property>
28 <vbox> 28 <vbox>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>2</number> 31 <number>2</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>2</number> 35 <number>2</number>
36 </property> 36 </property>
37 <widget> 37 <widget>
38 <class>QLayoutWidget</class> 38 <class>QLayoutWidget</class>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>name</name> 40 <name>name</name>
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">
45 <name>margin</name> 48 <name>margin</name>
46 <number>0</number> 49 <number>0</number>
47 </property> 50 </property>
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>
53 <class>QLabel</class> 56 <class>QLabel</class>
54 <property stdset="1"> 57 <property stdset="1">
55 <name>name</name> 58 <name>name</name>
56 <cstring>TextLabel1</cstring> 59 <cstring>TextLabel1</cstring>
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>
61 </property> 71 </property>
62 </widget> 72 </widget>
63 <widget> 73 <widget>
64 <class>QLabel</class> 74 <class>QLabel</class>
65 <property stdset="1"> 75 <property stdset="1">
66 <name>name</name> 76 <name>name</name>
67 <cstring>DeviceName_LBL</cstring> 77 <cstring>DeviceName_LBL</cstring>
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>
72 </property> 89 </property>
73 </widget> 90 </widget>
74 </hbox> 91 </hbox>
75 </widget> 92 </widget>
76 <widget> 93 <widget>
77 <class>QListBox</class> 94 <class>QListBox</class>
78 <property stdset="1"> 95 <property stdset="1">
79 <name>name</name> 96 <name>name</name>
80 <cstring>Profiles_LB</cstring> 97 <cstring>Profiles_LB</cstring>
81 </property> 98 </property>
82 </widget> 99 </widget>
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
@@ -1,47 +1,48 @@
1#include <qlistview.h> 1#include <qlistview.h>
2#include <qheader.h> 2#include <qheader.h>
3#include <resources.h> 3#include <resources.h>
4#include "activatevpn.h" 4#include "activatevpn.h"
5 5
6class MyCheckListItem : public QCheckListItem { 6class MyCheckListItem : public QCheckListItem {
7 7
8public : 8public :
9 9
10 MyCheckListItem( NodeCollection * N, QListView * V ); 10 MyCheckListItem( NodeCollection * N, QListView * V );
11 11
12 NodeCollection * NC; 12 NodeCollection * NC;
13 13
14}; 14};
15 15
16MyCheckListItem::MyCheckListItem( NodeCollection * N, QListView * V ): 16MyCheckListItem::MyCheckListItem( NodeCollection * N, QListView * V ):
17 QCheckListItem( V, N->name() ) { 17 QCheckListItem( V, N->name() ) {
18 NC = N; 18 NC = N;
19} 19}
20 20
21ActivateVPN::ActivateVPN( void ) : 21ActivateVPN::ActivateVPN( const QString & I ) :
22 ActivateVPNGUI( 0, 0, TRUE ), NSD() { 22 ActivateVPNGUI( 0, 0, TRUE ), NSD() {
23 23
24 QCheckListItem * CI; 24 QCheckListItem * CI;
25 VPN_LV->clear(); 25 VPN_LV->clear();
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 }
34 } 35 }
35} 36}
36 37
37ActivateVPN::~ActivateVPN( void ) { 38ActivateVPN::~ActivateVPN( void ) {
38} 39}
39 40
40void ActivateVPN::SLOT_ChangedVPNSetting( QListViewItem * I ) { 41void ActivateVPN::SLOT_ChangedVPNSetting( QListViewItem * I ) {
41 42
42 MyCheckListItem * MI = (MyCheckListItem *)I; 43 MyCheckListItem * MI = (MyCheckListItem *)I;
43 44
44 printf( "%s : %d\n", 45 printf( "%s : %d\n",
45 MI->text(0).latin1(), 46 MI->text(0).latin1(),
46 MI->isOn() ); 47 MI->isOn() );
47} 48}
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
@@ -1,20 +1,20 @@
1#include "activatevpnGUI.h" 1#include "activatevpnGUI.h"
2#include "nsdata.h" 2#include "nsdata.h"
3 3
4class ActivateVPN : public ActivateVPNGUI { 4class ActivateVPN : public ActivateVPNGUI {
5 5
6 Q_OBJECT 6 Q_OBJECT
7 7
8public : 8public :
9 9
10 ActivateVPN( void ); 10 ActivateVPN( const QString & Interface );
11 ~ActivateVPN( void ); 11 ~ActivateVPN( void );
12 12
13public slots : 13public slots :
14 14
15 void SLOT_ChangedVPNSetting( QListViewItem * ); 15 void SLOT_ChangedVPNSetting( QListViewItem * );
16 16
17private : 17private :
18 18
19 NetworkSettingsData NSD; 19 NetworkSettingsData NSD;
20}; 20};
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
@@ -2,153 +2,169 @@
2#include "activateprofile.h" 2#include "activateprofile.h"
3#include "activatevpn.h" 3#include "activatevpn.h"
4#include "networksettings.h" 4#include "networksettings.h"
5 5
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7#include <qpe/qpeapplication.h> 7#include <qpe/qpeapplication.h>
8 8
9#include <opie2/oapplicationfactory.h> 9#include <opie2/oapplicationfactory.h>
10using namespace Opie::Core; 10using namespace Opie::Core;
11 11
12#ifdef GONE 12#ifdef GONE
13 13
14OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) 14OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> )
15 15
16#else 16#else
17 17
18// just standard GUI 18// just standard GUI
19#define ACT_GUI 0 19#define ACT_GUI 0
20// used by interfaces to request for allow of up/down 20// used by interfaces to request for allow of up/down
21#define ACT_REQUEST 1 21#define ACT_REQUEST 1
22// regenerate config files 22// regenerate config files
23#define ACT_REGEN 2 23#define ACT_REGEN 2
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
32#include <opietooth2/Opietooth.h> 34#include <opietooth2/Opietooth.h>
33using namespace Opietooth2; 35using namespace Opietooth2;
34 36
35#include <qpushbutton.h> 37#include <qpushbutton.h>
36#include <qlayout.h> 38#include <qlayout.h>
37#include <qframe.h> 39#include <qframe.h>
38#include <qlabel.h> 40#include <qlabel.h>
39 41
40int main( int argc, char * argv[] ) { 42int main( int argc, char * argv[] ) {
41 int rv = 0; 43 int rv = 0;
42 int Action = ACT_GUI; 44 int Action = ACT_GUI;
43 // could be overruled by -qws 45 // could be overruled by -qws
44 QApplication::Type GuiType = QApplication::GuiClient; 46 QApplication::Type GuiType = QApplication::GuiClient;
45 47
46 QPEApplication * TheApp; 48 QPEApplication * TheApp;
47 49
48 for ( int i = 1; i < argc; i ++ ) { 50 for ( int i = 1; i < argc; i ++ ) {
49 int rmv; 51 int rmv;
50 rmv = 0; 52 rmv = 0;
51 if( strcmp( argv[i], "--regen" ) == 0 ) { 53 if( strcmp( argv[i], "--regen" ) == 0 ) {
52 Action = ACT_REGEN; 54 Action = ACT_REGEN;
53 GuiType = QApplication::Tty; 55 GuiType = QApplication::Tty;
54 rmv = 1; 56 rmv = 1;
55 } else if( strcmp( argv[i], "--prompt" ) == 0 ) { 57 } else if( strcmp( argv[i], "--prompt" ) == 0 ) {
56 Action = ACT_PROMPT; 58 Action = ACT_PROMPT;
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 ) {
62 Action = ACT_OT; 68 Action = ACT_OT;
63 rmv = 1; 69 rmv = 1;
64 } 70 }
65 if( rmv ) { 71 if( rmv ) {
66 memmove( argv+i, argv+i+rmv, 72 memmove( argv+i, argv+i+rmv,
67 sizeof( char * ) * (argc-i-rmv) ); 73 sizeof( char * ) * (argc-i-rmv) );
68 i --; 74 i --;
69 argc -= rmv; 75 argc -= rmv;
70 } 76 }
71 } 77 }
72 78
73 if( strstr( argv[0], "-request" ) ) { 79 if( strstr( argv[0], "-request" ) ) {
74 // called from system to request something 80 // called from system to request something
75 GuiType = QApplication::Tty; 81 GuiType = QApplication::Tty;
76 Action = ACT_REQUEST; 82 Action = ACT_REQUEST;
77 Log(("Request : %s\n", argv[1] )); 83 Log(("Request : %s\n", argv[1] ));
78 } else if( strstr( argv[0], "-opietooth" ) ) { 84 } else if( strstr( argv[0], "-opietooth" ) ) {
79 Action = ACT_OT; 85 Action = ACT_OT;
80 } 86 }
81 87
82 // Start Qt 88 // Start Qt
83 // because QPEApplication does not handle GuiType well 89 // because QPEApplication does not handle GuiType well
84 if( GuiType == QApplication::Tty ) { 90 if( GuiType == QApplication::Tty ) {
85 // this cast is NOT correct but we do not use 91 // this cast is NOT correct but we do not use
86 // TheApp anymore ... 92 // TheApp anymore ...
87 TheApp = (QPEApplication *)new QApplication( argc, argv, GuiType ); 93 TheApp = (QPEApplication *)new QApplication( argc, argv, GuiType );
88 } else { 94 } else {
89 TheApp = new QPEApplication( argc, argv, GuiType ); 95 TheApp = new QPEApplication( argc, argv, GuiType );
90 } 96 }
91 97
92 // init qt with app widget 98 // init qt with app widget
93 99
94 switch( Action ) { 100 switch( Action ) {
95 case ACT_REQUEST : 101 case ACT_REQUEST :
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 }
109 break; 124 break;
110 case ACT_REGEN : 125 case ACT_REGEN :
111 { NetworkSettingsData NS; 126 { NetworkSettingsData NS;
112 QString S= NS.generateSettings(); 127 QString S= NS.generateSettings();
113 // regen returns 0 if OK 128 // regen returns 0 if OK
114 rv = ( S.isEmpty() ) ? 0 : 1; 129 rv = ( S.isEmpty() ) ? 0 : 1;
115 } 130 }
116 break; 131 break;
117 case ACT_PROMPT : 132 case ACT_PROMPT :
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 }
133 break; 149 break;
134 case ACT_GUI : 150 case ACT_GUI :
135 case ACT_OT : 151 case ACT_OT :
136 { QWidget * W; 152 { QWidget * W;
137 153
138 if( Action == ACT_OT ) { 154 if( Action == ACT_OT ) {
139 W = new OTMain( 0 ); 155 W = new OTMain( 0 );
140 } else { 156 } else {
141 W = new NetworkSettings(0); 157 W = new NetworkSettings(0);
142 } 158 }
143 TheApp->setMainWidget( W ); 159 TheApp->setMainWidget( W );
144 160
145 W->show(); 161 W->show();
146 W->showMaximized(); 162 W->showMaximized();
147 rv = TheApp->exec(); 163 rv = TheApp->exec();
148 164
149 delete W; 165 delete W;
150 } 166 }
151 break; 167 break;
152 } 168 }
153 169
154 LogClose(); 170 LogClose();
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
@@ -95,74 +95,75 @@ QString ANetwork::acceptable( void ) {
95} 95}
96 96
97void ANetwork::commit( void ) { 97void ANetwork::commit( void ) {
98 if( GUI && GUI->commit( Data ) ) 98 if( GUI && GUI->commit( Data ) )
99 setModified( 1 ); 99 setModified( 1 );
100} 100}
101 101
102bool ANetwork::hasDataForFile( SystemFile & S ) { 102bool ANetwork::hasDataForFile( SystemFile & S ) {
103 return S.name() == "interfaces"; 103 return S.name() == "interfaces";
104} 104}
105 105
106short ANetwork::generateFile( SystemFile &SF, 106short ANetwork::generateFile( SystemFile &SF,
107 long DevNr 107 long DevNr
108 ) { 108 ) {
109 109
110 short rvl, rvd ; 110 short rvl, rvd ;
111 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); 111 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
112 112
113 rvl = 1; 113 rvl = 1;
114 if( SF.name() == "interfaces" ) { 114 if( SF.name() == "interfaces" ) {
115 Log(("Generate Network for %s\n", SF.name().latin1() )); 115 Log(("Generate Network for %s\n", SF.name().latin1() ));
116 // we can safely call from here since device item is deeper 116 // we can safely call from here since device item is deeper
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 \""
125 << NIC 125 << NIC
126 << "\" > /tmp/profile-" 126 << "\" > /tmp/profile-"
127 << connection()->number() 127 << connection()->number()
128 << ".up" 128 << ".up"
129 << endl; 129 << endl;
130 if( Data.SendHostname ) { 130 if( Data.SendHostname ) {
131 SF << " hostname " 131 SF << " hostname "
132 << Data.Hostname 132 << Data.Hostname
133 << endl; 133 << endl;
134 } 134 }
135 135
136 SF << " down rm -f /tmp/profile-" 136 SF << " down rm -f /tmp/profile-"
137 << connection()->number() 137 << connection()->number()
138 << ".up" 138 << ".up"
139 << endl; 139 << endl;
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 \""
147 << NIC 148 << NIC
148 << "\" > /tmp/profile-" 149 << "\" > /tmp/profile-"
149 << connection()->number() 150 << connection()->number()
150 << ".up" 151 << ".up"
151 << endl; 152 << endl;
152 SF << " down rm -f /tmp/profile-" 153 SF << " down rm -f /tmp/profile-"
153 << connection()->number() 154 << connection()->number()
154 << ".up" 155 << ".up"
155 << endl; 156 << endl;
156 SF << " address " 157 SF << " address "
157 << Data.IPAddress 158 << Data.IPAddress
158 << endl; 159 << endl;
159 SF << " broadcast " 160 SF << " broadcast "
160 << Data.Broadcast 161 << Data.Broadcast
161 << endl; 162 << endl;
162 SF << " netmask " 163 SF << " netmask "
163 << Data.NetMask 164 << Data.NetMask
164 << endl; 165 << endl;
165 166
166 // derive network address = IPAddress & netmask 167 // derive network address = IPAddress & netmask
167 { QString NW; 168 { QString NW;
168 QStringList ipal = QStringList::split( '.', Data.IPAddress ); 169 QStringList ipal = QStringList::split( '.', Data.IPAddress );
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
@@ -1,50 +1,51 @@
1#include <system.h> 1#include <system.h>
2#include <netnode.h> 2#include <netnode.h>
3#include <resources.h> 3#include <resources.h>
4#include "networkrun.h" 4#include "networkrun.h"
5 5
6State_t NetworkRun::detectState( void ) { 6State_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
12 return IsUp; 12 return IsUp;
13 } 13 }
14 14
15 // had no interface or interface is no longer up -> release 15 // had no interface or interface is no longer up -> release
16 nodeCollection()->assignInterface( 0 ); 16 nodeCollection()->assignInterface( 0 );
17 17
18 return Unknown; 18 return Unknown;
19} 19}
20 20
21QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) { 21QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
22 // we handle UP and DOWN 22 // we handle UP and DOWN
23 InterfaceInfo * II = NC->assignedInterface(); 23 InterfaceInfo * II = NC->assignedInterface();
24 24
25 if( ! II ) { 25 if( ! II ) {
26 Log(( "no interface assigned." )); 26 Log(( "no interface assigned." ));
27 return QString(); 27 return QString();
28 } 28 }
29 29
30 QStringList SL; 30 QStringList SL;
31 31
32 if( A == Up ) { 32 if( A == Up ) {
33 // we can bring UP if lower level is available 33 // we can bring UP if lower level is available
34 SL << "ifup"; 34 SL << "ifup";
35 } else if( A == Down ) { 35 } else if( A == Down ) {
36 SL << "ifdown"; 36 SL << "ifdown";
37 } else { 37 } else {
38 return QString(); 38 return QString();
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 ) ) {
46 return QString("Cannot call %1").arg(SL.join(" ")); 47 return QString("Cannot call %1").arg(SL.join(" "));
47 } 48 }
48 49
49 return QString(); 50 return QString();
50} 51}
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
@@ -226,48 +226,50 @@ QPixmap TheNSResources::getPixmap( const QString & QS ) {
226 QPixmap P; 226 QPixmap P;
227 QString S("networksettings2/"); 227 QString S("networksettings2/");
228 S += QS; 228 S += QS;
229 P = Resource::loadPixmap( S ); 229 P = Resource::loadPixmap( S );
230 if( P.isNull() ) { 230 if( P.isNull() ) {
231 Log(( "Cannot load %s\n", S.latin1() )); 231 Log(( "Cannot load %s\n", S.latin1() ));
232 } 232 }
233 return ( P.isNull() ) ? QPixmap() : P; 233 return ( P.isNull() ) ? QPixmap() : P;
234} 234}
235 235
236QString TheNSResources::tr( const char * s ) { 236QString TheNSResources::tr( const char * s ) {
237 return qApp->translate( "resource", s ); 237 return qApp->translate( "resource", s );
238} 238}
239 239
240const QString & TheNSResources::netNode2Name( const char * s ) { 240const QString & TheNSResources::netNode2Name( const char * s ) {
241 return NodeTypeNameMap[s]; 241 return NodeTypeNameMap[s];
242} 242}
243 243
244const QString & TheNSResources::netNode2Description( const char * s ) { 244const QString & TheNSResources::netNode2Description( const char * s ) {
245 return NodeTypeDescriptionMap[s]; 245 return NodeTypeDescriptionMap[s];
246} 246}
247 247
248void TheNSResources::addConnection( NodeCollection * NC, bool Dangling ) { 248void 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 );
252 } else { 254 } else {
253 ConnectionsMap.insert( NC->name(), NC ); 255 ConnectionsMap.insert( NC->name(), NC );
254 } 256 }
255 257
256 // add (new) nodes to NodeList 258 // add (new) nodes to NodeList
257 for( QListIterator<ANetNodeInstance> it(*NC); 259 for( QListIterator<ANetNodeInstance> it(*NC);
258 it.current(); 260 it.current();
259 ++it ) { 261 ++it ) {
260 NNI = it.current(); 262 NNI = it.current();
261 if( findNodeInstance( NNI->name() ) == 0 ) { 263 if( findNodeInstance( NNI->name() ) == 0 ) {
262 // new item 264 // new item
263 addNodeInstance( NNI ); 265 addNodeInstance( NNI );
264 } 266 }
265 } 267 }
266} 268}
267 269
268void TheNSResources::removeConnection( const QString & N ) { 270void TheNSResources::removeConnection( const QString & N ) {
269 NodeCollection * NC = findConnection( N ); 271 NodeCollection * NC = findConnection( N );
270 if( ! NC ) 272 if( ! NC )
271 return; 273 return;
272 274
273 // delete netnodes in this connection 275 // delete netnodes in this connection
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
@@ -89,49 +89,49 @@ public :
89 ANetNodeInstance * NNI = NN->createInstance(); 89 ANetNodeInstance * NNI = NN->createInstance();
90 NNI->initialize(); 90 NNI->initialize();
91 return NNI; 91 return NNI;
92 } 92 }
93 93
94 Name2Instance_t & netNodeInstances( void ) 94 Name2Instance_t & netNodeInstances( void )
95 { return AllNodes; } 95 { return AllNodes; }
96 void addNodeInstance( ANetNodeInstance * I ) 96 void addNodeInstance( ANetNodeInstance * I )
97 { AllNodes.insert( I->name(), I ); } 97 { AllNodes.insert( I->name(), I ); }
98 void removeNodeInstance( const QString & N ) 98 void removeNodeInstance( const QString & N )
99 { AllNodes.remove( N );} 99 { AllNodes.remove( N );}
100 ANetNodeInstance * findNodeInstance( const QString & S ) 100 ANetNodeInstance * findNodeInstance( const QString & S )
101 { return AllNodes[S]; } 101 { return AllNodes[S]; }
102 102
103 const QString & netNode2Name( const char * Type ); 103 const QString & netNode2Name( const char * Type );
104 const QString & netNode2Description( const char * Type ); 104 const QString & netNode2Description( const char * Type );
105 105
106 void addConnection( NodeCollection * NC, bool Dangling ); 106 void addConnection( NodeCollection * NC, bool Dangling );
107 void removeConnection( const QString & N ); 107 void removeConnection( const QString & N );
108 NodeCollection * findConnection( const QString & N ); 108 NodeCollection * findConnection( const QString & N );
109 NodeCollection * getConnection( int nr ); 109 NodeCollection * getConnection( int nr );
110 Name2Connection_t & connections( void ) 110 Name2Connection_t & connections( void )
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 )
116 { return CurrentUser.known(); } 116 { return CurrentUser.known(); }
117 CurrentQPEUser & currentUser( void ) 117 CurrentQPEUser & currentUser( void )
118 { return CurrentUser; } 118 { return CurrentUser; }
119 119
120private : 120private :
121 121
122 void detectCurrentUser( void ); 122 void detectCurrentUser( void );
123 QString tr( const char * path ); 123 QString tr( const char * path );
124 124
125 void findAvailableNetNodes( void ); 125 void findAvailableNetNodes( void );
126 126
127 QMap< QString, QString> NodeTypeNameMap; 127 QMap< QString, QString> NodeTypeNameMap;
128 QMap< QString, QString> NodeTypeDescriptionMap; 128 QMap< QString, QString> NodeTypeDescriptionMap;
129 // list of connections that are valid 129 // list of connections that are valid
130 Name2Connection_t ConnectionsMap; 130 Name2Connection_t ConnectionsMap;
131 // list of connection configurations that are not valid 131 // list of connection configurations that are not valid
132 // e.g. because plugins are missing 132 // e.g. because plugins are missing
133 Name2Connection_t DanglingConnectionsMap; 133 Name2Connection_t DanglingConnectionsMap;
134 System * TheSystem; 134 System * TheSystem;
135 Name2SystemFile_t SystemFiles; 135 Name2SystemFile_t SystemFiles;
136 136
137 // all node type classes 137 // all node type classes
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
@@ -42,49 +42,49 @@ static char Dig2Hex[] = {
42#define HN(x) Dig2Hex[(((x)&0xf0)>>4)] 42#define HN(x) Dig2Hex[(((x)&0xf0)>>4)]
43// get LOW nibble of byte 43// get LOW nibble of byte
44#define LN(x) Dig2Hex[((x)&0x0f)] 44#define LN(x) Dig2Hex[((x)&0x0f)]
45 45
46System::System( void ) : QObject(), ProbedInterfaces() { 46System::System( void ) : QObject(), ProbedInterfaces() {
47 ProcDevNet = 0; 47 ProcDevNet = 0;
48} 48}
49 49
50System::~System( void ) { 50System::~System( void ) {
51 if( ProcDevNet ) 51 if( ProcDevNet )
52 delete ProcDevNet; 52 delete ProcDevNet;
53} 53}
54 54
55QDict<InterfaceInfo> & System::interfaces( void ) { 55QDict<InterfaceInfo> & System::interfaces( void ) {
56 if( ProbedInterfaces.count() == 0 ) { 56 if( ProbedInterfaces.count() == 0 ) {
57 probeInterfaces(); 57 probeInterfaces();
58 } 58 }
59 return ProbedInterfaces; 59 return ProbedInterfaces;
60} 60}
61 61
62int System::runAsRoot( QStringList & S, MyProcess * Prc ) { 62int System::runAsRoot( QStringList & S, MyProcess * Prc ) {
63 char * usr = getenv("USER"); 63 char * usr = getenv("USER");
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 }
69 if( usr == 0 || strcmp( usr, "root" ) ) { 69 if( usr == 0 || strcmp( usr, "root" ) ) {
70 // unknown or non-root user -> use SUDO 70 // unknown or non-root user -> use SUDO
71 S.prepend( "sudo" ); 71 S.prepend( "sudo" );
72 } 72 }
73 73
74 if( getenv( "NS2TESTMODE" ) ) { 74 if( getenv( "NS2TESTMODE" ) ) {
75 odebug << "TESTMODE !!! execute " 75 odebug << "TESTMODE !!! execute "
76 << S.join( " ") 76 << S.join( " ")
77 << oendl; 77 << oendl;
78 } else { 78 } else {
79 MyProcess * P; 79 MyProcess * P;
80 80
81 if( Prc ) { 81 if( Prc ) {
82 P = Prc; 82 P = Prc;
83 } else { 83 } else {
84 P = new MyProcess(); 84 P = new MyProcess();
85 emit processEvent( tr("Command : ") + S.join( " " ) ); 85 emit processEvent( tr("Command : ") + S.join( " " ) );
86 86
87 connect( P, 87 connect( P,
88 SIGNAL( stdoutLine( const QString & ) ), 88 SIGNAL( stdoutLine( const QString & ) ),
89 this, 89 this,
90 SIGNAL( stdoutLine( const QString & ) ) ); 90 SIGNAL( stdoutLine( const QString & ) ) );
@@ -98,92 +98,98 @@ int System::runAsRoot( QStringList & S, MyProcess * Prc ) {
98 SIGNAL(processExited(MyProcess*) ), 98 SIGNAL(processExited(MyProcess*) ),
99 this, SLOT 99 this, SLOT
100 (SLOT_ProcessExited(MyProcess*) ) ); 100 (SLOT_ProcessExited(MyProcess*) ) );
101 } 101 }
102 102
103 P->process() << S; 103 P->process() << S;
104 104
105 Log(("Executing %s\n", S.join( " " ).latin1() )); 105 Log(("Executing %s\n", S.join( " " ).latin1() ));
106 106
107 if( ! P->process().start( OProcess::DontCare, 107 if( ! P->process().start( OProcess::DontCare,
108 OProcess::AllOutput ) ) { 108 OProcess::AllOutput ) ) {
109 odebug << "Error starting " << S << oendl; 109 odebug << "Error starting " << S << oendl;
110 if( ! Prc ) 110 if( ! Prc )
111 delete P; 111 delete P;
112 // error starting app 112 // error starting app
113 return 0; 113 return 0;
114 } 114 }
115 odebug << "Started " << S << oendl; 115 odebug << "Started " << S << oendl;
116 } 116 }
117 117
118 // all is fine 118 // all is fine
119 return 1; 119 return 1;
120} 120}
121 121
122int System::execAsUser( QStringList & SL ) { 122int 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() ) {
130 // if we come here, the exec was not successfull 131 // if we come here, the exec was not successfull
131 Log(("User not known \n" )); 132 Log(("User not known \n" ));
132 return 0; 133 return 0;
133 } 134 }
134 } 135 }
135 136
136 // now we are ready to exec the requested command 137 // now we are ready to exec the requested command
137 setuid( CU.Uid ); 138 setuid( CU.Uid );
138 setgid( CU.Gid ); 139 setgid( CU.Gid );
139 140
140 for( unsigned int i = 0 ; i < CU.EnvList.count() ; i ++ ) { 141 for( unsigned int i = 0 ; i < CU.EnvList.count() ; i ++ ) {
141 QString X; 142 QString X;
142 QStringList SL; 143 QStringList SL;
143 X = CU.EnvList[i]; 144 X = CU.EnvList[i];
144 SL = QStringList::split( "=", X ); 145 SL = QStringList::split( "=", X );
145 P->process().setEnvironment( SL[0], SL[1] ); 146 P->process().setEnvironment( SL[0], SL[1] );
146 } 147 }
147 148
148 P->process() << SL; 149 P->process() << SL;
149 150
150 emit processEvent( tr("Command : ") + SL.join( " " ) ); 151 emit processEvent( tr("Command : ") + SL.join( " " ) );
151 152
152 Log(("Executing as user %s : %s\n", 153 Log(("Executing as user %s : %s\n",
153 CU.UserName.latin1(), 154 CU.UserName.latin1(),
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
168void System::SLOT_ProcessExited( MyProcess * P ) { 174void System::SLOT_ProcessExited( MyProcess * P ) {
169 QString R; 175 QString R;
170 176
171 for( QValueListConstIterator<QCString> it = P->process().args().begin(); 177 for( QValueListConstIterator<QCString> it = P->process().args().begin();
172 it != P->process().args().end(); 178 it != P->process().args().end();
173 ++it ) { 179 ++it ) {
174 R += (*it); 180 R += (*it);
175 R += " "; 181 R += " ";
176 } 182 }
177 183
178 R += "Returned with " + QString().setNum( P->process().exitStatus() ); 184 R += "Returned with " + QString().setNum( P->process().exitStatus() );
179 emit processEvent( R ); 185 emit processEvent( R );
180 delete P; 186 delete P;
181} 187}
182 188
183void System::refreshStatistics( InterfaceInfo & I ) { 189void System::refreshStatistics( InterfaceInfo & I ) {
184 if( ! ProcDevNet ) { 190 if( ! ProcDevNet ) {
185 return; 191 return;
186 } 192 }
187 // cannot seek on dev 193 // cannot seek on dev
188 ProcDevNet->close(); 194 ProcDevNet->close();
189 ProcDevNet->open( IO_ReadOnly ); 195 ProcDevNet->open( IO_ReadOnly );
@@ -520,68 +526,78 @@ QString removeSpaces( const QString & X ) {
520// 526//
521 527
522MyProcess::MyProcess() : QObject(), StdoutBuffer(), StderrBuffer() { 528MyProcess::MyProcess() : QObject(), StdoutBuffer(), StderrBuffer() {
523 P = new OProcess(); 529 P = new OProcess();
524 connect( P, 530 connect( P,
525 SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int ) ), 531 SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int ) ),
526 this, 532 this,
527 SLOT( SLOT_Stdout(Opie::Core::OProcess*,char*,int) ) ); 533 SLOT( SLOT_Stdout(Opie::Core::OProcess*,char*,int) ) );
528 534
529 connect( P, 535 connect( P,
530 SIGNAL( receivedStderr(Opie::Core::OProcess*, char*, int ) ), 536 SIGNAL( receivedStderr(Opie::Core::OProcess*, char*, int ) ),
531 this, 537 this,
532 SLOT( SLOT_Stderr(Opie::Core::OProcess*,char*,int) ) ); 538 SLOT( SLOT_Stderr(Opie::Core::OProcess*,char*,int) ) );
533 connect( P, 539 connect( P,
534 SIGNAL( processExited(Opie::Core::OProcess*) ), 540 SIGNAL( processExited(Opie::Core::OProcess*) ),
535 this, 541 this,
536 SLOT( SLOT_ProcessExited(Opie::Core::OProcess*) ) ); 542 SLOT( SLOT_ProcessExited(Opie::Core::OProcess*) ) );
537} 543}
538 544
539MyProcess::~MyProcess() { 545MyProcess::~MyProcess() {
540 delete P; 546 delete P;
541} 547}
542 548
543void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) { 549void 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 );
546 LB[len] = '\0'; 557 LB[len] = '\0';
547 558
548 // now input is zero terminated 559 // now input is zero terminated
549 StdoutBuffer += LB; 560 StdoutBuffer += LB;
550 561
551 odebug << "Received " << len << " bytes on stdout" << oendl; 562 odebug << "Received " << len << " bytes on stdout" << oendl;
552 // see if we have some lines (allow empty lines) 563 // see if we have some lines (allow empty lines)
553 QStringList SL = QStringList::split( "\n", StdoutBuffer, TRUE ); 564 QStringList SL = QStringList::split( "\n", StdoutBuffer, TRUE );
554 565
555 for( unsigned int i = 0; i < SL.count()-1; i ++ ) { 566 for( unsigned int i = 0; i < SL.count()-1; i ++ ) {
556 Log(( "Stdout : \"%s\"\n", SL[i].latin1() ) ); 567 Log(( "Stdout : \"%s\"\n", SL[i].latin1() ) );
557 emit stdoutLine( SL[i] ); 568 emit stdoutLine( SL[i] );
558 } 569 }
559 570
560 // last line is rest 571 // last line is rest
561 StdoutBuffer = SL[ SL.count()-1 ]; 572 StdoutBuffer = SL[ SL.count()-1 ];
562} 573}
563 574
564void MyProcess::SLOT_Stderr( Opie::Core::OProcess * , char * Buf, int len ) { 575void 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 );
567 LB[len] = '\0'; 583 LB[len] = '\0';
568 584
569 // now input is zero terminated 585 // now input is zero terminated
570 StderrBuffer += LB; 586 StderrBuffer += LB;
571 587
572 odebug << "Received " << len << " bytes on stderr" << oendl; 588 odebug << "Received " << len << " bytes on stderr" << oendl;
573 // see if we have some lines (allow empty lines) 589 // see if we have some lines (allow empty lines)
574 QStringList SL = QStringList::split( "\n", StderrBuffer, TRUE ); 590 QStringList SL = QStringList::split( "\n", StderrBuffer, TRUE );
575 591
576 for( unsigned int i = 0; i < SL.count()-1; i ++ ) { 592 for( unsigned int i = 0; i < SL.count()-1; i ++ ) {
577 Log(( "Stderr : \"%s\"\n", SL[i].latin1() ) ); 593 Log(( "Stderr : \"%s\"\n", SL[i].latin1() ) );
578 emit stderrLine( SL[i] ); 594 emit stderrLine( SL[i] );
579 } 595 }
580 596
581 // last line is rest 597 // last line is rest
582 StderrBuffer = SL[ SL.count()-1 ]; 598 StderrBuffer = SL[ SL.count()-1 ];
583} 599}
584 600
585void MyProcess::SLOT_ProcessExited( Opie::Core::OProcess * ) { 601void MyProcess::SLOT_ProcessExited( Opie::Core::OProcess * ) {
586 emit processExited( this ); 602 emit processExited( this );
587} 603}
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
@@ -8,65 +8,71 @@
8using namespace Opie::Core; 8using namespace Opie::Core;
9 9
10// for hardware types 10// for hardware types
11#include <net/if_arp.h> 11#include <net/if_arp.h>
12#include <qdict.h> 12#include <qdict.h>
13#include <qobject.h> 13#include <qobject.h>
14#include <stdio.h> 14#include <stdio.h>
15 15
16class NodeCollection; 16class NodeCollection;
17class ANetNodeInstance; 17class ANetNodeInstance;
18class QFile; 18class QFile;
19 19
20class MyProcess : public QObject { 20class MyProcess : public QObject {
21 21
22 Q_OBJECT 22 Q_OBJECT
23 23
24public : 24public :
25 25
26 MyProcess(); 26 MyProcess();
27 ~MyProcess(); 27 ~MyProcess();
28 28
29 inline OProcess & process() 29 inline OProcess & process()
30 { return *P; } 30 { return *P; }
31 31
32 inline void setEchoMode( bool M ) {
33 EchoMode = M;
34 }
35
32public slots : 36public slots :
33 37
34 void SLOT_Stdout( Opie::Core::OProcess * P, char *, int ); 38 void SLOT_Stdout( Opie::Core::OProcess * P, char *, int );
35 void SLOT_Stderr( Opie::Core::OProcess * P, char *, int ); 39 void SLOT_Stderr( Opie::Core::OProcess * P, char *, int );
36 void SLOT_ProcessExited( Opie::Core::OProcess * P); 40 void SLOT_ProcessExited( Opie::Core::OProcess * P);
37 41
38signals : 42signals :
39 43
40 void stdoutLine( const QString & ); 44 void stdoutLine( const QString & );
41 void stderrLine( const QString & ); 45 void stderrLine( const QString & );
42 void processExited( MyProcess * ); 46 void processExited( MyProcess * );
43 47
44private : 48private :
45 49
46 QString StdoutBuffer; 50 QString StdoutBuffer;
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
51class InterfaceInfo { 57class InterfaceInfo {
52 58
53public : 59public :
54 60
55 InterfaceInfo() : 61 InterfaceInfo() :
56 Name(), 62 Name(),
57 MACAddress(), 63 MACAddress(),
58 BCastAddress(), 64 BCastAddress(),
59 Netmask(), 65 Netmask(),
60 DstAddress() { 66 DstAddress() {
61 } 67 }
62 68
63 NodeCollection * assignedConnection() 69 NodeCollection * assignedConnection()
64 { return Collection; } 70 { return Collection; }
65 71
66 void assignConnection( NodeCollection * NNI ) 72 void assignConnection( NodeCollection * NNI )
67 { Collection = NNI; } 73 { Collection = NNI; }
68 74
69 NodeCollection * Collection; // connection taking care of me 75 NodeCollection * Collection; // connection taking care of me
70 QString Name; // name of interface 76 QString Name; // name of interface
71 int CardType; // type of card 77 int CardType; // type of card
72 QString MACAddress; // MAC address 78 QString MACAddress; // MAC address
@@ -83,49 +89,49 @@ public :
83 QString RcvErrors; 89 QString RcvErrors;
84 QString SndErrors; 90 QString SndErrors;
85 QString RcvDropped; 91 QString RcvDropped;
86 QString SndDropped; 92 QString SndDropped;
87 QString Collisions; 93 QString Collisions;
88}; 94};
89 95
90class System : public QObject { 96class System : public QObject {
91 97
92 Q_OBJECT 98 Q_OBJECT
93 99
94public : 100public :
95 101
96 System( void ); 102 System( void );
97 ~System( void ); 103 ~System( void );
98 104
99 QDict<InterfaceInfo> & interfaces( void ); 105 QDict<InterfaceInfo> & interfaces( void );
100 InterfaceInfo * interface( const QString& N ) 106 InterfaceInfo * interface( const QString& N )
101 { return interfaces()[N]; } 107 { return interfaces()[N]; }
102 108
103 // exec command as root 109 // exec command as root
104 int runAsRoot( QStringList & S, MyProcess * Prc = 0 ); 110 int runAsRoot( QStringList & S, MyProcess * Prc = 0 );
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
110 void refreshStatistics( InterfaceInfo & ); 116 void refreshStatistics( InterfaceInfo & );
111 117
112 // reloads interfaces 118 // reloads interfaces
113 void probeInterfaces( void ); 119 void probeInterfaces( void );
114 120
115 InterfaceInfo * findInterface( const QString & DevName ); 121 InterfaceInfo * findInterface( const QString & DevName );
116 122
117private slots : 123private slots :
118 124
119 void SLOT_ProcessExited( MyProcess * ); 125 void SLOT_ProcessExited( MyProcess * );
120 126
121signals : 127signals :
122 128
123 void stdoutLine( const QString & ); 129 void stdoutLine( const QString & );
124 void stderrLine( const QString & ); 130 void stderrLine( const QString & );
125 void processEvent( const QString & ); 131 void processEvent( const QString & );
126 132
127private : 133private :
128 134
129 QDict<InterfaceInfo> ProbedInterfaces; 135 QDict<InterfaceInfo> ProbedInterfaces;
130 FILE * OutputOfCmd; 136 FILE * OutputOfCmd;
131 QFile * ProcDevNet; 137 QFile * ProcDevNet;
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
@@ -115,49 +115,48 @@ bool SystemFile::open( void ) {
115 } 115 }
116 } 116 }
117 setDevice( F ); 117 setDevice( F );
118 return 1; 118 return 1;
119} 119}
120 120
121bool SystemFile::close( void ) { 121bool SystemFile::close( void ) {
122 if( ! F || ! F->isOpen() ) { 122 if( ! F || ! F->isOpen() ) {
123 return 1 ; 123 return 1 ;
124 } 124 }
125 125
126 QString Prefix = getenv( "NS2OUTPUTTO" ); 126 QString Prefix = getenv( "NS2OUTPUTTO" );
127 127
128 if( Prefix == "stderr" ) { 128 if( Prefix == "stderr" ) {
129 return 1; 129 return 1;
130 } 130 }
131 131
132 QString OldP = Prefix + Path + "bup"; 132 QString OldP = Prefix + Path + "bup";
133 133
134 F->close(); 134 F->close();
135 delete F; 135 delete F;
136 F = 0; 136 F = 0;
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 }
142 return 1; 141 return 1;
143} 142}
144 143
145bool SystemFile::preSection( void ) { 144bool SystemFile::preSection( void ) {
146 if( hasPreSection ) { 145 if( hasPreSection ) {
147 QFile Fl( TemplDir + Name + "/presection" ); 146 QFile Fl( TemplDir + Name + "/presection" );
148 if( ! Fl.open( IO_ReadOnly ) ) 147 if( ! Fl.open( IO_ReadOnly ) )
149 return 0; // error 148 return 0; // error
150 // copy file to this file 149 // copy file to this file
151 F->writeBlock( Fl.readAll() ); 150 F->writeBlock( Fl.readAll() );
152 } 151 }
153 return 1; 152 return 1;
154} 153}
155 154
156bool SystemFile::postSection( void ) { 155bool SystemFile::postSection( void ) {
157 if( hasPostSection ) { 156 if( hasPostSection ) {
158 QFile Fl( TemplDir + Name + "/postsection" ); 157 QFile Fl( TemplDir + Name + "/postsection" );
159 if( ! Fl.open( IO_ReadOnly ) ) 158 if( ! Fl.open( IO_ReadOnly ) )
160 return 0; // error 159 return 0; // error
161 // copy file to this file 160 // copy file to this file
162 F->writeBlock( Fl.readAll() ); 161 F->writeBlock( Fl.readAll() );
163 } 162 }
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
@@ -40,48 +40,50 @@ NetworkSettingsData::NetworkSettingsData( void ) {
40 QStringList SL = D.entryList( "profile-*.up"); 40 QStringList SL = D.entryList( "profile-*.up");
41 41
42 Log(( "System reports %d interfaces. Found %d up\n", 42 Log(( "System reports %d interfaces. Found %d up\n",
43 NSResources->system().interfaces().count(), 43 NSResources->system().interfaces().count(),
44 SL.count() )); 44 SL.count() ));
45 45
46 for ( QStringList::Iterator it = SL.begin(); 46 for ( QStringList::Iterator it = SL.begin();
47 it != SL.end(); 47 it != SL.end();
48 ++it ) { 48 ++it ) {
49 profilenr = atol( (*it).mid( 8 ).latin1() ); 49 profilenr = atol( (*it).mid( 8 ).latin1() );
50 // read the interface store int 'up' 50 // read the interface store int 'up'
51 F->setName( D.path() + "/" + (*it) ); 51 F->setName( D.path() + "/" + (*it) );
52 if( F->open( IO_ReadOnly ) ) { 52 if( F->open( IO_ReadOnly ) ) {
53 NodeCollection * NC; 53 NodeCollection * NC;
54 interfacename = TS.readLine(); 54 interfacename = TS.readLine();
55 F->close(); 55 F->close();
56 56
57 Log(( "Assign interface %s to Profile nr %d\n", 57 Log(( "Assign interface %s to Profile nr %d\n",
58 interfacename.latin1(), profilenr )); 58 interfacename.latin1(), profilenr ));
59 59
60 NC = NSResources->getConnection( profilenr ); 60 NC = NSResources->getConnection( profilenr );
61 if( NC ) { 61 if( NC ) {
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",
66 profilenr )); 68 profilenr ));
67 } 69 }
68 } 70 }
69 } 71 }
70 } 72 }
71} 73}
72 74
73// saving is done by caller 75// saving is done by caller
74NetworkSettingsData::~NetworkSettingsData( void ) { 76NetworkSettingsData::~NetworkSettingsData( void ) {
75 delete NSResources; 77 delete NSResources;
76} 78}
77 79
78void NetworkSettingsData::loadSettings( void ) { 80void NetworkSettingsData::loadSettings( void ) {
79 QString Line, S; 81 QString Line, S;
80 QString Attr, Value; 82 QString Attr, Value;
81 long idx; 83 long idx;
82 84
83 QFile F( CfgFile ); 85 QFile F( CfgFile );
84 QTextStream TS( &F ); 86 QTextStream TS( &F );
85 87
86 ForceModified = 0; 88 ForceModified = 0;
87 89
@@ -622,122 +624,164 @@ QString NetworkSettingsData::generateSettings( void ) {
622 } 624 }
623 625
624 if( ! SF->postDeviceSection( CurDevNN ) ) { 626 if( ! SF->postDeviceSection( CurDevNN ) ) {
625 S = qApp->translate( "NetworkSettings", 627 S = qApp->translate( "NetworkSettings",
626 "<p>Error in section \"Post-Device\" for file \"%1\" and node \"%2\"</p>" ). 628 "<p>Error in section \"Post-Device\" for file \"%1\" and node \"%2\"</p>" ).
627 arg( SF->name() ). 629 arg( SF->name() ).
628 arg( CurDevNN->name() ); 630 arg( CurDevNN->name() );
629 return S; 631 return S;
630 } 632 }
631 633
632 634
633 if( ! SF->postSection() ) { 635 if( ! SF->postSection() ) {
634 S = qApp->translate( "NetworkSettings", 636 S = qApp->translate( "NetworkSettings",
635 "<p>Error in section \"Closure\" for file \"%1\"</p>" ). 637 "<p>Error in section \"Closure\" for file \"%1\"</p>" ).
636 arg( SF->name() ); 638 arg( SF->name() );
637 return S; 639 return S;
638 } 640 }
639 641
640 // end of file 642 // end of file
641 SF->close(); 643 SF->close();
642 } 644 }
643 return S; 645 return S;
644} 646}
645 647
646QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) { 648QList<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;
649 QList<NodeCollection> PossibleConnections; 652 QList<NodeCollection> PossibleConnections;
650 Name2Connection_t & M = NSResources->connections(); 653 Name2Connection_t & M = NSResources->connections();
651 654
652 // for all connections 655 // for all connections
653 for( QDictIterator<NodeCollection> it(M); 656 for( QDictIterator<NodeCollection> it(M);
654 it.current(); 657 it.current();
655 ++it ) { 658 ++it ) {
656 NC = it.current(); 659 NC = it.current();
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 }
665 } 669 }
666 return PossibleConnections; 670 return PossibleConnections;
667} 671}
668 672
669 673
670/* 674/*
671 Called by the system to see if interface can be brought UP 675 Called by the system to see if interface can be brought UP
672 676
673 if allowed, echo Interface-allowed else Interface-disallowed 677 if allowed, echo Interface-allowed else Interface-disallowed
674*/ 678*/
675 679
676bool NetworkSettingsData::canStart( const char * Interface ) { 680bool NetworkSettingsData::canStart( const QString & Interface ) {
677 // load situation 681 // load situation
678 NodeCollection * NC = 0; 682 NodeCollection * NC = 0;
679 QList<NodeCollection> PossibleConnections; 683 QList<NodeCollection> PossibleConnections;
680 684
681 PossibleConnections = collectPossible( Interface ); 685 PossibleConnections = collectPossible( 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
687 break; 691 break;
688 case 1 : // one connection 692 case 1 : // one connection
689 NC = PossibleConnections.first(); 693 NC = PossibleConnections.first();
690 break; 694 break;
691 default : // need to ask user ? 695 default : // need to ask user ?
692 return 1; 696 return 1;
693 } 697 }
694 698
695 if( NC ) { 699 if( NC ) {
696 switch( NC->state() ) { 700 switch( NC->state() ) {
697 case Unchecked : 701 case Unchecked :
698 case Unknown : 702 case Unknown :
699 case Unavailable : 703 case Unavailable :
700 case Disabled : 704 case Disabled :
701 // this profile does not allow interface to be UP 705 // this profile does not allow interface to be UP
702 // -> try others 706 // -> try others
703 break; 707 break;
704 case Off : 708 case Off :
705 // try to UP the device 709 // try to UP the device
706 { QString S= NC->setState( Activate ); 710 { QString S= NC->setState( Activate );
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 }
713 // interface assigned 717 // interface assigned
714 } 718 }
715 // FT 719 // FT
716 case Available : 720 case Available :
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 }
723 } 727 }
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}
730 734
731bool NetworkSettingsData::isModified( void ) { 735bool NetworkSettingsData::isModified( void ) {
732 if( ForceModified ) 736 if( ForceModified )
733 return 1; 737 return 1;
734 738
735 for( QDictIterator<NodeCollection> it(NSResources->connections()); 739 for( QDictIterator<NodeCollection> it(NSResources->connections());
736 it.current(); 740 it.current();
737 ++it ) { 741 ++it ) {
738 if( it.current()->isModified() ) { 742 if( it.current()->isModified() ) {
739 return 1; 743 return 1;
740 } 744 }
741 } 745 }
742 return 0; 746 return 0;
743} 747}
748
749bool 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
761QList<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
@@ -1,34 +1,38 @@
1#ifndef __NSDATA_H 1#ifndef __NSDATA_H
2#define __NSDATA_H 2#define __NSDATA_H
3 3
4#include <netnode.h> 4#include <netnode.h>
5 5
6class NetworkSettingsData { 6class NetworkSettingsData {
7 7
8public : 8public :
9 9
10 NetworkSettingsData( void ); 10 NetworkSettingsData( void );
11 ~NetworkSettingsData( void ); 11 ~NetworkSettingsData( void );
12 12
13 void loadSettings( void ); 13 void loadSettings( void );
14 QString saveSettings( void ); 14 QString saveSettings( void );
15 15
16 QString generateSettings( void ); 16 QString generateSettings( void );
17 17
18 bool isModified( void ); 18 bool isModified( void );
19 inline void setModified( bool M ) 19 inline void setModified( bool M )
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
26private : 29private :
27 30
31 QList<NodeCollection> collectTriggered( const QString &Interface );
28 bool ForceModified; 32 bool ForceModified;
29 33
30 // collect strings in config file nobody wants 34 // collect strings in config file nobody wants
31 QStringList LeftOvers; 35 QStringList LeftOvers;
32}; 36};
33 37
34#endif 38#endif
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,24 +1,25 @@
1#include <qpe/qpeapplication.h>
1#include <opie2/odebug.h> 2#include <opie2/odebug.h>
2#include "profileedit.h" 3#include "profileedit.h"
3#include "profile_NNI.h" 4#include "profile_NNI.h"
4#include "profile_NN.h" 5#include "profile_NN.h"
5 6
6AProfile::AProfile( ProfileNetNode * PNN ) : ANetNodeInstance( PNN ) { 7AProfile::AProfile( ProfileNetNode * PNN ) : ANetNodeInstance( PNN ) {
7 Data.Automatic = 1; 8 Data.Automatic = 1;
8 Data.Confirm = 0; 9 Data.Confirm = 0;
9 Data.Description = ""; 10 Data.Description = "";
10 Data.Disabled = 0; 11 Data.Disabled = 0;
11 Data.TriggerVPN = 0; 12 Data.TriggerVPN = 0;
12 GUI = 0; 13 GUI = 0;
13 RT = 0; 14 RT = 0;
14} 15}
15 16
16void AProfile::setSpecificAttribute( QString & Attr, QString & Value ) { 17void AProfile::setSpecificAttribute( QString & Attr, QString & Value ) {
17 18
18 if ( Attr == "automatic" ) { 19 if ( Attr == "automatic" ) {
19 Data.Automatic = (Value=="yes"); 20 Data.Automatic = (Value=="yes");
20 } else if ( Attr == "preconfirm" ) { 21 } else if ( Attr == "preconfirm" ) {
21 Data.Confirm = (Value=="yes"); 22 Data.Confirm = (Value=="yes");
22 } else if ( Attr == "disabled" ) { 23 } else if ( Attr == "disabled" ) {
23 Data.Disabled = (Value=="yes"); 24 Data.Disabled = (Value=="yes");
24 } else if ( Attr == "triggervpn" ) { 25 } else if ( Attr == "triggervpn" ) {
@@ -41,36 +42,40 @@ QWidget * AProfile::edit( QWidget * parent ) {
41 GUI->showData( Data ); 42 GUI->showData( Data );
42 return GUI; 43 return GUI;
43} 44}
44 45
45QString AProfile::acceptable( void ) { 46QString AProfile::acceptable( void ) {
46 return ( GUI ) ? GUI->acceptable( ) : QString(); 47 return ( GUI ) ? GUI->acceptable( ) : QString();
47} 48}
48 49
49void AProfile::commit( void ) { 50void AProfile::commit( void ) {
50 if( GUI && GUI->commit( Data ) ) 51 if( GUI && GUI->commit( Data ) )
51 setModified( 1 ); 52 setModified( 1 );
52} 53}
53 54
54short AProfile::generateFileEmbedded( SystemFile & SF, 55short AProfile::generateFileEmbedded( SystemFile & SF,
55 long DevNr ) { 56 long DevNr ) {
56 57
57 short rvl, rvd; 58 short rvl, rvd;
58 59
59 rvl = 1; 60 rvl = 1;
60 61
61 if( SF.name() == "interfaces" ) { 62 if( SF.name() == "interfaces" ) {
62 Log(("Generate Profile for %s\n", SF.name().latin1() )); 63 Log(("Generate Profile for %s\n", SF.name().latin1() ));
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;
68 } 73 }
69 } 74 }
70 rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr ); 75 rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr );
71 return (rvd == 2 || rvl == 2 ) ? 2 : 76 return (rvd == 2 || rvl == 2 ) ? 2 :
72 (rvd == 0 || rvl == 0 ) ? 0 : 1; 77 (rvd == 0 || rvl == 0 ) ? 0 : 1;
73} 78}
74 79
75 80
76 81