29 files changed, 818 insertions, 300 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth.pro b/noncore/settings/networksettings2/bluetooth/bluetooth.pro index 180bda9..2e1e138 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth.pro +++ b/noncore/settings/networksettings2/bluetooth/bluetooth.pro | |||
@@ -10,6 +10,7 @@ SOURCES = bluetooth_NN.cpp \ | |||
10 | bluetoothBNEP_NNI.cpp \ | 10 | bluetoothBNEP_NNI.cpp \ |
11 | bluetoothRFCOMM_NNI.cpp \ | 11 | bluetoothRFCOMM_NNI.cpp \ |
12 | bluetoothBNEPedit.cpp \ | 12 | bluetoothBNEPedit.cpp \ |
13 | bluetoothBNEPrun.cpp \ | ||
13 | bluetoothRFCOMMedit.cpp | 14 | bluetoothRFCOMMedit.cpp |
14 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../networksettings2 | 15 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../networksettings2 |
15 | DEPENDPATH+= $(OPIEDIR)/include ../ ../networksettings2 | 16 | DEPENDPATH+= $(OPIEDIR)/include ../ ../networksettings2 |
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp index 73312c6..d8420b9 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp | |||
@@ -2,21 +2,34 @@ | |||
2 | #include "bluetoothBNEP_NNI.h" | 2 | #include "bluetoothBNEP_NNI.h" |
3 | #include "bluetooth_NN.h" | 3 | #include "bluetooth_NN.h" |
4 | 4 | ||
5 | ABluetoothBNEP::ABluetoothBNEP( BluetoothBNEPNetNode * PNN ) : ANetNodeInstance( PNN ) { | 5 | ABluetoothBNEP::ABluetoothBNEP( BluetoothBNEPNetNode * PNN ) : |
6 | ANetNodeInstance( PNN ), Data() { | ||
6 | GUI = 0; | 7 | GUI = 0; |
7 | RT = 0; | 8 | RT = 0; |
9 | Data.AllowAll = 1; | ||
8 | } | 10 | } |
9 | 11 | ||
10 | void ABluetoothBNEP::setSpecificAttribute( QString & , QString & ) { | 12 | void ABluetoothBNEP::setSpecificAttribute( QString & S, QString & A ) { |
13 | if( S == "bdaddress" ) { | ||
14 | Data.BDAddress << A; | ||
15 | } else if ( S == "allowall" ) { | ||
16 | Data.AllowAll = 1; | ||
17 | } | ||
11 | } | 18 | } |
12 | 19 | ||
13 | void ABluetoothBNEP::saveSpecificAttribute( QTextStream & ) { | 20 | void ABluetoothBNEP::saveSpecificAttribute( QTextStream & TS ) { |
21 | TS << "allowall=" << Data.AllowAll << endl; | ||
22 | for ( QStringList::Iterator it = Data.BDAddress.begin(); | ||
23 | it != Data.BDAddress.end(); | ||
24 | ++it ) { | ||
25 | TS << "bdaddress=" << (*it) << endl; | ||
26 | } | ||
14 | } | 27 | } |
15 | 28 | ||
16 | QWidget * ABluetoothBNEP::edit( QWidget * parent ) { | 29 | QWidget * ABluetoothBNEP::edit( QWidget * parent ) { |
17 | GUI = new BluetoothBNEPEdit( parent ); | 30 | GUI = new BluetoothBNEPEdit( parent ); |
18 | GUI->showData( Data ); | 31 | GUI->showData( Data ); |
19 | return GUI; | 32 | return GUI; |
20 | } | 33 | } |
21 | 34 | ||
22 | QString ABluetoothBNEP::acceptable( void ) { | 35 | QString ABluetoothBNEP::acceptable( void ) { |
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h index 037b7b1..03c6903 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h | |||
@@ -1,8 +1,11 @@ | |||
1 | #ifndef BLUETOOTHBNEP_DATA_H | 1 | #ifndef BLUETOOTHBNEP_DATA_H |
2 | #define BLUETOOTHBNEP_DATA_H | 2 | #define BLUETOOTHBNEP_DATA_H |
3 | 3 | ||
4 | #include <qstringlist.h> | ||
5 | |||
4 | typedef struct BluetoothBNEPData { | 6 | typedef struct BluetoothBNEPData { |
5 | long x; | 7 | bool AllowAll; |
8 | QStringList BDAddress; | ||
6 | } BluetoothBNEPData_t; | 9 | } BluetoothBNEPData_t; |
7 | 10 | ||
8 | #endif | 11 | #endif |
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.cpp index 9a3156b..195dbae 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPedit.cpp | |||
@@ -1,4 +1,6 @@ | |||
1 | #include <qtopia/qcopenvelope_qws.h> | 1 | #include <qtopia/qcopenvelope_qws.h> |
2 | #include <qlistview.h> | ||
3 | #include <qcheckbox.h> | ||
2 | 4 | ||
3 | #include <GUIUtils.h> | 5 | #include <GUIUtils.h> |
4 | #include "bluetoothBNEPedit.h" | 6 | #include "bluetoothBNEPedit.h" |
@@ -9,14 +11,34 @@ BluetoothBNEPEdit::BluetoothBNEPEdit( QWidget * Parent ) : BluetoothBNEPGUI( Par | |||
9 | } | 11 | } |
10 | 12 | ||
11 | QString BluetoothBNEPEdit::acceptable( void ) { | 13 | QString BluetoothBNEPEdit::acceptable( void ) { |
14 | if( ( ! AnyPAN_CB->isChecked() ) && | ||
15 | BTPANServers_LV->firstChild() == 0 ) { | ||
16 | return tr("<p>No bluetooth device addresses specified</p>"); | ||
17 | } | ||
18 | |||
12 | return QString(); | 19 | return QString(); |
13 | } | 20 | } |
14 | 21 | ||
15 | bool BluetoothBNEPEdit::commit( BluetoothBNEPData & ) { | 22 | bool BluetoothBNEPEdit::commit( BluetoothBNEPData & Data ) { |
16 | return 0; | 23 | QListViewItem * it = BTPANServers_LV->firstChild(); |
24 | Data.BDAddress.clear(); | ||
25 | while( it ) { | ||
26 | Data.BDAddress << it->text(0); | ||
27 | it = it->nextSibling(); | ||
28 | } | ||
29 | return 0; | ||
17 | } | 30 | } |
18 | 31 | ||
19 | void BluetoothBNEPEdit::showData( BluetoothBNEPData & ) { | 32 | void BluetoothBNEPEdit::showData( BluetoothBNEPData & Data ) { |
33 | QListViewItem * lvit; | ||
34 | BTPANServers_LV->clear(); | ||
35 | |||
36 | for ( QStringList::Iterator it = Data.BDAddress.begin(); | ||
37 | it != Data.BDAddress.end(); | ||
38 | ++it ) { | ||
39 | lvit = new QListViewItem(BTPANServers_LV); | ||
40 | lvit->setText( 0, (*it) ); | ||
41 | } | ||
20 | } | 42 | } |
21 | 43 | ||
22 | void BluetoothBNEPEdit::SLOT_StartBTMgr( void ) { | 44 | void BluetoothBNEPEdit::SLOT_StartBTMgr( void ) { |
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp new file mode 100644 index 0000000..24e4b7b --- a/dev/null +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp | |||
@@ -0,0 +1,249 @@ | |||
1 | #include <qfile.h> | ||
2 | #include <qfileinfo.h> | ||
3 | #include <qtextstream.h> | ||
4 | #include <resources.h> | ||
5 | #include "bluetoothBNEPrun.h" | ||
6 | |||
7 | QDict<QString> * BluetoothBNEPRun::PANConnections = 0; | ||
8 | |||
9 | void BluetoothBNEPRun::detectState( NodeCollection * NC ) { | ||
10 | // unavailable : no card found | ||
11 | // available : card found and assigned to us or free | ||
12 | // up : card found and assigned to us and up | ||
13 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); | ||
14 | System & Sys = NSResources->system(); | ||
15 | InterfaceInfo * Run; | ||
16 | QFile F( S ); | ||
17 | |||
18 | Log(("Detecting for %s\n", NC->name().latin1() )); | ||
19 | |||
20 | if( F.open( IO_ReadOnly ) ) { | ||
21 | // could open file -> read interface and assign | ||
22 | QString X; | ||
23 | bool accepted = 0; | ||
24 | QTextStream TS(&F); | ||
25 | X = TS.readLine(); | ||
26 | Log(("%s exists : %s\n", S.latin1(), X.latin1() )); | ||
27 | // find interface | ||
28 | if( handlesInterface( X ) ) { | ||
29 | |||
30 | Log(("Handles interface %s, PANC %p\n", X.latin1(), PANConnections )); | ||
31 | if( PANConnections == 0 ) { | ||
32 | // load connections that are active | ||
33 | // format : bnep0 00:60:57:02:71:A2 PANU | ||
34 | FILE * OutputOfCmd = popen( "pand --show", "r" ) ; | ||
35 | |||
36 | PANConnections = new QDict<QString>; | ||
37 | |||
38 | if( OutputOfCmd ) { | ||
39 | char ch; | ||
40 | // could fork | ||
41 | // read all data | ||
42 | QString Line = ""; | ||
43 | while( 1 ) { | ||
44 | if( fread( &ch, 1, 1, OutputOfCmd ) < 1 ) { | ||
45 | // eof | ||
46 | break; | ||
47 | } | ||
48 | if( ch == '\n' || ch == '\r' ) { | ||
49 | if( ! Line.isEmpty() ) { | ||
50 | if( Line.startsWith( "bnep" ) ) { | ||
51 | QStringList SL = QStringList::split( " ", Line ); | ||
52 | Log(("Detected PAN %s %s\n", | ||
53 | SL[0].latin1(), SL[1].latin1() )); | ||
54 | PANConnections->insert( SL[0], new QString(SL[1])); | ||
55 | } | ||
56 | Line=""; | ||
57 | } | ||
58 | } else { | ||
59 | Line += ch; | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | |||
64 | pclose( OutputOfCmd ); | ||
65 | } | ||
66 | |||
67 | // check if this runtime allows connection to node | ||
68 | if( ! Data.AllowAll ) { | ||
69 | // has addresses | ||
70 | for ( QStringList::Iterator it = Data.BDAddress.begin(); | ||
71 | ! accepted && it != Data.BDAddress.end(); | ||
72 | ++ it ) { | ||
73 | for( QDictIterator<QString> it2( *(PANConnections) ); | ||
74 | it2.current(); | ||
75 | ++ it2 ) { | ||
76 | if( X == it2.currentKey() && | ||
77 | (*it) == *(it2.current()) | ||
78 | ) { | ||
79 | // found | ||
80 | Log(("%s accepts connections to %s\n", | ||
81 | NC->name().latin1(), | ||
82 | it2.current()->latin1() )); | ||
83 | accepted = 1; | ||
84 | break; | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | } else { | ||
89 | Log(("%s accepts any connection\n", NC->name().latin1() )); | ||
90 | // accept any | ||
91 | accepted = 1; | ||
92 | } | ||
93 | |||
94 | if( accepted ) { | ||
95 | // matches and is allowed for this node | ||
96 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); | ||
97 | It.current(); | ||
98 | ++It ) { | ||
99 | Run = It.current(); | ||
100 | if( X == Run->Name ) { | ||
101 | Log(("%s Assigned %p\n", NC->name().latin1(), Run )); | ||
102 | Run->assignNode( netNode() ); | ||
103 | assignInterface( Run ); | ||
104 | NC->setCurrentState( IsUp ); | ||
105 | return; | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | |||
112 | Log(("Assigned %p\n", assignedInterface() )); | ||
113 | if( ( Run = assignedInterface() ) ) { | ||
114 | // we already have an interface assigned -> still present ? | ||
115 | if( ! Run->IsUp ) { | ||
116 | // usb is still free -> keep assignment | ||
117 | NC->setCurrentState( Available ); | ||
118 | return; | ||
119 | } // else interface is up but NOT us -> some other profile | ||
120 | } | ||
121 | |||
122 | // nothing (valid) assigned to us | ||
123 | assignInterface( 0 ); | ||
124 | |||
125 | // find possible interface | ||
126 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); | ||
127 | It.current(); | ||
128 | ++It ) { | ||
129 | Run = It.current(); | ||
130 | |||
131 | Log(("%s %d %d=%d %d\n", | ||
132 | Run->Name.latin1(), | ||
133 | handlesInterface( Run->Name ), | ||
134 | Run->CardType, ARPHRD_ETHER, | ||
135 | ! Run->IsUp )); | ||
136 | |||
137 | if( handlesInterface( Run->Name ) && | ||
138 | Run->CardType == ARPHRD_ETHER && | ||
139 | ! Run->IsUp | ||
140 | ) { | ||
141 | Log(("Released(OFF)\n" )); | ||
142 | // proper type, and Not UP -> free | ||
143 | NC->setCurrentState( Off ); | ||
144 | return; | ||
145 | } | ||
146 | } | ||
147 | // no free found | ||
148 | Log(("None available\n" )); | ||
149 | |||
150 | NC->setCurrentState( Unavailable ); | ||
151 | } | ||
152 | |||
153 | bool BluetoothBNEPRun::setState( NodeCollection * NC, Action_t A, bool ) { | ||
154 | |||
155 | // we only handle activate and deactivate | ||
156 | switch( A ) { | ||
157 | case Activate : | ||
158 | { | ||
159 | if( NC->currentState() != Off ) { | ||
160 | return 0; | ||
161 | } | ||
162 | InterfaceInfo * N = getInterface(); | ||
163 | if( ! N ) { | ||
164 | // no interface available | ||
165 | NC->setCurrentState( Unavailable ); | ||
166 | return 0; | ||
167 | } | ||
168 | // because we were OFF the interface | ||
169 | // we get back is NOT assigned | ||
170 | N->assignNode( netNode() ); | ||
171 | assignInterface( N ); | ||
172 | Log(("Assing %p\n", N )); | ||
173 | NC->setCurrentState( Available ); | ||
174 | return 1; | ||
175 | } | ||
176 | case Deactivate : | ||
177 | if( NC->currentState() == IsUp ) { | ||
178 | // bring down first | ||
179 | if( ! connection()->setState( Down ) ) | ||
180 | // could not ... | ||
181 | return 0; | ||
182 | } else if( NC->currentState() != Available ) { | ||
183 | return 1; | ||
184 | } | ||
185 | assignedInterface()->assignNode( 0 ); // release | ||
186 | assignInterface( 0 ); | ||
187 | NC->setCurrentState( Off ); | ||
188 | return 1; | ||
189 | default : | ||
190 | // FT | ||
191 | break; | ||
192 | } | ||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | bool BluetoothBNEPRun::canSetState( State_t Curr , Action_t A ) { | ||
197 | // we only handle up down activate and deactivate | ||
198 | switch( A ) { | ||
199 | case Activate : | ||
200 | { // at least available | ||
201 | if( Curr == Available ) { | ||
202 | return 1; | ||
203 | } | ||
204 | // or we can make one available | ||
205 | InterfaceInfo * N = getInterface(); | ||
206 | if( ! N || N->assignedNode() != 0 ) { | ||
207 | // non available or assigned | ||
208 | return 0; | ||
209 | } | ||
210 | return 1; | ||
211 | } | ||
212 | case Deactivate : | ||
213 | return ( Curr >= Available ); | ||
214 | default : | ||
215 | // FT | ||
216 | break; | ||
217 | } | ||
218 | return 0; | ||
219 | } | ||
220 | |||
221 | // get interface that is free or assigned to us | ||
222 | InterfaceInfo * BluetoothBNEPRun::getInterface( void ) { | ||
223 | |||
224 | System & S = NSResources->system(); | ||
225 | InterfaceInfo * best = 0, * Run; | ||
226 | |||
227 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | ||
228 | It.current(); | ||
229 | ++It ) { | ||
230 | Run = It.current(); | ||
231 | if( handlesInterface( Run->Name ) && | ||
232 | Run->CardType == ARPHRD_ETHER | ||
233 | ) { | ||
234 | // this is a bluetooth card | ||
235 | if( Run->assignedNode() == netNode() ) { | ||
236 | // assigned to us | ||
237 | return Run; | ||
238 | } else if( Run->assignedNode() == 0 ) { | ||
239 | // free | ||
240 | best = Run; | ||
241 | } | ||
242 | } | ||
243 | } | ||
244 | return best; // can be 0 | ||
245 | } | ||
246 | |||
247 | bool BluetoothBNEPRun::handlesInterface( const QString & S ) { | ||
248 | return Pat.match( S ) >= 0; | ||
249 | } | ||
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h index c168429..ce03cbb 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h | |||
@@ -6,7 +6,10 @@ class BluetoothBNEPRun : public AsDevice { | |||
6 | public : | 6 | public : |
7 | 7 | ||
8 | BluetoothBNEPRun( ANetNodeInstance * NNI, | 8 | BluetoothBNEPRun( ANetNodeInstance * NNI, |
9 | BluetoothBNEPData & Data ) : AsDevice( NNI ) | 9 | BluetoothBNEPData & D ) : |
10 | AsDevice( NNI ), | ||
11 | Data( D), | ||
12 | Pat( "bnep[0-6]" ) | ||
10 | { } | 13 | { } |
11 | 14 | ||
12 | virtual AsDevice * asDevice( void ) | 15 | virtual AsDevice * asDevice( void ) |
@@ -17,15 +20,15 @@ public : | |||
17 | 20 | ||
18 | protected : | 21 | protected : |
19 | 22 | ||
20 | void detectState( NodeCollection * ) | 23 | void detectState( NodeCollection * ); |
21 | { } | 24 | bool setState( NodeCollection * , Action_t, bool ); |
22 | 25 | bool canSetState( State_t , Action_t ); | |
23 | bool setState( NodeCollection * , Action_t, bool ) | 26 | bool handlesInterface( const QString & ); |
24 | { return 0; } | ||
25 | 27 | ||
26 | bool canSetState( State_t , Action_t ) | 28 | private : |
27 | { return 0; } | ||
28 | 29 | ||
29 | bool handlesInterface( const QString & ) | 30 | InterfaceInfo * getInterface( void ); |
30 | { return 0; } | 31 | BluetoothBNEPData & Data; |
32 | static QDict<QString> * PANConnections; | ||
33 | QRegExp Pat; | ||
31 | }; | 34 | }; |
diff --git a/noncore/settings/networksettings2/lancard/lancardedit.cpp b/noncore/settings/networksettings2/lancard/lancardedit.cpp index ffe9bf6..c00d7aa 100644 --- a/noncore/settings/networksettings2/lancard/lancardedit.cpp +++ b/noncore/settings/networksettings2/lancard/lancardedit.cpp | |||
@@ -114,9 +114,9 @@ void LanCardEdit::SLOT_ScanCards( void ) { | |||
114 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | 114 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); |
115 | It.current(); | 115 | It.current(); |
116 | ++It ) { | 116 | ++It ) { |
117 | fprintf( stderr, "TEST %s %s\n", | 117 | Log(( "TEST %s %s\n", |
118 | It.current()->Name.latin1(), | 118 | It.current()->Name.latin1(), |
119 | It.current()->MACAddress.latin1() ); | 119 | It.current()->MACAddress.latin1() )); |
120 | if( R.match( It.current()->Name ) >= 0 && | 120 | if( R.match( It.current()->Name ) >= 0 && |
121 | ( It.current()->CardType == ARPHRD_ETHER | 121 | ( It.current()->CardType == ARPHRD_ETHER |
122 | #ifdef ARPHRD_IEEE1394 | 122 | #ifdef ARPHRD_IEEE1394 |
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp index 30d1270..6c969fc 100644 --- a/noncore/settings/networksettings2/main.cpp +++ b/noncore/settings/networksettings2/main.cpp | |||
@@ -78,8 +78,10 @@ int main( int argc, char * argv[] ) { | |||
78 | switch( Action ) { | 78 | switch( Action ) { |
79 | case ACT_REQUEST : | 79 | case ACT_REQUEST : |
80 | { NetworkSettingsData NS; | 80 | { NetworkSettingsData NS; |
81 | Log(("ACT_REQUEST\n")); | ||
81 | if( NS.canStart( argv[1] ) ) { | 82 | if( NS.canStart( argv[1] ) ) { |
82 | QString S; | 83 | QString S; |
84 | Log(("NEED FOR PROMPT\n" )); | ||
83 | S.sprintf( QPEApplication::qpeDir()+ | 85 | S.sprintf( QPEApplication::qpeDir()+ |
84 | "/bin/networksettings2" ); | 86 | "/bin/networksettings2" ); |
85 | char * MyArgv[4]; | 87 | char * MyArgv[4]; |
@@ -95,12 +97,14 @@ int main( int argc, char * argv[] ) { | |||
95 | break; | 97 | break; |
96 | case ACT_REGEN : | 98 | case ACT_REGEN : |
97 | { NetworkSettingsData NS; | 99 | { NetworkSettingsData NS; |
100 | Log(("REGEN\n" )); | ||
98 | // regen returns 0 if OK | 101 | // regen returns 0 if OK |
99 | rv = (NS.regenerate()) ? 1 : 0; | 102 | rv = (NS.regenerate()) ? 1 : 0; |
100 | } | 103 | } |
101 | break; | 104 | break; |
102 | case ACT_PROMPT : | 105 | case ACT_PROMPT : |
103 | { ActivateProfile AP(argv[1]); | 106 | { ActivateProfile AP(argv[1]); |
107 | Log(("PROMPT\n" )); | ||
104 | if( AP.exec() == QDialog::Accepted ) { | 108 | if( AP.exec() == QDialog::Accepted ) { |
105 | printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); | 109 | printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); |
106 | } else { | 110 | } else { |
@@ -110,6 +114,7 @@ int main( int argc, char * argv[] ) { | |||
110 | break; | 114 | break; |
111 | case ACT_GUI : | 115 | case ACT_GUI : |
112 | { QWidget * W = new NetworkSettings(0); | 116 | { QWidget * W = new NetworkSettings(0); |
117 | Log(("GUI\n" )); | ||
113 | TheApp->setMainWidget( W ); | 118 | TheApp->setMainWidget( W ); |
114 | W->show(); | 119 | W->show(); |
115 | #ifdef _WS_QWS_ | 120 | #ifdef _WS_QWS_ |
@@ -123,6 +128,8 @@ int main( int argc, char * argv[] ) { | |||
123 | break; | 128 | break; |
124 | } | 129 | } |
125 | 130 | ||
131 | LogClose(); | ||
132 | |||
126 | return rv; | 133 | return rv; |
127 | } | 134 | } |
128 | 135 | ||
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp index 41e1c53..3e24c5f 100644 --- a/noncore/settings/networksettings2/network/networkrun.cpp +++ b/noncore/settings/networksettings2/network/networkrun.cpp | |||
@@ -13,6 +13,7 @@ void NetworkRun::detectState( NodeCollection * NC ) { | |||
13 | return; | 13 | return; |
14 | } | 14 | } |
15 | 15 | ||
16 | Log(( "%s not ! UP or ava\n", NC->name().latin1() )); | ||
16 | // has no interface -> delegate | 17 | // has no interface -> delegate |
17 | RI->detectState( NC ); | 18 | RI->detectState( NC ); |
18 | } | 19 | } |
@@ -34,17 +35,28 @@ bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) { | |||
34 | } | 35 | } |
35 | return 1; | 36 | return 1; |
36 | } else if( A == Down ) { | 37 | } else if( A == Down ) { |
37 | if( NC->currentState() == IsUp || Force ) { | 38 | QString S; |
38 | QString S; | 39 | if( Force ) { |
39 | S.sprintf( "ifdown %s=%s-c%d-allowed", | 40 | Log(("Force mode %d\n", Force )); |
40 | II->Name.latin1(), II->Name.latin1(), | 41 | for( int i = 0; |
41 | connection()->number() ); | 42 | i < RI->netNode()->nodeClass()->instanceCount(); |
42 | NSResources->system().runAsRoot( S ); | 43 | i ++ ) { |
44 | S.sprintf( "ifdown %s", | ||
45 | RI->netNode()->nodeClass()->genNic( i ).latin1() ); | ||
46 | NSResources->system().runAsRoot( S ); | ||
47 | } | ||
48 | } else { | ||
49 | if( NC->currentState() == IsUp ) { | ||
50 | S.sprintf( "ifdown %s=%s-c%d-allowed", | ||
51 | II->Name.latin1(), II->Name.latin1(), | ||
52 | connection()->number() ); | ||
53 | NSResources->system().runAsRoot( S ); | ||
54 | } | ||
43 | } | 55 | } |
44 | return 1; | 56 | return 1; |
45 | } | 57 | } |
46 | // delegate | 58 | // delegate |
47 | return RI->setState( NC, A ); | 59 | return RI->setState( NC, A, Force ); |
48 | } | 60 | } |
49 | 61 | ||
50 | bool NetworkRun::canSetState( State_t Curr, Action_t A ) { | 62 | bool NetworkRun::canSetState( State_t Curr, Action_t A ) { |
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp index b36c7a0..6ee4106 100644 --- a/noncore/settings/networksettings2/networksettings.cpp +++ b/noncore/settings/networksettings2/networksettings.cpp | |||
@@ -1,4 +1,5 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <unistd.h> | ||
2 | 3 | ||
3 | #include <qpe/qpeapplication.h> | 4 | #include <qpe/qpeapplication.h> |
4 | #include <qlistbox.h> | 5 | #include <qlistbox.h> |
@@ -61,6 +62,10 @@ NetworkSettings::NetworkSettings( QWidget *parent, | |||
61 | QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) ); | 62 | QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) ); |
62 | } | 63 | } |
63 | 64 | ||
65 | connect( &(NSResources->system()), | ||
66 | SIGNAL( lineFromCommand(const QString &) ), | ||
67 | this, SLOT( SLOT_CmdMessage(const QString &) ) ); | ||
68 | |||
64 | UpdateTimer->start( 5000 ); | 69 | UpdateTimer->start( 5000 ); |
65 | connect( UpdateTimer, SIGNAL( timeout() ), | 70 | connect( UpdateTimer, SIGNAL( timeout() ), |
66 | this, SLOT( SLOT_RefreshStates() ) ); | 71 | this, SLOT( SLOT_RefreshStates() ) ); |
@@ -91,6 +96,12 @@ NetworkSettings::~NetworkSettings() { | |||
91 | } | 96 | } |
92 | } | 97 | } |
93 | 98 | ||
99 | void NetworkSettings::SLOT_CmdMessage( const QString & S ) { | ||
100 | Messages_LB->insertItem( S ); | ||
101 | Messages_LB->setCurrentItem( Messages_LB->count()-1 ); | ||
102 | Messages_LB->ensureCurrentVisible(); | ||
103 | } | ||
104 | |||
94 | void NetworkSettings::SLOT_RefreshStates( void ) { | 105 | void NetworkSettings::SLOT_RefreshStates( void ) { |
95 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember | 106 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember |
96 | 107 | ||
@@ -134,6 +145,9 @@ void NetworkSettings::SLOT_RefreshStates( void ) { | |||
134 | */ | 145 | */ |
135 | } | 146 | } |
136 | 147 | ||
148 | void NetworkSettings::SLOT_NoLongerBusy( void ) { | ||
149 | NSResources->busy( FALSE ); | ||
150 | } | ||
137 | void NetworkSettings::SLOT_AddNode( void ) { | 151 | void NetworkSettings::SLOT_AddNode( void ) { |
138 | SLOT_EditNode( 0 ); | 152 | SLOT_EditNode( 0 ); |
139 | } | 153 | } |
@@ -172,6 +186,8 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { | |||
172 | EC.showMaximized(); | 186 | EC.showMaximized(); |
173 | // disable refresh timer | 187 | // disable refresh timer |
174 | UpdateTimer->stop(); | 188 | UpdateTimer->stop(); |
189 | NSResources->busy( TRUE ); | ||
190 | QTimer::singleShot( 1000, this, SLOT( SLOT_NoLongerBusy() )); | ||
175 | // we need to retry | 191 | // we need to retry |
176 | while( 1 ) { | 192 | while( 1 ) { |
177 | if( EC.exec() == QDialog::Accepted ) { | 193 | if( EC.exec() == QDialog::Accepted ) { |
@@ -206,7 +222,7 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { | |||
206 | // new item | 222 | // new item |
207 | int ci = Profiles_LB->count(); | 223 | int ci = Profiles_LB->count(); |
208 | NSResources->addConnection( NC ); | 224 | NSResources->addConnection( NC ); |
209 | NC->setNumber( NC->maxConnectionNumber()+1 ); | 225 | NC->setNumber( NSResources->assignConnectionNumber() ); |
210 | Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); | 226 | Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); |
211 | Profiles_LB->setSelected( ci, TRUE ); | 227 | Profiles_LB->setSelected( ci, TRUE ); |
212 | } | 228 | } |
@@ -257,14 +273,20 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { | |||
257 | break; | 273 | break; |
258 | case Available : | 274 | case Available : |
259 | OnOn = 1; | 275 | OnOn = 1; |
276 | Connect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) ); | ||
260 | DisabledOn = 0; | 277 | DisabledOn = 0; |
261 | break; | 278 | break; |
262 | case IsUp : | 279 | case IsUp : |
263 | OnOn = ConnectOn = 1; | 280 | OnOn = ConnectOn = 1; |
281 | Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) ); | ||
264 | DisabledOn = 0; | 282 | DisabledOn = 0; |
265 | break; | 283 | break; |
266 | } | 284 | } |
267 | 285 | ||
286 | if( ! OnOn ) { | ||
287 | Connect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) ); | ||
288 | } | ||
289 | |||
268 | // set button state | 290 | // set button state |
269 | Enable_TB->setEnabled( EnabledPossible ); | 291 | Enable_TB->setEnabled( EnabledPossible ); |
270 | On_TB->setEnabled( OnPossible ); | 292 | On_TB->setEnabled( OnPossible ); |
@@ -275,13 +297,12 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { | |||
275 | Connect_TB->setOn( ConnectOn ); | 297 | Connect_TB->setOn( ConnectOn ); |
276 | 298 | ||
277 | if( NC->description().isEmpty() ) { | 299 | if( NC->description().isEmpty() ) { |
278 | Description_LBL->setText( tr( "No description" ) ); | 300 | Description_LBL->setText( tr( "<<No description>>" ) ); |
279 | } else { | 301 | } else { |
280 | Description_LBL->setText( NC->description() ); | 302 | Description_LBL->setText( NC->description() ); |
281 | } | 303 | } |
282 | 304 | ||
283 | Profile_GB->setTitle( LBI->text() ); | 305 | Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() ); |
284 | State_LBL->setText( NC->stateName() ); | ||
285 | } | 306 | } |
286 | 307 | ||
287 | void NetworkSettings::SLOT_CheckState( void ) { | 308 | void NetworkSettings::SLOT_CheckState( void ) { |
@@ -414,6 +435,7 @@ void NetworkSettings::SLOT_Connect( void ) { | |||
414 | } | 435 | } |
415 | 436 | ||
416 | void NetworkSettings::SLOT_Disconnect( void ) { | 437 | void NetworkSettings::SLOT_Disconnect( void ) { |
438 | QString S; | ||
417 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); | 439 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
418 | 440 | ||
419 | if ( ! LBI ) | 441 | if ( ! LBI ) |
@@ -422,7 +444,11 @@ void NetworkSettings::SLOT_Disconnect( void ) { | |||
422 | NodeCollection * NC = | 444 | NodeCollection * NC = |
423 | NSResources->findConnection( LBI->text() ); | 445 | NSResources->findConnection( LBI->text() ); |
424 | 446 | ||
447 | Log(( "Force interface %s down\n", NC->name().latin1() )); | ||
425 | NC->setState( Down, 1 ); | 448 | NC->setState( Down, 1 ); |
449 | // remove 'up' file to make sure | ||
450 | S.sprintf( "/tmp/Profile-%d.up", NC->number() ); | ||
451 | unlink( S.latin1() ); | ||
426 | } | 452 | } |
427 | 453 | ||
428 | void NetworkSettings::SLOT_ToMessages( void ) { | 454 | void NetworkSettings::SLOT_ToMessages( void ) { |
diff --git a/noncore/settings/networksettings2/networksettings.h b/noncore/settings/networksettings2/networksettings.h index 97852af..8ffde06 100644 --- a/noncore/settings/networksettings2/networksettings.h +++ b/noncore/settings/networksettings2/networksettings.h | |||
@@ -28,6 +28,7 @@ public : | |||
28 | 28 | ||
29 | public slots : | 29 | public slots : |
30 | 30 | ||
31 | void SLOT_NoLongerBusy( void ); | ||
31 | void SLOT_AddNode( void ); | 32 | void SLOT_AddNode( void ); |
32 | void SLOT_DeleteNode( void ); | 33 | void SLOT_DeleteNode( void ); |
33 | void SLOT_ShowNode( QListBoxItem * ); | 34 | void SLOT_ShowNode( QListBoxItem * ); |
@@ -42,6 +43,7 @@ public slots : | |||
42 | void SLOT_QCopMessage( const QCString&,const QByteArray& ); | 43 | void SLOT_QCopMessage( const QCString&,const QByteArray& ); |
43 | void SLOT_ToProfile( void ); | 44 | void SLOT_ToProfile( void ); |
44 | void SLOT_ToMessages( void ); | 45 | void SLOT_ToMessages( void ); |
46 | void SLOT_CmdMessage( const QString & S ); | ||
45 | 47 | ||
46 | private : | 48 | private : |
47 | 49 | ||
diff --git a/noncore/settings/networksettings2/networksettings2/Utils.h b/noncore/settings/networksettings2/networksettings2/Utils.h new file mode 100644 index 0000000..63ef51c --- a/dev/null +++ b/noncore/settings/networksettings2/networksettings2/Utils.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef __UTILS_H | ||
2 | #define __UTILS_H | ||
3 | |||
4 | #define Log(x) VLog x | ||
5 | extern void VLog( char * Format, ... ); | ||
6 | extern void LogClose( void ); | ||
7 | |||
8 | #endif | ||
diff --git a/noncore/settings/networksettings2/networksettings2/asfullsetup.h b/noncore/settings/networksettings2/networksettings2/asfullsetup.h index e358a83..072de9a 100644 --- a/noncore/settings/networksettings2/networksettings2/asfullsetup.h +++ b/noncore/settings/networksettings2/networksettings2/asfullsetup.h | |||
@@ -14,6 +14,8 @@ public : | |||
14 | } | 14 | } |
15 | 15 | ||
16 | virtual const QString & description( void ) = 0; | 16 | virtual const QString & description( void ) = 0; |
17 | virtual bool triggersVPN( void ) | ||
18 | { return 0; } | ||
17 | 19 | ||
18 | }; | 20 | }; |
19 | 21 | ||
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index 1182543..8c80e0b 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp | |||
@@ -103,8 +103,6 @@ ANetNodeInstance * ANetNodeInstance::nextNode( void ) { | |||
103 | // | 103 | // |
104 | // | 104 | // |
105 | 105 | ||
106 | long NodeCollection::MaxNr = -1; | ||
107 | |||
108 | NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { | 106 | NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { |
109 | IsModified = 0; | 107 | IsModified = 0; |
110 | Index = -1; | 108 | Index = -1; |
@@ -146,6 +144,7 @@ NodeCollection::NodeCollection( QTextStream & TS ) : | |||
146 | if( A == "name" ) { | 144 | if( A == "name" ) { |
147 | Name = N; | 145 | Name = N; |
148 | } else if( A == "number" ) { | 146 | } else if( A == "number" ) { |
147 | Log(( "read number %s\n", N.latin1() )); | ||
149 | setNumber( N.toLong() ); | 148 | setNumber( N.toLong() ); |
150 | } else if( A == "node" ) { | 149 | } else if( A == "node" ) { |
151 | ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); | 150 | ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); |
@@ -295,6 +294,9 @@ void NodeCollection::reassign( void ) { | |||
295 | } | 294 | } |
296 | } | 295 | } |
297 | 296 | ||
297 | bool NodeCollection::triggersVPN() { | ||
298 | return getToplevel()->runtime()->asFullSetup()->triggersVPN(); | ||
299 | } | ||
298 | // | 300 | // |
299 | // | 301 | // |
300 | // RUNTIMEINFO | 302 | // RUNTIMEINFO |
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h index 5e36062..ca35c27 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.h +++ b/noncore/settings/networksettings2/networksettings2/netnode.h | |||
@@ -8,6 +8,8 @@ | |||
8 | #include <qobject.h> | 8 | #include <qobject.h> |
9 | #include <time.h> | 9 | #include <time.h> |
10 | 10 | ||
11 | #include <Utils.h> | ||
12 | |||
11 | // difference feature interfaces | 13 | // difference feature interfaces |
12 | class AsDevice; | 14 | class AsDevice; |
13 | class AsLine; | 15 | class AsLine; |
@@ -283,7 +285,7 @@ public : | |||
283 | int number( void ) | 285 | int number( void ) |
284 | { return Number; } | 286 | { return Number; } |
285 | void setNumber( int i ) | 287 | void setNumber( int i ) |
286 | { Number = i; if( MaxNr < i ) MaxNr = i; } | 288 | { Number = i; } |
287 | bool isNew( void ) | 289 | bool isNew( void ) |
288 | { return IsNew; } | 290 | { return IsNew; } |
289 | void setNew( bool N ) | 291 | void setNew( bool N ) |
@@ -305,8 +307,15 @@ public : | |||
305 | return getToplevel()->runtime()->device(); | 307 | return getToplevel()->runtime()->device(); |
306 | } | 308 | } |
307 | 309 | ||
310 | bool triggersVPN(); | ||
311 | |||
308 | State_t state( bool Update = 0 ) | 312 | State_t state( bool Update = 0 ) |
309 | { if( CurrentState == Unchecked || Update ) { | 313 | { Log(( "%s state %d(=%d?)\n", Name.latin1(), CurrentState, |
314 | Unchecked )); | ||
315 | if( CurrentState == Unchecked || Update ) { | ||
316 | Log(( "TL %p TLR %p\n", | ||
317 | getToplevel(), | ||
318 | getToplevel()->runtime() )); | ||
310 | // need to get current state | 319 | // need to get current state |
311 | getToplevel()->runtime()->detectState( this ); | 320 | getToplevel()->runtime()->detectState( this ); |
312 | } | 321 | } |
@@ -352,18 +361,11 @@ public : | |||
352 | void setCurrentState( State_t S ) | 361 | void setCurrentState( State_t S ) |
353 | { CurrentState = S; } | 362 | { CurrentState = S; } |
354 | 363 | ||
355 | long maxConnectionNumber( void ) | ||
356 | { return MaxNr; } | ||
357 | |||
358 | static void resetMaxNr( void ) | ||
359 | { MaxNr = -1; } | ||
360 | |||
361 | private : | 364 | private : |
362 | 365 | ||
363 | int compareItems ( QCollection::Item item1, | 366 | int compareItems ( QCollection::Item item1, |
364 | QCollection::Item item2 ); | 367 | QCollection::Item item2 ); |
365 | 368 | ||
366 | static long MaxNr; | ||
367 | long Number; | 369 | long Number; |
368 | 370 | ||
369 | // state of this connection | 371 | // state of this connection |
diff --git a/noncore/settings/networksettings2/networksettings2/networksettings2.pro b/noncore/settings/networksettings2/networksettings2/networksettings2.pro index f97c93b..16a946b 100644 --- a/noncore/settings/networksettings2/networksettings2/networksettings2.pro +++ b/noncore/settings/networksettings2/networksettings2/networksettings2.pro | |||
@@ -20,7 +20,7 @@ SOURCES = netnode.cpp \ | |||
20 | resources.cpp | 20 | resources.cpp |
21 | INCLUDEPATH+= $(OPIEDIR)/include ../networksettings2 | 21 | INCLUDEPATH+= $(OPIEDIR)/include ../networksettings2 |
22 | DEPENDPATH+= $(OPIEDIR)/include | 22 | DEPENDPATH+= $(OPIEDIR)/include |
23 | LIBS += -lqpe -lopiecore2 | 23 | LIBS += -lqpe -lopiecore2 -lopieui2 |
24 | INTERFACES= | 24 | INTERFACES= |
25 | TARGET = networksettings2 | 25 | TARGET = networksettings2 |
26 | VERSION = 1.0.0 | 26 | VERSION = 1.0.0 |
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp index c95ac7f..71e84cd 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.cpp +++ b/noncore/settings/networksettings2/networksettings2/resources.cpp | |||
@@ -23,6 +23,8 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), | |||
23 | 23 | ||
24 | _NSResources = this; | 24 | _NSResources = this; |
25 | 25 | ||
26 | detectCurrentUser(); | ||
27 | |||
26 | // load available netnodes | 28 | // load available netnodes |
27 | findAvailableNetNodes(QPEApplication::qpeDir() + PLUGINDIR ); | 29 | findAvailableNetNodes(QPEApplication::qpeDir() + PLUGINDIR ); |
28 | 30 | ||
@@ -80,13 +82,23 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), | |||
80 | // get access to the system | 82 | // get access to the system |
81 | TheSystem = new System(); | 83 | TheSystem = new System(); |
82 | 84 | ||
83 | detectCurrentUser(); | ||
84 | } | 85 | } |
85 | 86 | ||
86 | TheNSResources::~TheNSResources( void ) { | 87 | TheNSResources::~TheNSResources( void ) { |
87 | delete TheSystem; | 88 | delete TheSystem; |
88 | } | 89 | } |
89 | 90 | ||
91 | void TheNSResources::busy( bool B ) { | ||
92 | /* | ||
93 | if( B ) { | ||
94 | ShowWait->show(); | ||
95 | qApp->process | ||
96 | } else { | ||
97 | ShowWait->hide(); | ||
98 | } | ||
99 | */ | ||
100 | } | ||
101 | |||
90 | /** | 102 | /** |
91 | * Load all modules that are found in the path | 103 | * Load all modules that are found in the path |
92 | * @param path a directory that is scaned for any plugins that can be loaded | 104 | * @param path a directory that is scaned for any plugins that can be loaded |
@@ -94,6 +106,7 @@ TheNSResources::~TheNSResources( void ) { | |||
94 | */ | 106 | */ |
95 | void TheNSResources::findAvailableNetNodes(const QString &path){ | 107 | void TheNSResources::findAvailableNetNodes(const QString &path){ |
96 | 108 | ||
109 | Log(("Locate plugins in %s\n", path.latin1() )); | ||
97 | QDir d(path); | 110 | QDir d(path); |
98 | if(!d.exists()) | 111 | if(!d.exists()) |
99 | return; | 112 | return; |
@@ -127,6 +140,27 @@ void TheNSResources::findAvailableNetNodes(const QString &path){ | |||
127 | } | 140 | } |
128 | } | 141 | } |
129 | 142 | ||
143 | // used to find unique connection number | ||
144 | int TheNSResources::assignConnectionNumber( void ) { | ||
145 | bool found = 1; | ||
146 | for( int trial = 0; ; trial ++ ) { | ||
147 | found = 1; | ||
148 | for( QDictIterator<NodeCollection> it(ConnectionsMap); | ||
149 | it.current(); | ||
150 | ++it ) { | ||
151 | if( it.current()->number() == trial ) { | ||
152 | found = 0; | ||
153 | break; | ||
154 | } | ||
155 | } | ||
156 | |||
157 | if( found ) { | ||
158 | Log(("Assign profile number %d\n", trial )); | ||
159 | return trial; | ||
160 | } | ||
161 | } | ||
162 | } | ||
163 | |||
130 | /** | 164 | /** |
131 | * Attempt to load a function and resolve a function. | 165 | * Attempt to load a function and resolve a function. |
132 | * @param pluginFileName - the name of the file in which to attempt to load | 166 | * @param pluginFileName - the name of the file in which to attempt to load |
@@ -167,7 +201,6 @@ bool TheNSResources::loadNetNode( | |||
167 | NN->NodeCountInLib = PNN.count(); | 201 | NN->NodeCountInLib = PNN.count(); |
168 | 202 | ||
169 | // store mapping | 203 | // store mapping |
170 | printf( "Store %s\n", NN->NetNode->name() ); | ||
171 | AllNodeTypes.insert( NN->NetNode->name(), NN ); | 204 | AllNodeTypes.insert( NN->NetNode->name(), NN ); |
172 | } | 205 | } |
173 | 206 | ||
@@ -175,10 +208,12 @@ bool TheNSResources::loadNetNode( | |||
175 | } | 208 | } |
176 | 209 | ||
177 | QPixmap TheNSResources::getPixmap( const QString & QS ) { | 210 | QPixmap TheNSResources::getPixmap( const QString & QS ) { |
211 | QPixmap P; | ||
178 | QString S("networksettings2/"); | 212 | QString S("networksettings2/"); |
179 | S += QS; | 213 | S += QS; |
180 | fprintf( stderr, "%s\n", S.latin1() ); | 214 | Log(("%s\n", S.latin1() )); |
181 | return Resource::loadPixmap( S ); | 215 | P = Resource::loadPixmap( S ); |
216 | return ( P.isNull() ) ? QPixmap() : P; | ||
182 | } | 217 | } |
183 | 218 | ||
184 | QString TheNSResources::tr( const char * s ) { | 219 | QString TheNSResources::tr( const char * s ) { |
@@ -225,6 +260,7 @@ NodeCollection * TheNSResources::findConnection( const QString & S ) { | |||
225 | return ConnectionsMap[ S ]; | 260 | return ConnectionsMap[ S ]; |
226 | } | 261 | } |
227 | 262 | ||
263 | /* | ||
228 | void TheNSResources::renumberConnections( void ) { | 264 | void TheNSResources::renumberConnections( void ) { |
229 | Name2Connection_t & M = NSResources->connections(); | 265 | Name2Connection_t & M = NSResources->connections(); |
230 | NodeCollection * NC; | 266 | NodeCollection * NC; |
@@ -239,6 +275,7 @@ void TheNSResources::renumberConnections( void ) { | |||
239 | NC->setModified( 1 ); | 275 | NC->setModified( 1 ); |
240 | } | 276 | } |
241 | } | 277 | } |
278 | */ | ||
242 | 279 | ||
243 | typedef struct EnvVars { | 280 | typedef struct EnvVars { |
244 | char * Name; | 281 | char * Name; |
@@ -263,108 +300,145 @@ void TheNSResources::detectCurrentUser( void ) { | |||
263 | // find current running qpe | 300 | // find current running qpe |
264 | QString QPEEnvFile = ""; | 301 | QString QPEEnvFile = ""; |
265 | 302 | ||
266 | // open proc dir and find all dirs in it | 303 | if( getenv( "OPIEDIR" ) == 0 ) { |
267 | { QRegExp R("[0-9]+"); | 304 | // nothing known |
268 | QDir ProcDir( "/proc" ); | 305 | { // open proc dir and find all dirs in it |
269 | QString QPELoc = QPEApplication::qpeDir() + "bin/qpe"; | 306 | QRegExp R("[0-9]+"); |
270 | QFileInfo FI; | 307 | QDir ProcDir( "/proc" ); |
271 | QStringList EL = ProcDir.entryList( QDir::Dirs ); | 308 | QFileInfo FI; |
272 | 309 | QStringList EL = ProcDir.entryList( QDir::Dirs ); | |
273 | // print it out | 310 | |
274 | for ( QStringList::Iterator it = EL.begin(); | 311 | // print it out |
275 | it != EL.end(); | 312 | for ( QStringList::Iterator it = EL.begin(); |
276 | ++it ) { | 313 | it != EL.end(); |
277 | if( R.match( (*it) ) >= 0 ) { | 314 | ++it ) { |
278 | QString S = ProcDir.path()+"/"+ (*it); | 315 | if( R.match( (*it) ) >= 0 ) { |
279 | S.append( "/exe" ); | 316 | QString S = ProcDir.path()+"/"+ (*it); |
280 | FI.setFile( S ); | 317 | S.append( "/exe" ); |
281 | // get the linke | 318 | FI.setFile( S ); |
282 | S = FI.readLink(); | 319 | // get the link |
283 | if( S == QPELoc ) { | 320 | S = FI.readLink(); |
284 | // found running qpe | 321 | if( S.right( 8 ) == "/bin/qpe" ) { |
285 | QPEEnvFile.sprintf( ProcDir.path()+ "/" + (*it) + "/environ" ); | 322 | // found running qpe |
286 | break; | 323 | QPEEnvFile.sprintf( ProcDir.path()+ "/" + (*it) + "/environ" ); |
324 | break; | ||
325 | } | ||
287 | } | 326 | } |
288 | } | 327 | } |
289 | } | 328 | } |
290 | } | ||
291 | 329 | ||
292 | if( QPEEnvFile.isEmpty() ) { | 330 | if( QPEEnvFile.isEmpty() ) { |
293 | // could not find qpe | 331 | // could not find qpe |
294 | fprintf( stderr, "Could not find qpe\n" ); | 332 | Log(("Could not find qpe\n" )); |
295 | return; | ||
296 | } | ||
297 | |||
298 | // FI now contains path ProcDir to the cmd dir | ||
299 | { char * Buf = 0; | ||
300 | char TB[1024]; | ||
301 | long BufSize = 0; | ||
302 | int fd; | ||
303 | int rd; | ||
304 | |||
305 | fd = open( QPEEnvFile.latin1(), O_RDONLY ); | ||
306 | if( fd < 0 ) { | ||
307 | fprintf( stderr, "Could not open %s : %d\n", | ||
308 | QPEEnvFile.latin1(), errno ); | ||
309 | return; | 333 | return; |
310 | } | 334 | } |
311 | 335 | ||
312 | while( (rd = read( fd, TB, sizeof(TB) ) ) > 0 ) { | 336 | // FI now contains path ProcDir to the cmd dir |
313 | Buf = (char *)realloc( Buf, BufSize+rd ); | 337 | { char * Buf = 0; |
314 | memcpy( Buf+BufSize, TB, rd ); | 338 | char TB[1024]; |
315 | BufSize += rd; | 339 | long BufSize = 0; |
316 | } | 340 | int fd; |
341 | int rd; | ||
342 | |||
343 | fd = open( QPEEnvFile.latin1(), O_RDONLY ); | ||
344 | if( fd < 0 ) { | ||
345 | Log(("Could not open %s : %d\n", | ||
346 | QPEEnvFile.latin1(), errno )); | ||
347 | return; | ||
348 | } | ||
317 | 349 | ||
318 | char * Data = Buf; | 350 | while( (rd = read( fd, TB, sizeof(TB) ) ) > 0 ) { |
319 | char * DataEnd = Data+BufSize-1; | 351 | Buf = (char *)realloc( Buf, BufSize+rd ); |
320 | 352 | memcpy( Buf+BufSize, TB, rd ); | |
321 | // get env items out of list | 353 | BufSize += rd; |
322 | while( Data < DataEnd ) { | 354 | } |
323 | if( strncmp( Data, "LOGNAME=", 8 ) == 0 ) { | 355 | |
324 | CurrentUser.UserName = Data+8; | 356 | char * Data = Buf; |
325 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | 357 | char * DataEnd = Data+BufSize-1; |
326 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = | 358 | |
327 | strdup( Data ); | 359 | // get env items out of list |
328 | } else if( strncmp( Data, "HOME=", 5 ) == 0 ) { | 360 | while( Data < DataEnd ) { |
329 | CurrentUser.HomeDir = Data+5; | 361 | if( strncmp( Data, "LOGNAME=", 8 ) == 0 ) { |
330 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | 362 | CurrentUser.UserName = Data+8; |
331 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = | 363 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); |
332 | strdup( Data ); | 364 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = |
333 | } else { | 365 | strdup( Data ); |
334 | EnvVar_t * Run = EV; | 366 | } else if( strncmp( Data, "HOME=", 5 ) == 0 ) { |
335 | while( Run->Name ) { | 367 | CurrentUser.HomeDir = Data+5; |
336 | if( strncmp( Data, Run->Name, Run->Len ) == 0 ) { | 368 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); |
337 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | 369 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = |
338 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = | 370 | strdup( Data ); |
339 | strdup( Data ); | 371 | } else { |
340 | break; | 372 | EnvVar_t * Run = EV; |
373 | while( Run->Name ) { | ||
374 | if( strncmp( Data, Run->Name, Run->Len ) == 0 ) { | ||
375 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | ||
376 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = | ||
377 | strdup( Data ); | ||
378 | // put OPIEDIR in env | ||
379 | if( strcmp( Run->Name, "OPIEDIR=" ) == 0 ) { | ||
380 | putenv( CurrentUser.EnvList[CurrentUser.EnvList.size()-1] ); | ||
381 | |||
382 | } | ||
383 | break; | ||
384 | } | ||
385 | Run ++; | ||
341 | } | 386 | } |
342 | Run ++; | ||
343 | } | 387 | } |
344 | } | ||
345 | 388 | ||
346 | Data += strlen( Data )+1; | 389 | Data += strlen( Data )+1; |
347 | } | 390 | } |
348 | 391 | ||
349 | free( Buf ); | 392 | free( Buf ); |
350 | 393 | ||
351 | if( ! CurrentUser.UserName.isEmpty() ) { | 394 | if( ! CurrentUser.UserName.isEmpty() ) { |
352 | // find user info | 395 | // find user info |
353 | struct passwd pwd; | 396 | struct passwd pwd; |
354 | struct passwd * pwdres; | 397 | struct passwd * pwdres; |
355 | 398 | ||
356 | if( getpwnam_r( CurrentUser.UserName.latin1(), | 399 | if( getpwnam_r( CurrentUser.UserName.latin1(), |
357 | &pwd, TB, sizeof(TB), &pwdres ) || | 400 | &pwd, TB, sizeof(TB), &pwdres ) || |
358 | pwdres == 0 ) { | 401 | pwdres == 0 ) { |
359 | fprintf( stderr, "Could not determine user %s : %d\n", | 402 | Log(("Could not determine user %s : %d\n", |
360 | CurrentUser.UserName.latin1(), errno ); | 403 | CurrentUser.UserName.latin1(), errno )); |
361 | return; | 404 | return; |
405 | } | ||
406 | CurrentUser.Uid = pwd.pw_uid; | ||
407 | CurrentUser.Gid = pwd.pw_gid; | ||
408 | } else{ | ||
409 | CurrentUser.Uid = | ||
410 | CurrentUser.Gid = -1; | ||
362 | } | 411 | } |
363 | CurrentUser.Uid = pwd.pw_uid; | ||
364 | CurrentUser.Gid = pwd.pw_gid; | ||
365 | } else{ | ||
366 | CurrentUser.Uid = | ||
367 | CurrentUser.Gid = -1; | ||
368 | } | 412 | } |
413 | |||
414 | } else { | ||
415 | CurrentUser.UserName = getenv( "LOGNAME" ); | ||
416 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | ||
417 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = | ||
418 | strdup( CurrentUser.UserName ); | ||
419 | |||
420 | CurrentUser.HomeDir = getenv( "HOME" ); | ||
421 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | ||
422 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = | ||
423 | strdup( CurrentUser.HomeDir ); | ||
424 | |||
425 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | ||
426 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("USER"); | ||
427 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | ||
428 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("LD_LIBRARY_PATH"); | ||
429 | |||
430 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | ||
431 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("PATH"); | ||
432 | |||
433 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | ||
434 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("QTDIR"); | ||
435 | |||
436 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | ||
437 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("OPIEDIR"); | ||
438 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | ||
439 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("SHELL"); | ||
440 | |||
441 | CurrentUser.Uid = getuid(); | ||
442 | CurrentUser.Gid = getgid(); | ||
369 | } | 443 | } |
370 | } | 444 | } |
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h index 3d6a44f..55d2f29 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.h +++ b/noncore/settings/networksettings2/networksettings2/resources.h | |||
@@ -46,9 +46,13 @@ public : | |||
46 | TheNSResources( void ); | 46 | TheNSResources( void ); |
47 | ~TheNSResources( ); | 47 | ~TheNSResources( ); |
48 | 48 | ||
49 | // give busy feedback | ||
50 | void busy( bool B ); | ||
51 | |||
49 | System & system() | 52 | System & system() |
50 | { return *TheSystem; } | 53 | { return *TheSystem; } |
51 | 54 | ||
55 | int assignConnectionNumber(void); | ||
52 | QPixmap getPixmap( const QString & Name ); | 56 | QPixmap getPixmap( const QString & Name ); |
53 | 57 | ||
54 | Name2NetNode_t & netNodes( void ) | 58 | Name2NetNode_t & netNodes( void ) |
@@ -88,7 +92,6 @@ public : | |||
88 | const QString & netNode2Name( const char * Type ); | 92 | const QString & netNode2Name( const char * Type ); |
89 | const QString & netNode2Description( const char * Type ); | 93 | const QString & netNode2Description( const char * Type ); |
90 | 94 | ||
91 | void renumberConnections( void ); | ||
92 | void addConnection( NodeCollection * NC ); | 95 | void addConnection( NodeCollection * NC ); |
93 | void removeConnection( const QString & N ); | 96 | void removeConnection( const QString & N ); |
94 | NodeCollection * findConnection( const QString & N ); | 97 | NodeCollection * findConnection( const QString & N ); |
@@ -119,7 +122,7 @@ private : | |||
119 | // all nodes | 122 | // all nodes |
120 | Name2Instance_t AllNodes; | 123 | Name2Instance_t AllNodes; |
121 | 124 | ||
122 | CurrentQPEUser CurrentUser; | 125 | CurrentQPEUser CurrentUser; |
123 | }; | 126 | }; |
124 | 127 | ||
125 | extern TheNSResources * _NSResources; | 128 | extern TheNSResources * _NSResources; |
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp index 2133d34..a579396 100644 --- a/noncore/settings/networksettings2/networksettings2/system.cpp +++ b/noncore/settings/networksettings2/networksettings2/system.cpp | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <sys/ioctl.h> | 8 | #include <sys/ioctl.h> |
9 | #include <sys/socket.h> | 9 | #include <sys/socket.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <stdio.h> | ||
11 | #include <fcntl.h> | 12 | #include <fcntl.h> |
12 | #include <errno.h> | 13 | #include <errno.h> |
13 | #include <unistd.h> | 14 | #include <unistd.h> |
@@ -17,6 +18,7 @@ | |||
17 | #include <qstringlist.h> | 18 | #include <qstringlist.h> |
18 | #include <qfile.h> | 19 | #include <qfile.h> |
19 | #include <qtextstream.h> | 20 | #include <qtextstream.h> |
21 | #include <qapplication.h> | ||
20 | 22 | ||
21 | #include "resources.h" | 23 | #include "resources.h" |
22 | #include "system.h" | 24 | #include "system.h" |
@@ -35,7 +37,7 @@ static char Dig2Hex[] = { | |||
35 | // get LOW nibble of byte | 37 | // get LOW nibble of byte |
36 | #define LN(x) Dig2Hex[((x)&0x0f)] | 38 | #define LN(x) Dig2Hex[((x)&0x0f)] |
37 | 39 | ||
38 | System::System( void ) : ProbedInterfaces() { | 40 | System::System( void ) : QObject(), ProbedInterfaces() { |
39 | probeInterfaces(); | 41 | probeInterfaces(); |
40 | } | 42 | } |
41 | 43 | ||
@@ -47,7 +49,7 @@ System::~System( void ) { | |||
47 | int System::runAsRoot( const QString & S ) { | 49 | int System::runAsRoot( const QString & S ) { |
48 | QString MyS = S; | 50 | QString MyS = S; |
49 | char * usr = getenv("USER"); | 51 | char * usr = getenv("USER"); |
50 | int rv; | 52 | char ch; |
51 | 53 | ||
52 | if( S.isEmpty() ) { | 54 | if( S.isEmpty() ) { |
53 | // loophole to start shell | 55 | // loophole to start shell |
@@ -58,22 +60,47 @@ int System::runAsRoot( const QString & S ) { | |||
58 | MyS.prepend( "sudo " ); | 60 | MyS.prepend( "sudo " ); |
59 | } | 61 | } |
60 | 62 | ||
61 | fprintf( stderr, "Executing %s\n", MyS.latin1() ); | 63 | Log(("Executing %s\n", MyS.latin1() )); |
62 | 64 | ||
63 | rv = system( MyS.latin1() ) ; | 65 | emit lineFromCommand( tr("Command : ") + MyS ); |
64 | switch( rv ) { | 66 | emit lineFromCommand( "---------------" ); |
65 | case -1 : | 67 | Log(( "Command : %s\n", MyS.latin1() ) ); |
66 | // cannot fork | 68 | MyS += " 2>&1 "; |
67 | return 1; | 69 | OutputOfCmd = popen( MyS.latin1(), "r" ) ; |
68 | case 127 : | 70 | if( ! OutputOfCmd ) { |
69 | // cannot start shell | 71 | // cannot fork |
70 | return 2; | 72 | return 1; |
71 | default : | 73 | } |
72 | if( WEXITSTATUS(rv) != 0 ) { | 74 | |
73 | // error in command | 75 | // read all data |
74 | return 3; | 76 | QString Line = ""; |
77 | while( 1 ) { | ||
78 | if( fread( &ch, 1, 1, OutputOfCmd ) < 1 ) | ||
79 | // eof | ||
80 | break; | ||
81 | if( ch == '\n' || ch == '\r' ) { | ||
82 | if( ! Line.isEmpty() ) { | ||
83 | Log(( "read cmd output : **%s**\n", Line.latin1() ) ); | ||
84 | emit lineFromCommand( Line ); | ||
85 | Line = ""; | ||
86 | qApp->processEvents(); | ||
75 | } | 87 | } |
88 | } else { | ||
89 | Line += ch; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | if( ! Line.isEmpty() ) { | ||
94 | emit lineFromCommand( Line ); | ||
95 | Log(( "read cmd output : **%s**\n", Line.latin1() ) ); | ||
96 | } | ||
97 | Log(( "End of command\n", Line.latin1() ) ); | ||
98 | |||
99 | if( pclose( OutputOfCmd ) < 0 ) { | ||
100 | // error in command | ||
101 | return 3; | ||
76 | } | 102 | } |
103 | |||
77 | // all is fine | 104 | // all is fine |
78 | return 0; | 105 | return 0; |
79 | } | 106 | } |
@@ -198,7 +225,7 @@ void System::probeInterfaces( void ) { | |||
198 | 225 | ||
199 | if ( ! ( IFI = ProbedInterfaces.find( NicName ) ) ) { | 226 | if ( ! ( IFI = ProbedInterfaces.find( NicName ) ) ) { |
200 | // new nic | 227 | // new nic |
201 | fprintf( stderr, "NEWNIC %s\n", NicName.latin1()); | 228 | Log(("NEWNIC %s\n", NicName.latin1())); |
202 | IFI = new InterfaceInfo; | 229 | IFI = new InterfaceInfo; |
203 | IFI->Name = line.left(loc); | 230 | IFI->Name = line.left(loc); |
204 | IFI->NetNode = 0; | 231 | IFI->NetNode = 0; |
@@ -225,8 +252,8 @@ void System::probeInterfaces( void ) { | |||
225 | IFI->MACAddress = ""; | 252 | IFI->MACAddress = ""; |
226 | 253 | ||
227 | if( ioctl(sockfd, SIOCGIFHWADDR, &ifrs) >= 0 ) { | 254 | if( ioctl(sockfd, SIOCGIFHWADDR, &ifrs) >= 0 ) { |
228 | fprintf( stderr, "%s = %d\n", IFI->Name.latin1(), | 255 | Log(("%s = %d\n", IFI->Name.latin1(), |
229 | ifrs.ifr_hwaddr.sa_family ); | 256 | ifrs.ifr_hwaddr.sa_family )); |
230 | 257 | ||
231 | IFI->CardType = ifrs.ifr_hwaddr.sa_family; | 258 | IFI->CardType = ifrs.ifr_hwaddr.sa_family; |
232 | switch( ifrs.ifr_hwaddr.sa_family ) { | 259 | switch( ifrs.ifr_hwaddr.sa_family ) { |
@@ -293,7 +320,7 @@ void System::probeInterfaces( void ) { | |||
293 | } | 320 | } |
294 | } | 321 | } |
295 | } else // else already probed before -> just update | 322 | } else // else already probed before -> just update |
296 | fprintf( stderr, "OLDNIC %s\n", NicName.latin1()); | 323 | Log(("OLDNIC %s\n", NicName.latin1())); |
297 | 324 | ||
298 | // get dynamic info | 325 | // get dynamic info |
299 | if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) { | 326 | if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) { |
@@ -323,7 +350,7 @@ void System::probeInterfaces( void ) { | |||
323 | } else { | 350 | } else { |
324 | IFI->Netmask = ""; | 351 | IFI->Netmask = ""; |
325 | } | 352 | } |
326 | fprintf( stderr, "NIC %s UP %d\n", NicName.latin1(), IFI->IsUp ); | 353 | Log(("NIC %s UP %d\n", NicName.latin1(), IFI->IsUp )); |
327 | } | 354 | } |
328 | } | 355 | } |
329 | 356 | ||
@@ -332,7 +359,7 @@ void System::execAsUser( QString & Cmd, char * argv[] ) { | |||
332 | 359 | ||
333 | if( CU.UserName.isEmpty() ) { | 360 | if( CU.UserName.isEmpty() ) { |
334 | // if we come here, the exec was not successfull | 361 | // if we come here, the exec was not successfull |
335 | fprintf( stderr, "User not known \n" ); | 362 | Log(("User not known \n" )); |
336 | return; | 363 | return; |
337 | } | 364 | } |
338 | 365 | ||
@@ -351,5 +378,40 @@ void System::execAsUser( QString & Cmd, char * argv[] ) { | |||
351 | execve( Cmd.latin1(), argv, envp ); | 378 | execve( Cmd.latin1(), argv, envp ); |
352 | 379 | ||
353 | // if we come here, the exec was not successfull | 380 | // if we come here, the exec was not successfull |
354 | fprintf( stderr, "Could not exec : %d\n", errno ); | 381 | Log(("Could not exec : %d\n", errno )); |
382 | } | ||
383 | |||
384 | #include <stdarg.h> | ||
385 | static FILE * logf = 0; | ||
386 | |||
387 | void VLog( char * Format, ... ) { | ||
388 | va_list l; | ||
389 | |||
390 | va_start(l, Format ); | ||
391 | |||
392 | if( logf == (FILE *)0 ) { | ||
393 | // logf = fopen( "/tmp/ns2log", "a" ); | ||
394 | logf = stderr; | ||
395 | if( ! logf ) { | ||
396 | fprintf( stderr, "Cannot open logfile /tmp/ns2log %d\n", | ||
397 | errno ); | ||
398 | logf = (FILE *)1; | ||
399 | } else { | ||
400 | fprintf( logf, "____ OPEN LOGFILE ____\n"); | ||
401 | } | ||
402 | } | ||
403 | |||
404 | if( (long)logf > 1 ) { | ||
405 | vfprintf( logf, Format, l ); | ||
406 | } | ||
407 | va_end( l ); | ||
408 | |||
409 | } | ||
410 | |||
411 | void LogClose( void ) { | ||
412 | if( (long)logf > 1 ) { | ||
413 | fprintf( logf, "____ CLOSE LOGFILE ____\n"); | ||
414 | fclose( logf ); | ||
415 | logf = 0; | ||
416 | } | ||
355 | } | 417 | } |
diff --git a/noncore/settings/networksettings2/networksettings2/system.h b/noncore/settings/networksettings2/networksettings2/system.h index 96ee9bd..33af391 100644 --- a/noncore/settings/networksettings2/networksettings2/system.h +++ b/noncore/settings/networksettings2/networksettings2/system.h | |||
@@ -4,6 +4,8 @@ | |||
4 | // for hardware types | 4 | // for hardware types |
5 | #include <net/if_arp.h> | 5 | #include <net/if_arp.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qobject.h> | ||
8 | #include <stdio.h> | ||
7 | 9 | ||
8 | class ANetNodeInstance; | 10 | class ANetNodeInstance; |
9 | class QFile; | 11 | class QFile; |
@@ -47,7 +49,9 @@ public : | |||
47 | QString Collisions; | 49 | QString Collisions; |
48 | }; | 50 | }; |
49 | 51 | ||
50 | class System { | 52 | class System : public QObject { |
53 | |||
54 | Q_OBJECT | ||
51 | 55 | ||
52 | public : | 56 | public : |
53 | 57 | ||
@@ -71,9 +75,14 @@ public : | |||
71 | // reloads interfaces | 75 | // reloads interfaces |
72 | void probeInterfaces( void ); | 76 | void probeInterfaces( void ); |
73 | 77 | ||
78 | signals : | ||
79 | |||
80 | void lineFromCommand( const QString & S ); | ||
81 | |||
74 | private : | 82 | private : |
75 | 83 | ||
76 | QDict<InterfaceInfo> ProbedInterfaces; | 84 | QDict<InterfaceInfo> ProbedInterfaces; |
85 | FILE * OutputOfCmd; | ||
77 | QFile * ProcDevNet; | 86 | QFile * ProcDevNet; |
78 | 87 | ||
79 | }; | 88 | }; |
diff --git a/noncore/settings/networksettings2/networksettingsGUI.ui b/noncore/settings/networksettings2/networksettingsGUI.ui index 7ef2f64..6ed29f3 100644 --- a/noncore/settings/networksettings2/networksettingsGUI.ui +++ b/noncore/settings/networksettings2/networksettingsGUI.ui | |||
@@ -11,7 +11,7 @@ | |||
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>160</width> | 14 | <width>144</width> |
15 | <height>260</height> | 15 | <height>260</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
@@ -28,7 +28,7 @@ | |||
28 | <vbox> | 28 | <vbox> |
29 | <property stdset="1"> | 29 | <property stdset="1"> |
30 | <name>margin</name> | 30 | <name>margin</name> |
31 | <number>0</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> |
@@ -302,70 +302,6 @@ | |||
302 | <number>2</number> | 302 | <number>2</number> |
303 | </property> | 303 | </property> |
304 | <widget> | 304 | <widget> |
305 | <class>QLayoutWidget</class> | ||
306 | <property stdset="1"> | ||
307 | <name>name</name> | ||
308 | <cstring>Layout3</cstring> | ||
309 | </property> | ||
310 | <hbox> | ||
311 | <property stdset="1"> | ||
312 | <name>margin</name> | ||
313 | <number>0</number> | ||
314 | </property> | ||
315 | <property stdset="1"> | ||
316 | <name>spacing</name> | ||
317 | <number>6</number> | ||
318 | </property> | ||
319 | <widget> | ||
320 | <class>QLabel</class> | ||
321 | <property stdset="1"> | ||
322 | <name>name</name> | ||
323 | <cstring>TextLabel2_2</cstring> | ||
324 | </property> | ||
325 | <property stdset="1"> | ||
326 | <name>text</name> | ||
327 | <string>State</string> | ||
328 | </property> | ||
329 | </widget> | ||
330 | <widget> | ||
331 | <class>QLabel</class> | ||
332 | <property stdset="1"> | ||
333 | <name>name</name> | ||
334 | <cstring>State_LBL</cstring> | ||
335 | </property> | ||
336 | <property stdset="1"> | ||
337 | <name>text</name> | ||
338 | <string>State</string> | ||
339 | </property> | ||
340 | <property stdset="1"> | ||
341 | <name>indent</name> | ||
342 | <number>0</number> | ||
343 | </property> | ||
344 | </widget> | ||
345 | <spacer> | ||
346 | <property> | ||
347 | <name>name</name> | ||
348 | <cstring>Spacer6_2</cstring> | ||
349 | </property> | ||
350 | <property stdset="1"> | ||
351 | <name>orientation</name> | ||
352 | <enum>Horizontal</enum> | ||
353 | </property> | ||
354 | <property stdset="1"> | ||
355 | <name>sizeType</name> | ||
356 | <enum>Expanding</enum> | ||
357 | </property> | ||
358 | <property> | ||
359 | <name>sizeHint</name> | ||
360 | <size> | ||
361 | <width>20</width> | ||
362 | <height>20</height> | ||
363 | </size> | ||
364 | </property> | ||
365 | </spacer> | ||
366 | </hbox> | ||
367 | </widget> | ||
368 | <widget> | ||
369 | <class>QLabel</class> | 305 | <class>QLabel</class> |
370 | <property stdset="1"> | 306 | <property stdset="1"> |
371 | <name>name</name> | 307 | <name>name</name> |
@@ -485,7 +421,7 @@ | |||
485 | <class>QListBox</class> | 421 | <class>QListBox</class> |
486 | <property stdset="1"> | 422 | <property stdset="1"> |
487 | <name>name</name> | 423 | <name>name</name> |
488 | <cstring>Mesages_LB</cstring> | 424 | <cstring>Messages_LB</cstring> |
489 | </property> | 425 | </property> |
490 | </widget> | 426 | </widget> |
491 | <widget> | 427 | <widget> |
@@ -614,6 +550,12 @@ | |||
614 | <receiver>NetworkSettingsGUI</receiver> | 550 | <receiver>NetworkSettingsGUI</receiver> |
615 | <slot>SLOT_ToMessages()</slot> | 551 | <slot>SLOT_ToMessages()</slot> |
616 | </connection> | 552 | </connection> |
553 | <connection> | ||
554 | <sender>Disconnect_TB</sender> | ||
555 | <signal>clicked()</signal> | ||
556 | <receiver>NetworkSettingsGUI</receiver> | ||
557 | <slot>SLOT_Disconnect()</slot> | ||
558 | </connection> | ||
617 | <slot access="public">SLOT_AddNode()</slot> | 559 | <slot access="public">SLOT_AddNode()</slot> |
618 | <slot access="public">SLOT_CheckState()</slot> | 560 | <slot access="public">SLOT_CheckState()</slot> |
619 | <slot access="public">SLOT_Connect()</slot> | 561 | <slot access="public">SLOT_Connect()</slot> |
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index bb37f10..3b17548 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp | |||
@@ -17,7 +17,7 @@ NetworkSettingsData::NetworkSettingsData( void ) { | |||
17 | 17 | ||
18 | CfgFile.sprintf( "%s/Settings/NS2.conf", | 18 | CfgFile.sprintf( "%s/Settings/NS2.conf", |
19 | NSResources->currentUser().HomeDir.latin1() ); | 19 | NSResources->currentUser().HomeDir.latin1() ); |
20 | fprintf( stderr, "Cfg from %s\n", CfgFile.latin1() ); | 20 | Log(( "Cfg from %s\n", CfgFile.latin1() )); |
21 | 21 | ||
22 | // load settings | 22 | // load settings |
23 | Force = 0; | 23 | Force = 0; |
@@ -79,11 +79,11 @@ void NetworkSettingsData::loadSettings( void ) { | |||
79 | S = deQuote(S); | 79 | S = deQuote(S); |
80 | // try to find netnode | 80 | // try to find netnode |
81 | NN = NSResources->findNetNode( S ); | 81 | NN = NSResources->findNetNode( S ); |
82 | fprintf( stderr, "Node %s : %p\n", S.latin1(), NN ); | 82 | Log( ( "Node %s : %p\n", S.latin1(), NN ) ); |
83 | } else { | 83 | } else { |
84 | // try to find instance | 84 | // try to find instance |
85 | NNI = NSResources->createNodeInstance( S ); | 85 | NNI = NSResources->createNodeInstance( S ); |
86 | fprintf( stderr, "NodeInstance %s : %p\n", S.latin1(), NNI ); | 86 | Log( ( "NodeInstance %s : %p\n", S.latin1(), NNI )); |
87 | } | 87 | } |
88 | 88 | ||
89 | if( NN == 0 && NNI == 0 ) { | 89 | if( NN == 0 && NNI == 0 ) { |
@@ -151,7 +151,7 @@ QString NetworkSettingsData::saveSettings( void ) { | |||
151 | QString S; | 151 | QString S; |
152 | QFile F( CfgFile + ".bup" ); | 152 | QFile F( CfgFile + ".bup" ); |
153 | 153 | ||
154 | printf( "Saving settings to %s\n", CfgFile.latin1() ); | 154 | Log( ( "Saving settings to %s\n", CfgFile.latin1() )); |
155 | if( ! F.open( IO_WriteOnly | IO_Truncate ) ) { | 155 | if( ! F.open( IO_WriteOnly | IO_Truncate ) ) { |
156 | ErrS = qApp->translate( "NetworkSettings", | 156 | ErrS = qApp->translate( "NetworkSettings", |
157 | "<p>Could not save setup to \"%1\" !</p>" ). | 157 | "<p>Could not save setup to \"%1\" !</p>" ). |
@@ -229,7 +229,7 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { | |||
229 | return S; | 229 | return S; |
230 | 230 | ||
231 | // regenerate system files | 231 | // regenerate system files |
232 | fprintf( stderr, "Generating settings from %s\n", CfgFile.latin1() ); | 232 | Log( ( "Generating settings from %s\n", CfgFile.latin1() )); |
233 | 233 | ||
234 | { Name2SystemFile_t & SFM = NSResources->systemFiles(); | 234 | { Name2SystemFile_t & SFM = NSResources->systemFiles(); |
235 | Name2Connection_t & M = NSResources->connections(); | 235 | Name2Connection_t & M = NSResources->connections(); |
@@ -281,14 +281,6 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { | |||
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | // we cannot renumber with a FORCE request since | ||
285 | // we probably are NOT going to save the config | ||
286 | // e.g. when using --regen option | ||
287 | if( ! ForceReq && needToRegenerate ) { | ||
288 | NSResources->renumberConnections(); | ||
289 | setModified(1); | ||
290 | } | ||
291 | |||
292 | // | 284 | // |
293 | // generate files proper to each netnodeinstance | 285 | // generate files proper to each netnodeinstance |
294 | // | 286 | // |
@@ -321,7 +313,7 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { | |||
321 | ++sfit ) { | 313 | ++sfit ) { |
322 | SF = sfit.current(); | 314 | SF = sfit.current(); |
323 | 315 | ||
324 | fprintf( stderr, "Generating %s\n", SF->name().latin1() ); | 316 | Log( ( "Generating %s\n", SF->name().latin1() )); |
325 | SF->open(); | 317 | SF->open(); |
326 | 318 | ||
327 | do { // so we can break; | 319 | do { // so we can break; |
@@ -405,7 +397,7 @@ QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interfa | |||
405 | NC->state() != Disabled && // if not enabled | 397 | NC->state() != Disabled && // if not enabled |
406 | NC->state() != IsUp // if already used | 398 | NC->state() != IsUp // if already used |
407 | ) { | 399 | ) { |
408 | fprintf( stderr, "Append %s for %s\n", NC->name().latin1(), Interface); | 400 | Log( ( "Append %s for %s\n", NC->name().latin1(), Interface)); |
409 | PossibleConnections.append( NC ); | 401 | PossibleConnections.append( NC ); |
410 | } | 402 | } |
411 | } | 403 | } |
@@ -426,8 +418,7 @@ bool NetworkSettingsData::canStart( const char * Interface ) { | |||
426 | 418 | ||
427 | PossibleConnections = collectPossible( Interface ); | 419 | PossibleConnections = collectPossible( Interface ); |
428 | 420 | ||
429 | fprintf( stderr, "Possiblilies %d\n", | 421 | Log( ( "Possiblilies %d\n", PossibleConnections.count() )); |
430 | PossibleConnections.count() ); | ||
431 | switch( PossibleConnections.count() ) { | 422 | switch( PossibleConnections.count() ) { |
432 | case 0 : // no connections | 423 | case 0 : // no connections |
433 | break; | 424 | break; |
diff --git a/noncore/settings/networksettings2/profile/profileGUI.ui b/noncore/settings/networksettings2/profile/profileGUI.ui index 365704b..5bf9a9c 100644 --- a/noncore/settings/networksettings2/profile/profileGUI.ui +++ b/noncore/settings/networksettings2/profile/profileGUI.ui | |||
@@ -11,8 +11,8 @@ | |||
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>225</width> | 14 | <width>276</width> |
15 | <height>301</height> | 15 | <height>231</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
@@ -59,58 +59,128 @@ | |||
59 | <vbox> | 59 | <vbox> |
60 | <property stdset="1"> | 60 | <property stdset="1"> |
61 | <name>margin</name> | 61 | <name>margin</name> |
62 | <number>2</number> | 62 | <number>1</number> |
63 | </property> | 63 | </property> |
64 | <property stdset="1"> | 64 | <property stdset="1"> |
65 | <name>spacing</name> | 65 | <name>spacing</name> |
66 | <number>0</number> | 66 | <number>2</number> |
67 | </property> | 67 | </property> |
68 | <widget> | 68 | <widget> |
69 | <class>QCheckBox</class> | 69 | <class>QLayoutWidget</class> |
70 | <property stdset="1"> | ||
71 | <name>name</name> | ||
72 | <cstring>Automatic_CB</cstring> | ||
73 | </property> | ||
74 | <property stdset="1"> | ||
75 | <name>text</name> | ||
76 | <string>Start automatically</string> | ||
77 | </property> | ||
78 | </widget> | ||
79 | <widget> | ||
80 | <class>QCheckBox</class> | ||
81 | <property stdset="1"> | ||
82 | <name>name</name> | ||
83 | <cstring>Confirm_CB</cstring> | ||
84 | </property> | ||
85 | <property stdset="1"> | ||
86 | <name>enabled</name> | ||
87 | <bool>true</bool> | ||
88 | </property> | ||
89 | <property stdset="1"> | ||
90 | <name>text</name> | ||
91 | <string>Confirm before start</string> | ||
92 | </property> | ||
93 | <property> | ||
94 | <name>layoutMargin</name> | ||
95 | </property> | ||
96 | </widget> | ||
97 | <widget> | ||
98 | <class>QCheckBox</class> | ||
99 | <property stdset="1"> | 70 | <property stdset="1"> |
100 | <name>name</name> | 71 | <name>name</name> |
101 | <cstring>Disabled_CB</cstring> | 72 | <cstring>Layout8</cstring> |
102 | </property> | ||
103 | <property stdset="1"> | ||
104 | <name>enabled</name> | ||
105 | <bool>true</bool> | ||
106 | </property> | ||
107 | <property stdset="1"> | ||
108 | <name>text</name> | ||
109 | <string>Disabled</string> | ||
110 | </property> | ||
111 | <property> | ||
112 | <name>layoutMargin</name> | ||
113 | </property> | 73 | </property> |
74 | <grid> | ||
75 | <property stdset="1"> | ||
76 | <name>margin</name> | ||
77 | <number>0</number> | ||
78 | </property> | ||
79 | <property stdset="1"> | ||
80 | <name>spacing</name> | ||
81 | <number>6</number> | ||
82 | </property> | ||
83 | <widget row="0" column="0" rowspan="2" colspan="1" > | ||
84 | <class>QGroupBox</class> | ||
85 | <property stdset="1"> | ||
86 | <name>name</name> | ||
87 | <cstring>GroupBox1</cstring> | ||
88 | </property> | ||
89 | <property stdset="1"> | ||
90 | <name>title</name> | ||
91 | <string>Start</string> | ||
92 | </property> | ||
93 | <vbox> | ||
94 | <property stdset="1"> | ||
95 | <name>margin</name> | ||
96 | <number>11</number> | ||
97 | </property> | ||
98 | <property stdset="1"> | ||
99 | <name>spacing</name> | ||
100 | <number>6</number> | ||
101 | </property> | ||
102 | <widget> | ||
103 | <class>QCheckBox</class> | ||
104 | <property stdset="1"> | ||
105 | <name>name</name> | ||
106 | <cstring>Automatic_CB</cstring> | ||
107 | </property> | ||
108 | <property stdset="1"> | ||
109 | <name>text</name> | ||
110 | <string>Automatically</string> | ||
111 | </property> | ||
112 | </widget> | ||
113 | <widget> | ||
114 | <class>QCheckBox</class> | ||
115 | <property stdset="1"> | ||
116 | <name>name</name> | ||
117 | <cstring>Confirm_CB</cstring> | ||
118 | </property> | ||
119 | <property stdset="1"> | ||
120 | <name>enabled</name> | ||
121 | <bool>true</bool> | ||
122 | </property> | ||
123 | <property stdset="1"> | ||
124 | <name>text</name> | ||
125 | <string>Ask</string> | ||
126 | </property> | ||
127 | <property> | ||
128 | <name>layoutMargin</name> | ||
129 | </property> | ||
130 | </widget> | ||
131 | <widget> | ||
132 | <class>QCheckBox</class> | ||
133 | <property stdset="1"> | ||
134 | <name>name</name> | ||
135 | <cstring>Disabled_CB</cstring> | ||
136 | </property> | ||
137 | <property stdset="1"> | ||
138 | <name>enabled</name> | ||
139 | <bool>true</bool> | ||
140 | </property> | ||
141 | <property stdset="1"> | ||
142 | <name>text</name> | ||
143 | <string>Disabled</string> | ||
144 | </property> | ||
145 | <property> | ||
146 | <name>layoutMargin</name> | ||
147 | </property> | ||
148 | </widget> | ||
149 | </vbox> | ||
150 | </widget> | ||
151 | <widget row="0" column="1" > | ||
152 | <class>QCheckBox</class> | ||
153 | <property stdset="1"> | ||
154 | <name>name</name> | ||
155 | <cstring>TriggersVPN_CB</cstring> | ||
156 | </property> | ||
157 | <property stdset="1"> | ||
158 | <name>text</name> | ||
159 | <string>Trigger VPN</string> | ||
160 | </property> | ||
161 | </widget> | ||
162 | <spacer row="1" column="1" > | ||
163 | <property> | ||
164 | <name>name</name> | ||
165 | <cstring>Spacer8</cstring> | ||
166 | </property> | ||
167 | <property stdset="1"> | ||
168 | <name>orientation</name> | ||
169 | <enum>Vertical</enum> | ||
170 | </property> | ||
171 | <property stdset="1"> | ||
172 | <name>sizeType</name> | ||
173 | <enum>Expanding</enum> | ||
174 | </property> | ||
175 | <property> | ||
176 | <name>sizeHint</name> | ||
177 | <size> | ||
178 | <width>20</width> | ||
179 | <height>20</height> | ||
180 | </size> | ||
181 | </property> | ||
182 | </spacer> | ||
183 | </grid> | ||
114 | </widget> | 184 | </widget> |
115 | <widget> | 185 | <widget> |
116 | <class>QLabel</class> | 186 | <class>QLabel</class> |
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.cpp b/noncore/settings/networksettings2/profile/profile_NNI.cpp index 5b54aa4..cb52b2a 100644 --- a/noncore/settings/networksettings2/profile/profile_NNI.cpp +++ b/noncore/settings/networksettings2/profile/profile_NNI.cpp | |||
@@ -7,6 +7,7 @@ AProfile::AProfile( ProfileNetNode * PNN ) : ANetNodeInstance( PNN ) { | |||
7 | Data.Confirm = 0; | 7 | Data.Confirm = 0; |
8 | Data.Description = ""; | 8 | Data.Description = ""; |
9 | Data.Disabled = 0; | 9 | Data.Disabled = 0; |
10 | Data.TriggerVPN = 0; | ||
10 | GUI = 0; | 11 | GUI = 0; |
11 | RT = 0; | 12 | RT = 0; |
12 | } | 13 | } |
@@ -19,6 +20,8 @@ void AProfile::setSpecificAttribute( QString & Attr, QString & Value ) { | |||
19 | Data.Confirm = (Value=="yes"); | 20 | Data.Confirm = (Value=="yes"); |
20 | } else if ( Attr == "disabled" ) { | 21 | } else if ( Attr == "disabled" ) { |
21 | Data.Disabled = (Value=="yes"); | 22 | Data.Disabled = (Value=="yes"); |
23 | } else if ( Attr == "triggervpn" ) { | ||
24 | Data.TriggerVPN = (Value=="yes"); | ||
22 | } else if ( Attr == "description" ) { | 25 | } else if ( Attr == "description" ) { |
23 | Data.Description = Value; | 26 | Data.Description = Value; |
24 | } | 27 | } |
@@ -28,6 +31,7 @@ void AProfile::saveSpecificAttribute( QTextStream & TS ) { | |||
28 | TS << "automatic=" << ((Data.Automatic) ? "yes" : "no") << endl; | 31 | TS << "automatic=" << ((Data.Automatic) ? "yes" : "no") << endl; |
29 | TS << "preconfirm=" << ((Data.Confirm) ? "yes" : "no") << endl; | 32 | TS << "preconfirm=" << ((Data.Confirm) ? "yes" : "no") << endl; |
30 | TS << "disabled=" << ((Data.Disabled) ? "yes" : "no") << endl; | 33 | TS << "disabled=" << ((Data.Disabled) ? "yes" : "no") << endl; |
34 | TS << "triggervpn=" << ((Data.TriggerVPN) ? "yes" : "no") << endl; | ||
31 | TS << "description=" << Data.Description << endl; | 35 | TS << "description=" << Data.Description << endl; |
32 | } | 36 | } |
33 | 37 | ||
diff --git a/noncore/settings/networksettings2/profile/profiledata.h b/noncore/settings/networksettings2/profile/profiledata.h index b4168e2..246d50c 100644 --- a/noncore/settings/networksettings2/profile/profiledata.h +++ b/noncore/settings/networksettings2/profile/profiledata.h | |||
@@ -10,6 +10,7 @@ typedef struct ProfileData { | |||
10 | bool Confirm; | 10 | bool Confirm; |
11 | // Do not bring this connection up | 11 | // Do not bring this connection up |
12 | bool Disabled; | 12 | bool Disabled; |
13 | bool TriggerVPN; | ||
13 | } ProfileData_t; | 14 | } ProfileData_t; |
14 | 15 | ||
15 | #endif | 16 | #endif |
diff --git a/noncore/settings/networksettings2/profile/profileedit.cpp b/noncore/settings/networksettings2/profile/profileedit.cpp index c9fb650..87e503e 100644 --- a/noncore/settings/networksettings2/profile/profileedit.cpp +++ b/noncore/settings/networksettings2/profile/profileedit.cpp | |||
@@ -58,6 +58,7 @@ QString ProfileEdit::acceptable( void ) { | |||
58 | void ProfileEdit::showData( ProfileData_t & Data ) { | 58 | void ProfileEdit::showData( ProfileData_t & Data ) { |
59 | Description_LE->setText( Data.Description ); | 59 | Description_LE->setText( Data.Description ); |
60 | Automatic_CB->setChecked( Data.Automatic ); | 60 | Automatic_CB->setChecked( Data.Automatic ); |
61 | TriggersVPN_CB->setChecked( Data.TriggerVPN ); | ||
61 | Confirm_CB->setChecked( Data.Confirm ); | 62 | Confirm_CB->setChecked( Data.Confirm ); |
62 | Disabled_CB->setChecked( Data.Disabled ); | 63 | Disabled_CB->setChecked( Data.Disabled ); |
63 | } | 64 | } |
@@ -68,6 +69,7 @@ bool ProfileEdit::commit( ProfileData_t & Data ) { | |||
68 | TXTM( Data.Description, Description_LE, SM ); | 69 | TXTM( Data.Description, Description_LE, SM ); |
69 | 70 | ||
70 | CBM( Data.Automatic, Automatic_CB, SM ); | 71 | CBM( Data.Automatic, Automatic_CB, SM ); |
72 | CBM( Data.TriggerVPN, TriggersVPN_CB, SM ); | ||
71 | CBM( Data.Disabled, Disabled_CB, SM ); | 73 | CBM( Data.Disabled, Disabled_CB, SM ); |
72 | CBM( Data.Confirm, Confirm_CB, SM ); | 74 | CBM( Data.Confirm, Confirm_CB, SM ); |
73 | 75 | ||
diff --git a/noncore/settings/networksettings2/profile/profilerun.cpp b/noncore/settings/networksettings2/profile/profilerun.cpp index 79bb93e..1a5b15b 100644 --- a/noncore/settings/networksettings2/profile/profilerun.cpp +++ b/noncore/settings/networksettings2/profile/profilerun.cpp | |||
@@ -4,15 +4,17 @@ | |||
4 | 4 | ||
5 | void ProfileRun::detectState( NodeCollection * NC ) { | 5 | void ProfileRun::detectState( NodeCollection * NC ) { |
6 | if( Data->Disabled ) { | 6 | if( Data->Disabled ) { |
7 | Log(( "%s disabled\n", NC->name().latin1() )); | ||
7 | NC->setCurrentState( Disabled ); | 8 | NC->setCurrentState( Disabled ); |
8 | } else { | 9 | } else { |
10 | Log(( "%s not disabled\n", NC->name().latin1() )); | ||
9 | // find next item in connection | 11 | // find next item in connection |
10 | // convert to runtime and ask to detect the state | 12 | // convert to runtime and ask to detect the state |
11 | netNode()->nextNode()->runtime()->detectState( NC ); | 13 | netNode()->nextNode()->runtime()->detectState( NC ); |
12 | } | 14 | } |
13 | } | 15 | } |
14 | 16 | ||
15 | bool ProfileRun::setState( NodeCollection * NC, Action_t A, bool ) { | 17 | bool ProfileRun::setState( NodeCollection * NC, Action_t A, bool F ) { |
16 | ANetNodeInstance * NNNI; | 18 | ANetNodeInstance * NNNI; |
17 | 19 | ||
18 | NNNI = netNode()->nextNode(); | 20 | NNNI = netNode()->nextNode(); |
@@ -41,7 +43,7 @@ bool ProfileRun::setState( NodeCollection * NC, Action_t A, bool ) { | |||
41 | default : | 43 | default : |
42 | break; | 44 | break; |
43 | } | 45 | } |
44 | return NNNI->runtime()->setState(NC, A); | 46 | return NNNI->runtime()->setState(NC, A, F ); |
45 | } | 47 | } |
46 | 48 | ||
47 | bool ProfileRun::canSetState( State_t Curr, Action_t A ) { | 49 | bool ProfileRun::canSetState( State_t Curr, Action_t A ) { |
diff --git a/noncore/settings/networksettings2/profile/profilerun.h b/noncore/settings/networksettings2/profile/profilerun.h index c8ea063..400b56c 100644 --- a/noncore/settings/networksettings2/profile/profilerun.h +++ b/noncore/settings/networksettings2/profile/profilerun.h | |||
@@ -23,6 +23,10 @@ public : | |||
23 | 23 | ||
24 | virtual AsFullSetup * asFullSetup( void ) | 24 | virtual AsFullSetup * asFullSetup( void ) |
25 | { return (AsFullSetup *)this; } | 25 | { return (AsFullSetup *)this; } |
26 | |||
27 | virtual bool triggersVPN( void ) | ||
28 | { return Data->TriggerVPN; } | ||
29 | |||
26 | private : | 30 | private : |
27 | 31 | ||
28 | ProfileData * Data; | 32 | ProfileData * Data; |
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp index beacd7b..b8ac8a8 100644 --- a/noncore/settings/networksettings2/usb/usbrun.cpp +++ b/noncore/settings/networksettings2/usb/usbrun.cpp | |||
@@ -12,12 +12,14 @@ void USBRun::detectState( NodeCollection * NC ) { | |||
12 | System & Sys = NSResources->system(); | 12 | System & Sys = NSResources->system(); |
13 | InterfaceInfo * Run; | 13 | InterfaceInfo * Run; |
14 | QFile F( S ); | 14 | QFile F( S ); |
15 | Log(("Detecting for %s\n", NC->name().latin1() )); | ||
15 | 16 | ||
16 | if( F.open( IO_ReadOnly ) ) { | 17 | if( F.open( IO_ReadOnly ) ) { |
17 | // could open file -> read interface and assign | 18 | // could open file -> read interface and assign |
18 | QString X; | 19 | QString X; |
19 | QTextStream TS(&F); | 20 | QTextStream TS(&F); |
20 | X = TS.readLine(); | 21 | X = TS.readLine(); |
22 | Log(("%s exists\n", S.latin1() )); | ||
21 | // find interface | 23 | // find interface |
22 | if( handlesInterface( X ) ) { | 24 | if( handlesInterface( X ) ) { |
23 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); | 25 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); |
@@ -34,7 +36,7 @@ void USBRun::detectState( NodeCollection * NC ) { | |||
34 | } | 36 | } |
35 | } | 37 | } |
36 | 38 | ||
37 | fprintf( stderr, "Assigned %p\n", assignedInterface() ); | 39 | Log(("Assigned %p\n", assignedInterface() )); |
38 | if( ( Run = assignedInterface() ) ) { | 40 | if( ( Run = assignedInterface() ) ) { |
39 | // we already have an interface assigned -> still present ? | 41 | // we already have an interface assigned -> still present ? |
40 | if( ! Run->IsUp ) { | 42 | if( ! Run->IsUp ) { |
@@ -53,24 +55,24 @@ void USBRun::detectState( NodeCollection * NC ) { | |||
53 | ++It ) { | 55 | ++It ) { |
54 | Run = It.current(); | 56 | Run = It.current(); |
55 | 57 | ||
56 | fprintf( stderr, "%s %d %d=%d %d\n", | 58 | Log(("%s %d %d=%d %d\n", |
57 | Run->Name.latin1(), | 59 | Run->Name.latin1(), |
58 | handlesInterface( Run->Name ), | 60 | handlesInterface( Run->Name ), |
59 | Run->CardType, ARPHRD_ETHER, | 61 | Run->CardType, ARPHRD_ETHER, |
60 | ! Run->IsUp ); | 62 | ! Run->IsUp )); |
61 | 63 | ||
62 | if( handlesInterface( Run->Name ) && | 64 | if( handlesInterface( Run->Name ) && |
63 | Run->CardType == ARPHRD_ETHER && | 65 | Run->CardType == ARPHRD_ETHER && |
64 | ! Run->IsUp | 66 | ! Run->IsUp |
65 | ) { | 67 | ) { |
66 | fprintf( stderr, "Released(OFF)\n" ); | 68 | Log(("Released(OFF)\n" )); |
67 | // proper type, and Not UP -> free | 69 | // proper type, and Not UP -> free |
68 | NC->setCurrentState( Off ); | 70 | NC->setCurrentState( Off ); |
69 | return; | 71 | return; |
70 | } | 72 | } |
71 | } | 73 | } |
72 | // no free found | 74 | // no free found |
73 | fprintf( stderr, "UNA\n" ); | 75 | Log(("UNA\n" )); |
74 | 76 | ||
75 | NC->setCurrentState( Unavailable ); | 77 | NC->setCurrentState( Unavailable ); |
76 | } | 78 | } |
@@ -94,7 +96,7 @@ bool USBRun::setState( NodeCollection * NC, Action_t A, bool ) { | |||
94 | // we get back is NOT assigned | 96 | // we get back is NOT assigned |
95 | N->assignNode( netNode() ); | 97 | N->assignNode( netNode() ); |
96 | assignInterface( N ); | 98 | assignInterface( N ); |
97 | fprintf( stderr, "Assing %p\n", N ); | 99 | Log(("Assing %p\n", N )); |
98 | NC->setCurrentState( Available ); | 100 | NC->setCurrentState( Available ); |
99 | return 1; | 101 | return 1; |
100 | } | 102 | } |