summaryrefslogtreecommitdiff
authorwimpie <wimpie>2005-01-12 01:40:53 (UTC)
committer wimpie <wimpie>2005-01-12 01:40:53 (UTC)
commitf9a83585111afa08a47176097a150d9f468bfcdf (patch) (unidiff)
tree6d5a3b5f9716f7c6ca6e7fae8b0e2bac8d6c57da
parentb2e60aa0222b348f34aab501feb8bc854e94413c (diff)
downloadopie-f9a83585111afa08a47176097a150d9f468bfcdf.zip
opie-f9a83585111afa08a47176097a150d9f468bfcdf.tar.gz
opie-f9a83585111afa08a47176097a150d9f468bfcdf.tar.bz2
*** empty log message ***
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp42
-rw-r--r--noncore/settings/networksettings2/gprs/GPRS_NNI.cpp5
-rw-r--r--noncore/settings/networksettings2/gprs/GPRS_NNI.h3
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp2
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.cpp7
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h10
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp55
-rw-r--r--noncore/settings/networksettings2/nsdata.h1
-rw-r--r--noncore/settings/networksettings2/opietooth2/Opietooth.cpp10
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.cpp4
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.h2
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.cpp5
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
7using Opietooth2::OTGateway; 17using Opietooth2::OTGateway;
8using Opietooth2::OTDevice; 18using Opietooth2::OTDevice;
9using Opietooth2::OTDeviceAddress; 19using Opietooth2::OTDeviceAddress;
20using Opietooth2::OTScan;
21using Opietooth2::OTPeer;
10 22
11BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) { 23BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) {
12 if( OT ) { 24 if( OT ) {
13 OTGateway::releaseOTGateway(); 25 OTGateway::releaseOTGateway();
14 } 26 }
15} 27}
16 28
17State_t BluetoothRFCOMMRun::detectState( void ) { 29State_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
34QString BluetoothRFCOMMRun::setMyState( NetworkSetup *, 46QString 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
87RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) { 96RFCOMMChannel * 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
133QString BluetoothRFCOMMRun::deviceFile( void ) { 161QString 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
142int BluetoothRFCOMMRun::deviceNrOfNetworkSetup( void ) { 170int 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
@@ -1,231 +1,234 @@
1#include <system.h> 1#include <system.h>
2#include <netnode.h> 2#include <netnode.h>
3#include "GPRSedit.h" 3#include "GPRSedit.h"
4#include "GPRS_NNI.h" 4#include "GPRS_NNI.h"
5#include "GPRS_NN.h" 5#include "GPRS_NN.h"
6 6
7AGPRSDevice::AGPRSDevice( GPRSNetNode * PNN ) : ANetNodeInstance( PNN ) { 7AGPRSDevice::AGPRSDevice( GPRSNetNode * PNN ) : ANetNodeInstance( PNN ) {
8 Data.APN = ""; 8 Data.APN = "";
9 Data.User = ""; 9 Data.User = "";
10 Data.Password = ""; 10 Data.Password = "";
11 Data.DefaultGateway = 1; 11 Data.DefaultGateway = 1;
12 Data.SetIfSet = 0; 12 Data.SetIfSet = 0;
13 Data.Debug = 0; 13 Data.Debug = 0;
14 Data.Routing.setAutoDelete( TRUE ); 14 Data.Routing.setAutoDelete( TRUE );
15 GUI = 0; 15 GUI = 0;
16 RT = 0; 16 RT = 0;
17} 17}
18 18
19void AGPRSDevice::setSpecificAttribute( QString & A, QString & V ) { 19void AGPRSDevice::setSpecificAttribute( QString & A, QString & V ) {
20 if( A == "apn" ) { 20 if( A == "apn" ) {
21 Data.APN = V; 21 Data.APN = V;
22 } else if( A == "user" ) { 22 } else if( A == "user" ) {
23 Data.User = V; 23 Data.User = V;
24 } else if( A == "password" ) { 24 } else if( A == "password" ) {
25 Data.Password = V; 25 Data.Password = V;
26 } else if( A == "dns2" ) { 26 } else if( A == "dns2" ) {
27 Data.DNS2 = V; 27 Data.DNS2 = V;
28 } else if( A == "dns1" ) { 28 } else if( A == "dns1" ) {
29 Data.DNS1 = V; 29 Data.DNS1 = V;
30 } else if( A == "defaultgateway" ) { 30 } else if( A == "defaultgateway" ) {
31 Data.DefaultGateway = (V=="yes"); 31 Data.DefaultGateway = (V=="yes");
32 } else if( A == "setifset" ) { 32 } else if( A == "setifset" ) {
33 Data.SetIfSet = (V == "yes"); 33 Data.SetIfSet = (V == "yes");
34 } else if( A == "routes" ) { 34 } else if( A == "routes" ) {
35 Data.Routing.resize( V.toULong() ); 35 Data.Routing.resize( V.toULong() );
36 } else if( A.startsWith( "route" ) ) { 36 } else if( A.startsWith( "route" ) ) {
37 QStringList SL = QStringList::split( "/", V ); 37 QStringList SL = QStringList::split( "/", V );
38 GPRSRoutingEntry * E = new GPRSRoutingEntry; 38 GPRSRoutingEntry * E = new GPRSRoutingEntry;
39 39
40 E->Address = SL[0]; 40 E->Address = SL[0];
41 E->Mask = SL[1].toULong(); 41 E->Mask = SL[1].toULong();
42 42
43 Data.Routing.insert( A.mid(5).toULong(), E ); 43 Data.Routing.insert( A.mid(5).toULong(), E );
44 } else if( A == "debug" ) { 44 } else if( A == "debug" ) {
45 Data.Debug = V.toShort(); 45 Data.Debug = V.toShort();
46 } 46 }
47} 47}
48 48
49void AGPRSDevice::saveSpecificAttribute( QTextStream & TS ) { 49void AGPRSDevice::saveSpecificAttribute( QTextStream & TS ) {
50 TS << "apn=" << Data.APN << endl; 50 TS << "apn=" << Data.APN << endl;
51 TS << "user=" << Data.User << endl; 51 TS << "user=" << Data.User << endl;
52 TS << "password=" << Data.Password << endl; 52 TS << "password=" << Data.Password << endl;
53 TS << "dns1=" << Data.DNS1 << endl; 53 TS << "dns1=" << Data.DNS1 << endl;
54 TS << "dns2=" << Data.DNS2 << endl; 54 TS << "dns2=" << Data.DNS2 << endl;
55 TS << "defaultgateway=" << ( (Data.DefaultGateway) ? "yes" : "no" ) << endl; 55 TS << "defaultgateway=" << ( (Data.DefaultGateway) ? "yes" : "no" ) << endl;
56 TS << "setifset=" << ((Data.SetIfSet) ? "yes" : "no") << endl; 56 TS << "setifset=" << ((Data.SetIfSet) ? "yes" : "no") << endl;
57 TS << "debug=" << Data.Debug << endl; 57 TS << "debug=" << Data.Debug << endl;
58 58
59 TS << "routes=" << Data.Routing.count() << oendl; 59 TS << "routes=" << Data.Routing.count() << oendl;
60 for( unsigned int i = 0; i < Data.Routing.count(); i ++ ) { 60 for( unsigned int i = 0; i < Data.Routing.count(); i ++ ) {
61 TS << "route" << i << "=" 61 TS << "route" << i << "="
62 << Data.Routing[i]->Address 62 << Data.Routing[i]->Address
63 << "/" 63 << "/"
64 << Data.Routing[i]->Mask 64 << Data.Routing[i]->Mask
65 << oendl; 65 << oendl;
66 } 66 }
67} 67}
68 68
69QWidget * AGPRSDevice::edit( QWidget * parent ) { 69QWidget * AGPRSDevice::edit( QWidget * parent ) {
70 GUI = new GPRSEdit( parent ); 70 GUI = new GPRSEdit( parent );
71 GUI->showData( Data ); 71 GUI->showData( Data );
72 return GUI; 72 return GUI;
73} 73}
74 74
75QString AGPRSDevice::acceptable( void ) { 75QString AGPRSDevice::acceptable( void ) {
76 return ( GUI ) ? GUI->acceptable( ) : QString(); 76 return ( GUI ) ? GUI->acceptable( ) : QString();
77} 77}
78 78
79void AGPRSDevice::commit( void ) { 79void AGPRSDevice::commit( void ) {
80 if( GUI && GUI->commit( Data ) ) 80 if( GUI && GUI->commit( Data ) )
81 setModified( 1 ); 81 setModified( 1 );
82} 82}
83 83
84bool AGPRSDevice::hasDataForFile( SystemFile & S ) { 84bool AGPRSDevice::hasDataForFile( SystemFile & S ) {
85 return S.name() == "pap-secrets" || 85 return S.name() == "pap-secrets" ||
86 S.name() == "peers" || 86 S.name() == "peers" ||
87 S.name() == "extra" || 87 S.name() == "extra" ||
88 S.name() == "chatscripts" ; 88 S.name() == "chatscripts" ;
89} 89}
90 90
91short AGPRSDevice::generateFile( SystemFile & SF, 91short AGPRSDevice::generateFile( SystemFile & SF,
92 long 92 long
93 ) { 93 ) {
94 94
95 if( SF.name() == "pap-secrets" ) { 95 if( SF.name() == "pap-secrets" ) {
96 SF << Data.User 96 SF << Data.User
97 << " * " 97 << " * "
98 << Data.Password 98 << Data.Password
99 << " *" 99 << " *"
100 << endl; 100 << endl;
101 return 0; 101 return 0;
102 } else if( SF.name() == "chatscripts" ) { 102 } else if( SF.name() == "chatscripts" ) {
103 SF << "SAY \"Starting\\n\"" << oendl; 103 SF << "SAY \"Starting\\n\"" << oendl;
104 SF << "ECHO OFF" << oendl; 104 SF << "ECHO OFF" << oendl;
105 SF << "ABORT BUSY" << oendl; 105 SF << "ABORT BUSY" << oendl;
106 SF << "ABORT ERROR" << oendl; 106 SF << "ABORT ERROR" << oendl;
107 SF << "ABORT VOICE" << oendl; 107 SF << "ABORT VOICE" << oendl;
108 SF << "ABORT \"NO CARRIER\"" << oendl; 108 SF << "ABORT \"NO CARRIER\"" << oendl;
109 SF << "ABORT \"NO DIALTONE\"" << oendl; 109 SF << "ABORT \"NO DIALTONE\"" << oendl;
110 SF << "\"\" AT" << oendl; 110 SF << "\"\" AT" << oendl;
111 SF << "OK AT+CGATT=1" << oendl; 111 SF << "OK AT+CGATT=1" << oendl;
112 SF << "OK AT+CGDCONT=1,\"IP\",\"" 112 SF << "OK AT+CGDCONT=1,\"IP\",\""
113 << Data.APN 113 << Data.APN
114 << "\"" 114 << "\""
115 << oendl; 115 << oendl;
116 SF << "OK ATD*99***1#\\n" << oendl; 116 SF << "OK ATD*99***1#\\n" << oendl;
117 SF << "TIMEOUT 10" << oendl; 117 SF << "TIMEOUT 10" << oendl;
118 SF << "CONNECT \"\"" << oendl; 118 SF << "CONNECT \"\"" << oendl;
119 SF << "SAY \"READY\\n\"" << oendl; 119 SF << "SAY \"READY\\n\"" << oendl;
120 return 0; 120 return 0;
121 } else if( SF.name() == "peers" ) { 121 } else if( SF.name() == "peers" ) {
122 SF << "noauth" << oendl; 122 SF << "noauth" << oendl;
123 SF << "user " << Data.User << oendl; 123 SF << "user " << Data.User << oendl;
124 SF << "connect \"/usr/sbin/chat -s -v -f /etc/chatscripts/" 124 SF << "connect \"/usr/sbin/chat -s -v -f /etc/chatscripts/"
125 << removeSpaces( networkSetup()->name() ) 125 << removeSpaces( networkSetup()->name() )
126 << "\"" 126 << "\""
127 << oendl; 127 << oendl;
128 SF << "ipcp-accept-local" << oendl; 128 SF << "ipcp-accept-local" << oendl;
129 SF << "ipcp-accept-remote" << oendl; 129 SF << "ipcp-accept-remote" << oendl;
130 if( Data.DefaultGateway ) { 130 if( Data.DefaultGateway ) {
131 SF << "defaultroute" << oendl; 131 SF << "defaultroute" << oendl;
132 if( Data.SetIfSet ) { 132 if( Data.SetIfSet ) {
133 SF << "replacedefaultroute" << oendl; 133 SF << "replacedefaultroute" << oendl;
134 } 134 }
135 } 135 }
136 if( Data.Debug ) { 136 if( Data.Debug ) {
137 SF << "logfile /tmp/" 137 SF << "logfile /tmp/"
138 << removeSpaces( networkSetup()->name() ) 138 << removeSpaces( networkSetup()->name() )
139 << oendl; 139 << oendl;
140 for( int i = 0; i < Data.Debug; i ++ ) { 140 for( int i = 0; i < Data.Debug; i ++ ) {
141 SF << "debug" << oendl; 141 SF << "debug" << oendl;
142 } 142 }
143 } 143 }
144 SF << "nocrtscts" << oendl; 144 SF << "nocrtscts" << oendl;
145 SF << "local" << oendl; 145 SF << "local" << oendl;
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
210bool AGPRSDevice::openFile( SystemFile & SF ) { 210bool 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
8class GPRSNetNode; 8class GPRSNetNode;
9class GPRSEdit; 9class GPRSEdit;
10class SystemFile; 10class SystemFile;
11 11
12class AGPRSDevice : public ANetNodeInstance{ 12class AGPRSDevice : public ANetNodeInstance{
13 13
14public : 14public :
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
36protected : 37protected :
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
41private : 42private :
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
@@ -1,510 +1,510 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <unistd.h> 2#include <unistd.h>
3#include <errno.h> 3#include <errno.h>
4 4
5#include <opie2/odebug.h> 5#include <opie2/odebug.h>
6#include <opie2/oledbox.h> 6#include <opie2/oledbox.h>
7 7
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qlistbox.h> 9#include <qlistbox.h>
10#include <qlayout.h> 10#include <qlayout.h>
11#include <qgroupbox.h> 11#include <qgroupbox.h>
12#include <qtimer.h> 12#include <qtimer.h>
13#include <qlistbox.h> 13#include <qlistbox.h>
14#include <qmessagebox.h> 14#include <qmessagebox.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qiconview.h> 16#include <qiconview.h>
17#include <qtimer.h> 17#include <qtimer.h>
18#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
19#include <qtoolbutton.h> 19#include <qtoolbutton.h>
20#include <qevent.h> 20#include <qevent.h>
21 21
22#include "networksettings.h" 22#include "networksettings.h"
23#include "netnode.h" 23#include "netnode.h"
24#include "editconnection.h" 24#include "editconnection.h"
25 25
26NetworkSettings::NetworkSettings( QWidget *parent, 26NetworkSettings::NetworkSettings( QWidget *parent,
27 const char *name, 27 const char *name,
28 WFlags fl ) : NetworkSettingsGUI(parent,name,fl), 28 WFlags fl ) : NetworkSettingsGUI(parent,name,fl),
29 NSD() { 29 NSD() {
30 30
31 UpdateTimer = new QTimer( this ); 31 UpdateTimer = new QTimer( this );
32 32
33 // set pixmaps 33 // set pixmaps
34 Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); 34 Add_TB->setPixmap( NSResources->getPixmap( "add" ) );
35 Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) ); 35 Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) );
36 CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) ); 36 CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) );
37 GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) ); 37 GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) );
38 38
39 Disable_TB->setPixmap( NSResources->getPixmap( "disabled" ) ); 39 Disable_TB->setPixmap( NSResources->getPixmap( "disabled" ) );
40 Up_TB->setPixmap( NSResources->getPixmap( "more" ) ); 40 Up_TB->setPixmap( NSResources->getPixmap( "more" ) );
41 Down_TB->setPixmap( NSResources->getPixmap( "less" ) ); 41 Down_TB->setPixmap( NSResources->getPixmap( "less" ) );
42 42
43 QVBoxLayout* V = new QVBoxLayout( LED_Frm ); 43 QVBoxLayout* V = new QVBoxLayout( LED_Frm );
44 QHBoxLayout * H = new QHBoxLayout( 0 ); 44 QHBoxLayout * H = new QHBoxLayout( 0 );
45 V->addStretch(1); 45 V->addStretch(1);
46 V->addLayout( H ); 46 V->addLayout( H );
47 Leds[0] = new Opie::Ui::OLedBox( red, LED_Frm ); 47 Leds[0] = new Opie::Ui::OLedBox( red, LED_Frm );
48 H->addWidget( Leds[0], 0, Qt::AlignVCenter ); 48 H->addWidget( Leds[0], 0, Qt::AlignVCenter );
49 Leds[1] = new Opie::Ui::OLedBox( red, LED_Frm ); 49 Leds[1] = new Opie::Ui::OLedBox( red, LED_Frm );
50 H->addWidget( Leds[1], 0, Qt::AlignVCenter ); 50 H->addWidget( Leds[1], 0, Qt::AlignVCenter );
51 Leds[2] = new Opie::Ui::OLedBox( red, LED_Frm ); 51 Leds[2] = new Opie::Ui::OLedBox( red, LED_Frm );
52 H->addWidget( Leds[2], 0, Qt::AlignVCenter ); 52 H->addWidget( Leds[2], 0, Qt::AlignVCenter );
53 V->addStretch(1); 53 V->addStretch(1);
54 54
55 55
56 SLOT_ToProfile(); 56 SLOT_ToProfile();
57 57
58 // populate main Listbox 58 // populate main Listbox
59 Profiles_LB->clear(); 59 Profiles_LB->clear();
60 QPEApplication::setStylusOperation( 60 QPEApplication::setStylusOperation(
61 Profiles_LB->viewport(), QPEApplication::RightOnHold ); 61 Profiles_LB->viewport(), QPEApplication::RightOnHold );
62 62
63 connect( Profiles_LB, 63 connect( Profiles_LB,
64 SIGNAL(rightButtonPressed(QListBoxItem*,const QPoint&)), 64 SIGNAL(rightButtonPressed(QListBoxItem*,const QPoint&)),
65 this, SLOT(SLOT_EditNode(QListBoxItem*)) ); 65 this, SLOT(SLOT_EditNode(QListBoxItem*)) );
66 66
67 { Name2NetworkSetup_t & M = NSResources->networkSetups(); 67 { Name2NetworkSetup_t & M = NSResources->networkSetups();
68 NetworkSetup * NC; 68 NetworkSetup * NC;
69 // for all NetworkSetups 69 // for all NetworkSetups
70 for( QDictIterator<NetworkSetup> it(M); 70 for( QDictIterator<NetworkSetup> it(M);
71 it.current(); 71 it.current();
72 ++it ) { 72 ++it ) {
73 NC = it.current(); 73 NC = it.current();
74 Profiles_LB->insertItem( NC->devicePixmap(), 74 Profiles_LB->insertItem( NC->devicePixmap(),
75 NC->name() ); 75 NC->name() );
76 } 76 }
77 } 77 }
78 78
79 if( Profiles_LB->count() ) { 79 if( Profiles_LB->count() ) {
80 Profiles_LB->setSelected( 0, TRUE ); 80 Profiles_LB->setSelected( 0, TRUE );
81 } 81 }
82 82
83 // if no profiles -> auto popup editing 83 // if no profiles -> auto popup editing
84 if( NSResources->networkSetups().count() == 0 ) { 84 if( NSResources->networkSetups().count() == 0 ) {
85 QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) ); 85 QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) );
86 } 86 }
87 87
88 connect( &(NSResources->system()), 88 connect( &(NSResources->system()),
89 SIGNAL( stdoutLine(const QString &) ), 89 SIGNAL( stdoutLine(const QString &) ),
90 this, SLOT( SLOT_CmdMessage(const QString &) ) ); 90 this, SLOT( SLOT_CmdMessage(const QString &) ) );
91 91
92 connect( &(NSResources->system()), 92 connect( &(NSResources->system()),
93 SIGNAL( stderrLine(const QString &) ), 93 SIGNAL( stderrLine(const QString &) ),
94 this, SLOT( SLOT_CmdMessage(const QString &) ) ); 94 this, SLOT( SLOT_CmdMessage(const QString &) ) );
95 95
96 connect( &(NSResources->system()), 96 connect( &(NSResources->system()),
97 SIGNAL( processEvent(const QString &) ), 97 SIGNAL( processEvent(const QString &) ),
98 this, SLOT( SLOT_CmdMessage(const QString &) ) ); 98 this, SLOT( SLOT_CmdMessage(const QString &) ) );
99 99
100 UpdateTimer->start( 5000 ); 100 UpdateTimer->start( 5000 );
101 connect( UpdateTimer, SIGNAL( timeout() ), 101 connect( UpdateTimer, SIGNAL( timeout() ),
102 this, SLOT( SLOT_RefreshStates() ) ); 102 this, SLOT( SLOT_RefreshStates() ) );
103 103
104 /* Add QCopChannel */ 104 /* Add QCopChannel */
105 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), 105 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
106 this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) ); 106 this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) );
107} 107}
108 108
109NetworkSettings::~NetworkSettings() { 109NetworkSettings::~NetworkSettings() {
110 QString S; 110 QString S;
111 111
112 if( NSD.isModified() ) { 112 if( NSD.isModified() ) {
113 S = NSD.saveSettings(); 113 S = NSD.saveSettings();
114 if( ! S.isEmpty() ) { 114 if( ! S.isEmpty() ) {
115 S.insert( 0, "<p>" ); 115 S.insert( 0, "<p>" );
116 S.append( "</p>" ); 116 S.append( "</p>" );
117 // problem saving 117 // problem saving
118 QMessageBox::warning( 118 QMessageBox::warning(
119 0, 119 0,
120 tr( "Saving setup" ), S ); 120 tr( "Saving setup" ), S );
121 } 121 }
122 122
123 SLOT_GenerateConfig(); 123 SLOT_GenerateConfig();
124 NSD.setModified( 0 ); 124 NSD.setModified( 0 );
125 } 125 }
126 126
127} 127}
128 128
129void NetworkSettings::SLOT_CmdMessage( const QString & S ) { 129void NetworkSettings::SLOT_CmdMessage( const QString & S ) {
130 Messages_LB->insertItem( S ); 130 Messages_LB->insertItem( S );
131 Messages_LB->setCurrentItem( Messages_LB->count()-1 ); 131 Messages_LB->setCurrentItem( Messages_LB->count()-1 );
132 Messages_LB->ensureCurrentVisible(); 132 Messages_LB->ensureCurrentVisible();
133} 133}
134 134
135void NetworkSettings::SLOT_RefreshStates( void ) { 135void NetworkSettings::SLOT_RefreshStates( void ) {
136 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember 136 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember
137 137
138 if( LBI ) { 138 if( LBI ) {
139 NetworkSetup * NC; 139 NetworkSetup * NC;
140 NSResources->system().probeInterfaces(); 140 NSResources->system().probeInterfaces();
141 // update current selection only 141 // update current selection only
142 NC = NSResources->findNetworkSetup( LBI->text() ); 142 NC = NSResources->findNetworkSetup( LBI->text() );
143 if( NC ) { 143 if( NC ) {
144 State_t OldS = NC->state(); 144 State_t OldS = NC->state();
145 State_t NewS = NC->state(1); 145 State_t NewS = NC->state(1);
146 if( OldS != NewS ) { 146 if( OldS != NewS ) {
147 updateProfileState( LBI ); 147 updateProfileState( LBI );
148 } 148 }
149 } 149 }
150 } 150 }
151 151
152 152
153 /* -> LATER !! 153 /* -> LATER !!
154 bool is; 154 bool is;
155 NetworkSetup * NC; 155 NetworkSetup * NC;
156 156
157 for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) { 157 for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) {
158 NC = NSResources->findNetworkSetup( Profiles_LB->text(i) ); 158 NC = NSResources->findNetworkSetup( Profiles_LB->text(i) );
159 if( NC ) { 159 if( NC ) {
160 State_t OldS = NC->state(); 160 State_t OldS = NC->state();
161 State_t NewS = NC->state(1); 161 State_t NewS = NC->state(1);
162 if( OldS != NewS ) { 162 if( OldS != NewS ) {
163 is = Profiles_LB->isSelected(i); 163 is = Profiles_LB->isSelected(i);
164 Profiles_LB->changeItem( NC->statePixmap(NewS), 164 Profiles_LB->changeItem( NC->statePixmap(NewS),
165 NC->name(), 165 NC->name(),
166 i ); 166 i );
167 if( is ) { 167 if( is ) {
168 Profiles_LB->setSelected( i, TRUE ); 168 Profiles_LB->setSelected( i, TRUE );
169 } 169 }
170 } 170 }
171 } 171 }
172 } 172 }
173 if( ci >= 0 ) 173 if( ci >= 0 )
174 Profiles_LB->setCurrentItem( ci ); 174 Profiles_LB->setCurrentItem( ci );
175 */ 175 */
176} 176}
177 177
178void NetworkSettings::SLOT_AddNode( void ) { 178void NetworkSettings::SLOT_AddNode( void ) {
179 SLOT_EditNode( 0 ); 179 SLOT_EditNode( 0 );
180} 180}
181 181
182void NetworkSettings::SLOT_DeleteNode( void ) { 182void NetworkSettings::SLOT_DeleteNode( void ) {
183 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 183 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
184 184
185 if ( ! LBI ) 185 if ( ! LBI )
186 return; 186 return;
187 187
188 if( QMessageBox::warning( 188 if( QMessageBox::warning(
189 0, 189 0,
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
199void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { 199void 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
269void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { 269void 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 }
319 319
320 Up_TB->setEnabled( leds < 3 && leds != 0 ); 320 Up_TB->setEnabled( leds < 3 && leds != 0 );
321 Down_TB->setEnabled( leds > 0 ); 321 Down_TB->setEnabled( leds > 0 );
322} 322}
323 323
324void NetworkSettings::SLOT_CheckState( void ) { 324void NetworkSettings::SLOT_CheckState( void ) {
325 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 325 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
326 if ( ! LBI ) 326 if ( ! LBI )
327 return; 327 return;
328 updateProfileState( LBI ); 328 updateProfileState( LBI );
329} 329}
330 330
331void NetworkSettings::updateProfileState( QListBoxItem * LBI ) { 331void NetworkSettings::updateProfileState( QListBoxItem * LBI ) {
332 if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) { 332 if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) {
333 SLOT_ShowNode( LBI ); 333 SLOT_ShowNode( LBI );
334 } 334 }
335} 335}
336 336
337void NetworkSettings::SLOT_GenerateConfig( void ) { 337void NetworkSettings::SLOT_GenerateConfig( void ) {
338 QString S = NSD.generateSettings(); 338 QString S = NSD.generateSettings();
339 if( ! S.isEmpty() ) { 339 if( ! S.isEmpty() ) {
340 S.insert( 0, "<p>" ); 340 S.insert( 0, "<p>" );
341 S.append( "</p>" ); 341 S.append( "</p>" );
342 QMessageBox::warning( 342 QMessageBox::warning(
343 0, 343 0,
344 tr( "Generate config" ), 344 tr( "Generate config" ),
345 S); 345 S);
346 } 346 }
347} 347}
348 348
349void NetworkSettings::SLOT_Disable( bool T ) { 349void NetworkSettings::SLOT_Disable( bool T ) {
350 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 350 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
351 QString Msg; 351 QString Msg;
352 352
353 if ( ! LBI ) 353 if ( ! LBI )
354 return; 354 return;
355 355
356 NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() ); 356 NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() );
357 357
358 Log(( "Prepare to %sable\n", (T) ? "en" : "dis" )); 358 Log(( "Prepare to %sable\n", (T) ? "en" : "dis" ));
359 Msg = NC->setState( (T) ? Disable : Enable ); 359 Msg = NC->setState( (T) ? Disable : Enable );
360 if( ! Msg.isEmpty() ) { 360 if( ! Msg.isEmpty() ) {
361 Msg.insert( 0, "<p>" ); 361 Msg.insert( 0, "<p>" );
362 Msg.append( "</p>" ); 362 Msg.append( "</p>" );
363 QMessageBox::warning( 363 QMessageBox::warning(
364 0, 364 0,
365 tr( "Activating profile" ), 365 tr( "Activating profile" ),
366 Msg ); 366 Msg );
367 return; 367 return;
368 } 368 }
369 369
370 // reload new state 370 // reload new state
371 NC->state( true ); 371 NC->state( true );
372 updateProfileState( LBI ); 372 updateProfileState( LBI );
373} 373}
374 374
375void NetworkSettings::SLOT_Up( void ) { 375void NetworkSettings::SLOT_Up( void ) {
376 // bring more up 376 // bring more up
377 377
378 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 378 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
379 QString Msg; 379 QString Msg;
380 int led = -1; 380 int led = -1;
381 381
382 if ( ! LBI ) 382 if ( ! LBI )
383 return; 383 return;
384 384
385 NetworkSetup * NC = 385 NetworkSetup * NC =
386 NSResources->findNetworkSetup( LBI->text() ); 386 NSResources->findNetworkSetup( LBI->text() );
387 387
388 switch( NC->state() ) { 388 switch( NC->state() ) {
389 case Disabled : // cannot modify this state 389 case Disabled : // cannot modify this state
390 case Unknown : // cannot modify this state 390 case Unknown : // cannot modify this state
391 case Unchecked : // cannot modify this state 391 case Unchecked : // cannot modify this state
392 case Unavailable : // cannot modify this state 392 case Unavailable : // cannot modify this state
393 case IsUp : // highest UP state 393 case IsUp : // highest UP state
394 return; 394 return;
395 case Off : // -> activate 395 case Off : // -> activate
396 led = 1; 396 led = 1;
397 Down_TB->setEnabled( true ); 397 Down_TB->setEnabled( true );
398 Log(( "Activate interface %s\n", NC->name().latin1() )); 398 Log(( "Activate interface %s\n", NC->name().latin1() ));
399 Msg = NC->setState( Activate ); 399 Msg = NC->setState( Activate );
400 break; 400 break;
401 case Available : // -> up 401 case Available : // -> up
402 led = 2; 402 led = 2;
403 Log(( "Bring up interface %s\n", NC->name().latin1() )); 403 Log(( "Bring up interface %s\n", NC->name().latin1() ));
404 Msg = NC->setState( Up ); 404 Msg = NC->setState( Up );
405 if( Msg.isEmpty() ) { 405 if( Msg.isEmpty() ) {
406 Up_TB->setEnabled( false ); 406 Up_TB->setEnabled( false );
407 } 407 }
408 break; 408 break;
409 } 409 }
410 410
411 if( ! Msg.isEmpty() ) { 411 if( ! Msg.isEmpty() ) {
412 Msg.insert( 0, "<p>" ); 412 Msg.insert( 0, "<p>" );
413 Msg.append( "</p>" ); 413 Msg.append( "</p>" );
414 QMessageBox::warning( 414 QMessageBox::warning(
415 0, 415 0,
416 tr( "Increase availability" ), 416 tr( "Increase availability" ),
417 Msg ); 417 Msg );
418 return; 418 return;
419 } 419 }
420 420
421 updateProfileState( LBI ); 421 updateProfileState( LBI );
422 422
423 // set color of led we should change 423 // set color of led we should change
424 if( led > 0 ) { 424 if( led > 0 ) {
425 Leds[led]->setColor( blue ); 425 Leds[led]->setColor( blue );
426 Leds[led]->setOn( true ); 426 Leds[led]->setOn( true );
427 } 427 }
428 428
429} 429}
430 430
431void NetworkSettings::SLOT_Down( void ) { 431void NetworkSettings::SLOT_Down( void ) {
432 // bring more down 432 // bring more down
433 433
434 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 434 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
435 int led = -1; 435 int led = -1;
436 QString Msg; 436 QString Msg;
437 437
438 if ( ! LBI ) 438 if ( ! LBI )
439 return; 439 return;
440 440
441 NetworkSetup * NC = 441 NetworkSetup * NC =
442 NSResources->findNetworkSetup( LBI->text() ); 442 NSResources->findNetworkSetup( LBI->text() );
443 443
444 switch( NC->state() ) { 444 switch( NC->state() ) {
445 case Disabled : // cannot modify this state 445 case Disabled : // cannot modify this state
446 case Unknown : // cannot modify this state 446 case Unknown : // cannot modify this state
447 case Unchecked : // cannot modify this state 447 case Unchecked : // cannot modify this state
448 case Unavailable : // cannot modify this state 448 case Unavailable : // cannot modify this state
449 case Off : // highest DOWN state 449 case Off : // highest DOWN state
450 break; 450 break;
451 case Available : // -> down 451 case Available : // -> down
452 led = 0; 452 led = 0;
453 Log(( "Deactivate interface %s\n", NC->name().latin1() )); 453 Log(( "Deactivate interface %s\n", NC->name().latin1() ));
454 Msg = NC->setState( Deactivate ); 454 Msg = NC->setState( Deactivate );
455 Down_TB->setEnabled( false ); 455 Down_TB->setEnabled( false );
456 break; 456 break;
457 case IsUp : // highest UP state 457 case IsUp : // highest UP state
458 led = 1; 458 led = 1;
459 Up_TB->setEnabled( true ); 459 Up_TB->setEnabled( true );
460 Log(( "Bring down interface %s\n", NC->name().latin1() )); 460 Log(( "Bring down interface %s\n", NC->name().latin1() ));
461 Msg = NC->setState( Down, 1 ); 461 Msg = NC->setState( Down, 1 );
462 if( Msg.isEmpty() ) { 462 if( Msg.isEmpty() ) {
463 // remove 'up' file to make sure 463 // remove 'up' file to make sure
464 unlink ( QString().sprintf( "/tmp/Profile-%d.up", NC->number() ).latin1() );; 464 unlink ( QString().sprintf( "/tmp/Profile-%d.up", NC->number() ).latin1() );;
465 } 465 }
466 break; 466 break;
467 } 467 }
468 468
469 if( ! Msg.isEmpty() ) { 469 if( ! Msg.isEmpty() ) {
470 Msg.insert( 0, "<p>" ); 470 Msg.insert( 0, "<p>" );
471 Msg.append( "</p>" ); 471 Msg.append( "</p>" );
472 QMessageBox::warning( 472 QMessageBox::warning(
473 0, 473 0,
474 tr( "Decrease availability" ), 474 tr( "Decrease availability" ),
475 Msg ); 475 Msg );
476 return; 476 return;
477 } 477 }
478 478
479 updateProfileState( LBI ); 479 updateProfileState( LBI );
480 480
481 // set color of led we should change 481 // set color of led we should change
482 if( led >= 0 ) { 482 if( led >= 0 ) {
483 Leds[led]->setColor( blue ); 483 Leds[led]->setColor( blue );
484 } 484 }
485} 485}
486 486
487void NetworkSettings::SLOT_ToMessages( void ) { 487void NetworkSettings::SLOT_ToMessages( void ) {
488 Profiles_LB->hide(); 488 Profiles_LB->hide();
489 Profile_GB->hide(); 489 Profile_GB->hide();
490 Messages_GB->show(); 490 Messages_GB->show();
491} 491}
492 492
493void NetworkSettings::SLOT_ToProfile( void ) { 493void NetworkSettings::SLOT_ToProfile( void ) {
494 Profiles_LB->show(); 494 Profiles_LB->show();
495 Profile_GB->show(); 495 Profile_GB->show();
496 Messages_GB->hide(); 496 Messages_GB->hide();
497} 497}
498 498
499void NetworkSettings::SLOT_QCopMessage(const QCString &msg, const QByteArray &data) { 499void NetworkSettings::SLOT_QCopMessage(const QCString &msg, const QByteArray &data) {
500 QDataStream stream( data, IO_ReadOnly ); 500 QDataStream stream( data, IO_ReadOnly );
501 501
502 if( msg == "raise" ) { 502 if( msg == "raise" ) {
503 raise(); 503 raise();
504 return; 504 return;
505 } /* if ( msg == "someMessage(int,int,int)" ) { 505 } /* if ( msg == "someMessage(int,int,int)" ) {
506 int a,b,c; 506 int a,b,c;
507 stream >> a >> b >> c; 507 stream >> a >> b >> c;
508 ... 508 ...
509 } */ 509 } */
510} 510}
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
@@ -1,528 +1,531 @@
1#include <time.h> 1#include <time.h>
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4 4
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qbitmap.h> 6#include <qbitmap.h>
7#include <qtextstream.h> 7#include <qtextstream.h>
8#include <qpixmap.h> 8#include <qpixmap.h>
9 9
10#include "resources.h" 10#include "resources.h"
11#include "netnode.h" 11#include "netnode.h"
12 12
13static char * ActionName[] = { 13static char * ActionName[] = {
14 "Disable", 14 "Disable",
15 "Enable", 15 "Enable",
16 "Activate", 16 "Activate",
17 "Deactivate", 17 "Deactivate",
18 "Up", 18 "Up",
19 "Down" 19 "Down"
20}; 20};
21 21
22static char * StateName[] = { 22static char * StateName[] = {
23 "Unchecked", 23 "Unchecked",
24 "Unknown", 24 "Unknown",
25 "Unavailable", 25 "Unavailable",
26 "Disabled", 26 "Disabled",
27 "Off", 27 "Off",
28 "Available", 28 "Available",
29 "IsUp" 29 "IsUp"
30}; 30};
31 31
32QString & deQuote( QString & X ) { 32QString & 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
50QString quote( QString X ) { 50QString 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
73void ANetNode::saveAttributes( QTextStream & TS ) { 73void ANetNode::saveAttributes( QTextStream & TS ) {
74 saveSpecificAttribute( TS ); 74 saveSpecificAttribute( TS );
75} 75}
76 76
77void ANetNode::setAttribute( QString & Attr, QString & Value ){ 77void ANetNode::setAttribute( QString & Attr, QString & Value ){
78 setSpecificAttribute( Attr, Value ); 78 setSpecificAttribute( Attr, Value );
79} 79}
80 80
81bool ANetNode::isToplevel( void ) { 81bool 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
91bool ANetNode::openFile( SystemFile & SF, 91bool 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
102long ANetNodeInstance::InstanceCounter = -1; 103long ANetNodeInstance::InstanceCounter = -1;
103 104
104void ANetNodeInstance::initialize( void ) { 105void 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
114void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ 115void 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
122void ANetNodeInstance::saveAttributes( QTextStream & TS ) { 123void ANetNodeInstance::saveAttributes( QTextStream & TS ) {
123 TS << "__name=" << name() << endl; 124 TS << "__name=" << name() << endl;
124 saveSpecificAttribute( TS ); 125 saveSpecificAttribute( TS );
125} 126}
126 127
127ANetNodeInstance * ANetNodeInstance::nextNode( void ) { 128ANetNodeInstance * 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
137NetworkSetup::NetworkSetup( void ) : QList<ANetNodeInstance>() { 138NetworkSetup::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
148NetworkSetup::NetworkSetup( QTextStream & TS, bool & Dangling ) : 149NetworkSetup::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="";
158 IsNew = 0; 159 IsNew = 0;
159 AssignedInterface = 0; 160 AssignedInterface = 0;
160 CurrentState = Unchecked; 161 CurrentState = Unchecked;
161 162
162 Dangling = 0; // by default node collection is ok 163 Dangling = 0; // by default node collection is ok
163 164
164 do { 165 do {
165 S = TS.readLine(); 166 S = TS.readLine();
166 if( S.isEmpty() ) { 167 if( S.isEmpty() ) {
167 // empty line 168 // empty line
168 break; 169 break;
169 } 170 }
170 171
171 idx = S.find('='); 172 idx = S.find('=');
172 S.stripWhiteSpace(); 173 S.stripWhiteSpace();
173 A = S.left( idx ); 174 A = S.left( idx );
174 A.lower(); 175 A.lower();
175 N = S.mid( idx+1, S.length() ); 176 N = S.mid( idx+1, S.length() );
176 N.stripWhiteSpace(); 177 N.stripWhiteSpace();
177 N = deQuote( N ); 178 N = deQuote( N );
178 179
179 if( A == "name" ) { 180 if( A == "name" ) {
180 Name = N; 181 Name = N;
181 } else if( A == "number" ) { 182 } else if( A == "number" ) {
182 setNumber( N.toLong() ); 183 setNumber( N.toLong() );
183 } else if( A == "node" ) { 184 } else if( A == "node" ) {
184 ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); 185 ANetNodeInstance * NNI = NSResources->findNodeInstance( N );
185 Log(( "Find node %s : %p\n", N.latin1(), NNI )); 186 Log(( "Find node %s : %p\n", N.latin1(), NNI ));
186 if( NNI ) { 187 if( NNI ) {
187 append( NNI ); 188 append( NNI );
188 } else { 189 } else {
189 // could not find a node type -> collection invalid 190 // could not find a node type -> collection invalid
190 Log(( "Node %s missing -> NetworkSetup dangling\n", 191 Log(( "Node %s missing -> NetworkSetup dangling\n",
191 N.latin1() )); 192 N.latin1() ));
192 // create placeholder for this dangling NNI 193 // create placeholder for this dangling NNI
193 NNI = new ErrorNNI( N ); 194 NNI = new ErrorNNI( N );
194 Dangling = 1; 195 Dangling = 1;
195 } 196 }
196 } 197 }
197 } while( 1 ); 198 } while( 1 );
198 199
199 Log(( "Profile number %s : %d nodes\n", 200 Log(( "Profile number %s : %d nodes\n",
200 Name.latin1(), count() )); 201 Name.latin1(), count() ));
201} 202}
202 203
203NetworkSetup::~NetworkSetup( void ) { 204NetworkSetup::~NetworkSetup( void ) {
204} 205}
205 206
206const QString & NetworkSetup::description( void ) { 207const QString & NetworkSetup::description( void ) {
207 ANetNodeInstance * NNI = getToplevel(); 208 ANetNodeInstance * NNI = getToplevel();
208 return (NNI) ? NNI->runtime()->description() : Name; 209 return (NNI) ? NNI->runtime()->description() : Name;
209} 210}
210 211
211void NetworkSetup::append( ANetNodeInstance * NNI ) { 212void NetworkSetup::append( ANetNodeInstance * NNI ) {
212 NNI->setNetworkSetup( this ); 213 NNI->setNetworkSetup( this );
213 QList<ANetNodeInstance>::append( NNI ); 214 QList<ANetNodeInstance>::append( NNI );
214} 215}
215 216
216void NetworkSetup::save( QTextStream & TS ) { 217void NetworkSetup::save( QTextStream & TS ) {
217 218
218 TS << "name=" << quote( Name ) << endl; 219 TS << "name=" << quote( Name ) << endl;
219 TS << "number=" << number() << endl; 220 TS << "number=" << number() << endl;
220 ANetNodeInstance * NNI; 221 ANetNodeInstance * NNI;
221 for( QListIterator<ANetNodeInstance> it(*this); 222 for( QListIterator<ANetNodeInstance> it(*this);
222 it.current(); 223 it.current();
223 ++it ) { 224 ++it ) {
224 NNI = it.current(); 225 NNI = it.current();
225 TS << "node=" << NNI->name() << endl; 226 TS << "node=" << NNI->name() << endl;
226 } 227 }
227 TS << endl; 228 TS << endl;
228 IsNew = 0; 229 IsNew = 0;
229} 230}
230 231
231ANetNodeInstance * NetworkSetup::getToplevel( void ) { 232ANetNodeInstance * NetworkSetup::getToplevel( void ) {
232 ANetNodeInstance * NNI = 0; 233 ANetNodeInstance * NNI = 0;
233 for( QListIterator<ANetNodeInstance> it(*this); 234 for( QListIterator<ANetNodeInstance> it(*this);
234 it.current(); 235 it.current();
235 ++it ) { 236 ++it ) {
236 NNI = it.current(); 237 NNI = it.current();
237 if( NNI->nodeClass()->isToplevel() ) { 238 if( NNI->nodeClass()->isToplevel() ) {
238 return NNI; 239 return NNI;
239 } 240 }
240 } 241 }
241 return 0; 242 return 0;
242} 243}
243 244
244ANetNodeInstance * NetworkSetup::findByName( const QString & S ) { 245ANetNodeInstance * NetworkSetup::findByName( const QString & S ) {
245 ANetNodeInstance * NNI = 0; 246 ANetNodeInstance * NNI = 0;
246 for( QListIterator<ANetNodeInstance> it(*this); 247 for( QListIterator<ANetNodeInstance> it(*this);
247 it.current(); 248 it.current();
248 ++it ) { 249 ++it ) {
249 NNI = it.current(); 250 NNI = it.current();
250 if( NNI->name() == S ) { 251 if( NNI->name() == S ) {
251 return NNI; 252 return NNI;
252 } 253 }
253 } 254 }
254 return 0; 255 return 0;
255} 256}
256 257
257ANetNodeInstance * NetworkSetup::findNext( ANetNodeInstance * NNI ) { 258ANetNodeInstance * NetworkSetup::findNext( ANetNodeInstance * NNI ) {
258 ANetNodeInstance * NNNI; 259 ANetNodeInstance * NNNI;
259 260
260 if( ! NNI ) 261 if( ! NNI )
261 getToplevel(); 262 getToplevel();
262 263
263 for( QListIterator<ANetNodeInstance> it(*this); 264 for( QListIterator<ANetNodeInstance> it(*this);
264 it.current(); 265 it.current();
265 ++it ) { 266 ++it ) {
266 NNNI = it.current(); 267 NNNI = it.current();
267 if( NNNI == NNI ) { 268 if( NNNI == NNI ) {
268 ++it; 269 ++it;
269 return it.current(); 270 return it.current();
270 } 271 }
271 } 272 }
272 return 0; // no more next 273 return 0; // no more next
273} 274}
274 275
275int NetworkSetup::compareItems( QCollection::Item I1, 276int NetworkSetup::compareItems( QCollection::Item I1,
276 QCollection::Item I2 ) { 277 QCollection::Item I2 ) {
277 ANetNodeInstance * NNI1, * NNI2; 278 ANetNodeInstance * NNI1, * NNI2;
278 NNI1 = (ANetNodeInstance *)I1; 279 NNI1 = (ANetNodeInstance *)I1;
279 NNI2 = (ANetNodeInstance *)I2; 280 NNI2 = (ANetNodeInstance *)I2;
280 return strcmp( NNI1->name(), NNI2->name() ); 281 return strcmp( NNI1->name(), NNI2->name() );
281} 282}
282 283
283static char * State2PixmapTbl[] = { 284static char * State2PixmapTbl[] = {
284 "NULL", // Unchecked : no pixmap 285 "NULL", // Unchecked : no pixmap
285 "check", // Unknown 286 "check", // Unknown
286 "delete", // unavailable 287 "delete", // unavailable
287 "disabled", // disabled 288 "disabled", // disabled
288 "off", // off 289 "off", // off
289 "disconnected", // available 290 "disconnected", // available
290 "connected" // up 291 "connected" // up
291}; 292};
292 293
293QPixmap NetworkSetup::devicePixmap( void ) { 294QPixmap NetworkSetup::devicePixmap( void ) {
294 QPixmap pm = NSResources->getPixmap( 295 QPixmap pm = NSResources->getPixmap(
295 getToplevel()->nextNode()->pixmapName()+"-large"); 296 getToplevel()->nextNode()->pixmapName()+"-large");
296 297
297 QPixmap Mini = NSResources->getPixmap( 298 QPixmap Mini = NSResources->getPixmap(
298 device()->netNode()->pixmapName() ); 299 device()->netNode()->pixmapName() );
299 300
300 if( pm.isNull() || Mini.isNull() ) 301 if( pm.isNull() || Mini.isNull() )
301 return Resource::loadPixmap("Unknown"); 302 return Resource::loadPixmap("Unknown");
302 303
303 QPainter painter( &pm ); 304 QPainter painter( &pm );
304 painter.drawPixmap( pm.width()-Mini.width(), 305 painter.drawPixmap( pm.width()-Mini.width(),
305 pm.height()-Mini.height(), 306 pm.height()-Mini.height(),
306 Mini ); 307 Mini );
307 pm.setMask( pm.createHeuristicMask( TRUE ) ); 308 pm.setMask( pm.createHeuristicMask( TRUE ) );
308 return pm; 309 return pm;
309} 310}
310 311
311QPixmap NetworkSetup::statePixmap( State_t S) { 312QPixmap NetworkSetup::statePixmap( State_t S) {
312 return NSResources->getPixmap( State2PixmapTbl[S] ); 313 return NSResources->getPixmap( State2PixmapTbl[S] );
313} 314}
314 315
315QString NetworkSetup::stateName( State_t S) { 316QString NetworkSetup::stateName( State_t S) {
316 switch( S ) { 317 switch( S ) {
317 case Unknown : 318 case Unknown :
318 return qApp->translate( "networksettings2", "Unknown"); 319 return qApp->translate( "networksettings2", "Unknown");
319 case Unavailable : 320 case Unavailable :
320 return qApp->translate( "networksettings2", "Unavailable"); 321 return qApp->translate( "networksettings2", "Unavailable");
321 case Disabled : 322 case Disabled :
322 return qApp->translate( "networksettings2", "Disabled"); 323 return qApp->translate( "networksettings2", "Disabled");
323 case Off : 324 case Off :
324 return qApp->translate( "networksettings2", "Inactive"); 325 return qApp->translate( "networksettings2", "Inactive");
325 case Available : 326 case Available :
326 return qApp->translate( "networksettings2", "Available"); 327 return qApp->translate( "networksettings2", "Available");
327 case IsUp : 328 case IsUp :
328 return qApp->translate( "networksettings2", "Up"); 329 return qApp->translate( "networksettings2", "Up");
329 case Unchecked : /* FT */ 330 case Unchecked : /* FT */
330 default : 331 default :
331 break; 332 break;
332 } 333 }
333 return QString(""); 334 return QString("");
334} 335}
335 336
336void NetworkSetup::reassign( void ) { 337void NetworkSetup::reassign( void ) {
337 for( QListIterator<ANetNodeInstance> it(*this); 338 for( QListIterator<ANetNodeInstance> it(*this);
338 it.current(); 339 it.current();
339 ++it ) { 340 ++it ) {
340 it.current()->setNetworkSetup( this ); 341 it.current()->setNetworkSetup( this );
341 } 342 }
342} 343}
343 344
344const QStringList & NetworkSetup::triggers() { 345const QStringList & NetworkSetup::triggers() {
345 return getToplevel()->runtime()->triggers(); 346 return getToplevel()->runtime()->triggers();
346} 347}
347 348
348bool NetworkSetup::hasDataForFile( SystemFile & S ) { 349bool NetworkSetup::hasDataForFile( SystemFile & S ) {
349 return ( firstWithDataForFile( S ) != 0 ); 350 return ( firstWithDataForFile( S ) != 0 );
350} 351}
351 352
352ANetNodeInstance * NetworkSetup::firstWithDataForFile( SystemFile & S ) { 353ANetNodeInstance * 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
363State_t NetworkSetup::state( bool Update ) { 364State_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
398QString NetworkSetup::setState( Action_t A, bool Force ) { 399QString 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;
478 break; 481 break;
479 } 482 }
480 483
481 // send actions to all nodes 484 // send actions to all nodes
482 Log(( "Action %s requires %d steps\n", 485 Log(( "Action %s requires %d steps\n",
483 ActionName[A], NoOfActions )); 486 ActionName[A], NoOfActions ));
484 487
485 for( int i = 0 ; i < NoOfActions; i ++ ) { 488 for( int i = 0 ; i < NoOfActions; i ++ ) {
486 // setState recurses through the tree depth first 489 // setState recurses through the tree depth first
487 msg = getToplevel()->runtime()->setState( this, Actions[i], Force ); 490 msg = getToplevel()->runtime()->setState( this, Actions[i], Force );
488 if( ! msg.isEmpty() ) { 491 if( ! msg.isEmpty() ) {
489 return msg; 492 return msg;
490 } 493 }
491 } 494 }
492 return QString(); 495 return QString();
493} 496}
494 497
495void NetworkSetup::copyFrom( const NetworkSetup & N ) { 498void NetworkSetup::copyFrom( const NetworkSetup & N ) {
496 Number = N.Number; 499 Number = N.Number;
497 CurrentState = N.CurrentState; 500 CurrentState = N.CurrentState;
498 Name = N.Name; 501 Name = N.Name;
499 IsNew = N.IsNew; 502 IsNew = N.IsNew;
500 Index = N.Index; 503 Index = N.Index;
501 AssignedInterface = N.AssignedInterface; 504 AssignedInterface = N.AssignedInterface;
502} 505}
503 506
504// 507//
505// 508//
506// RuntimeInfo 509// RuntimeInfo
507// 510//
508// 511//
509 512
510QString RuntimeInfo::setState( NetworkSetup * NC, 513QString RuntimeInfo::setState( NetworkSetup * NC,
511 Action_t A, 514 Action_t A,
512 bool Force ) { 515 bool Force ) {
513 QString M; 516 QString M;
514 RuntimeInfo * Deeper = nextNode(); 517 RuntimeInfo * Deeper = nextNode();
515 518
516 if( Deeper ) { 519 if( Deeper ) {
517 // first go deeper 520 // first go deeper
518 M = Deeper->setState( NC, A, Force ); 521 M = Deeper->setState( NC, A, Force );
519 if( ! M.isEmpty() ) 522 if( ! M.isEmpty() )
520 return M; 523 return M;
521 } 524 }
522 525
523 // set my own state 526 // set my own state
524 Log (( "-> Act upon %s\n", netNode()->name() )); 527 Log (( "-> Act upon %s\n", netNode()->name() ));
525 M = setMyState( NC, A, Force ); 528 M = setMyState( NC, A, Force );
526 Log (( " result %s\n", M.latin1() )); 529 Log (( " result %s\n", M.latin1() ));
527 return M; 530 return M;
528} 531}
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
@@ -1,641 +1,647 @@
1#ifndef NETNODE_H 1#ifndef NETNODE_H
2#define NETNODE_H 2#define NETNODE_H
3 3
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qlist.h> 5#include <qlist.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qstringlist.h> 8#include <qstringlist.h>
9#include <qobject.h> 9#include <qobject.h>
10#include <time.h> 10#include <time.h>
11 11
12#include <Utils.h> 12#include <Utils.h>
13#include <system.h> 13#include <system.h>
14 14
15// difference feature interfaces 15// difference feature interfaces
16class AsDevice; 16class AsDevice;
17class AsLine; 17class AsLine;
18class AsNetworkSetup; 18class AsNetworkSetup;
19class AsFullSetup; 19class AsFullSetup;
20 20
21// needed for plugin creation function 21// needed for plugin creation function
22#include <qlist.h> 22#include <qlist.h>
23 23
24class ANetNode; 24class ANetNode;
25class ANetNodeInstance; 25class ANetNodeInstance;
26class NetworkSetup; 26class NetworkSetup;
27class QTextStream; 27class QTextStream;
28class RuntimeInfo; 28class RuntimeInfo;
29class InterfaceInfo; 29class InterfaceInfo;
30class NSResources; 30class NSResources;
31 31
32extern QString & deQuote( QString & X ); 32extern QString & deQuote( QString & X );
33extern QString quote( QString X ); 33extern QString quote( QString X );
34 34
35#include "systemfile.h" 35#include "systemfile.h"
36 36
37typedef enum State { 37typedef enum State {
38 // if we have not yet detected the state of the device 38 // if we have not yet detected the state of the device
39 Unchecked = 0, 39 Unchecked = 0,
40 // if we cannot determine the state 40 // if we cannot determine the state
41 Unknown = 1, 41 Unknown = 1,
42 // if networkSetup cannot be established e.g. because 42 // if networkSetup cannot be established e.g. because
43 // the hardware is not available 43 // the hardware is not available
44 Unavailable = 2, 44 Unavailable = 2,
45 // if the networkSetup cannot be establishec but NOT 45 // if the networkSetup cannot be establishec but NOT
46 // because it is physically impossible but because 46 // because it is physically impossible but because
47 // it has been disabled for FUNCTIONAL reasons 47 // it has been disabled for FUNCTIONAL reasons
48 Disabled = 3, 48 Disabled = 3,
49 // if networkSetup is available to is currently down 49 // if networkSetup is available to is currently down
50 // i.e. the corresponding hardware is not activated 50 // i.e. the corresponding hardware is not activated
51 Off = 4, 51 Off = 4,
52 // if networkSetup is available to be used (i.e. the 52 // if networkSetup is available to be used (i.e. the
53 // devices if fully ready to be used 53 // devices if fully ready to be used
54 Available = 5, 54 Available = 5,
55 // if networkSetup is being used 55 // if networkSetup is being used
56 IsUp = 6 56 IsUp = 6
57} State_t; 57} State_t;
58 58
59typedef enum Action { 59typedef 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
74class ANetNode : public QObject { 74class ANetNode : public QObject {
75 75
76public: 76public:
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
182protected : 187protected :
183 188
184 NetNodeList * Alternatives; 189 NetNodeList * Alternatives;
185 190
186private : 191private :
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
192}; 197};
193 198
194class ANetNodeInstance : public QObject { 199class ANetNodeInstance : public QObject {
195 200
196public: 201public:
197 202
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
312protected : 318protected :
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
327 static long InstanceCounter; 333 static long InstanceCounter;
328}; 334};
329 335
330class ErrorNNI: public ANetNodeInstance { 336class ErrorNNI: public ANetNodeInstance {
331 337
332public: 338public:
333 339
334 ErrorNNI( const QString & _Name ) : ANetNodeInstance( 0 ) { 340 ErrorNNI( const QString & _Name ) : ANetNodeInstance( 0 ) {
335 setName( _Name.latin1() ); 341 setName( _Name.latin1() );
336 } 342 }
337 343
338 RuntimeInfo * runtime( void ) { 344 RuntimeInfo * runtime( void ) {
339 return 0; 345 return 0;
340 } 346 }
341 347
342 // create edit widget under parent 348 // create edit widget under parent
343 QWidget * edit( QWidget * parent ) { 349 QWidget * edit( QWidget * parent ) {
344 return 0; 350 return 0;
345 } 351 }
346 352
347 // is given data acceptable 353 // is given data acceptable
348 QString acceptable( void ) { 354 QString acceptable( void ) {
349 return QString(); 355 return QString();
350 } 356 }
351 357
352 // get data from GUI and store in node 358 // get data from GUI and store in node
353 void commit( void ) { 359 void commit( void ) {
354 } 360 }
355 361
356 // returns node specific data -> only useful for 'buddy' 362 // returns node specific data -> only useful for 'buddy'
357 void * data( void ) { 363 void * data( void ) {
358 return 0; 364 return 0;
359 } 365 }
360 366
361protected : 367protected :
362 368
363 void setSpecificAttribute( QString & , QString & ) { 369 void setSpecificAttribute( QString & , QString & ) {
364 } 370 }
365 371
366 void saveSpecificAttribute( QTextStream & ) { 372 void saveSpecificAttribute( QTextStream & ) {
367 } 373 }
368}; 374};
369 375
370class RuntimeInfo : public QObject { 376class RuntimeInfo : public QObject {
371 377
372 Q_OBJECT 378 Q_OBJECT
373 379
374public : 380public :
375 381
376 RuntimeInfo( ANetNodeInstance * TheNNI ) 382 RuntimeInfo( ANetNodeInstance * TheNNI )
377 { NNI = TheNNI; } 383 { NNI = TheNNI; }
378 384
379 // 385 //
380 // 386 //
381 // methods to be overloaded by networkSetup capable 387 // methods to be overloaded by networkSetup capable
382 // runtimes 388 // runtimes
383 // 389 //
384 // 390 //
385 391
386 392
387 // 393 //
388 // 394 //
389 // methods to be overloaded by device capable 395 // methods to be overloaded by device capable
390 // runtimes 396 // runtimes
391 // 397 //
392 // 398 //
393 399
394 // does this node handles this interface e.g.eth0 400 // does this node handles this interface e.g.eth0
395 // recurse deeper if this node cannot answer that question 401 // recurse deeper if this node cannot answer that question
396 virtual bool handlesInterface( const QString & S ) { 402 virtual bool handlesInterface( const QString & S ) {
397 RuntimeInfo * RI = device(); 403 RuntimeInfo * RI = device();
398 if( RI ) { 404 if( RI ) {
399 return RI->handlesInterface( S ); 405 return RI->handlesInterface( S );
400 } 406 }
401 return 0; 407 return 0;
402 } 408 }
403 bool handlesInterface( const InterfaceInfo & I ) { 409 bool handlesInterface( const InterfaceInfo & I ) {
404 RuntimeInfo * RI = device(); 410 RuntimeInfo * RI = device();
405 if( RI ) { 411 if( RI ) {
406 return RI->handlesInterface( I ); 412 return RI->handlesInterface( I );
407 } 413 }
408 return 0; 414 return 0;
409 } 415 }
410 416
411 // 417 //
412 // 418 //
413 // methods to be overloaded by full setup capable 419 // methods to be overloaded by full setup capable
414 // runtimes 420 // runtimes
415 // 421 //
416 // 422 //
417 423
418 // return description for this full setup 424 // return description for this full setup
419 virtual const QString & description( void ) { 425 virtual const QString & description( void ) {
420 return fullSetup()->description( ); 426 return fullSetup()->description( );
421 } 427 }
422 // return triggers that should fire when this 428 // return triggers that should fire when this
423 // setup is brought up 429 // setup is brought up
424 virtual const QStringList & triggers( void ) { 430 virtual const QStringList & triggers( void ) {
425 return fullSetup()->triggers( ); 431 return fullSetup()->triggers( );
426 } 432 }
427 433
428 // 434 //
429 // 435 //
430 // methods to be overloaded by line capable 436 // methods to be overloaded by line capable
431 // runtimes 437 // runtimes
432 // 438 //
433 // 439 //
434 440
435 // return the device file ('/dev/xxx') created 441 // return the device file ('/dev/xxx') created
436 // by this line capable runtime 442 // by this line capable runtime
437 virtual QString deviceFile( void ) { 443 virtual QString deviceFile( void ) {
438 RuntimeInfo * RI = line(); 444 RuntimeInfo * RI = line();
439 if( RI ) { 445 if( RI ) {
440 return RI->deviceFile(); 446 return RI->deviceFile();
441 } 447 }
442 return QString(); 448 return QString();
443 } 449 }
444 450
445 // 451 //
446 // 452 //
447 // runtime interface 453 // runtime interface
448 // 454 //
449 // 455 //
450 456
451 // return the node that offers device capability 457 // return the node that offers device capability
452 virtual RuntimeInfo * device( void ) 458 virtual RuntimeInfo * device( void )
453 { RuntimeInfo * RI = nextNode(); 459 { RuntimeInfo * RI = nextNode();
454 return (RI) ? RI->device() : 0; 460 return (RI) ? RI->device() : 0;
455 } 461 }
456 462
457 // return the node that offers connection capability 463 // return the node that offers connection capability
458 virtual RuntimeInfo * connection( void ) 464 virtual RuntimeInfo * connection( void )
459 { RuntimeInfo * RI = nextNode(); 465 { RuntimeInfo * RI = nextNode();
460 return (RI) ? RI->connection() : 0; 466 return (RI) ? RI->connection() : 0;
461 } 467 }
462 468
463 // return the node that offers line capability 469 // return the node that offers line capability
464 virtual RuntimeInfo * line( void ) 470 virtual RuntimeInfo * line( void )
465 { RuntimeInfo * RI = nextNode(); 471 { RuntimeInfo * RI = nextNode();
466 return (RI) ? RI->line() : 0; 472 return (RI) ? RI->line() : 0;
467 } 473 }
468 474
469 // return the node that offers full setup capability 475 // return the node that offers full setup capability
470 virtual RuntimeInfo * fullSetup( void ) 476 virtual RuntimeInfo * fullSetup( void )
471 { RuntimeInfo * RI = nextNode(); 477 { RuntimeInfo * RI = nextNode();
472 return (RI) ? RI->fullSetup() : 0; 478 return (RI) ? RI->fullSetup() : 0;
473 } 479 }
474 480
475 inline ANetNodeInstance * netNode() 481 inline ANetNodeInstance * netNode()
476 { return NNI; } 482 { return NNI; }
477 483
478 inline NetworkSetup * networkSetup() 484 inline NetworkSetup * networkSetup()
479 { return NNI->networkSetup(); } 485 { return NNI->networkSetup(); }
480 486
481 virtual State_t detectState( void ) = 0; 487 virtual State_t detectState( void ) = 0;
482 // public API to set the state 488 // public API to set the state
483 virtual QString setState( NetworkSetup * NC, 489 virtual QString setState( NetworkSetup * NC,
484 Action_t A, 490 Action_t A,
485 bool Force = 0 ); 491 bool Force = 0 );
486 492
487 inline RuntimeInfo * nextNode( void ) { 493 inline RuntimeInfo * nextNode( void ) {
488 ANetNodeInstance * NNI = netNode()->nextNode(); 494 ANetNodeInstance * NNI = netNode()->nextNode();
489 return (NNI) ? NNI->runtime() : 0; 495 return (NNI) ? NNI->runtime() : 0;
490 } 496 }
491 497
492signals : 498signals :
493 499
494 // sent by device if state changes 500 // sent by device if state changes
495 void stateChanged( State_t S, ANetNodeInstance * NNI ); 501 void stateChanged( State_t S, ANetNodeInstance * NNI );
496 502
497protected : 503protected :
498 504
499 // set state of this node (private API) 505 // set state of this node (private API)
500 virtual QString setMyState( NetworkSetup * NC, 506 virtual QString setMyState( NetworkSetup * NC,
501 Action_t A, 507 Action_t A,
502 bool Force = 0 ) = 0; 508 bool Force = 0 ) = 0;
503 509
504 // networkSetup this runtime info belongs to 510 // networkSetup this runtime info belongs to
505 ANetNodeInstance * NNI; 511 ANetNodeInstance * NNI;
506}; 512};
507 513
508class NetworkSetup : public QList<ANetNodeInstance> { 514class NetworkSetup : public QList<ANetNodeInstance> {
509 515
510public : 516public :
511 517
512 NetworkSetup( void ); 518 NetworkSetup( void );
513 NetworkSetup( QTextStream & TS, bool & Dangling ); 519 NetworkSetup( QTextStream & TS, bool & Dangling );
514 ~NetworkSetup( void ); 520 ~NetworkSetup( void );
515 521
516 // copy settings from NC to this 522 // copy settings from NC to this
517 void copyFrom( const NetworkSetup & NC ); 523 void copyFrom( const NetworkSetup & NC );
518 524
519 inline int done( void ) 525 inline int done( void )
520 { return Done; } 526 { return Done; }
521 inline void setDone( int D ) 527 inline void setDone( int D )
522 { Done = D; } 528 { Done = D; }
523 529
524 inline int number( void ) 530 inline int number( void )
525 { return Number; } 531 { return Number; }
526 inline void setNumber( int i ) 532 inline void setNumber( int i )
527 { Number = i; } 533 { Number = i; }
528 inline bool isNew( void ) 534 inline bool isNew( void )
529 { return IsNew; } 535 { return IsNew; }
530 inline void setNew( bool N ) 536 inline void setNew( bool N )
531 { IsNew = N ; } 537 { IsNew = N ; }
532 inline bool isModified( void ) 538 inline bool isModified( void )
533 { return IsModified; } 539 { return IsModified; }
534 inline void setModified( bool N ) 540 inline void setModified( bool N )
535 { IsModified = N ; } 541 { IsModified = N ; }
536 542
537 inline bool handlesInterface( const QString & S ) { 543 inline bool handlesInterface( const QString & S ) {
538 return getToplevel()->runtime()->handlesInterface( S ); 544 return getToplevel()->runtime()->handlesInterface( S );
539 } 545 }
540 546
541 // return the interface in the OS that is assigned to 547 // return the interface in the OS that is assigned to
542 // this device 548 // this device
543 inline InterfaceInfo * assignedInterface( void ) { 549 inline InterfaceInfo * assignedInterface( void ) {
544 return AssignedInterface; 550 return AssignedInterface;
545 } 551 }
546 552
547 // assign the interface to this device 553 // assign the interface to this device
548 inline void assignInterface( InterfaceInfo * NI ) { 554 inline void assignInterface( InterfaceInfo * NI ) {
549 // cleanup previous 555 // cleanup previous
550 if( AssignedInterface ) { 556 if( AssignedInterface ) {
551 AssignedInterface->assignToNetworkSetup( 0 ); 557 AssignedInterface->assignToNetworkSetup( 0 );
552 } 558 }
553 if( NI ) { 559 if( NI ) {
554 // assign new 560 // assign new
555 NI->assignToNetworkSetup( this ); 561 NI->assignToNetworkSetup( this );
556 } 562 }
557 AssignedInterface = NI; 563 AssignedInterface = NI;
558 } 564 }
559 565
560 inline RuntimeInfo * device() { 566 inline RuntimeInfo * device() {
561 return getToplevel()->runtime()->device(); 567 return getToplevel()->runtime()->device();
562 } 568 }
563 569
564 const QStringList & triggers(); 570 const QStringList & triggers();
565 571
566 State_t state( bool Update = 0 ); 572 State_t state( bool Update = 0 );
567 573
568 // get the ixmap for this device 574 // get the ixmap for this device
569 QPixmap devicePixmap( void ); 575 QPixmap devicePixmap( void );
570 QPixmap statePixmap( State_t S ); 576 QPixmap statePixmap( State_t S );
571 inline QPixmap statePixmap( bool Update = 0 ) 577 inline QPixmap statePixmap( bool Update = 0 )
572 { return statePixmap( state(Update) ); } 578 { return statePixmap( state(Update) ); }
573 QString stateName( State_t ); 579 QString stateName( State_t );
574 inline QString stateName( bool Update = 0 ) 580 inline QString stateName( bool Update = 0 )
575 { return stateName( state(Update) ); } 581 { return stateName( state(Update) ); }
576 582
577 QString setState( Action_t A, bool Force = 0 ); 583 QString setState( Action_t A, bool Force = 0 );
578 584
579 void save( QTextStream & TS ); 585 void save( QTextStream & TS );
580 586
581 void append( ANetNodeInstance * NNI ); 587 void append( ANetNodeInstance * NNI );
582 588
583 // makes sure that all items in the networkSetup point to 589 // makes sure that all items in the networkSetup point to
584 // that connectoin 590 // that connectoin
585 void reassign( void ); 591 void reassign( void );
586 592
587 ANetNodeInstance * getToplevel( void ); 593 ANetNodeInstance * getToplevel( void );
588 ANetNodeInstance * findNext( ANetNodeInstance * NNI ); 594 ANetNodeInstance * findNext( ANetNodeInstance * NNI );
589 ANetNodeInstance * findByName( const QString & S ); 595 ANetNodeInstance * findByName( const QString & S );
590 596
591 inline const QString & name() 597 inline const QString & name()
592 { return Name; } 598 { return Name; }
593 599
594 const QString & description( void ); 600 const QString & description( void );
595 601
596 inline void setName( const QString & N) 602 inline void setName( const QString & N)
597 { Name = N; } 603 { Name = N; }
598 604
599 inline State_t currentState( void ) 605 inline State_t currentState( void )
600 { return CurrentState; } 606 { return CurrentState; }
601 inline void setCurrentState( State_t S ) 607 inline void setCurrentState( State_t S )
602 { CurrentState = S; } 608 { CurrentState = S; }
603 609
604 // return TRUE if this node can have data to be inserted in 610 // return TRUE if this node can have data to be inserted in
605 // file identified by S 611 // file identified by S
606 bool hasDataForFile( SystemFile & S ); 612 bool hasDataForFile( SystemFile & S );
607 ANetNodeInstance * firstWithDataForFile( SystemFile & ); 613 ANetNodeInstance * firstWithDataForFile( SystemFile & );
608 614
609 // generate items for this file -> toplevel call 615 // generate items for this file -> toplevel call
610 short generateFile( SystemFile & SF, 616 short generateFile( SystemFile & SF,
611 long DN // device number 617 long DN // device number
612 ) 618 )
613 { return getToplevel()->generateFile( SF, DN ); } 619 { return getToplevel()->generateFile( SF, DN ); }
614 620
615 bool triggeredBy( const QString & Trigger ) 621 bool triggeredBy( const QString & Trigger )
616 { return getToplevel()->triggeredBy( Trigger ); } 622 { return getToplevel()->triggeredBy( Trigger ); }
617 623
618private : 624private :
619 625
620 int compareItems ( QCollection::Item item1, 626 int compareItems ( QCollection::Item item1,
621 QCollection::Item item2 ); 627 QCollection::Item item2 );
622 628
623 long Number; 629 long Number;
624 630
625 // state of this networkSetup 631 // state of this networkSetup
626 State_t CurrentState; 632 State_t CurrentState;
627 633
628 QString Name; 634 QString Name;
629 // true if this collection was just created (and not 635 // true if this collection was just created (and not
630 // loaded from file 636 // loaded from file
631 bool IsNew; 637 bool IsNew;
632 // index in listbox 638 // index in listbox
633 int Index; 639 int Index;
634 bool IsModified; 640 bool IsModified;
635 int Done; 641 int Done;
636 642
637 InterfaceInfo * AssignedInterface; 643 InterfaceInfo * AssignedInterface;
638 644
639}; 645};
640 646
641#endif 647#endif
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
@@ -1,787 +1,832 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <opie2/odebug.h> 2#include <opie2/odebug.h>
3#include <qpe/qpeapplication.h> 3#include <qpe/qpeapplication.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qdir.h> 5#include <qdir.h>
6#include <qfile.h> 6#include <qfile.h>
7#include <qfileinfo.h> 7#include <qfileinfo.h>
8 8
9#include "nsdata.h" 9#include "nsdata.h"
10#include <netnode.h> 10#include <netnode.h>
11#include <resources.h> 11#include <resources.h>
12 12
13static QString CfgFile; 13static QString CfgFile;
14 14
15NetworkSettingsData::NetworkSettingsData( void ) { 15NetworkSettingsData::NetworkSettingsData( void ) {
16 // init global resources structure 16 // init global resources structure
17 new TheNSResources(); 17 new TheNSResources();
18 18
19 if( ! NSResources->userKnown() ) { 19 if( ! NSResources->userKnown() ) {
20 Log(( "Cannot detect qpe user HOME=\"%s\" USER=\"%s\"\n", 20 Log(( "Cannot detect qpe user HOME=\"%s\" USER=\"%s\"\n",
21 NSResources->currentUser().HomeDir.latin1(), 21 NSResources->currentUser().HomeDir.latin1(),
22 NSResources->currentUser().UserName.latin1() )); 22 NSResources->currentUser().UserName.latin1() ));
23 return; 23 return;
24 } 24 }
25 25
26 CfgFile.sprintf( "%s/Settings/NS2.conf", 26 CfgFile.sprintf( "%s/Settings/NS2.conf",
27 NSResources->currentUser().HomeDir.latin1() ); 27 NSResources->currentUser().HomeDir.latin1() );
28 Log(( "Cfg from %s\n", CfgFile.latin1() )); 28 Log(( "Cfg from %s\n", CfgFile.latin1() ));
29 29
30 // load settings 30 // load settings
31 loadSettings(); 31 loadSettings();
32 32
33 // assign interfaces by scanning /tmp/profile-%s.Up files 33 // assign interfaces by scanning /tmp/profile-%s.Up files
34 { QDir D( "/tmp" ); 34 { QDir D( "/tmp" );
35 QFile * F = new QFile; 35 QFile * F = new QFile;
36 int profilenr; 36 int profilenr;
37 QString interfacename; 37 QString interfacename;
38 QTextStream TS ( F ); 38 QTextStream TS ( F );
39 39
40 QStringList SL = D.entryList( "profile-*.up"); 40 QStringList SL = D.entryList( "profile-*.up");
41 41
42 Log(( "System reports %d interfaces. Found %d up\n", 42 Log(( "System reports %d interfaces. Found %d up\n",
43 NSResources->system().interfaces().count(), 43 NSResources->system().interfaces().count(),
44 SL.count() )); 44 SL.count() ));
45 45
46 for ( QStringList::Iterator it = SL.begin(); 46 for ( QStringList::Iterator it = SL.begin();
47 it != SL.end(); 47 it != SL.end();
48 ++it ) { 48 ++it ) {
49 profilenr = atol( (*it).mid( 8 ).latin1() ); 49 profilenr = atol( (*it).mid( 8 ).latin1() );
50 // read the interface store int 'up' 50 // read the interface store int 'up'
51 F->setName( D.path() + "/" + (*it) ); 51 F->setName( D.path() + "/" + (*it) );
52 if( F->open( IO_ReadOnly ) ) { 52 if( F->open( IO_ReadOnly ) ) {
53 NetworkSetup * NC; 53 NetworkSetup * NC;
54 interfacename = TS.readLine(); 54 interfacename = TS.readLine();
55 F->close(); 55 F->close();
56 56
57 Log(( "Assign interface %s to Profile nr %d\n", 57 Log(( "Assign interface %s to Profile nr %d\n",
58 interfacename.latin1(), profilenr )); 58 interfacename.latin1(), profilenr ));
59 59
60 NC = NSResources->getNetworkSetup( profilenr ); 60 NC = NSResources->getNetworkSetup( profilenr );
61 if( NC ) { 61 if( NC ) {
62 NC->assignInterface( 62 NC->assignInterface(
63 NSResources->system().findInterface( interfacename ) ); 63 NSResources->system().findInterface( interfacename ) );
64 Log(( "Assign interface %p\n", 64 Log(( "Assign interface %p\n",
65 NC->assignedInterface() )); 65 NC->assignedInterface() ));
66 } else { 66 } else {
67 Log(( "Profile nr %d no longer defined\n", 67 Log(( "Profile nr %d no longer defined\n",
68 profilenr )); 68 profilenr ));
69 } 69 }
70 } 70 }
71 } 71 }
72 } 72 }
73} 73}
74 74
75// saving is done by caller 75// saving is done by caller
76NetworkSettingsData::~NetworkSettingsData( void ) { 76NetworkSettingsData::~NetworkSettingsData( void ) {
77 delete NSResources; 77 delete NSResources;
78} 78}
79 79
80void NetworkSettingsData::loadSettings( void ) { 80void NetworkSettingsData::loadSettings( void ) {
81 QString Line, S; 81 QString Line, S;
82 QString Attr, Value; 82 QString Attr, Value;
83 long idx; 83 long idx;
84 84
85 QFile F( CfgFile ); 85 QFile F( CfgFile );
86 QTextStream TS( &F ); 86 QTextStream TS( &F );
87 87
88 ForceModified = 0; 88 ForceModified = 0;
89 89
90 do { 90 do {
91 91
92 if( ! F.open(IO_ReadOnly) ) 92 if( ! F.open(IO_ReadOnly) )
93 break; 93 break;
94 94
95 /* load the file -> 95 /* load the file ->
96 96
97 FORMAT : 97 FORMAT :
98 98
99 [NETNODETYPE] 99 [NETNODETYPE]
100 Entries ... 100 Entries ...
101 <EMPTYLINE> 101 <EMPTYLINE>
102 [NetworkSetup] 102 [NetworkSetup]
103 Name=Name 103 Name=Name
104 Node=Name 104 Node=Name
105 <EMPTYLINE> 105 <EMPTYLINE>
106 */ 106 */
107 while( ! TS.atEnd() ) { 107 while( ! TS.atEnd() ) {
108 S = Line = TS.readLine(); 108 S = Line = TS.readLine();
109 109
110 if ( S.isEmpty() || S[0] != '[' ) 110 if ( S.isEmpty() || S[0] != '[' )
111 continue; 111 continue;
112 112
113 S = S.mid( 1, S.length()-2 ); 113 S = S.mid( 1, S.length()-2 );
114 114
115 if( ! NSResources ) { 115 if( ! NSResources ) {
116 continue; 116 continue;
117 } 117 }
118 118
119 if( S == "NetworkSetup" ) { 119 if( S == "NetworkSetup" ) {
120 // load NetworkSetups -> collections of nodes 120 // load NetworkSetups -> collections of nodes
121 bool Dangling; 121 bool Dangling;
122 NetworkSetup * NC = new NetworkSetup( TS, Dangling ); 122 NetworkSetup * NC = new NetworkSetup( TS, Dangling );
123 NSResources->addNetworkSetup( NC, Dangling ); 123 NSResources->addNetworkSetup( NC, Dangling );
124 } else { 124 } else {
125 ANetNode * NN = 0; 125 ANetNode * NN = 0;
126 ANetNodeInstance* NNI = 0; 126 ANetNodeInstance* NNI = 0;
127 if( S.startsWith( "nodetype " ) ) { 127 if( S.startsWith( "nodetype " ) ) {
128 S = S.mid( 9, S.length()-9 ); 128 S = S.mid( 9, S.length()-9 );
129 S = deQuote(S); 129 S = deQuote(S);
130 // try to find netnode 130 // try to find netnode
131 NN = NSResources->findNetNode( S ); 131 NN = NSResources->findNetNode( S );
132 } else { 132 } else {
133 // try to find instance 133 // try to find instance
134 NNI = NSResources->createNodeInstance( S ); 134 NNI = NSResources->createNodeInstance( S );
135 } 135 }
136 136
137 if( NN == 0 && NNI == 0 ) { 137 if( NN == 0 && NNI == 0 ) {
138 LeftOvers.append( Line ); 138 LeftOvers.append( Line );
139 do { 139 do {
140 Line = TS.readLine(); 140 Line = TS.readLine();
141 // store even delimiter 141 // store even delimiter
142 LeftOvers.append( Line ); 142 LeftOvers.append( Line );
143 } while ( ! Line.isEmpty() ); 143 } while ( ! Line.isEmpty() );
144 144
145 //next section 145 //next section
146 continue; 146 continue;
147 } 147 }
148 148
149 // read entries of this section 149 // read entries of this section
150 do { 150 do {
151 S = Line = TS.readLine(); 151 S = Line = TS.readLine();
152 152
153 if( S.isEmpty() ) { 153 if( S.isEmpty() ) {
154 // empty line 154 // empty line
155 break; 155 break;
156 } 156 }
157 idx = S.find( '=' ); 157 idx = S.find( '=' );
158 if( idx > 0 ) { 158 if( idx > 0 ) {
159 Attr = S.left( idx ); 159 Attr = S.left( idx );
160 Value = S.mid( idx+1, S.length() ); 160 Value = S.mid( idx+1, S.length() );
161 } else { 161 } else {
162 Value=""; 162 Value="";
163 Attr = S; 163 Attr = S;
164 } 164 }
165 165
166 Value.stripWhiteSpace(); 166 Value.stripWhiteSpace();
167 Attr.stripWhiteSpace(); 167 Attr.stripWhiteSpace();
168 Attr.lower(); 168 Attr.lower();
169 // dequote Attr 169 // dequote Attr
170 Value = deQuote(Value); 170 Value = deQuote(Value);
171 171
172 if( NN ) { 172 if( NN ) {
173 // set the attribute 173 // set the attribute
174 NN->setAttribute( Attr, Value ); 174 NN->setAttribute( Attr, Value );
175 } else { 175 } else {
176 // set the attribute 176 // set the attribute
177 NNI->setAttribute( Attr, Value ); 177 NNI->setAttribute( Attr, Value );
178 } 178 }
179 } while( 1 ); 179 } while( 1 );
180 180
181 if( NNI ) { 181 if( NNI ) {
182 // loading from file -> exists 182 // loading from file -> exists
183 Log( ( "NodeInstance %s : %p\n", NNI->name(), NNI )); 183 Log( ( "NodeInstance %s : %p\n", NNI->name(), NNI ));
184 NNI->setNew( FALSE ); 184 NNI->setNew( FALSE );
185 NSResources->addNodeInstance( NNI ); 185 NSResources->addNodeInstance( NNI );
186 } 186 }
187 187
188 if( NN ) { 188 if( NN ) {
189 Log( ( "Node %s : %p\n", NN->name(), NN ) ); 189 Log( ( "Node %s : %p\n", NN->name(), NN ) );
190 } 190 }
191 } 191 }
192 } 192 }
193 193
194 } while( 0 ); 194 } while( 0 );
195 195
196} 196}
197 197
198QString NetworkSettingsData::saveSettings( void ) { 198QString NetworkSettingsData::saveSettings( void ) {
199 QString ErrS = ""; 199 QString ErrS = "";
200 200
201 if( ! isModified() ) 201 if( ! isModified() )
202 return ErrS; 202 return ErrS;
203 203
204 QString S; 204 QString S;
205 QFile F( CfgFile + ".bup" ); 205 QFile F( CfgFile + ".bup" );
206 206
207 Log( ( "Saving settings to %s\n", CfgFile.latin1() )); 207 Log( ( "Saving settings to %s\n", CfgFile.latin1() ));
208 if( ! F.open( IO_WriteOnly | IO_Truncate ) ) { 208 if( ! F.open( IO_WriteOnly | IO_Truncate ) ) {
209 ErrS = qApp->translate( "NetworkSettings", 209 ErrS = qApp->translate( "NetworkSettings",
210 "<p>Could not save setup to \"%1\" !</p>" ). 210 "<p>Could not save setup to \"%1\" !</p>" ).
211 arg(CfgFile); 211 arg(CfgFile);
212 // problem 212 // problem
213 return ErrS; 213 return ErrS;
214 } 214 }
215 215
216 QTextStream TS( &F ); 216 QTextStream TS( &F );
217 217
218 // save global configs 218 // save global configs
219 for( QDictIterator<ANetNode> it( NSResources->netNodes() ); 219 for( QDictIterator<ANetNode> it( NSResources->netNodes() );
220 it.current(); 220 it.current();
221 ++it ) { 221 ++it ) {
222 TS << "[nodetype " 222 TS << "[nodetype "
223 << quote( QString( it.current()->name() ) ) 223 << quote( QString( it.current()->name() ) )
224 << "]" 224 << "]"
225 << endl; 225 << endl;
226 226
227 it.current()->saveAttributes( TS ); 227 it.current()->saveAttributes( TS );
228 TS << endl; 228 TS << endl;
229 } 229 }
230 230
231 // save leftovers 231 // save leftovers
232 for ( QStringList::Iterator it = LeftOvers.begin(); 232 for ( QStringList::Iterator it = LeftOvers.begin();
233 it != LeftOvers.end(); ++it ) { 233 it != LeftOvers.end(); ++it ) {
234 TS << (*it) << endl; 234 TS << (*it) << endl;
235 } 235 }
236 236
237 // save all netnode instances 237 // save all netnode instances
238 { ANetNodeInstance * NNI; 238 { ANetNodeInstance * NNI;
239 for( QDictIterator<ANetNodeInstance> nit( 239 for( QDictIterator<ANetNodeInstance> nit(
240 NSResources->netNodeInstances()); 240 NSResources->netNodeInstances());
241 nit.current(); 241 nit.current();
242 ++nit ) { 242 ++nit ) {
243 // header 243 // header
244 NNI = nit.current(); 244 NNI = nit.current();
245 TS << '[' 245 TS << '['
246 << QString(NNI->nodeClass()->name()) 246 << QString(NNI->nodeClass()->name())
247 << ']' 247 << ']'
248 << endl; 248 << endl;
249 NNI->saveAttributes( TS ); 249 NNI->saveAttributes( TS );
250 TS << endl; 250 TS << endl;
251 } 251 }
252 } 252 }
253 253
254 // good NetworkSetups 254 // good NetworkSetups
255 { Name2NetworkSetup_t & M = NSResources->networkSetups(); 255 { Name2NetworkSetup_t & M = NSResources->networkSetups();
256 256
257 // for all NetworkSetups 257 // for all NetworkSetups
258 for( QDictIterator<NetworkSetup> it(M); 258 for( QDictIterator<NetworkSetup> it(M);
259 it.current(); 259 it.current();
260 ++it ) { 260 ++it ) {
261 TS << "[NetworkSetup]" << endl; 261 TS << "[NetworkSetup]" << endl;
262 it.current()->save(TS); 262 it.current()->save(TS);
263 } 263 }
264 } 264 }
265 265
266 // save dangling NetworkSetups 266 // save dangling NetworkSetups
267 { Name2NetworkSetup_t & M = NSResources->danglingNetworkSetups(); 267 { Name2NetworkSetup_t & M = NSResources->danglingNetworkSetups();
268 268
269 // for all NetworkSetups 269 // for all NetworkSetups
270 for( QDictIterator<NetworkSetup> it(M); 270 for( QDictIterator<NetworkSetup> it(M);
271 it.current(); 271 it.current();
272 ++it ) { 272 ++it ) {
273 TS << "[NetworkSetup]" << endl; 273 TS << "[NetworkSetup]" << endl;
274 it.current()->save(TS); 274 it.current()->save(TS);
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
295QString NetworkSettingsData::generateSettings( void ) { 295QString 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() );
455 ! needToGenerate && nniit.current(); 477 ! needToGenerate && nniit.current();
456 ++nniit ) { 478 ++nniit ) {
457 if( nniit.current()->nodeClass() == NN ) { 479 if( nniit.current()->nodeClass() == NN ) {
458 // yes 480 // yes
459 Log(("Node %s has data\n", 481 Log(("Node %s has data\n",
460 nniit.current()->name() )); 482 nniit.current()->name() ));
461 needToGenerate = 1; 483 needToGenerate = 1;
462 break; 484 break;
463 } 485 }
464 } 486 }
465 } 487 }
466 } 488 }
467 489
468 if( ! needToGenerate ) { 490 if( ! needToGenerate ) {
469 // no instances found that might need to write data 491 // no instances found that might need to write data
470 // in this systemfile 492 // in this systemfile
471 Log(("No nodes for systemfile %s\n", SF->name().latin1() )); 493 Log(("No nodes for systemfile %s\n", SF->name().latin1() ));
472 continue; 494 continue;
473 } 495 }
474 496
475 // ok generate this system file 497 // ok generate this system file
476 if( ! SF->open() ) { 498 if( ! SF->open() ) {
477 S = qApp->translate( "NetworkSettings", 499 S = qApp->translate( "NetworkSettings",
478 "<p>Cannot open system file \"%1\"</p>" ). 500 "<p>Cannot open system file \"%1\"</p>" ).
479 arg( SF->name() ); 501 arg( SF->name() );
480 return S; 502 return S;
481 } 503 }
482 504
483 // global presection for this system file 505 // global presection for this system file
484 if( ! SF->preSection() ) { 506 if( ! SF->preSection() ) {
485 S = qApp->translate( "NetworkSettings", 507 S = qApp->translate( "NetworkSettings",
486 "<p>Error in section \"Preamble\" for file \"%1\"</p>" ). 508 "<p>Error in section \"Preamble\" for file \"%1\"</p>" ).
487 arg( SF->name() ); 509 arg( SF->name() );
488 return S; 510 return S;
489 } 511 }
490 512
491 // find NetworkSetups that want to write to this file 513 // find NetworkSetups that want to write to this file
492 for( QDictIterator<NetworkSetup> ncit(M); 514 for( QDictIterator<NetworkSetup> ncit(M);
493 ncit.current(); 515 ncit.current();
494 ++ncit ) { 516 ++ncit ) {
495 517
496 NC = ncit.current(); 518 NC = ncit.current();
497 519
498 if( NC->done() ) { 520 if( NC->done() ) {
499 // already done 521 // already done
500 continue; 522 continue;
501 } 523 }
502 524
503 if( ! NC->hasDataForFile( *SF ) ) { 525 if( ! NC->hasDataForFile( *SF ) ) {
504 // no data 526 // no data
505 continue; 527 continue;
506 } 528 }
507 529
508 Log(("Generating %s for NetworkSetup %s\n", 530 Log(("Generating %s for NetworkSetup %s\n",
509 SF->name().latin1(), NC->name().latin1() )); 531 SF->name().latin1(), NC->name().latin1() ));
510 // find highest item that wants to write data to this file 532 // find highest item that wants to write data to this file
511 FirstWithData = NC->firstWithDataForFile( *SF ); 533 FirstWithData = NC->firstWithDataForFile( *SF );
512 534
513 // find device on which this NetworkSetup works 535 // find device on which this NetworkSetup works
514 CurDev = NC->device(); 536 CurDev = NC->device();
515 // class of that node 537 // class of that node
516 CurDevNN = CurDev->netNode()->nodeClass(); 538 CurDevNN = CurDev->netNode()->nodeClass();
517 539
518 if( ! FirstWithData->nodeClass()->done() ) { 540 if( ! FirstWithData->nodeClass()->done() ) {
519 // generate fixed part 541 // generate fixed part
520 if( ! SF->preDeviceSection( CurDevNN ) ) { 542 if( ! SF->preDeviceSection( CurDevNN ) ) {
521 S = qApp->translate( "NetworkSettings", 543 S = qApp->translate( "NetworkSettings",
522 "<p>Error in section \"Pre-Device\" for file \"%1\"</p>" ). 544 "<p>Error in section \"Pre-Device\" for file \"%1\"</p>" ).
523 arg( SF->name() ); 545 arg( SF->name() );
524 return S; 546 return S;
525 } 547 }
526 548
527 if( FirstWithData->nodeClass()->generateFile( 549 if( FirstWithData->nodeClass()->generateFile(
528 *SF, 550 *SF,
529 FirstWithData, 551 FirstWithData,
530 -2 ) == 2 ) { 552 -2 ) == 2 ) {
531 S = qApp->translate( "NetworkSettings", 553 S = qApp->translate( "NetworkSettings",
532 "<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ). 554 "<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ).
533 arg( SF->name() ). 555 arg( SF->name() ).
534 arg( CurDevNN->name() ); 556 arg( CurDevNN->name() );
535 return S; 557 return S;
536 } 558 }
537 FirstWithData->nodeClass()->setDone( 1 ); 559 FirstWithData->nodeClass()->setDone( 1 );
538 Log(( "Systemfile %s for node instance %s is done\n", 560 Log(( "Systemfile %s for node instance %s is done\n",
539 SF->name().latin1(), 561 SF->name().latin1(),
540 FirstWithData->name() )); 562 FirstWithData->name() ));
541 } 563 }
542 564
543 NoOfDevs = 0; 565 NoOfDevs = 0;
544 DevCtStart = -1; 566 DevCtStart = -1;
545 567
546 if( SF->knowsDeviceInstances() ) { 568 if( SF->knowsDeviceInstances() ) {
547 DevCtStart = 0; 569 DevCtStart = 0;
548 NoOfDevs = CurDevNN->instanceCount(); 570 NoOfDevs = CurDevNN->instanceCount();
549 } 571 }
550 572
551 if( ! CurDev->netNode()->nodeClass()->done() ) { 573 if( ! CurDev->netNode()->nodeClass()->done() ) {
552 // first time this device is handled 574 // first time this device is handled
553 // generate common device specific part 575 // generate common device specific part
554 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { 576 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) {
555 577
556 if( FirstWithData->nodeClass()->generateFile( 578 if( FirstWithData->nodeClass()->generateFile(
557 *SF, CurDev->netNode(), i ) == 2 ) { 579 *SF, CurDev->netNode(), i ) == 2 ) {
558 S = qApp->translate( "NetworkSettings", 580 S = qApp->translate( "NetworkSettings",
559 "<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ). 581 "<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ).
560 arg( SF->name() ). 582 arg( SF->name() ).
561 arg( CurDevNN->name() ); 583 arg( CurDevNN->name() );
562 return S; 584 return S;
563 } 585 }
564 } 586 }
565 CurDev->netNode()->nodeClass()->setDone( 1 ); 587 CurDev->netNode()->nodeClass()->setDone( 1 );
566 588
567 Log(( "Systemfile %s for Nodeclass %s is done\n", 589 Log(( "Systemfile %s for Nodeclass %s is done\n",
568 SF->name().latin1(), 590 SF->name().latin1(),
569 CurDev->netNode()->nodeClass()->name() 591 CurDev->netNode()->nodeClass()->name()
570 )); 592 ));
571 } 593 }
572 594
573 // generate profile specific info 595 // generate profile specific info
574 // for all nodeNetworkSetups that work on the same device 596 // for all nodeNetworkSetups that work on the same device
575 for( QDictIterator<NetworkSetup> ncit2(M); 597 for( QDictIterator<NetworkSetup> ncit2(M);
576 ncit2.current(); 598 ncit2.current();
577 ++ncit2 ) { 599 ++ncit2 ) {
578 600
579 if( ncit2.current()->device() != CurDev ) { 601 if( ncit2.current()->device() != CurDev ) {
580 // different device 602 // different device
581 continue; 603 continue;
582 } 604 }
583 605
584 Log(("NetworkSetup %s of family %s\n", 606 Log(("NetworkSetup %s of family %s\n",
585 ncit2.current()->name().latin1(), 607 ncit2.current()->name().latin1(),
586 CurDev->name() )); 608 CurDev->name() ));
587 // generate 609 // generate
588 NNI = ncit2.current()->firstWithDataForFile( *SF ); 610 NNI = ncit2.current()->firstWithDataForFile( *SF );
589 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { 611 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) {
590 if( ! SF->preNodeSection( NNI, i ) ) { 612 if( ! SF->preNodeSection( NNI, i ) ) {
591 S = qApp->translate( "NetworkSettings", 613 S = qApp->translate( "NetworkSettings",
592 "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ). 614 "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
593 arg( SF->name() ). 615 arg( SF->name() ).
594 arg( CurDevNN->name() ); 616 arg( CurDevNN->name() );
595 return S; 617 return S;
596 } 618 }
597 619
598 switch( NNI->generateFile( *SF, i ) ) { 620 switch( NNI->generateFile( *SF, i ) ) {
599 case 0 : 621 case 0 :
600 (*SF) << endl; 622 (*SF) << endl;
601 break; 623 break;
602 case 1 : 624 case 1 :
603 break; 625 break;
604 case 2 : 626 case 2 :
605 S = qApp->translate( "NetworkSettings", 627 S = qApp->translate( "NetworkSettings",
606 "<p>Error in section \"Node\" for file \"%1\" and node \"%2\"</p>" ). 628 "<p>Error in section \"Node\" for file \"%1\" and node \"%2\"</p>" ).
607 arg( SF->name() ). 629 arg( SF->name() ).
608 arg( CurDevNN->name() ); 630 arg( CurDevNN->name() );
609 return S; 631 return S;
610 } 632 }
611 633
612 if( ! SF->postNodeSection( NNI, i ) ) { 634 if( ! SF->postNodeSection( NNI, i ) ) {
613 S = qApp->translate( "NetworkSettings", 635 S = qApp->translate( "NetworkSettings",
614 "<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ). 636 "<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
615 arg( SF->name() ). 637 arg( SF->name() ).
616 arg( CurDevNN->name() ); 638 arg( CurDevNN->name() );
617 return S; 639 return S;
618 } 640 }
619 } 641 }
620 642
621 ncit2.current()->setDone( 1 ); 643 ncit2.current()->setDone( 1 );
622 644
623 } 645 }
624 } 646 }
625 647
626 if( ! SF->postDeviceSection( CurDevNN ) ) { 648 if( ! SF->postDeviceSection( CurDevNN ) ) {
627 S = qApp->translate( "NetworkSettings", 649 S = qApp->translate( "NetworkSettings",
628 "<p>Error in section \"Post-Device\" for file \"%1\" and node \"%2\"</p>" ). 650 "<p>Error in section \"Post-Device\" for file \"%1\" and node \"%2\"</p>" ).
629 arg( SF->name() ). 651 arg( SF->name() ).
630 arg( CurDevNN->name() ); 652 arg( CurDevNN->name() );
631 return S; 653 return S;
632 } 654 }
633 655
634 656
635 if( ! SF->postSection() ) { 657 if( ! SF->postSection() ) {
636 S = qApp->translate( "NetworkSettings", 658 S = qApp->translate( "NetworkSettings",
637 "<p>Error in section \"Closure\" for file \"%1\"</p>" ). 659 "<p>Error in section \"Closure\" for file \"%1\"</p>" ).
638 arg( SF->name() ); 660 arg( SF->name() );
639 return S; 661 return S;
640 } 662 }
641 663
642 // end of file 664 // end of file
643 SF->close(); 665 SF->close();
644 } 666 }
645 return S; 667 return S;
646} 668}
647 669
648QList<NetworkSetup> NetworkSettingsData::collectPossible( 670QList<NetworkSetup> NetworkSettingsData::collectPossible(
649 const QString & Interface ) { 671 const QString & Interface ) {
650 // collect NetworkSetups that can work on top of this interface 672 // collect NetworkSetups that can work on top of this interface
651 NetworkSetup * NC; 673 NetworkSetup * NC;
652 QList<NetworkSetup> PossibleNetworkSetups; 674 QList<NetworkSetup> PossibleNetworkSetups;
653 Name2NetworkSetup_t & M = NSResources->networkSetups(); 675 Name2NetworkSetup_t & M = NSResources->networkSetups();
654 676
655 // for all NetworkSetups 677 // for all NetworkSetups
656 for( QDictIterator<NetworkSetup> it(M); 678 for( QDictIterator<NetworkSetup> it(M);
657 it.current(); 679 it.current();
658 ++it ) { 680 ++it ) {
659 NC = it.current(); 681 NC = it.current();
660 // check if this profile handles the requested interface 682 // check if this profile handles the requested interface
661 if( NC->handlesInterface( Interface ) && // if different Intf. 683 if( NC->handlesInterface( Interface ) && // if different Intf.
662 NC->state() != Disabled && // if enabled 684 NC->state() != Disabled && // if enabled
663 NC->state() != IsUp // if already used 685 NC->state() != IsUp // if already used
664 ) { 686 ) {
665 Log( ( "Append %s for %s\n", 687 Log( ( "Append %s for %s\n",
666 NC->name().latin1(), Interface.latin1() )); 688 NC->name().latin1(), Interface.latin1() ));
667 PossibleNetworkSetups.append( NC ); 689 PossibleNetworkSetups.append( NC );
668 } 690 }
669 } 691 }
670 return PossibleNetworkSetups; 692 return PossibleNetworkSetups;
671} 693}
672 694
673 695
674/* 696/*
675 Called by the system to see if interface can be brought UP 697 Called by the system to see if interface can be brought UP
676 698
677 if allowed, echo Interface-allowed else Interface-disallowed 699 if allowed, echo Interface-allowed else Interface-disallowed
678*/ 700*/
679 701
680bool NetworkSettingsData::canStart( const QString & Interface ) { 702bool NetworkSettingsData::canStart( const QString & Interface ) {
681 // load situation 703 // load situation
682 NetworkSetup * NC = 0; 704 NetworkSetup * NC = 0;
683 QList<NetworkSetup> PossibleNetworkSetups; 705 QList<NetworkSetup> PossibleNetworkSetups;
684 706
685 PossibleNetworkSetups = collectPossible( Interface ); 707 PossibleNetworkSetups = collectPossible( Interface );
686 708
687 Log( ( "for %s : Possiblilies %d\n", 709 Log( ( "for %s : Possiblilies %d\n",
688 Interface.latin1(), PossibleNetworkSetups.count() )); 710 Interface.latin1(), PossibleNetworkSetups.count() ));
689 switch( PossibleNetworkSetups.count() ) { 711 switch( PossibleNetworkSetups.count() ) {
690 case 0 : // no NetworkSetups 712 case 0 : // no NetworkSetups
691 break; 713 break;
692 case 1 : // one NetworkSetup 714 case 1 : // one NetworkSetup
693 NC = PossibleNetworkSetups.first(); 715 NC = PossibleNetworkSetups.first();
694 break; 716 break;
695 default : // need to ask user ? 717 default : // need to ask user ?
696 return 1; 718 return 1;
697 } 719 }
698 720
699 if( NC ) { 721 if( NC ) {
700 switch( NC->state() ) { 722 switch( NC->state() ) {
701 case Unchecked : 723 case Unchecked :
702 case Unknown : 724 case Unknown :
703 case Unavailable : 725 case Unavailable :
704 case Disabled : 726 case Disabled :
705 // this profile does not allow interface to be UP 727 // this profile does not allow interface to be UP
706 // -> try others 728 // -> try others
707 break; 729 break;
708 case Off : 730 case Off :
709 // try to UP the device 731 // try to UP the device
710 { QString S= NC->setState( Activate ); 732 { QString S= NC->setState( Activate );
711 if( ! S.isEmpty() ) { 733 if( ! S.isEmpty() ) {
712 // could not bring device Online -> try other alters 734 // could not bring device Online -> try other alters
713 Log(( "disallow %ld for %s : %s\n", 735 Log(( "disallow %ld for %s : %s\n",
714 NC->number(), Interface.latin1(), S.latin1() )); 736 NC->number(), Interface.latin1(), S.latin1() ));
715 break; 737 break;
716 } 738 }
717 // interface assigned 739 // interface assigned
718 } 740 }
719 // FT 741 // FT
720 case Available : 742 case Available :
721 case IsUp : // also called for 'ifdown' 743 case IsUp : // also called for 'ifdown'
722 // device is ready -> done 744 // device is ready -> done
723 Log(( "allow %ld for %s\n", NC->number(), Interface.latin1())); 745 Log(( "allow %ld for %s\n", NC->number(), Interface.latin1()));
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
735bool NetworkSettingsData::isModified( void ) { 757bool 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
749bool NetworkSettingsData::couldBeTriggered( const QString & Interface ) { 771bool 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
761QList<NetworkSetup> NetworkSettingsData::collectTriggered( 783QList<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
810bool 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
6class NetworkSettingsData { 6class NetworkSettingsData {
7 7
8public : 8public :
9 9
10 NetworkSettingsData( void ); 10 NetworkSettingsData( void );
11 ~NetworkSettingsData( void ); 11 ~NetworkSettingsData( void );
12 12
13 void loadSettings( void ); 13 void loadSettings( void );
14 QString saveSettings( void ); 14 QString saveSettings( void );
15 15
16 QString generateSettings( void ); 16 QString generateSettings( void );
17 17
18 bool isModified( void ); 18 bool isModified( void );
19 inline void setModified( bool M ) 19 inline void setModified( bool M )
20 { ForceModified = M; } 20 { ForceModified = M; }
21 21
22 QList<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
29private : 29private :
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
@@ -1,958 +1,966 @@
1#include <opie2/odebug.h> 1#include <opie2/odebug.h>
2#include <opie2/oledbox.h> 2#include <opie2/oledbox.h>
3#include <opie2/ofiledialog.h> 3#include <opie2/ofiledialog.h>
4 4
5using namespace Opie::Core; 5using namespace Opie::Core;
6using namespace Opie::Ui; 6using namespace Opie::Ui;
7 7
8#include <qpe/resource.h> 8#include <qpe/resource.h>
9#include <qapplication.h> 9#include <qapplication.h>
10#include <qcheckbox.h> 10#include <qcheckbox.h>
11#include <qcombobox.h> 11#include <qcombobox.h>
12#include <qdialog.h> 12#include <qdialog.h>
13#include <qdir.h> 13#include <qdir.h>
14#include <qfile.h> 14#include <qfile.h>
15#include <qgroupbox.h> 15#include <qgroupbox.h>
16#include <qheader.h> 16#include <qheader.h>
17#include <qlabel.h> 17#include <qlabel.h>
18#include <qlayout.h> 18#include <qlayout.h>
19#include <qlistbox.h> 19#include <qlistbox.h>
20#include <qlistview.h> 20#include <qlistview.h>
21#include <qmessagebox.h> 21#include <qmessagebox.h>
22#include <qprogressbar.h> 22#include <qprogressbar.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24#include <qscrollbar.h> 24#include <qscrollbar.h>
25#include <qtextstream.h> 25#include <qtextstream.h>
26#include <qtextview.h> 26#include <qtextview.h>
27 27
28#include <Opietooth.h> 28#include <Opietooth.h>
29#include <OTDriver.h> 29#include <OTDriver.h>
30#include <OTPeer.h> 30#include <OTPeer.h>
31#include <OTGateway.h> 31#include <OTGateway.h>
32#include <OTSDPAttribute.h> 32#include <OTSDPAttribute.h>
33#include <OTSDPService.h> 33#include <OTSDPService.h>
34#include <OTInquiry.h> 34#include <OTInquiry.h>
35 35
36#include <system.h> 36#include <system.h>
37 37
38using namespace Opietooth2; 38using namespace Opietooth2;
39 39
40namespace Opietooth2 { 40namespace Opietooth2 {
41 41
42class PeerLVI : public QListViewItem { 42class PeerLVI : public QListViewItem {
43 43
44public : 44public :
45 45
46 PeerLVI( OTPeer * P, QListView * it ) : QListViewItem (it) { 46 PeerLVI( OTPeer * P, QListView * it ) : QListViewItem (it) {
47 Peer = P; 47 Peer = P;
48 } 48 }
49 ~PeerLVI( void ) { 49 ~PeerLVI( void ) {
50 } 50 }
51 51
52 inline OTPeer * peer( void ) 52 inline OTPeer * peer( void )
53 { return Peer; } 53 { return Peer; }
54 54
55private : 55private :
56 56
57 OTPeer * Peer; 57 OTPeer * Peer;
58}; 58};
59 59
60class ChannelLVI : public QListViewItem { 60class ChannelLVI : public QListViewItem {
61 61
62public : 62public :
63 63
64 ChannelLVI( int Ch, QListViewItem * it ) : QListViewItem (it) { 64 ChannelLVI( int Ch, QListViewItem * it ) : QListViewItem (it) {
65 Channel = Ch; 65 Channel = Ch;
66 } 66 }
67 ~ChannelLVI( void ) { 67 ~ChannelLVI( void ) {
68 } 68 }
69 69
70 inline int channel( void ) 70 inline int channel( void )
71 { return Channel; } 71 { return Channel; }
72 72
73private : 73private :
74 74
75 int Channel; 75 int Channel;
76}; 76};
77 77
78class DriverLVI : public QListViewItem { 78class DriverLVI : public QListViewItem {
79 79
80public : 80public :
81 81
82 DriverLVI( OTDriver * P, QListView * it ) : QListViewItem (it) { 82 DriverLVI( OTDriver * P, QListView * it ) : QListViewItem (it) {
83 Driver = P; 83 Driver = P;
84 } 84 }
85 ~DriverLVI( void ) { 85 ~DriverLVI( void ) {
86 } 86 }
87 87
88 inline OTDriver * driver( void ) 88 inline OTDriver * driver( void )
89 { return Driver; } 89 { return Driver; }
90 90
91private : 91private :
92 92
93 OTDriver * Driver; 93 OTDriver * Driver;
94}; 94};
95 95
96class LinkKeyLVI : public QListViewItem { 96class LinkKeyLVI : public QListViewItem {
97 97
98public : 98public :
99 99
100 LinkKeyLVI( int Ch, QListView * it ) : QListViewItem (it) { 100 LinkKeyLVI( int Ch, QListView * it ) : QListViewItem (it) {
101 LinkKey = Ch; 101 LinkKey = Ch;
102 } 102 }
103 ~LinkKeyLVI( void ) { 103 ~LinkKeyLVI( void ) {
104 } 104 }
105 105
106 inline int index( void ) 106 inline int index( void )
107 { return LinkKey; } 107 { return LinkKey; }
108 108
109private : 109private :
110 110
111 int LinkKey; 111 int LinkKey;
112}; 112};
113}; 113};
114 114
115// 115//
116// 116//
117// 117//
118// 118//
119// 119//
120 120
121OTSniffing::OTSniffing( QWidget * parent ) : OTSniffGUI( parent ) { 121OTSniffing::OTSniffing( QWidget * parent ) : OTSniffGUI( parent ) {
122 122
123 OT = OTGateway::getOTGateway(); 123 OT = OTGateway::getOTGateway();
124 HciDump = 0; 124 HciDump = 0;
125} 125}
126 126
127OTSniffing::~OTSniffing() { 127OTSniffing::~OTSniffing() {
128 SLOT_Trace( 0 ); 128 SLOT_Trace( 0 );
129} 129}
130 130
131void OTSniffing::SLOT_Trace( bool Run ) { 131void 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
186void OTSniffing::SLOT_Show( const QString & S ) { 186void 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
197void OTSniffing::SLOT_ProcessExited( MyProcess * ) { 196void 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
203void OTSniffing::SLOT_Save( void ) { 202void 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
225void OTSniffing::SLOT_Load( void ) { 224void 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
250void OTSniffing::SLOT_ClearLog( void ) { 249void OTSniffing::SLOT_ClearLog( void ) {
251 // Output_LB->clear(); 250 // Output_LB->clear();
252 Output_TV->setText( "" ); 251 Output_TV->setText( "" );
253} 252}
254 253
255// 254//
256// 255//
257// 256//
258// 257//
259// 258//
260 259
261OTPairing::OTPairing( QWidget * parent, OTIcons * _IC ) : 260OTPairing::OTPairing( QWidget * parent, OTIcons * _IC ) :
262 OTPairingGUI( parent ) { 261 OTPairingGUI( parent ) {
263 262
264 OT = OTGateway::getOTGateway(); 263 OT = OTGateway::getOTGateway();
265 Icons = (_IC ) ? _IC : new OTIcons(); 264 Icons = (_IC ) ? _IC : new OTIcons();
266 MyIcons = (_IC == 0 ); 265 MyIcons = (_IC == 0 );
267 266
268 // unpairing can only be done if bluetooth is disabled 267 // unpairing can only be done if bluetooth is disabled
269 Unpair_But->setEnabled( ! OT->isEnabled() ); 268 Unpair_But->setEnabled( ! OT->isEnabled() );
270 if( ! OT->isEnabled() ) { 269 if( ! OT->isEnabled() ) {
271 Unpair_LBL->hide(); 270 Unpair_LBL->hide();
272 } else { 271 } else {
273 Unpair_LBL->show(); 272 Unpair_LBL->show();
274 } 273 }
275 274
276 // open linkkey file and load pairs 275 // open linkkey file and load pairs
277 LinkKeyArray Keys = OT->getLinkKeys(); 276 LinkKeyArray Keys = OT->getLinkKeys();
278 LinkKeyLVI * it; 277 LinkKeyLVI * it;
279 OTPeer * P; 278 OTPeer * P;
280 OTDriver * D; 279 OTDriver * D;
281 280
282 for( unsigned int i = 0 ; 281 for( unsigned int i = 0 ;
283 i < Keys.count(); 282 i < Keys.count();
284 i ++ ) { 283 i ++ ) {
285 284
286 it = new LinkKeyLVI( i, Pairs_LV ); 285 it = new LinkKeyLVI( i, Pairs_LV );
287 286
288 P = 0; 287 P = 0;
289 D = OT->findDriver( Keys[i].from() ); 288 D = OT->findDriver( Keys[i].from() );
290 289
291 if( D ) { 290 if( D ) {
292 it->setText( 0, D->devname() ); 291 it->setText( 0, D->devname() );
293 292
294 // we are source 293 // we are source
295 P = OT->findPeer( Keys[i].to() ); 294 P = OT->findPeer( Keys[i].to() );
296 295
297 if( P ) { 296 if( P ) {
298 // put name 297 // put name
299 it->setText( 1, P->name() ); 298 it->setText( 1, P->name() );
300 } else { 299 } else {
301 // unknown 300 // unknown
302 it->setText( 1, Keys[i].to().toString() ); 301 it->setText( 1, Keys[i].to().toString() );
303 } 302 }
304 303
305 // and put address as sub 304 // and put address as sub
306 QListViewItem * Sub = new QListViewItem( it ); 305 QListViewItem * Sub = new QListViewItem( it );
307 Sub->setText( 0, D->address().toString() ); 306 Sub->setText( 0, D->address().toString() );
308 Sub->setText( 1, Keys[i].to().toString() ); 307 Sub->setText( 1, Keys[i].to().toString() );
309 } else { 308 } else {
310 // perhaps we are destination 309 // perhaps we are destination
311 D = OT->findDriver( Keys[i].to() ); 310 D = OT->findDriver( Keys[i].to() );
312 311
313 if( D ) { 312 if( D ) {
314 it->setText( 1, D->devname() ); 313 it->setText( 1, D->devname() );
315 314
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
341OTPairing::~OTPairing() { 340OTPairing::~OTPairing() {
342 if( MyIcons ) 341 if( MyIcons )
343 delete Icons; 342 delete Icons;
344 OTGateway::releaseOTGateway(); 343 OTGateway::releaseOTGateway();
345} 344}
346 345
347void OTPairing::SLOT_Unpair( ) { 346void 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
376OTScan::OTScan( QWidget * parent, OTIcons * _IC ) : 375OTScan::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
425OTScan::~OTScan() { 425OTScan::~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
439int OTScan::getDevice( OTPeer *& Peer, 439int 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
498void OTScan::setScanFilter( const UUIDVector & V ) { 506void OTScan::setScanFilter( const UUIDVector & V ) {
499 Filter = V; 507 Filter = V;
500} 508}
501 509
502void OTScan::resetScanFilter( void ) { 510void OTScan::resetScanFilter( void ) {
503 Filter.truncate(0); 511 Filter.truncate(0);
504} 512}
505 513
506void OTScan::SLOT_DoScan( bool DoIt ) { 514void 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();
511 } 519 }
512 520
513 scanMode( DoIt ); 521 scanMode( DoIt );
514} 522}
515 523
516// double clicked on a device 524// double clicked on a device
517void OTScan::SLOT_Selected( QListViewItem * it ) { 525void OTScan::SLOT_Selected( QListViewItem * it ) {
518 if( ! it ) 526 if( ! it )
519 return; 527 return;
520 528
521 if( Filter.count() > 0 ) { 529 if( Filter.count() > 0 ) {
522 // filter on service 530 // filter on service
523 if( it->depth() == 0 ) { 531 if( it->depth() == 0 ) {
524 // select a service and not a device 532 // select a service and not a device
525 return; 533 return;
526 } 534 }
527 535
528 // store result 536 // store result
529 SelectedPeer = ((PeerLVI *)it->parent())->peer(); 537 SelectedPeer = ((PeerLVI *)it->parent())->peer();
530 SelectedChannel = ((ChannelLVI *)it)->channel(); 538 SelectedChannel = ((ChannelLVI *)it)->channel();
531 } else { 539 } else {
532 // click on device 540 // click on device
533 if( it->depth() != 0 ) { 541 if( it->depth() != 0 ) {
534 return; 542 return;
535 } 543 }
536 544
537 SelectedPeer = ((PeerLVI *)it)->peer(); 545 SelectedPeer = ((PeerLVI *)it)->peer();
538 SelectedChannel = 0; 546 SelectedChannel = 0;
539 } 547 }
540 odebug << "Selected " << SelectedPeer->address().toString() << 548 odebug << "Selected " << SelectedPeer->address().toString() <<
541 " Channel " << SelectedChannel << oendl; 549 " Channel " << SelectedChannel << oendl;
542 emit selected(); 550 emit selected();
543} 551}
544 552
545void OTScan::SLOT_FinishedDetecting( ) { 553void OTScan::SLOT_FinishedDetecting( ) {
546 scanMode( false ); 554 scanMode( false );
547} 555}
548 556
549void OTScan::SLOT_CleanupOld( ) { 557void OTScan::SLOT_CleanupOld( ) {
550 558
551 // iterate over all peers and find those that 559 // iterate over all peers and find those that
552 // are down and have no pairing info 560 // are down and have no pairing info
553 OTPeer * TheP; 561 OTPeer * TheP;
554 const LinkKeyArray & Keys = OT->getLinkKeys(); 562 const LinkKeyArray & Keys = OT->getLinkKeys();
555 563
556 QListViewItem * Lit = DetectedPeers_LV->firstChild(); 564 QListViewItem * Lit = DetectedPeers_LV->firstChild();
557 while( Lit ) { 565 while( Lit ) {
558 TheP = ((PeerLVI *)Lit)->peer(); 566 TheP = ((PeerLVI *)Lit)->peer();
559 if( TheP->state() == OTPeer::Peer_Down ) { 567 if( TheP->state() == OTPeer::Peer_Down ) {
560 unsigned int k; 568 unsigned int k;
561 569
562 // what about linkkeys ? 570 // what about linkkeys ?
563 for( k = 0; k < Keys.count(); k ++ ) { 571 for( k = 0; k < Keys.count(); k ++ ) {
564 if( TheP->address() == Keys[k].to() || 572 if( TheP->address() == Keys[k].to() ||
565 TheP->address() == Keys[k].from() 573 TheP->address() == Keys[k].from()
566 ) { 574 ) {
567 // part of linkkey 575 // part of linkkey
568 odebug << "LINKKEY " << TheP->address().toString() << oendl; 576 odebug << "LINKKEY " << TheP->address().toString() << oendl;
569 break; 577 break;
570 } 578 }
571 } 579 }
572 580
573 if( k == Keys.count() ) { 581 if( k == Keys.count() ) {
574 odebug << "RM LINKKEY " << TheP->address().toString() << oendl; 582 odebug << "RM LINKKEY " << TheP->address().toString() << oendl;
575 // not found -> remember to remove this peer 583 // not found -> remember to remove this peer
576 QListViewItem * Nit; 584 QListViewItem * Nit;
577 OT->removePeer( TheP ); 585 OT->removePeer( TheP );
578 Nit = Lit->nextSibling(); 586 Nit = Lit->nextSibling();
579 delete Lit; 587 delete Lit;
580 Lit = Nit; 588 Lit = Nit;
581 continue; 589 continue;
582 } 590 }
583 } else { 591 } else {
584 odebug << "NODOWN " << TheP->address().toString() << oendl; 592 odebug << "NODOWN " << TheP->address().toString() << oendl;
585 } 593 }
586 594
587 Lit = Lit->nextSibling(); 595 Lit = Lit->nextSibling();
588 } 596 }
589} 597}
590 598
591void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){ 599void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){
592 PeerLVI * it = 0; 600 PeerLVI * it = 0;
593 601
594 if( IsNew ) { 602 if( IsNew ) {
595 it = new PeerLVI( P, DetectedPeers_LV ); 603 it = new PeerLVI( P, DetectedPeers_LV );
596 } else { 604 } else {
597 // find peer in table 605 // find peer in table
598 QListViewItem * Lit = DetectedPeers_LV->firstChild(); 606 QListViewItem * Lit = DetectedPeers_LV->firstChild();
599 while( Lit ) { 607 while( Lit ) {
600 if( ((PeerLVI *)Lit)->peer() == P ) { 608 if( ((PeerLVI *)Lit)->peer() == P ) {
601 // this item 609 // this item
602 it = (PeerLVI *)Lit; 610 it = (PeerLVI *)Lit;
603 break; 611 break;
604 } 612 }
605 Lit = Lit->nextSibling(); 613 Lit = Lit->nextSibling();
606 } 614 }
607 615
608 if( ! it ) { 616 if( ! it ) {
609 odebug << "Should not occur" << oendl; 617 odebug << "Should not occur" << oendl;
610 return; 618 return;
611 } 619 }
612 } 620 }
613 621
614 // update/show info 622 // update/show info
615 it->setText( 0, P->name() ); 623 it->setText( 0, P->name() );
616 it->setPixmap(0, Icons->deviceIcon( 624 it->setPixmap(0, Icons->deviceIcon(
617 OT->deviceTypeToName( P->deviceClass() ) ) ); 625 OT->deviceTypeToName( P->deviceClass() ) ) );
618 626
619 // tell peer to report its state async 627 // tell peer to report its state async
620 connect( P, 628 connect( P,
621 SIGNAL( peerStateReport( OTPeer *)), 629 SIGNAL( peerStateReport( OTPeer *)),
622 this, 630 this,
623 SLOT( SLOT_PeerState( OTPeer *)) 631 SLOT( SLOT_PeerState( OTPeer *))
624 ); 632 );
625 633
626 if( IsNew ) { 634 if( IsNew ) {
627 // find state 635 // find state
628 refreshState( (PeerLVI *)it, 1 ); 636 refreshState( (PeerLVI *)it, 1 );
629 } else { 637 } else {
630 // update staet 638 // update staet
631 SLOT_PeerState( P ); 639 SLOT_PeerState( P );
632 } 640 }
633} 641}
634 642
635void OTScan::SLOT_PeerState( OTPeer * P ) { 643void OTScan::SLOT_PeerState( OTPeer * P ) {
636 PeerLVI * it = (PeerLVI *)DetectedPeers_LV->firstChild(); 644 PeerLVI * it = (PeerLVI *)DetectedPeers_LV->firstChild();
637 while( it ) { 645 while( it ) {
638 if( it->peer() == P ) { 646 if( it->peer() == P ) {
639 break; 647 break;
640 } 648 }
641 it = (PeerLVI * )it->nextSibling(); 649 it = (PeerLVI * )it->nextSibling();
642 } 650 }
643 651
644 if( ! it ) 652 if( ! it )
645 return; 653 return;
646 654
647 switch( P->state() ) { 655 switch( P->state() ) {
648 case OTPeer::Peer_Unknown : 656 case OTPeer::Peer_Unknown :
649 case OTPeer::Peer_Down : 657 case OTPeer::Peer_Down :
650 it->setPixmap( 1, 0 ); 658 it->setPixmap( 1, 0 );
651 break; 659 break;
652 case OTPeer::Peer_Up : 660 case OTPeer::Peer_Up :
653 it->setPixmap( 1, Icons->loadPixmap( 661 it->setPixmap( 1, Icons->loadPixmap(
654 ( P->connectedTo() ) ? "connected" : "notconnected" ) ); 662 ( P->connectedTo() ) ? "connected" : "notconnected" ) );
655 if( it == Current && ! StrengthTimer->isActive() ) { 663 if( it == Current && ! StrengthTimer->isActive() ) {
656 // start showing strength 664 // start showing strength
657 StrengthTimer->start( 1000, FALSE ); 665 StrengthTimer->start( 1000, FALSE );
658 SLOT_UpdateStrength(); 666 SLOT_UpdateStrength();
659 } 667 }
660 break; 668 break;
661 } 669 }
662} 670}
663 671
664void OTScan::SLOT_RefreshState( void ) { 672void OTScan::SLOT_RefreshState( void ) {
665 673
666 QListViewItem * it = DetectedPeers_LV->firstChild(); 674 QListViewItem * it = DetectedPeers_LV->firstChild();
667 while( it ) { 675 while( it ) {
668 if( it->isSelected() ) { 676 if( it->isSelected() ) {
669 break; 677 break;
670 } 678 }
671 it = it->nextSibling(); 679 it = it->nextSibling();
672 } 680 }
673 681
674 if( ! it ) 682 if( ! it )
675 return; 683 return;
676 684
677 refreshState( (PeerLVI *)it, 1 ); 685 refreshState( (PeerLVI *)it, 1 );
678} 686}
679 687
680void OTScan::refreshState( PeerLVI * it, bool Force ) { 688void OTScan::refreshState( PeerLVI * it, bool Force ) {
681 it->setPixmap( 1, Icons->loadPixmap( "find" ) ); 689 it->setPixmap( 1, Icons->loadPixmap( "find" ) );
682 it->peer()->findOutState( 30, Force ); 690 it->peer()->findOutState( 30, Force );
683} 691}
684 692
685void OTScan::SLOT_Show( QListViewItem * it ) { 693void OTScan::SLOT_Show( QListViewItem * it ) {
686 694
687 if( ! it || it->depth() > 0 ) 695 if( ! it || it->depth() > 0 )
688 return; 696 return;
689 697
690 QString S; 698 QString S;
691 699
692 Current = (PeerLVI *)it; 700 Current = (PeerLVI *)it;
693 701
694 Strength_PB->setProgress( 0 ); // reset 702 Strength_PB->setProgress( 0 ); // reset
695 Address_LBL->setText( Current->peer()->address().toString() ); 703 Address_LBL->setText( Current->peer()->address().toString() );
696 Peer_GB->setTitle( Current->peer()->name() ); 704 Peer_GB->setTitle( Current->peer()->name() );
697 705
698 const LinkKeyArray & Keys = OT->getLinkKeys(); 706 const LinkKeyArray & Keys = OT->getLinkKeys();
699 707
700 Paired_Led->setOn( FALSE ); 708 Paired_Led->setOn( FALSE );
701 for( unsigned int i = 0; 709 for( unsigned int i = 0;
702 i < Keys.count(); 710 i < Keys.count();
703 i ++ ) { 711 i ++ ) {
704 if( Current->peer()->address() == Keys[i].to() ) { 712 if( Current->peer()->address() == Keys[i].to() ) {
705 Paired_Led->setOn( TRUE ); 713 Paired_Led->setOn( TRUE );
706 break; 714 break;
707 } 715 }
708 } 716 }
709 717
710 if( Current->peer()->state() == OTPeer::Peer_Up ) { 718 if( Current->peer()->state() == OTPeer::Peer_Up ) {
711 RefreshServices_But->setEnabled( TRUE ); 719 RefreshServices_But->setEnabled( TRUE );
712 StrengthTimer->start( 1000, FALSE ); 720 StrengthTimer->start( 1000, FALSE );
713 SLOT_UpdateStrength(); 721 SLOT_UpdateStrength();
714 } else { 722 } else {
715 RefreshServices_But->setEnabled( FALSE ); 723 RefreshServices_But->setEnabled( FALSE );
716 } 724 }
717 725
718} 726}
719 727
720void OTScan::SLOT_UpdateStrength( void ) { 728void OTScan::SLOT_UpdateStrength( void ) {
721 OTDriver * D = Current->peer()->connectedTo(); 729 OTDriver * D = Current->peer()->connectedTo();
722 730
723 if( D ) { 731 if( D ) {
724 long Q = D->getLinkQuality( Current->peer()->address() ); 732 long Q = D->getLinkQuality( Current->peer()->address() );
725 Strength_PB->setProgress( Q ); 733 Strength_PB->setProgress( Q );
726 if( ! Q ) { 734 if( ! Q ) {
727 // no quality 735 // no quality
728 Strength_PB->setEnabled( TRUE ); 736 Strength_PB->setEnabled( TRUE );
729 StrengthTimer->stop(); 737 StrengthTimer->stop();
730 } 738 }
731 } else { 739 } else {
732 Strength_PB->setEnabled( FALSE ); 740 Strength_PB->setEnabled( FALSE );
733 Strength_PB->setProgress( 0 ); 741 Strength_PB->setProgress( 0 );
734 // no point in continuing 742 // no point in continuing
735 StrengthTimer->stop(); 743 StrengthTimer->stop();
736 } 744 }
737} 745}
738 746
739void OTScan::SLOT_RefreshServices( void ) { 747void OTScan::SLOT_RefreshServices( void ) {
740 748
741 QListViewItem * it = DetectedPeers_LV->firstChild(); 749 QListViewItem * it = DetectedPeers_LV->firstChild();
742 while( it ) { 750 while( it ) {
743 if( it->isSelected() ) { 751 if( it->isSelected() ) {
744 break; 752 break;
745 } 753 }
746 it = it->nextSibling(); 754 it = it->nextSibling();
747 } 755 }
748 756
749 if( ! it ) 757 if( ! it )
750 return; 758 return;
751 759
752 QString S; 760 QString S;
753 PeerLVI * PI = (PeerLVI *)it; 761 PeerLVI * PI = (PeerLVI *)it;
754 762
755 scanMode( true ); 763 scanMode( true );
756 qApp->processEvents(0); 764 qApp->processEvents(0);
757 765
758 ServiceVector & V = PI->peer()->services(); 766 ServiceVector & V = PI->peer()->services();
759 767
760 while( PI->firstChild() ) { 768 while( PI->firstChild() ) {
761 // remove children 769 // remove children
762 delete PI->firstChild(); 770 delete PI->firstChild();
763 } 771 }
764 772
765 for( unsigned int i = 0 ; 773 for( unsigned int i = 0 ;
766 i < V.count(); 774 i < V.count();
767 i ++ ) { 775 i ++ ) {
768 QString S; 776 QString S;
769 S = V[i]->name(); 777 S = V[i]->name();
770 778
771 if( S.isEmpty() ) { 779 if( S.isEmpty() ) {
772 continue; 780 continue;
773 } 781 }
774 782
775 { QListViewItem * SIt; 783 { QListViewItem * SIt;
776 UUIDVector UIDV; 784 UUIDVector UIDV;
777 QPixmap Pm; 785 QPixmap Pm;
778 bool Done = 0; 786 bool Done = 0;
779 bool R; 787 bool R;
780 short ID; 788 short ID;
781 789
782 SIt = 0; 790 SIt = 0;
783 791
784 UIDV = V[i]->classIDList(); 792 UIDV = V[i]->classIDList();
785 // first all UUID ! 1200 12ff (Genericprofiles) 793 // first all UUID ! 1200 12ff (Genericprofiles)
786 for( unsigned int j = 0; 794 for( unsigned int j = 0;
787 j < UIDV.count(); 795 j < UIDV.count();
788 j ++ ) { 796 j ++ ) {
789 797
790 if( Filter.count() ) { 798 if( Filter.count() ) {
791 bool FilterOut = 1; 799 bool FilterOut = 1;
792 // filter out if not in list 800 // filter out if not in list
793 for( unsigned int ff = 0; 801 for( unsigned int ff = 0;
794 ff < Filter.count(); 802 ff < Filter.count();
795 ff ++ ) { 803 ff ++ ) {
796 if( UIDV[j] == Filter[ff] ) { 804 if( UIDV[j] == Filter[ff] ) {
797 FilterOut = 0; 805 FilterOut = 0;
798 break; 806 break;
799 } 807 }
800 } 808 }
801 809
802 if( FilterOut ) { 810 if( FilterOut ) {
803 // not in filter list 811 // not in filter list
804 continue; 812 continue;
805 } 813 }
806 } // else show 814 } // else show
807 815
808 ID = UIDV[j].toShort(); 816 ID = UIDV[j].toShort();
809 if( ID < 0x1200 || ID > 0x12ff ) { 817 if( ID < 0x1200 || ID > 0x12ff ) {
810 // use this profile 818 // use this profile
811 if( R ) { 819 if( R ) {
812 unsigned int ch; 820 unsigned int ch;
813 bool has; 821 bool has;
814 has = V[i]->rfcommChannel( ch ); 822 has = V[i]->rfcommChannel( ch );
815 SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); 823 SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI );
816 SIt->setText(0, V[i]->name() ); 824 SIt->setText(0, V[i]->name() );
817 825
818 Pm = Icons->serviceIcon( ID, R ); 826 Pm = Icons->serviceIcon( ID, R );
819 SIt->setPixmap(0, Pm ); 827 SIt->setPixmap(0, Pm );
820 Done = 1; 828 Done = 1;
821 break; 829 break;
822 } 830 }
823 } 831 }
824 } 832 }
825 833
826 if( ! Done ) { 834 if( ! Done ) {
827 // check other range too 835 // check other range too
828 for( unsigned int j = 0; 836 for( unsigned int j = 0;
829 j < UIDV.count(); 837 j < UIDV.count();
830 j ++ ) { 838 j ++ ) {
831 839
832 if( Filter.count() ) { 840 if( Filter.count() ) {
833 bool FilterOut = 1; 841 bool FilterOut = 1;
834 // filter out if not in list 842 // filter out if not in list
835 for( unsigned int ff = 0; 843 for( unsigned int ff = 0;
836 ff < Filter.count(); 844 ff < Filter.count();
837 ff ++ ) { 845 ff ++ ) {
838 if( UIDV[j] == Filter[ff] ) { 846 if( UIDV[j] == Filter[ff] ) {
839 FilterOut = 0; 847 FilterOut = 0;
840 break; 848 break;
841 } 849 }
842 } 850 }
843 851
844 if( FilterOut ) { 852 if( FilterOut ) {
845 // not in filter list 853 // not in filter list
846 continue; 854 continue;
847 } 855 }
848 } // else show 856 } // else show
849 857
850 ID = UIDV[j].toShort(); 858 ID = UIDV[j].toShort();
851 if( ID >= 0x1200 && ID <= 0x12ff ) { 859 if( ID >= 0x1200 && ID <= 0x12ff ) {
852 // use this profile 860 // use this profile
853 unsigned int ch; 861 unsigned int ch;
854 bool has; 862 bool has;
855 has = V[i]->rfcommChannel( ch ); 863 has = V[i]->rfcommChannel( ch );
856 SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); 864 SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI );
857 SIt->setText(0, V[i]->name() ); 865 SIt->setText(0, V[i]->name() );
858 866
859 Pm = Icons->serviceIcon( ID, R ); 867 Pm = Icons->serviceIcon( ID, R );
860 SIt->setPixmap(0, Pm ); 868 SIt->setPixmap(0, Pm );
861 869
862 break; 870 break;
863 } 871 }
864 } 872 }
865 } 873 }
866 874
867 } 875 }
868 } 876 }
869 877
870 scanMode( false ); 878 scanMode( false );
871} 879}
872 880
873void OTScan::scanMode( bool M ) { 881void OTScan::scanMode( bool M ) {
874 // avoid infinite loop because it triggers DoScan 882 // avoid infinite loop because it triggers DoScan
875 Detect_But->blockSignals( TRUE ); 883 Detect_But->blockSignals( TRUE );
876 Detect_But->setOn( M ); 884 Detect_But->setOn( M );
877 Detect_But->setText( (M) ? tr("Scanning") : tr("Scan") ); 885 Detect_But->setText( (M) ? tr("Scanning") : tr("Scan") );
878 Detect_But->blockSignals( FALSE ); 886 Detect_But->blockSignals( FALSE );
879} 887}
880 888
881// 889//
882// 890//
883// 891//
884// 892//
885// 893//
886 894
887OTManage::OTManage( QWidget * parent, OTIcons * _IC ) : 895OTManage::OTManage( QWidget * parent, OTIcons * _IC ) :
888 OTManageGUI( parent ) { 896 OTManageGUI( parent ) {
889 897
890 OT = OTGateway::getOTGateway(); 898 OT = OTGateway::getOTGateway();
891 899
892 Icons = (_IC ) ? _IC : new OTIcons(); 900 Icons = (_IC ) ? _IC : new OTIcons();
893 MyIcons = (_IC == 0 ); 901 MyIcons = (_IC == 0 );
894 AllDrivers_LV->setSorting(-1); 902 AllDrivers_LV->setSorting(-1);
895 903
896 connect( OT, 904 connect( OT,
897 SIGNAL( driverListChanged() ), 905 SIGNAL( driverListChanged() ),
898 this, 906 this,
899 SLOT( SLOT_DriverListChanged() ) 907 SLOT( SLOT_DriverListChanged() )
900 ); 908 );
901 connect( OT, 909 connect( OT,
902 SIGNAL( stateChange( OTDriver *, bool ) ), 910 SIGNAL( stateChange( OTDriver *, bool ) ),
903 this, 911 this,
904 SLOT( SLOT_StateChange( OTDriver *, bool ) ) 912 SLOT( SLOT_StateChange( OTDriver *, bool ) )
905 ); 913 );
906 914
907 SLOT_DriverListChanged(); 915 SLOT_DriverListChanged();
908 916
909 AllDrivers_LV->header()->hide(); 917 AllDrivers_LV->header()->hide();
910} 918}
911 919
912OTManage::~OTManage() { 920OTManage::~OTManage() {
913 if( MyIcons ) 921 if( MyIcons )
914 delete Icons; 922 delete Icons;
915 OTGateway::releaseOTGateway(); 923 OTGateway::releaseOTGateway();
916} 924}
917 925
918void OTManage::SLOT_ShowDriver( QListViewItem * It ) { 926void OTManage::SLOT_ShowDriver( QListViewItem * It ) {
919 if( It == 0 || It->depth() > 0 ) 927 if( It == 0 || It->depth() > 0 )
920 // not toplevel 928 // not toplevel
921 return; 929 return;
922 930
923 DriverLVI * it = (DriverLVI *) It; 931 DriverLVI * it = (DriverLVI *) It;
924 DriverIsUp_CB->setChecked( it->driver()->isUp() ); 932 DriverIsUp_CB->setChecked( it->driver()->isUp() );
925} 933}
926 934
927void OTManage::SLOT_UpDriver( bool Up ) { 935void OTManage::SLOT_UpDriver( bool Up ) {
928 QListViewItem * it = AllDrivers_LV->firstChild(); 936 QListViewItem * it = AllDrivers_LV->firstChild();
929 while( it ) { 937 while( it ) {
930 if( it->isSelected() ) { 938 if( it->isSelected() ) {
931 OTDriver * D = ((DriverLVI *)it)->driver(); 939 OTDriver * D = ((DriverLVI *)it)->driver();
932 odebug << "UP driver " << D->devname() << oendl; 940 odebug << "UP driver " << D->devname() << oendl;
933 // this 941 // this
934 D->setUp( Up ); 942 D->setUp( Up );
935 return; 943 return;
936 } 944 }
937 it = it->nextSibling(); 945 it = it->nextSibling();
938 } 946 }
939} 947}
940 948
941void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) { 949void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) {
942 QListViewItem * it = AllDrivers_LV->firstChild(); 950 QListViewItem * it = AllDrivers_LV->firstChild();
943 while( it ) { 951 while( it ) {
944 if( ((DriverLVI *)it)->driver() == D ) { 952 if( ((DriverLVI *)it)->driver() == D ) {
945 it->setPixmap( 0, 953 it->setPixmap( 0,
946 Icons->loadPixmap( ( Up ) ? "bluezon" : "bluezoff" ) ); 954 Icons->loadPixmap( ( Up ) ? "bluezon" : "bluezoff" ) );
947 return; 955 return;
948 } 956 }
949 it = it->nextSibling(); 957 it = it->nextSibling();
950 } 958 }
951} 959}
952 960
953void OTManage::SLOT_DriverListChanged( ) { 961void OTManage::SLOT_DriverListChanged( ) {
954 DriverLVI * It; 962 DriverLVI * It;
955 QListViewItem * Sub; 963 QListViewItem * Sub;
956 QListViewItem * First = 0; 964 QListViewItem * First = 0;
957 OTDriver* D; 965 OTDriver* D;
958 OTDriverList & DL = OT->getDriverList(); 966 OTDriverList & DL = OT->getDriverList();
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
@@ -1,235 +1,237 @@
1#include <qfile.h> 1#include <qfile.h>
2#include <qfileinfo.h> 2#include <qfileinfo.h>
3#include "PPPedit.h" 3#include "PPPedit.h"
4#include "ppp_NNI.h" 4#include "ppp_NNI.h"
5#include "ppp_NN.h" 5#include "ppp_NN.h"
6 6
7APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) { 7APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) {
8 Data.DNS.ServerAssigned = 1; 8 Data.DNS.ServerAssigned = 1;
9 Data.DNS.DomainName = ""; 9 Data.DNS.DomainName = "";
10 10
11 Data.Auth.Mode = 0; 11 Data.Auth.Mode = 0;
12 Data.Auth.Login.Expect = "ogin:"; 12 Data.Auth.Login.Expect = "ogin:";
13 Data.Auth.Password.Expect = "assword:"; 13 Data.Auth.Password.Expect = "assword:";
14 Data.Auth.PCEMode = 0; 14 Data.Auth.PCEMode = 0;
15 Data.Auth.Client = "*"; 15 Data.Auth.Client = "*";
16 Data.Auth.Server = "*"; 16 Data.Auth.Server = "*";
17 Data.Auth.Secret = ""; 17 Data.Auth.Secret = "";
18 18
19 Data.IP.LocalAddress = "10.0.0.1"; 19 Data.IP.LocalAddress = "10.0.0.1";
20 Data.IP.RemoteAddress = "10.0.0.2"; 20 Data.IP.RemoteAddress = "10.0.0.2";
21 Data.IP.LocalOverrule = 1; 21 Data.IP.LocalOverrule = 1;
22 Data.IP.RemoteOverrule = 1; 22 Data.IP.RemoteOverrule = 1;
23 23
24 Data.IP.GWAutomatic = 1; 24 Data.IP.GWAutomatic = 1;
25 Data.IP.GWAddress = ""; 25 Data.IP.GWAddress = "";
26 Data.IP.GWIsDefault = 1; 26 Data.IP.GWIsDefault = 1;
27 Data.IP.GWIfNotSet = 1; 27 Data.IP.GWIfNotSet = 1;
28 28
29 Data.Run.PreConnect = ""; 29 Data.Run.PreConnect = "";
30 Data.Run.PostConnect = ""; 30 Data.Run.PostConnect = "";
31 Data.Run.PreDisconnect = ""; 31 Data.Run.PreDisconnect = "";
32 Data.Run.PostDisconnect = ""; 32 Data.Run.PostDisconnect = "";
33 33
34 GUI = 0; 34 GUI = 0;
35 RT = 0; 35 RT = 0;
36 36
37} 37}
38 38
39void APPP::setSpecificAttribute( QString & A, QString & V ) { 39void APPP::setSpecificAttribute( QString & A, QString & V ) {
40 if( A.startsWith( "dns" ) ) { 40 if( A.startsWith( "dns" ) ) {
41 if( A == "dnsserverassigned" ) { 41 if( A == "dnsserverassigned" ) {
42 Data.DNS.ServerAssigned = (V == "yes"); 42 Data.DNS.ServerAssigned = (V == "yes");
43 } else if( A == "dnsdomainname" ) { 43 } else if( A == "dnsdomainname" ) {
44 Data.DNS.DomainName = V; 44 Data.DNS.DomainName = V;
45 } else if( A == "dnsserver" ) { 45 } else if( A == "dnsserver" ) {
46 Data.DNS.Servers.resize( Data.DNS.Servers.size()+1 ); 46 Data.DNS.Servers.resize( Data.DNS.Servers.size()+1 );
47 Data.DNS.Servers[Data.DNS.Servers.size()-1] = 47 Data.DNS.Servers[Data.DNS.Servers.size()-1] =
48 new QString( V ); 48 new QString( V );
49 } 49 }
50 } else if( A.startsWith( "auth" ) ) { 50 } else if( A.startsWith( "auth" ) ) {
51 if( A == "authmode" ) { 51 if( A == "authmode" ) {
52 Data.Auth.Mode = V.toShort(); 52 Data.Auth.Mode = V.toShort();
53 } else if( A == "authloginexpect" ) { 53 } else if( A == "authloginexpect" ) {
54 Data.Auth.Login.Expect = V; 54 Data.Auth.Login.Expect = V;
55 } else if( A == "authloginsend" ) { 55 } else if( A == "authloginsend" ) {
56 Data.Auth.Login.Send = V; 56 Data.Auth.Login.Send = V;
57 } else if( A == "authpasswordexpect" ) { 57 } else if( A == "authpasswordexpect" ) {
58 Data.Auth.Password.Expect = V; 58 Data.Auth.Password.Expect = V;
59 } else if( A == "authpasswordsend" ) { 59 } else if( A == "authpasswordsend" ) {
60 Data.Auth.Password.Send = V; 60 Data.Auth.Password.Send = V;
61 } else if( A == "authpcemode" ) { 61 } else if( A == "authpcemode" ) {
62 Data.Auth.PCEMode = V.toShort(); 62 Data.Auth.PCEMode = V.toShort();
63 } else if( A == "authclient" ) { 63 } else if( A == "authclient" ) {
64 Data.Auth.Client = V; 64 Data.Auth.Client = V;
65 } else if( A == "authserver" ) { 65 } else if( A == "authserver" ) {
66 Data.Auth.Server = V; 66 Data.Auth.Server = V;
67 } else if( A == "authsecret" ) { 67 } else if( A == "authsecret" ) {
68 Data.Auth.Secret = V; 68 Data.Auth.Secret = V;
69 } 69 }
70 } else if( A.startsWith( "ip" ) ) { 70 } else if( A.startsWith( "ip" ) ) {
71 if( A == "iplocaloverrule" ) { 71 if( A == "iplocaloverrule" ) {
72 Data.IP.LocalOverrule = (V == "yes"); 72 Data.IP.LocalOverrule = (V == "yes");
73 } else if( A == "ipremoteoverrule" ) { 73 } else if( A == "ipremoteoverrule" ) {
74 Data.IP.RemoteOverrule = (V == "yes"); 74 Data.IP.RemoteOverrule = (V == "yes");
75 } else if( A == "ipgwautomatic" ) { 75 } else if( A == "ipgwautomatic" ) {
76 Data.IP.GWAutomatic = (V == "yes"); 76 Data.IP.GWAutomatic = (V == "yes");
77 } else if( A == "ipgwisdefault" ) { 77 } else if( A == "ipgwisdefault" ) {
78 Data.IP.GWIsDefault = (V == "yes"); 78 Data.IP.GWIsDefault = (V == "yes");
79 } else if( A == "ipgwifnotset" ) { 79 } else if( A == "ipgwifnotset" ) {
80 Data.IP.GWIfNotSet = (V == "yes"); 80 Data.IP.GWIfNotSet = (V == "yes");
81 } else if( A == "iplocaladdress" ) { 81 } else if( A == "iplocaladdress" ) {
82 Data.IP.LocalAddress = V; 82 Data.IP.LocalAddress = V;
83 } else if( A == "ipremoteaddress" ) { 83 } else if( A == "ipremoteaddress" ) {
84 Data.IP.RemoteAddress = V; 84 Data.IP.RemoteAddress = 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
101void APPP::saveSpecificAttribute( QTextStream & TS ) { 101void 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
133QWidget * APPP::edit( QWidget * parent ) { 133QWidget * 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
139QString APPP::acceptable( void ) { 139QString APPP::acceptable( void ) {
140 return ( GUI ) ? GUI->acceptable( ) : QString(); 140 return ( GUI ) ? GUI->acceptable( ) : QString();
141} 141}
142 142
143void APPP::commit( void ) { 143void 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
149bool APPP::openFile( SystemFile & SF ) { 149bool 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
162short APPP::generateFile( SystemFile & SF, long DevNr ) { 164short 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 "
219 << removeSpaces( SF.name().latin1() ) 221 << removeSpaces( SF.name().latin1() )
220 << endl; 222 << endl;
221 223
222 // insert other data here 224 // insert other data here
223 rvl = 0; 225 rvl = 0;
224 rvd = networkSetup()->getToplevel()->generateFileEmbedded( 226 rvd = networkSetup()->getToplevel()->generateFileEmbedded(
225 SF, DevNr ); 227 SF, DevNr );
226 } else if ( SF.name() == "chatscripts" ) { 228 } else if ( SF.name() == "chatscripts" ) {
227 Log(("Generate PPP for %s\n", SF.name().latin1() )); 229 Log(("Generate PPP for %s\n", SF.name().latin1() ));
228 rvl = 0; 230 rvl = 0;
229 rvd = networkSetup()->getToplevel()->generateFileEmbedded( 231 rvd = networkSetup()->getToplevel()->generateFileEmbedded(
230 SF, DevNr ); 232 SF, DevNr );
231 } 233 }
232 234
233 return (rvd == 2 || rvl == 2 ) ? 2 : 235 return (rvd == 2 || rvl == 2 ) ? 2 :
234 (rvd == 0 || rvl == 0 ) ? 0 : 1; 236 (rvd == 0 || rvl == 0 ) ? 0 : 1;
235} 237}
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
8class PPPNetNode; 8class PPPNetNode;
9class PPPEdit; 9class PPPEdit;
10class QTextStream; 10class QTextStream;
11 11
12class APPP : public ANetNodeInstance { 12class APPP : public ANetNodeInstance {
13 13
14public : 14public :
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
32protected : 32protected :
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
37private : 37private :
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
5State_t ProfileRun::detectState( void ) { 5State_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
16QString ProfileRun::setMyState( NetworkSetup * NC, Action_t A, bool ) { 15QString 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}