summaryrefslogtreecommitdiff
Side-by-side diff
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,12 +1,24 @@
#include <qapplication.h>
#include <resources.h>
+
+#include <OTPeer.h>
#include <OTDevice.h>
#include <OTGateway.h>
+#include <Opietooth.h>
+
+#include <qlistbox.h>
+#include <qframe.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qdialog.h>
+
#include "bluetoothRFCOMMrun.h"
using Opietooth2::OTGateway;
using Opietooth2::OTDevice;
using Opietooth2::OTDeviceAddress;
+using Opietooth2::OTScan;
+using Opietooth2::OTPeer;
BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) {
if( OT ) {
@@ -55,6 +67,9 @@ QString BluetoothRFCOMMRun::setMyState( NetworkSetup *,
<< Ch->BDAddress
<< QString().setNum( Ch->Channel );
+ // no longer needed
+ delete Ch;
+
if( Sys.runAsRoot( S ) ) {
return QString( "Error starting %1").arg(S.join(" "));
}
@@ -78,12 +93,6 @@ QString BluetoothRFCOMMRun::setMyState( NetworkSetup *,
return QString();
}
-#include <qlistbox.h>
-#include <qframe.h>
-#include <qlabel.h>
-#include <qlayout.h>
-#include <qdialog.h>
-
RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) {
if( Data->Devices.count() == 1 ) {
@@ -92,6 +101,22 @@ RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) {
}
RFCOMMChannel * Ch = 0;
+
+ if( Data->Devices.count() == 0 ) {
+ OTPeer * Peer;
+ int Channel;
+
+ if( OTScan::getDevice( Peer, Channel, OT ) == QDialog::Accepted ) {
+ Ch = new RFCOMMChannel;
+ Ch->BDAddress = Peer->address().toString();
+ Ch->Name = Peer->name();
+ Ch->Channel = Channel;
+ return Ch;
+ }
+
+ return 0;
+ }
+
QDialog * Dlg = new QDialog( qApp->mainWidget(), 0, TRUE );
QVBoxLayout * V = new QVBoxLayout( Dlg );
@@ -120,7 +145,10 @@ RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) {
for( i = 0; i < Data->Devices.count(); i ++ ) {
if( LB->isSelected(i) ) {
odebug << "Selected " << Data->Devices[i]->Name << oendl;
- Ch = Data->Devices[i];
+ Ch = new RFCOMMChannel;
+ Ch->BDAddress = Data->Devices[i]->BDAddress;
+ Ch->Name = Data->Devices[i]->Name;
+ Ch->Channel = Data->Devices[i]->Channel;
break;
}
}
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
@@ -207,19 +207,22 @@ short AGPRSDevice::generateFile( SystemFile & SF,
return 1;
}
-bool AGPRSDevice::openFile( SystemFile & SF ) {
+bool AGPRSDevice::openFile( SystemFile & SF, QStringList & SL ) {
if( SF.name() == "peers" ) {
+ SL << "/etc" << "ppp" << "peers";
SF.setPath(
QString( "/etc/ppp/peers/" ) +
removeSpaces( networkSetup()->name() )
);
return 1;
} else if ( SF.name() == "chatscripts" ) {
+ SL << "/etc" << "chatscripts";
SF.setPath(
QString( "/etc/chatscripts/" ) +
removeSpaces( networkSetup()->name() )
);
return 1;
+ SL << "/etc" << "ppp";
} else if ( SF.name() == "extra" ) {
SF.setPath(
QString( "/etc/ppp/" ) +
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
@@ -24,7 +24,8 @@ public :
QString acceptable( void );
void commit( void );
- virtual bool openFile( SystemFile & SF );
+ virtual bool openFile( SystemFile & SF,
+ QStringList & SL );
virtual void * data( void )
{ return (void *)&Data; }
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
@@ -251,7 +251,7 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
Profiles_LB->insertItem( NC->devicePixmap(), NC->name() );
Profiles_LB->setSelected( ci, TRUE );
}
- updateProfileState( LBI );
+ SLOT_RefreshStates();
}
} else {
// cancelled : reset NetworkSetup
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
@@ -89,8 +89,9 @@ bool ANetNode::isToplevel( void ) {
}
bool ANetNode::openFile( SystemFile & SF,
- ANetNodeInstance * NNI ) {
- return (NNI ) ? NNI->openFile( SF ) : 0 ;
+ ANetNodeInstance * NNI,
+ QStringList & SL ) {
+ return (NNI ) ? NNI->openFile( SF, SL ) : 0 ;
}
//
@@ -406,11 +407,13 @@ QString NetworkSetup::setState( Action_t A, bool Force ) {
switch( A ) {
case Disable :
+ /*
if( CurrentState < Disabled ) {
// disabled
CurrentState = Disabled;
return QString();
}
+ */
if( CurrentState == IsUp ) {
Actions[NoOfActions++] = Down;
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index 8aebdc0..fa4ab70 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -121,10 +121,15 @@ public:
// for all NNI of this node class and the data generated
// by each of the NNI needs to be put in one file
//
+ // the function can return a set of folders that should
+ // be created (or perhaps already exist) prior to opening
+ // the file
+ //
// if this is the case the file should be (re)opened in append
// return 0 if file cannot be opened
virtual bool openFile( SystemFile &SF,
- ANetNodeInstance * NNI );
+ ANetNodeInstance * NNI,
+ QStringList & PathToCreate );
// generate instance independent stuff
// 0 : data output, 1 no data, 2 error
@@ -259,7 +264,8 @@ public:
// open proper file identified by S
- virtual bool openFile( SystemFile & )
+ virtual bool openFile( SystemFile &,
+ QStringList & )
{ return 0; }
// check if this node (or sub nodes) have data for this file
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
@@ -336,12 +336,23 @@ QString NetworkSettingsData::generateSettings( void ) {
// open proper file
{ SystemFile SF( (*it) );
+ QStringList SL;
- if( ! CurDevNN->openFile( SF, nniit.current()) ) {
+ if( ! CurDevNN->openFile( SF, nniit.current(), SL) ) {
// cannot open
S = qApp->translate( "NetworkSettings",
- "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
- arg( (*it) ).arg( CurDevNN->name() );
+ "<p>Cannot build proper file \"%1\" for node \"%2\"</p>" ).
+ arg( (*it) ).
+ arg( CurDevNN->name() );
+ return S;
+ }
+
+ if( ! createPath( SL ) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Cannot create path \"%1\" for proper file \"%2\" for node \"%3\"</p>" ).
+ arg( SL.join("/") ).
+ arg( (*it) ).
+ arg( CurDevNN->name() );
return S;
}
@@ -379,15 +390,26 @@ QString NetworkSettingsData::generateSettings( void ) {
if( Generated ) {
SystemFile SF( (*it) );
+ QStringList SL;
- if( CurDevNN->openFile( SF, 0 ) &&
+ if( CurDevNN->openFile( SF, 0, SL ) &&
! SF.path().isEmpty()
) {
+ if( ! createPath( SL ) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Cannot create path \"%1\" for proper file \"%2\" for node \"%3\"</p>" ).
+ arg( SL.join("/") ).
+ arg( (*it) ).
+ arg( CurDevNN->name() );
+ return S;
+ }
+
if( ! SF.open() ) {
S = qApp->translate( "NetworkSettings",
"<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
- arg( (*it) ).arg( CurDevNN->name() );
+ arg( (*it) ).
+ arg( CurDevNN->name() );
return S;
}
@@ -785,3 +807,26 @@ QList<NetworkSetup> NetworkSettingsData::collectTriggered(
return PossibleTriggered;
}
+bool NetworkSettingsData::createPath( const QStringList & SL ) {
+
+ QDir D( SL[0] );
+
+ for ( QStringList::ConstIterator it = SL.begin();
+ it != SL.end();
+ ++it ) {
+
+ printf( "Create %s\n", (*it).latin1() );
+ if( it == SL.begin() )
+ continue;
+
+ if( ! D.exists( *it ) ) {
+ if( ! D.mkdir( *it ) ) {
+ printf( "Failed %s %s\n", D.path().latin1(), (*it).latin1() );
+ return 0;
+ }
+ }
+
+ D.cd( *it );
+ }
+ return 1;
+}
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
@@ -29,6 +29,7 @@ public :
private :
QList<NetworkSetup> collectTriggered( const QString &Interface );
+ bool createPath( const QStringList & SL );
bool ForceModified;
// collect strings in config file nobody wants
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
@@ -184,7 +184,6 @@ void OTSniffing::SLOT_Trace( bool Run ) {
}
void OTSniffing::SLOT_Show( const QString & S ) {
- printf( "%s\n", S.latin1() );
Output_TV->setText( Output_TV->text() + S + "\n" );
QScrollBar *scroll = Output_TV->verticalScrollBar();
@@ -377,6 +376,7 @@ OTScan::OTScan( QWidget * parent, OTIcons * _IC ) :
OTScanGUI( parent ), Filter() {
OT = OTGateway::getOTGateway();
+
Icons = (_IC ) ? _IC : new OTIcons();
MyIcons = (_IC == 0 );
DetectedPeers_LV->header()->hide();
@@ -444,6 +444,14 @@ int OTScan::getDevice( OTPeer *& Peer,
bool IsUp = 0;
unsigned int i;
+ if( ! OT->isEnabled() ) {
+ QMessageBox::warning( 0,
+ tr("Scanning problem"),
+ tr("Bluetooth not enabled" )
+ );
+ return QDialog::Rejected;
+ }
+
// check if bluetooth is up
OTDriverList & DL = OT->getDriverList();
for( i = 0;
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
@@ -146,12 +146,14 @@ void APPP::commit( void ) {
}
}
-bool APPP::openFile( SystemFile & SF ) {
+bool APPP::openFile( SystemFile & SF, QStringList & SL ) {
if( SF.name() == "peers" ) {
+ SL << "/tmp/ppp" << "peers" ;
SF.setPath( removeSpaces(
QString( "/tmp/ppp/peers/" ) + networkSetup()->name() ) );
return 1;
} else if ( SF.name() == "chatscripts" ) {
+ SL << "/tmp/chatscripts";
SF.setPath( removeSpaces(
QString( "/tmp/chatscripts/" ) + networkSetup()->name() ) );
return 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
@@ -25,7 +25,7 @@ public :
virtual void * data( void )
{ return (void *)&Data; }
- virtual bool openFile( SystemFile & Sf );
+ virtual bool openFile( SystemFile & Sf, QStringList &SL );
short generateFile( SystemFile & TS,
long DevNr );
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
@@ -3,10 +3,9 @@
#include "profilerun.h"
State_t ProfileRun::detectState( void ) {
- InterfaceInfo * II = networkSetup()->assignedInterface();
- Log(( "Interface %p %p %p: %d\n", II,
- netNode(), netNode()->networkSetup(), (II) ? II->IsUp : 0 ));
+ Log(( "Profile %sabled\n", (Data->Disabled) ? "dis" : "en" ));
+
if( Data->Disabled ) {
return Disabled;
}