author | wimpie <wimpie> | 2004-08-09 02:31:25 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-08-09 02:31:25 (UTC) |
commit | 0784cfdbd261c43856b45be6ab7439841e69b858 (patch) (unidiff) | |
tree | f6a27d6b2e1e6d8dcc908b2ef5836cd320ddfab1 | |
parent | 5e10278e748608766245ff9f59a54d1ae8ff6f7e (diff) | |
download | opie-0784cfdbd261c43856b45be6ab7439841e69b858.zip opie-0784cfdbd261c43856b45be6ab7439841e69b858.tar.gz opie-0784cfdbd261c43856b45be6ab7439841e69b858.tar.bz2 |
Many changes :
bluetooth and usb seems to work
added preliminary support for VPN on top of any network
This version is still very much crippled yet is does DO some
things
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 | |||
@@ -1,21 +1,22 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/plugins/networksettings2 | 3 | DESTDIR = $(OPIEDIR)/plugins/networksettings2 |
4 | HEADERS = bluetooth_NN.h \ | 4 | HEADERS = bluetooth_NN.h \ |
5 | bluetoothBNEP_NNI.h \ | 5 | bluetoothBNEP_NNI.h \ |
6 | bluetoothRFCOMM_NNI.h \ | 6 | bluetoothRFCOMM_NNI.h \ |
7 | bluetoothBNEPedit.h \ | 7 | bluetoothBNEPedit.h \ |
8 | bluetoothRFCOMMedit.h | 8 | bluetoothRFCOMMedit.h |
9 | SOURCES = bluetooth_NN.cpp \ | 9 | 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 |
16 | LIBS += -lqpe | 17 | LIBS += -lqpe |
17 | INTERFACES= bluetoothBNEPGUI.ui bluetoothRFCOMMGUI.ui | 18 | INTERFACES= bluetoothBNEPGUI.ui bluetoothRFCOMMGUI.ui |
18 | TARGET = bluetooth | 19 | TARGET = bluetooth |
19 | VERSION = 1.0.0 | 20 | VERSION = 1.0.0 |
20 | 21 | ||
21 | include ( $(OPIEDIR)/include.pro ) | 22 | include ( $(OPIEDIR)/include.pro ) |
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 | |||
@@ -1,37 +1,50 @@ | |||
1 | #include "bluetoothBNEPedit.h" | 1 | #include "bluetoothBNEPedit.h" |
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 ) { |
23 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 36 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
24 | } | 37 | } |
25 | 38 | ||
26 | void ABluetoothBNEP::commit( void ) { | 39 | void ABluetoothBNEP::commit( void ) { |
27 | if( GUI && GUI->commit( Data ) ) | 40 | if( GUI && GUI->commit( Data ) ) |
28 | setModified( 1 ); | 41 | setModified( 1 ); |
29 | } | 42 | } |
30 | 43 | ||
31 | bool ABluetoothBNEP::hasDataFor( const QString & ) { | 44 | bool ABluetoothBNEP::hasDataFor( const QString & ) { |
32 | return 0; | 45 | return 0; |
33 | } | 46 | } |
34 | 47 | ||
35 | bool ABluetoothBNEP::generateDataForCommonFile( SystemFile & , long ){ | 48 | bool ABluetoothBNEP::generateDataForCommonFile( SystemFile & , long ){ |
36 | return 0; | 49 | return 0; |
37 | } | 50 | } |
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,26 +1,48 @@ | |||
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" |
5 | 7 | ||
6 | 8 | ||
7 | BluetoothBNEPEdit::BluetoothBNEPEdit( QWidget * Parent ) : BluetoothBNEPGUI( Parent ){ | 9 | BluetoothBNEPEdit::BluetoothBNEPEdit( QWidget * Parent ) : BluetoothBNEPGUI( Parent ){ |
8 | 10 | ||
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 ) { |
23 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 45 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
24 | e << QString( "bluetooth-manager" ); | 46 | e << QString( "bluetooth-manager" ); |
25 | 47 | ||
26 | } | 48 | } |
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 | |||
@@ -1,31 +1,34 @@ | |||
1 | #include <asdevice.h> | 1 | #include <asdevice.h> |
2 | #include "bluetoothBNEPdata.h" | 2 | #include "bluetoothBNEPdata.h" |
3 | 3 | ||
4 | class BluetoothBNEPRun : public AsDevice { | 4 | class BluetoothBNEPRun : public AsDevice { |
5 | 5 | ||
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 ) |
13 | { return (AsDevice *)this; } | 16 | { return (AsDevice *)this; } |
14 | 17 | ||
15 | virtual AsDevice * device( void ) | 18 | virtual AsDevice * device( void ) |
16 | { return asDevice(); } | 19 | { return asDevice(); } |
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 | |||
@@ -1,208 +1,208 @@ | |||
1 | #include <GUIUtils.h> | 1 | #include <GUIUtils.h> |
2 | #include <resources.h> | 2 | #include <resources.h> |
3 | #include <qarray.h> | 3 | #include <qarray.h> |
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qcheckbox.h> | 5 | #include <qcheckbox.h> |
6 | #include <qheader.h> | 6 | #include <qheader.h> |
7 | #include <qregexp.h> | 7 | #include <qregexp.h> |
8 | 8 | ||
9 | #include "lancardedit.h" | 9 | #include "lancardedit.h" |
10 | #include "lancard_NN.h" | 10 | #include "lancard_NN.h" |
11 | #include "lancard_NNI.h" | 11 | #include "lancard_NNI.h" |
12 | 12 | ||
13 | LanCardEdit::LanCardEdit( QWidget * Parent ) : LanCardGUI( Parent ){ | 13 | LanCardEdit::LanCardEdit( QWidget * Parent ) : LanCardGUI( Parent ){ |
14 | LanCards_LV->header()->hide(); | 14 | LanCards_LV->header()->hide(); |
15 | 15 | ||
16 | } | 16 | } |
17 | 17 | ||
18 | QString LanCardEdit::acceptable( void ) { | 18 | QString LanCardEdit::acceptable( void ) { |
19 | return QString(); | 19 | return QString(); |
20 | } | 20 | } |
21 | 21 | ||
22 | bool LanCardEdit::commit( LanCardData & Data ) { | 22 | bool LanCardEdit::commit( LanCardData & Data ) { |
23 | bool SM = 0; | 23 | bool SM = 0; |
24 | CBM( Data.AnyLanCard, AnyCard_CB, SM ); | 24 | CBM( Data.AnyLanCard, AnyCard_CB, SM ); |
25 | 25 | ||
26 | if( ! Data.AnyLanCard ) { | 26 | if( ! Data.AnyLanCard ) { |
27 | // take copy for orig list | 27 | // take copy for orig list |
28 | QStringList NewList( Data.HWAddresses ); | 28 | QStringList NewList( Data.HWAddresses ); |
29 | 29 | ||
30 | // update HWAddresses to new state | 30 | // update HWAddresses to new state |
31 | // remove item also from NewList | 31 | // remove item also from NewList |
32 | int idx; | 32 | int idx; |
33 | QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild(); | 33 | QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild(); |
34 | while( CLI ) { | 34 | while( CLI ) { |
35 | idx = Data.HWAddresses.findIndex(CLI->text(0)); | 35 | idx = Data.HWAddresses.findIndex(CLI->text(0)); |
36 | if( CLI->isOn() ) { | 36 | if( CLI->isOn() ) { |
37 | if( idx < 0 ) { | 37 | if( idx < 0 ) { |
38 | // should be in list | 38 | // should be in list |
39 | Data.HWAddresses.append( CLI->text(0) ); | 39 | Data.HWAddresses.append( CLI->text(0) ); |
40 | SM = 1; | 40 | SM = 1; |
41 | } | 41 | } |
42 | } else { | 42 | } else { |
43 | // should not be in list | 43 | // should not be in list |
44 | if( idx >= 0 ) { | 44 | if( idx >= 0 ) { |
45 | NewList.remove( CLI->text(0) ); | 45 | NewList.remove( CLI->text(0) ); |
46 | Data.HWAddresses.remove( CLI->text(0) ); | 46 | Data.HWAddresses.remove( CLI->text(0) ); |
47 | SM = 1; | 47 | SM = 1; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | CLI = (QCheckListItem *)CLI->nextSibling(); | 50 | CLI = (QCheckListItem *)CLI->nextSibling(); |
51 | } | 51 | } |
52 | 52 | ||
53 | // if newlist still contains items. it were items | 53 | // if newlist still contains items. it were items |
54 | // that were checked but no longer are present in the system | 54 | // that were checked but no longer are present in the system |
55 | SM |= ( NewList.count() > 0 ) ; | 55 | SM |= ( NewList.count() > 0 ) ; |
56 | } | 56 | } |
57 | return SM; | 57 | return SM; |
58 | } | 58 | } |
59 | 59 | ||
60 | void LanCardEdit::showData( ALanCard * LC ) { | 60 | void LanCardEdit::showData( ALanCard * LC ) { |
61 | NNI = LC; | 61 | NNI = LC; |
62 | LanCardData & Data = *((LanCardData *)LC->data()); | 62 | LanCardData & Data = *((LanCardData *)LC->data()); |
63 | 63 | ||
64 | AnyCard_CB->setChecked( Data.AnyLanCard ); | 64 | AnyCard_CB->setChecked( Data.AnyLanCard ); |
65 | 65 | ||
66 | // load all cards | 66 | // load all cards |
67 | populateList(); | 67 | populateList(); |
68 | 68 | ||
69 | // set checks | 69 | // set checks |
70 | QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild(); | 70 | QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild(); |
71 | while( CLI ) { | 71 | while( CLI ) { |
72 | CLI->setOn( Data.HWAddresses.findIndex(CLI->text(0)) >= 0 ); | 72 | CLI->setOn( Data.HWAddresses.findIndex(CLI->text(0)) >= 0 ); |
73 | CLI = (QCheckListItem *)CLI->nextSibling(); | 73 | CLI = (QCheckListItem *)CLI->nextSibling(); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | // load all known cards in list | 77 | // load all known cards in list |
78 | void LanCardEdit::populateList( void ) { | 78 | void LanCardEdit::populateList( void ) { |
79 | LanCardNetNode *NN = (LanCardNetNode *)NNI->nodeClass(); | 79 | LanCardNetNode *NN = (LanCardNetNode *)NNI->nodeClass(); |
80 | QCheckListItem * CLI; | 80 | QCheckListItem * CLI; |
81 | bool Found; | 81 | bool Found; |
82 | 82 | ||
83 | LanCards_LV->clear(); | 83 | LanCards_LV->clear(); |
84 | 84 | ||
85 | for( QStringList::Iterator it = NN->addressesOfNIC().begin(); | 85 | for( QStringList::Iterator it = NN->addressesOfNIC().begin(); |
86 | it != NN->addressesOfNIC().end(); | 86 | it != NN->addressesOfNIC().end(); |
87 | ++it ) { | 87 | ++it ) { |
88 | CLI = new QCheckListItem( LanCards_LV, (*it), QCheckListItem::CheckBox ); | 88 | CLI = new QCheckListItem( LanCards_LV, (*it), QCheckListItem::CheckBox ); |
89 | 89 | ||
90 | // check interfaces and see if this card is present | 90 | // check interfaces and see if this card is present |
91 | Found = 0; | 91 | Found = 0; |
92 | for( QDictIterator<InterfaceInfo> NIt(NSResources->system().interfaces()); | 92 | for( QDictIterator<InterfaceInfo> NIt(NSResources->system().interfaces()); |
93 | NIt.current(); | 93 | NIt.current(); |
94 | ++NIt ) { | 94 | ++NIt ) { |
95 | if( NIt.current()->MACAddress == (*it) ) { | 95 | if( NIt.current()->MACAddress == (*it) ) { |
96 | Found = 1; | 96 | Found = 1; |
97 | break; | 97 | break; |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | CLI->setPixmap( 0, NSResources->getPixmap( | 101 | CLI->setPixmap( 0, NSResources->getPixmap( |
102 | (Found) ? "add" : "remove" ) ); | 102 | (Found) ? "add" : "remove" ) ); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | // rescan system for new cards | 106 | // rescan system for new cards |
107 | void LanCardEdit::SLOT_ScanCards( void ) { | 107 | void LanCardEdit::SLOT_ScanCards( void ) { |
108 | LanCardNetNode *NN = (LanCardNetNode *)NNI->nodeClass(); | 108 | LanCardNetNode *NN = (LanCardNetNode *)NNI->nodeClass(); |
109 | 109 | ||
110 | // add any NIC that is new and matches our interfacename | 110 | // add any NIC that is new and matches our interfacename |
111 | System & S = NSResources->system(); | 111 | System & S = NSResources->system(); |
112 | QRegExp R( "eth[0-9]" ); | 112 | QRegExp R( "eth[0-9]" ); |
113 | // populate with all lancards in system | 113 | // populate with all lancards in system |
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 |
123 | || It.current()->CardType == ARPHRD_IEEE1394 | 123 | || It.current()->CardType == ARPHRD_IEEE1394 |
124 | #endif | 124 | #endif |
125 | ) | 125 | ) |
126 | ) { | 126 | ) { |
127 | // old item ? | 127 | // old item ? |
128 | QCheckListItem * CLI = | 128 | QCheckListItem * CLI = |
129 | (QCheckListItem *)LanCards_LV->firstChild(); | 129 | (QCheckListItem *)LanCards_LV->firstChild(); |
130 | while( CLI ) { | 130 | while( CLI ) { |
131 | if( CLI->text(0) == It.current()->MACAddress ) { | 131 | if( CLI->text(0) == It.current()->MACAddress ) { |
132 | break; | 132 | break; |
133 | } | 133 | } |
134 | CLI = (QCheckListItem *)CLI->nextSibling(); | 134 | CLI = (QCheckListItem *)CLI->nextSibling(); |
135 | } | 135 | } |
136 | 136 | ||
137 | if( ! CLI ) { | 137 | if( ! CLI ) { |
138 | // new item | 138 | // new item |
139 | CLI = new QCheckListItem( LanCards_LV, | 139 | CLI = new QCheckListItem( LanCards_LV, |
140 | It.current()->MACAddress, | 140 | It.current()->MACAddress, |
141 | QCheckListItem::CheckBox ); | 141 | QCheckListItem::CheckBox ); |
142 | } | 142 | } |
143 | 143 | ||
144 | // mark present | 144 | // mark present |
145 | CLI->setPixmap( 0, NSResources->getPixmap( | 145 | CLI->setPixmap( 0, NSResources->getPixmap( |
146 | "add" ) ); | 146 | "add" ) ); |
147 | 147 | ||
148 | if( NN->addressesOfNIC().findIndex( It.current()->MACAddress) < 0 ) { | 148 | if( NN->addressesOfNIC().findIndex( It.current()->MACAddress) < 0 ) { |
149 | // new | 149 | // new |
150 | NN->addressesOfNIC().append( It.current()->MACAddress ); | 150 | NN->addressesOfNIC().append( It.current()->MACAddress ); |
151 | } | 151 | } |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | } | 155 | } |
156 | 156 | ||
157 | // remove all cards that are not present -> flagged with 'remove' | 157 | // remove all cards that are not present -> flagged with 'remove' |
158 | // and unchecked | 158 | // and unchecked |
159 | void LanCardEdit::SLOT_RemoveUnknown( void ) { | 159 | void LanCardEdit::SLOT_RemoveUnknown( void ) { |
160 | QArray<QCheckListItem *> AllItems; | 160 | QArray<QCheckListItem *> AllItems; |
161 | 161 | ||
162 | LanCardNetNode *NN = (LanCardNetNode *)NNI->nodeClass(); | 162 | LanCardNetNode *NN = (LanCardNetNode *)NNI->nodeClass(); |
163 | 163 | ||
164 | QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild(); | 164 | QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild(); |
165 | while( CLI ) { | 165 | while( CLI ) { |
166 | AllItems.resize( AllItems.size()+1 ); | 166 | AllItems.resize( AllItems.size()+1 ); |
167 | AllItems[ AllItems.size()-1 ] = CLI; | 167 | AllItems[ AllItems.size()-1 ] = CLI; |
168 | CLI = (QCheckListItem *)CLI->nextSibling(); | 168 | CLI = (QCheckListItem *)CLI->nextSibling(); |
169 | } | 169 | } |
170 | 170 | ||
171 | // force update of system | 171 | // force update of system |
172 | System & S = NSResources->system(); | 172 | System & S = NSResources->system(); |
173 | S.probeInterfaces(); | 173 | S.probeInterfaces(); |
174 | 174 | ||
175 | // add any NIC that is new and matches our interfacename | 175 | // add any NIC that is new and matches our interfacename |
176 | QRegExp R( "eth[0-9]" ); | 176 | QRegExp R( "eth[0-9]" ); |
177 | 177 | ||
178 | 178 | ||
179 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | 179 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); |
180 | It.current(); | 180 | It.current(); |
181 | ++It ) { | 181 | ++It ) { |
182 | if( R.match( It.current()->Name ) >= 0 && | 182 | if( R.match( It.current()->Name ) >= 0 && |
183 | ( It.current()->CardType == ARPHRD_ETHER | 183 | ( It.current()->CardType == ARPHRD_ETHER |
184 | #ifdef ARPHRD_IEEE1394 | 184 | #ifdef ARPHRD_IEEE1394 |
185 | || It.current()->CardType == ARPHRD_IEEE1394 | 185 | || It.current()->CardType == ARPHRD_IEEE1394 |
186 | #endif | 186 | #endif |
187 | ) | 187 | ) |
188 | ) { | 188 | ) { |
189 | 189 | ||
190 | for ( unsigned i = 0; i< AllItems.size(); i++ ) { | 190 | for ( unsigned i = 0; i< AllItems.size(); i++ ) { |
191 | if( AllItems[i] && | 191 | if( AllItems[i] && |
192 | AllItems[i]->text(0) == It.current()->MACAddress ) { | 192 | AllItems[i]->text(0) == It.current()->MACAddress ) { |
193 | AllItems[i] = 0; | 193 | AllItems[i] = 0; |
194 | break; | 194 | break; |
195 | } | 195 | } |
196 | } | 196 | } |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | // AllItems now contains all cards NOT present | 200 | // AllItems now contains all cards NOT present |
201 | // remove all items non null and not ON | 201 | // remove all items non null and not ON |
202 | for ( unsigned i = 0; i< AllItems.size(); i++ ) { | 202 | for ( unsigned i = 0; i< AllItems.size(); i++ ) { |
203 | if( AllItems[i] && ! AllItems[i]->isOn() ) { | 203 | if( AllItems[i] && ! AllItems[i]->isOn() ) { |
204 | NN->addressesOfNIC().remove( AllItems[i]->text(0) ); | 204 | NN->addressesOfNIC().remove( AllItems[i]->text(0) ); |
205 | delete AllItems[i]; | 205 | delete AllItems[i]; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
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 | |||
@@ -1,133 +1,140 @@ | |||
1 | #include "nsdata.h" | 1 | #include "nsdata.h" |
2 | #include "activateprofile.h" | 2 | #include "activateprofile.h" |
3 | #include "networksettings.h" | 3 | #include "networksettings.h" |
4 | 4 | ||
5 | #include <qpe/qpeapplication.h> | 5 | #include <qpe/qpeapplication.h> |
6 | 6 | ||
7 | #include <opie2/oapplicationfactory.h> | 7 | #include <opie2/oapplicationfactory.h> |
8 | using namespace Opie::Core; | 8 | using namespace Opie::Core; |
9 | 9 | ||
10 | #ifdef GONE | 10 | #ifdef GONE |
11 | 11 | ||
12 | OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) | 12 | OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) |
13 | 13 | ||
14 | #else | 14 | #else |
15 | 15 | ||
16 | // just standard GUI | 16 | // just standard GUI |
17 | #define ACT_GUI 0 | 17 | #define ACT_GUI 0 |
18 | // used by interfaces to request for allow of up/down | 18 | // used by interfaces to request for allow of up/down |
19 | #define ACT_REQUEST 1 | 19 | #define ACT_REQUEST 1 |
20 | // regenerate config files | 20 | // regenerate config files |
21 | #define ACT_REGEN 2 | 21 | #define ACT_REGEN 2 |
22 | // used by interfaces to request user prompt | 22 | // used by interfaces to request user prompt |
23 | #define ACT_PROMPT 3 | 23 | #define ACT_PROMPT 3 |
24 | 24 | ||
25 | int main( int argc, char * argv[] ) { | 25 | int main( int argc, char * argv[] ) { |
26 | int rv = 0; | 26 | int rv = 0; |
27 | int Action = ACT_GUI; | 27 | int Action = ACT_GUI; |
28 | // could be overruled by -qws | 28 | // could be overruled by -qws |
29 | QApplication::Type GuiType = QApplication::GuiClient; | 29 | QApplication::Type GuiType = QApplication::GuiClient; |
30 | 30 | ||
31 | #ifdef _WS_QWS_ | 31 | #ifdef _WS_QWS_ |
32 | QPEApplication * TheApp; | 32 | QPEApplication * TheApp; |
33 | #else | 33 | #else |
34 | QApplication * TheApp; | 34 | QApplication * TheApp; |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | for ( int i = 1; i < argc; i ++ ) { | 37 | for ( int i = 1; i < argc; i ++ ) { |
38 | int rmv; | 38 | int rmv; |
39 | rmv = 0; | 39 | rmv = 0; |
40 | if( strcmp( argv[i], "--regen" ) == 0 ) { | 40 | if( strcmp( argv[i], "--regen" ) == 0 ) { |
41 | Action = ACT_REGEN; | 41 | Action = ACT_REGEN; |
42 | GuiType = QApplication::Tty; | 42 | GuiType = QApplication::Tty; |
43 | rmv = 1; | 43 | rmv = 1; |
44 | } else if( strcmp( argv[i], "--prompt" ) == 0 ) { | 44 | } else if( strcmp( argv[i], "--prompt" ) == 0 ) { |
45 | Action = ACT_PROMPT; | 45 | Action = ACT_PROMPT; |
46 | rmv = 1; | 46 | rmv = 1; |
47 | } | 47 | } |
48 | if( rmv ) { | 48 | if( rmv ) { |
49 | memmove( argv+i, argv+i+rmv, | 49 | memmove( argv+i, argv+i+rmv, |
50 | sizeof( char * ) * (argc-i-rmv) ); | 50 | sizeof( char * ) * (argc-i-rmv) ); |
51 | i --; | 51 | i --; |
52 | argc -= rmv; | 52 | argc -= rmv; |
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | if( strstr( argv[0], "-request" ) ) { | 56 | if( strstr( argv[0], "-request" ) ) { |
57 | // called from system to request something | 57 | // called from system to request something |
58 | GuiType = QApplication::Tty; | 58 | GuiType = QApplication::Tty; |
59 | Action = ACT_REQUEST; | 59 | Action = ACT_REQUEST; |
60 | } | 60 | } |
61 | 61 | ||
62 | // Start Qt | 62 | // Start Qt |
63 | #ifdef _WS_QWS_ | 63 | #ifdef _WS_QWS_ |
64 | // because QPEApplication does not handle GuiType well | 64 | // because QPEApplication does not handle GuiType well |
65 | if( GuiType == QApplication::Tty ) { | 65 | if( GuiType == QApplication::Tty ) { |
66 | // this cast is NOT correct but we do not use | 66 | // this cast is NOT correct but we do not use |
67 | // TheApp anymore ... | 67 | // TheApp anymore ... |
68 | TheApp = (QPEApplication *)new QApplication( argc, argv, GuiType ); | 68 | TheApp = (QPEApplication *)new QApplication( argc, argv, GuiType ); |
69 | } else { | 69 | } else { |
70 | TheApp = new QPEApplication( argc, argv, GuiType ); | 70 | TheApp = new QPEApplication( argc, argv, GuiType ); |
71 | } | 71 | } |
72 | #else | 72 | #else |
73 | TheApp = new QApplication( argc, argv, GuiType ); | 73 | TheApp = new QApplication( argc, argv, GuiType ); |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | // init qt with app widget | 76 | // init qt with app widget |
77 | 77 | ||
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]; |
86 | MyArgv[0] = "networksettings2"; | 88 | MyArgv[0] = "networksettings2"; |
87 | MyArgv[1] = "--prompt"; | 89 | MyArgv[1] = "--prompt"; |
88 | MyArgv[2] = argv[1]; | 90 | MyArgv[2] = argv[1]; |
89 | MyArgv[3] = NULL; | 91 | MyArgv[3] = NULL; |
90 | NSResources->system().execAsUser( S, MyArgv ); | 92 | NSResources->system().execAsUser( S, MyArgv ); |
91 | // if we come here , failed | 93 | // if we come here , failed |
92 | printf( "%s-cNN-disallowed", argv[1] ); | 94 | printf( "%s-cNN-disallowed", argv[1] ); |
93 | } | 95 | } |
94 | } | 96 | } |
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 { |
107 | printf( "%s-cNN-disallowed", argv[1] ); | 111 | printf( "%s-cNN-disallowed", argv[1] ); |
108 | } | 112 | } |
109 | } | 113 | } |
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_ |
116 | W->showMaximized(); | 121 | W->showMaximized(); |
117 | #else | 122 | #else |
118 | W->resize( W->sizeHint() ); | 123 | W->resize( W->sizeHint() ); |
119 | #endif | 124 | #endif |
120 | rv = TheApp->exec(); | 125 | rv = TheApp->exec(); |
121 | delete W; | 126 | delete W; |
122 | } | 127 | } |
123 | break; | 128 | break; |
124 | } | 129 | } |
125 | 130 | ||
131 | LogClose(); | ||
132 | |||
126 | return rv; | 133 | return rv; |
127 | } | 134 | } |
128 | 135 | ||
129 | #endif | 136 | #endif |
130 | 137 | ||
131 | 138 | ||
132 | // main.cpp | 139 | // main.cpp |
133 | 140 | ||
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 | |||
@@ -1,66 +1,78 @@ | |||
1 | #include <system.h> | 1 | #include <system.h> |
2 | #include <asdevice.h> | 2 | #include <asdevice.h> |
3 | #include "networkrun.h" | 3 | #include "networkrun.h" |
4 | 4 | ||
5 | void NetworkRun::detectState( NodeCollection * NC ) { | 5 | void NetworkRun::detectState( NodeCollection * NC ) { |
6 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 6 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); |
7 | AsDevice * Next = RI->asDevice(); | 7 | AsDevice * Next = RI->asDevice(); |
8 | InterfaceInfo * II = Next->assignedInterface(); | 8 | InterfaceInfo * II = Next->assignedInterface(); |
9 | 9 | ||
10 | if( II ) { | 10 | if( II ) { |
11 | // device has assigned interface | 11 | // device has assigned interface |
12 | NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); | 12 | NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); |
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 | } |
19 | 20 | ||
20 | bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) { | 21 | bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) { |
21 | // we handle UP and DOWN | 22 | // we handle UP and DOWN |
22 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 23 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); |
23 | AsDevice * Next = RI->asDevice(); | 24 | AsDevice * Next = RI->asDevice(); |
24 | InterfaceInfo * II = Next->assignedInterface(); | 25 | InterfaceInfo * II = Next->assignedInterface(); |
25 | 26 | ||
26 | if( A == Up ) { | 27 | if( A == Up ) { |
27 | // we can bring UP if lower level is available | 28 | // we can bring UP if lower level is available |
28 | if( NC->currentState() == Available || Force ) { | 29 | if( NC->currentState() == Available || Force ) { |
29 | QString S; | 30 | QString S; |
30 | S.sprintf( "ifup %s=%s-c%d-allowed", | 31 | S.sprintf( "ifup %s=%s-c%d-allowed", |
31 | II->Name.latin1(), II->Name.latin1(), | 32 | II->Name.latin1(), II->Name.latin1(), |
32 | connection()->number() ); | 33 | connection()->number() ); |
33 | NSResources->system().runAsRoot( S ); | 34 | NSResources->system().runAsRoot( S ); |
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 ) { |
51 | // we handle UP and DOWN | 63 | // we handle UP and DOWN |
52 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 64 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); |
53 | 65 | ||
54 | if( A == Up ) { | 66 | if( A == Up ) { |
55 | return ( Curr == Available ); | 67 | return ( Curr == Available ); |
56 | } else if( A == Down ) { | 68 | } else if( A == Down ) { |
57 | return ( Curr == IsUp ); | 69 | return ( Curr == IsUp ); |
58 | } | 70 | } |
59 | // delegate | 71 | // delegate |
60 | return RI->canSetState( Curr, A ); | 72 | return RI->canSetState( Curr, A ); |
61 | } | 73 | } |
62 | 74 | ||
63 | bool NetworkRun::handlesInterface( const QString & S ) { | 75 | bool NetworkRun::handlesInterface( const QString & S ) { |
64 | // donno -> pass deeper | 76 | // donno -> pass deeper |
65 | return netNode()->nextNode()->runtime()->handlesInterface(S); | 77 | return netNode()->nextNode()->runtime()->handlesInterface(S); |
66 | } | 78 | } |
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,449 +1,475 @@ | |||
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> |
5 | #include <qgroupbox.h> | 6 | #include <qgroupbox.h> |
6 | #include <qtimer.h> | 7 | #include <qtimer.h> |
7 | #include <qlistbox.h> | 8 | #include <qlistbox.h> |
8 | #include <qmessagebox.h> | 9 | #include <qmessagebox.h> |
9 | #include <qlabel.h> | 10 | #include <qlabel.h> |
10 | #include <qiconview.h> | 11 | #include <qiconview.h> |
11 | #include <qtimer.h> | 12 | #include <qtimer.h> |
12 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
13 | #include <qtoolbutton.h> | 14 | #include <qtoolbutton.h> |
14 | 15 | ||
15 | #include <asdevice.h> | 16 | #include <asdevice.h> |
16 | #include "networksettings.h" | 17 | #include "networksettings.h" |
17 | #include "netnode.h" | 18 | #include "netnode.h" |
18 | #include "editconnection.h" | 19 | #include "editconnection.h" |
19 | 20 | ||
20 | NetworkSettings::NetworkSettings( QWidget *parent, | 21 | NetworkSettings::NetworkSettings( QWidget *parent, |
21 | const char *name, | 22 | const char *name, |
22 | WFlags fl ) : NetworkSettingsGUI(parent,name,fl), | 23 | WFlags fl ) : NetworkSettingsGUI(parent,name,fl), |
23 | NSD() { | 24 | NSD() { |
24 | 25 | ||
25 | UpdateTimer = new QTimer( this ); | 26 | UpdateTimer = new QTimer( this ); |
26 | 27 | ||
27 | // set pixmaps | 28 | // set pixmaps |
28 | Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); | 29 | Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); |
29 | Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) ); | 30 | Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) ); |
30 | CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) ); | 31 | CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) ); |
31 | Enable_TB->setPixmap( NSResources->getPixmap( "disabled" ) ); | 32 | Enable_TB->setPixmap( NSResources->getPixmap( "disabled" ) ); |
32 | GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) ); | 33 | GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) ); |
33 | 34 | ||
34 | Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) ); | 35 | Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) ); |
35 | Disconnect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) ); | 36 | Disconnect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) ); |
36 | 37 | ||
37 | On_TB->setPixmap( NSResources->getPixmap( "off" ) ); | 38 | On_TB->setPixmap( NSResources->getPixmap( "off" ) ); |
38 | 39 | ||
39 | SLOT_ToProfile(); | 40 | SLOT_ToProfile(); |
40 | 41 | ||
41 | // populate main Listbox | 42 | // populate main Listbox |
42 | Profiles_LB->clear(); | 43 | Profiles_LB->clear(); |
43 | { Name2Connection_t & M = NSResources->connections(); | 44 | { Name2Connection_t & M = NSResources->connections(); |
44 | NodeCollection * NC; | 45 | NodeCollection * NC; |
45 | // for all connections | 46 | // for all connections |
46 | for( QDictIterator<NodeCollection> it(M); | 47 | for( QDictIterator<NodeCollection> it(M); |
47 | it.current(); | 48 | it.current(); |
48 | ++it ) { | 49 | ++it ) { |
49 | NC = it.current(); | 50 | NC = it.current(); |
50 | Profiles_LB->insertItem( NC->devicePixmap(), | 51 | Profiles_LB->insertItem( NC->devicePixmap(), |
51 | NC->name() ); | 52 | NC->name() ); |
52 | } | 53 | } |
53 | } | 54 | } |
54 | 55 | ||
55 | if( Profiles_LB->count() ) { | 56 | if( Profiles_LB->count() ) { |
56 | Profiles_LB->setSelected( 0, TRUE ); | 57 | Profiles_LB->setSelected( 0, TRUE ); |
57 | } | 58 | } |
58 | 59 | ||
59 | // if no profiles -> auto popup editing | 60 | // if no profiles -> auto popup editing |
60 | if( NSResources->connections().count() == 0 ) { | 61 | if( NSResources->connections().count() == 0 ) { |
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() ) ); |
67 | 72 | ||
68 | /* Add QCopChannel */ | 73 | /* Add QCopChannel */ |
69 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), | 74 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
70 | this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) ); | 75 | this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) ); |
71 | } | 76 | } |
72 | 77 | ||
73 | NetworkSettings::~NetworkSettings() { | 78 | NetworkSettings::~NetworkSettings() { |
74 | QString S; | 79 | QString S; |
75 | 80 | ||
76 | S = NSD.generateSettings(); | 81 | S = NSD.generateSettings(); |
77 | if( ! S.isEmpty() ) { | 82 | if( ! S.isEmpty() ) { |
78 | QMessageBox::warning( | 83 | QMessageBox::warning( |
79 | 0, | 84 | 0, |
80 | tr( "In System Config" ), | 85 | tr( "In System Config" ), |
81 | S | 86 | S |
82 | ); | 87 | ); |
83 | } | 88 | } |
84 | 89 | ||
85 | S = NSD.saveSettings(); | 90 | S = NSD.saveSettings(); |
86 | if( ! S.isEmpty() ) { | 91 | if( ! S.isEmpty() ) { |
87 | // problem saving | 92 | // problem saving |
88 | QMessageBox::warning( | 93 | QMessageBox::warning( |
89 | 0, | 94 | 0, |
90 | tr( "Saving setup" ), S ); | 95 | tr( "Saving setup" ), S ); |
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 | ||
97 | if( LBI ) { | 108 | if( LBI ) { |
98 | NodeCollection * NC; | 109 | NodeCollection * NC; |
99 | NSResources->system().probeInterfaces(); | 110 | NSResources->system().probeInterfaces(); |
100 | // update current selection only | 111 | // update current selection only |
101 | NC = NSResources->findConnection( LBI->text() ); | 112 | NC = NSResources->findConnection( LBI->text() ); |
102 | if( NC ) { | 113 | if( NC ) { |
103 | State_t OldS = NC->state(); | 114 | State_t OldS = NC->state(); |
104 | State_t NewS = NC->state(1); | 115 | State_t NewS = NC->state(1); |
105 | if( OldS != NewS ) { | 116 | if( OldS != NewS ) { |
106 | updateProfileState( LBI ); | 117 | updateProfileState( LBI ); |
107 | } | 118 | } |
108 | } | 119 | } |
109 | } | 120 | } |
110 | 121 | ||
111 | 122 | ||
112 | /* -> LATER !! | 123 | /* -> LATER !! |
113 | bool is; | 124 | bool is; |
114 | NodeCollection * NC; | 125 | NodeCollection * NC; |
115 | 126 | ||
116 | for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) { | 127 | for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) { |
117 | NC = NSResources->findConnection( Profiles_LB->text(i) ); | 128 | NC = NSResources->findConnection( Profiles_LB->text(i) ); |
118 | if( NC ) { | 129 | if( NC ) { |
119 | State_t OldS = NC->state(); | 130 | State_t OldS = NC->state(); |
120 | State_t NewS = NC->state(1); | 131 | State_t NewS = NC->state(1); |
121 | if( OldS != NewS ) { | 132 | if( OldS != NewS ) { |
122 | is = Profiles_LB->isSelected(i); | 133 | is = Profiles_LB->isSelected(i); |
123 | Profiles_LB->changeItem( NC->statePixmap(NewS), | 134 | Profiles_LB->changeItem( NC->statePixmap(NewS), |
124 | NC->name(), | 135 | NC->name(), |
125 | i ); | 136 | i ); |
126 | if( is ) { | 137 | if( is ) { |
127 | Profiles_LB->setSelected( i, TRUE ); | 138 | Profiles_LB->setSelected( i, TRUE ); |
128 | } | 139 | } |
129 | } | 140 | } |
130 | } | 141 | } |
131 | } | 142 | } |
132 | if( ci >= 0 ) | 143 | if( ci >= 0 ) |
133 | Profiles_LB->setCurrentItem( ci ); | 144 | Profiles_LB->setCurrentItem( ci ); |
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 | } |
140 | 154 | ||
141 | void NetworkSettings::SLOT_DeleteNode( void ) { | 155 | void NetworkSettings::SLOT_DeleteNode( void ) { |
142 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); | 156 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
143 | 157 | ||
144 | if ( ! LBI ) | 158 | if ( ! LBI ) |
145 | return; | 159 | return; |
146 | 160 | ||
147 | if( QMessageBox::warning( | 161 | if( QMessageBox::warning( |
148 | 0, | 162 | 0, |
149 | tr( "Removing profile" ), | 163 | tr( "Removing profile" ), |
150 | tr( "Remove selected profile ?" ), | 164 | tr( "Remove selected profile ?" ), |
151 | 1, 0 ) == 1 ) { | 165 | 1, 0 ) == 1 ) { |
152 | NSResources->removeConnection( LBI->text() ); | 166 | NSResources->removeConnection( LBI->text() ); |
153 | delete LBI; | 167 | delete LBI; |
154 | setModified( 1 ); | 168 | setModified( 1 ); |
155 | NSD.forceGeneration(1); | 169 | NSD.forceGeneration(1); |
156 | } | 170 | } |
157 | } | 171 | } |
158 | 172 | ||
159 | void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { | 173 | void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { |
160 | QString OldName = ""; | 174 | QString OldName = ""; |
161 | EditConnection EC( this ); | 175 | EditConnection EC( this ); |
162 | 176 | ||
163 | if( LBI ) { | 177 | if( LBI ) { |
164 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); | 178 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); |
165 | if( ! NC ) { | 179 | if( ! NC ) { |
166 | return; | 180 | return; |
167 | } | 181 | } |
168 | OldName = NC->name(); | 182 | OldName = NC->name(); |
169 | EC.setConnection( NC ); | 183 | EC.setConnection( NC ); |
170 | } | 184 | } |
171 | 185 | ||
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 ) { |
178 | // toplevel item -> store | 194 | // toplevel item -> store |
179 | NodeCollection * NC = EC.connection(); | 195 | NodeCollection * NC = EC.connection(); |
180 | if( NC->isModified() ) { | 196 | if( NC->isModified() ) { |
181 | setModified( 1 ); | 197 | setModified( 1 ); |
182 | if( LBI ) { | 198 | if( LBI ) { |
183 | if( NC->name() != OldName ) { | 199 | if( NC->name() != OldName ) { |
184 | // find if new name is free | 200 | // find if new name is free |
185 | NodeCollection * LCN = NSResources->findConnection( | 201 | NodeCollection * LCN = NSResources->findConnection( |
186 | NC->name() ); | 202 | NC->name() ); |
187 | if( LCN ) { | 203 | if( LCN ) { |
188 | QMessageBox::warning( | 204 | QMessageBox::warning( |
189 | 0, | 205 | 0, |
190 | tr( "In System Config" ), | 206 | tr( "In System Config" ), |
191 | tr( "Name %1 already exists" ).arg(NC->name()) | 207 | tr( "Name %1 already exists" ).arg(NC->name()) |
192 | ); | 208 | ); |
193 | continue; // restart exec | 209 | continue; // restart exec |
194 | } // else new name | 210 | } // else new name |
195 | // new name -> remove item | 211 | // new name -> remove item |
196 | NSResources->removeConnection( OldName ); | 212 | NSResources->removeConnection( OldName ); |
197 | NSResources->addConnection( NC ); | 213 | NSResources->addConnection( NC ); |
198 | } // else not changed | 214 | } // else not changed |
199 | 215 | ||
200 | // must add it here since change will trigger event | 216 | // must add it here since change will trigger event |
201 | Profiles_LB->changeItem( NC->devicePixmap(), | 217 | Profiles_LB->changeItem( NC->devicePixmap(), |
202 | NC->name(), | 218 | NC->name(), |
203 | Profiles_LB->index( LBI ) | 219 | Profiles_LB->index( LBI ) |
204 | ); | 220 | ); |
205 | } else { | 221 | } else { |
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 | } |
213 | updateProfileState( LBI ); | 229 | updateProfileState( LBI ); |
214 | } | 230 | } |
215 | } else { | 231 | } else { |
216 | // cancelled : reset connection | 232 | // cancelled : reset connection |
217 | if( LBI ) { | 233 | if( LBI ) { |
218 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); | 234 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); |
219 | NC->reassign(); | 235 | NC->reassign(); |
220 | } | 236 | } |
221 | } | 237 | } |
222 | break; | 238 | break; |
223 | } | 239 | } |
224 | // reenable | 240 | // reenable |
225 | UpdateTimer->start( 5000 ); | 241 | UpdateTimer->start( 5000 ); |
226 | } | 242 | } |
227 | 243 | ||
228 | void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { | 244 | void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { |
229 | if( LBI == 0 ) | 245 | if( LBI == 0 ) |
230 | return; | 246 | return; |
231 | 247 | ||
232 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); | 248 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); |
233 | 249 | ||
234 | // is button possible | 250 | // is button possible |
235 | bool EnabledPossible, OnPossible, ConnectPossible; | 251 | bool EnabledPossible, OnPossible, ConnectPossible; |
236 | // is button On or Off | 252 | // is button On or Off |
237 | bool DisabledOn, OnOn, ConnectOn; | 253 | bool DisabledOn, OnOn, ConnectOn; |
238 | 254 | ||
239 | EnabledPossible = OnPossible = ConnectPossible = 1; | 255 | EnabledPossible = OnPossible = ConnectPossible = 1; |
240 | DisabledOn = 1; | 256 | DisabledOn = 1; |
241 | OnOn = ConnectOn = 0; | 257 | OnOn = ConnectOn = 0; |
242 | 258 | ||
243 | switch( NC->state() ) { | 259 | switch( NC->state() ) { |
244 | case Unknown : | 260 | case Unknown : |
245 | // cannot occur here | 261 | // cannot occur here |
246 | break; | 262 | break; |
247 | case Unchecked : | 263 | case Unchecked : |
248 | case Unavailable : | 264 | case Unavailable : |
249 | // cannot do anything but recheck | 265 | // cannot do anything but recheck |
250 | EnabledPossible = OnPossible = ConnectPossible = 0; | 266 | EnabledPossible = OnPossible = ConnectPossible = 0; |
251 | break; | 267 | break; |
252 | case Disabled : | 268 | case Disabled : |
253 | OnPossible = ConnectPossible = 0; | 269 | OnPossible = ConnectPossible = 0; |
254 | break; | 270 | break; |
255 | case Off : | 271 | case Off : |
256 | DisabledOn = 0; | 272 | DisabledOn = 0; |
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 ); |
271 | Connect_TB->setEnabled( ConnectPossible ); | 293 | Connect_TB->setEnabled( ConnectPossible ); |
272 | 294 | ||
273 | Enable_TB->setOn( DisabledOn ); | 295 | Enable_TB->setOn( DisabledOn ); |
274 | On_TB->setOn( OnOn ); | 296 | On_TB->setOn( OnOn ); |
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 ) { |
288 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); | 309 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
289 | if ( ! LBI ) | 310 | if ( ! LBI ) |
290 | return; | 311 | return; |
291 | updateProfileState( LBI ); | 312 | updateProfileState( LBI ); |
292 | } | 313 | } |
293 | 314 | ||
294 | void NetworkSettings::updateProfileState( QListBoxItem * LBI ) { | 315 | void NetworkSettings::updateProfileState( QListBoxItem * LBI ) { |
295 | if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) { | 316 | if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) { |
296 | SLOT_ShowNode( LBI ); | 317 | SLOT_ShowNode( LBI ); |
297 | } | 318 | } |
298 | } | 319 | } |
299 | 320 | ||
300 | void NetworkSettings::SLOT_GenerateConfig( void ) { | 321 | void NetworkSettings::SLOT_GenerateConfig( void ) { |
301 | QString S = NSD.generateSettings( TRUE ); | 322 | QString S = NSD.generateSettings( TRUE ); |
302 | 323 | ||
303 | if( ! S.isEmpty() ) { | 324 | if( ! S.isEmpty() ) { |
304 | QMessageBox::warning( | 325 | QMessageBox::warning( |
305 | 0, | 326 | 0, |
306 | tr( "Generating system configuration" ), | 327 | tr( "Generating system configuration" ), |
307 | S | 328 | S |
308 | ); | 329 | ); |
309 | } | 330 | } |
310 | } | 331 | } |
311 | 332 | ||
312 | void NetworkSettings::SLOT_Enable( void ) { | 333 | void NetworkSettings::SLOT_Enable( void ) { |
313 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); | 334 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
314 | QString Msg; | 335 | QString Msg; |
315 | if ( ! LBI ) | 336 | if ( ! LBI ) |
316 | return; | 337 | return; |
317 | 338 | ||
318 | NodeCollection * NC = | 339 | NodeCollection * NC = |
319 | NSResources->findConnection( LBI->text() ); | 340 | NSResources->findConnection( LBI->text() ); |
320 | 341 | ||
321 | bool rv; | 342 | bool rv; |
322 | switch( NC->state() ) { | 343 | switch( NC->state() ) { |
323 | case Disabled : | 344 | case Disabled : |
324 | Msg = tr( "Cannot enable profile" ); | 345 | Msg = tr( "Cannot enable profile" ); |
325 | rv = NC->setState( Enable ); | 346 | rv = NC->setState( Enable ); |
326 | break; | 347 | break; |
327 | default : | 348 | default : |
328 | Msg = tr( "Cannot disable profile" ); | 349 | Msg = tr( "Cannot disable profile" ); |
329 | rv = NC->setState( Disable ); | 350 | rv = NC->setState( Disable ); |
330 | break; | 351 | break; |
331 | } | 352 | } |
332 | 353 | ||
333 | if( ! rv ) { | 354 | if( ! rv ) { |
334 | QMessageBox::warning( | 355 | QMessageBox::warning( |
335 | 0, | 356 | 0, |
336 | tr( "Activating profile" ), | 357 | tr( "Activating profile" ), |
337 | Msg ); | 358 | Msg ); |
338 | return; | 359 | return; |
339 | } | 360 | } |
340 | updateProfileState( LBI ); | 361 | updateProfileState( LBI ); |
341 | } | 362 | } |
342 | 363 | ||
343 | void NetworkSettings::SLOT_On( void ) { | 364 | void NetworkSettings::SLOT_On( void ) { |
344 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); | 365 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
345 | 366 | ||
346 | if ( ! LBI ) | 367 | if ( ! LBI ) |
347 | return; | 368 | return; |
348 | 369 | ||
349 | NodeCollection * NC = | 370 | NodeCollection * NC = |
350 | NSResources->findConnection( LBI->text() ); | 371 | NSResources->findConnection( LBI->text() ); |
351 | 372 | ||
352 | bool rv; | 373 | bool rv; |
353 | switch( NC->state() ) { | 374 | switch( NC->state() ) { |
354 | case Off : | 375 | case Off : |
355 | // activate interface | 376 | // activate interface |
356 | rv = NC->setState( Activate ); | 377 | rv = NC->setState( Activate ); |
357 | break; | 378 | break; |
358 | case Available : // deactivate | 379 | case Available : // deactivate |
359 | case IsUp : // deactivate (will also bring down if needed) | 380 | case IsUp : // deactivate (will also bring down if needed) |
360 | rv = NC->setState( Deactivate ); | 381 | rv = NC->setState( Deactivate ); |
361 | break; | 382 | break; |
362 | default : | 383 | default : |
363 | // others no change | 384 | // others no change |
364 | return; | 385 | return; |
365 | } | 386 | } |
366 | 387 | ||
367 | if( ! rv ) { | 388 | if( ! rv ) { |
368 | QMessageBox::warning( | 389 | QMessageBox::warning( |
369 | 0, | 390 | 0, |
370 | tr( "Activating profile" ), | 391 | tr( "Activating profile" ), |
371 | tr( "Cannot enable profile" ) ); | 392 | tr( "Cannot enable profile" ) ); |
372 | return; | 393 | return; |
373 | } | 394 | } |
374 | updateProfileState( LBI ); | 395 | updateProfileState( LBI ); |
375 | } | 396 | } |
376 | 397 | ||
377 | void NetworkSettings::SLOT_Connect( void ) { | 398 | void NetworkSettings::SLOT_Connect( void ) { |
378 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); | 399 | QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); |
379 | 400 | ||
380 | if ( ! LBI ) | 401 | if ( ! LBI ) |
381 | return; | 402 | return; |
382 | 403 | ||
383 | NodeCollection * NC = | 404 | NodeCollection * NC = |
384 | NSResources->findConnection( LBI->text() ); | 405 | NSResources->findConnection( LBI->text() ); |
385 | 406 | ||
386 | bool rv = 1 ; | 407 | bool rv = 1 ; |
387 | switch( NC->state() ) { | 408 | switch( NC->state() ) { |
388 | case IsUp : | 409 | case IsUp : |
389 | // down interface | 410 | // down interface |
390 | rv = NC->setState( Down ); | 411 | rv = NC->setState( Down ); |
391 | break; | 412 | break; |
392 | case Available : | 413 | case Available : |
393 | // up interface | 414 | // up interface |
394 | rv = NC->setState( Up ); | 415 | rv = NC->setState( Up ); |
395 | break; | 416 | break; |
396 | case Off : | 417 | case Off : |
397 | // activate and bring up | 418 | // activate and bring up |
398 | rv = ( NC->setState( Activate ) && | 419 | rv = ( NC->setState( Activate ) && |
399 | NC->setState( Up ) ); | 420 | NC->setState( Up ) ); |
400 | break; | 421 | break; |
401 | default : | 422 | default : |
402 | // others no change | 423 | // others no change |
403 | break; | 424 | break; |
404 | } | 425 | } |
405 | 426 | ||
406 | if( ! rv ) { | 427 | if( ! rv ) { |
407 | QMessageBox::warning( | 428 | QMessageBox::warning( |
408 | 0, | 429 | 0, |
409 | tr( "Activating profile" ), | 430 | tr( "Activating profile" ), |
410 | tr( "Cannot enable profile" ) ); | 431 | tr( "Cannot enable profile" ) ); |
411 | } | 432 | } |
412 | 433 | ||
413 | // we do not update the GUI but wait for the REAL upping of the device | 434 | // we do not update the GUI but wait for the REAL upping of the device |
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 ) |
420 | return; | 442 | return; |
421 | 443 | ||
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 ) { |
429 | Profile_GB->hide(); | 455 | Profile_GB->hide(); |
430 | Messages_GB->show(); | 456 | Messages_GB->show(); |
431 | } | 457 | } |
432 | 458 | ||
433 | void NetworkSettings::SLOT_ToProfile( void ) { | 459 | void NetworkSettings::SLOT_ToProfile( void ) { |
434 | Profile_GB->show(); | 460 | Profile_GB->show(); |
435 | Messages_GB->hide(); | 461 | Messages_GB->hide(); |
436 | } | 462 | } |
437 | 463 | ||
438 | void NetworkSettings::SLOT_QCopMessage(const QCString &msg, const QByteArray &data) { | 464 | void NetworkSettings::SLOT_QCopMessage(const QCString &msg, const QByteArray &data) { |
439 | QDataStream stream( data, IO_ReadOnly ); | 465 | QDataStream stream( data, IO_ReadOnly ); |
440 | 466 | ||
441 | if( msg == "raise" ) { | 467 | if( msg == "raise" ) { |
442 | raise(); | 468 | raise(); |
443 | return; | 469 | return; |
444 | } /* if ( msg == "someMessage(int,int,int)" ) { | 470 | } /* if ( msg == "someMessage(int,int,int)" ) { |
445 | int a,b,c; | 471 | int a,b,c; |
446 | stream >> a >> b >> c; | 472 | stream >> a >> b >> c; |
447 | ... | 473 | ... |
448 | } */ | 474 | } */ |
449 | } | 475 | } |
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 | |||
@@ -1,52 +1,54 @@ | |||
1 | #include "nsdata.h" | 1 | #include "nsdata.h" |
2 | #include "networksettingsGUI.h" | 2 | #include "networksettingsGUI.h" |
3 | #include "resources.h" | 3 | #include "resources.h" |
4 | 4 | ||
5 | class ANetNode; | 5 | class ANetNode; |
6 | class ANetNodeInstance; | 6 | class ANetNodeInstance; |
7 | class QTimer; | 7 | class QTimer; |
8 | class QListBoxItem; | 8 | class QListBoxItem; |
9 | 9 | ||
10 | class NetworkSettings : public NetworkSettingsGUI { | 10 | class NetworkSettings : public NetworkSettingsGUI { |
11 | 11 | ||
12 | Q_OBJECT | 12 | Q_OBJECT |
13 | 13 | ||
14 | public : | 14 | public : |
15 | 15 | ||
16 | NetworkSettings( QWidget *parent=0, | 16 | NetworkSettings( QWidget *parent=0, |
17 | const char *name=0, | 17 | const char *name=0, |
18 | WFlags fl = 0 ); | 18 | WFlags fl = 0 ); |
19 | ~NetworkSettings( void ); | 19 | ~NetworkSettings( void ); |
20 | 20 | ||
21 | static QString appName( void ) | 21 | static QString appName( void ) |
22 | { return QString::fromLatin1("networksettings"); } | 22 | { return QString::fromLatin1("networksettings"); } |
23 | 23 | ||
24 | bool isModified( void ) | 24 | bool isModified( void ) |
25 | { return NSD.isModified(); } | 25 | { return NSD.isModified(); } |
26 | void setModified( bool m ) | 26 | void setModified( bool m ) |
27 | { NSD.setModified( m ); } | 27 | { NSD.setModified( m ); } |
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 * ); |
34 | void SLOT_EditNode( QListBoxItem * ); | 35 | void SLOT_EditNode( QListBoxItem * ); |
35 | void SLOT_CheckState( void ); | 36 | void SLOT_CheckState( void ); |
36 | void SLOT_Enable( void ); | 37 | void SLOT_Enable( void ); |
37 | void SLOT_On( void ); | 38 | void SLOT_On( void ); |
38 | void SLOT_Connect( void ); | 39 | void SLOT_Connect( void ); |
39 | void SLOT_Disconnect( void ); | 40 | void SLOT_Disconnect( void ); |
40 | void SLOT_GenerateConfig( void ); | 41 | void SLOT_GenerateConfig( void ); |
41 | void SLOT_RefreshStates( void ); | 42 | void SLOT_RefreshStates( void ); |
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 | ||
48 | void updateProfileState( QListBoxItem * it ); | 50 | void updateProfileState( QListBoxItem * it ); |
49 | QTimer * UpdateTimer; | 51 | QTimer * UpdateTimer; |
50 | NetworkSettingsData NSD; | 52 | NetworkSettingsData NSD; |
51 | 53 | ||
52 | }; | 54 | }; |
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 | |||
@@ -1,20 +1,22 @@ | |||
1 | #ifndef ASFULLSETUP_H | 1 | #ifndef ASFULLSETUP_H |
2 | #define ASFULLSETUP_H | 2 | #define ASFULLSETUP_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | 5 | ||
6 | // pure virtual (component oriented) interface of any | 6 | // pure virtual (component oriented) interface of any |
7 | // plugin that offers a full setup | 7 | // plugin that offers a full setup |
8 | class AsFullSetup : public RuntimeInfo { | 8 | class AsFullSetup : public RuntimeInfo { |
9 | 9 | ||
10 | public : | 10 | public : |
11 | 11 | ||
12 | AsFullSetup( ANetNodeInstance * NNI ) : | 12 | AsFullSetup( ANetNodeInstance * NNI ) : |
13 | RuntimeInfo( NNI ) { | 13 | RuntimeInfo( NNI ) { |
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 | ||
20 | #endif | 22 | #endif |
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 | |||
@@ -1,310 +1,312 @@ | |||
1 | #include <time.h> | 1 | #include <time.h> |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <qpainter.h> | 3 | #include <qpainter.h> |
4 | #include <qbitmap.h> | 4 | #include <qbitmap.h> |
5 | #include <qtextstream.h> | 5 | #include <qtextstream.h> |
6 | #include <qpixmap.h> | 6 | #include <qpixmap.h> |
7 | 7 | ||
8 | #include "resources.h" | 8 | #include "resources.h" |
9 | #include "netnode.h" | 9 | #include "netnode.h" |
10 | 10 | ||
11 | #include "asdevice.h" | 11 | #include "asdevice.h" |
12 | #include "asline.h" | 12 | #include "asline.h" |
13 | #include "asconnection.h" | 13 | #include "asconnection.h" |
14 | #include "asfullsetup.h" | 14 | #include "asfullsetup.h" |
15 | 15 | ||
16 | QString & deQuote( QString & X ) { | 16 | QString & deQuote( QString & X ) { |
17 | if( X[0] == '"' ) { | 17 | if( X[0] == '"' ) { |
18 | // remove end and trailing "" and \x -> x | 18 | // remove end and trailing "" and \x -> x |
19 | QChar R; | 19 | QChar R; |
20 | long idx; | 20 | long idx; |
21 | idx = X.length()-1; | 21 | idx = X.length()-1; |
22 | X = X.mid( 1, idx ); | 22 | X = X.mid( 1, idx ); |
23 | 23 | ||
24 | idx = 0; | 24 | idx = 0; |
25 | while( ( idx = X.find( '\\', idx ) ) >= 0 ) { | 25 | while( ( idx = X.find( '\\', idx ) ) >= 0 ) { |
26 | R = X.at( idx + 1 ); | 26 | R = X.at( idx + 1 ); |
27 | X.replace( idx, 2, &R, 1 ); | 27 | X.replace( idx, 2, &R, 1 ); |
28 | } | 28 | } |
29 | X = X.left( X.length()-1 ); | 29 | X = X.left( X.length()-1 ); |
30 | } | 30 | } |
31 | return X; | 31 | return X; |
32 | } | 32 | } |
33 | 33 | ||
34 | QString quote( QString X ) { | 34 | QString quote( QString X ) { |
35 | if( X.find( QRegExp( "[ \n\"\\\t]" ) ) >= 0 ) { | 35 | if( X.find( QRegExp( "[ \n\"\\\t]" ) ) >= 0 ) { |
36 | // need to quote this | 36 | // need to quote this |
37 | QString OutString = "\""; | 37 | QString OutString = "\""; |
38 | 38 | ||
39 | X.replace( QRegExp("\""), "\\\"" ); | 39 | X.replace( QRegExp("\""), "\\\"" ); |
40 | X.replace( QRegExp("\\"), "\\\\" ); | 40 | X.replace( QRegExp("\\"), "\\\\" ); |
41 | X.replace( QRegExp(" "), "\\ " ); | 41 | X.replace( QRegExp(" "), "\\ " ); |
42 | 42 | ||
43 | OutString += X; | 43 | OutString += X; |
44 | OutString += "\""; | 44 | OutString += "\""; |
45 | X = OutString; | 45 | X = OutString; |
46 | } | 46 | } |
47 | return X; | 47 | return X; |
48 | } | 48 | } |
49 | 49 | ||
50 | 50 | ||
51 | // | 51 | // |
52 | // | 52 | // |
53 | // ANETNODE | 53 | // ANETNODE |
54 | // | 54 | // |
55 | // | 55 | // |
56 | 56 | ||
57 | void ANetNode::saveAttributes( QTextStream & TS ) { | 57 | void ANetNode::saveAttributes( QTextStream & TS ) { |
58 | saveSpecificAttribute( TS ); | 58 | saveSpecificAttribute( TS ); |
59 | } | 59 | } |
60 | 60 | ||
61 | void ANetNode::setAttribute( QString & Attr, QString & Value ){ | 61 | void ANetNode::setAttribute( QString & Attr, QString & Value ){ |
62 | setSpecificAttribute( Attr, Value ); | 62 | setSpecificAttribute( Attr, Value ); |
63 | } | 63 | } |
64 | 64 | ||
65 | // | 65 | // |
66 | // | 66 | // |
67 | // ANETNODEINSTANCE | 67 | // ANETNODEINSTANCE |
68 | // | 68 | // |
69 | // | 69 | // |
70 | 70 | ||
71 | long ANetNodeInstance::InstanceCounter = -1; | 71 | long ANetNodeInstance::InstanceCounter = -1; |
72 | 72 | ||
73 | void ANetNodeInstance::initialize( void ) { | 73 | void ANetNodeInstance::initialize( void ) { |
74 | if( InstanceCounter == -1 ) | 74 | if( InstanceCounter == -1 ) |
75 | InstanceCounter = time(0); | 75 | InstanceCounter = time(0); |
76 | // set name | 76 | // set name |
77 | QString N; | 77 | QString N; |
78 | N.sprintf( "-%ld", InstanceCounter++ ); | 78 | N.sprintf( "-%ld", InstanceCounter++ ); |
79 | N.prepend( NodeType->name() ); | 79 | N.prepend( NodeType->name() ); |
80 | setName( N.latin1() ); | 80 | setName( N.latin1() ); |
81 | } | 81 | } |
82 | 82 | ||
83 | void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ | 83 | void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ |
84 | if( Attr == "name" ) { | 84 | if( Attr == "name" ) { |
85 | setName( Value.latin1() ); | 85 | setName( Value.latin1() ); |
86 | } else { | 86 | } else { |
87 | setSpecificAttribute( Attr, Value ); | 87 | setSpecificAttribute( Attr, Value ); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void ANetNodeInstance::saveAttributes( QTextStream & TS ) { | 91 | void ANetNodeInstance::saveAttributes( QTextStream & TS ) { |
92 | TS << "name=" << name() << endl; | 92 | TS << "name=" << name() << endl; |
93 | saveSpecificAttribute( TS ); | 93 | saveSpecificAttribute( TS ); |
94 | } | 94 | } |
95 | 95 | ||
96 | ANetNodeInstance * ANetNodeInstance::nextNode( void ) { | 96 | ANetNodeInstance * ANetNodeInstance::nextNode( void ) { |
97 | return connection()->findNext( this ); | 97 | return connection()->findNext( this ); |
98 | } | 98 | } |
99 | 99 | ||
100 | // | 100 | // |
101 | // | 101 | // |
102 | // NODECOLLECTION | 102 | // NODECOLLECTION |
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; |
111 | Name=""; | 109 | Name=""; |
112 | IsNew = 1; | 110 | IsNew = 1; |
113 | CurrentState = Unchecked; | 111 | CurrentState = Unchecked; |
114 | } | 112 | } |
115 | 113 | ||
116 | NodeCollection::NodeCollection( QTextStream & TS ) : | 114 | NodeCollection::NodeCollection( QTextStream & TS ) : |
117 | QList<ANetNodeInstance>() { | 115 | QList<ANetNodeInstance>() { |
118 | long idx; | 116 | long idx; |
119 | bool InError = 0; | 117 | bool InError = 0; |
120 | QString S, A, N; | 118 | QString S, A, N; |
121 | IsModified = 0; | 119 | IsModified = 0; |
122 | Index = -1; | 120 | Index = -1; |
123 | Name=""; | 121 | Name=""; |
124 | IsNew = 0; | 122 | IsNew = 0; |
125 | CurrentState = Unchecked; | 123 | CurrentState = Unchecked; |
126 | 124 | ||
127 | do { | 125 | do { |
128 | S = TS.readLine(); | 126 | S = TS.readLine(); |
129 | if( S.isEmpty() ) { | 127 | if( S.isEmpty() ) { |
130 | if( InError ) { | 128 | if( InError ) { |
131 | // remove all nodes | 129 | // remove all nodes |
132 | clear(); | 130 | clear(); |
133 | } | 131 | } |
134 | // empty line | 132 | // empty line |
135 | break; | 133 | break; |
136 | } | 134 | } |
137 | 135 | ||
138 | idx = S.find('='); | 136 | idx = S.find('='); |
139 | S.stripWhiteSpace(); | 137 | S.stripWhiteSpace(); |
140 | A = S.left( idx ); | 138 | A = S.left( idx ); |
141 | A.lower(); | 139 | A.lower(); |
142 | N = S.mid( idx+1, S.length() ); | 140 | N = S.mid( idx+1, S.length() ); |
143 | N.stripWhiteSpace(); | 141 | N.stripWhiteSpace(); |
144 | N = deQuote( N ); | 142 | N = deQuote( N ); |
145 | 143 | ||
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 ); |
152 | if( NNI && ! InError ) { | 151 | if( NNI && ! InError ) { |
153 | append( NSResources->findNodeInstance( N ) ); | 152 | append( NSResources->findNodeInstance( N ) ); |
154 | } else { | 153 | } else { |
155 | // could not find a node type -> collection invalid | 154 | // could not find a node type -> collection invalid |
156 | InError = 1; | 155 | InError = 1; |
157 | } | 156 | } |
158 | } | 157 | } |
159 | } while( 1 ); | 158 | } while( 1 ); |
160 | } | 159 | } |
161 | 160 | ||
162 | 161 | ||
163 | NodeCollection::~NodeCollection( void ) { | 162 | NodeCollection::~NodeCollection( void ) { |
164 | } | 163 | } |
165 | 164 | ||
166 | const QString & NodeCollection::description( void ) { | 165 | const QString & NodeCollection::description( void ) { |
167 | ANetNodeInstance * NNI = getToplevel(); | 166 | ANetNodeInstance * NNI = getToplevel(); |
168 | return (NNI) ? NNI->runtime()->asFullSetup()->description() : Name; | 167 | return (NNI) ? NNI->runtime()->asFullSetup()->description() : Name; |
169 | } | 168 | } |
170 | 169 | ||
171 | void NodeCollection::append( ANetNodeInstance * NNI ) { | 170 | void NodeCollection::append( ANetNodeInstance * NNI ) { |
172 | NNI->setConnection( this ); | 171 | NNI->setConnection( this ); |
173 | QList<ANetNodeInstance>::append( NNI ); | 172 | QList<ANetNodeInstance>::append( NNI ); |
174 | } | 173 | } |
175 | 174 | ||
176 | void NodeCollection::save( QTextStream & TS ) { | 175 | void NodeCollection::save( QTextStream & TS ) { |
177 | 176 | ||
178 | TS << "name=" << quote( Name ) << endl; | 177 | TS << "name=" << quote( Name ) << endl; |
179 | TS << "number=" << number() << endl; | 178 | TS << "number=" << number() << endl; |
180 | ANetNodeInstance * NNI; | 179 | ANetNodeInstance * NNI; |
181 | for( QListIterator<ANetNodeInstance> it(*this); | 180 | for( QListIterator<ANetNodeInstance> it(*this); |
182 | it.current(); | 181 | it.current(); |
183 | ++it ) { | 182 | ++it ) { |
184 | NNI = it.current(); | 183 | NNI = it.current(); |
185 | TS << "node=" << NNI->name() << endl; | 184 | TS << "node=" << NNI->name() << endl; |
186 | } | 185 | } |
187 | TS << endl; | 186 | TS << endl; |
188 | IsNew = 0; | 187 | IsNew = 0; |
189 | } | 188 | } |
190 | 189 | ||
191 | ANetNodeInstance * NodeCollection::getToplevel( void ) { | 190 | ANetNodeInstance * NodeCollection::getToplevel( void ) { |
192 | ANetNodeInstance * NNI = 0; | 191 | ANetNodeInstance * NNI = 0; |
193 | for( QListIterator<ANetNodeInstance> it(*this); | 192 | for( QListIterator<ANetNodeInstance> it(*this); |
194 | it.current(); | 193 | it.current(); |
195 | ++it ) { | 194 | ++it ) { |
196 | NNI = it.current(); | 195 | NNI = it.current(); |
197 | if( NNI->nodeClass()->isToplevel() ) | 196 | if( NNI->nodeClass()->isToplevel() ) |
198 | break; | 197 | break; |
199 | } | 198 | } |
200 | return NNI; | 199 | return NNI; |
201 | } | 200 | } |
202 | 201 | ||
203 | ANetNodeInstance * NodeCollection::findByName( const QString & S ) { | 202 | ANetNodeInstance * NodeCollection::findByName( const QString & S ) { |
204 | ANetNodeInstance * NNI = 0; | 203 | ANetNodeInstance * NNI = 0; |
205 | for( QListIterator<ANetNodeInstance> it(*this); | 204 | for( QListIterator<ANetNodeInstance> it(*this); |
206 | it.current(); | 205 | it.current(); |
207 | ++it ) { | 206 | ++it ) { |
208 | NNI = it.current(); | 207 | NNI = it.current(); |
209 | if( NNI->name() == S ) | 208 | if( NNI->name() == S ) |
210 | break; | 209 | break; |
211 | } | 210 | } |
212 | return NNI; | 211 | return NNI; |
213 | } | 212 | } |
214 | 213 | ||
215 | ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { | 214 | ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { |
216 | ANetNodeInstance * NNNI; | 215 | ANetNodeInstance * NNNI; |
217 | 216 | ||
218 | if( ! NNI ) | 217 | if( ! NNI ) |
219 | getToplevel(); | 218 | getToplevel(); |
220 | 219 | ||
221 | for( QListIterator<ANetNodeInstance> it(*this); | 220 | for( QListIterator<ANetNodeInstance> it(*this); |
222 | it.current(); | 221 | it.current(); |
223 | ++it ) { | 222 | ++it ) { |
224 | NNNI = it.current(); | 223 | NNNI = it.current(); |
225 | if( NNNI == NNI ) { | 224 | if( NNNI == NNI ) { |
226 | ++it; | 225 | ++it; |
227 | return it.current(); | 226 | return it.current(); |
228 | } | 227 | } |
229 | } | 228 | } |
230 | return 0; // no more next | 229 | return 0; // no more next |
231 | } | 230 | } |
232 | 231 | ||
233 | int NodeCollection::compareItems( QCollection::Item I1, | 232 | int NodeCollection::compareItems( QCollection::Item I1, |
234 | QCollection::Item I2 ) { | 233 | QCollection::Item I2 ) { |
235 | ANetNodeInstance * NNI1, * NNI2; | 234 | ANetNodeInstance * NNI1, * NNI2; |
236 | NNI1 = (ANetNodeInstance *)I1; | 235 | NNI1 = (ANetNodeInstance *)I1; |
237 | NNI2 = (ANetNodeInstance *)I2; | 236 | NNI2 = (ANetNodeInstance *)I2; |
238 | return strcmp( NNI1->name(), NNI2->name() ); | 237 | return strcmp( NNI1->name(), NNI2->name() ); |
239 | } | 238 | } |
240 | 239 | ||
241 | static char * State2PixmapTbl[] = { | 240 | static char * State2PixmapTbl[] = { |
242 | "NULL", // Unchecked : no pixmap | 241 | "NULL", // Unchecked : no pixmap |
243 | "check", // Unknown | 242 | "check", // Unknown |
244 | "delete", // unavailable | 243 | "delete", // unavailable |
245 | "disabled", // disabled | 244 | "disabled", // disabled |
246 | "off", // off | 245 | "off", // off |
247 | "disconnected", // available | 246 | "disconnected", // available |
248 | "connected" // up | 247 | "connected" // up |
249 | }; | 248 | }; |
250 | 249 | ||
251 | QPixmap NodeCollection::devicePixmap( void ) { | 250 | QPixmap NodeCollection::devicePixmap( void ) { |
252 | QPixmap pm = NSResources->getPixmap( | 251 | QPixmap pm = NSResources->getPixmap( |
253 | getToplevel()->nextNode()->pixmapName()+"-large"); | 252 | getToplevel()->nextNode()->pixmapName()+"-large"); |
254 | 253 | ||
255 | QPixmap Mini = NSResources->getPixmap( device()->netNode()->pixmapName() ); | 254 | QPixmap Mini = NSResources->getPixmap( device()->netNode()->pixmapName() ); |
256 | 255 | ||
257 | QPainter painter( &pm ); | 256 | QPainter painter( &pm ); |
258 | painter.drawPixmap( pm.width()-Mini.width(), | 257 | painter.drawPixmap( pm.width()-Mini.width(), |
259 | pm.height()-Mini.height(), | 258 | pm.height()-Mini.height(), |
260 | Mini ); | 259 | Mini ); |
261 | pm.setMask( pm.createHeuristicMask( TRUE ) ); | 260 | pm.setMask( pm.createHeuristicMask( TRUE ) ); |
262 | return pm; | 261 | return pm; |
263 | } | 262 | } |
264 | 263 | ||
265 | QPixmap NodeCollection::statePixmap( State_t S) { | 264 | QPixmap NodeCollection::statePixmap( State_t S) { |
266 | return NSResources->getPixmap( State2PixmapTbl[S] ); | 265 | return NSResources->getPixmap( State2PixmapTbl[S] ); |
267 | } | 266 | } |
268 | 267 | ||
269 | QString NodeCollection::stateName( State_t S) { | 268 | QString NodeCollection::stateName( State_t S) { |
270 | switch( S ) { | 269 | switch( S ) { |
271 | case Unknown : | 270 | case Unknown : |
272 | return qApp->translate( "networksettings2", "Unknown"); | 271 | return qApp->translate( "networksettings2", "Unknown"); |
273 | case Unavailable : | 272 | case Unavailable : |
274 | return qApp->translate( "networksettings2", "Unavailable"); | 273 | return qApp->translate( "networksettings2", "Unavailable"); |
275 | case Disabled : | 274 | case Disabled : |
276 | return qApp->translate( "networksettings2", "Disabled"); | 275 | return qApp->translate( "networksettings2", "Disabled"); |
277 | case Off : | 276 | case Off : |
278 | return qApp->translate( "networksettings2", "Off"); | 277 | return qApp->translate( "networksettings2", "Off"); |
279 | case Available : | 278 | case Available : |
280 | return qApp->translate( "networksettings2", "Available"); | 279 | return qApp->translate( "networksettings2", "Available"); |
281 | case IsUp : | 280 | case IsUp : |
282 | return qApp->translate( "networksettings2", "IsUp"); | 281 | return qApp->translate( "networksettings2", "IsUp"); |
283 | case Unchecked : /* FT */ | 282 | case Unchecked : /* FT */ |
284 | default : | 283 | default : |
285 | break; | 284 | break; |
286 | } | 285 | } |
287 | return QString(""); | 286 | return QString(""); |
288 | } | 287 | } |
289 | 288 | ||
290 | void NodeCollection::reassign( void ) { | 289 | void NodeCollection::reassign( void ) { |
291 | for( QListIterator<ANetNodeInstance> it(*this); | 290 | for( QListIterator<ANetNodeInstance> it(*this); |
292 | it.current(); | 291 | it.current(); |
293 | ++it ) { | 292 | ++it ) { |
294 | it.current()->setConnection( this ); | 293 | it.current()->setConnection( this ); |
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 |
301 | // | 303 | // |
302 | // | 304 | // |
303 | 305 | ||
304 | InterfaceInfo * RuntimeInfo::assignedInterface( void ) { | 306 | InterfaceInfo * RuntimeInfo::assignedInterface( void ) { |
305 | return netNode()->nextNode()->runtime()->assignedInterface(); | 307 | return netNode()->nextNode()->runtime()->assignedInterface(); |
306 | } | 308 | } |
307 | 309 | ||
308 | AsDevice * RuntimeInfo::device( void ) { | 310 | AsDevice * RuntimeInfo::device( void ) { |
309 | return netNode()->nextNode()->runtime()->device(); | 311 | return netNode()->nextNode()->runtime()->device(); |
310 | } | 312 | } |
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 | |||
@@ -1,382 +1,384 @@ | |||
1 | #ifndef NETNODE_H | 1 | #ifndef NETNODE_H |
2 | #define NETNODE_H | 2 | #define NETNODE_H |
3 | 3 | ||
4 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qpixmap.h> | 7 | #include <qpixmap.h> |
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; |
14 | class AsConnection; | 16 | class AsConnection; |
15 | class AsFullSetup; | 17 | class AsFullSetup; |
16 | 18 | ||
17 | // needed for plugin creation function | 19 | // needed for plugin creation function |
18 | #include <qlist.h> | 20 | #include <qlist.h> |
19 | 21 | ||
20 | class ANetNode; | 22 | class ANetNode; |
21 | class ANetNodeInstance; | 23 | class ANetNodeInstance; |
22 | class NodeCollection; | 24 | class NodeCollection; |
23 | class QTextStream; | 25 | class QTextStream; |
24 | class RuntimeInfo; | 26 | class RuntimeInfo; |
25 | class InterfaceInfo; | 27 | class InterfaceInfo; |
26 | 28 | ||
27 | extern QString & deQuote( QString & X ); | 29 | extern QString & deQuote( QString & X ); |
28 | extern QString quote( QString X ); | 30 | extern QString quote( QString X ); |
29 | 31 | ||
30 | #include "systemfile.h" | 32 | #include "systemfile.h" |
31 | 33 | ||
32 | typedef enum State { | 34 | typedef enum State { |
33 | // if we have not yet detected the state of the device | 35 | // if we have not yet detected the state of the device |
34 | Unchecked = 0, | 36 | Unchecked = 0, |
35 | // if we cannot determine the state | 37 | // if we cannot determine the state |
36 | Unknown = 1, | 38 | Unknown = 1, |
37 | // if connection cannot be established e.g. because | 39 | // if connection cannot be established e.g. because |
38 | // the hardware is not available | 40 | // the hardware is not available |
39 | Unavailable = 2, | 41 | Unavailable = 2, |
40 | // if the connection cannot be establishec but NOT | 42 | // if the connection cannot be establishec but NOT |
41 | // because it is physically impossible but because | 43 | // because it is physically impossible but because |
42 | // it has been disabled for FUNCTIONAL reasons | 44 | // it has been disabled for FUNCTIONAL reasons |
43 | Disabled = 3, | 45 | Disabled = 3, |
44 | // if connection is available to is currently down | 46 | // if connection is available to is currently down |
45 | // i.e. the corresponding hardware is not activated | 47 | // i.e. the corresponding hardware is not activated |
46 | Off = 4, | 48 | Off = 4, |
47 | // if connection is available to be used (i.e. the | 49 | // if connection is available to be used (i.e. the |
48 | // devices if fully ready to be used | 50 | // devices if fully ready to be used |
49 | Available = 5, | 51 | Available = 5, |
50 | // if connection is being used | 52 | // if connection is being used |
51 | IsUp = 6 | 53 | IsUp = 6 |
52 | } State_t; | 54 | } State_t; |
53 | 55 | ||
54 | typedef enum Action { | 56 | typedef enum Action { |
55 | // to make the device unavailable functionally | 57 | // to make the device unavailable functionally |
56 | Disable = 0, | 58 | Disable = 0, |
57 | // to make the device available functionally | 59 | // to make the device available functionally |
58 | Enable = 1, | 60 | Enable = 1, |
59 | // bring the hardware up | 61 | // bring the hardware up |
60 | Activate = 2, | 62 | Activate = 2, |
61 | // bring the hardware down | 63 | // bring the hardware down |
62 | Deactivate = 3, | 64 | Deactivate = 3, |
63 | // bring the connection up | 65 | // bring the connection up |
64 | Up = 4, | 66 | Up = 4, |
65 | // bring the connection down | 67 | // bring the connection down |
66 | Down = 5 | 68 | Down = 5 |
67 | } Action_t; | 69 | } Action_t; |
68 | 70 | ||
69 | class ANetNode : public QObject{ | 71 | class ANetNode : public QObject{ |
70 | 72 | ||
71 | public: | 73 | public: |
72 | 74 | ||
73 | typedef QArray<ANetNode *> NetNodeList; | 75 | typedef QArray<ANetNode *> NetNodeList; |
74 | 76 | ||
75 | ANetNode( const char * Name ) : QObject( 0, Name ) {} | 77 | ANetNode( const char * Name ) : QObject( 0, Name ) {} |
76 | virtual ~ANetNode(){}; | 78 | virtual ~ANetNode(){}; |
77 | 79 | ||
78 | // pixmap needed for this NetNode | 80 | // pixmap needed for this NetNode |
79 | virtual const QString pixmapName() = 0; | 81 | virtual const QString pixmapName() = 0; |
80 | 82 | ||
81 | // description for this NetNode | 83 | // description for this NetNode |
82 | virtual const QString nodeDescription() = 0; | 84 | virtual const QString nodeDescription() = 0; |
83 | 85 | ||
84 | // create a blank instance of a net node | 86 | // create a blank instance of a net node |
85 | virtual ANetNodeInstance * createInstance( void ) = 0; | 87 | virtual ANetNodeInstance * createInstance( void ) = 0; |
86 | 88 | ||
87 | // return feature this NetNode provides | 89 | // return feature this NetNode provides |
88 | virtual const char * provides( void ) = 0; | 90 | virtual const char * provides( void ) = 0; |
89 | virtual const char ** needs( void ) = 0; | 91 | virtual const char ** needs( void ) = 0; |
90 | 92 | ||
91 | // generate files specific for this node (if any) | 93 | // generate files specific for this node (if any) |
92 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0; | 94 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0; |
93 | // return TRUE if this node has data to be inserted in systemfile | 95 | // return TRUE if this node has data to be inserted in systemfile |
94 | // with name S | 96 | // with name S |
95 | virtual bool hasDataFor( const QString & S ) = 0; | 97 | virtual bool hasDataFor( const QString & S ) = 0; |
96 | // generate data specific for the device for the system file S | 98 | // generate data specific for the device for the system file S |
97 | // called only IF data was needed | 99 | // called only IF data was needed |
98 | virtual bool generateDeviceDataForCommonFile( | 100 | virtual bool generateDeviceDataForCommonFile( |
99 | SystemFile & SF, long DevNr ) = 0; | 101 | SystemFile & SF, long DevNr ) = 0; |
100 | 102 | ||
101 | // does this Node provide a Connection | 103 | // does this Node provide a Connection |
102 | bool isToplevel( void ) | 104 | bool isToplevel( void ) |
103 | { return strcmp( provides(), "fullsetup") == 0 ; } | 105 | { return strcmp( provides(), "fullsetup") == 0 ; } |
104 | 106 | ||
105 | // generate NIC name based on instance nr | 107 | // generate NIC name based on instance nr |
106 | // only relevant if node instances are devices | 108 | // only relevant if node instances are devices |
107 | virtual QString genNic( long ) | 109 | virtual QString genNic( long ) |
108 | { return QString(""); } | 110 | { return QString(""); } |
109 | 111 | ||
110 | // max number of instances for this node type | 112 | // max number of instances for this node type |
111 | // only relevant if node instances are devices | 113 | // only relevant if node instances are devices |
112 | virtual long instanceCount( void ) | 114 | virtual long instanceCount( void ) |
113 | { return 1; } | 115 | { return 1; } |
114 | 116 | ||
115 | // set the value of an attribute | 117 | // set the value of an attribute |
116 | void setAttribute( QString & Attr, QString & Value ) ; | 118 | void setAttribute( QString & Attr, QString & Value ) ; |
117 | void saveAttributes( QTextStream & TS ) ; | 119 | void saveAttributes( QTextStream & TS ) ; |
118 | 120 | ||
119 | // compiled references to 'needed' NetNodes -> needs list | 121 | // compiled references to 'needed' NetNodes -> needs list |
120 | void setAlternatives( NetNodeList * Alt ) | 122 | void setAlternatives( NetNodeList * Alt ) |
121 | { Alternatives = Alt; } | 123 | { Alternatives = Alt; } |
122 | NetNodeList & alternatives( void ) | 124 | NetNodeList & alternatives( void ) |
123 | { return *Alternatives; } | 125 | { return *Alternatives; } |
124 | 126 | ||
125 | protected : | 127 | protected : |
126 | 128 | ||
127 | NetNodeList * Alternatives; | 129 | NetNodeList * Alternatives; |
128 | 130 | ||
129 | private : | 131 | private : |
130 | 132 | ||
131 | virtual void setSpecificAttribute( QString & , QString & ) = 0; | 133 | virtual void setSpecificAttribute( QString & , QString & ) = 0; |
132 | virtual void saveSpecificAttribute( QTextStream & ) = 0; | 134 | virtual void saveSpecificAttribute( QTextStream & ) = 0; |
133 | 135 | ||
134 | }; | 136 | }; |
135 | 137 | ||
136 | class ANetNodeInstance : public QObject { | 138 | class ANetNodeInstance : public QObject { |
137 | 139 | ||
138 | public: | 140 | public: |
139 | 141 | ||
140 | ANetNodeInstance( ANetNode * NN ) : QObject() | 142 | ANetNodeInstance( ANetNode * NN ) : QObject() |
141 | { IsModified=0; NodeType = NN; IsNew = TRUE; } | 143 | { IsModified=0; NodeType = NN; IsNew = TRUE; } |
142 | virtual ~ANetNodeInstance( void ) { } | 144 | virtual ~ANetNodeInstance( void ) { } |
143 | 145 | ||
144 | virtual RuntimeInfo * runtime( void ) = 0; | 146 | virtual RuntimeInfo * runtime( void ) = 0; |
145 | 147 | ||
146 | void setConnection( NodeCollection * NC ) | 148 | void setConnection( NodeCollection * NC ) |
147 | { Connection = NC; } | 149 | { Connection = NC; } |
148 | NodeCollection * connection( void ) | 150 | NodeCollection * connection( void ) |
149 | { return Connection; } | 151 | { return Connection; } |
150 | 152 | ||
151 | // create edit widget under parent | 153 | // create edit widget under parent |
152 | virtual QWidget * edit( QWidget * parent ) = 0; | 154 | virtual QWidget * edit( QWidget * parent ) = 0; |
153 | // is given data acceptable | 155 | // is given data acceptable |
154 | virtual QString acceptable( void ) = 0; | 156 | virtual QString acceptable( void ) = 0; |
155 | 157 | ||
156 | // return data was modified | 158 | // return data was modified |
157 | void setModified( bool M ) | 159 | void setModified( bool M ) |
158 | { IsModified = M; } | 160 | { IsModified = M; } |
159 | bool isModified( void ) | 161 | bool isModified( void ) |
160 | { return IsModified; } | 162 | { return IsModified; } |
161 | 163 | ||
162 | // get data from GUI and store in node | 164 | // get data from GUI and store in node |
163 | virtual void commit( void ) = 0; | 165 | virtual void commit( void ) = 0; |
164 | 166 | ||
165 | // get next node | 167 | // get next node |
166 | ANetNodeInstance * nextNode(); | 168 | ANetNodeInstance * nextNode(); |
167 | // return NetNode this is an instance of | 169 | // return NetNode this is an instance of |
168 | ANetNode * nodeClass( void ) | 170 | ANetNode * nodeClass( void ) |
169 | { return NodeType; } | 171 | { return NodeType; } |
170 | 172 | ||
171 | // intialize am instance of a net node | 173 | // intialize am instance of a net node |
172 | void initialize( void ); | 174 | void initialize( void ); |
173 | 175 | ||
174 | // set the value of an attribute | 176 | // set the value of an attribute |
175 | void setAttribute( QString & Attr, QString & Value ) ; | 177 | void setAttribute( QString & Attr, QString & Value ) ; |
176 | void saveAttributes( QTextStream & TS ) ; | 178 | void saveAttributes( QTextStream & TS ) ; |
177 | 179 | ||
178 | // return true if node isntance is NEW and not loaded | 180 | // return true if node isntance is NEW and not loaded |
179 | void setNew( bool IsN ) | 181 | void setNew( bool IsN ) |
180 | { IsNew = IsN; } | 182 | { IsNew = IsN; } |
181 | bool isNew( void ) | 183 | bool isNew( void ) |
182 | { return IsNew; } | 184 | { return IsNew; } |
183 | 185 | ||
184 | // return description for this instance | 186 | // return description for this instance |
185 | QString & description( void ) | 187 | QString & description( void ) |
186 | { return Description; } | 188 | { return Description; } |
187 | void setDescription( const QString & S ) | 189 | void setDescription( const QString & S ) |
188 | { Description = S; } | 190 | { Description = S; } |
189 | 191 | ||
190 | // pixmap for this instance -> from NetNode | 192 | // pixmap for this instance -> from NetNode |
191 | const QString pixmapName( void ) | 193 | const QString pixmapName( void ) |
192 | { return NodeType->pixmapName(); } | 194 | { return NodeType->pixmapName(); } |
193 | 195 | ||
194 | const char * provides( void ) | 196 | const char * provides( void ) |
195 | { return NodeType->provides(); } | 197 | { return NodeType->provides(); } |
196 | 198 | ||
197 | const char ** needs( void ) | 199 | const char ** needs( void ) |
198 | { return NodeType->needs(); } | 200 | { return NodeType->needs(); } |
199 | 201 | ||
200 | // returns node specific data -> only useful for 'buddy' | 202 | // returns node specific data -> only useful for 'buddy' |
201 | virtual void * data( void ) = 0; | 203 | virtual void * data( void ) = 0; |
202 | 204 | ||
203 | // return TRUE if this node has data to be inserted in systemfile | 205 | // return TRUE if this node has data to be inserted in systemfile |
204 | // with name S | 206 | // with name S |
205 | virtual bool hasDataFor( const QString & S ) = 0; | 207 | virtual bool hasDataFor( const QString & S ) = 0; |
206 | 208 | ||
207 | // generate data specific for a profile and for the system file S | 209 | // generate data specific for a profile and for the system file S |
208 | // called only IF data was needed | 210 | // called only IF data was needed |
209 | virtual bool generateDataForCommonFile( | 211 | virtual bool generateDataForCommonFile( |
210 | SystemFile & SF, long DevNr ) = 0; | 212 | SystemFile & SF, long DevNr ) = 0; |
211 | 213 | ||
212 | protected : | 214 | protected : |
213 | 215 | ||
214 | virtual void setSpecificAttribute( QString & , QString & ) = 0; | 216 | virtual void setSpecificAttribute( QString & , QString & ) = 0; |
215 | virtual void saveSpecificAttribute( QTextStream & ) = 0; | 217 | virtual void saveSpecificAttribute( QTextStream & ) = 0; |
216 | 218 | ||
217 | ANetNode * NodeType; | 219 | ANetNode * NodeType; |
218 | // connection to which this node belongs to | 220 | // connection to which this node belongs to |
219 | NodeCollection * Connection; | 221 | NodeCollection * Connection; |
220 | QString Description; | 222 | QString Description; |
221 | bool IsModified; | 223 | bool IsModified; |
222 | bool IsNew; | 224 | bool IsNew; |
223 | 225 | ||
224 | static long InstanceCounter; | 226 | static long InstanceCounter; |
225 | }; | 227 | }; |
226 | 228 | ||
227 | class RuntimeInfo : public QObject { | 229 | class RuntimeInfo : public QObject { |
228 | 230 | ||
229 | Q_OBJECT | 231 | Q_OBJECT |
230 | 232 | ||
231 | public : | 233 | public : |
232 | 234 | ||
233 | RuntimeInfo( ANetNodeInstance * TheNNI ) | 235 | RuntimeInfo( ANetNodeInstance * TheNNI ) |
234 | { NNI = TheNNI; } | 236 | { NNI = TheNNI; } |
235 | 237 | ||
236 | // downcast implemented by specify runtime classes | 238 | // downcast implemented by specify runtime classes |
237 | virtual AsDevice * asDevice( void ) | 239 | virtual AsDevice * asDevice( void ) |
238 | { return 0; } | 240 | { return 0; } |
239 | virtual AsConnection * asConnection( void ) | 241 | virtual AsConnection * asConnection( void ) |
240 | { return 0; } | 242 | { return 0; } |
241 | virtual AsLine * asLine( void ) | 243 | virtual AsLine * asLine( void ) |
242 | { return 0; } | 244 | { return 0; } |
243 | virtual AsFullSetup * asFullSetup( void ) | 245 | virtual AsFullSetup * asFullSetup( void ) |
244 | { return 0; } | 246 | { return 0; } |
245 | 247 | ||
246 | // does this node handles this interface e.g.eth0 | 248 | // does this node handles this interface e.g.eth0 |
247 | // recurse deeper if this node cannot answer that question | 249 | // recurse deeper if this node cannot answer that question |
248 | virtual bool handlesInterface( const QString & ) | 250 | virtual bool handlesInterface( const QString & ) |
249 | { return 0; } | 251 | { return 0; } |
250 | virtual bool handlesInterface( const InterfaceInfo & ) | 252 | virtual bool handlesInterface( const InterfaceInfo & ) |
251 | { return 0; } | 253 | { return 0; } |
252 | virtual InterfaceInfo * assignedInterface( void ); | 254 | virtual InterfaceInfo * assignedInterface( void ); |
253 | virtual AsDevice * device( void ); | 255 | virtual AsDevice * device( void ); |
254 | 256 | ||
255 | ANetNodeInstance * netNode() | 257 | ANetNodeInstance * netNode() |
256 | { return NNI; } | 258 | { return NNI; } |
257 | NodeCollection * connection() | 259 | NodeCollection * connection() |
258 | { return NNI->connection(); } | 260 | { return NNI->connection(); } |
259 | 261 | ||
260 | virtual void detectState( NodeCollection * NC ) = 0; | 262 | virtual void detectState( NodeCollection * NC ) = 0; |
261 | virtual bool setState( NodeCollection * NC, Action_t A, bool Force = 0 ) = 0; | 263 | virtual bool setState( NodeCollection * NC, Action_t A, bool Force = 0 ) = 0; |
262 | virtual bool canSetState( State_t Curr, Action_t A ) = 0; | 264 | virtual bool canSetState( State_t Curr, Action_t A ) = 0; |
263 | 265 | ||
264 | signals : | 266 | signals : |
265 | 267 | ||
266 | // sent by device if state changes | 268 | // sent by device if state changes |
267 | void stateChanged( State_t S, ANetNodeInstance * NNI ); | 269 | void stateChanged( State_t S, ANetNodeInstance * NNI ); |
268 | 270 | ||
269 | protected : | 271 | protected : |
270 | 272 | ||
271 | // connection this runtime info belongs to | 273 | // connection this runtime info belongs to |
272 | ANetNodeInstance * NNI; | 274 | ANetNodeInstance * NNI; |
273 | }; | 275 | }; |
274 | 276 | ||
275 | class NodeCollection : public QList<ANetNodeInstance> { | 277 | class NodeCollection : public QList<ANetNodeInstance> { |
276 | 278 | ||
277 | public : | 279 | public : |
278 | 280 | ||
279 | NodeCollection( void ); | 281 | NodeCollection( void ); |
280 | NodeCollection( QTextStream & TS ); | 282 | NodeCollection( QTextStream & TS ); |
281 | ~NodeCollection( void ); | 283 | ~NodeCollection( void ); |
282 | 284 | ||
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 ) |
290 | { IsNew = N ; } | 292 | { IsNew = N ; } |
291 | bool isModified( void ) | 293 | bool isModified( void ) |
292 | { return IsModified; } | 294 | { return IsModified; } |
293 | void setModified( bool N ) | 295 | void setModified( bool N ) |
294 | { IsModified = N ; } | 296 | { IsModified = N ; } |
295 | 297 | ||
296 | bool handlesInterface( const QString & S ) { | 298 | bool handlesInterface( const QString & S ) { |
297 | return getToplevel()->runtime()->handlesInterface( S ); | 299 | return getToplevel()->runtime()->handlesInterface( S ); |
298 | } | 300 | } |
299 | 301 | ||
300 | InterfaceInfo * assignedInterface( void ) { | 302 | InterfaceInfo * assignedInterface( void ) { |
301 | return getToplevel()->runtime()->assignedInterface(); | 303 | return getToplevel()->runtime()->assignedInterface(); |
302 | } | 304 | } |
303 | 305 | ||
304 | AsDevice * device() { | 306 | AsDevice * device() { |
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 | } |
313 | return CurrentState; | 322 | return CurrentState; |
314 | } | 323 | } |
315 | 324 | ||
316 | // get the ixmap for this device | 325 | // get the ixmap for this device |
317 | QPixmap devicePixmap( void ); | 326 | QPixmap devicePixmap( void ); |
318 | QPixmap statePixmap( State_t S ); | 327 | QPixmap statePixmap( State_t S ); |
319 | QPixmap statePixmap( bool Update = 0 ) | 328 | QPixmap statePixmap( bool Update = 0 ) |
320 | { return statePixmap( state(Update) ); } | 329 | { return statePixmap( state(Update) ); } |
321 | QString stateName( State_t ); | 330 | QString stateName( State_t ); |
322 | QString stateName( bool Update = 0 ) | 331 | QString stateName( bool Update = 0 ) |
323 | { return stateName( state(Update) ); } | 332 | { return stateName( state(Update) ); } |
324 | 333 | ||
325 | bool setState( Action_t A, bool Force =0 ) | 334 | bool setState( Action_t A, bool Force =0 ) |
326 | { return getToplevel()->runtime()->setState( this, A, Force ); } | 335 | { return getToplevel()->runtime()->setState( this, A, Force ); } |
327 | bool canSetState( Action_t A ) | 336 | bool canSetState( Action_t A ) |
328 | { return getToplevel()->runtime()->canSetState( CurrentState, A ); } | 337 | { return getToplevel()->runtime()->canSetState( CurrentState, A ); } |
329 | 338 | ||
330 | void save( QTextStream & TS ); | 339 | void save( QTextStream & TS ); |
331 | 340 | ||
332 | void append( ANetNodeInstance * NNI ); | 341 | void append( ANetNodeInstance * NNI ); |
333 | 342 | ||
334 | // makes sure that all items in the connection point to | 343 | // makes sure that all items in the connection point to |
335 | // that connectoin | 344 | // that connectoin |
336 | void reassign( void ); | 345 | void reassign( void ); |
337 | 346 | ||
338 | ANetNodeInstance * getToplevel( void ); | 347 | ANetNodeInstance * getToplevel( void ); |
339 | ANetNodeInstance * findNext( ANetNodeInstance * NNI ); | 348 | ANetNodeInstance * findNext( ANetNodeInstance * NNI ); |
340 | ANetNodeInstance * findByName( const QString & S ); | 349 | ANetNodeInstance * findByName( const QString & S ); |
341 | 350 | ||
342 | const QString & name() | 351 | const QString & name() |
343 | { return Name; } | 352 | { return Name; } |
344 | 353 | ||
345 | const QString & description( void ); | 354 | const QString & description( void ); |
346 | 355 | ||
347 | void setName( const QString & N) | 356 | void setName( const QString & N) |
348 | { Name = N; } | 357 | { Name = N; } |
349 | 358 | ||
350 | State_t currentState( void ) | 359 | State_t currentState( void ) |
351 | { return CurrentState; } | 360 | { return CurrentState; } |
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 |
370 | State_t CurrentState; | 372 | State_t CurrentState; |
371 | 373 | ||
372 | QString Name; | 374 | QString Name; |
373 | // true if this collection was just created (and not | 375 | // true if this collection was just created (and not |
374 | // loaded from file | 376 | // loaded from file |
375 | bool IsNew; | 377 | bool IsNew; |
376 | // index in listbox | 378 | // index in listbox |
377 | int Index; | 379 | int Index; |
378 | bool IsModified; | 380 | bool IsModified; |
379 | 381 | ||
380 | }; | 382 | }; |
381 | 383 | ||
382 | #endif | 384 | #endif |
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 | |||
@@ -1,28 +1,28 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #CONFIG += qt warn_on debug | 3 | #CONFIG += qt warn_on debug |
4 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) | 4 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) |
5 | HEADERS = netnode.h \ | 5 | HEADERS = netnode.h \ |
6 | resources.h \ | 6 | resources.h \ |
7 | system.h \ | 7 | system.h \ |
8 | asline.h \ | 8 | asline.h \ |
9 | GUIUtils.h \ | 9 | GUIUtils.h \ |
10 | asconnection.h \ | 10 | asconnection.h \ |
11 | asfullsetup.h \ | 11 | asfullsetup.h \ |
12 | systemfile.h \ | 12 | systemfile.h \ |
13 | wextensions.h \ | 13 | wextensions.h \ |
14 | asdevice.h | 14 | asdevice.h |
15 | SOURCES = netnode.cpp \ | 15 | SOURCES = netnode.cpp \ |
16 | GUIUtils.cpp \ | 16 | GUIUtils.cpp \ |
17 | system.cpp \ | 17 | system.cpp \ |
18 | systemfile.cpp \ | 18 | systemfile.cpp \ |
19 | wextensions.cpp \ | 19 | wextensions.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 |
27 | 27 | ||
28 | include ( $(OPIEDIR)/include.pro ) | 28 | include ( $(OPIEDIR)/include.pro ) |
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 | |||
@@ -1,370 +1,444 @@ | |||
1 | #include <unistd.h> | 1 | #include <unistd.h> |
2 | #include <errno.h> | 2 | #include <errno.h> |
3 | #include <fcntl.h> | 3 | #include <fcntl.h> |
4 | #include <pwd.h> | 4 | #include <pwd.h> |
5 | #include <qpixmap.h> | 5 | #include <qpixmap.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | #include <qpe/qlibrary.h> | 7 | #include <qpe/qlibrary.h> |
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | #include <opie2/odebug.h> | 9 | #include <opie2/odebug.h> |
10 | #include <qtopia/resource.h> | 10 | #include <qtopia/resource.h> |
11 | 11 | ||
12 | #include "netnode.h" | 12 | #include "netnode.h" |
13 | #include "resources.h" | 13 | #include "resources.h" |
14 | 14 | ||
15 | #define PLUGINDIR "plugins/networksettings2" | 15 | #define PLUGINDIR "plugins/networksettings2" |
16 | #define ICONDIR "/pics/networksettings2/" | 16 | #define ICONDIR "/pics/networksettings2/" |
17 | 17 | ||
18 | // single resources instance | 18 | // single resources instance |
19 | TheNSResources * _NSResources = 0; | 19 | TheNSResources * _NSResources = 0; |
20 | 20 | ||
21 | TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), | 21 | TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), |
22 | ConnectionsMap() { | 22 | ConnectionsMap() { |
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 | ||
29 | // compile provides and needs lists | 31 | // compile provides and needs lists |
30 | { const char ** NeedsRun; | 32 | { const char ** NeedsRun; |
31 | QDictIterator<NetNode_t> OuterIt( AllNodeTypes ); | 33 | QDictIterator<NetNode_t> OuterIt( AllNodeTypes ); |
32 | bool Done; | 34 | bool Done; |
33 | 35 | ||
34 | for ( ; OuterIt.current(); ++OuterIt ) { | 36 | for ( ; OuterIt.current(); ++OuterIt ) { |
35 | // find needs list | 37 | // find needs list |
36 | ANetNode::NetNodeList * NNLP = new ANetNode::NetNodeList; | 38 | ANetNode::NetNodeList * NNLP = new ANetNode::NetNodeList; |
37 | ANetNode::NetNodeList & NNL = *(NNLP); | 39 | ANetNode::NetNodeList & NNL = *(NNLP); |
38 | 40 | ||
39 | // must iterate this way to avoid duplication pointers | 41 | // must iterate this way to avoid duplication pointers |
40 | for ( QDictIterator<NetNode_t> InnerIt( AllNodeTypes ); | 42 | for ( QDictIterator<NetNode_t> InnerIt( AllNodeTypes ); |
41 | InnerIt.current(); ++InnerIt ) { | 43 | InnerIt.current(); ++InnerIt ) { |
42 | if( InnerIt.current() == OuterIt.current() ) | 44 | if( InnerIt.current() == OuterIt.current() ) |
43 | // avoid recursive | 45 | // avoid recursive |
44 | continue; | 46 | continue; |
45 | 47 | ||
46 | const char * Provides = InnerIt.current()->NetNode->provides(); | 48 | const char * Provides = InnerIt.current()->NetNode->provides(); |
47 | NeedsRun = OuterIt.current()->NetNode->needs(); | 49 | NeedsRun = OuterIt.current()->NetNode->needs(); |
48 | for( ; *NeedsRun; NeedsRun ++ ) { | 50 | for( ; *NeedsRun; NeedsRun ++ ) { |
49 | if( strcmp( Provides, *NeedsRun ) == 0 ) { | 51 | if( strcmp( Provides, *NeedsRun ) == 0 ) { |
50 | // inner provides what outer needs | 52 | // inner provides what outer needs |
51 | NNL.resize( NNL.size() + 1 ); | 53 | NNL.resize( NNL.size() + 1 ); |
52 | NNL[NNL.size()-1] = InnerIt.current()->NetNode; | 54 | NNL[NNL.size()-1] = InnerIt.current()->NetNode; |
53 | Done = 1; // break from 2 loops | 55 | Done = 1; // break from 2 loops |
54 | break; | 56 | break; |
55 | } | 57 | } |
56 | } | 58 | } |
57 | } | 59 | } |
58 | OuterIt.current()->NetNode->setAlternatives( NNLP ); | 60 | OuterIt.current()->NetNode->setAlternatives( NNLP ); |
59 | } | 61 | } |
60 | } | 62 | } |
61 | 63 | ||
62 | // define Node types to Description map | 64 | // define Node types to Description map |
63 | NodeTypeNameMap.insert( "device", tr( "Network Device" ) ); | 65 | NodeTypeNameMap.insert( "device", tr( "Network Device" ) ); |
64 | NodeTypeNameMap.insert( "line", tr( "Character device" ) ); | 66 | NodeTypeNameMap.insert( "line", tr( "Character device" ) ); |
65 | NodeTypeNameMap.insert( "connection", tr( "IP Connection" ) ); | 67 | NodeTypeNameMap.insert( "connection", tr( "IP Connection" ) ); |
66 | NodeTypeNameMap.insert( "fullsetup", tr( "Connection Profile" ) ); | 68 | NodeTypeNameMap.insert( "fullsetup", tr( "Connection Profile" ) ); |
67 | 69 | ||
68 | NodeTypeDescriptionMap.insert( "device", | 70 | NodeTypeDescriptionMap.insert( "device", |
69 | tr( "<p>Devices that can handle IP packets</p>" ) ); | 71 | tr( "<p>Devices that can handle IP packets</p>" ) ); |
70 | NodeTypeDescriptionMap.insert( "line", | 72 | NodeTypeDescriptionMap.insert( "line", |
71 | tr( "<p>Devices that can handle single bytes</p>" ) ); | 73 | tr( "<p>Devices that can handle single bytes</p>" ) ); |
72 | NodeTypeDescriptionMap.insert( "connection", | 74 | NodeTypeDescriptionMap.insert( "connection", |
73 | tr( "<p>Nodes that provide working IP connections</p>" ) ); | 75 | tr( "<p>Nodes that provide working IP connections</p>" ) ); |
74 | NodeTypeDescriptionMap.insert( "fullsetup", | 76 | NodeTypeDescriptionMap.insert( "fullsetup", |
75 | tr( "<p>Fully configured connection profile</p>" ) ); | 77 | tr( "<p>Fully configured connection profile</p>" ) ); |
76 | 78 | ||
77 | // define system files | 79 | // define system files |
78 | addSystemFile( new SystemFile( "interfaces", "./interfaces" ) ); | 80 | addSystemFile( new SystemFile( "interfaces", "./interfaces" ) ); |
79 | 81 | ||
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 |
93 | * and attempts to load them | 105 | * and attempts to load them |
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; |
100 | 113 | ||
101 | QString lang = ::getenv("LANG"); | 114 | QString lang = ::getenv("LANG"); |
102 | 115 | ||
103 | // Don't want sym links | 116 | // Don't want sym links |
104 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 117 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
105 | const QFileInfoList *list = d.entryInfoList(); | 118 | const QFileInfoList *list = d.entryInfoList(); |
106 | QFileInfoListIterator it( *list ); | 119 | QFileInfoListIterator it( *list ); |
107 | QFileInfo *fi; | 120 | QFileInfo *fi; |
108 | 121 | ||
109 | while ( (fi=it.current()) ) { | 122 | while ( (fi=it.current()) ) { |
110 | 123 | ||
111 | if( fi->fileName().contains(".so")){ | 124 | if( fi->fileName().contains(".so")){ |
112 | /* if loaded install translation */ | 125 | /* if loaded install translation */ |
113 | if( loadNetNode(path + "/" + fi->fileName()) ) { | 126 | if( loadNetNode(path + "/" + fi->fileName()) ) { |
114 | QTranslator *trans = new QTranslator(qApp); | 127 | QTranslator *trans = new QTranslator(qApp); |
115 | QString fn = QPEApplication::qpeDir()+ | 128 | QString fn = QPEApplication::qpeDir()+ |
116 | "/i18n/"+lang+"/"+ | 129 | "/i18n/"+lang+"/"+ |
117 | fi->fileName().left( fi->fileName().find(".") )+ | 130 | fi->fileName().left( fi->fileName().find(".") )+ |
118 | ".qm"; | 131 | ".qm"; |
119 | 132 | ||
120 | if( trans->load( fn ) ) | 133 | if( trans->load( fn ) ) |
121 | qApp->installTranslator( trans ); | 134 | qApp->installTranslator( trans ); |
122 | else | 135 | else |
123 | delete trans; | 136 | delete trans; |
124 | } | 137 | } |
125 | } | 138 | } |
126 | ++it; | 139 | ++it; |
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 |
133 | * @param resolveString - function pointer to resolve | 167 | * @param resolveString - function pointer to resolve |
134 | * @return true of loading is successful | 168 | * @return true of loading is successful |
135 | */ | 169 | */ |
136 | bool TheNSResources::loadNetNode( | 170 | bool TheNSResources::loadNetNode( |
137 | const QString &pluginFileName, const QString &resolveString){ | 171 | const QString &pluginFileName, const QString &resolveString){ |
138 | 172 | ||
139 | QLibrary *lib = new QLibrary(pluginFileName); | 173 | QLibrary *lib = new QLibrary(pluginFileName); |
140 | void * res = lib->resolve(resolveString); | 174 | void * res = lib->resolve(resolveString); |
141 | if( ! res ){ | 175 | if( ! res ){ |
142 | delete lib; | 176 | delete lib; |
143 | return 0; | 177 | return 0; |
144 | } | 178 | } |
145 | 179 | ||
146 | GetNetNodeListFt_t getNetNodeList = (GetNetNodeListFt_t)res; | 180 | GetNetNodeListFt_t getNetNodeList = (GetNetNodeListFt_t)res; |
147 | 181 | ||
148 | // Try to get an object. | 182 | // Try to get an object. |
149 | QList<ANetNode> PNN; | 183 | QList<ANetNode> PNN; |
150 | 184 | ||
151 | getNetNodeList( PNN ); | 185 | getNetNodeList( PNN ); |
152 | if( PNN.isEmpty() ) { | 186 | if( PNN.isEmpty() ) { |
153 | delete lib; | 187 | delete lib; |
154 | return 0; | 188 | return 0; |
155 | } | 189 | } |
156 | 190 | ||
157 | ANetNode * NNP; | 191 | ANetNode * NNP; |
158 | for( QListIterator<ANetNode> it(PNN); | 192 | for( QListIterator<ANetNode> it(PNN); |
159 | it.current(); | 193 | it.current(); |
160 | ++it ) { | 194 | ++it ) { |
161 | NetNode_t * NN; | 195 | NetNode_t * NN; |
162 | 196 | ||
163 | NNP = it.current(); | 197 | NNP = it.current(); |
164 | NN = new NetNode_t; | 198 | NN = new NetNode_t; |
165 | NN->NetNode = NNP; | 199 | NN->NetNode = NNP; |
166 | NN->TheLibrary = lib; | 200 | NN->TheLibrary = lib; |
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 | ||
174 | return 1; | 207 | return 1; |
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 ) { |
185 | return qApp->translate( "resource", s ); | 220 | return qApp->translate( "resource", s ); |
186 | } | 221 | } |
187 | 222 | ||
188 | const QString & TheNSResources::netNode2Name( const char * s ) { | 223 | const QString & TheNSResources::netNode2Name( const char * s ) { |
189 | return NodeTypeNameMap[s]; | 224 | return NodeTypeNameMap[s]; |
190 | } | 225 | } |
191 | 226 | ||
192 | const QString & TheNSResources::netNode2Description( const char * s ) { | 227 | const QString & TheNSResources::netNode2Description( const char * s ) { |
193 | return NodeTypeDescriptionMap[s]; | 228 | return NodeTypeDescriptionMap[s]; |
194 | } | 229 | } |
195 | 230 | ||
196 | void TheNSResources::addConnection( NodeCollection * NC ) { | 231 | void TheNSResources::addConnection( NodeCollection * NC ) { |
197 | ANetNodeInstance * NNI; | 232 | ANetNodeInstance * NNI; |
198 | ConnectionsMap.insert( NC->name(), NC ); | 233 | ConnectionsMap.insert( NC->name(), NC ); |
199 | // add (new) nodes to NodeList | 234 | // add (new) nodes to NodeList |
200 | for( QListIterator<ANetNodeInstance> it(*NC); | 235 | for( QListIterator<ANetNodeInstance> it(*NC); |
201 | it.current(); | 236 | it.current(); |
202 | ++it ) { | 237 | ++it ) { |
203 | NNI = it.current(); | 238 | NNI = it.current(); |
204 | if( findNodeInstance( NNI->name() ) == 0 ) { | 239 | if( findNodeInstance( NNI->name() ) == 0 ) { |
205 | // new item | 240 | // new item |
206 | addNodeInstance( NNI ); | 241 | addNodeInstance( NNI ); |
207 | } | 242 | } |
208 | } | 243 | } |
209 | } | 244 | } |
210 | 245 | ||
211 | void TheNSResources::removeConnection( const QString & N ) { | 246 | void TheNSResources::removeConnection( const QString & N ) { |
212 | NodeCollection * NC = findConnection( N ); | 247 | NodeCollection * NC = findConnection( N ); |
213 | if( ! NC ) | 248 | if( ! NC ) |
214 | return; | 249 | return; |
215 | 250 | ||
216 | // delete netnodes in this connection | 251 | // delete netnodes in this connection |
217 | ANetNodeInstance * NNI; | 252 | ANetNodeInstance * NNI; |
218 | for( NNI = NC->first(); NNI != 0; NNI = NC->next() ) { | 253 | for( NNI = NC->first(); NNI != 0; NNI = NC->next() ) { |
219 | removeNodeInstance( NNI->name() ); | 254 | removeNodeInstance( NNI->name() ); |
220 | } | 255 | } |
221 | ConnectionsMap.remove( N ); | 256 | ConnectionsMap.remove( N ); |
222 | } | 257 | } |
223 | 258 | ||
224 | NodeCollection * TheNSResources::findConnection( const QString & S ) { | 259 | 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; |
231 | 267 | ||
232 | // for all connections | 268 | // for all connections |
233 | NodeCollection::resetMaxNr(); | 269 | NodeCollection::resetMaxNr(); |
234 | for( QDictIterator<NodeCollection> it(M); | 270 | for( QDictIterator<NodeCollection> it(M); |
235 | it.current(); | 271 | it.current(); |
236 | ++it ) { | 272 | ++it ) { |
237 | NC = it.current(); | 273 | NC = it.current(); |
238 | NC->setNumber( NC->maxConnectionNumber()+1 ); | 274 | NC->setNumber( NC->maxConnectionNumber()+1 ); |
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; |
245 | int Len; | 282 | int Len; |
246 | } EnvVar_t; | 283 | } EnvVar_t; |
247 | 284 | ||
248 | #define AnEV(x) x, sizeof(x)-1 | 285 | #define AnEV(x) x, sizeof(x)-1 |
249 | 286 | ||
250 | static EnvVar_t EV[] = { | 287 | static EnvVar_t EV[] = { |
251 | // AnEV( "HOME=" ), -> SPECIAL | 288 | // AnEV( "HOME=" ), -> SPECIAL |
252 | // AnEV( "LOGNAME=" ), -> SPECIAL | 289 | // AnEV( "LOGNAME=" ), -> SPECIAL |
253 | AnEV( "USER=" ), | 290 | AnEV( "USER=" ), |
254 | AnEV( "LD_LIBRARY_PATH=" ), | 291 | AnEV( "LD_LIBRARY_PATH=" ), |
255 | AnEV( "PATH=" ), | 292 | AnEV( "PATH=" ), |
256 | AnEV( "QTDIR=" ), | 293 | AnEV( "QTDIR=" ), |
257 | AnEV( "OPIEDIR=" ), | 294 | AnEV( "OPIEDIR=" ), |
258 | AnEV( "SHELL=" ), | 295 | AnEV( "SHELL=" ), |
259 | { NULL, 0 } | 296 | { NULL, 0 } |
260 | }; | 297 | }; |
261 | 298 | ||
262 | void TheNSResources::detectCurrentUser( void ) { | 299 | 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 | |||
@@ -1,128 +1,131 @@ | |||
1 | #ifndef __RESOURCES__H | 1 | #ifndef __RESOURCES__H |
2 | #define __RESOURCES__H | 2 | #define __RESOURCES__H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qdict.h> | 5 | #include <qdict.h> |
6 | #include <qmap.h> | 6 | #include <qmap.h> |
7 | #include <qlist.h> | 7 | #include <qlist.h> |
8 | #include "netnode.h" | 8 | #include "netnode.h" |
9 | #include "systemfile.h" | 9 | #include "systemfile.h" |
10 | #include "system.h" | 10 | #include "system.h" |
11 | 11 | ||
12 | class QLibrary; | 12 | class QLibrary; |
13 | class QPixmap; | 13 | class QPixmap; |
14 | class ANetNode; | 14 | class ANetNode; |
15 | class ANetNodeInstance; | 15 | class ANetNodeInstance; |
16 | 16 | ||
17 | typedef void (*GetNetNodeListFt_t)(QList<ANetNode>& PNN ); | 17 | typedef void (*GetNetNodeListFt_t)(QList<ANetNode>& PNN ); |
18 | 18 | ||
19 | typedef struct NetNode_S { | 19 | typedef struct NetNode_S { |
20 | ANetNode * NetNode; | 20 | ANetNode * NetNode; |
21 | QLibrary * TheLibrary; | 21 | QLibrary * TheLibrary; |
22 | long NodeCountInLib; | 22 | long NodeCountInLib; |
23 | } NetNode_t; | 23 | } NetNode_t; |
24 | 24 | ||
25 | class CurrentQPEUser { | 25 | class CurrentQPEUser { |
26 | 26 | ||
27 | public : | 27 | public : |
28 | CurrentQPEUser() : UserName(), HomeDir(), EnvList() {} | 28 | CurrentQPEUser() : UserName(), HomeDir(), EnvList() {} |
29 | 29 | ||
30 | QString UserName; | 30 | QString UserName; |
31 | QString HomeDir; | 31 | QString HomeDir; |
32 | int Uid; | 32 | int Uid; |
33 | int Gid; | 33 | int Gid; |
34 | QArray<char *> EnvList; | 34 | QArray<char *> EnvList; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | typedef QDict<NetNode_t> Name2NetNode_t; | 37 | typedef QDict<NetNode_t> Name2NetNode_t; |
38 | typedef QDict<ANetNodeInstance > Name2Instance_t; | 38 | typedef QDict<ANetNodeInstance > Name2Instance_t; |
39 | typedef QDict<NodeCollection> Name2Connection_t; | 39 | typedef QDict<NodeCollection> Name2Connection_t; |
40 | typedef QDict<SystemFile> Name2SystemFile_t; | 40 | typedef QDict<SystemFile> Name2SystemFile_t; |
41 | 41 | ||
42 | class TheNSResources { | 42 | class TheNSResources { |
43 | 43 | ||
44 | public : | 44 | public : |
45 | 45 | ||
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 ) |
55 | { return AllNodeTypes; } | 59 | { return AllNodeTypes; } |
56 | bool netNodeExists( const QString & X ) | 60 | bool netNodeExists( const QString & X ) |
57 | { return AllNodeTypes.find(X)!=0; } | 61 | { return AllNodeTypes.find(X)!=0; } |
58 | ANetNode * findNetNode( const QString & N ) | 62 | ANetNode * findNetNode( const QString & N ) |
59 | { NetNode_t * NNT = AllNodeTypes.find(N); | 63 | { NetNode_t * NNT = AllNodeTypes.find(N); |
60 | return (NNT) ? NNT->NetNode : 0; | 64 | return (NNT) ? NNT->NetNode : 0; |
61 | } | 65 | } |
62 | 66 | ||
63 | Name2SystemFile_t & systemFiles( void ) | 67 | Name2SystemFile_t & systemFiles( void ) |
64 | { return SystemFiles; } | 68 | { return SystemFiles; } |
65 | void addSystemFile( SystemFile * SF ) | 69 | void addSystemFile( SystemFile * SF ) |
66 | { SystemFiles.insert( SF->name(), SF ); } | 70 | { SystemFiles.insert( SF->name(), SF ); } |
67 | 71 | ||
68 | ANetNodeInstance * createNodeInstance( const QString & S ) | 72 | ANetNodeInstance * createNodeInstance( const QString & S ) |
69 | { ANetNodeInstance * NNI = 0; | 73 | { ANetNodeInstance * NNI = 0; |
70 | NetNode_t * NNT = AllNodeTypes[S]; | 74 | NetNode_t * NNT = AllNodeTypes[S]; |
71 | if( ! NNT ) { | 75 | if( ! NNT ) { |
72 | return 0; | 76 | return 0; |
73 | } | 77 | } |
74 | NNI = NNT->NetNode->createInstance(); | 78 | NNI = NNT->NetNode->createInstance(); |
75 | NNI->initialize(); | 79 | NNI->initialize(); |
76 | return NNI; | 80 | return NNI; |
77 | } | 81 | } |
78 | 82 | ||
79 | Name2Instance_t & netNodeInstances( void ) | 83 | Name2Instance_t & netNodeInstances( void ) |
80 | { return AllNodes; } | 84 | { return AllNodes; } |
81 | void addNodeInstance( ANetNodeInstance * I ) | 85 | void addNodeInstance( ANetNodeInstance * I ) |
82 | { AllNodes.insert( I->name(), I ); } | 86 | { AllNodes.insert( I->name(), I ); } |
83 | void removeNodeInstance( const QString & N ) | 87 | void removeNodeInstance( const QString & N ) |
84 | { AllNodes.remove( N );} | 88 | { AllNodes.remove( N );} |
85 | ANetNodeInstance * findNodeInstance( const QString & S ) | 89 | ANetNodeInstance * findNodeInstance( const QString & S ) |
86 | { return (AllNodes.find(S)!=0) ? AllNodes[S] : 0; } | 90 | { return (AllNodes.find(S)!=0) ? AllNodes[S] : 0; } |
87 | 91 | ||
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 ); |
95 | Name2Connection_t & connections( void ) | 98 | Name2Connection_t & connections( void ) |
96 | { return ConnectionsMap; } | 99 | { return ConnectionsMap; } |
97 | 100 | ||
98 | CurrentQPEUser & currentUser( void ) | 101 | CurrentQPEUser & currentUser( void ) |
99 | { return CurrentUser; } | 102 | { return CurrentUser; } |
100 | 103 | ||
101 | private : | 104 | private : |
102 | 105 | ||
103 | void detectCurrentUser( void ); | 106 | void detectCurrentUser( void ); |
104 | QString tr( const char * path ); | 107 | QString tr( const char * path ); |
105 | void findAvailableNetNodes( const QString &path ); | 108 | void findAvailableNetNodes( const QString &path ); |
106 | bool loadNetNode( | 109 | bool loadNetNode( |
107 | const QString &pluginFileName, | 110 | const QString &pluginFileName, |
108 | const QString &resolveString = "create_plugin"); | 111 | const QString &resolveString = "create_plugin"); |
109 | 112 | ||
110 | QMap< QString, QString> NodeTypeNameMap; | 113 | QMap< QString, QString> NodeTypeNameMap; |
111 | QMap< QString, QString> NodeTypeDescriptionMap; | 114 | QMap< QString, QString> NodeTypeDescriptionMap; |
112 | Name2Connection_t ConnectionsMap; | 115 | Name2Connection_t ConnectionsMap; |
113 | System * TheSystem; | 116 | System * TheSystem; |
114 | Name2SystemFile_t SystemFiles; | 117 | Name2SystemFile_t SystemFiles; |
115 | 118 | ||
116 | // all node type classes | 119 | // all node type classes |
117 | Name2NetNode_t AllNodeTypes; | 120 | Name2NetNode_t AllNodeTypes; |
118 | 121 | ||
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; |
126 | #define NSResources _NSResources | 129 | #define NSResources _NSResources |
127 | 130 | ||
128 | #endif | 131 | #endif |
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 | |||
@@ -1,355 +1,417 @@ | |||
1 | #include <sys/types.h> | 1 | #include <sys/types.h> |
2 | #include <sys/wait.h> | 2 | #include <sys/wait.h> |
3 | 3 | ||
4 | #include <net/if.h> | 4 | #include <net/if.h> |
5 | #include <net/if_arp.h> | 5 | #include <net/if_arp.h> |
6 | #include <netinet/in.h> | 6 | #include <netinet/in.h> |
7 | #include <arpa/inet.h> | 7 | #include <arpa/inet.h> |
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> |
14 | 15 | ||
15 | #include <qdir.h> | 16 | #include <qdir.h> |
16 | #include <qregexp.h> | 17 | #include <qregexp.h> |
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" |
23 | 25 | ||
24 | #define PROCNETDEV "/proc/net/dev" | 26 | #define PROCNETDEV "/proc/net/dev" |
25 | 27 | ||
26 | static char Dig2Hex[] = { | 28 | static char Dig2Hex[] = { |
27 | '0', '1', '2', '3', | 29 | '0', '1', '2', '3', |
28 | '4', '5', '6', '7', | 30 | '4', '5', '6', '7', |
29 | '8', '9', 'A', 'B', | 31 | '8', '9', 'A', 'B', |
30 | 'C', 'D', 'E', 'F' | 32 | 'C', 'D', 'E', 'F' |
31 | }; | 33 | }; |
32 | 34 | ||
33 | // get HIGH nibble of byte | 35 | // get HIGH nibble of byte |
34 | #define HN(x) Dig2Hex[(((x)&0xf0)>>4)] | 36 | #define HN(x) Dig2Hex[(((x)&0xf0)>>4)] |
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 | ||
42 | System::~System( void ) { | 44 | System::~System( void ) { |
43 | if( ProcDevNet ) | 45 | if( ProcDevNet ) |
44 | delete ProcDevNet; | 46 | delete ProcDevNet; |
45 | } | 47 | } |
46 | 48 | ||
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 |
54 | return 8888; | 56 | return 8888; |
55 | } | 57 | } |
56 | if( usr == 0 || strcmp( usr, "root" ) ) { | 58 | if( usr == 0 || strcmp( usr, "root" ) ) { |
57 | // unknown or non-root user -> use SUDO | 59 | // unknown or non-root user -> use SUDO |
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 | } |
80 | 107 | ||
81 | void System::refreshStatistics( InterfaceInfo & I ) { | 108 | void System::refreshStatistics( InterfaceInfo & I ) { |
82 | if( ! ProcDevNet ) { | 109 | if( ! ProcDevNet ) { |
83 | return; | 110 | return; |
84 | } | 111 | } |
85 | // cannot seek on dev | 112 | // cannot seek on dev |
86 | ProcDevNet->close(); | 113 | ProcDevNet->close(); |
87 | ProcDevNet->open( IO_ReadOnly ); | 114 | ProcDevNet->open( IO_ReadOnly ); |
88 | 115 | ||
89 | QString line; | 116 | QString line; |
90 | QTextStream procTs(ProcDevNet); | 117 | QTextStream procTs(ProcDevNet); |
91 | QStringList SL; | 118 | QStringList SL; |
92 | int loc = -1; | 119 | int loc = -1; |
93 | int version; | 120 | int version; |
94 | 121 | ||
95 | procTs.readLine(); | 122 | procTs.readLine(); |
96 | line = procTs.readLine(); | 123 | line = procTs.readLine(); |
97 | // get version | 124 | // get version |
98 | if( line.find("compressed") ) | 125 | if( line.find("compressed") ) |
99 | version = 3; | 126 | version = 3; |
100 | else if( line.find( "bytes" ) ) | 127 | else if( line.find( "bytes" ) ) |
101 | version = 2; | 128 | version = 2; |
102 | else | 129 | else |
103 | version = 1; | 130 | version = 1; |
104 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { | 131 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { |
105 | if( (loc = line.find(":") ) == -1) { | 132 | if( (loc = line.find(":") ) == -1) { |
106 | continue; | 133 | continue; |
107 | } | 134 | } |
108 | 135 | ||
109 | if( I.Name != line.left(loc) ) | 136 | if( I.Name != line.left(loc) ) |
110 | continue; | 137 | continue; |
111 | 138 | ||
112 | // tokenize | 139 | // tokenize |
113 | SL = QStringList::split( ' ', line, FALSE ); | 140 | SL = QStringList::split( ' ', line, FALSE ); |
114 | 141 | ||
115 | // update data | 142 | // update data |
116 | switch( version ) { | 143 | switch( version ) { |
117 | case 1 : | 144 | case 1 : |
118 | I.RcvBytes = SL[1]; | 145 | I.RcvBytes = SL[1]; |
119 | I.RcvErrors = SL[3]; | 146 | I.RcvErrors = SL[3]; |
120 | I.RcvDropped = SL[4]; | 147 | I.RcvDropped = SL[4]; |
121 | I.SndBytes = SL[6]; | 148 | I.SndBytes = SL[6]; |
122 | I.SndErrors = SL[8]; | 149 | I.SndErrors = SL[8]; |
123 | I.SndDropped = SL[9]; | 150 | I.SndDropped = SL[9]; |
124 | I.Collisions = SL[11]; | 151 | I.Collisions = SL[11]; |
125 | break; | 152 | break; |
126 | case 2 : | 153 | case 2 : |
127 | I.RcvBytes = SL[1]; | 154 | I.RcvBytes = SL[1]; |
128 | I.RcvErrors = SL[3]; | 155 | I.RcvErrors = SL[3]; |
129 | I.RcvDropped = SL[4]; | 156 | I.RcvDropped = SL[4]; |
130 | I.SndBytes = SL[7]; | 157 | I.SndBytes = SL[7]; |
131 | I.SndErrors = SL[9]; | 158 | I.SndErrors = SL[9]; |
132 | I.SndDropped = SL[10]; | 159 | I.SndDropped = SL[10]; |
133 | I.Collisions = SL[12]; | 160 | I.Collisions = SL[12]; |
134 | break; | 161 | break; |
135 | case 3 : | 162 | case 3 : |
136 | I.RcvBytes = SL[1]; | 163 | I.RcvBytes = SL[1]; |
137 | I.RcvErrors = SL[3]; | 164 | I.RcvErrors = SL[3]; |
138 | I.RcvDropped = SL[4]; | 165 | I.RcvDropped = SL[4]; |
139 | I.SndBytes = SL[9]; | 166 | I.SndBytes = SL[9]; |
140 | I.SndErrors = SL[11]; | 167 | I.SndErrors = SL[11]; |
141 | I.SndDropped = SL[12]; | 168 | I.SndDropped = SL[12]; |
142 | I.Collisions = SL[14]; | 169 | I.Collisions = SL[14]; |
143 | break; | 170 | break; |
144 | } | 171 | } |
145 | break; | 172 | break; |
146 | } | 173 | } |
147 | } | 174 | } |
148 | 175 | ||
149 | // | 176 | // |
150 | // THIS UPDATES THE LIST -> INTERFACES ARE NOT DELETED BUT | 177 | // THIS UPDATES THE LIST -> INTERFACES ARE NOT DELETED BUT |
151 | // FLAGGED AS ! 'IsUp' IF NO LONGER PRESENT | 178 | // FLAGGED AS ! 'IsUp' IF NO LONGER PRESENT |
152 | // | 179 | // |
153 | 180 | ||
154 | void System::probeInterfaces( void ) { | 181 | void System::probeInterfaces( void ) { |
155 | 182 | ||
156 | // probe interfaces | 183 | // probe interfaces |
157 | int sockfd; | 184 | int sockfd; |
158 | // get list of all interfaces | 185 | // get list of all interfaces |
159 | struct ifreq ifrs; | 186 | struct ifreq ifrs; |
160 | InterfaceInfo * IFI; | 187 | InterfaceInfo * IFI; |
161 | 188 | ||
162 | // flag all as 'down' | 189 | // flag all as 'down' |
163 | for( QDictIterator<InterfaceInfo> it( ProbedInterfaces ); | 190 | for( QDictIterator<InterfaceInfo> it( ProbedInterfaces ); |
164 | it.current(); | 191 | it.current(); |
165 | ++it ) { | 192 | ++it ) { |
166 | it.current()->IsUp = 0; | 193 | it.current()->IsUp = 0; |
167 | } | 194 | } |
168 | 195 | ||
169 | sockfd = socket(PF_INET, SOCK_DGRAM, 0); | 196 | sockfd = socket(PF_INET, SOCK_DGRAM, 0); |
170 | if(sockfd == -1) | 197 | if(sockfd == -1) |
171 | return; | 198 | return; |
172 | 199 | ||
173 | // read interfaces from /proc/dev/net | 200 | // read interfaces from /proc/dev/net |
174 | // SIOCGIFCONF does not return ALL interfaces ???!? | 201 | // SIOCGIFCONF does not return ALL interfaces ???!? |
175 | ProcDevNet = new QFile(PROCNETDEV); | 202 | ProcDevNet = new QFile(PROCNETDEV); |
176 | if( ! ProcDevNet->open(IO_ReadOnly) ) { | 203 | if( ! ProcDevNet->open(IO_ReadOnly) ) { |
177 | delete ProcDevNet; | 204 | delete ProcDevNet; |
178 | ProcDevNet =0; | 205 | ProcDevNet =0; |
179 | return; | 206 | return; |
180 | } | 207 | } |
181 | 208 | ||
182 | QString line; | 209 | QString line; |
183 | QString NicName; | 210 | QString NicName; |
184 | QTextStream procTs(ProcDevNet); | 211 | QTextStream procTs(ProcDevNet); |
185 | int loc = -1; | 212 | int loc = -1; |
186 | 213 | ||
187 | procTs.readLine(); // eat a line | 214 | procTs.readLine(); // eat a line |
188 | procTs.readLine(); // eat a line | 215 | procTs.readLine(); // eat a line |
189 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { | 216 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { |
190 | if((loc = line.find(":")) == -1) { | 217 | if((loc = line.find(":")) == -1) { |
191 | continue; | 218 | continue; |
192 | } | 219 | } |
193 | 220 | ||
194 | NicName = line.left(loc); | 221 | NicName = line.left(loc); |
195 | 222 | ||
196 | // set name for ioctl | 223 | // set name for ioctl |
197 | strcpy( ifrs.ifr_name, NicName.latin1() ); | 224 | strcpy( ifrs.ifr_name, NicName.latin1() ); |
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; |
205 | ProbedInterfaces.insert( IFI->Name, IFI ); | 232 | ProbedInterfaces.insert( IFI->Name, IFI ); |
206 | 233 | ||
207 | // get dynamic info | 234 | // get dynamic info |
208 | if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) { | 235 | if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) { |
209 | IFI->IsPointToPoint = ((ifrs.ifr_flags & IFF_POINTOPOINT) == IFF_POINTOPOINT); | 236 | IFI->IsPointToPoint = ((ifrs.ifr_flags & IFF_POINTOPOINT) == IFF_POINTOPOINT); |
210 | } else { | 237 | } else { |
211 | IFI->IsPointToPoint = 0; | 238 | IFI->IsPointToPoint = 0; |
212 | } | 239 | } |
213 | 240 | ||
214 | // settings that never change | 241 | // settings that never change |
215 | IFI->DstAddress = ""; | 242 | IFI->DstAddress = ""; |
216 | 243 | ||
217 | if( IFI->IsPointToPoint ) { | 244 | if( IFI->IsPointToPoint ) { |
218 | if( ioctl(sockfd, SIOCGIFDSTADDR, &ifrs) >= 0 ) { | 245 | if( ioctl(sockfd, SIOCGIFDSTADDR, &ifrs) >= 0 ) { |
219 | IFI->DstAddress = | 246 | IFI->DstAddress = |
220 | inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_dstaddr)->sin_addr); | 247 | inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_dstaddr)->sin_addr); |
221 | } | 248 | } |
222 | } | 249 | } |
223 | 250 | ||
224 | IFI->CardType = 999999; | 251 | IFI->CardType = 999999; |
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 ) { |
233 | case ARPHRD_ETHER : // regular MAC address | 260 | case ARPHRD_ETHER : // regular MAC address |
234 | // valid address -> convert to regular ::: format | 261 | // valid address -> convert to regular ::: format |
235 | // length = 6 bytes = 12 DIGITS -> 6 : | 262 | // length = 6 bytes = 12 DIGITS -> 6 : |
236 | IFI->MACAddress.sprintf( | 263 | IFI->MACAddress.sprintf( |
237 | "%c%c:%c%c:%c%c:%c%c:%c%c:%c%c", | 264 | "%c%c:%c%c:%c%c:%c%c:%c%c:%c%c", |
238 | HN( ifrs.ifr_hwaddr.sa_data[0] ), | 265 | HN( ifrs.ifr_hwaddr.sa_data[0] ), |
239 | LN( ifrs.ifr_hwaddr.sa_data[0] ), | 266 | LN( ifrs.ifr_hwaddr.sa_data[0] ), |
240 | HN( ifrs.ifr_hwaddr.sa_data[1] ), | 267 | HN( ifrs.ifr_hwaddr.sa_data[1] ), |
241 | LN( ifrs.ifr_hwaddr.sa_data[1] ), | 268 | LN( ifrs.ifr_hwaddr.sa_data[1] ), |
242 | HN( ifrs.ifr_hwaddr.sa_data[2] ), | 269 | HN( ifrs.ifr_hwaddr.sa_data[2] ), |
243 | LN( ifrs.ifr_hwaddr.sa_data[2] ), | 270 | LN( ifrs.ifr_hwaddr.sa_data[2] ), |
244 | HN( ifrs.ifr_hwaddr.sa_data[3] ), | 271 | HN( ifrs.ifr_hwaddr.sa_data[3] ), |
245 | LN( ifrs.ifr_hwaddr.sa_data[3] ), | 272 | LN( ifrs.ifr_hwaddr.sa_data[3] ), |
246 | HN( ifrs.ifr_hwaddr.sa_data[4] ), | 273 | HN( ifrs.ifr_hwaddr.sa_data[4] ), |
247 | LN( ifrs.ifr_hwaddr.sa_data[4] ), | 274 | LN( ifrs.ifr_hwaddr.sa_data[4] ), |
248 | HN( ifrs.ifr_hwaddr.sa_data[5] ), | 275 | HN( ifrs.ifr_hwaddr.sa_data[5] ), |
249 | LN( ifrs.ifr_hwaddr.sa_data[5] ) | 276 | LN( ifrs.ifr_hwaddr.sa_data[5] ) |
250 | ); | 277 | ); |
251 | break; | 278 | break; |
252 | #ifdef ARPHRD_IEEE1394 | 279 | #ifdef ARPHRD_IEEE1394 |
253 | case ARPHRD_IEEE1394 : // Firewire Eth address | 280 | case ARPHRD_IEEE1394 : // Firewire Eth address |
254 | IFI->MACAddress.sprintf( | 281 | IFI->MACAddress.sprintf( |
255 | "%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-00-00", | 282 | "%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-00-00", |
256 | HN( ifrs.ifr_hwaddr.sa_data[0] ), | 283 | HN( ifrs.ifr_hwaddr.sa_data[0] ), |
257 | LN( ifrs.ifr_hwaddr.sa_data[0] ), | 284 | LN( ifrs.ifr_hwaddr.sa_data[0] ), |
258 | HN( ifrs.ifr_hwaddr.sa_data[1] ), | 285 | HN( ifrs.ifr_hwaddr.sa_data[1] ), |
259 | LN( ifrs.ifr_hwaddr.sa_data[1] ), | 286 | LN( ifrs.ifr_hwaddr.sa_data[1] ), |
260 | HN( ifrs.ifr_hwaddr.sa_data[2] ), | 287 | HN( ifrs.ifr_hwaddr.sa_data[2] ), |
261 | LN( ifrs.ifr_hwaddr.sa_data[2] ), | 288 | LN( ifrs.ifr_hwaddr.sa_data[2] ), |
262 | HN( ifrs.ifr_hwaddr.sa_data[3] ), | 289 | HN( ifrs.ifr_hwaddr.sa_data[3] ), |
263 | LN( ifrs.ifr_hwaddr.sa_data[3] ), | 290 | LN( ifrs.ifr_hwaddr.sa_data[3] ), |
264 | HN( ifrs.ifr_hwaddr.sa_data[4] ), | 291 | HN( ifrs.ifr_hwaddr.sa_data[4] ), |
265 | LN( ifrs.ifr_hwaddr.sa_data[4] ), | 292 | LN( ifrs.ifr_hwaddr.sa_data[4] ), |
266 | HN( ifrs.ifr_hwaddr.sa_data[5] ), | 293 | HN( ifrs.ifr_hwaddr.sa_data[5] ), |
267 | LN( ifrs.ifr_hwaddr.sa_data[5] ), | 294 | LN( ifrs.ifr_hwaddr.sa_data[5] ), |
268 | HN( ifrs.ifr_hwaddr.sa_data[6] ), | 295 | HN( ifrs.ifr_hwaddr.sa_data[6] ), |
269 | LN( ifrs.ifr_hwaddr.sa_data[6] ), | 296 | LN( ifrs.ifr_hwaddr.sa_data[6] ), |
270 | HN( ifrs.ifr_hwaddr.sa_data[7] ), | 297 | HN( ifrs.ifr_hwaddr.sa_data[7] ), |
271 | LN( ifrs.ifr_hwaddr.sa_data[7] ), | 298 | LN( ifrs.ifr_hwaddr.sa_data[7] ), |
272 | HN( ifrs.ifr_hwaddr.sa_data[8] ), | 299 | HN( ifrs.ifr_hwaddr.sa_data[8] ), |
273 | LN( ifrs.ifr_hwaddr.sa_data[8] ), | 300 | LN( ifrs.ifr_hwaddr.sa_data[8] ), |
274 | HN( ifrs.ifr_hwaddr.sa_data[9] ), | 301 | HN( ifrs.ifr_hwaddr.sa_data[9] ), |
275 | LN( ifrs.ifr_hwaddr.sa_data[9] ), | 302 | LN( ifrs.ifr_hwaddr.sa_data[9] ), |
276 | HN( ifrs.ifr_hwaddr.sa_data[10] ), | 303 | HN( ifrs.ifr_hwaddr.sa_data[10] ), |
277 | LN( ifrs.ifr_hwaddr.sa_data[10] ), | 304 | LN( ifrs.ifr_hwaddr.sa_data[10] ), |
278 | HN( ifrs.ifr_hwaddr.sa_data[11] ), | 305 | HN( ifrs.ifr_hwaddr.sa_data[11] ), |
279 | LN( ifrs.ifr_hwaddr.sa_data[11] ), | 306 | LN( ifrs.ifr_hwaddr.sa_data[11] ), |
280 | HN( ifrs.ifr_hwaddr.sa_data[12] ), | 307 | HN( ifrs.ifr_hwaddr.sa_data[12] ), |
281 | LN( ifrs.ifr_hwaddr.sa_data[12] ), | 308 | LN( ifrs.ifr_hwaddr.sa_data[12] ), |
282 | HN( ifrs.ifr_hwaddr.sa_data[13] ), | 309 | HN( ifrs.ifr_hwaddr.sa_data[13] ), |
283 | LN( ifrs.ifr_hwaddr.sa_data[13] ) | 310 | LN( ifrs.ifr_hwaddr.sa_data[13] ) |
284 | ); | 311 | ); |
285 | break; | 312 | break; |
286 | #endif | 313 | #endif |
287 | case ARPHRD_PPP : // PPP | 314 | case ARPHRD_PPP : // PPP |
288 | break; | 315 | break; |
289 | case ARPHRD_IEEE80211 : // WLAN | 316 | case ARPHRD_IEEE80211 : // WLAN |
290 | break; | 317 | break; |
291 | case ARPHRD_IRDA : // IRDA | 318 | case ARPHRD_IRDA : // IRDA |
292 | break; | 319 | break; |
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 ) { |
300 | IFI->IsUp = ((ifrs.ifr_flags & IFF_UP) == IFF_UP); | 327 | IFI->IsUp = ((ifrs.ifr_flags & IFF_UP) == IFF_UP); |
301 | IFI->HasMulticast = ((ifrs.ifr_flags & IFF_MULTICAST) == IFF_MULTICAST); | 328 | IFI->HasMulticast = ((ifrs.ifr_flags & IFF_MULTICAST) == IFF_MULTICAST); |
302 | } else { | 329 | } else { |
303 | IFI->IsUp = 0; | 330 | IFI->IsUp = 0; |
304 | IFI->HasMulticast = 0; | 331 | IFI->HasMulticast = 0; |
305 | } | 332 | } |
306 | 333 | ||
307 | if( ioctl(sockfd, SIOCGIFADDR, &ifrs) >= 0 ) { | 334 | if( ioctl(sockfd, SIOCGIFADDR, &ifrs) >= 0 ) { |
308 | IFI->Address = | 335 | IFI->Address = |
309 | inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_addr)->sin_addr); | 336 | inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_addr)->sin_addr); |
310 | } else { | 337 | } else { |
311 | IFI->Address = ""; | 338 | IFI->Address = ""; |
312 | IFI->IsUp = 0; | 339 | IFI->IsUp = 0; |
313 | } | 340 | } |
314 | if( ioctl(sockfd, SIOCGIFBRDADDR, &ifrs) >= 0 ) { | 341 | if( ioctl(sockfd, SIOCGIFBRDADDR, &ifrs) >= 0 ) { |
315 | IFI->BCastAddress = | 342 | IFI->BCastAddress = |
316 | inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_broadaddr)->sin_addr); | 343 | inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_broadaddr)->sin_addr); |
317 | } else { | 344 | } else { |
318 | IFI->BCastAddress = ""; | 345 | IFI->BCastAddress = ""; |
319 | } | 346 | } |
320 | if( ioctl(sockfd, SIOCGIFNETMASK, &ifrs) >= 0 ) { | 347 | if( ioctl(sockfd, SIOCGIFNETMASK, &ifrs) >= 0 ) { |
321 | IFI->Netmask = | 348 | IFI->Netmask = |
322 | inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_netmask)->sin_addr); | 349 | inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_netmask)->sin_addr); |
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 | ||
330 | void System::execAsUser( QString & Cmd, char * argv[] ) { | 357 | void System::execAsUser( QString & Cmd, char * argv[] ) { |
331 | CurrentQPEUser CU = NSResources->currentUser(); | 358 | CurrentQPEUser CU = NSResources->currentUser(); |
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 | ||
339 | // now we are ready to exec the requested command | 366 | // now we are ready to exec the requested command |
340 | setuid( CU.Uid ); | 367 | setuid( CU.Uid ); |
341 | setgid( CU.Gid ); | 368 | setgid( CU.Gid ); |
342 | 369 | ||
343 | char ** envp = (char **)alloca( sizeof( char *) * | 370 | char ** envp = (char **)alloca( sizeof( char *) * |
344 | (CU.EnvList.count()+1) ); | 371 | (CU.EnvList.count()+1) ); |
345 | 372 | ||
346 | for( unsigned int i = 0 ; i < CU.EnvList.count() ; i ++ ) { | 373 | for( unsigned int i = 0 ; i < CU.EnvList.count() ; i ++ ) { |
347 | *(envp+i) = CU.EnvList[i]; | 374 | *(envp+i) = CU.EnvList[i]; |
348 | } | 375 | } |
349 | envp[CU.EnvList.count()]=NULL; | 376 | envp[CU.EnvList.count()]=NULL; |
350 | 377 | ||
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 | |||
@@ -1,81 +1,90 @@ | |||
1 | #ifndef __SYSTEM__H | 1 | #ifndef __SYSTEM__H |
2 | #define __SYSTEM__H | 2 | #define __SYSTEM__H |
3 | 3 | ||
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; |
10 | 12 | ||
11 | class InterfaceInfo { | 13 | class InterfaceInfo { |
12 | 14 | ||
13 | public : | 15 | public : |
14 | 16 | ||
15 | InterfaceInfo() : | 17 | InterfaceInfo() : |
16 | Name(), | 18 | Name(), |
17 | MACAddress(), | 19 | MACAddress(), |
18 | BCastAddress(), | 20 | BCastAddress(), |
19 | Netmask(), | 21 | Netmask(), |
20 | DstAddress() { | 22 | DstAddress() { |
21 | } | 23 | } |
22 | 24 | ||
23 | ANetNodeInstance * assignedNode() | 25 | ANetNodeInstance * assignedNode() |
24 | { return NetNode; } | 26 | { return NetNode; } |
25 | 27 | ||
26 | void assignNode( ANetNodeInstance * NNI ) | 28 | void assignNode( ANetNodeInstance * NNI ) |
27 | { NetNode = NNI; } | 29 | { NetNode = NNI; } |
28 | 30 | ||
29 | ANetNodeInstance * NetNode; // netnode taking care of me | 31 | ANetNodeInstance * NetNode; // netnode taking care of me |
30 | QString Name; // name of interface | 32 | QString Name; // name of interface |
31 | int CardType; // type of card | 33 | int CardType; // type of card |
32 | QString MACAddress; // MAC address | 34 | QString MACAddress; // MAC address |
33 | QString Address; // IP Address | 35 | QString Address; // IP Address |
34 | QString BCastAddress; // Broadcast Address | 36 | QString BCastAddress; // Broadcast Address |
35 | QString Netmask; // Netmask | 37 | QString Netmask; // Netmask |
36 | QString DstAddress; // Peer address (if P-t-P) | 38 | QString DstAddress; // Peer address (if P-t-P) |
37 | bool IsUp; // interface is UP | 39 | bool IsUp; // interface is UP |
38 | bool HasMulticast; // Supports Multicast | 40 | bool HasMulticast; // Supports Multicast |
39 | bool IsPointToPoint; // IsPointToPoint card | 41 | bool IsPointToPoint; // IsPointToPoint card |
40 | 42 | ||
41 | QString RcvBytes; | 43 | QString RcvBytes; |
42 | QString SndBytes; | 44 | QString SndBytes; |
43 | QString RcvErrors; | 45 | QString RcvErrors; |
44 | QString SndErrors; | 46 | QString SndErrors; |
45 | QString RcvDropped; | 47 | QString RcvDropped; |
46 | QString SndDropped; | 48 | QString SndDropped; |
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 | ||
54 | System( void ); | 58 | System( void ); |
55 | ~System( void ); | 59 | ~System( void ); |
56 | 60 | ||
57 | QDict<InterfaceInfo> & interfaces( void ) | 61 | QDict<InterfaceInfo> & interfaces( void ) |
58 | { return ProbedInterfaces; } | 62 | { return ProbedInterfaces; } |
59 | InterfaceInfo * interface( const QString& N ) | 63 | InterfaceInfo * interface( const QString& N ) |
60 | { return ProbedInterfaces[N]; } | 64 | { return ProbedInterfaces[N]; } |
61 | 65 | ||
62 | // exec command as root | 66 | // exec command as root |
63 | int runAsRoot( const QString & S ); | 67 | int runAsRoot( const QString & S ); |
64 | 68 | ||
65 | // exec command as user | 69 | // exec command as user |
66 | void execAsUser( QString & Cmd, char * argv[] ); | 70 | void execAsUser( QString & Cmd, char * argv[] ); |
67 | 71 | ||
68 | // refresh stats for this interface | 72 | // refresh stats for this interface |
69 | void refreshStatistics( InterfaceInfo & ); | 73 | void refreshStatistics( InterfaceInfo & ); |
70 | 74 | ||
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 | }; |
80 | 89 | ||
81 | #endif | 90 | #endif |
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 | |||
@@ -1,630 +1,572 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>NetworkSettingsGUI</class> | 2 | <class>NetworkSettingsGUI</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QWidget</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>NetworkSettingsGUI</cstring> | 7 | <cstring>NetworkSettingsGUI</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>160</width> | 14 | <width>144</width> |
15 | <height>260</height> | 15 | <height>260</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>Network Settings</string> | 20 | <string>Network Settings</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>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> |
35 | <number>2</number> | 35 | <number>2</number> |
36 | </property> | 36 | </property> |
37 | <widget> | 37 | <widget> |
38 | <class>QFrame</class> | 38 | <class>QFrame</class> |
39 | <property stdset="1"> | 39 | <property stdset="1"> |
40 | <name>name</name> | 40 | <name>name</name> |
41 | <cstring>Frame4</cstring> | 41 | <cstring>Frame4</cstring> |
42 | </property> | 42 | </property> |
43 | <property stdset="1"> | 43 | <property stdset="1"> |
44 | <name>sizePolicy</name> | 44 | <name>sizePolicy</name> |
45 | <sizepolicy> | 45 | <sizepolicy> |
46 | <hsizetype>7</hsizetype> | 46 | <hsizetype>7</hsizetype> |
47 | <vsizetype>0</vsizetype> | 47 | <vsizetype>0</vsizetype> |
48 | </sizepolicy> | 48 | </sizepolicy> |
49 | </property> | 49 | </property> |
50 | <property stdset="1"> | 50 | <property stdset="1"> |
51 | <name>frameShape</name> | 51 | <name>frameShape</name> |
52 | <enum>NoFrame</enum> | 52 | <enum>NoFrame</enum> |
53 | </property> | 53 | </property> |
54 | <property stdset="1"> | 54 | <property stdset="1"> |
55 | <name>frameShadow</name> | 55 | <name>frameShadow</name> |
56 | <enum>Raised</enum> | 56 | <enum>Raised</enum> |
57 | </property> | 57 | </property> |
58 | <property> | 58 | <property> |
59 | <name>layoutMargin</name> | 59 | <name>layoutMargin</name> |
60 | </property> | 60 | </property> |
61 | <property> | 61 | <property> |
62 | <name>layoutSpacing</name> | 62 | <name>layoutSpacing</name> |
63 | </property> | 63 | </property> |
64 | <hbox> | 64 | <hbox> |
65 | <property stdset="1"> | 65 | <property stdset="1"> |
66 | <name>margin</name> | 66 | <name>margin</name> |
67 | <number>0</number> | 67 | <number>0</number> |
68 | </property> | 68 | </property> |
69 | <property stdset="1"> | 69 | <property stdset="1"> |
70 | <name>spacing</name> | 70 | <name>spacing</name> |
71 | <number>1</number> | 71 | <number>1</number> |
72 | </property> | 72 | </property> |
73 | <widget> | 73 | <widget> |
74 | <class>QToolButton</class> | 74 | <class>QToolButton</class> |
75 | <property stdset="1"> | 75 | <property stdset="1"> |
76 | <name>name</name> | 76 | <name>name</name> |
77 | <cstring>Add_TB</cstring> | 77 | <cstring>Add_TB</cstring> |
78 | </property> | 78 | </property> |
79 | <property stdset="1"> | 79 | <property stdset="1"> |
80 | <name>sizePolicy</name> | 80 | <name>sizePolicy</name> |
81 | <sizepolicy> | 81 | <sizepolicy> |
82 | <hsizetype>0</hsizetype> | 82 | <hsizetype>0</hsizetype> |
83 | <vsizetype>0</vsizetype> | 83 | <vsizetype>0</vsizetype> |
84 | </sizepolicy> | 84 | </sizepolicy> |
85 | </property> | 85 | </property> |
86 | <property stdset="1"> | 86 | <property stdset="1"> |
87 | <name>text</name> | 87 | <name>text</name> |
88 | <string>...</string> | 88 | <string>...</string> |
89 | </property> | 89 | </property> |
90 | </widget> | 90 | </widget> |
91 | <widget> | 91 | <widget> |
92 | <class>QToolButton</class> | 92 | <class>QToolButton</class> |
93 | <property stdset="1"> | 93 | <property stdset="1"> |
94 | <name>name</name> | 94 | <name>name</name> |
95 | <cstring>Delete_TB</cstring> | 95 | <cstring>Delete_TB</cstring> |
96 | </property> | 96 | </property> |
97 | <property stdset="1"> | 97 | <property stdset="1"> |
98 | <name>sizePolicy</name> | 98 | <name>sizePolicy</name> |
99 | <sizepolicy> | 99 | <sizepolicy> |
100 | <hsizetype>0</hsizetype> | 100 | <hsizetype>0</hsizetype> |
101 | <vsizetype>0</vsizetype> | 101 | <vsizetype>0</vsizetype> |
102 | </sizepolicy> | 102 | </sizepolicy> |
103 | </property> | 103 | </property> |
104 | <property stdset="1"> | 104 | <property stdset="1"> |
105 | <name>text</name> | 105 | <name>text</name> |
106 | <string>...</string> | 106 | <string>...</string> |
107 | </property> | 107 | </property> |
108 | </widget> | 108 | </widget> |
109 | <widget> | 109 | <widget> |
110 | <class>QToolButton</class> | 110 | <class>QToolButton</class> |
111 | <property stdset="1"> | 111 | <property stdset="1"> |
112 | <name>name</name> | 112 | <name>name</name> |
113 | <cstring>CheckState_TB</cstring> | 113 | <cstring>CheckState_TB</cstring> |
114 | </property> | 114 | </property> |
115 | <property stdset="1"> | 115 | <property stdset="1"> |
116 | <name>sizePolicy</name> | 116 | <name>sizePolicy</name> |
117 | <sizepolicy> | 117 | <sizepolicy> |
118 | <hsizetype>0</hsizetype> | 118 | <hsizetype>0</hsizetype> |
119 | <vsizetype>0</vsizetype> | 119 | <vsizetype>0</vsizetype> |
120 | </sizepolicy> | 120 | </sizepolicy> |
121 | </property> | 121 | </property> |
122 | <property stdset="1"> | 122 | <property stdset="1"> |
123 | <name>text</name> | 123 | <name>text</name> |
124 | <string>...</string> | 124 | <string>...</string> |
125 | </property> | 125 | </property> |
126 | </widget> | 126 | </widget> |
127 | <widget> | 127 | <widget> |
128 | <class>QToolButton</class> | 128 | <class>QToolButton</class> |
129 | <property stdset="1"> | 129 | <property stdset="1"> |
130 | <name>name</name> | 130 | <name>name</name> |
131 | <cstring>GenConfig_TB</cstring> | 131 | <cstring>GenConfig_TB</cstring> |
132 | </property> | 132 | </property> |
133 | <property stdset="1"> | 133 | <property stdset="1"> |
134 | <name>sizePolicy</name> | 134 | <name>sizePolicy</name> |
135 | <sizepolicy> | 135 | <sizepolicy> |
136 | <hsizetype>0</hsizetype> | 136 | <hsizetype>0</hsizetype> |
137 | <vsizetype>0</vsizetype> | 137 | <vsizetype>0</vsizetype> |
138 | </sizepolicy> | 138 | </sizepolicy> |
139 | </property> | 139 | </property> |
140 | <property stdset="1"> | 140 | <property stdset="1"> |
141 | <name>text</name> | 141 | <name>text</name> |
142 | <string>...</string> | 142 | <string>...</string> |
143 | </property> | 143 | </property> |
144 | </widget> | 144 | </widget> |
145 | <spacer> | 145 | <spacer> |
146 | <property> | 146 | <property> |
147 | <name>name</name> | 147 | <name>name</name> |
148 | <cstring>Spacer1</cstring> | 148 | <cstring>Spacer1</cstring> |
149 | </property> | 149 | </property> |
150 | <property stdset="1"> | 150 | <property stdset="1"> |
151 | <name>orientation</name> | 151 | <name>orientation</name> |
152 | <enum>Horizontal</enum> | 152 | <enum>Horizontal</enum> |
153 | </property> | 153 | </property> |
154 | <property stdset="1"> | 154 | <property stdset="1"> |
155 | <name>sizeType</name> | 155 | <name>sizeType</name> |
156 | <enum>Expanding</enum> | 156 | <enum>Expanding</enum> |
157 | </property> | 157 | </property> |
158 | <property> | 158 | <property> |
159 | <name>sizeHint</name> | 159 | <name>sizeHint</name> |
160 | <size> | 160 | <size> |
161 | <width>20</width> | 161 | <width>20</width> |
162 | <height>20</height> | 162 | <height>20</height> |
163 | </size> | 163 | </size> |
164 | </property> | 164 | </property> |
165 | </spacer> | 165 | </spacer> |
166 | <widget> | 166 | <widget> |
167 | <class>QToolButton</class> | 167 | <class>QToolButton</class> |
168 | <property stdset="1"> | 168 | <property stdset="1"> |
169 | <name>name</name> | 169 | <name>name</name> |
170 | <cstring>Enable_TB</cstring> | 170 | <cstring>Enable_TB</cstring> |
171 | </property> | 171 | </property> |
172 | <property stdset="1"> | 172 | <property stdset="1"> |
173 | <name>sizePolicy</name> | 173 | <name>sizePolicy</name> |
174 | <sizepolicy> | 174 | <sizepolicy> |
175 | <hsizetype>0</hsizetype> | 175 | <hsizetype>0</hsizetype> |
176 | <vsizetype>0</vsizetype> | 176 | <vsizetype>0</vsizetype> |
177 | </sizepolicy> | 177 | </sizepolicy> |
178 | </property> | 178 | </property> |
179 | <property stdset="1"> | 179 | <property stdset="1"> |
180 | <name>text</name> | 180 | <name>text</name> |
181 | <string>...</string> | 181 | <string>...</string> |
182 | </property> | 182 | </property> |
183 | <property stdset="1"> | 183 | <property stdset="1"> |
184 | <name>toggleButton</name> | 184 | <name>toggleButton</name> |
185 | <bool>true</bool> | 185 | <bool>true</bool> |
186 | </property> | 186 | </property> |
187 | <property stdset="1"> | 187 | <property stdset="1"> |
188 | <name>toggleButton</name> | 188 | <name>toggleButton</name> |
189 | <bool>true</bool> | 189 | <bool>true</bool> |
190 | </property> | 190 | </property> |
191 | </widget> | 191 | </widget> |
192 | <widget> | 192 | <widget> |
193 | <class>QToolButton</class> | 193 | <class>QToolButton</class> |
194 | <property stdset="1"> | 194 | <property stdset="1"> |
195 | <name>name</name> | 195 | <name>name</name> |
196 | <cstring>On_TB</cstring> | 196 | <cstring>On_TB</cstring> |
197 | </property> | 197 | </property> |
198 | <property stdset="1"> | 198 | <property stdset="1"> |
199 | <name>sizePolicy</name> | 199 | <name>sizePolicy</name> |
200 | <sizepolicy> | 200 | <sizepolicy> |
201 | <hsizetype>0</hsizetype> | 201 | <hsizetype>0</hsizetype> |
202 | <vsizetype>0</vsizetype> | 202 | <vsizetype>0</vsizetype> |
203 | </sizepolicy> | 203 | </sizepolicy> |
204 | </property> | 204 | </property> |
205 | <property stdset="1"> | 205 | <property stdset="1"> |
206 | <name>text</name> | 206 | <name>text</name> |
207 | <string>...</string> | 207 | <string>...</string> |
208 | </property> | 208 | </property> |
209 | <property stdset="1"> | 209 | <property stdset="1"> |
210 | <name>toggleButton</name> | 210 | <name>toggleButton</name> |
211 | <bool>true</bool> | 211 | <bool>true</bool> |
212 | </property> | 212 | </property> |
213 | <property stdset="1"> | 213 | <property stdset="1"> |
214 | <name>toggleButton</name> | 214 | <name>toggleButton</name> |
215 | <bool>true</bool> | 215 | <bool>true</bool> |
216 | </property> | 216 | </property> |
217 | </widget> | 217 | </widget> |
218 | <widget> | 218 | <widget> |
219 | <class>QToolButton</class> | 219 | <class>QToolButton</class> |
220 | <property stdset="1"> | 220 | <property stdset="1"> |
221 | <name>name</name> | 221 | <name>name</name> |
222 | <cstring>Connect_TB</cstring> | 222 | <cstring>Connect_TB</cstring> |
223 | </property> | 223 | </property> |
224 | <property stdset="1"> | 224 | <property stdset="1"> |
225 | <name>sizePolicy</name> | 225 | <name>sizePolicy</name> |
226 | <sizepolicy> | 226 | <sizepolicy> |
227 | <hsizetype>0</hsizetype> | 227 | <hsizetype>0</hsizetype> |
228 | <vsizetype>0</vsizetype> | 228 | <vsizetype>0</vsizetype> |
229 | </sizepolicy> | 229 | </sizepolicy> |
230 | </property> | 230 | </property> |
231 | <property stdset="1"> | 231 | <property stdset="1"> |
232 | <name>text</name> | 232 | <name>text</name> |
233 | <string>...</string> | 233 | <string>...</string> |
234 | </property> | 234 | </property> |
235 | <property stdset="1"> | 235 | <property stdset="1"> |
236 | <name>toggleButton</name> | 236 | <name>toggleButton</name> |
237 | <bool>true</bool> | 237 | <bool>true</bool> |
238 | </property> | 238 | </property> |
239 | <property stdset="1"> | 239 | <property stdset="1"> |
240 | <name>toggleButton</name> | 240 | <name>toggleButton</name> |
241 | <bool>true</bool> | 241 | <bool>true</bool> |
242 | </property> | 242 | </property> |
243 | </widget> | 243 | </widget> |
244 | <widget> | 244 | <widget> |
245 | <class>QToolButton</class> | 245 | <class>QToolButton</class> |
246 | <property stdset="1"> | 246 | <property stdset="1"> |
247 | <name>name</name> | 247 | <name>name</name> |
248 | <cstring>Disconnect_TB</cstring> | 248 | <cstring>Disconnect_TB</cstring> |
249 | </property> | 249 | </property> |
250 | <property stdset="1"> | 250 | <property stdset="1"> |
251 | <name>sizePolicy</name> | 251 | <name>sizePolicy</name> |
252 | <sizepolicy> | 252 | <sizepolicy> |
253 | <hsizetype>0</hsizetype> | 253 | <hsizetype>0</hsizetype> |
254 | <vsizetype>0</vsizetype> | 254 | <vsizetype>0</vsizetype> |
255 | </sizepolicy> | 255 | </sizepolicy> |
256 | </property> | 256 | </property> |
257 | <property stdset="1"> | 257 | <property stdset="1"> |
258 | <name>text</name> | 258 | <name>text</name> |
259 | <string>...</string> | 259 | <string>...</string> |
260 | </property> | 260 | </property> |
261 | <property stdset="1"> | 261 | <property stdset="1"> |
262 | <name>toggleButton</name> | 262 | <name>toggleButton</name> |
263 | <bool>true</bool> | 263 | <bool>true</bool> |
264 | </property> | 264 | </property> |
265 | <property stdset="1"> | 265 | <property stdset="1"> |
266 | <name>toggleButton</name> | 266 | <name>toggleButton</name> |
267 | <bool>true</bool> | 267 | <bool>true</bool> |
268 | </property> | 268 | </property> |
269 | </widget> | 269 | </widget> |
270 | </hbox> | 270 | </hbox> |
271 | </widget> | 271 | </widget> |
272 | <widget> | 272 | <widget> |
273 | <class>QListBox</class> | 273 | <class>QListBox</class> |
274 | <property stdset="1"> | 274 | <property stdset="1"> |
275 | <name>name</name> | 275 | <name>name</name> |
276 | <cstring>Profiles_LB</cstring> | 276 | <cstring>Profiles_LB</cstring> |
277 | </property> | 277 | </property> |
278 | </widget> | 278 | </widget> |
279 | <widget> | 279 | <widget> |
280 | <class>QGroupBox</class> | 280 | <class>QGroupBox</class> |
281 | <property stdset="1"> | 281 | <property stdset="1"> |
282 | <name>name</name> | 282 | <name>name</name> |
283 | <cstring>Profile_GB</cstring> | 283 | <cstring>Profile_GB</cstring> |
284 | </property> | 284 | </property> |
285 | <property stdset="1"> | 285 | <property stdset="1"> |
286 | <name>title</name> | 286 | <name>title</name> |
287 | <string>Profile</string> | 287 | <string>Profile</string> |
288 | </property> | 288 | </property> |
289 | <property> | 289 | <property> |
290 | <name>layoutMargin</name> | 290 | <name>layoutMargin</name> |
291 | </property> | 291 | </property> |
292 | <property> | 292 | <property> |
293 | <name>layoutSpacing</name> | 293 | <name>layoutSpacing</name> |
294 | </property> | 294 | </property> |
295 | <vbox> | 295 | <vbox> |
296 | <property stdset="1"> | 296 | <property stdset="1"> |
297 | <name>margin</name> | 297 | <name>margin</name> |
298 | <number>4</number> | 298 | <number>4</number> |
299 | </property> | 299 | </property> |
300 | <property stdset="1"> | 300 | <property stdset="1"> |
301 | <name>spacing</name> | 301 | <name>spacing</name> |
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> |
372 | <cstring>Description_LBL</cstring> | 308 | <cstring>Description_LBL</cstring> |
373 | </property> | 309 | </property> |
374 | <property stdset="1"> | 310 | <property stdset="1"> |
375 | <name>sizePolicy</name> | 311 | <name>sizePolicy</name> |
376 | <sizepolicy> | 312 | <sizepolicy> |
377 | <hsizetype>5</hsizetype> | 313 | <hsizetype>5</hsizetype> |
378 | <vsizetype>7</vsizetype> | 314 | <vsizetype>7</vsizetype> |
379 | </sizepolicy> | 315 | </sizepolicy> |
380 | </property> | 316 | </property> |
381 | <property stdset="1"> | 317 | <property stdset="1"> |
382 | <name>frameShape</name> | 318 | <name>frameShape</name> |
383 | <enum>NoFrame</enum> | 319 | <enum>NoFrame</enum> |
384 | </property> | 320 | </property> |
385 | <property stdset="1"> | 321 | <property stdset="1"> |
386 | <name>frameShadow</name> | 322 | <name>frameShadow</name> |
387 | <enum>Raised</enum> | 323 | <enum>Raised</enum> |
388 | </property> | 324 | </property> |
389 | <property stdset="1"> | 325 | <property stdset="1"> |
390 | <name>text</name> | 326 | <name>text</name> |
391 | <string></string> | 327 | <string></string> |
392 | </property> | 328 | </property> |
393 | <property stdset="1"> | 329 | <property stdset="1"> |
394 | <name>alignment</name> | 330 | <name>alignment</name> |
395 | <set>AlignTop|AlignLeft</set> | 331 | <set>AlignTop|AlignLeft</set> |
396 | </property> | 332 | </property> |
397 | <property> | 333 | <property> |
398 | <name>vAlign</name> | 334 | <name>vAlign</name> |
399 | </property> | 335 | </property> |
400 | </widget> | 336 | </widget> |
401 | <widget> | 337 | <widget> |
402 | <class>QLayoutWidget</class> | 338 | <class>QLayoutWidget</class> |
403 | <property stdset="1"> | 339 | <property stdset="1"> |
404 | <name>name</name> | 340 | <name>name</name> |
405 | <cstring>Layout4</cstring> | 341 | <cstring>Layout4</cstring> |
406 | </property> | 342 | </property> |
407 | <hbox> | 343 | <hbox> |
408 | <property stdset="1"> | 344 | <property stdset="1"> |
409 | <name>margin</name> | 345 | <name>margin</name> |
410 | <number>0</number> | 346 | <number>0</number> |
411 | </property> | 347 | </property> |
412 | <property stdset="1"> | 348 | <property stdset="1"> |
413 | <name>spacing</name> | 349 | <name>spacing</name> |
414 | <number>6</number> | 350 | <number>6</number> |
415 | </property> | 351 | </property> |
416 | <spacer> | 352 | <spacer> |
417 | <property> | 353 | <property> |
418 | <name>name</name> | 354 | <name>name</name> |
419 | <cstring>Spacer4</cstring> | 355 | <cstring>Spacer4</cstring> |
420 | </property> | 356 | </property> |
421 | <property stdset="1"> | 357 | <property stdset="1"> |
422 | <name>orientation</name> | 358 | <name>orientation</name> |
423 | <enum>Horizontal</enum> | 359 | <enum>Horizontal</enum> |
424 | </property> | 360 | </property> |
425 | <property stdset="1"> | 361 | <property stdset="1"> |
426 | <name>sizeType</name> | 362 | <name>sizeType</name> |
427 | <enum>Expanding</enum> | 363 | <enum>Expanding</enum> |
428 | </property> | 364 | </property> |
429 | <property> | 365 | <property> |
430 | <name>sizeHint</name> | 366 | <name>sizeHint</name> |
431 | <size> | 367 | <size> |
432 | <width>20</width> | 368 | <width>20</width> |
433 | <height>20</height> | 369 | <height>20</height> |
434 | </size> | 370 | </size> |
435 | </property> | 371 | </property> |
436 | </spacer> | 372 | </spacer> |
437 | <widget> | 373 | <widget> |
438 | <class>QPushButton</class> | 374 | <class>QPushButton</class> |
439 | <property stdset="1"> | 375 | <property stdset="1"> |
440 | <name>name</name> | 376 | <name>name</name> |
441 | <cstring>ToMessages_BUT</cstring> | 377 | <cstring>ToMessages_BUT</cstring> |
442 | </property> | 378 | </property> |
443 | <property stdset="1"> | 379 | <property stdset="1"> |
444 | <name>sizePolicy</name> | 380 | <name>sizePolicy</name> |
445 | <sizepolicy> | 381 | <sizepolicy> |
446 | <hsizetype>1</hsizetype> | 382 | <hsizetype>1</hsizetype> |
447 | <vsizetype>0</vsizetype> | 383 | <vsizetype>0</vsizetype> |
448 | </sizepolicy> | 384 | </sizepolicy> |
449 | </property> | 385 | </property> |
450 | <property stdset="1"> | 386 | <property stdset="1"> |
451 | <name>text</name> | 387 | <name>text</name> |
452 | <string>Messages ...</string> | 388 | <string>Messages ...</string> |
453 | </property> | 389 | </property> |
454 | </widget> | 390 | </widget> |
455 | </hbox> | 391 | </hbox> |
456 | </widget> | 392 | </widget> |
457 | </vbox> | 393 | </vbox> |
458 | </widget> | 394 | </widget> |
459 | <widget> | 395 | <widget> |
460 | <class>QGroupBox</class> | 396 | <class>QGroupBox</class> |
461 | <property stdset="1"> | 397 | <property stdset="1"> |
462 | <name>name</name> | 398 | <name>name</name> |
463 | <cstring>Messages_GB</cstring> | 399 | <cstring>Messages_GB</cstring> |
464 | </property> | 400 | </property> |
465 | <property stdset="1"> | 401 | <property stdset="1"> |
466 | <name>title</name> | 402 | <name>title</name> |
467 | <string>Messages</string> | 403 | <string>Messages</string> |
468 | </property> | 404 | </property> |
469 | <property> | 405 | <property> |
470 | <name>layoutMargin</name> | 406 | <name>layoutMargin</name> |
471 | </property> | 407 | </property> |
472 | <property> | 408 | <property> |
473 | <name>layoutSpacing</name> | 409 | <name>layoutSpacing</name> |
474 | </property> | 410 | </property> |
475 | <vbox> | 411 | <vbox> |
476 | <property stdset="1"> | 412 | <property stdset="1"> |
477 | <name>margin</name> | 413 | <name>margin</name> |
478 | <number>4</number> | 414 | <number>4</number> |
479 | </property> | 415 | </property> |
480 | <property stdset="1"> | 416 | <property stdset="1"> |
481 | <name>spacing</name> | 417 | <name>spacing</name> |
482 | <number>2</number> | 418 | <number>2</number> |
483 | </property> | 419 | </property> |
484 | <widget> | 420 | <widget> |
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> |
492 | <class>QLayoutWidget</class> | 428 | <class>QLayoutWidget</class> |
493 | <property stdset="1"> | 429 | <property stdset="1"> |
494 | <name>name</name> | 430 | <name>name</name> |
495 | <cstring>Layout2</cstring> | 431 | <cstring>Layout2</cstring> |
496 | </property> | 432 | </property> |
497 | <hbox> | 433 | <hbox> |
498 | <property stdset="1"> | 434 | <property stdset="1"> |
499 | <name>margin</name> | 435 | <name>margin</name> |
500 | <number>0</number> | 436 | <number>0</number> |
501 | </property> | 437 | </property> |
502 | <property stdset="1"> | 438 | <property stdset="1"> |
503 | <name>spacing</name> | 439 | <name>spacing</name> |
504 | <number>6</number> | 440 | <number>6</number> |
505 | </property> | 441 | </property> |
506 | <spacer> | 442 | <spacer> |
507 | <property> | 443 | <property> |
508 | <name>name</name> | 444 | <name>name</name> |
509 | <cstring>Spacer3</cstring> | 445 | <cstring>Spacer3</cstring> |
510 | </property> | 446 | </property> |
511 | <property stdset="1"> | 447 | <property stdset="1"> |
512 | <name>orientation</name> | 448 | <name>orientation</name> |
513 | <enum>Horizontal</enum> | 449 | <enum>Horizontal</enum> |
514 | </property> | 450 | </property> |
515 | <property stdset="1"> | 451 | <property stdset="1"> |
516 | <name>sizeType</name> | 452 | <name>sizeType</name> |
517 | <enum>Expanding</enum> | 453 | <enum>Expanding</enum> |
518 | </property> | 454 | </property> |
519 | <property> | 455 | <property> |
520 | <name>sizeHint</name> | 456 | <name>sizeHint</name> |
521 | <size> | 457 | <size> |
522 | <width>20</width> | 458 | <width>20</width> |
523 | <height>20</height> | 459 | <height>20</height> |
524 | </size> | 460 | </size> |
525 | </property> | 461 | </property> |
526 | </spacer> | 462 | </spacer> |
527 | <widget> | 463 | <widget> |
528 | <class>QPushButton</class> | 464 | <class>QPushButton</class> |
529 | <property stdset="1"> | 465 | <property stdset="1"> |
530 | <name>name</name> | 466 | <name>name</name> |
531 | <cstring>ToProfile_BUT</cstring> | 467 | <cstring>ToProfile_BUT</cstring> |
532 | </property> | 468 | </property> |
533 | <property stdset="1"> | 469 | <property stdset="1"> |
534 | <name>text</name> | 470 | <name>text</name> |
535 | <string>Profile ...</string> | 471 | <string>Profile ...</string> |
536 | </property> | 472 | </property> |
537 | </widget> | 473 | </widget> |
538 | </hbox> | 474 | </hbox> |
539 | </widget> | 475 | </widget> |
540 | </vbox> | 476 | </vbox> |
541 | </widget> | 477 | </widget> |
542 | </vbox> | 478 | </vbox> |
543 | </widget> | 479 | </widget> |
544 | <connections> | 480 | <connections> |
545 | <connection> | 481 | <connection> |
546 | <sender>Add_TB</sender> | 482 | <sender>Add_TB</sender> |
547 | <signal>clicked()</signal> | 483 | <signal>clicked()</signal> |
548 | <receiver>NetworkSettingsGUI</receiver> | 484 | <receiver>NetworkSettingsGUI</receiver> |
549 | <slot>SLOT_AddNode()</slot> | 485 | <slot>SLOT_AddNode()</slot> |
550 | </connection> | 486 | </connection> |
551 | <connection> | 487 | <connection> |
552 | <sender>Delete_TB</sender> | 488 | <sender>Delete_TB</sender> |
553 | <signal>clicked()</signal> | 489 | <signal>clicked()</signal> |
554 | <receiver>NetworkSettingsGUI</receiver> | 490 | <receiver>NetworkSettingsGUI</receiver> |
555 | <slot>SLOT_DeleteNode()</slot> | 491 | <slot>SLOT_DeleteNode()</slot> |
556 | </connection> | 492 | </connection> |
557 | <connection> | 493 | <connection> |
558 | <sender>CheckState_TB</sender> | 494 | <sender>CheckState_TB</sender> |
559 | <signal>clicked()</signal> | 495 | <signal>clicked()</signal> |
560 | <receiver>NetworkSettingsGUI</receiver> | 496 | <receiver>NetworkSettingsGUI</receiver> |
561 | <slot>SLOT_CheckState()</slot> | 497 | <slot>SLOT_CheckState()</slot> |
562 | </connection> | 498 | </connection> |
563 | <connection> | 499 | <connection> |
564 | <sender>Enable_TB</sender> | 500 | <sender>Enable_TB</sender> |
565 | <signal>clicked()</signal> | 501 | <signal>clicked()</signal> |
566 | <receiver>NetworkSettingsGUI</receiver> | 502 | <receiver>NetworkSettingsGUI</receiver> |
567 | <slot>SLOT_Enable()</slot> | 503 | <slot>SLOT_Enable()</slot> |
568 | </connection> | 504 | </connection> |
569 | <connection> | 505 | <connection> |
570 | <sender>Connect_TB</sender> | 506 | <sender>Connect_TB</sender> |
571 | <signal>clicked()</signal> | 507 | <signal>clicked()</signal> |
572 | <receiver>NetworkSettingsGUI</receiver> | 508 | <receiver>NetworkSettingsGUI</receiver> |
573 | <slot>SLOT_Connect()</slot> | 509 | <slot>SLOT_Connect()</slot> |
574 | </connection> | 510 | </connection> |
575 | <connection> | 511 | <connection> |
576 | <sender>On_TB</sender> | 512 | <sender>On_TB</sender> |
577 | <signal>clicked()</signal> | 513 | <signal>clicked()</signal> |
578 | <receiver>NetworkSettingsGUI</receiver> | 514 | <receiver>NetworkSettingsGUI</receiver> |
579 | <slot>SLOT_On()</slot> | 515 | <slot>SLOT_On()</slot> |
580 | </connection> | 516 | </connection> |
581 | <connection> | 517 | <connection> |
582 | <sender>GenConfig_TB</sender> | 518 | <sender>GenConfig_TB</sender> |
583 | <signal>clicked()</signal> | 519 | <signal>clicked()</signal> |
584 | <receiver>NetworkSettingsGUI</receiver> | 520 | <receiver>NetworkSettingsGUI</receiver> |
585 | <slot>SLOT_GenerateConfig()</slot> | 521 | <slot>SLOT_GenerateConfig()</slot> |
586 | </connection> | 522 | </connection> |
587 | <connection> | 523 | <connection> |
588 | <sender>Profiles_LB</sender> | 524 | <sender>Profiles_LB</sender> |
589 | <signal>clicked(QListBoxItem*)</signal> | 525 | <signal>clicked(QListBoxItem*)</signal> |
590 | <receiver>NetworkSettingsGUI</receiver> | 526 | <receiver>NetworkSettingsGUI</receiver> |
591 | <slot>SLOT_ShowNode( QListBoxItem*)</slot> | 527 | <slot>SLOT_ShowNode( QListBoxItem*)</slot> |
592 | </connection> | 528 | </connection> |
593 | <connection> | 529 | <connection> |
594 | <sender>Profiles_LB</sender> | 530 | <sender>Profiles_LB</sender> |
595 | <signal>currentChanged(QListBoxItem*)</signal> | 531 | <signal>currentChanged(QListBoxItem*)</signal> |
596 | <receiver>NetworkSettingsGUI</receiver> | 532 | <receiver>NetworkSettingsGUI</receiver> |
597 | <slot>SLOT_ShowNode( QListBoxItem*)</slot> | 533 | <slot>SLOT_ShowNode( QListBoxItem*)</slot> |
598 | </connection> | 534 | </connection> |
599 | <connection> | 535 | <connection> |
600 | <sender>Profiles_LB</sender> | 536 | <sender>Profiles_LB</sender> |
601 | <signal>doubleClicked(QListBoxItem*)</signal> | 537 | <signal>doubleClicked(QListBoxItem*)</signal> |
602 | <receiver>NetworkSettingsGUI</receiver> | 538 | <receiver>NetworkSettingsGUI</receiver> |
603 | <slot>SLOT_EditNode( QListBoxItem *)</slot> | 539 | <slot>SLOT_EditNode( QListBoxItem *)</slot> |
604 | </connection> | 540 | </connection> |
605 | <connection> | 541 | <connection> |
606 | <sender>ToProfile_BUT</sender> | 542 | <sender>ToProfile_BUT</sender> |
607 | <signal>clicked()</signal> | 543 | <signal>clicked()</signal> |
608 | <receiver>NetworkSettingsGUI</receiver> | 544 | <receiver>NetworkSettingsGUI</receiver> |
609 | <slot>SLOT_ToProfile()</slot> | 545 | <slot>SLOT_ToProfile()</slot> |
610 | </connection> | 546 | </connection> |
611 | <connection> | 547 | <connection> |
612 | <sender>ToMessages_BUT</sender> | 548 | <sender>ToMessages_BUT</sender> |
613 | <signal>clicked()</signal> | 549 | <signal>clicked()</signal> |
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> |
620 | <slot access="public">SLOT_DeleteNode()</slot> | 562 | <slot access="public">SLOT_DeleteNode()</slot> |
621 | <slot access="public">SLOT_EditNode( QListBoxItem *)</slot> | 563 | <slot access="public">SLOT_EditNode( QListBoxItem *)</slot> |
622 | <slot access="public">SLOT_Enable()</slot> | 564 | <slot access="public">SLOT_Enable()</slot> |
623 | <slot access="public">SLOT_GenerateConfig()</slot> | 565 | <slot access="public">SLOT_GenerateConfig()</slot> |
624 | <slot access="public">SLOT_On()</slot> | 566 | <slot access="public">SLOT_On()</slot> |
625 | <slot access="public">SLOT_ShowNode( QListBoxItem*)</slot> | 567 | <slot access="public">SLOT_ShowNode( QListBoxItem*)</slot> |
626 | <slot access="public">SLOT_ToMessages()</slot> | 568 | <slot access="public">SLOT_ToMessages()</slot> |
627 | <slot access="public">SLOT_ToProfile()</slot> | 569 | <slot access="public">SLOT_ToProfile()</slot> |
628 | <slot access="public">SLOT_Disconnect()</slot> | 570 | <slot access="public">SLOT_Disconnect()</slot> |
629 | </connections> | 571 | </connections> |
630 | </UI> | 572 | </UI> |
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 | |||
@@ -1,582 +1,573 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qdir.h> | 4 | #include <qdir.h> |
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | #include <qfileinfo.h> | 6 | #include <qfileinfo.h> |
7 | 7 | ||
8 | #include "nsdata.h" | 8 | #include "nsdata.h" |
9 | #include <asdevice.h> | 9 | #include <asdevice.h> |
10 | #include <resources.h> | 10 | #include <resources.h> |
11 | 11 | ||
12 | static QString CfgFile; | 12 | static QString CfgFile; |
13 | 13 | ||
14 | NetworkSettingsData::NetworkSettingsData( void ) { | 14 | NetworkSettingsData::NetworkSettingsData( void ) { |
15 | // init global resources structure | 15 | // init global resources structure |
16 | new TheNSResources(); | 16 | new TheNSResources(); |
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; |
24 | IsModified = 0; | 24 | IsModified = 0; |
25 | loadSettings(); | 25 | loadSettings(); |
26 | } | 26 | } |
27 | 27 | ||
28 | // saving is done by caller | 28 | // saving is done by caller |
29 | NetworkSettingsData::~NetworkSettingsData( void ) { | 29 | NetworkSettingsData::~NetworkSettingsData( void ) { |
30 | delete NSResources; | 30 | delete NSResources; |
31 | } | 31 | } |
32 | 32 | ||
33 | void NetworkSettingsData::loadSettings( void ) { | 33 | void NetworkSettingsData::loadSettings( void ) { |
34 | QString Line, S; | 34 | QString Line, S; |
35 | QString Attr, Value; | 35 | QString Attr, Value; |
36 | long idx; | 36 | long idx; |
37 | 37 | ||
38 | QFile F( CfgFile ); | 38 | QFile F( CfgFile ); |
39 | QTextStream TS( &F ); | 39 | QTextStream TS( &F ); |
40 | 40 | ||
41 | do { | 41 | do { |
42 | 42 | ||
43 | if( ! F.open(IO_ReadOnly) ) | 43 | if( ! F.open(IO_ReadOnly) ) |
44 | break; | 44 | break; |
45 | 45 | ||
46 | /* load the file -> | 46 | /* load the file -> |
47 | 47 | ||
48 | FORMAT : | 48 | FORMAT : |
49 | 49 | ||
50 | [NETNODETYPE] | 50 | [NETNODETYPE] |
51 | Entries ... | 51 | Entries ... |
52 | <EMPTYLINE> | 52 | <EMPTYLINE> |
53 | [connection] | 53 | [connection] |
54 | Name=Name | 54 | Name=Name |
55 | Node=Name | 55 | Node=Name |
56 | <EMPTYLINE> | 56 | <EMPTYLINE> |
57 | */ | 57 | */ |
58 | while( ! TS.atEnd() ) { | 58 | while( ! TS.atEnd() ) { |
59 | S = Line = TS.readLine(); | 59 | S = Line = TS.readLine(); |
60 | 60 | ||
61 | if ( S.isEmpty() || S[0] != '[' ) | 61 | if ( S.isEmpty() || S[0] != '[' ) |
62 | continue; | 62 | continue; |
63 | 63 | ||
64 | S = S.mid( 1, S.length()-2 ); | 64 | S = S.mid( 1, S.length()-2 ); |
65 | 65 | ||
66 | if( ! NSResources ) { | 66 | if( ! NSResources ) { |
67 | continue; | 67 | continue; |
68 | } | 68 | } |
69 | 69 | ||
70 | if( S == "connection" ) { | 70 | if( S == "connection" ) { |
71 | // load connections -> collections of nodes | 71 | // load connections -> collections of nodes |
72 | NodeCollection * NC = new NodeCollection( TS ); | 72 | NodeCollection * NC = new NodeCollection( TS ); |
73 | NSResources->addConnection( NC ); | 73 | NSResources->addConnection( NC ); |
74 | } else { | 74 | } else { |
75 | ANetNode * NN = 0; | 75 | ANetNode * NN = 0; |
76 | ANetNodeInstance* NNI = 0; | 76 | ANetNodeInstance* NNI = 0; |
77 | if( S.startsWith( "nodetype " ) ) { | 77 | if( S.startsWith( "nodetype " ) ) { |
78 | S = S.mid( 9, S.length()-9 ); | 78 | S = S.mid( 9, S.length()-9 ); |
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 ) { |
90 | LeftOvers.append( Line ); | 90 | LeftOvers.append( Line ); |
91 | } | 91 | } |
92 | 92 | ||
93 | do { | 93 | do { |
94 | S = Line = TS.readLine(); | 94 | S = Line = TS.readLine(); |
95 | 95 | ||
96 | if( NN || NNI ) { | 96 | if( NN || NNI ) { |
97 | if( S.isEmpty() ) { | 97 | if( S.isEmpty() ) { |
98 | // empty line | 98 | // empty line |
99 | break; | 99 | break; |
100 | } | 100 | } |
101 | idx = S.find( '=' ); | 101 | idx = S.find( '=' ); |
102 | if( idx > 0 ) { | 102 | if( idx > 0 ) { |
103 | Attr = S.left( idx ); | 103 | Attr = S.left( idx ); |
104 | Value = S.mid( idx+1, S.length() ); | 104 | Value = S.mid( idx+1, S.length() ); |
105 | } else { | 105 | } else { |
106 | Value=""; | 106 | Value=""; |
107 | Attr = S; | 107 | Attr = S; |
108 | } | 108 | } |
109 | 109 | ||
110 | Value.stripWhiteSpace(); | 110 | Value.stripWhiteSpace(); |
111 | Attr.stripWhiteSpace(); | 111 | Attr.stripWhiteSpace(); |
112 | Attr.lower(); | 112 | Attr.lower(); |
113 | // dequote Attr | 113 | // dequote Attr |
114 | Value = deQuote(Value); | 114 | Value = deQuote(Value); |
115 | 115 | ||
116 | if( NN ) { | 116 | if( NN ) { |
117 | // set the attribute | 117 | // set the attribute |
118 | NN->setAttribute( Attr, Value ); | 118 | NN->setAttribute( Attr, Value ); |
119 | } else { | 119 | } else { |
120 | // set the attribute | 120 | // set the attribute |
121 | NNI->setAttribute( Attr, Value ); | 121 | NNI->setAttribute( Attr, Value ); |
122 | } | 122 | } |
123 | } else { | 123 | } else { |
124 | LeftOvers.append( Line ); | 124 | LeftOvers.append( Line ); |
125 | // add empty line too as delimiter | 125 | // add empty line too as delimiter |
126 | if( S.isEmpty() ) { | 126 | if( S.isEmpty() ) { |
127 | // empty line | 127 | // empty line |
128 | break; | 128 | break; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | } while( 1 ); | 131 | } while( 1 ); |
132 | 132 | ||
133 | if( NNI ) { | 133 | if( NNI ) { |
134 | // loading from file -> exists | 134 | // loading from file -> exists |
135 | NNI->setNew( FALSE ); | 135 | NNI->setNew( FALSE ); |
136 | NSResources->addNodeInstance( NNI ); | 136 | NSResources->addNodeInstance( NNI ); |
137 | } | 137 | } |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | } while( 0 ); | 141 | } while( 0 ); |
142 | 142 | ||
143 | } | 143 | } |
144 | 144 | ||
145 | QString NetworkSettingsData::saveSettings( void ) { | 145 | QString NetworkSettingsData::saveSettings( void ) { |
146 | QString ErrS = ""; | 146 | QString ErrS = ""; |
147 | 147 | ||
148 | if( ! isModified() ) | 148 | if( ! isModified() ) |
149 | return ErrS; | 149 | return ErrS; |
150 | 150 | ||
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>" ). |
158 | arg(CfgFile); | 158 | arg(CfgFile); |
159 | // problem | 159 | // problem |
160 | return ErrS; | 160 | return ErrS; |
161 | } | 161 | } |
162 | 162 | ||
163 | QTextStream TS( &F ); | 163 | QTextStream TS( &F ); |
164 | 164 | ||
165 | // save leftovers | 165 | // save leftovers |
166 | for ( QStringList::Iterator it = LeftOvers.begin(); | 166 | for ( QStringList::Iterator it = LeftOvers.begin(); |
167 | it != LeftOvers.end(); ++it ) { | 167 | it != LeftOvers.end(); ++it ) { |
168 | TS << (*it) << endl; | 168 | TS << (*it) << endl; |
169 | } | 169 | } |
170 | 170 | ||
171 | // save global configs | 171 | // save global configs |
172 | for( QDictIterator<NetNode_t> it( NSResources->netNodes() ); | 172 | for( QDictIterator<NetNode_t> it( NSResources->netNodes() ); |
173 | it.current(); | 173 | it.current(); |
174 | ++it ) { | 174 | ++it ) { |
175 | TS << "[nodetype " | 175 | TS << "[nodetype " |
176 | << quote( QString( it.current()->NetNode->name() ) ) | 176 | << quote( QString( it.current()->NetNode->name() ) ) |
177 | << "]" | 177 | << "]" |
178 | << endl; | 178 | << endl; |
179 | 179 | ||
180 | it.current()->NetNode->saveAttributes( TS ); | 180 | it.current()->NetNode->saveAttributes( TS ); |
181 | TS << endl; | 181 | TS << endl; |
182 | } | 182 | } |
183 | 183 | ||
184 | { Name2Connection_t & M = NSResources->connections(); | 184 | { Name2Connection_t & M = NSResources->connections(); |
185 | ANetNodeInstance * NNI; | 185 | ANetNodeInstance * NNI; |
186 | 186 | ||
187 | // for all connections | 187 | // for all connections |
188 | for( QDictIterator<NodeCollection> it(M); | 188 | for( QDictIterator<NodeCollection> it(M); |
189 | it.current(); | 189 | it.current(); |
190 | ++it ) { | 190 | ++it ) { |
191 | // all nodes in those connections | 191 | // all nodes in those connections |
192 | for( QListIterator<ANetNodeInstance> nit(*(it.current())); | 192 | for( QListIterator<ANetNodeInstance> nit(*(it.current())); |
193 | nit.current(); | 193 | nit.current(); |
194 | ++nit ) { | 194 | ++nit ) { |
195 | // header | 195 | // header |
196 | NNI = nit.current(); | 196 | NNI = nit.current(); |
197 | TS << '[' | 197 | TS << '[' |
198 | << QString(NNI->nodeClass()->name()) | 198 | << QString(NNI->nodeClass()->name()) |
199 | << ']' | 199 | << ']' |
200 | << endl; | 200 | << endl; |
201 | NNI->saveAttributes( TS ); | 201 | NNI->saveAttributes( TS ); |
202 | TS << endl; | 202 | TS << endl; |
203 | } | 203 | } |
204 | 204 | ||
205 | TS << "[connection]" << endl; | 205 | TS << "[connection]" << endl; |
206 | it.current()->save(TS); | 206 | it.current()->save(TS); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | QDir D("."); | 210 | QDir D("."); |
211 | D.rename( CfgFile + ".bup", CfgFile ); | 211 | D.rename( CfgFile + ".bup", CfgFile ); |
212 | 212 | ||
213 | // | 213 | // |
214 | // proper files AND system files regenerated | 214 | // proper files AND system files regenerated |
215 | // | 215 | // |
216 | 216 | ||
217 | setModified( 0 ); | 217 | setModified( 0 ); |
218 | return ErrS; | 218 | return ErrS; |
219 | } | 219 | } |
220 | 220 | ||
221 | QString NetworkSettingsData::generateSettings( bool ForceReq ) { | 221 | QString NetworkSettingsData::generateSettings( bool ForceReq ) { |
222 | bool ForceIt; | 222 | bool ForceIt; |
223 | QString S = ""; | 223 | QString S = ""; |
224 | 224 | ||
225 | // include own force flag | 225 | // include own force flag |
226 | ForceIt = (Force) ? 1 : ForceReq; | 226 | ForceIt = (Force) ? 1 : ForceReq; |
227 | 227 | ||
228 | if( ! ForceIt && ! isModified() ) | 228 | if( ! ForceIt && ! isModified() ) |
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(); |
236 | NodeCollection * NC; | 236 | NodeCollection * NC; |
237 | ANetNodeInstance * NNI; | 237 | ANetNodeInstance * NNI; |
238 | SystemFile * SF; | 238 | SystemFile * SF; |
239 | AsDevice * CurDev; | 239 | AsDevice * CurDev; |
240 | ANetNode * CurDevNN; | 240 | ANetNode * CurDevNN; |
241 | bool needToRegenerate = ForceIt; | 241 | bool needToRegenerate = ForceIt; |
242 | 242 | ||
243 | // | 243 | // |
244 | // check if we need to generate at least one of the system files | 244 | // check if we need to generate at least one of the system files |
245 | // | 245 | // |
246 | if( ! ForceIt ) { | 246 | if( ! ForceIt ) { |
247 | for( QDictIterator<SystemFile> sfit(SFM); | 247 | for( QDictIterator<SystemFile> sfit(SFM); |
248 | sfit.current(); | 248 | sfit.current(); |
249 | ++sfit ) { | 249 | ++sfit ) { |
250 | SF = sfit.current(); | 250 | SF = sfit.current(); |
251 | 251 | ||
252 | // check if there are nodes that are modified and require | 252 | // check if there are nodes that are modified and require |
253 | // data for this system file | 253 | // data for this system file |
254 | 254 | ||
255 | // for all connections | 255 | // for all connections |
256 | for( QDictIterator<NodeCollection> ncit(M); | 256 | for( QDictIterator<NodeCollection> ncit(M); |
257 | ncit.current(); | 257 | ncit.current(); |
258 | ++ncit ) { | 258 | ++ncit ) { |
259 | NC = ncit.current(); | 259 | NC = ncit.current(); |
260 | 260 | ||
261 | if( NC->isModified() ) { | 261 | if( NC->isModified() ) { |
262 | // does this connection 'touch' this system file ? | 262 | // does this connection 'touch' this system file ? |
263 | for( QListIterator<ANetNodeInstance> cncit(*NC); | 263 | for( QListIterator<ANetNodeInstance> cncit(*NC); |
264 | cncit.current(); | 264 | cncit.current(); |
265 | ++cncit ) { | 265 | ++cncit ) { |
266 | NNI = cncit.current(); | 266 | NNI = cncit.current(); |
267 | if( ( NNI->nodeClass()->hasDataFor( SF->name() ) || | 267 | if( ( NNI->nodeClass()->hasDataFor( SF->name() ) || |
268 | NNI->hasDataFor( SF->name() ) | 268 | NNI->hasDataFor( SF->name() ) |
269 | ) && | 269 | ) && |
270 | NNI->isModified() ) { | 270 | NNI->isModified() ) { |
271 | needToRegenerate = 1; | 271 | needToRegenerate = 1; |
272 | break; | 272 | break; |
273 | } | 273 | } |
274 | } | 274 | } |
275 | } | 275 | } |
276 | if( needToRegenerate ) | 276 | if( needToRegenerate ) |
277 | break; | 277 | break; |
278 | } | 278 | } |
279 | if( needToRegenerate ) | 279 | if( needToRegenerate ) |
280 | break; | 280 | break; |
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 | // |
295 | { Name2Instance_t & NNIs = NSResources->netNodeInstances(); | 287 | { Name2Instance_t & NNIs = NSResources->netNodeInstances(); |
296 | 288 | ||
297 | for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); | 289 | for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); |
298 | NNIIt.current(); | 290 | NNIIt.current(); |
299 | ++NNIIt | 291 | ++NNIIt |
300 | ){ | 292 | ){ |
301 | // for all nodes find those that are modified | 293 | // for all nodes find those that are modified |
302 | NNI = NNIIt.current(); | 294 | NNI = NNIIt.current(); |
303 | 295 | ||
304 | if( ForceIt || NNI->isModified() ) { | 296 | if( ForceIt || NNI->isModified() ) { |
305 | if( NNI->nodeClass()->generateProperFilesFor( NNI ) ) { | 297 | if( NNI->nodeClass()->generateProperFilesFor( NNI ) ) { |
306 | // problem generating | 298 | // problem generating |
307 | S = qApp->translate( "NetworkSettings", | 299 | S = qApp->translate( "NetworkSettings", |
308 | "<p>Cannot generate files proper to \"%1\"</p>" ). | 300 | "<p>Cannot generate files proper to \"%1\"</p>" ). |
309 | arg(NNI->nodeClass()->name()) ; | 301 | arg(NNI->nodeClass()->name()) ; |
310 | return S; | 302 | return S; |
311 | } | 303 | } |
312 | } | 304 | } |
313 | } | 305 | } |
314 | } | 306 | } |
315 | 307 | ||
316 | // | 308 | // |
317 | // generate all system files | 309 | // generate all system files |
318 | // | 310 | // |
319 | for( QDictIterator<SystemFile> sfit(SFM); | 311 | for( QDictIterator<SystemFile> sfit(SFM); |
320 | sfit.current(); | 312 | sfit.current(); |
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; |
328 | 320 | ||
329 | // global presection for this system file | 321 | // global presection for this system file |
330 | if( SF->preSection() ) { | 322 | if( SF->preSection() ) { |
331 | S = qApp->translate( "NetworkSettings", | 323 | S = qApp->translate( "NetworkSettings", |
332 | "<p>Error in preSection for file \"%1\"</p>" ). | 324 | "<p>Error in preSection for file \"%1\"</p>" ). |
333 | arg( SF->name() ); | 325 | arg( SF->name() ); |
334 | return S; | 326 | return S; |
335 | } | 327 | } |
336 | 328 | ||
337 | // find all netnodes and figure out if | 329 | // find all netnodes and figure out if |
338 | // for that node there are instances | 330 | // for that node there are instances |
339 | for( QDictIterator<NetNode_t> nnit( | 331 | for( QDictIterator<NetNode_t> nnit( |
340 | NSResources->netNodes() ); | 332 | NSResources->netNodes() ); |
341 | nnit.current(); | 333 | nnit.current(); |
342 | ++nnit ) { | 334 | ++nnit ) { |
343 | 335 | ||
344 | CurDevNN = nnit.current()->NetNode; | 336 | CurDevNN = nnit.current()->NetNode; |
345 | 337 | ||
346 | // are there instances for this netnode ? | 338 | // are there instances for this netnode ? |
347 | NNI = 0; | 339 | NNI = 0; |
348 | for( QDictIterator<ANetNodeInstance> nniit( | 340 | for( QDictIterator<ANetNodeInstance> nniit( |
349 | NSResources->netNodeInstances() ); | 341 | NSResources->netNodeInstances() ); |
350 | nniit.current(); | 342 | nniit.current(); |
351 | ++nniit ) { | 343 | ++nniit ) { |
352 | if( nniit.current()->nodeClass() == CurDevNN ) { | 344 | if( nniit.current()->nodeClass() == CurDevNN ) { |
353 | NNI = nniit.current(); | 345 | NNI = nniit.current(); |
354 | break; | 346 | break; |
355 | } | 347 | } |
356 | } | 348 | } |
357 | 349 | ||
358 | if( ! NNI ) | 350 | if( ! NNI ) |
359 | // no instances -> next netnode type | 351 | // no instances -> next netnode type |
360 | continue; | 352 | continue; |
361 | 353 | ||
362 | // has this node data for this system file ? | 354 | // has this node data for this system file ? |
363 | if( (CurDev = NNI->runtime()->asDevice() ) ) { | 355 | if( (CurDev = NNI->runtime()->asDevice() ) ) { |
364 | // generate start for this nodetype for all possible devices of this type | 356 | // generate start for this nodetype for all possible devices of this type |
365 | for( int i = 0; i < CurDevNN->instanceCount(); i ++ ) { | 357 | for( int i = 0; i < CurDevNN->instanceCount(); i ++ ) { |
366 | S = generateSystemFileNode( *SF, CurDev, NNI, i ); | 358 | S = generateSystemFileNode( *SF, CurDev, NNI, i ); |
367 | if( ! S.isEmpty() ) | 359 | if( ! S.isEmpty() ) |
368 | return S; | 360 | return S; |
369 | } | 361 | } |
370 | } else { | 362 | } else { |
371 | S = generateSystemFileNode( *SF, 0, NNI, -1 ); | 363 | S = generateSystemFileNode( *SF, 0, NNI, -1 ); |
372 | if( ! S.isEmpty() ) | 364 | if( ! S.isEmpty() ) |
373 | return S; | 365 | return S; |
374 | } | 366 | } |
375 | } | 367 | } |
376 | 368 | ||
377 | if( SF->postSection() ) { | 369 | if( SF->postSection() ) { |
378 | S = qApp->translate( "NetworkSettings", | 370 | S = qApp->translate( "NetworkSettings", |
379 | "<p>Error in postSection for file \"%1\"</p>" ). | 371 | "<p>Error in postSection for file \"%1\"</p>" ). |
380 | arg( SF->name() ); | 372 | arg( SF->name() ); |
381 | return S; | 373 | return S; |
382 | } | 374 | } |
383 | 375 | ||
384 | } while( 0 ); | 376 | } while( 0 ); |
385 | SF->close(); | 377 | SF->close(); |
386 | } | 378 | } |
387 | } | 379 | } |
388 | Force = 0; | 380 | Force = 0; |
389 | return S; | 381 | return S; |
390 | } | 382 | } |
391 | 383 | ||
392 | QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) { | 384 | QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) { |
393 | // collect connections that can work on top of this interface | 385 | // collect connections that can work on top of this interface |
394 | NodeCollection * NC; | 386 | NodeCollection * NC; |
395 | QList<NodeCollection> PossibleConnections; | 387 | QList<NodeCollection> PossibleConnections; |
396 | Name2Connection_t & M = NSResources->connections(); | 388 | Name2Connection_t & M = NSResources->connections(); |
397 | 389 | ||
398 | // for all connections | 390 | // for all connections |
399 | for( QDictIterator<NodeCollection> it(M); | 391 | for( QDictIterator<NodeCollection> it(M); |
400 | it.current(); | 392 | it.current(); |
401 | ++it ) { | 393 | ++it ) { |
402 | NC = it.current(); | 394 | NC = it.current(); |
403 | // check if this profile handles the requested interface | 395 | // check if this profile handles the requested interface |
404 | if( NC->handlesInterface( Interface ) && // if different Intf. | 396 | if( NC->handlesInterface( Interface ) && // if different Intf. |
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 | } |
412 | return PossibleConnections; | 404 | return PossibleConnections; |
413 | } | 405 | } |
414 | 406 | ||
415 | 407 | ||
416 | /* | 408 | /* |
417 | Called by the system to see if interface can be brought UP | 409 | Called by the system to see if interface can be brought UP |
418 | 410 | ||
419 | if allowed, echo Interface-allowed else Interface-disallowed | 411 | if allowed, echo Interface-allowed else Interface-disallowed |
420 | */ | 412 | */ |
421 | 413 | ||
422 | bool NetworkSettingsData::canStart( const char * Interface ) { | 414 | bool NetworkSettingsData::canStart( const char * Interface ) { |
423 | // load situation | 415 | // load situation |
424 | NodeCollection * NC = 0; | 416 | NodeCollection * NC = 0; |
425 | QList<NodeCollection> PossibleConnections; | 417 | QList<NodeCollection> PossibleConnections; |
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; |
434 | case 1 : // one connection | 425 | case 1 : // one connection |
435 | NC = PossibleConnections.first(); | 426 | NC = PossibleConnections.first(); |
436 | break; | 427 | break; |
437 | default : // need to ask user ? | 428 | default : // need to ask user ? |
438 | return 1; | 429 | return 1; |
439 | } | 430 | } |
440 | 431 | ||
441 | if( NC ) { | 432 | if( NC ) { |
442 | switch( NC->state() ) { | 433 | switch( NC->state() ) { |
443 | case Unchecked : | 434 | case Unchecked : |
444 | case Unknown : | 435 | case Unknown : |
445 | case Unavailable : | 436 | case Unavailable : |
446 | case Disabled : | 437 | case Disabled : |
447 | // this profile does not allow interface to be UP | 438 | // this profile does not allow interface to be UP |
448 | // -> try others | 439 | // -> try others |
449 | break; | 440 | break; |
450 | case Off : | 441 | case Off : |
451 | // try to UP the device | 442 | // try to UP the device |
452 | if( ! NC->setState( Activate ) ) { | 443 | if( ! NC->setState( Activate ) ) { |
453 | // cannot bring device Online -> try other alters | 444 | // cannot bring device Online -> try other alters |
454 | break; | 445 | break; |
455 | } | 446 | } |
456 | // FT | 447 | // FT |
457 | case Available : | 448 | case Available : |
458 | case IsUp : // also called for 'ifdown' | 449 | case IsUp : // also called for 'ifdown' |
459 | // device is ready -> done | 450 | // device is ready -> done |
460 | printf( "%s-c%d-allowed\n", Interface, NC->number() ); | 451 | printf( "%s-c%d-allowed\n", Interface, NC->number() ); |
461 | return 0; | 452 | return 0; |
462 | } | 453 | } |
463 | } | 454 | } |
464 | 455 | ||
465 | // if we come here no alternatives are possible | 456 | // if we come here no alternatives are possible |
466 | printf( "%s-cnn-disallowed\n", Interface ); | 457 | printf( "%s-cnn-disallowed\n", Interface ); |
467 | return 0; | 458 | return 0; |
468 | } | 459 | } |
469 | 460 | ||
470 | /* | 461 | /* |
471 | Called by the system to regenerate config files | 462 | Called by the system to regenerate config files |
472 | */ | 463 | */ |
473 | 464 | ||
474 | bool NetworkSettingsData::regenerate( void ) { | 465 | bool NetworkSettingsData::regenerate( void ) { |
475 | QString S; | 466 | QString S; |
476 | // load situation | 467 | // load situation |
477 | S = generateSettings( TRUE ); | 468 | S = generateSettings( TRUE ); |
478 | if( ! S.isEmpty() ) { | 469 | if( ! S.isEmpty() ) { |
479 | fprintf( stdout, "%s\n", S.latin1() ); | 470 | fprintf( stdout, "%s\n", S.latin1() ); |
480 | return 1; | 471 | return 1; |
481 | } | 472 | } |
482 | return 0; | 473 | return 0; |
483 | } | 474 | } |
484 | 475 | ||
485 | QString NetworkSettingsData::generateSystemFileNode( | 476 | QString NetworkSettingsData::generateSystemFileNode( |
486 | SystemFile &SF, | 477 | SystemFile &SF, |
487 | AsDevice * CurDev, | 478 | AsDevice * CurDev, |
488 | ANetNodeInstance * DevNNI, | 479 | ANetNodeInstance * DevNNI, |
489 | long DevInstNr ) { | 480 | long DevInstNr ) { |
490 | 481 | ||
491 | QString S=""; | 482 | QString S=""; |
492 | ANetNode * CurDevNN = DevNNI->nodeClass(); | 483 | ANetNode * CurDevNN = DevNNI->nodeClass(); |
493 | Name2Connection_t & M = NSResources->connections(); | 484 | Name2Connection_t & M = NSResources->connections(); |
494 | 485 | ||
495 | if( SF.preDeviceSection( CurDevNN ) ) { | 486 | if( SF.preDeviceSection( CurDevNN ) ) { |
496 | S = qApp->translate( "NetworkSettings", | 487 | S = qApp->translate( "NetworkSettings", |
497 | "<p>Error in \"Pre-Device Part\" for file \"%1\" and nodetype \"%2\"</p>" ). | 488 | "<p>Error in \"Pre-Device Part\" for file \"%1\" and nodetype \"%2\"</p>" ). |
498 | arg( SF.name() ). | 489 | arg( SF.name() ). |
499 | arg( CurDevNN->name() ); | 490 | arg( CurDevNN->name() ); |
500 | return S; | 491 | return S; |
501 | } | 492 | } |
502 | 493 | ||
503 | if( CurDevNN->hasDataFor( SF.name() ) ) { | 494 | if( CurDevNN->hasDataFor( SF.name() ) ) { |
504 | if( CurDevNN->generateDeviceDataForCommonFile( SF, DevInstNr ) ) { | 495 | if( CurDevNN->generateDeviceDataForCommonFile( SF, DevInstNr ) ) { |
505 | S = qApp->translate( "NetworkSettings", | 496 | S = qApp->translate( "NetworkSettings", |
506 | "<p>Error in \"Device Part\" for file \"%1\" and node \"%2\"</p>" ). | 497 | "<p>Error in \"Device Part\" for file \"%1\" and node \"%2\"</p>" ). |
507 | arg( SF.name() ). | 498 | arg( SF.name() ). |
508 | arg( CurDevNN->name() ); | 499 | arg( CurDevNN->name() ); |
509 | return S; | 500 | return S; |
510 | } | 501 | } |
511 | } | 502 | } |
512 | 503 | ||
513 | // now generate profile specific data for all | 504 | // now generate profile specific data for all |
514 | // connections working on a device of the current | 505 | // connections working on a device of the current |
515 | // netnode type | 506 | // netnode type |
516 | for( QDictIterator<NodeCollection> ncit(M); | 507 | for( QDictIterator<NodeCollection> ncit(M); |
517 | ncit.current(); | 508 | ncit.current(); |
518 | ++ncit ) { | 509 | ++ncit ) { |
519 | NodeCollection * NC = ncit.current(); | 510 | NodeCollection * NC = ncit.current(); |
520 | 511 | ||
521 | // currenly only those connections that work on | 512 | // currenly only those connections that work on |
522 | // the current device (or on no device if no current) | 513 | // the current device (or on no device if no current) |
523 | AsDevice * Dev = NC->device(); | 514 | AsDevice * Dev = NC->device(); |
524 | 515 | ||
525 | if( CurDev ) { | 516 | if( CurDev ) { |
526 | if( CurDevNN != Dev->netNode()->nodeClass() ) { | 517 | if( CurDevNN != Dev->netNode()->nodeClass() ) { |
527 | // other device type -> later | 518 | // other device type -> later |
528 | continue; | 519 | continue; |
529 | } | 520 | } |
530 | } else { | 521 | } else { |
531 | if( Dev ) { | 522 | if( Dev ) { |
532 | // other | 523 | // other |
533 | continue; | 524 | continue; |
534 | } | 525 | } |
535 | } | 526 | } |
536 | 527 | ||
537 | // generate 'entry' | 528 | // generate 'entry' |
538 | if( SF.preNodeSection( DevNNI, DevInstNr ) ) { | 529 | if( SF.preNodeSection( DevNNI, DevInstNr ) ) { |
539 | S = qApp->translate( "NetworkSettings", | 530 | S = qApp->translate( "NetworkSettings", |
540 | "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ). | 531 | "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ). |
541 | arg( SF.name() ). | 532 | arg( SF.name() ). |
542 | arg( CurDevNN->name() ); | 533 | arg( CurDevNN->name() ); |
543 | return S; | 534 | return S; |
544 | } | 535 | } |
545 | 536 | ||
546 | // ask all nodes in connection | 537 | // ask all nodes in connection |
547 | for( QListIterator<ANetNodeInstance> cncit(*NC); | 538 | for( QListIterator<ANetNodeInstance> cncit(*NC); |
548 | cncit.current(); | 539 | cncit.current(); |
549 | ++cncit ) { | 540 | ++cncit ) { |
550 | ANetNodeInstance * NNI = cncit.current(); | 541 | ANetNodeInstance * NNI = cncit.current(); |
551 | 542 | ||
552 | if( NNI->hasDataFor( SF.name() ) ) { | 543 | if( NNI->hasDataFor( SF.name() ) ) { |
553 | if( NNI->generateDataForCommonFile(SF,DevInstNr) ) { | 544 | if( NNI->generateDataForCommonFile(SF,DevInstNr) ) { |
554 | S = qApp->translate( "NetworkSettings", | 545 | S = qApp->translate( "NetworkSettings", |
555 | "<p>Error in \"Node Part\" for file \"%1\" and node \"%2\"</p>" ). | 546 | "<p>Error in \"Node Part\" for file \"%1\" and node \"%2\"</p>" ). |
556 | arg( SF.name() ). | 547 | arg( SF.name() ). |
557 | arg( NNI->nodeClass()->name() ); | 548 | arg( NNI->nodeClass()->name() ); |
558 | return S; | 549 | return S; |
559 | } | 550 | } |
560 | } | 551 | } |
561 | } | 552 | } |
562 | 553 | ||
563 | if( SF.postNodeSection( DevNNI, DevInstNr ) ) { | 554 | if( SF.postNodeSection( DevNNI, DevInstNr ) ) { |
564 | S = qApp->translate( "NetworkSettings", | 555 | S = qApp->translate( "NetworkSettings", |
565 | "<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ). | 556 | "<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ). |
566 | arg( SF.name() ). | 557 | arg( SF.name() ). |
567 | arg( CurDevNN->name() ); | 558 | arg( CurDevNN->name() ); |
568 | return S; | 559 | return S; |
569 | } | 560 | } |
570 | SF << endl; | 561 | SF << endl; |
571 | } | 562 | } |
572 | 563 | ||
573 | if( SF.postDeviceSection( CurDevNN ) ) { | 564 | if( SF.postDeviceSection( CurDevNN ) ) { |
574 | S = qApp->translate( "NetworkSettings", | 565 | S = qApp->translate( "NetworkSettings", |
575 | "<p>Error in \"Post-Device Part\" for file \"%1\" and node \"%2\"</p>" ). | 566 | "<p>Error in \"Post-Device Part\" for file \"%1\" and node \"%2\"</p>" ). |
576 | arg( SF.name() ). | 567 | arg( SF.name() ). |
577 | arg( CurDevNN->name() ); | 568 | arg( CurDevNN->name() ); |
578 | return S; | 569 | return S; |
579 | } | 570 | } |
580 | 571 | ||
581 | return S; | 572 | return S; |
582 | } | 573 | } |
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 | |||
@@ -1,497 +1,567 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>ProfileGUI</class> | 2 | <class>ProfileGUI</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QWidget</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>Profile_FRM</cstring> | 7 | <cstring>Profile_FRM</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>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"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Profile</string> | 20 | <string>Profile</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>0</number> | 31 | <number>0</number> |
32 | </property> | 32 | </property> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>spacing</name> | 34 | <name>spacing</name> |
35 | <number>0</number> | 35 | <number>0</number> |
36 | </property> | 36 | </property> |
37 | <widget> | 37 | <widget> |
38 | <class>QTabWidget</class> | 38 | <class>QTabWidget</class> |
39 | <property stdset="1"> | 39 | <property stdset="1"> |
40 | <name>name</name> | 40 | <name>name</name> |
41 | <cstring>TabWidget6</cstring> | 41 | <cstring>TabWidget6</cstring> |
42 | </property> | 42 | </property> |
43 | <property> | 43 | <property> |
44 | <name>layoutMargin</name> | 44 | <name>layoutMargin</name> |
45 | </property> | 45 | </property> |
46 | <property> | 46 | <property> |
47 | <name>layoutSpacing</name> | 47 | <name>layoutSpacing</name> |
48 | </property> | 48 | </property> |
49 | <widget> | 49 | <widget> |
50 | <class>QWidget</class> | 50 | <class>QWidget</class> |
51 | <property stdset="1"> | 51 | <property stdset="1"> |
52 | <name>name</name> | 52 | <name>name</name> |
53 | <cstring>tab</cstring> | 53 | <cstring>tab</cstring> |
54 | </property> | 54 | </property> |
55 | <attribute> | 55 | <attribute> |
56 | <name>title</name> | 56 | <name>title</name> |
57 | <string>Setup</string> | 57 | <string>Setup</string> |
58 | </attribute> | 58 | </attribute> |
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> |
117 | <property stdset="1"> | 187 | <property stdset="1"> |
118 | <name>name</name> | 188 | <name>name</name> |
119 | <cstring>TextLabel3</cstring> | 189 | <cstring>TextLabel3</cstring> |
120 | </property> | 190 | </property> |
121 | <property stdset="1"> | 191 | <property stdset="1"> |
122 | <name>text</name> | 192 | <name>text</name> |
123 | <string>Description</string> | 193 | <string>Description</string> |
124 | </property> | 194 | </property> |
125 | </widget> | 195 | </widget> |
126 | <widget> | 196 | <widget> |
127 | <class>QMultiLineEdit</class> | 197 | <class>QMultiLineEdit</class> |
128 | <property stdset="1"> | 198 | <property stdset="1"> |
129 | <name>name</name> | 199 | <name>name</name> |
130 | <cstring>Description_LE</cstring> | 200 | <cstring>Description_LE</cstring> |
131 | </property> | 201 | </property> |
132 | </widget> | 202 | </widget> |
133 | </vbox> | 203 | </vbox> |
134 | </widget> | 204 | </widget> |
135 | <widget> | 205 | <widget> |
136 | <class>QWidget</class> | 206 | <class>QWidget</class> |
137 | <property stdset="1"> | 207 | <property stdset="1"> |
138 | <name>name</name> | 208 | <name>name</name> |
139 | <cstring>tab</cstring> | 209 | <cstring>tab</cstring> |
140 | </property> | 210 | </property> |
141 | <attribute> | 211 | <attribute> |
142 | <name>title</name> | 212 | <name>title</name> |
143 | <string>State</string> | 213 | <string>State</string> |
144 | </attribute> | 214 | </attribute> |
145 | <vbox> | 215 | <vbox> |
146 | <property stdset="1"> | 216 | <property stdset="1"> |
147 | <name>margin</name> | 217 | <name>margin</name> |
148 | <number>0</number> | 218 | <number>0</number> |
149 | </property> | 219 | </property> |
150 | <property stdset="1"> | 220 | <property stdset="1"> |
151 | <name>spacing</name> | 221 | <name>spacing</name> |
152 | <number>2</number> | 222 | <number>2</number> |
153 | </property> | 223 | </property> |
154 | <widget> | 224 | <widget> |
155 | <class>QFrame</class> | 225 | <class>QFrame</class> |
156 | <property stdset="1"> | 226 | <property stdset="1"> |
157 | <name>name</name> | 227 | <name>name</name> |
158 | <cstring>Frame73</cstring> | 228 | <cstring>Frame73</cstring> |
159 | </property> | 229 | </property> |
160 | <property stdset="1"> | 230 | <property stdset="1"> |
161 | <name>sizePolicy</name> | 231 | <name>sizePolicy</name> |
162 | <sizepolicy> | 232 | <sizepolicy> |
163 | <hsizetype>7</hsizetype> | 233 | <hsizetype>7</hsizetype> |
164 | <vsizetype>5</vsizetype> | 234 | <vsizetype>5</vsizetype> |
165 | </sizepolicy> | 235 | </sizepolicy> |
166 | </property> | 236 | </property> |
167 | <property stdset="1"> | 237 | <property stdset="1"> |
168 | <name>frameShape</name> | 238 | <name>frameShape</name> |
169 | <enum>NoFrame</enum> | 239 | <enum>NoFrame</enum> |
170 | </property> | 240 | </property> |
171 | <property stdset="1"> | 241 | <property stdset="1"> |
172 | <name>frameShadow</name> | 242 | <name>frameShadow</name> |
173 | <enum>Plain</enum> | 243 | <enum>Plain</enum> |
174 | </property> | 244 | </property> |
175 | <property> | 245 | <property> |
176 | <name>layoutMargin</name> | 246 | <name>layoutMargin</name> |
177 | </property> | 247 | </property> |
178 | <property> | 248 | <property> |
179 | <name>layoutSpacing</name> | 249 | <name>layoutSpacing</name> |
180 | </property> | 250 | </property> |
181 | <hbox> | 251 | <hbox> |
182 | <property stdset="1"> | 252 | <property stdset="1"> |
183 | <name>margin</name> | 253 | <name>margin</name> |
184 | <number>2</number> | 254 | <number>2</number> |
185 | </property> | 255 | </property> |
186 | <property stdset="1"> | 256 | <property stdset="1"> |
187 | <name>spacing</name> | 257 | <name>spacing</name> |
188 | <number>0</number> | 258 | <number>0</number> |
189 | </property> | 259 | </property> |
190 | <widget> | 260 | <widget> |
191 | <class>QLabel</class> | 261 | <class>QLabel</class> |
192 | <property stdset="1"> | 262 | <property stdset="1"> |
193 | <name>name</name> | 263 | <name>name</name> |
194 | <cstring>InterfaceName_LBL</cstring> | 264 | <cstring>InterfaceName_LBL</cstring> |
195 | </property> | 265 | </property> |
196 | <property stdset="1"> | 266 | <property stdset="1"> |
197 | <name>font</name> | 267 | <name>font</name> |
198 | <font> | 268 | <font> |
199 | <underline>1</underline> | 269 | <underline>1</underline> |
200 | </font> | 270 | </font> |
201 | </property> | 271 | </property> |
202 | <property stdset="1"> | 272 | <property stdset="1"> |
203 | <name>text</name> | 273 | <name>text</name> |
204 | <string>eth0</string> | 274 | <string>eth0</string> |
205 | </property> | 275 | </property> |
206 | </widget> | 276 | </widget> |
207 | <widget> | 277 | <widget> |
208 | <class>QLabel</class> | 278 | <class>QLabel</class> |
209 | <property stdset="1"> | 279 | <property stdset="1"> |
210 | <name>name</name> | 280 | <name>name</name> |
211 | <cstring>InterfaceOptions_LBL</cstring> | 281 | <cstring>InterfaceOptions_LBL</cstring> |
212 | </property> | 282 | </property> |
213 | <property stdset="1"> | 283 | <property stdset="1"> |
214 | <name>sizePolicy</name> | 284 | <name>sizePolicy</name> |
215 | <sizepolicy> | 285 | <sizepolicy> |
216 | <hsizetype>7</hsizetype> | 286 | <hsizetype>7</hsizetype> |
217 | <vsizetype>1</vsizetype> | 287 | <vsizetype>1</vsizetype> |
218 | </sizepolicy> | 288 | </sizepolicy> |
219 | </property> | 289 | </property> |
220 | <property stdset="1"> | 290 | <property stdset="1"> |
221 | <name>font</name> | 291 | <name>font</name> |
222 | <font> | 292 | <font> |
223 | <underline>1</underline> | 293 | <underline>1</underline> |
224 | </font> | 294 | </font> |
225 | </property> | 295 | </property> |
226 | <property stdset="1"> | 296 | <property stdset="1"> |
227 | <name>text</name> | 297 | <name>text</name> |
228 | <string>(Multicast, Up)</string> | 298 | <string>(Multicast, Up)</string> |
229 | </property> | 299 | </property> |
230 | <property stdset="1"> | 300 | <property stdset="1"> |
231 | <name>indent</name> | 301 | <name>indent</name> |
232 | <number>0</number> | 302 | <number>0</number> |
233 | </property> | 303 | </property> |
234 | </widget> | 304 | </widget> |
235 | </hbox> | 305 | </hbox> |
236 | </widget> | 306 | </widget> |
237 | <widget> | 307 | <widget> |
238 | <class>QFrame</class> | 308 | <class>QFrame</class> |
239 | <property stdset="1"> | 309 | <property stdset="1"> |
240 | <name>name</name> | 310 | <name>name</name> |
241 | <cstring>Interface_GB</cstring> | 311 | <cstring>Interface_GB</cstring> |
242 | </property> | 312 | </property> |
243 | <property stdset="1"> | 313 | <property stdset="1"> |
244 | <name>enabled</name> | 314 | <name>enabled</name> |
245 | <bool>true</bool> | 315 | <bool>true</bool> |
246 | </property> | 316 | </property> |
247 | <property stdset="1"> | 317 | <property stdset="1"> |
248 | <name>sizePolicy</name> | 318 | <name>sizePolicy</name> |
249 | <sizepolicy> | 319 | <sizepolicy> |
250 | <hsizetype>7</hsizetype> | 320 | <hsizetype>7</hsizetype> |
251 | <vsizetype>5</vsizetype> | 321 | <vsizetype>5</vsizetype> |
252 | </sizepolicy> | 322 | </sizepolicy> |
253 | </property> | 323 | </property> |
254 | <property stdset="1"> | 324 | <property stdset="1"> |
255 | <name>frameShape</name> | 325 | <name>frameShape</name> |
256 | <enum>NoFrame</enum> | 326 | <enum>NoFrame</enum> |
257 | </property> | 327 | </property> |
258 | <property stdset="1"> | 328 | <property stdset="1"> |
259 | <name>frameShadow</name> | 329 | <name>frameShadow</name> |
260 | <enum>Raised</enum> | 330 | <enum>Raised</enum> |
261 | </property> | 331 | </property> |
262 | <property> | 332 | <property> |
263 | <name>layoutMargin</name> | 333 | <name>layoutMargin</name> |
264 | </property> | 334 | </property> |
265 | <property> | 335 | <property> |
266 | <name>layoutSpacing</name> | 336 | <name>layoutSpacing</name> |
267 | </property> | 337 | </property> |
268 | <grid> | 338 | <grid> |
269 | <property stdset="1"> | 339 | <property stdset="1"> |
270 | <name>margin</name> | 340 | <name>margin</name> |
271 | <number>2</number> | 341 | <number>2</number> |
272 | </property> | 342 | </property> |
273 | <property stdset="1"> | 343 | <property stdset="1"> |
274 | <name>spacing</name> | 344 | <name>spacing</name> |
275 | <number>1</number> | 345 | <number>1</number> |
276 | </property> | 346 | </property> |
277 | <widget row="0" column="2" > | 347 | <widget row="0" column="2" > |
278 | <class>QLabel</class> | 348 | <class>QLabel</class> |
279 | <property stdset="1"> | 349 | <property stdset="1"> |
280 | <name>name</name> | 350 | <name>name</name> |
281 | <cstring>TextLabel4_2_3</cstring> | 351 | <cstring>TextLabel4_2_3</cstring> |
282 | </property> | 352 | </property> |
283 | <property stdset="1"> | 353 | <property stdset="1"> |
284 | <name>enabled</name> | 354 | <name>enabled</name> |
285 | <bool>true</bool> | 355 | <bool>true</bool> |
286 | </property> | 356 | </property> |
287 | <property stdset="1"> | 357 | <property stdset="1"> |
288 | <name>sizePolicy</name> | 358 | <name>sizePolicy</name> |
289 | <sizepolicy> | 359 | <sizepolicy> |
290 | <hsizetype>0</hsizetype> | 360 | <hsizetype>0</hsizetype> |
291 | <vsizetype>1</vsizetype> | 361 | <vsizetype>1</vsizetype> |
292 | </sizepolicy> | 362 | </sizepolicy> |
293 | </property> | 363 | </property> |
294 | <property stdset="1"> | 364 | <property stdset="1"> |
295 | <name>frameShape</name> | 365 | <name>frameShape</name> |
296 | <enum>NoFrame</enum> | 366 | <enum>NoFrame</enum> |
297 | </property> | 367 | </property> |
298 | <property stdset="1"> | 368 | <property stdset="1"> |
299 | <name>frameShadow</name> | 369 | <name>frameShadow</name> |
300 | <enum>Raised</enum> | 370 | <enum>Raised</enum> |
301 | </property> | 371 | </property> |
302 | <property stdset="1"> | 372 | <property stdset="1"> |
303 | <name>text</name> | 373 | <name>text</name> |
304 | <string>Subnet Mask</string> | 374 | <string>Subnet Mask</string> |
305 | </property> | 375 | </property> |
306 | </widget> | 376 | </widget> |
307 | <widget row="0" column="3" > | 377 | <widget row="0" column="3" > |
308 | <class>QLabel</class> | 378 | <class>QLabel</class> |
309 | <property stdset="1"> | 379 | <property stdset="1"> |
310 | <name>name</name> | 380 | <name>name</name> |
311 | <cstring>TextLabel1_3_3</cstring> | 381 | <cstring>TextLabel1_3_3</cstring> |
312 | </property> | 382 | </property> |
313 | <property stdset="1"> | 383 | <property stdset="1"> |
314 | <name>enabled</name> | 384 | <name>enabled</name> |
315 | <bool>true</bool> | 385 | <bool>true</bool> |
316 | </property> | 386 | </property> |
317 | <property stdset="1"> | 387 | <property stdset="1"> |
318 | <name>sizePolicy</name> | 388 | <name>sizePolicy</name> |
319 | <sizepolicy> | 389 | <sizepolicy> |
320 | <hsizetype>0</hsizetype> | 390 | <hsizetype>0</hsizetype> |
321 | <vsizetype>1</vsizetype> | 391 | <vsizetype>1</vsizetype> |
322 | </sizepolicy> | 392 | </sizepolicy> |
323 | </property> | 393 | </property> |
324 | <property stdset="1"> | 394 | <property stdset="1"> |
325 | <name>frameShape</name> | 395 | <name>frameShape</name> |
326 | <enum>NoFrame</enum> | 396 | <enum>NoFrame</enum> |
327 | </property> | 397 | </property> |
328 | <property stdset="1"> | 398 | <property stdset="1"> |
329 | <name>frameShadow</name> | 399 | <name>frameShadow</name> |
330 | <enum>Raised</enum> | 400 | <enum>Raised</enum> |
331 | </property> | 401 | </property> |
332 | <property stdset="1"> | 402 | <property stdset="1"> |
333 | <name>text</name> | 403 | <name>text</name> |
334 | <string>Broadcast</string> | 404 | <string>Broadcast</string> |
335 | </property> | 405 | </property> |
336 | </widget> | 406 | </widget> |
337 | <widget row="3" column="0" > | 407 | <widget row="3" column="0" > |
338 | <class>QLabel</class> | 408 | <class>QLabel</class> |
339 | <property stdset="1"> | 409 | <property stdset="1"> |
340 | <name>name</name> | 410 | <name>name</name> |
341 | <cstring>TextLabel1_5</cstring> | 411 | <cstring>TextLabel1_5</cstring> |
342 | </property> | 412 | </property> |
343 | <property stdset="1"> | 413 | <property stdset="1"> |
344 | <name>enabled</name> | 414 | <name>enabled</name> |
345 | <bool>true</bool> | 415 | <bool>true</bool> |
346 | </property> | 416 | </property> |
347 | <property stdset="1"> | 417 | <property stdset="1"> |
348 | <name>sizePolicy</name> | 418 | <name>sizePolicy</name> |
349 | <sizepolicy> | 419 | <sizepolicy> |
350 | <hsizetype>1</hsizetype> | 420 | <hsizetype>1</hsizetype> |
351 | <vsizetype>1</vsizetype> | 421 | <vsizetype>1</vsizetype> |
352 | </sizepolicy> | 422 | </sizepolicy> |
353 | </property> | 423 | </property> |
354 | <property stdset="1"> | 424 | <property stdset="1"> |
355 | <name>text</name> | 425 | <name>text</name> |
356 | <string>MAC</string> | 426 | <string>MAC</string> |
357 | </property> | 427 | </property> |
358 | <property stdset="1"> | 428 | <property stdset="1"> |
359 | <name>indent</name> | 429 | <name>indent</name> |
360 | <number>0</number> | 430 | <number>0</number> |
361 | </property> | 431 | </property> |
362 | </widget> | 432 | </widget> |
363 | <widget row="2" column="0" > | 433 | <widget row="2" column="0" > |
364 | <class>QLabel</class> | 434 | <class>QLabel</class> |
365 | <property stdset="1"> | 435 | <property stdset="1"> |
366 | <name>name</name> | 436 | <name>name</name> |
367 | <cstring>TextLabel1_5_2</cstring> | 437 | <cstring>TextLabel1_5_2</cstring> |
368 | </property> | 438 | </property> |
369 | <property stdset="1"> | 439 | <property stdset="1"> |
370 | <name>enabled</name> | 440 | <name>enabled</name> |
371 | <bool>true</bool> | 441 | <bool>true</bool> |
372 | </property> | 442 | </property> |
373 | <property stdset="1"> | 443 | <property stdset="1"> |
374 | <name>sizePolicy</name> | 444 | <name>sizePolicy</name> |
375 | <sizepolicy> | 445 | <sizepolicy> |
376 | <hsizetype>1</hsizetype> | 446 | <hsizetype>1</hsizetype> |
377 | <vsizetype>1</vsizetype> | 447 | <vsizetype>1</vsizetype> |
378 | </sizepolicy> | 448 | </sizepolicy> |
379 | </property> | 449 | </property> |
380 | <property stdset="1"> | 450 | <property stdset="1"> |
381 | <name>text</name> | 451 | <name>text</name> |
382 | <string>P-t-P</string> | 452 | <string>P-t-P</string> |
383 | </property> | 453 | </property> |
384 | <property stdset="1"> | 454 | <property stdset="1"> |
385 | <name>indent</name> | 455 | <name>indent</name> |
386 | <number>0</number> | 456 | <number>0</number> |
387 | </property> | 457 | </property> |
388 | </widget> | 458 | </widget> |
389 | <widget row="0" column="0" rowspan="1" colspan="2" > | 459 | <widget row="0" column="0" rowspan="1" colspan="2" > |
390 | <class>QLabel</class> | 460 | <class>QLabel</class> |
391 | <property stdset="1"> | 461 | <property stdset="1"> |
392 | <name>name</name> | 462 | <name>name</name> |
393 | <cstring>TextLabel3_2_3</cstring> | 463 | <cstring>TextLabel3_2_3</cstring> |
394 | </property> | 464 | </property> |
395 | <property stdset="1"> | 465 | <property stdset="1"> |
396 | <name>enabled</name> | 466 | <name>enabled</name> |
397 | <bool>true</bool> | 467 | <bool>true</bool> |
398 | </property> | 468 | </property> |
399 | <property stdset="1"> | 469 | <property stdset="1"> |
400 | <name>sizePolicy</name> | 470 | <name>sizePolicy</name> |
401 | <sizepolicy> | 471 | <sizepolicy> |
402 | <hsizetype>0</hsizetype> | 472 | <hsizetype>0</hsizetype> |
403 | <vsizetype>1</vsizetype> | 473 | <vsizetype>1</vsizetype> |
404 | </sizepolicy> | 474 | </sizepolicy> |
405 | </property> | 475 | </property> |
406 | <property stdset="1"> | 476 | <property stdset="1"> |
407 | <name>text</name> | 477 | <name>text</name> |
408 | <string>IP Address</string> | 478 | <string>IP Address</string> |
409 | </property> | 479 | </property> |
410 | </widget> | 480 | </widget> |
411 | <widget row="1" column="0" rowspan="1" colspan="2" > | 481 | <widget row="1" column="0" rowspan="1" colspan="2" > |
412 | <class>QLabel</class> | 482 | <class>QLabel</class> |
413 | <property stdset="1"> | 483 | <property stdset="1"> |
414 | <name>name</name> | 484 | <name>name</name> |
415 | <cstring>IPAddress_LBL</cstring> | 485 | <cstring>IPAddress_LBL</cstring> |
416 | </property> | 486 | </property> |
417 | <property stdset="1"> | 487 | <property stdset="1"> |
418 | <name>enabled</name> | 488 | <name>enabled</name> |
419 | <bool>true</bool> | 489 | <bool>true</bool> |
420 | </property> | 490 | </property> |
421 | <property stdset="1"> | 491 | <property stdset="1"> |
422 | <name>sizePolicy</name> | 492 | <name>sizePolicy</name> |
423 | <sizepolicy> | 493 | <sizepolicy> |
424 | <hsizetype>7</hsizetype> | 494 | <hsizetype>7</hsizetype> |
425 | <vsizetype>1</vsizetype> | 495 | <vsizetype>1</vsizetype> |
426 | </sizepolicy> | 496 | </sizepolicy> |
427 | </property> | 497 | </property> |
428 | <property stdset="1"> | 498 | <property stdset="1"> |
429 | <name>frameShape</name> | 499 | <name>frameShape</name> |
430 | <enum>Panel</enum> | 500 | <enum>Panel</enum> |
431 | </property> | 501 | </property> |
432 | <property stdset="1"> | 502 | <property stdset="1"> |
433 | <name>frameShadow</name> | 503 | <name>frameShadow</name> |
434 | <enum>Sunken</enum> | 504 | <enum>Sunken</enum> |
435 | </property> | 505 | </property> |
436 | <property stdset="1"> | 506 | <property stdset="1"> |
437 | <name>text</name> | 507 | <name>text</name> |
438 | <string>0.0.0.0</string> | 508 | <string>0.0.0.0</string> |
439 | </property> | 509 | </property> |
440 | <property stdset="1"> | 510 | <property stdset="1"> |
441 | <name>alignment</name> | 511 | <name>alignment</name> |
442 | <set>AlignCenter</set> | 512 | <set>AlignCenter</set> |
443 | </property> | 513 | </property> |
444 | <property stdset="1"> | 514 | <property stdset="1"> |
445 | <name>indent</name> | 515 | <name>indent</name> |
446 | <number>0</number> | 516 | <number>0</number> |
447 | </property> | 517 | </property> |
448 | <property> | 518 | <property> |
449 | <name>hAlign</name> | 519 | <name>hAlign</name> |
450 | </property> | 520 | </property> |
451 | </widget> | 521 | </widget> |
452 | <widget row="1" column="2" > | 522 | <widget row="1" column="2" > |
453 | <class>QLabel</class> | 523 | <class>QLabel</class> |
454 | <property stdset="1"> | 524 | <property stdset="1"> |
455 | <name>name</name> | 525 | <name>name</name> |
456 | <cstring>SubnetMask_LBL</cstring> | 526 | <cstring>SubnetMask_LBL</cstring> |
457 | </property> | 527 | </property> |
458 | <property stdset="1"> | 528 | <property stdset="1"> |
459 | <name>enabled</name> | 529 | <name>enabled</name> |
460 | <bool>true</bool> | 530 | <bool>true</bool> |
461 | </property> | 531 | </property> |
462 | <property stdset="1"> | 532 | <property stdset="1"> |
463 | <name>sizePolicy</name> | 533 | <name>sizePolicy</name> |
464 | <sizepolicy> | 534 | <sizepolicy> |
465 | <hsizetype>7</hsizetype> | 535 | <hsizetype>7</hsizetype> |
466 | <vsizetype>1</vsizetype> | 536 | <vsizetype>1</vsizetype> |
467 | </sizepolicy> | 537 | </sizepolicy> |
468 | </property> | 538 | </property> |
469 | <property stdset="1"> | 539 | <property stdset="1"> |
470 | <name>frameShape</name> | 540 | <name>frameShape</name> |
471 | <enum>Panel</enum> | 541 | <enum>Panel</enum> |
472 | </property> | 542 | </property> |
473 | <property stdset="1"> | 543 | <property stdset="1"> |
474 | <name>frameShadow</name> | 544 | <name>frameShadow</name> |
475 | <enum>Sunken</enum> | 545 | <enum>Sunken</enum> |
476 | </property> | 546 | </property> |
477 | <property stdset="1"> | 547 | <property stdset="1"> |
478 | <name>text</name> | 548 | <name>text</name> |
479 | <string>0.0.0.0</string> | 549 | <string>0.0.0.0</string> |
480 | </property> | 550 | </property> |
481 | <property stdset="1"> | 551 | <property stdset="1"> |
482 | <name>alignment</name> | 552 | <name>alignment</name> |
483 | <set>AlignCenter</set> | 553 | <set>AlignCenter</set> |
484 | </property> | 554 | </property> |
485 | <property stdset="1"> | 555 | <property stdset="1"> |
486 | <name>indent</name> | 556 | <name>indent</name> |
487 | <number>0</number> | 557 | <number>0</number> |
488 | </property> | 558 | </property> |
489 | <property> | 559 | <property> |
490 | <name>hAlign</name> | 560 | <name>hAlign</name> |
491 | </property> | 561 | </property> |
492 | </widget> | 562 | </widget> |
493 | <widget row="1" column="3" > | 563 | <widget row="1" column="3" > |
494 | <class>QLabel</class> | 564 | <class>QLabel</class> |
495 | <property stdset="1"> | 565 | <property stdset="1"> |
496 | <name>name</name> | 566 | <name>name</name> |
497 | <cstring>Broadcast_LBL</cstring> | 567 | <cstring>Broadcast_LBL</cstring> |
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 | |||
@@ -1,54 +1,58 @@ | |||
1 | #include "profileedit.h" | 1 | #include "profileedit.h" |
2 | #include "profile_NNI.h" | 2 | #include "profile_NNI.h" |
3 | #include "profile_NN.h" | 3 | #include "profile_NN.h" |
4 | 4 | ||
5 | AProfile::AProfile( ProfileNetNode * PNN ) : ANetNodeInstance( PNN ) { | 5 | AProfile::AProfile( ProfileNetNode * PNN ) : ANetNodeInstance( PNN ) { |
6 | Data.Automatic = 1; | 6 | Data.Automatic = 1; |
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 | } |
13 | 14 | ||
14 | void AProfile::setSpecificAttribute( QString & Attr, QString & Value ) { | 15 | void AProfile::setSpecificAttribute( QString & Attr, QString & Value ) { |
15 | 16 | ||
16 | if ( Attr == "automatic" ) { | 17 | if ( Attr == "automatic" ) { |
17 | Data.Automatic = (Value=="yes"); | 18 | Data.Automatic = (Value=="yes"); |
18 | } else if ( Attr == "preconfirm" ) { | 19 | } else if ( Attr == "preconfirm" ) { |
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 | } |
25 | } | 28 | } |
26 | 29 | ||
27 | void AProfile::saveSpecificAttribute( QTextStream & TS ) { | 30 | 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 | ||
34 | QWidget * AProfile::edit( QWidget * parent ) { | 38 | QWidget * AProfile::edit( QWidget * parent ) { |
35 | GUI = new ProfileEdit( parent, this ); | 39 | GUI = new ProfileEdit( parent, this ); |
36 | GUI->showData( Data ); | 40 | GUI->showData( Data ); |
37 | return GUI; | 41 | return GUI; |
38 | } | 42 | } |
39 | 43 | ||
40 | QString AProfile::acceptable( void ) { | 44 | QString AProfile::acceptable( void ) { |
41 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 45 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
42 | } | 46 | } |
43 | 47 | ||
44 | void AProfile::commit( void ) { | 48 | void AProfile::commit( void ) { |
45 | if( GUI && GUI->commit( Data ) ) | 49 | if( GUI && GUI->commit( Data ) ) |
46 | setModified( 1 ); | 50 | setModified( 1 ); |
47 | } | 51 | } |
48 | 52 | ||
49 | bool AProfile::generateDataForCommonFile( | 53 | bool AProfile::generateDataForCommonFile( |
50 | SystemFile & , | 54 | SystemFile & , |
51 | long) { | 55 | long) { |
52 | return 1; | 56 | return 1; |
53 | } | 57 | } |
54 | 58 | ||
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 | |||
@@ -1,15 +1,16 @@ | |||
1 | #ifndef PROFILE_DATA_H | 1 | #ifndef PROFILE_DATA_H |
2 | #define PROFILE_DATA_H | 2 | #define PROFILE_DATA_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | typedef struct ProfileData { | 5 | typedef struct ProfileData { |
6 | QString Description; | 6 | QString Description; |
7 | // start up automatically | 7 | // start up automatically |
8 | bool Automatic; | 8 | bool Automatic; |
9 | // if started up automatically, ask user for confirmation | 9 | // if started up automatically, ask user for confirmation |
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 | |||
@@ -1,96 +1,98 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qframe.h> | 2 | #include <qframe.h> |
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qmultilineedit.h> | 4 | #include <qmultilineedit.h> |
5 | #include <qcheckbox.h> | 5 | #include <qcheckbox.h> |
6 | 6 | ||
7 | #include <GUIUtils.h> | 7 | #include <GUIUtils.h> |
8 | #include <asdevice.h> | 8 | #include <asdevice.h> |
9 | #include <resources.h> | 9 | #include <resources.h> |
10 | 10 | ||
11 | #include "profileedit.h" | 11 | #include "profileedit.h" |
12 | 12 | ||
13 | ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : | 13 | ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : |
14 | ProfileGUI( Parent ), RefreshTimer(this) { | 14 | ProfileGUI( Parent ), RefreshTimer(this) { |
15 | InterfaceInfo * II; | 15 | InterfaceInfo * II; |
16 | 16 | ||
17 | NNI = TNNI; | 17 | NNI = TNNI; |
18 | Dev = NNI->runtime()->device(); | 18 | Dev = NNI->runtime()->device(); |
19 | if( ( II = Dev->assignedInterface() ) ) { | 19 | if( ( II = Dev->assignedInterface() ) ) { |
20 | 20 | ||
21 | Refresh_CB->setEnabled( TRUE ); | 21 | Refresh_CB->setEnabled( TRUE ); |
22 | Snd_GB->setEnabled( TRUE ); | 22 | Snd_GB->setEnabled( TRUE ); |
23 | Rcv_GB->setEnabled( TRUE ); | 23 | Rcv_GB->setEnabled( TRUE ); |
24 | Collisions_FRM->setEnabled( TRUE ); | 24 | Collisions_FRM->setEnabled( TRUE ); |
25 | 25 | ||
26 | // show current content | 26 | // show current content |
27 | SLOT_Refresh(); | 27 | SLOT_Refresh(); |
28 | 28 | ||
29 | // fill in static data | 29 | // fill in static data |
30 | InterfaceName_LBL->setText( II->Name ); | 30 | InterfaceName_LBL->setText( II->Name ); |
31 | IPAddress_LBL->setText( II->Address ); | 31 | IPAddress_LBL->setText( II->Address ); |
32 | SubnetMask_LBL->setText( II->Netmask ); | 32 | SubnetMask_LBL->setText( II->Netmask ); |
33 | Broadcast_LBL->setText( II->BCastAddress ); | 33 | Broadcast_LBL->setText( II->BCastAddress ); |
34 | MACAddress_LBL->setText( II->MACAddress ); | 34 | MACAddress_LBL->setText( II->MACAddress ); |
35 | if( II->IsPointToPoint ) { | 35 | if( II->IsPointToPoint ) { |
36 | PointToPoint_LBL->setText( II->DstAddress ); | 36 | PointToPoint_LBL->setText( II->DstAddress ); |
37 | } | 37 | } |
38 | QString S; | 38 | QString S; |
39 | InterfaceName_LBL->setText( II->Name ); | 39 | InterfaceName_LBL->setText( II->Name ); |
40 | if( II->HasMulticast ) { | 40 | if( II->HasMulticast ) { |
41 | S += "Multicast"; | 41 | S += "Multicast"; |
42 | } | 42 | } |
43 | if( ! S.isEmpty() ) { | 43 | if( ! S.isEmpty() ) { |
44 | S.prepend( " : " ); | 44 | S.prepend( " : " ); |
45 | } | 45 | } |
46 | InterfaceOptions_LBL->setText( S ); | 46 | InterfaceOptions_LBL->setText( S ); |
47 | 47 | ||
48 | connect( &RefreshTimer, SIGNAL( timeout() ), | 48 | connect( &RefreshTimer, SIGNAL( timeout() ), |
49 | this, SLOT( SLOT_Refresh() ) ); | 49 | this, SLOT( SLOT_Refresh() ) ); |
50 | } | 50 | } |
51 | 51 | ||
52 | } | 52 | } |
53 | 53 | ||
54 | QString ProfileEdit::acceptable( void ) { | 54 | QString ProfileEdit::acceptable( void ) { |
55 | return QString(); | 55 | return QString(); |
56 | } | 56 | } |
57 | 57 | ||
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 | } |
64 | 65 | ||
65 | 66 | ||
66 | bool ProfileEdit::commit( ProfileData_t & Data ) { | 67 | bool ProfileEdit::commit( ProfileData_t & Data ) { |
67 | bool SM = 0; | 68 | bool SM = 0; |
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 | ||
74 | return SM; | 76 | return SM; |
75 | } | 77 | } |
76 | 78 | ||
77 | void ProfileEdit::SLOT_Refresh( void ) { | 79 | void ProfileEdit::SLOT_Refresh( void ) { |
78 | InterfaceInfo * II = Dev->assignedInterface(); | 80 | InterfaceInfo * II = Dev->assignedInterface(); |
79 | NSResources->system().refreshStatistics( *II ); | 81 | NSResources->system().refreshStatistics( *II ); |
80 | RcvBytes_LBL->setText( II->RcvBytes ); | 82 | RcvBytes_LBL->setText( II->RcvBytes ); |
81 | SndBytes_LBL->setText( II->SndBytes ); | 83 | SndBytes_LBL->setText( II->SndBytes ); |
82 | RcvErrors_LBL->setText( II->RcvErrors ); | 84 | RcvErrors_LBL->setText( II->RcvErrors ); |
83 | SndErrors_LBL->setText( II->SndErrors ); | 85 | SndErrors_LBL->setText( II->SndErrors ); |
84 | RcvDropped_LBL->setText( II->RcvDropped ); | 86 | RcvDropped_LBL->setText( II->RcvDropped ); |
85 | SndDropped_LBL->setText( II->SndDropped ); | 87 | SndDropped_LBL->setText( II->SndDropped ); |
86 | Collisions_LBL->setText( II->Collisions ); | 88 | Collisions_LBL->setText( II->Collisions ); |
87 | } | 89 | } |
88 | 90 | ||
89 | void ProfileEdit::SLOT_AutoRefresh( bool ar ) { | 91 | void ProfileEdit::SLOT_AutoRefresh( bool ar ) { |
90 | if( ar ) { | 92 | if( ar ) { |
91 | RefreshTimer.start( 1000 ); | 93 | RefreshTimer.start( 1000 ); |
92 | SLOT_Refresh(); | 94 | SLOT_Refresh(); |
93 | } else { | 95 | } else { |
94 | RefreshTimer.stop(); | 96 | RefreshTimer.stop(); |
95 | } | 97 | } |
96 | } | 98 | } |
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 | |||
@@ -1,65 +1,67 @@ | |||
1 | #include <resources.h> | 1 | #include <resources.h> |
2 | 2 | ||
3 | #include "profilerun.h" | 3 | #include "profilerun.h" |
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(); |
19 | switch ( A ) { | 21 | switch ( A ) { |
20 | case Enable : | 22 | case Enable : |
21 | if( NC->currentState() == Disabled ) { | 23 | if( NC->currentState() == Disabled ) { |
22 | Data->Disabled = 0; | 24 | Data->Disabled = 0; |
23 | NC->setCurrentState( Off ); // at least | 25 | NC->setCurrentState( Off ); // at least |
24 | // ... but request deeper | 26 | // ... but request deeper |
25 | NNNI->runtime()->detectState(NC); | 27 | NNNI->runtime()->detectState(NC); |
26 | } | 28 | } |
27 | return 1; | 29 | return 1; |
28 | case Disable : | 30 | case Disable : |
29 | switch( NC->currentState() ) { | 31 | switch( NC->currentState() ) { |
30 | case IsUp : | 32 | case IsUp : |
31 | case Available : | 33 | case Available : |
32 | // bring Deactivate (will bring down) | 34 | // bring Deactivate (will bring down) |
33 | if( ! NNNI->runtime()->setState(NC, Deactivate) ) | 35 | if( ! NNNI->runtime()->setState(NC, Deactivate) ) |
34 | return 0; | 36 | return 0; |
35 | default : | 37 | default : |
36 | break; | 38 | break; |
37 | } | 39 | } |
38 | Data->Disabled = 1; | 40 | Data->Disabled = 1; |
39 | NC->setCurrentState( Disabled ); | 41 | NC->setCurrentState( Disabled ); |
40 | return 1; | 42 | return 1; |
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 ) { |
48 | RuntimeInfo * RI; | 50 | RuntimeInfo * RI; |
49 | switch ( A ) { | 51 | switch ( A ) { |
50 | case Enable : | 52 | case Enable : |
51 | case Disable : | 53 | case Disable : |
52 | // always possible | 54 | // always possible |
53 | return 1; | 55 | return 1; |
54 | default : | 56 | default : |
55 | break; | 57 | break; |
56 | } | 58 | } |
57 | RI = netNode()->nextNode()->runtime(); | 59 | RI = netNode()->nextNode()->runtime(); |
58 | return ( Curr != Disabled ) ? | 60 | return ( Curr != Disabled ) ? |
59 | RI->canSetState(Curr, A) : 0; | 61 | RI->canSetState(Curr, A) : 0; |
60 | } | 62 | } |
61 | 63 | ||
62 | bool ProfileRun::handlesInterface( const QString & S ) { | 64 | bool ProfileRun::handlesInterface( const QString & S ) { |
63 | // donno -> pass deeper | 65 | // donno -> pass deeper |
64 | return netNode()->nextNode()->runtime()->handlesInterface(S); | 66 | return netNode()->nextNode()->runtime()->handlesInterface(S); |
65 | } | 67 | } |
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 | |||
@@ -1,31 +1,35 @@ | |||
1 | #ifndef PROFILERUN_H | 1 | #ifndef PROFILERUN_H |
2 | #define PROFILERUN_H | 2 | #define PROFILERUN_H |
3 | 3 | ||
4 | #include <asfullsetup.h> | 4 | #include <asfullsetup.h> |
5 | #include "profiledata.h" | 5 | #include "profiledata.h" |
6 | 6 | ||
7 | class ProfileRun : public AsFullSetup { | 7 | class ProfileRun : public AsFullSetup { |
8 | 8 | ||
9 | public : | 9 | public : |
10 | 10 | ||
11 | ProfileRun( ANetNodeInstance * NNI, ProfileData & D ) : | 11 | ProfileRun( ANetNodeInstance * NNI, ProfileData & D ) : |
12 | AsFullSetup( NNI ) | 12 | AsFullSetup( NNI ) |
13 | { Data = &D; } | 13 | { Data = &D; } |
14 | 14 | ||
15 | void detectState( NodeCollection * NC ); | 15 | void detectState( NodeCollection * NC ); |
16 | bool setState( NodeCollection * NC, Action_t A, bool ); | 16 | bool setState( NodeCollection * NC, Action_t A, bool ); |
17 | bool canSetState( State_t Curr, Action_t A ); | 17 | bool canSetState( State_t Curr, Action_t A ); |
18 | 18 | ||
19 | bool handlesInterface( const QString & I ); | 19 | bool handlesInterface( const QString & I ); |
20 | 20 | ||
21 | virtual const QString & description( void ) | 21 | virtual const QString & description( void ) |
22 | { return Data->Description; } | 22 | { return Data->Description; } |
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; |
29 | 33 | ||
30 | }; | 34 | }; |
31 | #endif | 35 | #endif |
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 | |||
@@ -1,176 +1,178 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | #include <qfileinfo.h> | 2 | #include <qfileinfo.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <resources.h> | 4 | #include <resources.h> |
5 | #include "usbrun.h" | 5 | #include "usbrun.h" |
6 | 6 | ||
7 | void USBRun::detectState( NodeCollection * NC ) { | 7 | void USBRun::detectState( NodeCollection * NC ) { |
8 | // unavailable : no card found | 8 | // unavailable : no card found |
9 | // available : card found and assigned to us or free | 9 | // available : card found and assigned to us or free |
10 | // up : card found and assigned to us and up | 10 | // up : card found and assigned to us and up |
11 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); | 11 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); |
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()); |
24 | It.current(); | 26 | It.current(); |
25 | ++It ) { | 27 | ++It ) { |
26 | Run = It.current(); | 28 | Run = It.current(); |
27 | if( X == Run->Name ) { | 29 | if( X == Run->Name ) { |
28 | Run->assignNode( netNode() ); | 30 | Run->assignNode( netNode() ); |
29 | assignInterface( Run ); | 31 | assignInterface( Run ); |
30 | NC->setCurrentState( IsUp ); | 32 | NC->setCurrentState( IsUp ); |
31 | return; | 33 | return; |
32 | } | 34 | } |
33 | } | 35 | } |
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 ) { |
41 | // usb is still free -> keep assignment | 43 | // usb is still free -> keep assignment |
42 | NC->setCurrentState( Available ); | 44 | NC->setCurrentState( Available ); |
43 | return; | 45 | return; |
44 | } // else interface is up but NOT us -> some other profile | 46 | } // else interface is up but NOT us -> some other profile |
45 | } | 47 | } |
46 | 48 | ||
47 | // nothing (valid) assigned to us | 49 | // nothing (valid) assigned to us |
48 | assignInterface( 0 ); | 50 | assignInterface( 0 ); |
49 | 51 | ||
50 | // find possible interface | 52 | // find possible interface |
51 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); | 53 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); |
52 | It.current(); | 54 | It.current(); |
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 | } |
77 | 79 | ||
78 | bool USBRun::setState( NodeCollection * NC, Action_t A, bool ) { | 80 | bool USBRun::setState( NodeCollection * NC, Action_t A, bool ) { |
79 | 81 | ||
80 | // we only handle activate and deactivate | 82 | // we only handle activate and deactivate |
81 | switch( A ) { | 83 | switch( A ) { |
82 | case Activate : | 84 | case Activate : |
83 | { | 85 | { |
84 | if( NC->currentState() != Off ) { | 86 | if( NC->currentState() != Off ) { |
85 | return 0; | 87 | return 0; |
86 | } | 88 | } |
87 | InterfaceInfo * N = getInterface(); | 89 | InterfaceInfo * N = getInterface(); |
88 | if( ! N ) { | 90 | if( ! N ) { |
89 | // no interface available | 91 | // no interface available |
90 | NC->setCurrentState( Unavailable ); | 92 | NC->setCurrentState( Unavailable ); |
91 | return 0; | 93 | return 0; |
92 | } | 94 | } |
93 | // because we were OFF the interface | 95 | // because we were OFF the interface |
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 | } |
101 | case Deactivate : | 103 | case Deactivate : |
102 | if( NC->currentState() == IsUp ) { | 104 | if( NC->currentState() == IsUp ) { |
103 | // bring down first | 105 | // bring down first |
104 | if( ! connection()->setState( Down ) ) | 106 | if( ! connection()->setState( Down ) ) |
105 | // could not ... | 107 | // could not ... |
106 | return 0; | 108 | return 0; |
107 | } else if( NC->currentState() != Available ) { | 109 | } else if( NC->currentState() != Available ) { |
108 | return 1; | 110 | return 1; |
109 | } | 111 | } |
110 | assignedInterface()->assignNode( 0 ); // release | 112 | assignedInterface()->assignNode( 0 ); // release |
111 | assignInterface( 0 ); | 113 | assignInterface( 0 ); |
112 | NC->setCurrentState( Off ); | 114 | NC->setCurrentState( Off ); |
113 | return 1; | 115 | return 1; |
114 | default : | 116 | default : |
115 | // FT | 117 | // FT |
116 | break; | 118 | break; |
117 | } | 119 | } |
118 | return 0; | 120 | return 0; |
119 | } | 121 | } |
120 | 122 | ||
121 | bool USBRun::canSetState( State_t Curr, Action_t A ) { | 123 | bool USBRun::canSetState( State_t Curr, Action_t A ) { |
122 | // we only handle up down activate and deactivate | 124 | // we only handle up down activate and deactivate |
123 | switch( A ) { | 125 | switch( A ) { |
124 | case Activate : | 126 | case Activate : |
125 | { // at least available | 127 | { // at least available |
126 | if( Curr == Available ) { | 128 | if( Curr == Available ) { |
127 | return 1; | 129 | return 1; |
128 | } | 130 | } |
129 | // or we can make one available | 131 | // or we can make one available |
130 | InterfaceInfo * N = getInterface(); | 132 | InterfaceInfo * N = getInterface(); |
131 | if( ! N || N->assignedNode() != 0 ) { | 133 | if( ! N || N->assignedNode() != 0 ) { |
132 | // non available or assigned | 134 | // non available or assigned |
133 | return 0; | 135 | return 0; |
134 | } | 136 | } |
135 | return 1; | 137 | return 1; |
136 | } | 138 | } |
137 | case Deactivate : | 139 | case Deactivate : |
138 | return ( Curr >= Available ); | 140 | return ( Curr >= Available ); |
139 | default : | 141 | default : |
140 | // FT | 142 | // FT |
141 | break; | 143 | break; |
142 | } | 144 | } |
143 | return 0; | 145 | return 0; |
144 | } | 146 | } |
145 | 147 | ||
146 | // get interface that is free or assigned to us | 148 | // get interface that is free or assigned to us |
147 | InterfaceInfo * USBRun::getInterface( void ) { | 149 | InterfaceInfo * USBRun::getInterface( void ) { |
148 | 150 | ||
149 | System & S = NSResources->system(); | 151 | System & S = NSResources->system(); |
150 | InterfaceInfo * best = 0, * Run; | 152 | InterfaceInfo * best = 0, * Run; |
151 | QRegExp R( "usb[0-9abcdef]" ); | 153 | QRegExp R( "usb[0-9abcdef]" ); |
152 | 154 | ||
153 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | 155 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); |
154 | It.current(); | 156 | It.current(); |
155 | ++It ) { | 157 | ++It ) { |
156 | Run = It.current(); | 158 | Run = It.current(); |
157 | if( handlesInterface( Run->Name ) && | 159 | if( handlesInterface( Run->Name ) && |
158 | Run->CardType == ARPHRD_ETHER | 160 | Run->CardType == ARPHRD_ETHER |
159 | ) { | 161 | ) { |
160 | // this is a USB card | 162 | // this is a USB card |
161 | if( Run->assignedNode() == netNode() ) { | 163 | if( Run->assignedNode() == netNode() ) { |
162 | // assigned to us | 164 | // assigned to us |
163 | return Run; | 165 | return Run; |
164 | } else if( Run->assignedNode() == 0 ) { | 166 | } else if( Run->assignedNode() == 0 ) { |
165 | // free | 167 | // free |
166 | best = Run; | 168 | best = Run; |
167 | } | 169 | } |
168 | } | 170 | } |
169 | } | 171 | } |
170 | return best; // can be 0 | 172 | return best; // can be 0 |
171 | } | 173 | } |
172 | 174 | ||
173 | bool USBRun::handlesInterface( const QString & S ) { | 175 | bool USBRun::handlesInterface( const QString & S ) { |
174 | return Pat.match( S ) >= 0; | 176 | return Pat.match( S ) >= 0; |
175 | } | 177 | } |
176 | 178 | ||