summaryrefslogtreecommitdiff
path: root/noncore
authorwimpie <wimpie>2005-01-12 01:40:53 (UTC)
committer wimpie <wimpie>2005-01-12 01:40:53 (UTC)
commitf9a83585111afa08a47176097a150d9f468bfcdf (patch) (unidiff)
tree6d5a3b5f9716f7c6ca6e7fae8b0e2bac8d6c57da /noncore
parentb2e60aa0222b348f34aab501feb8bc854e94413c (diff)
downloadopie-f9a83585111afa08a47176097a150d9f468bfcdf.zip
opie-f9a83585111afa08a47176097a150d9f468bfcdf.tar.gz
opie-f9a83585111afa08a47176097a150d9f468bfcdf.tar.bz2
*** empty log message ***
Diffstat (limited to 'noncore') (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,21 +1,33 @@
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 }
@@ -46,61 +58,74 @@ QString BluetoothRFCOMMRun::setMyState( NetworkSetup *,
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 ).
@@ -111,25 +136,28 @@ RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) {
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();
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
@@ -198,34 +198,37 @@ short AGPRSDevice::generateFile( SystemFile & SF,
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
@@ -15,25 +15,26 @@ public :
15 15
16 AGPRSDevice( GPRSNetNode * PNN ); 16 AGPRSDevice( GPRSNetNode * PNN );
17 17
18 RuntimeInfo * runtime( void ) 18 RuntimeInfo * runtime( void )
19 { return 19 { return
20 ( RT ) ? RT : ( RT = new GPRSRun( this, Data ) ); 20 ( RT ) ? RT : ( RT = new GPRSRun( this, Data ) );
21 } 21 }
22 22
23 QWidget * edit( QWidget * parent ); 23 QWidget * edit( QWidget * parent );
24 QString acceptable( void ); 24 QString acceptable( void );
25 void commit( void ); 25 void commit( void );
26 26
27 virtual bool openFile( SystemFile & SF ); 27 virtual bool openFile( SystemFile & SF,
28 QStringList & SL );
28 29
29 virtual void * data( void ) 30 virtual void * data( void )
30 { return (void *)&Data; } 31 { return (void *)&Data; }
31 32
32 virtual bool hasDataForFile( SystemFile & S ); 33 virtual bool hasDataForFile( SystemFile & S );
33 virtual short generateFile( SystemFile & SF, 34 virtual short generateFile( SystemFile & SF,
34 long DevNr ); 35 long DevNr );
35 36
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 );
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
@@ -242,25 +242,25 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
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 );
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
@@ -80,26 +80,27 @@ void ANetNode::setAttribute( QString & Attr, QString & Value ){
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 )
@@ -397,29 +398,31 @@ State_t NetworkSetup::state( bool Update ) {
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;
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
@@ -112,28 +112,33 @@ public:
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
@@ -250,25 +255,26 @@ public:
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();
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
@@ -327,30 +327,41 @@ QString NetworkSettingsData::generateSettings( void ) {
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 ) {
@@ -370,33 +381,44 @@ QString NetworkSettingsData::generateSettings( void ) {
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 }
@@ -776,12 +798,35 @@ QList<NetworkSetup> NetworkSettingsData::collectTriggered(
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
@@ -20,19 +20,20 @@ public :
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
@@ -175,25 +175,24 @@ void OTSniffing::SLOT_Trace( bool Run ) {
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;
@@ -368,24 +367,25 @@ void OTPairing::SLOT_Unpair( ) {
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())
@@ -435,24 +435,32 @@ OTScan::~OTScan() {
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
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
@@ -137,30 +137,32 @@ QWidget * APPP::edit( QWidget * parent ) {
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;
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
@@ -16,25 +16,25 @@ public :
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;
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,21 +1,20 @@
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 );