12 files changed, 121 insertions, 25 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp index cd7bb4a..63b214e 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp | |||
@@ -1,164 +1,192 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <resources.h> | 2 | #include <resources.h> |
3 | |||
4 | #include <OTPeer.h> | ||
3 | #include <OTDevice.h> | 5 | #include <OTDevice.h> |
4 | #include <OTGateway.h> | 6 | #include <OTGateway.h> |
7 | #include <Opietooth.h> | ||
8 | |||
9 | #include <qlistbox.h> | ||
10 | #include <qframe.h> | ||
11 | #include <qlabel.h> | ||
12 | #include <qlayout.h> | ||
13 | #include <qdialog.h> | ||
14 | |||
5 | #include "bluetoothRFCOMMrun.h" | 15 | #include "bluetoothRFCOMMrun.h" |
6 | 16 | ||
7 | using Opietooth2::OTGateway; | 17 | using Opietooth2::OTGateway; |
8 | using Opietooth2::OTDevice; | 18 | using Opietooth2::OTDevice; |
9 | using Opietooth2::OTDeviceAddress; | 19 | using Opietooth2::OTDeviceAddress; |
20 | using Opietooth2::OTScan; | ||
21 | using Opietooth2::OTPeer; | ||
10 | 22 | ||
11 | BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) { | 23 | BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) { |
12 | if( OT ) { | 24 | if( OT ) { |
13 | OTGateway::releaseOTGateway(); | 25 | OTGateway::releaseOTGateway(); |
14 | } | 26 | } |
15 | } | 27 | } |
16 | 28 | ||
17 | State_t BluetoothRFCOMMRun::detectState( void ) { | 29 | State_t BluetoothRFCOMMRun::detectState( void ) { |
18 | 30 | ||
19 | if( ! OT ) { | 31 | if( ! OT ) { |
20 | OT = OTGateway::getOTGateway(); | 32 | OT = OTGateway::getOTGateway(); |
21 | } | 33 | } |
22 | 34 | ||
23 | if( deviceNrOfNetworkSetup() >= 0 ) { | 35 | if( deviceNrOfNetworkSetup() >= 0 ) { |
24 | return Available; | 36 | return Available; |
25 | } | 37 | } |
26 | 38 | ||
27 | odebug << "Bluetooth " | 39 | odebug << "Bluetooth " |
28 | << OT->isEnabled() | 40 | << OT->isEnabled() |
29 | << oendl; | 41 | << oendl; |
30 | 42 | ||
31 | return ( OT->isEnabled() ) ? Off : Unavailable; | 43 | return ( OT->isEnabled() ) ? Off : Unavailable; |
32 | } | 44 | } |
33 | 45 | ||
34 | QString BluetoothRFCOMMRun::setMyState( NetworkSetup *, | 46 | QString BluetoothRFCOMMRun::setMyState( NetworkSetup *, |
35 | Action_t A, | 47 | Action_t A, |
36 | bool ) { | 48 | bool ) { |
37 | 49 | ||
38 | if( OT ) { | 50 | if( OT ) { |
39 | OTGateway::getOTGateway(); | 51 | OTGateway::getOTGateway(); |
40 | } | 52 | } |
41 | 53 | ||
42 | if( A == Activate ) { | 54 | if( A == Activate ) { |
43 | // from OFF to Available | 55 | // from OFF to Available |
44 | RFCOMMChannel * Ch = getChannel( ); | 56 | RFCOMMChannel * Ch = getChannel( ); |
45 | System & Sys = NSResources->system(); | 57 | System & Sys = NSResources->system(); |
46 | 58 | ||
47 | if( Ch ) { | 59 | if( Ch ) { |
48 | // connect to this peer | 60 | // connect to this peer |
49 | DeviceNr = OT->getFreeRFCommDevice(); | 61 | DeviceNr = OT->getFreeRFCommDevice(); |
50 | QStringList S; | 62 | QStringList S; |
51 | 63 | ||
52 | S << "rfcomm" | 64 | S << "rfcomm" |
53 | << "bind" | 65 | << "bind" |
54 | << QString().setNum( DeviceNr ) | 66 | << QString().setNum( DeviceNr ) |
55 | << Ch->BDAddress | 67 | << Ch->BDAddress |
56 | << QString().setNum( Ch->Channel ); | 68 | << QString().setNum( Ch->Channel ); |
57 | 69 | ||
70 | // no longer needed | ||
71 | delete Ch; | ||
72 | |||
58 | if( Sys.runAsRoot( S ) ) { | 73 | if( Sys.runAsRoot( S ) ) { |
59 | return QString( "Error starting %1").arg(S.join(" ")); | 74 | return QString( "Error starting %1").arg(S.join(" ")); |
60 | } | 75 | } |
61 | 76 | ||
62 | // here rfcomm should be running -> we will detect state later | 77 | // here rfcomm should be running -> we will detect state later |
63 | return QString(); | 78 | return QString(); |
64 | } else { | 79 | } else { |
65 | Log(( "No channel selected -> cancel\n" )); | 80 | Log(( "No channel selected -> cancel\n" )); |
66 | return QString( "No channel selected. Operation cancelled" ); | 81 | return QString( "No channel selected. Operation cancelled" ); |
67 | } | 82 | } |
68 | } | 83 | } |
69 | 84 | ||
70 | if( A == Deactivate ) { | 85 | if( A == Deactivate ) { |
71 | if( DeviceNr >= 0 ) { | 86 | if( DeviceNr >= 0 ) { |
72 | if( OT->releaseRFCommDevice( DeviceNr ) ) { | 87 | if( OT->releaseRFCommDevice( DeviceNr ) ) { |
73 | return QString( "Cannot release RFCOMM NetworkSetup" ); | 88 | return QString( "Cannot release RFCOMM NetworkSetup" ); |
74 | } | 89 | } |
75 | DeviceNr = -1; | 90 | DeviceNr = -1; |
76 | } | 91 | } |
77 | } | 92 | } |
78 | return QString(); | 93 | return QString(); |
79 | } | 94 | } |
80 | 95 | ||
81 | #include <qlistbox.h> | ||
82 | #include <qframe.h> | ||
83 | #include <qlabel.h> | ||
84 | #include <qlayout.h> | ||
85 | #include <qdialog.h> | ||
86 | |||
87 | RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) { | 96 | RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) { |
88 | 97 | ||
89 | if( Data->Devices.count() == 1 ) { | 98 | if( Data->Devices.count() == 1 ) { |
90 | // only one device -> return channel | 99 | // only one device -> return channel |
91 | return Data->Devices[0]; | 100 | return Data->Devices[0]; |
92 | } | 101 | } |
93 | 102 | ||
94 | RFCOMMChannel * Ch = 0; | 103 | RFCOMMChannel * Ch = 0; |
104 | |||
105 | if( Data->Devices.count() == 0 ) { | ||
106 | OTPeer * Peer; | ||
107 | int Channel; | ||
108 | |||
109 | if( OTScan::getDevice( Peer, Channel, OT ) == QDialog::Accepted ) { | ||
110 | Ch = new RFCOMMChannel; | ||
111 | Ch->BDAddress = Peer->address().toString(); | ||
112 | Ch->Name = Peer->name(); | ||
113 | Ch->Channel = Channel; | ||
114 | return Ch; | ||
115 | } | ||
116 | |||
117 | return 0; | ||
118 | } | ||
119 | |||
95 | QDialog * Dlg = new QDialog( qApp->mainWidget(), 0, TRUE ); | 120 | QDialog * Dlg = new QDialog( qApp->mainWidget(), 0, TRUE ); |
96 | QVBoxLayout * V = new QVBoxLayout( Dlg ); | 121 | QVBoxLayout * V = new QVBoxLayout( Dlg ); |
97 | 122 | ||
98 | QLabel * L = new QLabel( | 123 | QLabel * L = new QLabel( |
99 | qApp->translate( "BluetoothRFCOMMRun", | 124 | qApp->translate( "BluetoothRFCOMMRun", |
100 | "Select device to connect to"), | 125 | "Select device to connect to"), |
101 | Dlg ); | 126 | Dlg ); |
102 | QListBox * LB = new QListBox( Dlg ); | 127 | QListBox * LB = new QListBox( Dlg ); |
103 | 128 | ||
104 | for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) { | 129 | for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) { |
105 | LB->insertItem( QString( "%1 (%2 Chnl %3)" ). | 130 | LB->insertItem( QString( "%1 (%2 Chnl %3)" ). |
106 | arg( Data->Devices[i]->Name ). | 131 | arg( Data->Devices[i]->Name ). |
107 | arg( Data->Devices[i]->BDAddress ). | 132 | arg( Data->Devices[i]->BDAddress ). |
108 | arg( Data->Devices[i]->Channel ) ); | 133 | arg( Data->Devices[i]->Channel ) ); |
109 | } | 134 | } |
110 | 135 | ||
111 | V->addWidget( L ); | 136 | V->addWidget( L ); |
112 | V->addWidget( LB ); | 137 | V->addWidget( LB ); |
113 | 138 | ||
114 | Dlg->resize( 100, 100 ); | 139 | Dlg->resize( 100, 100 ); |
115 | Dlg->move( 20, | 140 | Dlg->move( 20, |
116 | (qApp->desktop()->height()-100)/2 ); | 141 | (qApp->desktop()->height()-100)/2 ); |
117 | 142 | ||
118 | if( Dlg->exec() == QDialog::Accepted ) { | 143 | if( Dlg->exec() == QDialog::Accepted ) { |
119 | unsigned int i = 0; | 144 | unsigned int i = 0; |
120 | for( i = 0; i < Data->Devices.count(); i ++ ) { | 145 | for( i = 0; i < Data->Devices.count(); i ++ ) { |
121 | if( LB->isSelected(i) ) { | 146 | if( LB->isSelected(i) ) { |
122 | odebug << "Selected " << Data->Devices[i]->Name << oendl; | 147 | odebug << "Selected " << Data->Devices[i]->Name << oendl; |
123 | Ch = Data->Devices[i]; | 148 | Ch = new RFCOMMChannel; |
149 | Ch->BDAddress = Data->Devices[i]->BDAddress; | ||
150 | Ch->Name = Data->Devices[i]->Name; | ||
151 | Ch->Channel = Data->Devices[i]->Channel; | ||
124 | break; | 152 | break; |
125 | } | 153 | } |
126 | } | 154 | } |
127 | } | 155 | } |
128 | 156 | ||
129 | delete Dlg; | 157 | delete Dlg; |
130 | return Ch; | 158 | return Ch; |
131 | } | 159 | } |
132 | 160 | ||
133 | QString BluetoothRFCOMMRun::deviceFile( void ) { | 161 | QString BluetoothRFCOMMRun::deviceFile( void ) { |
134 | if( deviceNrOfNetworkSetup() >= 0 ) { | 162 | if( deviceNrOfNetworkSetup() >= 0 ) { |
135 | OTDevice * OTD = OT->getOTDevice(); | 163 | OTDevice * OTD = OT->getOTDevice(); |
136 | // there is a NetworkSetup | 164 | // there is a NetworkSetup |
137 | return OTD->getRFCommDevicePattern().arg(DeviceNr); | 165 | return OTD->getRFCommDevicePattern().arg(DeviceNr); |
138 | } | 166 | } |
139 | return QString(); | 167 | return QString(); |
140 | } | 168 | } |
141 | 169 | ||
142 | int BluetoothRFCOMMRun::deviceNrOfNetworkSetup( void ) { | 170 | int BluetoothRFCOMMRun::deviceNrOfNetworkSetup( void ) { |
143 | 171 | ||
144 | if( ! OT ) { | 172 | if( ! OT ) { |
145 | OT = OTGateway::getOTGateway(); | 173 | OT = OTGateway::getOTGateway(); |
146 | } | 174 | } |
147 | 175 | ||
148 | DeviceNr = -1; | 176 | DeviceNr = -1; |
149 | for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) { | 177 | for( unsigned int i = 0; i < Data->Devices.count(); i ++ ) { |
150 | odebug << "Check for rfcomm on " | 178 | odebug << "Check for rfcomm on " |
151 | << Data->Devices[i]->BDAddress | 179 | << Data->Devices[i]->BDAddress |
152 | << " " | 180 | << " " |
153 | << Data->Devices[i]->Channel | 181 | << Data->Devices[i]->Channel |
154 | << oendl; | 182 | << oendl; |
155 | if( ( DeviceNr = OT->connectedToRFCommChannel( | 183 | if( ( DeviceNr = OT->connectedToRFCommChannel( |
156 | OTDeviceAddress( Data->Devices[i]->BDAddress ), | 184 | OTDeviceAddress( Data->Devices[i]->BDAddress ), |
157 | Data->Devices[i]->Channel ) ) >= 0 ) { | 185 | Data->Devices[i]->Channel ) ) >= 0 ) { |
158 | odebug << "Up " | 186 | odebug << "Up " |
159 | << oendl; | 187 | << oendl; |
160 | break; | 188 | break; |
161 | } | 189 | } |
162 | } | 190 | } |
163 | return DeviceNr; | 191 | return DeviceNr; |
164 | } | 192 | } |
diff --git a/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp b/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp index bf8cc59..2dd54ff 100644 --- a/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp +++ b/noncore/settings/networksettings2/gprs/GPRS_NNI.cpp | |||
@@ -146,86 +146,89 @@ short AGPRSDevice::generateFile( SystemFile & SF, | |||
146 | SF << "lcp-echo-interval 0" << oendl; | 146 | SF << "lcp-echo-interval 0" << oendl; |
147 | SF << "lcp-echo-failure 0" << oendl; | 147 | SF << "lcp-echo-failure 0" << oendl; |
148 | SF << "usepeerdns" << oendl; | 148 | SF << "usepeerdns" << oendl; |
149 | SF << "linkname " << removeSpaces( networkSetup()->name() ) << oendl; | 149 | SF << "linkname " << removeSpaces( networkSetup()->name() ) << oendl; |
150 | SF << "nopersist" << oendl; | 150 | SF << "nopersist" << oendl; |
151 | SF << "ipparam " << removeSpaces( networkSetup()->name() ) <<oendl; | 151 | SF << "ipparam " << removeSpaces( networkSetup()->name() ) <<oendl; |
152 | SF << "maxfail 1" << oendl; | 152 | SF << "maxfail 1" << oendl; |
153 | return 0; | 153 | return 0; |
154 | } else if( SF.name() == "extra" ) { | 154 | } else if( SF.name() == "extra" ) { |
155 | unsigned long Bits; | 155 | unsigned long Bits; |
156 | // generate 'fixed' settings | 156 | // generate 'fixed' settings |
157 | for( unsigned int i = 0 ; | 157 | for( unsigned int i = 0 ; |
158 | i < Data.Routing.count(); | 158 | i < Data.Routing.count(); |
159 | i ++ ) { | 159 | i ++ ) { |
160 | if( Data.Routing[i]->Mask == 32 ) { | 160 | if( Data.Routing[i]->Mask == 32 ) { |
161 | Bits = 0xffffffff; | 161 | Bits = 0xffffffff; |
162 | } else { | 162 | } else { |
163 | Bits = ~ ((1 << ((32-Data.Routing[i]->Mask))) - 1); | 163 | Bits = ~ ((1 << ((32-Data.Routing[i]->Mask))) - 1); |
164 | } | 164 | } |
165 | SF << "route add -net " | 165 | SF << "route add -net " |
166 | << Data.Routing[i]->Address | 166 | << Data.Routing[i]->Address |
167 | << " netmask " | 167 | << " netmask " |
168 | << ((Bits&0xff000000)>>24) | 168 | << ((Bits&0xff000000)>>24) |
169 | << "." | 169 | << "." |
170 | << ((Bits&0x00ff0000)>>16) | 170 | << ((Bits&0x00ff0000)>>16) |
171 | << "." | 171 | << "." |
172 | << ((Bits&0x0000ff00)>>8) | 172 | << ((Bits&0x0000ff00)>>8) |
173 | << "." | 173 | << "." |
174 | << ((Bits&0x000000ff)) | 174 | << ((Bits&0x000000ff)) |
175 | << " gw $PPP_REMOTE" | 175 | << " gw $PPP_REMOTE" |
176 | << oendl; | 176 | << oendl; |
177 | SF << "route del -net " | 177 | SF << "route del -net " |
178 | << Data.Routing[i]->Address | 178 | << Data.Routing[i]->Address |
179 | << " netmask " | 179 | << " netmask " |
180 | << ((Bits&0xff000000)>>24) | 180 | << ((Bits&0xff000000)>>24) |
181 | << "." | 181 | << "." |
182 | << ((Bits&0x00ff0000)>>16) | 182 | << ((Bits&0x00ff0000)>>16) |
183 | << "." | 183 | << "." |
184 | << ((Bits&0x0000ff00)>>8) | 184 | << ((Bits&0x0000ff00)>>8) |
185 | << "." | 185 | << "." |
186 | << ((Bits&0x000000ff)) | 186 | << ((Bits&0x000000ff)) |
187 | << " gw $PPP_REMOTE" | 187 | << " gw $PPP_REMOTE" |
188 | << oendl; | 188 | << oendl; |
189 | } | 189 | } |
190 | 190 | ||
191 | if( ! Data.DNS1.isEmpty() ) { | 191 | if( ! Data.DNS1.isEmpty() ) { |
192 | SF << "nameserver " | 192 | SF << "nameserver " |
193 | << Data.DNS1 | 193 | << Data.DNS1 |
194 | << " # profile " | 194 | << " # profile " |
195 | << removeSpaces( networkSetup()->name() ) | 195 | << removeSpaces( networkSetup()->name() ) |
196 | <<oendl; | 196 | <<oendl; |
197 | } | 197 | } |
198 | 198 | ||
199 | if( ! Data.DNS2.isEmpty() ) { | 199 | if( ! Data.DNS2.isEmpty() ) { |
200 | SF << "nameserver " | 200 | SF << "nameserver " |
201 | << Data.DNS2 | 201 | << Data.DNS2 |
202 | << " # profile " | 202 | << " # profile " |
203 | << removeSpaces( networkSetup()->name() ) | 203 | << removeSpaces( networkSetup()->name() ) |
204 | <<oendl; | 204 | <<oendl; |
205 | } | 205 | } |
206 | } | 206 | } |
207 | return 1; | 207 | return 1; |
208 | } | 208 | } |
209 | 209 | ||
210 | bool AGPRSDevice::openFile( SystemFile & SF ) { | 210 | bool AGPRSDevice::openFile( SystemFile & SF, QStringList & SL ) { |
211 | if( SF.name() == "peers" ) { | 211 | if( SF.name() == "peers" ) { |
212 | SL << "/etc" << "ppp" << "peers"; | ||
212 | SF.setPath( | 213 | SF.setPath( |
213 | QString( "/etc/ppp/peers/" ) + | 214 | QString( "/etc/ppp/peers/" ) + |
214 | removeSpaces( networkSetup()->name() ) | 215 | removeSpaces( networkSetup()->name() ) |
215 | ); | 216 | ); |
216 | return 1; | 217 | return 1; |
217 | } else if ( SF.name() == "chatscripts" ) { | 218 | } else if ( SF.name() == "chatscripts" ) { |
219 | SL << "/etc" << "chatscripts"; | ||
218 | SF.setPath( | 220 | SF.setPath( |
219 | QString( "/etc/chatscripts/" ) + | 221 | QString( "/etc/chatscripts/" ) + |
220 | removeSpaces( networkSetup()->name() ) | 222 | removeSpaces( networkSetup()->name() ) |
221 | ); | 223 | ); |
222 | return 1; | 224 | return 1; |
225 | SL << "/etc" << "ppp"; | ||
223 | } else if ( SF.name() == "extra" ) { | 226 | } else if ( SF.name() == "extra" ) { |
224 | SF.setPath( | 227 | SF.setPath( |
225 | QString( "/etc/ppp/" ) + | 228 | QString( "/etc/ppp/" ) + |
226 | removeSpaces( networkSetup()->name() ) + ".fixed" | 229 | removeSpaces( networkSetup()->name() ) + ".fixed" |
227 | ); | 230 | ); |
228 | return 1; | 231 | return 1; |
229 | } | 232 | } |
230 | return 0; | 233 | return 0; |
231 | } | 234 | } |
diff --git a/noncore/settings/networksettings2/gprs/GPRS_NNI.h b/noncore/settings/networksettings2/gprs/GPRS_NNI.h index 1060a6e..b5bf1b9 100644 --- a/noncore/settings/networksettings2/gprs/GPRS_NNI.h +++ b/noncore/settings/networksettings2/gprs/GPRS_NNI.h | |||
@@ -1,48 +1,49 @@ | |||
1 | #ifndef GPRS_H | 1 | #ifndef GPRS_H |
2 | #define GPRS_H | 2 | #define GPRS_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "GPRSdata.h" | 5 | #include "GPRSdata.h" |
6 | #include "GPRSrun.h" | 6 | #include "GPRSrun.h" |
7 | 7 | ||
8 | class GPRSNetNode; | 8 | class GPRSNetNode; |
9 | class GPRSEdit; | 9 | class GPRSEdit; |
10 | class SystemFile; | 10 | class SystemFile; |
11 | 11 | ||
12 | class AGPRSDevice : public ANetNodeInstance{ | 12 | class AGPRSDevice : public ANetNodeInstance{ |
13 | 13 | ||
14 | public : | 14 | public : |
15 | 15 | ||
16 | AGPRSDevice( GPRSNetNode * PNN ); | 16 | AGPRSDevice( GPRSNetNode * PNN ); |
17 | 17 | ||
18 | RuntimeInfo * runtime( void ) | 18 | RuntimeInfo * runtime( void ) |
19 | { return | 19 | { return |
20 | ( RT ) ? RT : ( RT = new GPRSRun( this, Data ) ); | 20 | ( RT ) ? RT : ( RT = new GPRSRun( this, Data ) ); |
21 | } | 21 | } |
22 | 22 | ||
23 | QWidget * edit( QWidget * parent ); | 23 | QWidget * edit( QWidget * parent ); |
24 | QString acceptable( void ); | 24 | QString acceptable( void ); |
25 | void commit( void ); | 25 | void commit( void ); |
26 | 26 | ||
27 | virtual bool openFile( SystemFile & SF ); | 27 | virtual bool openFile( SystemFile & SF, |
28 | QStringList & SL ); | ||
28 | 29 | ||
29 | virtual void * data( void ) | 30 | virtual void * data( void ) |
30 | { return (void *)&Data; } | 31 | { return (void *)&Data; } |
31 | 32 | ||
32 | virtual bool hasDataForFile( SystemFile & S ); | 33 | virtual bool hasDataForFile( SystemFile & S ); |
33 | virtual short generateFile( SystemFile & SF, | 34 | virtual short generateFile( SystemFile & SF, |
34 | long DevNr ); | 35 | long DevNr ); |
35 | 36 | ||
36 | protected : | 37 | protected : |
37 | 38 | ||
38 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 39 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
39 | virtual void saveSpecificAttribute( QTextStream & TS ); | 40 | virtual void saveSpecificAttribute( QTextStream & TS ); |
40 | 41 | ||
41 | private : | 42 | private : |
42 | 43 | ||
43 | GPRSEdit * GUI; | 44 | GPRSEdit * GUI; |
44 | GPRSData Data; | 45 | GPRSData Data; |
45 | GPRSRun * RT; | 46 | GPRSRun * RT; |
46 | }; | 47 | }; |
47 | 48 | ||
48 | #endif | 49 | #endif |
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp index 80dcb3d..2714dd5 100644 --- a/noncore/settings/networksettings2/networksettings.cpp +++ b/noncore/settings/networksettings2/networksettings.cpp | |||
@@ -190,129 +190,129 @@ void NetworkSettings::SLOT_DeleteNode( void ) { | |||
190 | tr( "Removing profile" ), | 190 | tr( "Removing profile" ), |
191 | tr( "Remove selected profile ?" ), | 191 | tr( "Remove selected profile ?" ), |
192 | 1, 0 ) == 1 ) { | 192 | 1, 0 ) == 1 ) { |
193 | NSResources->removeNetworkSetup( LBI->text() ); | 193 | NSResources->removeNetworkSetup( LBI->text() ); |
194 | delete LBI; | 194 | delete LBI; |
195 | NSD.setModified( 1 ); | 195 | NSD.setModified( 1 ); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { | 199 | void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { |
200 | QString OldName = ""; | 200 | QString OldName = ""; |
201 | 201 | ||
202 | EditNetworkSetup EC( this ); | 202 | EditNetworkSetup EC( this ); |
203 | 203 | ||
204 | if( LBI ) { | 204 | if( LBI ) { |
205 | NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() ); | 205 | NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() ); |
206 | if( ! NC ) { | 206 | if( ! NC ) { |
207 | return; | 207 | return; |
208 | } | 208 | } |
209 | OldName = NC->name(); | 209 | OldName = NC->name(); |
210 | EC.setNetworkSetup( NC ); | 210 | EC.setNetworkSetup( NC ); |
211 | } | 211 | } |
212 | 212 | ||
213 | EC.showMaximized(); | 213 | EC.showMaximized(); |
214 | // disable refresh timer | 214 | // disable refresh timer |
215 | UpdateTimer->stop(); | 215 | UpdateTimer->stop(); |
216 | 216 | ||
217 | // we need to retry | 217 | // we need to retry |
218 | while( 1 ) { | 218 | while( 1 ) { |
219 | if( EC.exec() == QDialog::Accepted ) { | 219 | if( EC.exec() == QDialog::Accepted ) { |
220 | // toplevel item -> store | 220 | // toplevel item -> store |
221 | NetworkSetup * NC = EC.networkSetup(); | 221 | NetworkSetup * NC = EC.networkSetup(); |
222 | if( NC->isModified() ) { | 222 | if( NC->isModified() ) { |
223 | if( LBI ) { | 223 | if( LBI ) { |
224 | if( NC->name() != OldName ) { | 224 | if( NC->name() != OldName ) { |
225 | // find if new name is free | 225 | // find if new name is free |
226 | NetworkSetup * LCN = NSResources->findNetworkSetup( | 226 | NetworkSetup * LCN = NSResources->findNetworkSetup( |
227 | NC->name() ); | 227 | NC->name() ); |
228 | if( LCN ) { | 228 | if( LCN ) { |
229 | QMessageBox::warning( | 229 | QMessageBox::warning( |
230 | 0, | 230 | 0, |
231 | tr( "In System Config" ), | 231 | tr( "In System Config" ), |
232 | tr( "Name %1 already exists" ).arg(NC->name()) | 232 | tr( "Name %1 already exists" ).arg(NC->name()) |
233 | ); | 233 | ); |
234 | continue; // restart exec | 234 | continue; // restart exec |
235 | } // else new name | 235 | } // else new name |
236 | // new name -> remove item | 236 | // new name -> remove item |
237 | NSResources->removeNetworkSetup( OldName ); | 237 | NSResources->removeNetworkSetup( OldName ); |
238 | NSResources->addNetworkSetup( NC, 0 ); | 238 | NSResources->addNetworkSetup( NC, 0 ); |
239 | } // else not changed | 239 | } // else not changed |
240 | 240 | ||
241 | // must add it here since change will trigger event | 241 | // must add it here since change will trigger event |
242 | Profiles_LB->changeItem( NC->devicePixmap(), | 242 | Profiles_LB->changeItem( NC->devicePixmap(), |
243 | NC->name(), | 243 | NC->name(), |
244 | Profiles_LB->index( LBI ) | 244 | Profiles_LB->index( LBI ) |
245 | ); | 245 | ); |
246 | } else { | 246 | } else { |
247 | // new item | 247 | // new item |
248 | int ci = Profiles_LB->count(); | 248 | int ci = Profiles_LB->count(); |
249 | NSResources->addNetworkSetup( NC, 0 ); | 249 | NSResources->addNetworkSetup( NC, 0 ); |
250 | NC->setNumber( NSResources->assignNetworkSetupNumber() ); | 250 | NC->setNumber( NSResources->assignNetworkSetupNumber() ); |
251 | Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); | 251 | Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); |
252 | Profiles_LB->setSelected( ci, TRUE ); | 252 | Profiles_LB->setSelected( ci, TRUE ); |
253 | } | 253 | } |
254 | updateProfileState( LBI ); | 254 | SLOT_RefreshStates(); |
255 | } | 255 | } |
256 | } else { | 256 | } else { |
257 | // cancelled : reset NetworkSetup | 257 | // cancelled : reset NetworkSetup |
258 | if( LBI ) { | 258 | if( LBI ) { |
259 | NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() ); | 259 | NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() ); |
260 | NC->reassign(); | 260 | NC->reassign(); |
261 | } | 261 | } |
262 | } | 262 | } |
263 | break; | 263 | break; |
264 | } | 264 | } |
265 | // reenable | 265 | // reenable |
266 | UpdateTimer->start( 5000 ); | 266 | UpdateTimer->start( 5000 ); |
267 | } | 267 | } |
268 | 268 | ||
269 | void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { | 269 | void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { |
270 | if( LBI == 0 ) | 270 | if( LBI == 0 ) |
271 | return; | 271 | return; |
272 | 272 | ||
273 | NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() ); | 273 | NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() ); |
274 | 274 | ||
275 | if( NC->description().isEmpty() ) { | 275 | if( NC->description().isEmpty() ) { |
276 | Description_LBL->setText( tr( "<<No description>>" ) ); | 276 | Description_LBL->setText( tr( "<<No description>>" ) ); |
277 | } else { | 277 | } else { |
278 | Description_LBL->setText( NC->description() ); | 278 | Description_LBL->setText( NC->description() ); |
279 | } | 279 | } |
280 | 280 | ||
281 | Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() ); | 281 | Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() ); |
282 | 282 | ||
283 | bool FrmActive = 1; | 283 | bool FrmActive = 1; |
284 | bool IsEnabled = 1; | 284 | bool IsEnabled = 1; |
285 | int leds = 0; | 285 | int leds = 0; |
286 | 286 | ||
287 | switch( NC->state() ) { | 287 | switch( NC->state() ) { |
288 | case Disabled : // no further work | 288 | case Disabled : // no further work |
289 | IsEnabled = 0; | 289 | IsEnabled = 0; |
290 | FrmActive = 0; | 290 | FrmActive = 0; |
291 | break; | 291 | break; |
292 | case Unknown : | 292 | case Unknown : |
293 | case Unchecked : | 293 | case Unchecked : |
294 | case Unavailable : | 294 | case Unavailable : |
295 | FrmActive = 0; | 295 | FrmActive = 0; |
296 | break; | 296 | break; |
297 | case Off : | 297 | case Off : |
298 | leds = 1; | 298 | leds = 1; |
299 | break; | 299 | break; |
300 | case Available : | 300 | case Available : |
301 | leds = 2; | 301 | leds = 2; |
302 | break; | 302 | break; |
303 | case IsUp : | 303 | case IsUp : |
304 | leds = 3; | 304 | leds = 3; |
305 | break; | 305 | break; |
306 | } | 306 | } |
307 | 307 | ||
308 | Disable_TB->setOn( ! IsEnabled ); | 308 | Disable_TB->setOn( ! IsEnabled ); |
309 | LED_Frm->setEnabled( FrmActive ); | 309 | LED_Frm->setEnabled( FrmActive ); |
310 | 310 | ||
311 | for( int i = 0 ; i < leds; i ++ ) { | 311 | for( int i = 0 ; i < leds; i ++ ) { |
312 | Leds[i]->setColor( red ); | 312 | Leds[i]->setColor( red ); |
313 | Leds[i]->setOn( true ); | 313 | Leds[i]->setOn( true ); |
314 | } | 314 | } |
315 | for( int i = leds ; i < 3; i ++ ) { | 315 | for( int i = leds ; i < 3; i ++ ) { |
316 | Leds[i]->setColor( red ); | 316 | Leds[i]->setColor( red ); |
317 | Leds[i]->setOn( false ); | 317 | Leds[i]->setOn( false ); |
318 | } | 318 | } |
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index 0ab0e5b..1bcd95c 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp | |||
@@ -28,130 +28,131 @@ static char * StateName[] = { | |||
28 | "Available", | 28 | "Available", |
29 | "IsUp" | 29 | "IsUp" |
30 | }; | 30 | }; |
31 | 31 | ||
32 | QString & deQuote( QString & X ) { | 32 | QString & deQuote( QString & X ) { |
33 | if( X[0] == '"' ) { | 33 | if( X[0] == '"' ) { |
34 | // remove end and trailing "" and \x -> x | 34 | // remove end and trailing "" and \x -> x |
35 | QChar R; | 35 | QChar R; |
36 | long idx; | 36 | long idx; |
37 | idx = X.length()-1; | 37 | idx = X.length()-1; |
38 | X = X.mid( 1, idx ); | 38 | X = X.mid( 1, idx ); |
39 | 39 | ||
40 | idx = 0; | 40 | idx = 0; |
41 | while( ( idx = X.find( '\\', idx ) ) >= 0 ) { | 41 | while( ( idx = X.find( '\\', idx ) ) >= 0 ) { |
42 | R = X.at( idx + 1 ); | 42 | R = X.at( idx + 1 ); |
43 | X.replace( idx, 2, &R, 1 ); | 43 | X.replace( idx, 2, &R, 1 ); |
44 | } | 44 | } |
45 | X = X.left( X.length()-1 ); | 45 | X = X.left( X.length()-1 ); |
46 | } | 46 | } |
47 | return X; | 47 | return X; |
48 | } | 48 | } |
49 | 49 | ||
50 | QString quote( QString X ) { | 50 | QString quote( QString X ) { |
51 | if( X.find( QRegExp( "[ \n\"\\\t]" ) ) >= 0 ) { | 51 | if( X.find( QRegExp( "[ \n\"\\\t]" ) ) >= 0 ) { |
52 | // need to quote this | 52 | // need to quote this |
53 | QString OutString = "\""; | 53 | QString OutString = "\""; |
54 | 54 | ||
55 | X.replace( QRegExp("\""), "\\\"" ); | 55 | X.replace( QRegExp("\""), "\\\"" ); |
56 | X.replace( QRegExp("\\"), "\\\\" ); | 56 | X.replace( QRegExp("\\"), "\\\\" ); |
57 | X.replace( QRegExp(" "), "\\ " ); | 57 | X.replace( QRegExp(" "), "\\ " ); |
58 | 58 | ||
59 | OutString += X; | 59 | OutString += X; |
60 | OutString += "\""; | 60 | OutString += "\""; |
61 | X = OutString; | 61 | X = OutString; |
62 | } | 62 | } |
63 | return X; | 63 | return X; |
64 | } | 64 | } |
65 | 65 | ||
66 | 66 | ||
67 | // | 67 | // |
68 | // | 68 | // |
69 | // ANETNODE | 69 | // ANETNODE |
70 | // | 70 | // |
71 | // | 71 | // |
72 | 72 | ||
73 | void ANetNode::saveAttributes( QTextStream & TS ) { | 73 | void ANetNode::saveAttributes( QTextStream & TS ) { |
74 | saveSpecificAttribute( TS ); | 74 | saveSpecificAttribute( TS ); |
75 | } | 75 | } |
76 | 76 | ||
77 | void ANetNode::setAttribute( QString & Attr, QString & Value ){ | 77 | void ANetNode::setAttribute( QString & Attr, QString & Value ){ |
78 | setSpecificAttribute( Attr, Value ); | 78 | setSpecificAttribute( Attr, Value ); |
79 | } | 79 | } |
80 | 80 | ||
81 | bool ANetNode::isToplevel( void ) { | 81 | bool ANetNode::isToplevel( void ) { |
82 | const char ** P = provides(); | 82 | const char ** P = provides(); |
83 | while( *P ) { | 83 | while( *P ) { |
84 | if( strcmp( *P, "fullsetup") == 0 ) | 84 | if( strcmp( *P, "fullsetup") == 0 ) |
85 | return 1; | 85 | return 1; |
86 | P ++; | 86 | P ++; |
87 | } | 87 | } |
88 | return 0; | 88 | return 0; |
89 | } | 89 | } |
90 | 90 | ||
91 | bool ANetNode::openFile( SystemFile & SF, | 91 | bool ANetNode::openFile( SystemFile & SF, |
92 | ANetNodeInstance * NNI ) { | 92 | ANetNodeInstance * NNI, |
93 | return (NNI ) ? NNI->openFile( SF ) : 0 ; | 93 | QStringList & SL ) { |
94 | return (NNI ) ? NNI->openFile( SF, SL ) : 0 ; | ||
94 | } | 95 | } |
95 | 96 | ||
96 | // | 97 | // |
97 | // | 98 | // |
98 | // ANETNODEINSTANCE | 99 | // ANETNODEINSTANCE |
99 | // | 100 | // |
100 | // | 101 | // |
101 | 102 | ||
102 | long ANetNodeInstance::InstanceCounter = -1; | 103 | long ANetNodeInstance::InstanceCounter = -1; |
103 | 104 | ||
104 | void ANetNodeInstance::initialize( void ) { | 105 | void ANetNodeInstance::initialize( void ) { |
105 | if( InstanceCounter == -1 ) | 106 | if( InstanceCounter == -1 ) |
106 | InstanceCounter = time(0); | 107 | InstanceCounter = time(0); |
107 | // set name | 108 | // set name |
108 | QString N; | 109 | QString N; |
109 | N.sprintf( "-%ld", InstanceCounter++ ); | 110 | N.sprintf( "-%ld", InstanceCounter++ ); |
110 | N.prepend( NodeType->name() ); | 111 | N.prepend( NodeType->name() ); |
111 | setName( N.latin1() ); | 112 | setName( N.latin1() ); |
112 | } | 113 | } |
113 | 114 | ||
114 | void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ | 115 | void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ |
115 | if( Attr == "__name" ) { | 116 | if( Attr == "__name" ) { |
116 | setName( Value.latin1() ); | 117 | setName( Value.latin1() ); |
117 | } else { | 118 | } else { |
118 | setSpecificAttribute( Attr, Value ); | 119 | setSpecificAttribute( Attr, Value ); |
119 | } | 120 | } |
120 | } | 121 | } |
121 | 122 | ||
122 | void ANetNodeInstance::saveAttributes( QTextStream & TS ) { | 123 | void ANetNodeInstance::saveAttributes( QTextStream & TS ) { |
123 | TS << "__name=" << name() << endl; | 124 | TS << "__name=" << name() << endl; |
124 | saveSpecificAttribute( TS ); | 125 | saveSpecificAttribute( TS ); |
125 | } | 126 | } |
126 | 127 | ||
127 | ANetNodeInstance * ANetNodeInstance::nextNode( void ) { | 128 | ANetNodeInstance * ANetNodeInstance::nextNode( void ) { |
128 | return networkSetup()->findNext( this ); | 129 | return networkSetup()->findNext( this ); |
129 | } | 130 | } |
130 | 131 | ||
131 | // | 132 | // |
132 | // | 133 | // |
133 | // NODECOLLECTION | 134 | // NODECOLLECTION |
134 | // | 135 | // |
135 | // | 136 | // |
136 | 137 | ||
137 | NetworkSetup::NetworkSetup( void ) : QList<ANetNodeInstance>() { | 138 | NetworkSetup::NetworkSetup( void ) : QList<ANetNodeInstance>() { |
138 | IsModified = 0; | 139 | IsModified = 0; |
139 | Index = -1; | 140 | Index = -1; |
140 | Name=""; | 141 | Name=""; |
141 | IsNew = 1; | 142 | IsNew = 1; |
142 | CurrentState = Unchecked; | 143 | CurrentState = Unchecked; |
143 | AssignedInterface = 0; | 144 | AssignedInterface = 0; |
144 | Number = -1; | 145 | Number = -1; |
145 | Done = 0; | 146 | Done = 0; |
146 | } | 147 | } |
147 | 148 | ||
148 | NetworkSetup::NetworkSetup( QTextStream & TS, bool & Dangling ) : | 149 | NetworkSetup::NetworkSetup( QTextStream & TS, bool & Dangling ) : |
149 | QList<ANetNodeInstance>() { | 150 | QList<ANetNodeInstance>() { |
150 | long idx; | 151 | long idx; |
151 | QString S, A, N; | 152 | QString S, A, N; |
152 | 153 | ||
153 | Number = -1; | 154 | Number = -1; |
154 | Done = 0; | 155 | Done = 0; |
155 | IsModified = 0; | 156 | IsModified = 0; |
156 | Index = -1; | 157 | Index = -1; |
157 | Name=""; | 158 | Name=""; |
@@ -345,133 +346,135 @@ const QStringList & NetworkSetup::triggers() { | |||
345 | return getToplevel()->runtime()->triggers(); | 346 | return getToplevel()->runtime()->triggers(); |
346 | } | 347 | } |
347 | 348 | ||
348 | bool NetworkSetup::hasDataForFile( SystemFile & S ) { | 349 | bool NetworkSetup::hasDataForFile( SystemFile & S ) { |
349 | return ( firstWithDataForFile( S ) != 0 ); | 350 | return ( firstWithDataForFile( S ) != 0 ); |
350 | } | 351 | } |
351 | 352 | ||
352 | ANetNodeInstance * NetworkSetup::firstWithDataForFile( SystemFile & S ) { | 353 | ANetNodeInstance * NetworkSetup::firstWithDataForFile( SystemFile & S ) { |
353 | for( QListIterator<ANetNodeInstance> it(*this); | 354 | for( QListIterator<ANetNodeInstance> it(*this); |
354 | it.current(); | 355 | it.current(); |
355 | ++it ) { | 356 | ++it ) { |
356 | if( it.current()->hasDataForFile( S ) ) { | 357 | if( it.current()->hasDataForFile( S ) ) { |
357 | return it.current(); | 358 | return it.current(); |
358 | } | 359 | } |
359 | } | 360 | } |
360 | return 0; | 361 | return 0; |
361 | } | 362 | } |
362 | 363 | ||
363 | State_t NetworkSetup::state( bool Update ) { | 364 | State_t NetworkSetup::state( bool Update ) { |
364 | State_t NodeState; | 365 | State_t NodeState; |
365 | 366 | ||
366 | if( CurrentState == Unchecked || Update ) { | 367 | if( CurrentState == Unchecked || Update ) { |
367 | // collect states of all nodes until with get the 'higest' | 368 | // collect states of all nodes until with get the 'higest' |
368 | // state possible | 369 | // state possible |
369 | 370 | ||
370 | Log(( "NetworkSetup %s state %s\n", | 371 | Log(( "NetworkSetup %s state %s\n", |
371 | Name.latin1(), StateName[CurrentState] )); | 372 | Name.latin1(), StateName[CurrentState] )); |
372 | 373 | ||
373 | CurrentState = Unknown; | 374 | CurrentState = Unknown; |
374 | for( QListIterator<ANetNodeInstance> it(*this); | 375 | for( QListIterator<ANetNodeInstance> it(*this); |
375 | it.current(); | 376 | it.current(); |
376 | ++it ) { | 377 | ++it ) { |
377 | Log(( "-> Detect %s\n", it.current()->name() )); | 378 | Log(( "-> Detect %s\n", it.current()->name() )); |
378 | NodeState = it.current()->runtime()->detectState(); | 379 | NodeState = it.current()->runtime()->detectState(); |
379 | Log(( " state %s\n", StateName[NodeState] )); | 380 | Log(( " state %s\n", StateName[NodeState] )); |
380 | 381 | ||
381 | if( NodeState == Disabled || | 382 | if( NodeState == Disabled || |
382 | NodeState == IsUp ) { | 383 | NodeState == IsUp ) { |
383 | // max | 384 | // max |
384 | CurrentState = NodeState; | 385 | CurrentState = NodeState; |
385 | break; | 386 | break; |
386 | } | 387 | } |
387 | 388 | ||
388 | if( NodeState > CurrentState ) { | 389 | if( NodeState > CurrentState ) { |
389 | // higher | 390 | // higher |
390 | CurrentState = NodeState; | 391 | CurrentState = NodeState; |
391 | } | 392 | } |
392 | } | 393 | } |
393 | } | 394 | } |
394 | 395 | ||
395 | return CurrentState; | 396 | return CurrentState; |
396 | } | 397 | } |
397 | 398 | ||
398 | QString NetworkSetup::setState( Action_t A, bool Force ) { | 399 | QString NetworkSetup::setState( Action_t A, bool Force ) { |
399 | 400 | ||
400 | QString msg; | 401 | QString msg; |
401 | Action_t Actions[10]; | 402 | Action_t Actions[10]; |
402 | int NoOfActions = 0; | 403 | int NoOfActions = 0; |
403 | 404 | ||
404 | // get current state | 405 | // get current state |
405 | state( Force ); | 406 | state( Force ); |
406 | 407 | ||
407 | switch( A ) { | 408 | switch( A ) { |
408 | case Disable : | 409 | case Disable : |
410 | /* | ||
409 | if( CurrentState < Disabled ) { | 411 | if( CurrentState < Disabled ) { |
410 | // disabled | 412 | // disabled |
411 | CurrentState = Disabled; | 413 | CurrentState = Disabled; |
412 | return QString(); | 414 | return QString(); |
413 | } | 415 | } |
416 | */ | ||
414 | 417 | ||
415 | if( CurrentState == IsUp ) { | 418 | if( CurrentState == IsUp ) { |
416 | Actions[NoOfActions++] = Down; | 419 | Actions[NoOfActions++] = Down; |
417 | Actions[NoOfActions++] = Deactivate; | 420 | Actions[NoOfActions++] = Deactivate; |
418 | } else if( CurrentState == Available ) { | 421 | } else if( CurrentState == Available ) { |
419 | Actions[NoOfActions++] = Deactivate; | 422 | Actions[NoOfActions++] = Deactivate; |
420 | } | 423 | } |
421 | Actions[NoOfActions++] = Disable; | 424 | Actions[NoOfActions++] = Disable; |
422 | break; | 425 | break; |
423 | case Enable : | 426 | case Enable : |
424 | // always possible -> detected state is new state | 427 | // always possible -> detected state is new state |
425 | Actions[NoOfActions++] = Enable; | 428 | Actions[NoOfActions++] = Enable; |
426 | break; | 429 | break; |
427 | case Activate : | 430 | case Activate : |
428 | if( ! Force ) { | 431 | if( ! Force ) { |
429 | if( CurrentState >= Available ) { | 432 | if( CurrentState >= Available ) { |
430 | // already available | 433 | // already available |
431 | return QString(); | 434 | return QString(); |
432 | } | 435 | } |
433 | 436 | ||
434 | if( CurrentState != Off ) { | 437 | if( CurrentState != Off ) { |
435 | return qApp->translate( "System", | 438 | return qApp->translate( "System", |
436 | "State should be off" ); | 439 | "State should be off" ); |
437 | } | 440 | } |
438 | } | 441 | } |
439 | 442 | ||
440 | Actions[NoOfActions++] = Activate; | 443 | Actions[NoOfActions++] = Activate; |
441 | break; | 444 | break; |
442 | case Deactivate : | 445 | case Deactivate : |
443 | if( ! Force ) { | 446 | if( ! Force ) { |
444 | if( CurrentState < Off ) { | 447 | if( CurrentState < Off ) { |
445 | // already inactive | 448 | // already inactive |
446 | return QString(); | 449 | return QString(); |
447 | } | 450 | } |
448 | } | 451 | } |
449 | 452 | ||
450 | if( CurrentState == IsUp ) { | 453 | if( CurrentState == IsUp ) { |
451 | Actions[NoOfActions++] = Down; | 454 | Actions[NoOfActions++] = Down; |
452 | } | 455 | } |
453 | Actions[NoOfActions++] = Deactivate; | 456 | Actions[NoOfActions++] = Deactivate; |
454 | break; | 457 | break; |
455 | case Up : | 458 | case Up : |
456 | if( ! Force ) { | 459 | if( ! Force ) { |
457 | if( CurrentState == IsUp ) { | 460 | if( CurrentState == IsUp ) { |
458 | return QString(); | 461 | return QString(); |
459 | } | 462 | } |
460 | if( CurrentState < Off ) { | 463 | if( CurrentState < Off ) { |
461 | return qApp->translate( "System", | 464 | return qApp->translate( "System", |
462 | "State should at least be off" ); | 465 | "State should at least be off" ); |
463 | } | 466 | } |
464 | } | 467 | } |
465 | if( CurrentState == Off ) { | 468 | if( CurrentState == Off ) { |
466 | Actions[NoOfActions++] = Activate; | 469 | Actions[NoOfActions++] = Activate; |
467 | } | 470 | } |
468 | Actions[NoOfActions++] = Up; | 471 | Actions[NoOfActions++] = Up; |
469 | break; | 472 | break; |
470 | case Down : | 473 | case Down : |
471 | if( ! Force ) { | 474 | if( ! Force ) { |
472 | if( CurrentState < Available ) { | 475 | if( CurrentState < Available ) { |
473 | // OK | 476 | // OK |
474 | return QString(); | 477 | return QString(); |
475 | } | 478 | } |
476 | } | 479 | } |
477 | Actions[NoOfActions++] = Down; | 480 | Actions[NoOfActions++] = Down; |
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h index 8aebdc0..fa4ab70 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.h +++ b/noncore/settings/networksettings2/networksettings2/netnode.h | |||
@@ -60,132 +60,137 @@ typedef enum Action { | |||
60 | // to make the device unavailable functionally -> to disabled | 60 | // to make the device unavailable functionally -> to disabled |
61 | Disable = 0, | 61 | Disable = 0, |
62 | // to make the device available functionally -> to off | 62 | // to make the device available functionally -> to off |
63 | Enable = 1, | 63 | Enable = 1, |
64 | // bring the hardware up -> to Available | 64 | // bring the hardware up -> to Available |
65 | Activate = 2, | 65 | Activate = 2, |
66 | // bring the hardware down -> to off | 66 | // bring the hardware down -> to off |
67 | Deactivate = 3, | 67 | Deactivate = 3, |
68 | // bring the networkSetup up -> to IsUp | 68 | // bring the networkSetup up -> to IsUp |
69 | Up = 4, | 69 | Up = 4, |
70 | // bring the networkSetup down -> to Available | 70 | // bring the networkSetup down -> to Available |
71 | Down = 5 | 71 | Down = 5 |
72 | } Action_t; | 72 | } Action_t; |
73 | 73 | ||
74 | class ANetNode : public QObject { | 74 | class ANetNode : public QObject { |
75 | 75 | ||
76 | public: | 76 | public: |
77 | 77 | ||
78 | typedef QArray<ANetNode *> NetNodeList; | 78 | typedef QArray<ANetNode *> NetNodeList; |
79 | 79 | ||
80 | ANetNode( const char * Name ) : QObject( 0, Name ) {} | 80 | ANetNode( const char * Name ) : QObject( 0, Name ) {} |
81 | virtual ~ANetNode(){}; | 81 | virtual ~ANetNode(){}; |
82 | 82 | ||
83 | // | 83 | // |
84 | // | 84 | // |
85 | // standard methods with sensible default | 85 | // standard methods with sensible default |
86 | // | 86 | // |
87 | // | 87 | // |
88 | 88 | ||
89 | inline int done( void ) | 89 | inline int done( void ) |
90 | { return Done; } | 90 | { return Done; } |
91 | inline void setDone( int D ) | 91 | inline void setDone( int D ) |
92 | { Done = D; } | 92 | { Done = D; } |
93 | 93 | ||
94 | // does this Node provide a NetworkSetup | 94 | // does this Node provide a NetworkSetup |
95 | bool isToplevel( void ); | 95 | bool isToplevel( void ); |
96 | 96 | ||
97 | // set the value of an attribute | 97 | // set the value of an attribute |
98 | void setAttribute( QString & Attr, QString & Value ) ; | 98 | void setAttribute( QString & Attr, QString & Value ) ; |
99 | void saveAttributes( QTextStream & TS ) ; | 99 | void saveAttributes( QTextStream & TS ) ; |
100 | 100 | ||
101 | // compiled references to 'needed' NetNodes -> needs list | 101 | // compiled references to 'needed' NetNodes -> needs list |
102 | inline void setAlternatives( NetNodeList * Alt ) | 102 | inline void setAlternatives( NetNodeList * Alt ) |
103 | { Alternatives = Alt; } | 103 | { Alternatives = Alt; } |
104 | inline NetNodeList & alternatives( void ) | 104 | inline NetNodeList & alternatives( void ) |
105 | { return *Alternatives; } | 105 | { return *Alternatives; } |
106 | 106 | ||
107 | // | 107 | // |
108 | // | 108 | // |
109 | // Virtual methods with sensible default | 109 | // Virtual methods with sensible default |
110 | // | 110 | // |
111 | // | 111 | // |
112 | 112 | ||
113 | // do instances of this noce class have data for this file | 113 | // do instances of this noce class have data for this file |
114 | virtual bool hasDataForFile( SystemFile & ) | 114 | virtual bool hasDataForFile( SystemFile & ) |
115 | { return 0; } | 115 | { return 0; } |
116 | 116 | ||
117 | // open proper file SF identified by S | 117 | // open proper file SF identified by S |
118 | // this method is called by NS2. | 118 | // this method is called by NS2. |
119 | // | 119 | // |
120 | // overrule this ONLY if this proper file is a common file | 120 | // overrule this ONLY if this proper file is a common file |
121 | // for all NNI of this node class and the data generated | 121 | // for all NNI of this node class and the data generated |
122 | // by each of the NNI needs to be put in one file | 122 | // by each of the NNI needs to be put in one file |
123 | // | 123 | // |
124 | // the function can return a set of folders that should | ||
125 | // be created (or perhaps already exist) prior to opening | ||
126 | // the file | ||
127 | // | ||
124 | // if this is the case the file should be (re)opened in append | 128 | // if this is the case the file should be (re)opened in append |
125 | // return 0 if file cannot be opened | 129 | // return 0 if file cannot be opened |
126 | virtual bool openFile( SystemFile &SF, | 130 | virtual bool openFile( SystemFile &SF, |
127 | ANetNodeInstance * NNI ); | 131 | ANetNodeInstance * NNI, |
132 | QStringList & PathToCreate ); | ||
128 | 133 | ||
129 | // generate instance independent stuff | 134 | // generate instance independent stuff |
130 | // 0 : data output, 1 no data, 2 error | 135 | // 0 : data output, 1 no data, 2 error |
131 | virtual short generatePreamble( SystemFile & ) | 136 | virtual short generatePreamble( SystemFile & ) |
132 | { return 1; } | 137 | { return 1; } |
133 | 138 | ||
134 | // generate instance independent stuff | 139 | // generate instance independent stuff |
135 | // 0 : data output, 1 no data, 2 error | 140 | // 0 : data output, 1 no data, 2 error |
136 | virtual short generatePostamble( SystemFile & ) | 141 | virtual short generatePostamble( SystemFile & ) |
137 | { return 1; } | 142 | { return 1; } |
138 | 143 | ||
139 | // generate instance dependent but instance common stuff | 144 | // generate instance dependent but instance common stuff |
140 | // 0 : data output, 1 no data, 2 error | 145 | // 0 : data output, 1 no data, 2 error |
141 | virtual short generateFile( SystemFile &, | 146 | virtual short generateFile( SystemFile &, |
142 | ANetNodeInstance * , | 147 | ANetNodeInstance * , |
143 | long ) | 148 | long ) |
144 | { return 1; } | 149 | { return 1; } |
145 | 150 | ||
146 | // generate NIC name based on instance nr | 151 | // generate NIC name based on instance nr |
147 | // only relevant if node instances are devices | 152 | // only relevant if node instances are devices |
148 | virtual QString genNic( long ) | 153 | virtual QString genNic( long ) |
149 | { return QString(""); } | 154 | { return QString(""); } |
150 | 155 | ||
151 | // max number of instances for this node type | 156 | // max number of instances for this node type |
152 | // only relevant if node instances are devices | 157 | // only relevant if node instances are devices |
153 | virtual long instanceCount( void ) | 158 | virtual long instanceCount( void ) |
154 | { return 1; } | 159 | { return 1; } |
155 | 160 | ||
156 | // return ID list for each file generated specially for | 161 | // return ID list for each file generated specially for |
157 | // this node type | 162 | // this node type |
158 | virtual QStringList properFiles( void ) | 163 | virtual QStringList properFiles( void ) |
159 | { return QStringList(); } | 164 | { return QStringList(); } |
160 | 165 | ||
161 | // | 166 | // |
162 | // | 167 | // |
163 | // pure virtual methods with sensible default | 168 | // pure virtual methods with sensible default |
164 | // | 169 | // |
165 | // | 170 | // |
166 | 171 | ||
167 | // pixmap needed for this NetNode | 172 | // pixmap needed for this NetNode |
168 | virtual const QString pixmapName() = 0; | 173 | virtual const QString pixmapName() = 0; |
169 | 174 | ||
170 | // description for this NetNode | 175 | // description for this NetNode |
171 | virtual const QString nodeDescription() = 0; | 176 | virtual const QString nodeDescription() = 0; |
172 | 177 | ||
173 | // create a blank instance of a net node | 178 | // create a blank instance of a net node |
174 | virtual ANetNodeInstance * createInstance( void ) = 0; | 179 | virtual ANetNodeInstance * createInstance( void ) = 0; |
175 | 180 | ||
176 | // return features this NetNode provides | 181 | // return features this NetNode provides |
177 | virtual const char ** provides( void ) = 0; | 182 | virtual const char ** provides( void ) = 0; |
178 | 183 | ||
179 | // return features this NetNode needs | 184 | // return features this NetNode needs |
180 | virtual const char ** needs( void ) = 0; | 185 | virtual const char ** needs( void ) = 0; |
181 | 186 | ||
182 | protected : | 187 | protected : |
183 | 188 | ||
184 | NetNodeList * Alternatives; | 189 | NetNodeList * Alternatives; |
185 | 190 | ||
186 | private : | 191 | private : |
187 | 192 | ||
188 | virtual void setSpecificAttribute( QString & , QString & ) = 0; | 193 | virtual void setSpecificAttribute( QString & , QString & ) = 0; |
189 | virtual void saveSpecificAttribute( QTextStream & ) = 0; | 194 | virtual void saveSpecificAttribute( QTextStream & ) = 0; |
190 | int Done; | 195 | int Done; |
191 | 196 | ||
@@ -198,129 +203,130 @@ public: | |||
198 | ANetNodeInstance( ANetNode * NN ) : QObject() | 203 | ANetNodeInstance( ANetNode * NN ) : QObject() |
199 | { IsModified=0; NodeType = NN; IsNew = TRUE; } | 204 | { IsModified=0; NodeType = NN; IsNew = TRUE; } |
200 | virtual ~ANetNodeInstance( void ) { } | 205 | virtual ~ANetNodeInstance( void ) { } |
201 | 206 | ||
202 | inline int done( void ) | 207 | inline int done( void ) |
203 | { return Done; } | 208 | { return Done; } |
204 | inline void setDone( int D ) | 209 | inline void setDone( int D ) |
205 | { Done = D; } | 210 | { Done = D; } |
206 | 211 | ||
207 | // return data was modified | 212 | // return data was modified |
208 | inline void setModified( bool M ) | 213 | inline void setModified( bool M ) |
209 | { IsModified = M; } | 214 | { IsModified = M; } |
210 | inline bool isModified( void ) | 215 | inline bool isModified( void ) |
211 | { return IsModified; } | 216 | { return IsModified; } |
212 | 217 | ||
213 | // get next node | 218 | // get next node |
214 | ANetNodeInstance * nextNode(); | 219 | ANetNodeInstance * nextNode(); |
215 | // return NetNode this is an instance of | 220 | // return NetNode this is an instance of |
216 | ANetNode * nodeClass( void ) | 221 | ANetNode * nodeClass( void ) |
217 | { return NodeType; } | 222 | { return NodeType; } |
218 | 223 | ||
219 | // intialize am instance of a net node | 224 | // intialize am instance of a net node |
220 | void initialize( void ); | 225 | void initialize( void ); |
221 | 226 | ||
222 | // set the value of an attribute | 227 | // set the value of an attribute |
223 | void setAttribute( QString & Attr, QString & Value ) ; | 228 | void setAttribute( QString & Attr, QString & Value ) ; |
224 | void saveAttributes( QTextStream & TS ) ; | 229 | void saveAttributes( QTextStream & TS ) ; |
225 | 230 | ||
226 | // return true if node isntance is NEW and not loaded | 231 | // return true if node isntance is NEW and not loaded |
227 | inline void setNew( bool IsN ) | 232 | inline void setNew( bool IsN ) |
228 | { IsNew = IsN; } | 233 | { IsNew = IsN; } |
229 | inline bool isNew( void ) | 234 | inline bool isNew( void ) |
230 | { return IsNew; } | 235 | { return IsNew; } |
231 | 236 | ||
232 | // return description for this instance | 237 | // return description for this instance |
233 | inline QString & description( void ) | 238 | inline QString & description( void ) |
234 | { return Description; } | 239 | { return Description; } |
235 | inline void setDescription( const QString & S ) | 240 | inline void setDescription( const QString & S ) |
236 | { Description = S; } | 241 | { Description = S; } |
237 | 242 | ||
238 | // pixmap for this instance -> from NetNode | 243 | // pixmap for this instance -> from NetNode |
239 | inline const QString pixmapName( void ) | 244 | inline const QString pixmapName( void ) |
240 | { return NodeType->pixmapName(); } | 245 | { return NodeType->pixmapName(); } |
241 | 246 | ||
242 | inline const char ** provides( void ) | 247 | inline const char ** provides( void ) |
243 | { return NodeType->provides(); } | 248 | { return NodeType->provides(); } |
244 | 249 | ||
245 | inline const char ** needs( void ) | 250 | inline const char ** needs( void ) |
246 | { return NodeType->needs(); } | 251 | { return NodeType->needs(); } |
247 | 252 | ||
248 | inline void setNetworkSetup( NetworkSetup * NC ) | 253 | inline void setNetworkSetup( NetworkSetup * NC ) |
249 | { TheNetworkSetup = NC; } | 254 | { TheNetworkSetup = NC; } |
250 | inline NetworkSetup * networkSetup( void ) | 255 | inline NetworkSetup * networkSetup( void ) |
251 | { return TheNetworkSetup; } | 256 | { return TheNetworkSetup; } |
252 | 257 | ||
253 | // | 258 | // |
254 | // | 259 | // |
255 | // Virtual methods with sensible defaults | 260 | // Virtual methods with sensible defaults |
256 | // | 261 | // |
257 | // | 262 | // |
258 | 263 | ||
259 | 264 | ||
260 | 265 | ||
261 | // open proper file identified by S | 266 | // open proper file identified by S |
262 | virtual bool openFile( SystemFile & ) | 267 | virtual bool openFile( SystemFile &, |
268 | QStringList & ) | ||
263 | { return 0; } | 269 | { return 0; } |
264 | 270 | ||
265 | // check if this node (or sub nodes) have data for this file | 271 | // check if this node (or sub nodes) have data for this file |
266 | virtual bool hasDataForFile( SystemFile & S ) | 272 | virtual bool hasDataForFile( SystemFile & S ) |
267 | { return nodeClass()->hasDataForFile( S ); } | 273 | { return nodeClass()->hasDataForFile( S ); } |
268 | 274 | ||
269 | // generate code specific for this node but embedded | 275 | // generate code specific for this node but embedded |
270 | // in the section of the parent | 276 | // in the section of the parent |
271 | // this is called within the code of the parent | 277 | // this is called within the code of the parent |
272 | virtual short generateFileEmbedded( SystemFile & SF, | 278 | virtual short generateFileEmbedded( SystemFile & SF, |
273 | long DevNr ) | 279 | long DevNr ) |
274 | { ANetNodeInstance * NNI = nextNode(); | 280 | { ANetNodeInstance * NNI = nextNode(); |
275 | return (NNI) ? NNI->generateFileEmbedded( SF, DevNr ) : 1; | 281 | return (NNI) ? NNI->generateFileEmbedded( SF, DevNr ) : 1; |
276 | } | 282 | } |
277 | 283 | ||
278 | // generate code specific for this node | 284 | // generate code specific for this node |
279 | // (or find the first node that does) | 285 | // (or find the first node that does) |
280 | virtual short generateFile( SystemFile & SF, | 286 | virtual short generateFile( SystemFile & SF, |
281 | long DevNr ) | 287 | long DevNr ) |
282 | { ANetNodeInstance * NNI = nextNode(); | 288 | { ANetNodeInstance * NNI = nextNode(); |
283 | return (NNI) ? NNI->generateFile( SF, DevNr ) : 1; | 289 | return (NNI) ? NNI->generateFile( SF, DevNr ) : 1; |
284 | } | 290 | } |
285 | 291 | ||
286 | // return true if this node instance is triggered by this trigger | 292 | // return true if this node instance is triggered by this trigger |
287 | // could be delegated to deeper instances | 293 | // could be delegated to deeper instances |
288 | virtual bool triggeredBy( const QString & ) | 294 | virtual bool triggeredBy( const QString & ) |
289 | { return 0; } | 295 | { return 0; } |
290 | 296 | ||
291 | // | 297 | // |
292 | // | 298 | // |
293 | // Pure virtual functions | 299 | // Pure virtual functions |
294 | // | 300 | // |
295 | // | 301 | // |
296 | 302 | ||
297 | // return runtime information for this node | 303 | // return runtime information for this node |
298 | virtual RuntimeInfo * runtime( void ) = 0; | 304 | virtual RuntimeInfo * runtime( void ) = 0; |
299 | 305 | ||
300 | // create edit widget under parent | 306 | // create edit widget under parent |
301 | virtual QWidget * edit( QWidget * parent ) = 0; | 307 | virtual QWidget * edit( QWidget * parent ) = 0; |
302 | 308 | ||
303 | // is given data acceptable | 309 | // is given data acceptable |
304 | virtual QString acceptable( void ) = 0; | 310 | virtual QString acceptable( void ) = 0; |
305 | 311 | ||
306 | // get data from GUI and store in node | 312 | // get data from GUI and store in node |
307 | virtual void commit( void ) = 0; | 313 | virtual void commit( void ) = 0; |
308 | 314 | ||
309 | // returns node specific data -> only useful for 'buddy' | 315 | // returns node specific data -> only useful for 'buddy' |
310 | virtual void * data( void ) = 0; | 316 | virtual void * data( void ) = 0; |
311 | 317 | ||
312 | protected : | 318 | protected : |
313 | 319 | ||
314 | virtual void setSpecificAttribute( QString & , QString & ) = 0; | 320 | virtual void setSpecificAttribute( QString & , QString & ) = 0; |
315 | virtual void saveSpecificAttribute( QTextStream & ) = 0; | 321 | virtual void saveSpecificAttribute( QTextStream & ) = 0; |
316 | 322 | ||
317 | ANetNode * NodeType; | 323 | ANetNode * NodeType; |
318 | // networkSetup to which this node belongs to | 324 | // networkSetup to which this node belongs to |
319 | NetworkSetup * TheNetworkSetup; | 325 | NetworkSetup * TheNetworkSetup; |
320 | QString Description; | 326 | QString Description; |
321 | bool IsModified; | 327 | bool IsModified; |
322 | // true if this nodeinstance was just created (and not | 328 | // true if this nodeinstance was just created (and not |
323 | // loaded from file | 329 | // loaded from file |
324 | bool IsNew; | 330 | bool IsNew; |
325 | int Done; | 331 | int Done; |
326 | 332 | ||
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index 835c7c3..6b87399 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp | |||
@@ -275,180 +275,202 @@ QString NetworkSettingsData::saveSettings( void ) { | |||
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | QDir D("."); | 278 | QDir D("."); |
279 | D.rename( CfgFile + ".bup", CfgFile ); | 279 | D.rename( CfgFile + ".bup", CfgFile ); |
280 | 280 | ||
281 | // | 281 | // |
282 | // proper files AND system files regenerated | 282 | // proper files AND system files regenerated |
283 | // | 283 | // |
284 | 284 | ||
285 | 285 | ||
286 | for( QDictIterator<NetworkSetup> it(NSResources->networkSetups()); | 286 | for( QDictIterator<NetworkSetup> it(NSResources->networkSetups()); |
287 | it.current(); | 287 | it.current(); |
288 | ++it ) { | 288 | ++it ) { |
289 | it.current()->setModified( 0 ); | 289 | it.current()->setModified( 0 ); |
290 | } | 290 | } |
291 | 291 | ||
292 | return ErrS; | 292 | return ErrS; |
293 | } | 293 | } |
294 | 294 | ||
295 | QString NetworkSettingsData::generateSettings( void ) { | 295 | QString NetworkSettingsData::generateSettings( void ) { |
296 | QString S = ""; | 296 | QString S = ""; |
297 | Name2SystemFile_t & SFM = NSResources->systemFiles(); | 297 | Name2SystemFile_t & SFM = NSResources->systemFiles(); |
298 | Name2NetworkSetup_t & M = NSResources->networkSetups(); | 298 | Name2NetworkSetup_t & M = NSResources->networkSetups(); |
299 | NetworkSetup * NC; | 299 | NetworkSetup * NC; |
300 | ANetNodeInstance * NNI; | 300 | ANetNodeInstance * NNI; |
301 | ANetNodeInstance * FirstWithData; | 301 | ANetNodeInstance * FirstWithData; |
302 | RuntimeInfo * CurDev; | 302 | RuntimeInfo * CurDev; |
303 | ANetNode * NN, * CurDevNN = 0; | 303 | ANetNode * NN, * CurDevNN = 0; |
304 | long NoOfDevs; | 304 | long NoOfDevs; |
305 | long DevCtStart; | 305 | long DevCtStart; |
306 | bool needToGenerate; | 306 | bool needToGenerate; |
307 | 307 | ||
308 | // regenerate system files | 308 | // regenerate system files |
309 | Log( ( "Generating settings from %s\n", CfgFile.latin1() )); | 309 | Log( ( "Generating settings from %s\n", CfgFile.latin1() )); |
310 | 310 | ||
311 | for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); | 311 | for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); |
312 | nnit.current(); | 312 | nnit.current(); |
313 | ++nnit ) { | 313 | ++nnit ) { |
314 | bool FirstItem = 1; | 314 | bool FirstItem = 1; |
315 | bool Generated = 0; | 315 | bool Generated = 0; |
316 | 316 | ||
317 | CurDevNN = nnit.current(); | 317 | CurDevNN = nnit.current(); |
318 | 318 | ||
319 | { QStringList SL; | 319 | { QStringList SL; |
320 | SL = CurDevNN->properFiles(); | 320 | SL = CurDevNN->properFiles(); |
321 | 321 | ||
322 | for ( QStringList::Iterator it = SL.begin(); | 322 | for ( QStringList::Iterator it = SL.begin(); |
323 | it != SL.end(); | 323 | it != SL.end(); |
324 | ++it ) { | 324 | ++it ) { |
325 | 325 | ||
326 | Generated = 0; | 326 | Generated = 0; |
327 | FirstItem = 1; | 327 | FirstItem = 1; |
328 | // iterate over NNI's of this class | 328 | // iterate over NNI's of this class |
329 | for( QDictIterator<ANetNodeInstance> nniit( | 329 | for( QDictIterator<ANetNodeInstance> nniit( |
330 | NSResources->netNodeInstances() ); | 330 | NSResources->netNodeInstances() ); |
331 | nniit.current(); | 331 | nniit.current(); |
332 | ++nniit ) { | 332 | ++nniit ) { |
333 | if( nniit.current()->nodeClass() != CurDevNN ) | 333 | if( nniit.current()->nodeClass() != CurDevNN ) |
334 | // different class | 334 | // different class |
335 | continue; | 335 | continue; |
336 | 336 | ||
337 | // open proper file | 337 | // open proper file |
338 | { SystemFile SF( (*it) ); | 338 | { SystemFile SF( (*it) ); |
339 | QStringList SL; | ||
339 | 340 | ||
340 | if( ! CurDevNN->openFile( SF, nniit.current()) ) { | 341 | if( ! CurDevNN->openFile( SF, nniit.current(), SL) ) { |
341 | // cannot open | 342 | // cannot open |
342 | S = qApp->translate( "NetworkSettings", | 343 | S = qApp->translate( "NetworkSettings", |
343 | "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). | 344 | "<p>Cannot build proper file \"%1\" for node \"%2\"</p>" ). |
344 | arg( (*it) ).arg( CurDevNN->name() ); | 345 | arg( (*it) ). |
346 | arg( CurDevNN->name() ); | ||
347 | return S; | ||
348 | } | ||
349 | |||
350 | if( ! createPath( SL ) ) { | ||
351 | S = qApp->translate( "NetworkSettings", | ||
352 | "<p>Cannot create path \"%1\" for proper file \"%2\" for node \"%3\"</p>" ). | ||
353 | arg( SL.join("/") ). | ||
354 | arg( (*it) ). | ||
355 | arg( CurDevNN->name() ); | ||
345 | return S; | 356 | return S; |
346 | } | 357 | } |
347 | 358 | ||
348 | if( ! SF.open() ) { | 359 | if( ! SF.open() ) { |
349 | S = qApp->translate( "NetworkSettings", | 360 | S = qApp->translate( "NetworkSettings", |
350 | "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). | 361 | "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). |
351 | arg( (*it) ).arg( CurDevNN->name() ); | 362 | arg( (*it) ).arg( CurDevNN->name() ); |
352 | return S; | 363 | return S; |
353 | } | 364 | } |
354 | 365 | ||
355 | // preamble on first | 366 | // preamble on first |
356 | if( FirstItem ) { | 367 | if( FirstItem ) { |
357 | if( CurDevNN->generatePreamble( SF ) == 2 ) { | 368 | if( CurDevNN->generatePreamble( SF ) == 2 ) { |
358 | S = qApp->translate( "NetworkSettings", | 369 | S = qApp->translate( "NetworkSettings", |
359 | "<p>Error in section \"preamble\" for proper file \"%1\" and node \"%2\"</p>" ). | 370 | "<p>Error in section \"preamble\" for proper file \"%1\" and node \"%2\"</p>" ). |
360 | arg( (*it) ). | 371 | arg( (*it) ). |
361 | arg( CurDevNN->name() ); | 372 | arg( CurDevNN->name() ); |
362 | return S; | 373 | return S; |
363 | } | 374 | } |
364 | } | 375 | } |
365 | FirstItem = 0; | 376 | FirstItem = 0; |
366 | Generated = 1; | 377 | Generated = 1; |
367 | 378 | ||
368 | // item specific | 379 | // item specific |
369 | if( nniit.current()->generateFile( SF, -1 ) == 2 ) { | 380 | if( nniit.current()->generateFile( SF, -1 ) == 2 ) { |
370 | S = qApp->translate( "NetworkSettings", | 381 | S = qApp->translate( "NetworkSettings", |
371 | "<p>Error in section for node \"%1\" for proper file \"%2\" and node class \"%3\"</p>" ). | 382 | "<p>Error in section for node \"%1\" for proper file \"%2\" and node class \"%3\"</p>" ). |
372 | arg( nniit.current()->name() ). | 383 | arg( nniit.current()->name() ). |
373 | arg( (*it) ). | 384 | arg( (*it) ). |
374 | arg( CurDevNN->name() ); | 385 | arg( CurDevNN->name() ); |
375 | return S; | 386 | return S; |
376 | } | 387 | } |
377 | } | 388 | } |
378 | } | 389 | } |
379 | 390 | ||
380 | if( Generated ) { | 391 | if( Generated ) { |
381 | SystemFile SF( (*it) ); | 392 | SystemFile SF( (*it) ); |
393 | QStringList SL; | ||
382 | 394 | ||
383 | if( CurDevNN->openFile( SF, 0 ) && | 395 | if( CurDevNN->openFile( SF, 0, SL ) && |
384 | ! SF.path().isEmpty() | 396 | ! SF.path().isEmpty() |
385 | ) { | 397 | ) { |
386 | 398 | ||
399 | if( ! createPath( SL ) ) { | ||
400 | S = qApp->translate( "NetworkSettings", | ||
401 | "<p>Cannot create path \"%1\" for proper file \"%2\" for node \"%3\"</p>" ). | ||
402 | arg( SL.join("/") ). | ||
403 | arg( (*it) ). | ||
404 | arg( CurDevNN->name() ); | ||
405 | return S; | ||
406 | } | ||
407 | |||
387 | if( ! SF.open() ) { | 408 | if( ! SF.open() ) { |
388 | S = qApp->translate( "NetworkSettings", | 409 | S = qApp->translate( "NetworkSettings", |
389 | "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). | 410 | "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). |
390 | arg( (*it) ).arg( CurDevNN->name() ); | 411 | arg( (*it) ). |
412 | arg( CurDevNN->name() ); | ||
391 | return S; | 413 | return S; |
392 | } | 414 | } |
393 | 415 | ||
394 | if( CurDevNN->generatePostamble( SF ) == 2 ) { | 416 | if( CurDevNN->generatePostamble( SF ) == 2 ) { |
395 | S = qApp->translate( "NetworkSettings", | 417 | S = qApp->translate( "NetworkSettings", |
396 | "<p>Error in section \"postamble\" for proper file \"%1\" and node \"%2\"</p>" ). | 418 | "<p>Error in section \"postamble\" for proper file \"%1\" and node \"%2\"</p>" ). |
397 | arg( (*it) ). | 419 | arg( (*it) ). |
398 | arg( CurDevNN->name() ); | 420 | arg( CurDevNN->name() ); |
399 | return S; | 421 | return S; |
400 | } | 422 | } |
401 | } // no postamble | 423 | } // no postamble |
402 | } | 424 | } |
403 | } | 425 | } |
404 | } | 426 | } |
405 | } | 427 | } |
406 | 428 | ||
407 | // | 429 | // |
408 | // generate all registered files | 430 | // generate all registered files |
409 | // | 431 | // |
410 | for( QDictIterator<SystemFile> sfit(SFM); | 432 | for( QDictIterator<SystemFile> sfit(SFM); |
411 | sfit.current(); | 433 | sfit.current(); |
412 | ++sfit ) { | 434 | ++sfit ) { |
413 | SystemFile * SF; | 435 | SystemFile * SF; |
414 | 436 | ||
415 | SF = sfit.current(); | 437 | SF = sfit.current(); |
416 | 438 | ||
417 | // reset all | 439 | // reset all |
418 | for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); | 440 | for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); |
419 | nnit.current(); | 441 | nnit.current(); |
420 | ++nnit ) { | 442 | ++nnit ) { |
421 | nnit.current()->setDone(0); | 443 | nnit.current()->setDone(0); |
422 | } | 444 | } |
423 | 445 | ||
424 | for( QDictIterator<ANetNodeInstance> nniit( | 446 | for( QDictIterator<ANetNodeInstance> nniit( |
425 | NSResources->netNodeInstances() ); | 447 | NSResources->netNodeInstances() ); |
426 | nniit.current(); | 448 | nniit.current(); |
427 | ++nniit ) { | 449 | ++nniit ) { |
428 | nniit.current()->setDone(0); | 450 | nniit.current()->setDone(0); |
429 | } | 451 | } |
430 | 452 | ||
431 | for( QDictIterator<NetworkSetup> ncit(M); | 453 | for( QDictIterator<NetworkSetup> ncit(M); |
432 | ncit.current(); | 454 | ncit.current(); |
433 | ++ncit ) { | 455 | ++ncit ) { |
434 | ncit.current()->setDone(0); | 456 | ncit.current()->setDone(0); |
435 | } | 457 | } |
436 | 458 | ||
437 | Log( ( "Generating system file %s\n", SF->name().latin1() )); | 459 | Log( ( "Generating system file %s\n", SF->name().latin1() )); |
438 | 460 | ||
439 | needToGenerate = 0; | 461 | needToGenerate = 0; |
440 | 462 | ||
441 | // are there netnodes that have instances and need | 463 | // are there netnodes that have instances and need |
442 | // to write data in this system file ? | 464 | // to write data in this system file ? |
443 | for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); | 465 | for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); |
444 | ! needToGenerate && nnit.current(); | 466 | ! needToGenerate && nnit.current(); |
445 | ++nnit ) { | 467 | ++nnit ) { |
446 | 468 | ||
447 | NN = nnit.current(); | 469 | NN = nnit.current(); |
448 | 470 | ||
449 | if( NN->hasDataForFile( *SF ) ) { | 471 | if( NN->hasDataForFile( *SF ) ) { |
450 | // netnode can have data | 472 | // netnode can have data |
451 | 473 | ||
452 | // are there instances of this node ? | 474 | // are there instances of this node ? |
453 | for( QDictIterator<ANetNodeInstance> nniit( | 475 | for( QDictIterator<ANetNodeInstance> nniit( |
454 | NSResources->netNodeInstances() ); | 476 | NSResources->netNodeInstances() ); |
@@ -724,64 +746,87 @@ bool NetworkSettingsData::canStart( const QString & Interface ) { | |||
724 | printf( "A%d%s\n", NC->number(), Interface.latin1() ); | 746 | printf( "A%d%s\n", NC->number(), Interface.latin1() ); |
725 | return 0; | 747 | return 0; |
726 | } | 748 | } |
727 | } | 749 | } |
728 | 750 | ||
729 | // if we come here no alternatives are possible | 751 | // if we come here no alternatives are possible |
730 | Log(( "disallow %s\n", Interface.latin1())); | 752 | Log(( "disallow %s\n", Interface.latin1())); |
731 | printf( "D-%s\n", Interface.latin1() ); | 753 | printf( "D-%s\n", Interface.latin1() ); |
732 | return 0; | 754 | return 0; |
733 | } | 755 | } |
734 | 756 | ||
735 | bool NetworkSettingsData::isModified( void ) { | 757 | bool NetworkSettingsData::isModified( void ) { |
736 | if( ForceModified ) | 758 | if( ForceModified ) |
737 | return 1; | 759 | return 1; |
738 | 760 | ||
739 | for( QDictIterator<NetworkSetup> it(NSResources->networkSetups()); | 761 | for( QDictIterator<NetworkSetup> it(NSResources->networkSetups()); |
740 | it.current(); | 762 | it.current(); |
741 | ++it ) { | 763 | ++it ) { |
742 | if( it.current()->isModified() ) { | 764 | if( it.current()->isModified() ) { |
743 | return 1; | 765 | return 1; |
744 | } | 766 | } |
745 | } | 767 | } |
746 | return 0; | 768 | return 0; |
747 | } | 769 | } |
748 | 770 | ||
749 | bool NetworkSettingsData::couldBeTriggered( const QString & Interface ) { | 771 | bool NetworkSettingsData::couldBeTriggered( const QString & Interface ) { |
750 | // load situation | 772 | // load situation |
751 | QList<NetworkSetup> PossibleTriggered; | 773 | QList<NetworkSetup> PossibleTriggered; |
752 | 774 | ||
753 | PossibleTriggered = collectTriggered( Interface ); | 775 | PossibleTriggered = collectTriggered( Interface ); |
754 | 776 | ||
755 | Log( ( "for %s : Possiblilies %d\n", | 777 | Log( ( "for %s : Possiblilies %d\n", |
756 | Interface.latin1(), PossibleTriggered.count() )); | 778 | Interface.latin1(), PossibleTriggered.count() )); |
757 | 779 | ||
758 | return ( PossibleTriggered.count() ) ? 1 : 0; | 780 | return ( PossibleTriggered.count() ) ? 1 : 0; |
759 | } | 781 | } |
760 | 782 | ||
761 | QList<NetworkSetup> NetworkSettingsData::collectTriggered( | 783 | QList<NetworkSetup> NetworkSettingsData::collectTriggered( |
762 | const QString & Interface ) { | 784 | const QString & Interface ) { |
763 | 785 | ||
764 | // collect NetworkSetups that could be triggered by this interface | 786 | // collect NetworkSetups that could be triggered by this interface |
765 | NetworkSetup * NC; | 787 | NetworkSetup * NC; |
766 | QList<NetworkSetup> PossibleTriggered; | 788 | QList<NetworkSetup> PossibleTriggered; |
767 | 789 | ||
768 | // for all NetworkSetups | 790 | // for all NetworkSetups |
769 | Name2NetworkSetup_t & M = NSResources->networkSetups(); | 791 | Name2NetworkSetup_t & M = NSResources->networkSetups(); |
770 | 792 | ||
771 | for( QDictIterator<NetworkSetup> it(M); | 793 | for( QDictIterator<NetworkSetup> it(M); |
772 | it.current(); | 794 | it.current(); |
773 | ++it ) { | 795 | ++it ) { |
774 | NC = it.current(); | 796 | NC = it.current(); |
775 | // check if this profile handles the requested interface | 797 | // check if this profile handles the requested interface |
776 | if( NC->triggeredBy( Interface ) && // if different Intf. | 798 | if( NC->triggeredBy( Interface ) && // if different Intf. |
777 | NC->state() != Disabled && // if enabled | 799 | NC->state() != Disabled && // if enabled |
778 | NC->state() != IsUp // if already used | 800 | NC->state() != IsUp // if already used |
779 | ) { | 801 | ) { |
780 | Log( ( "Append %s for %s\n", | 802 | Log( ( "Append %s for %s\n", |
781 | NC->name().latin1(), Interface.latin1() )); | 803 | NC->name().latin1(), Interface.latin1() )); |
782 | PossibleTriggered.append( NC ); | 804 | PossibleTriggered.append( NC ); |
783 | } | 805 | } |
784 | } | 806 | } |
785 | return PossibleTriggered; | 807 | return PossibleTriggered; |
786 | } | 808 | } |
787 | 809 | ||
810 | bool NetworkSettingsData::createPath( const QStringList & SL ) { | ||
811 | |||
812 | QDir D( SL[0] ); | ||
813 | |||
814 | for ( QStringList::ConstIterator it = SL.begin(); | ||
815 | it != SL.end(); | ||
816 | ++it ) { | ||
817 | |||
818 | printf( "Create %s\n", (*it).latin1() ); | ||
819 | if( it == SL.begin() ) | ||
820 | continue; | ||
821 | |||
822 | if( ! D.exists( *it ) ) { | ||
823 | if( ! D.mkdir( *it ) ) { | ||
824 | printf( "Failed %s %s\n", D.path().latin1(), (*it).latin1() ); | ||
825 | return 0; | ||
826 | } | ||
827 | } | ||
828 | |||
829 | D.cd( *it ); | ||
830 | } | ||
831 | return 1; | ||
832 | } | ||
diff --git a/noncore/settings/networksettings2/nsdata.h b/noncore/settings/networksettings2/nsdata.h index b9c216d..65b61a3 100644 --- a/noncore/settings/networksettings2/nsdata.h +++ b/noncore/settings/networksettings2/nsdata.h | |||
@@ -1,38 +1,39 @@ | |||
1 | #ifndef __NSDATA_H | 1 | #ifndef __NSDATA_H |
2 | #define __NSDATA_H | 2 | #define __NSDATA_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | 5 | ||
6 | class NetworkSettingsData { | 6 | class NetworkSettingsData { |
7 | 7 | ||
8 | public : | 8 | public : |
9 | 9 | ||
10 | NetworkSettingsData( void ); | 10 | NetworkSettingsData( void ); |
11 | ~NetworkSettingsData( void ); | 11 | ~NetworkSettingsData( void ); |
12 | 12 | ||
13 | void loadSettings( void ); | 13 | void loadSettings( void ); |
14 | QString saveSettings( void ); | 14 | QString saveSettings( void ); |
15 | 15 | ||
16 | QString generateSettings( void ); | 16 | QString generateSettings( void ); |
17 | 17 | ||
18 | bool isModified( void ); | 18 | bool isModified( void ); |
19 | inline void setModified( bool M ) | 19 | inline void setModified( bool M ) |
20 | { ForceModified = M; } | 20 | { ForceModified = M; } |
21 | 21 | ||
22 | QList<NetworkSetup> collectPossible( const QString & Interface ); | 22 | QList<NetworkSetup> collectPossible( const QString & Interface ); |
23 | // return TRUE if we need gui to decide | 23 | // return TRUE if we need gui to decide |
24 | bool canStart( const QString & Interface ); | 24 | bool canStart( const QString & Interface ); |
25 | // return TRUE if there are vpns that could be triggered | 25 | // return TRUE if there are vpns that could be triggered |
26 | // by this interface | 26 | // by this interface |
27 | bool couldBeTriggered( const QString & Interface ); | 27 | bool couldBeTriggered( const QString & Interface ); |
28 | 28 | ||
29 | private : | 29 | private : |
30 | 30 | ||
31 | QList<NetworkSetup> collectTriggered( const QString &Interface ); | 31 | QList<NetworkSetup> collectTriggered( const QString &Interface ); |
32 | bool createPath( const QStringList & SL ); | ||
32 | bool ForceModified; | 33 | bool ForceModified; |
33 | 34 | ||
34 | // collect strings in config file nobody wants | 35 | // collect strings in config file nobody wants |
35 | QStringList LeftOvers; | 36 | QStringList LeftOvers; |
36 | }; | 37 | }; |
37 | 38 | ||
38 | #endif | 39 | #endif |
diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp index 8323549..fc30bf8 100644 --- a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp +++ b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp | |||
@@ -123,129 +123,128 @@ OTSniffing::OTSniffing( QWidget * parent ) : OTSniffGUI( parent ) { | |||
123 | OT = OTGateway::getOTGateway(); | 123 | OT = OTGateway::getOTGateway(); |
124 | HciDump = 0; | 124 | HciDump = 0; |
125 | } | 125 | } |
126 | 126 | ||
127 | OTSniffing::~OTSniffing() { | 127 | OTSniffing::~OTSniffing() { |
128 | SLOT_Trace( 0 ); | 128 | SLOT_Trace( 0 ); |
129 | } | 129 | } |
130 | 130 | ||
131 | void OTSniffing::SLOT_Trace( bool Run ) { | 131 | void OTSniffing::SLOT_Trace( bool Run ) { |
132 | 132 | ||
133 | if( ! Run ) { | 133 | if( ! Run ) { |
134 | if ( HciDump ) { | 134 | if ( HciDump ) { |
135 | HciDump->process().kill(); | 135 | HciDump->process().kill(); |
136 | delete HciDump; | 136 | delete HciDump; |
137 | } | 137 | } |
138 | HciDump = 0; | 138 | HciDump = 0; |
139 | return; | 139 | return; |
140 | } | 140 | } |
141 | 141 | ||
142 | HciDump = new MyProcess(); | 142 | HciDump = new MyProcess(); |
143 | QStringList SL; | 143 | QStringList SL; |
144 | 144 | ||
145 | SL << "/usr/sbin/hcidump"; | 145 | SL << "/usr/sbin/hcidump"; |
146 | switch( DataFormat_CB->currentItem() ) { | 146 | switch( DataFormat_CB->currentItem() ) { |
147 | case 0 : // Hex | 147 | case 0 : // Hex |
148 | SL << "-x"; | 148 | SL << "-x"; |
149 | break; | 149 | break; |
150 | case 1 : // Ascii | 150 | case 1 : // Ascii |
151 | SL << "-a"; | 151 | SL << "-a"; |
152 | break; | 152 | break; |
153 | case 2 : // both | 153 | case 2 : // both |
154 | SL << "-X"; | 154 | SL << "-X"; |
155 | break; | 155 | break; |
156 | } | 156 | } |
157 | 157 | ||
158 | SL << "-i"; | 158 | SL << "-i"; |
159 | SL << OT->scanWith()->devname(); | 159 | SL << OT->scanWith()->devname(); |
160 | 160 | ||
161 | connect( HciDump, | 161 | connect( HciDump, |
162 | SIGNAL( stdoutLine( const QString & ) ), | 162 | SIGNAL( stdoutLine( const QString & ) ), |
163 | this, | 163 | this, |
164 | SLOT( SLOT_Show( const QString & ) ) ); | 164 | SLOT( SLOT_Show( const QString & ) ) ); |
165 | 165 | ||
166 | connect( HciDump, | 166 | connect( HciDump, |
167 | SIGNAL(processExited(MyProcess*) ), | 167 | SIGNAL(processExited(MyProcess*) ), |
168 | this, | 168 | this, |
169 | SLOT( SLOT_ProcessExited(MyProcess*) ) ); | 169 | SLOT( SLOT_ProcessExited(MyProcess*) ) ); |
170 | 170 | ||
171 | HciDump->process() << SL; | 171 | HciDump->process() << SL; |
172 | 172 | ||
173 | if( ! HciDump->process().start( OProcess::DontCare, | 173 | if( ! HciDump->process().start( OProcess::DontCare, |
174 | OProcess::AllOutput ) | 174 | OProcess::AllOutput ) |
175 | ) { | 175 | ) { |
176 | QMessageBox::warning(0, | 176 | QMessageBox::warning(0, |
177 | tr("Run hcidump"), | 177 | tr("Run hcidump"), |
178 | tr("Cannot start %1").arg(SL.join(" ")) | 178 | tr("Cannot start %1").arg(SL.join(" ")) |
179 | ); | 179 | ); |
180 | delete HciDump; | 180 | delete HciDump; |
181 | HciDump = 0; | 181 | HciDump = 0; |
182 | } | 182 | } |
183 | 183 | ||
184 | } | 184 | } |
185 | 185 | ||
186 | void OTSniffing::SLOT_Show( const QString & S ) { | 186 | void OTSniffing::SLOT_Show( const QString & S ) { |
187 | printf( "%s\n", S.latin1() ); | ||
188 | Output_TV->setText( Output_TV->text() + S + "\n" ); | 187 | Output_TV->setText( Output_TV->text() + S + "\n" ); |
189 | 188 | ||
190 | QScrollBar *scroll = Output_TV->verticalScrollBar(); | 189 | QScrollBar *scroll = Output_TV->verticalScrollBar(); |
191 | scroll->setValue(scroll->maxValue()); | 190 | scroll->setValue(scroll->maxValue()); |
192 | //Output_LB->insertItem( S ); | 191 | //Output_LB->insertItem( S ); |
193 | //Output_LB->setCurrentItem( Output_LB->count()-1 ); | 192 | //Output_LB->setCurrentItem( Output_LB->count()-1 ); |
194 | //Output_LB->ensureCurrentVisible(); | 193 | //Output_LB->ensureCurrentVisible(); |
195 | } | 194 | } |
196 | 195 | ||
197 | void OTSniffing::SLOT_ProcessExited( MyProcess * ) { | 196 | void OTSniffing::SLOT_ProcessExited( MyProcess * ) { |
198 | printf( "Exited\n" ); | 197 | printf( "Exited\n" ); |
199 | delete HciDump; | 198 | delete HciDump; |
200 | HciDump = 0; | 199 | HciDump = 0; |
201 | } | 200 | } |
202 | 201 | ||
203 | void OTSniffing::SLOT_Save( void ) { | 202 | void OTSniffing::SLOT_Save( void ) { |
204 | QString S = OFileDialog::getSaveFileName( | 203 | QString S = OFileDialog::getSaveFileName( |
205 | OFileSelector::Extended, | 204 | OFileSelector::Extended, |
206 | QDir::home().path(), | 205 | QDir::home().path(), |
207 | QString::null, | 206 | QString::null, |
208 | MimeTypes(), | 207 | MimeTypes(), |
209 | this ); | 208 | this ); |
210 | 209 | ||
211 | if( ! S.isEmpty() ) { | 210 | if( ! S.isEmpty() ) { |
212 | QFile F( S ); | 211 | QFile F( S ); |
213 | if( ! F.open( IO_WriteOnly ) ) { | 212 | if( ! F.open( IO_WriteOnly ) ) { |
214 | QMessageBox::warning(0, | 213 | QMessageBox::warning(0, |
215 | tr("Save log"), | 214 | tr("Save log"), |
216 | tr("Cannot open %1").arg(S) | 215 | tr("Cannot open %1").arg(S) |
217 | ); | 216 | ); |
218 | return; | 217 | return; |
219 | } | 218 | } |
220 | QTextStream TS( &F ); | 219 | QTextStream TS( &F ); |
221 | TS << S << endl; | 220 | TS << S << endl; |
222 | } | 221 | } |
223 | } | 222 | } |
224 | 223 | ||
225 | void OTSniffing::SLOT_Load( void ) { | 224 | void OTSniffing::SLOT_Load( void ) { |
226 | QString S = OFileDialog::getOpenFileName( | 225 | QString S = OFileDialog::getOpenFileName( |
227 | OFileSelector::Extended, | 226 | OFileSelector::Extended, |
228 | QDir::home().path(), | 227 | QDir::home().path(), |
229 | QString::null, | 228 | QString::null, |
230 | MimeTypes(), | 229 | MimeTypes(), |
231 | this ); | 230 | this ); |
232 | 231 | ||
233 | if( ! S.isEmpty() ) { | 232 | if( ! S.isEmpty() ) { |
234 | QFile F( S ); | 233 | QFile F( S ); |
235 | if( ! F.open( IO_ReadOnly ) ) { | 234 | if( ! F.open( IO_ReadOnly ) ) { |
236 | QMessageBox::warning(0, | 235 | QMessageBox::warning(0, |
237 | tr("Save log"), | 236 | tr("Save log"), |
238 | tr("Cannot open %1").arg(S) | 237 | tr("Cannot open %1").arg(S) |
239 | ); | 238 | ); |
240 | return; | 239 | return; |
241 | } | 240 | } |
242 | QTextStream TS ( &F ); | 241 | QTextStream TS ( &F ); |
243 | SLOT_ClearLog(); | 242 | SLOT_ClearLog(); |
244 | S = TS.read(); | 243 | S = TS.read(); |
245 | // Output_LB->insertStringList( QStringList::split( "\n", S ) ); | 244 | // Output_LB->insertStringList( QStringList::split( "\n", S ) ); |
246 | Output_TV->setText( S ); | 245 | Output_TV->setText( S ); |
247 | } | 246 | } |
248 | } | 247 | } |
249 | 248 | ||
250 | void OTSniffing::SLOT_ClearLog( void ) { | 249 | void OTSniffing::SLOT_ClearLog( void ) { |
251 | // Output_LB->clear(); | 250 | // Output_LB->clear(); |
@@ -316,195 +315,204 @@ OTPairing::OTPairing( QWidget * parent, OTIcons * _IC ) : | |||
316 | // we are source | 315 | // we are source |
317 | P = OT->findPeer( Keys[i].from() ); | 316 | P = OT->findPeer( Keys[i].from() ); |
318 | 317 | ||
319 | if( P ) { | 318 | if( P ) { |
320 | // put name | 319 | // put name |
321 | it->setText( 0, P->name() ); | 320 | it->setText( 0, P->name() ); |
322 | } else { | 321 | } else { |
323 | // unknown | 322 | // unknown |
324 | it->setText( 0, Keys[i].from().toString() ); | 323 | it->setText( 0, Keys[i].from().toString() ); |
325 | } | 324 | } |
326 | 325 | ||
327 | // and put address as sub | 326 | // and put address as sub |
328 | QListViewItem * Sub = new QListViewItem( it ); | 327 | QListViewItem * Sub = new QListViewItem( it ); |
329 | Sub->setText( 0, Keys[i].from().toString() ); | 328 | Sub->setText( 0, Keys[i].from().toString() ); |
330 | Sub->setText( 1, D->address().toString() ); | 329 | Sub->setText( 1, D->address().toString() ); |
331 | } else { | 330 | } else { |
332 | // nor source nor destination -> unknown | 331 | // nor source nor destination -> unknown |
333 | it->setText( 0, Keys[i].from().toString() ); | 332 | it->setText( 0, Keys[i].from().toString() ); |
334 | it->setText( 1, Keys[i].to().toString() ); | 333 | it->setText( 1, Keys[i].to().toString() ); |
335 | } | 334 | } |
336 | } | 335 | } |
337 | } | 336 | } |
338 | } | 337 | } |
339 | 338 | ||
340 | 339 | ||
341 | OTPairing::~OTPairing() { | 340 | OTPairing::~OTPairing() { |
342 | if( MyIcons ) | 341 | if( MyIcons ) |
343 | delete Icons; | 342 | delete Icons; |
344 | OTGateway::releaseOTGateway(); | 343 | OTGateway::releaseOTGateway(); |
345 | } | 344 | } |
346 | 345 | ||
347 | void OTPairing::SLOT_Unpair( ) { | 346 | void OTPairing::SLOT_Unpair( ) { |
348 | // find selected pair | 347 | // find selected pair |
349 | 348 | ||
350 | QListViewItem * it = Pairs_LV->firstChild(); | 349 | QListViewItem * it = Pairs_LV->firstChild(); |
351 | while( it ) { | 350 | while( it ) { |
352 | if( it->isSelected() ) { | 351 | if( it->isSelected() ) { |
353 | // confirm ? | 352 | // confirm ? |
354 | if( QMessageBox::warning(0, | 353 | if( QMessageBox::warning(0, |
355 | tr("Break pairing"), | 354 | tr("Break pairing"), |
356 | tr("Sure ?"), | 355 | tr("Sure ?"), |
357 | tr("Yes, break"), | 356 | tr("Yes, break"), |
358 | tr("No, don't break") ) == 0 ) { | 357 | tr("No, don't break") ) == 0 ) { |
359 | LinkKeyLVI * KPIt = (LinkKeyLVI *)it; | 358 | LinkKeyLVI * KPIt = (LinkKeyLVI *)it; |
360 | // break | 359 | // break |
361 | OT->removeLinkKey( KPIt->index() ); | 360 | OT->removeLinkKey( KPIt->index() ); |
362 | delete KPIt; | 361 | delete KPIt; |
363 | } | 362 | } |
364 | return; | 363 | return; |
365 | } | 364 | } |
366 | it= it->nextSibling(); | 365 | it= it->nextSibling(); |
367 | } | 366 | } |
368 | } | 367 | } |
369 | 368 | ||
370 | // | 369 | // |
371 | // | 370 | // |
372 | // | 371 | // |
373 | // | 372 | // |
374 | // | 373 | // |
375 | 374 | ||
376 | OTScan::OTScan( QWidget * parent, OTIcons * _IC ) : | 375 | OTScan::OTScan( QWidget * parent, OTIcons * _IC ) : |
377 | OTScanGUI( parent ), Filter() { | 376 | OTScanGUI( parent ), Filter() { |
378 | 377 | ||
379 | OT = OTGateway::getOTGateway(); | 378 | OT = OTGateway::getOTGateway(); |
379 | |||
380 | Icons = (_IC ) ? _IC : new OTIcons(); | 380 | Icons = (_IC ) ? _IC : new OTIcons(); |
381 | MyIcons = (_IC == 0 ); | 381 | MyIcons = (_IC == 0 ); |
382 | DetectedPeers_LV->header()->hide(); | 382 | DetectedPeers_LV->header()->hide(); |
383 | Current = 0; | 383 | Current = 0; |
384 | SelectedPeer = 0; | 384 | SelectedPeer = 0; |
385 | SelectedChannel = 0; | 385 | SelectedChannel = 0; |
386 | 386 | ||
387 | StrengthTimer = new QTimer( this ); | 387 | StrengthTimer = new QTimer( this ); |
388 | connect( StrengthTimer, | 388 | connect( StrengthTimer, |
389 | SIGNAL( timeout()), | 389 | SIGNAL( timeout()), |
390 | this, | 390 | this, |
391 | SLOT( SLOT_UpdateStrength()) | 391 | SLOT( SLOT_UpdateStrength()) |
392 | ); | 392 | ); |
393 | 393 | ||
394 | connect( OT, | 394 | connect( OT, |
395 | SIGNAL( detectedPeer( OTPeer *, bool )), | 395 | SIGNAL( detectedPeer( OTPeer *, bool )), |
396 | this, | 396 | this, |
397 | SLOT( SLOT_NewPeer( OTPeer *, bool )) | 397 | SLOT( SLOT_NewPeer( OTPeer *, bool )) |
398 | ); | 398 | ); |
399 | connect( OT, | 399 | connect( OT, |
400 | SIGNAL( finishedDetecting()), | 400 | SIGNAL( finishedDetecting()), |
401 | this, | 401 | this, |
402 | SLOT( SLOT_FinishedDetecting()) | 402 | SLOT( SLOT_FinishedDetecting()) |
403 | ); | 403 | ); |
404 | 404 | ||
405 | // populate with peers we already know about | 405 | // populate with peers we already know about |
406 | const PeerVector & P = OT->peers(); | 406 | const PeerVector & P = OT->peers(); |
407 | for( unsigned int i = 0; | 407 | for( unsigned int i = 0; |
408 | i < P.count(); | 408 | i < P.count(); |
409 | i ++ ) { | 409 | i ++ ) { |
410 | SLOT_NewPeer( P[i], TRUE ); | 410 | SLOT_NewPeer( P[i], TRUE ); |
411 | } | 411 | } |
412 | 412 | ||
413 | // populate State fram | 413 | // populate State fram |
414 | { QHBoxLayout * H =new QHBoxLayout( State_Frm ); | 414 | { QHBoxLayout * H =new QHBoxLayout( State_Frm ); |
415 | 415 | ||
416 | Paired_Led = new OLedBox( green, State_Frm ); | 416 | Paired_Led = new OLedBox( green, State_Frm ); |
417 | QLabel * L1 = new QLabel( tr( "Paired" ), State_Frm ); | 417 | QLabel * L1 = new QLabel( tr( "Paired" ), State_Frm ); |
418 | 418 | ||
419 | H->addWidget( Paired_Led ); | 419 | H->addWidget( Paired_Led ); |
420 | H->addWidget( L1 ); | 420 | H->addWidget( L1 ); |
421 | H->addStretch( 1 ); | 421 | H->addStretch( 1 ); |
422 | } | 422 | } |
423 | } | 423 | } |
424 | 424 | ||
425 | OTScan::~OTScan() { | 425 | OTScan::~OTScan() { |
426 | if( MyIcons ) | 426 | if( MyIcons ) |
427 | delete Icons; | 427 | delete Icons; |
428 | OTGateway::releaseOTGateway(); | 428 | OTGateway::releaseOTGateway(); |
429 | 429 | ||
430 | // send all peers that we do not care about states | 430 | // send all peers that we do not care about states |
431 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); | 431 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); |
432 | while( Lit ) { | 432 | while( Lit ) { |
433 | ((PeerLVI *)Lit)->peer()->stopFindingOutState( ); | 433 | ((PeerLVI *)Lit)->peer()->stopFindingOutState( ); |
434 | Lit = Lit->nextSibling(); | 434 | Lit = Lit->nextSibling(); |
435 | } | 435 | } |
436 | } | 436 | } |
437 | 437 | ||
438 | // static scan dialog function | 438 | // static scan dialog function |
439 | int OTScan::getDevice( OTPeer *& Peer, | 439 | int OTScan::getDevice( OTPeer *& Peer, |
440 | int & Channel, | 440 | int & Channel, |
441 | OTGateway * OT, | 441 | OTGateway * OT, |
442 | const UUIDVector & Filter, | 442 | const UUIDVector & Filter, |
443 | QWidget* Parent ) { | 443 | QWidget* Parent ) { |
444 | bool IsUp = 0; | 444 | bool IsUp = 0; |
445 | unsigned int i; | 445 | unsigned int i; |
446 | 446 | ||
447 | if( ! OT->isEnabled() ) { | ||
448 | QMessageBox::warning( 0, | ||
449 | tr("Scanning problem"), | ||
450 | tr("Bluetooth not enabled" ) | ||
451 | ); | ||
452 | return QDialog::Rejected; | ||
453 | } | ||
454 | |||
447 | // check if bluetooth is up | 455 | // check if bluetooth is up |
448 | OTDriverList & DL = OT->getDriverList(); | 456 | OTDriverList & DL = OT->getDriverList(); |
449 | for( i = 0; | 457 | for( i = 0; |
450 | i < DL.count(); | 458 | i < DL.count(); |
451 | i ++ ) { | 459 | i ++ ) { |
452 | if( DL[i]->isUp() ) { | 460 | if( DL[i]->isUp() ) { |
453 | // one device that is up found | 461 | // one device that is up found |
454 | IsUp = 1; | 462 | IsUp = 1; |
455 | break; | 463 | break; |
456 | } | 464 | } |
457 | } | 465 | } |
458 | 466 | ||
459 | // use this driver | 467 | // use this driver |
460 | OT->setScanWith( OT->driver(i) ); | 468 | OT->setScanWith( OT->driver(i) ); |
461 | 469 | ||
462 | // create dialog | 470 | // create dialog |
463 | QDialog * Dlg = new QDialog( Parent, 0, TRUE ); | 471 | QDialog * Dlg = new QDialog( Parent, 0, TRUE ); |
464 | QVBoxLayout * V = new QVBoxLayout( Dlg ); | 472 | QVBoxLayout * V = new QVBoxLayout( Dlg ); |
465 | OTScan * Scn = new OTScan( Dlg ); | 473 | OTScan * Scn = new OTScan( Dlg ); |
466 | 474 | ||
467 | connect( Scn, | 475 | connect( Scn, |
468 | SIGNAL( selected() ), | 476 | SIGNAL( selected() ), |
469 | Dlg, | 477 | Dlg, |
470 | SLOT( accept() ) | 478 | SLOT( accept() ) |
471 | ); | 479 | ); |
472 | 480 | ||
473 | if( Filter ) { | 481 | if( Filter ) { |
474 | Scn->setScanFilter( Filter ); | 482 | Scn->setScanFilter( Filter ); |
475 | } | 483 | } |
476 | 484 | ||
477 | V->addWidget( Scn ); | 485 | V->addWidget( Scn ); |
478 | Dlg->setCaption( tr("Scan Neighbourhood" ) ); | 486 | Dlg->setCaption( tr("Scan Neighbourhood" ) ); |
479 | Dlg->showMaximized(); | 487 | Dlg->showMaximized(); |
480 | int rv = Dlg->exec(); | 488 | int rv = Dlg->exec(); |
481 | 489 | ||
482 | if( rv == QDialog::Accepted ) { | 490 | if( rv == QDialog::Accepted ) { |
483 | // get peer | 491 | // get peer |
484 | Peer = Scn->selectedPeer(); | 492 | Peer = Scn->selectedPeer(); |
485 | if( Peer == 0 ) { | 493 | if( Peer == 0 ) { |
486 | // no peer selected | 494 | // no peer selected |
487 | rv = QDialog::Rejected; | 495 | rv = QDialog::Rejected; |
488 | } else { | 496 | } else { |
489 | Channel = Scn->selectedChannel(); | 497 | Channel = Scn->selectedChannel(); |
490 | } | 498 | } |
491 | } | 499 | } |
492 | 500 | ||
493 | delete Dlg; | 501 | delete Dlg; |
494 | 502 | ||
495 | return rv; | 503 | return rv; |
496 | } | 504 | } |
497 | 505 | ||
498 | void OTScan::setScanFilter( const UUIDVector & V ) { | 506 | void OTScan::setScanFilter( const UUIDVector & V ) { |
499 | Filter = V; | 507 | Filter = V; |
500 | } | 508 | } |
501 | 509 | ||
502 | void OTScan::resetScanFilter( void ) { | 510 | void OTScan::resetScanFilter( void ) { |
503 | Filter.truncate(0); | 511 | Filter.truncate(0); |
504 | } | 512 | } |
505 | 513 | ||
506 | void OTScan::SLOT_DoScan( bool DoIt ) { | 514 | void OTScan::SLOT_DoScan( bool DoIt ) { |
507 | if( DoIt ) { | 515 | if( DoIt ) { |
508 | OT->scanNeighbourhood(); | 516 | OT->scanNeighbourhood(); |
509 | } else { | 517 | } else { |
510 | OT->stopScanOfNeighbourhood(); | 518 | OT->stopScanOfNeighbourhood(); |
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp index 7286d96..9cdd51e 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp | |||
@@ -85,134 +85,136 @@ void APPP::setSpecificAttribute( QString & A, QString & V ) { | |||
85 | } else if( A == "ipgwaddress" ) { | 85 | } else if( A == "ipgwaddress" ) { |
86 | Data.IP.GWAddress = V; | 86 | Data.IP.GWAddress = V; |
87 | } | 87 | } |
88 | } else if( A.startsWith( "run" ) ) { | 88 | } else if( A.startsWith( "run" ) ) { |
89 | if( A == "runpreconnect" ) { | 89 | if( A == "runpreconnect" ) { |
90 | Data.Run.PreConnect = V; | 90 | Data.Run.PreConnect = V; |
91 | } else if( A == "runpostconnect" ) { | 91 | } else if( A == "runpostconnect" ) { |
92 | Data.Run.PostConnect = V; | 92 | Data.Run.PostConnect = V; |
93 | } else if( A == "runpredisconnect" ) { | 93 | } else if( A == "runpredisconnect" ) { |
94 | Data.Run.PreDisconnect = V; | 94 | Data.Run.PreDisconnect = V; |
95 | } else if( A == "runpostdisconnect" ) { | 95 | } else if( A == "runpostdisconnect" ) { |
96 | Data.Run.PostDisconnect = V; | 96 | Data.Run.PostDisconnect = V; |
97 | } | 97 | } |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | void APPP::saveSpecificAttribute( QTextStream & TS ) { | 101 | void APPP::saveSpecificAttribute( QTextStream & TS ) { |
102 | TS << "dnsserverassigned=" << | 102 | TS << "dnsserverassigned=" << |
103 | ( ( Data.DNS.ServerAssigned ) ? "yes" : "no" ) << endl; | 103 | ( ( Data.DNS.ServerAssigned ) ? "yes" : "no" ) << endl; |
104 | TS << "dnsdomainname=" << Data.DNS.DomainName << endl; | 104 | TS << "dnsdomainname=" << Data.DNS.DomainName << endl; |
105 | for( unsigned int i = 0; i < Data.DNS.Servers.size(); i ++ ) { | 105 | for( unsigned int i = 0; i < Data.DNS.Servers.size(); i ++ ) { |
106 | TS << "dnsserver=" << *(Data.DNS.Servers[i]) << endl; | 106 | TS << "dnsserver=" << *(Data.DNS.Servers[i]) << endl; |
107 | } | 107 | } |
108 | TS << "authmode=" << Data.Auth.Mode << endl; | 108 | TS << "authmode=" << Data.Auth.Mode << endl; |
109 | TS << "authloginexpect=" << quote( Data.Auth.Login.Expect ) << endl; | 109 | TS << "authloginexpect=" << quote( Data.Auth.Login.Expect ) << endl; |
110 | TS << "authloginsend=" << quote( Data.Auth.Login.Send ) << endl; | 110 | TS << "authloginsend=" << quote( Data.Auth.Login.Send ) << endl; |
111 | TS << "authpasswordexpect=" << quote( Data.Auth.Password.Expect ) << endl; | 111 | TS << "authpasswordexpect=" << quote( Data.Auth.Password.Expect ) << endl; |
112 | TS << "authpasswordsend=" << quote( Data.Auth.Password.Send ) << endl; | 112 | TS << "authpasswordsend=" << quote( Data.Auth.Password.Send ) << endl; |
113 | TS << "authpcemode=" << Data.Auth.PCEMode << endl; | 113 | TS << "authpcemode=" << Data.Auth.PCEMode << endl; |
114 | TS << "authclient=" << Data.Auth.Client << endl; | 114 | TS << "authclient=" << Data.Auth.Client << endl; |
115 | TS << "authserver=" << Data.Auth.Server << endl; | 115 | TS << "authserver=" << Data.Auth.Server << endl; |
116 | TS << "authsecret=" << quote( Data.Auth.Secret ) << endl; | 116 | TS << "authsecret=" << quote( Data.Auth.Secret ) << endl; |
117 | TS << "ipgwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl; | 117 | TS << "ipgwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl; |
118 | TS << "ipgwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl; | 118 | TS << "ipgwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl; |
119 | TS << "ipgwifnotset=" << ( ( Data.IP.GWIfNotSet ) ? "yes" : "no" ) << endl; | 119 | TS << "ipgwifnotset=" << ( ( Data.IP.GWIfNotSet ) ? "yes" : "no" ) << endl; |
120 | TS << "iplocaloverrule=" << ( ( Data.IP.LocalOverrule ) ? "yes" : "no" ) << endl; | 120 | TS << "iplocaloverrule=" << ( ( Data.IP.LocalOverrule ) ? "yes" : "no" ) << endl; |
121 | TS << "ipremoteoverrule=" << ( ( Data.IP.RemoteOverrule ) ? "yes" : "no" ) << endl; | 121 | TS << "ipremoteoverrule=" << ( ( Data.IP.RemoteOverrule ) ? "yes" : "no" ) << endl; |
122 | TS << "iplocaladdress=" << Data.IP.LocalAddress << endl; | 122 | TS << "iplocaladdress=" << Data.IP.LocalAddress << endl; |
123 | TS << "ipremoteaddress=" << Data.IP.RemoteAddress << endl; | 123 | TS << "ipremoteaddress=" << Data.IP.RemoteAddress << endl; |
124 | TS << "ipgwaddress=" << Data.IP.GWAddress << endl; | 124 | TS << "ipgwaddress=" << Data.IP.GWAddress << endl; |
125 | 125 | ||
126 | TS << "runpreconnect=" << Data.Run.PreConnect << endl; | 126 | TS << "runpreconnect=" << Data.Run.PreConnect << endl; |
127 | TS << "runpostconnect=" << Data.Run.PostConnect << endl; | 127 | TS << "runpostconnect=" << Data.Run.PostConnect << endl; |
128 | TS << "runpredisconnect=" << Data.Run.PreDisconnect << endl; | 128 | TS << "runpredisconnect=" << Data.Run.PreDisconnect << endl; |
129 | TS << "runpostdisconnect=" << Data.Run.PostDisconnect << endl; | 129 | TS << "runpostdisconnect=" << Data.Run.PostDisconnect << endl; |
130 | 130 | ||
131 | } | 131 | } |
132 | 132 | ||
133 | QWidget * APPP::edit( QWidget * parent ) { | 133 | QWidget * APPP::edit( QWidget * parent ) { |
134 | GUI = new PPPEdit( parent ); | 134 | GUI = new PPPEdit( parent ); |
135 | GUI->showData( Data ); | 135 | GUI->showData( Data ); |
136 | return GUI; | 136 | return GUI; |
137 | } | 137 | } |
138 | 138 | ||
139 | QString APPP::acceptable( void ) { | 139 | QString APPP::acceptable( void ) { |
140 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 140 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
141 | } | 141 | } |
142 | 142 | ||
143 | void APPP::commit( void ) { | 143 | void APPP::commit( void ) { |
144 | if( GUI && GUI->commit( Data ) ) { | 144 | if( GUI && GUI->commit( Data ) ) { |
145 | setModified( 1 ); | 145 | setModified( 1 ); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | bool APPP::openFile( SystemFile & SF ) { | 149 | bool APPP::openFile( SystemFile & SF, QStringList & SL ) { |
150 | if( SF.name() == "peers" ) { | 150 | if( SF.name() == "peers" ) { |
151 | SL << "/tmp/ppp" << "peers" ; | ||
151 | SF.setPath( removeSpaces( | 152 | SF.setPath( removeSpaces( |
152 | QString( "/tmp/ppp/peers/" ) + networkSetup()->name() ) ); | 153 | QString( "/tmp/ppp/peers/" ) + networkSetup()->name() ) ); |
153 | return 1; | 154 | return 1; |
154 | } else if ( SF.name() == "chatscripts" ) { | 155 | } else if ( SF.name() == "chatscripts" ) { |
156 | SL << "/tmp/chatscripts"; | ||
155 | SF.setPath( removeSpaces( | 157 | SF.setPath( removeSpaces( |
156 | QString( "/tmp/chatscripts/" ) + networkSetup()->name() ) ); | 158 | QString( "/tmp/chatscripts/" ) + networkSetup()->name() ) ); |
157 | return 1; | 159 | return 1; |
158 | } | 160 | } |
159 | return 0; | 161 | return 0; |
160 | } | 162 | } |
161 | 163 | ||
162 | short APPP::generateFile( SystemFile & SF, long DevNr ) { | 164 | short APPP::generateFile( SystemFile & SF, long DevNr ) { |
163 | short rvl, rvd; | 165 | short rvl, rvd; |
164 | 166 | ||
165 | rvl = 1; | 167 | rvl = 1; |
166 | rvd = 1; | 168 | rvd = 1; |
167 | 169 | ||
168 | if( SF.name() == "pap-secrets" ) { | 170 | if( SF.name() == "pap-secrets" ) { |
169 | Log(("Generate PPP for %s\n", SF.name().latin1() )); | 171 | Log(("Generate PPP for %s\n", SF.name().latin1() )); |
170 | 172 | ||
171 | if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) { | 173 | if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) { |
172 | SF << "# secrets for " | 174 | SF << "# secrets for " |
173 | << networkSetup()->name().latin1() | 175 | << networkSetup()->name().latin1() |
174 | << endl; | 176 | << endl; |
175 | SF << Data.Auth.Client | 177 | SF << Data.Auth.Client |
176 | << " " | 178 | << " " |
177 | << Data.Auth.Server | 179 | << Data.Auth.Server |
178 | << " " | 180 | << " " |
179 | << Data.Auth.Secret | 181 | << Data.Auth.Secret |
180 | << endl; | 182 | << endl; |
181 | rvl = 0; | 183 | rvl = 0; |
182 | rvd = networkSetup()->getToplevel()->generateFileEmbedded( | 184 | rvd = networkSetup()->getToplevel()->generateFileEmbedded( |
183 | SF, DevNr ); | 185 | SF, DevNr ); |
184 | } | 186 | } |
185 | } else if( SF.name() == "chap-secrets" ) { | 187 | } else if( SF.name() == "chap-secrets" ) { |
186 | Log(("Generate PPP for %s\n", SF.name().latin1() )); | 188 | Log(("Generate PPP for %s\n", SF.name().latin1() )); |
187 | if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) { | 189 | if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) { |
188 | // used for both EAP and Chap | 190 | // used for both EAP and Chap |
189 | SF << "# secrets for " | 191 | SF << "# secrets for " |
190 | << networkSetup()->name().latin1() | 192 | << networkSetup()->name().latin1() |
191 | << endl; | 193 | << endl; |
192 | SF << Data.Auth.Client | 194 | SF << Data.Auth.Client |
193 | << " " | 195 | << " " |
194 | << Data.Auth.Server | 196 | << Data.Auth.Server |
195 | << " " | 197 | << " " |
196 | << Data.Auth.Secret | 198 | << Data.Auth.Secret |
197 | << endl; | 199 | << endl; |
198 | 200 | ||
199 | rvl = 0; | 201 | rvl = 0; |
200 | rvd = networkSetup()->getToplevel()->generateFileEmbedded( | 202 | rvd = networkSetup()->getToplevel()->generateFileEmbedded( |
201 | SF, DevNr ); | 203 | SF, DevNr ); |
202 | } | 204 | } |
203 | } else if ( SF.name() == "peers" ) { | 205 | } else if ( SF.name() == "peers" ) { |
204 | 206 | ||
205 | QFileInfo FI(SF.path()); | 207 | QFileInfo FI(SF.path()); |
206 | Log(("Generate PPP for %s\n", SF.name().latin1() )); | 208 | Log(("Generate PPP for %s\n", SF.name().latin1() )); |
207 | 209 | ||
208 | SF << "connect \"/usr/sbin/chat -v -f /etc/chatscripts/" | 210 | SF << "connect \"/usr/sbin/chat -v -f /etc/chatscripts/" |
209 | << FI.baseName() | 211 | << FI.baseName() |
210 | << "\"" | 212 | << "\"" |
211 | << endl; | 213 | << endl; |
212 | 214 | ||
213 | if( Data.IP.GWIsDefault ) { | 215 | if( Data.IP.GWIsDefault ) { |
214 | SF << "defaultroute" | 216 | SF << "defaultroute" |
215 | << endl; | 217 | << endl; |
216 | } | 218 | } |
217 | 219 | ||
218 | SF << "linkname " | 220 | SF << "linkname " |
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.h b/noncore/settings/networksettings2/ppp/ppp_NNI.h index 76afb21..7830a4a 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NNI.h +++ b/noncore/settings/networksettings2/ppp/ppp_NNI.h | |||
@@ -1,45 +1,45 @@ | |||
1 | #ifndef PPP_H | 1 | #ifndef PPP_H |
2 | #define PPP_H | 2 | #define PPP_H |
3 | 3 | ||
4 | #include <netnode.h> | 4 | #include <netnode.h> |
5 | #include "pppdata.h" | 5 | #include "pppdata.h" |
6 | #include "ppprun.h" | 6 | #include "ppprun.h" |
7 | 7 | ||
8 | class PPPNetNode; | 8 | class PPPNetNode; |
9 | class PPPEdit; | 9 | class PPPEdit; |
10 | class QTextStream; | 10 | class QTextStream; |
11 | 11 | ||
12 | class APPP : public ANetNodeInstance { | 12 | class APPP : public ANetNodeInstance { |
13 | 13 | ||
14 | public : | 14 | public : |
15 | 15 | ||
16 | APPP( PPPNetNode * PNN ); | 16 | APPP( PPPNetNode * PNN ); |
17 | 17 | ||
18 | RuntimeInfo * runtime( void ) | 18 | RuntimeInfo * runtime( void ) |
19 | { return (RT) ? RT : (RT = new PPPRun( this, Data ) ); } | 19 | { return (RT) ? RT : (RT = new PPPRun( this, Data ) ); } |
20 | 20 | ||
21 | QWidget * edit( QWidget * parent ); | 21 | QWidget * edit( QWidget * parent ); |
22 | QString acceptable( void ); | 22 | QString acceptable( void ); |
23 | void commit( void ); | 23 | void commit( void ); |
24 | 24 | ||
25 | virtual void * data( void ) | 25 | virtual void * data( void ) |
26 | { return (void *)&Data; } | 26 | { return (void *)&Data; } |
27 | 27 | ||
28 | virtual bool openFile( SystemFile & Sf ); | 28 | virtual bool openFile( SystemFile & Sf, QStringList &SL ); |
29 | short generateFile( SystemFile & TS, | 29 | short generateFile( SystemFile & TS, |
30 | long DevNr ); | 30 | long DevNr ); |
31 | 31 | ||
32 | protected : | 32 | protected : |
33 | 33 | ||
34 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); | 34 | virtual void setSpecificAttribute( QString & Attr, QString & Value ); |
35 | virtual void saveSpecificAttribute( QTextStream & TS ); | 35 | virtual void saveSpecificAttribute( QTextStream & TS ); |
36 | 36 | ||
37 | private : | 37 | private : |
38 | 38 | ||
39 | PPPEdit * GUI; | 39 | PPPEdit * GUI; |
40 | PPPData Data; | 40 | PPPData Data; |
41 | PPPRun * RT; | 41 | PPPRun * RT; |
42 | 42 | ||
43 | }; | 43 | }; |
44 | 44 | ||
45 | #endif | 45 | #endif |
diff --git a/noncore/settings/networksettings2/profile/profilerun.cpp b/noncore/settings/networksettings2/profile/profilerun.cpp index 48011ea..77bf9ac 100644 --- a/noncore/settings/networksettings2/profile/profilerun.cpp +++ b/noncore/settings/networksettings2/profile/profilerun.cpp | |||
@@ -1,31 +1,30 @@ | |||
1 | #include <resources.h> | 1 | #include <resources.h> |
2 | 2 | ||
3 | #include "profilerun.h" | 3 | #include "profilerun.h" |
4 | 4 | ||
5 | State_t ProfileRun::detectState( void ) { | 5 | State_t ProfileRun::detectState( void ) { |
6 | InterfaceInfo * II = networkSetup()->assignedInterface(); | ||
7 | 6 | ||
8 | Log(( "Interface %p %p %p: %d\n", II, | 7 | Log(( "Profile %sabled\n", (Data->Disabled) ? "dis" : "en" )); |
9 | netNode(), netNode()->networkSetup(), (II) ? II->IsUp : 0 )); | 8 | |
10 | if( Data->Disabled ) { | 9 | if( Data->Disabled ) { |
11 | return Disabled; | 10 | return Disabled; |
12 | } | 11 | } |
13 | return Unknown; | 12 | return Unknown; |
14 | } | 13 | } |
15 | 14 | ||
16 | QString ProfileRun::setMyState( NetworkSetup * NC, Action_t A, bool ) { | 15 | QString ProfileRun::setMyState( NetworkSetup * NC, Action_t A, bool ) { |
17 | odebug << "Profile " << Data->Disabled << oendl; | 16 | odebug << "Profile " << Data->Disabled << oendl; |
18 | if( A == Disable ) { | 17 | if( A == Disable ) { |
19 | if( ! Data->Disabled ) { | 18 | if( ! Data->Disabled ) { |
20 | Data->Disabled = 1; | 19 | Data->Disabled = 1; |
21 | NC->setModified( 1 ); | 20 | NC->setModified( 1 ); |
22 | } | 21 | } |
23 | } else if( A == Enable ) { | 22 | } else if( A == Enable ) { |
24 | if( Data->Disabled ) { | 23 | if( Data->Disabled ) { |
25 | Data->Disabled = 0; | 24 | Data->Disabled = 0; |
26 | NC->setModified( 1 ); | 25 | NC->setModified( 1 ); |
27 | } | 26 | } |
28 | } | 27 | } |
29 | 28 | ||
30 | return QString(); | 29 | return QString(); |
31 | } | 30 | } |