summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth
Side-by-side diff
Diffstat (limited to 'noncore/net/opietooth') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/device.cc9
-rw-r--r--noncore/net/opietooth/lib/manager.cc18
-rw-r--r--noncore/net/opietooth/lib/startdunconnection.cpp5
-rw-r--r--noncore/net/opietooth/lib/startpanconnection.cpp8
-rw-r--r--noncore/net/opietooth/manager/pppdialog.cpp3
5 files changed, 20 insertions, 23 deletions
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc
index d913853..18d26e4 100644
--- a/noncore/net/opietooth/lib/device.cc
+++ b/noncore/net/opietooth/lib/device.cc
@@ -1,126 +1,125 @@
#include <signal.h>
#include <opie2/oprocess.h>
#include "device.h"
using namespace OpieTooth;
using namespace Opie::Core;
-using namespace Opie::Core;
namespace {
int parsePid( const QCString& par ){
int id=0;
QString string( par );
QStringList list = QStringList::split( '\n', string );
for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ){
qWarning("parsePID: %s", (*it).latin1() );
if( !(*it).startsWith("CSR") ){
id = (*it).toInt();
break;
}
}
return id;
}
}
Device::Device(const QString &device, const QString &mode, const QString &speed )
: QObject(0, "device") {
qWarning("OpieTooth::Device create" );
m_hci = 0;
m_process = 0;
m_attached = false;
m_device = device;
m_mode = mode;
m_speed = speed;
attach();
}
Device::~Device(){
detach();
}
void Device::attach(){
qWarning("attaching %s %s %s", m_device.latin1(), m_mode.latin1(), m_speed.latin1() );
if(m_process == 0 ){
m_output.resize(0);
qWarning("new process to create" );
m_process = new OProcess();
*m_process << "hciattach";
*m_process << "-p";
*m_process << m_device << m_mode << m_speed;
connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ),
- this, SLOT( slotExited(OProcess* ) ) );
+ this, SLOT( slotExited(Opie::Core::OProcess* ) ) );
connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ),
- this, SLOT(slotStdOut(OProcess*,char*,int ) ) );
+ this, SLOT(slotStdOut(Opie::Core::OProcess*,char*,int ) ) );
connect(m_process, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ),
- this, SLOT(slotStdErr(OProcess*,char*,int) ) );
+ this, SLOT(slotStdErr(Opie::Core::OProcess*,char*,int) ) );
if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){
qWarning("Could not start" );
delete m_process;
m_process = 0;
}
};
}
void Device::detach(){
delete m_hci;
delete m_process;
// kill the pid we got
if(m_attached ){
//kill the pid
qWarning( "killing" );
kill(pid, 9);
}
qWarning("detached" );
}
bool Device::isLoaded()const{
return m_attached;
}
QString Device::devName()const {
return QString::fromLatin1("hci0");
};
void Device::slotExited( OProcess* proc)
{
qWarning("prcess exited" );
if(proc== m_process ){
qWarning("proc == m_process" );
if( m_process->normalExit() ){ // normal exit
qWarning("normalExit" );
int ret = m_process->exitStatus();
if( ret == 0 ){ // attached
qWarning("attached" );
qWarning("Output: %s", m_output.data() );
pid = parsePid( m_output );
qWarning("Pid = %d", pid );
// now hciconfig hci0 up ( determine hciX FIXME)
// and call hciconfig hci0 up
// FIXME hardcoded to hci0 now :(
m_hci = new OProcess( );
*m_hci << "hciconfig";
*m_hci << "hci0 up";
connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ),
- this, SLOT( slotExited(OProcess* ) ) );
+ this, SLOT( slotExited(Opie::Core::OProcess* ) ) );
if(!m_hci->start() ){
qWarning("could not start" );
m_attached = false;
emit device("hci0", false );
}
}else{
qWarning("crass" );
m_attached = false;
emit device("hci0", false );
}
}
delete m_process;
m_process = 0;
}else if(proc== m_hci ){
qWarning("M HCI exited" );
if( m_hci->normalExit() ){
qWarning("normal exit" );
int ret = m_hci->exitStatus();
if( ret == 0 ){
qWarning("attached really really attached" );
m_attached = true;
emit device("hci0", true );
}else{
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index 56156a8..7c9ea5b 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -24,116 +24,116 @@ Manager::Manager( Device* /*dev*/ )
m_hcitool = 0;
m_sdp = 0;
}
Manager::Manager()
: QObject()
{
m_hcitool = 0;
m_sdp = 0;
}
Manager::~Manager(){
delete m_hcitool;
delete m_sdp;
}
void Manager::setDevice( const QString& dev ){
m_device = dev;
}
void Manager::setDevice( Device* /*dev*/ ){
}
void Manager::isAvailable( const QString& device ){
OProcess* l2ping = new OProcess();
l2ping->setName( device.latin1() );
*l2ping << "l2ping" << "-c1" << device;
connect(l2ping, SIGNAL(processExited(Opie::Core::OProcess* ) ),
- this, SLOT(slotProcessExited(OProcess*) ) );
+ this, SLOT(slotProcessExited(Opie::Core::OProcess*) ) );
if (!l2ping->start() ) {
emit available( device, false );
delete l2ping;
}
}
void Manager::isAvailable( Device* /*dev*/ ){
}
void Manager::searchDevices( const QString& device ){
qWarning("search devices");
OProcess* hcitool = new OProcess();
hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() );
*hcitool << "hcitool" << "scan";
connect( hcitool, SIGNAL(processExited(Opie::Core::OProcess*) ) ,
- this, SLOT(slotHCIExited(OProcess* ) ) );
+ this, SLOT(slotHCIExited(Opie::Core::OProcess* ) ) );
connect( hcitool, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
- this, SLOT(slotHCIOut(OProcess*, char*, int ) ) );
+ this, SLOT(slotHCIOut(Opie::Core::OProcess*, char*, int ) ) );
if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
qWarning("could not start");
RemoteDevice::ValueList list;
emit foundDevices( device, list );
delete hcitool;
}
}
void Manager::searchDevices(Device* /*d*/ ){
}
void Manager::addService(const QString& name ){
OProcess proc;
proc << "sdptool" << "add" << name;
bool bo = true;
if (!proc.start(OProcess::DontCare ) )
bo = false;
emit addedService( name, bo );
}
void Manager::addServices(const QStringList& list){
QStringList::ConstIterator it;
for (it = list.begin(); it != list.end(); ++it )
addService( (*it) );
}
void Manager::removeService( const QString& name ){
OProcess prc;
prc << "sdptool" << "del" << name;
bool bo = true;
if (!prc.start(OProcess::DontCare ) )
bo = false;
emit removedService( name, bo );
}
void Manager::removeServices( const QStringList& list){
QStringList::ConstIterator it;
for (it = list.begin(); it != list.end(); ++it )
removeService( (*it) );
}
void Manager::searchServices( const QString& remDevice ){
OProcess *m_sdp =new OProcess();
*m_sdp << "sdptool" << "browse" << remDevice;
m_sdp->setName( remDevice.latin1() );
qWarning("search Services for %s", remDevice.latin1() );
connect(m_sdp, SIGNAL(processExited(Opie::Core::OProcess*) ),
- this, SLOT(slotSDPExited(OProcess* ) ) );
+ this, SLOT(slotSDPExited(Opie::Core::OProcess* ) ) );
connect(m_sdp, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
- this, SLOT(slotSDPOut(OProcess*, char*, int) ) );
+ this, SLOT(slotSDPOut(Opie::Core::OProcess*, char*, int) ) );
if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
qWarning("could not start sdptool" );
delete m_sdp;
Services::ValueList list;
emit foundServices( remDevice, list );
}
}
void Manager::searchServices( const RemoteDevice& dev){
searchServices( dev.mac() );
}
QString Manager::toDevice( const QString& /*mac*/ ){
return QString::null;
}
QString Manager::toMac( const QString &/*device*/ ){
return QString::null;
}
void Manager::slotProcessExited(OProcess* proc ) {
bool conn= false;
if (proc->normalExit() && proc->exitStatus() == 0 )
conn = true;
QString name = QString::fromLatin1(proc->name() );
emit available( name, conn );
delete proc;
@@ -228,51 +228,51 @@ RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) {
}
////// hcitool cc and hcitool con
/**
* Create it on the stack as don't care
* so we don't need to care for it
* cause hcitool gets reparented
*/
void Manager::connectTo( const QString& mac) {
OProcess proc;
proc << "hcitool";
proc << "cc";
proc << mac;
proc.start(OProcess::DontCare); // the lib does not care at this point
}
void Manager::searchConnections() {
qWarning("searching connections?");
OProcess* proc = new OProcess();
m_hcitoolCon = QString::null;
connect(proc, SIGNAL(processExited(Opie::Core::OProcess*) ),
- this, SLOT(slotConnectionExited( OProcess*) ) );
+ this, SLOT(slotConnectionExited( Opie::Core::OProcess*) ) );
connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ),
- this, SLOT(slotConnectionOutput(OProcess*, char*, int) ) );
+ this, SLOT(slotConnectionOutput(Opie::Core::OProcess*, char*, int) ) );
*proc << "hcitool";
*proc << "con";
if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
ConnectionState::ValueList list;
emit connections( list );
delete proc;
}
}
void Manager::slotConnectionExited( OProcess* proc ) {
ConnectionState::ValueList list;
list = parseConnections( m_hcitoolCon );
emit connections(list );
delete proc;
}
void Manager::slotConnectionOutput(OProcess* /*proc*/, char* cha, int len) {
QCString str(cha, len );
m_hcitoolCon.append( str );
//delete proc;
}
ConnectionState::ValueList Manager::parseConnections( const QString& out ) {
ConnectionState::ValueList list2;
QStringList list = QStringList::split('\n', out );
QStringList::Iterator it;
@@ -287,50 +287,50 @@ ConnectionState::ValueList Manager::parseConnections( const QString& out ) {
qWarning("2: %s", value[2].latin1() );
qWarning("3: %s", value[3].latin1() );
qWarning("4: %s", value[4].latin1() );
qWarning("5: %s", value[5].latin1() );
qWarning("6: %s", value[6].latin1() );
qWarning("7: %s", value[7].latin1() );
qWarning("8: %s", value[8].latin1() );
ConnectionState con;
con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming );
con.setConnectionMode( value[1] );
con.setMac( value[2] );
con.setHandle( value[4].toInt() );
con.setState( value[6].toInt() );
con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client );
list2.append( con );
}
return list2;
}
void Manager::signalStrength( const QString &mac ) {
OProcess* sig_proc = new OProcess();
connect(sig_proc, SIGNAL(processExited(Opie::Core::OProcess*) ),
- this, SLOT(slotSignalStrengthExited( OProcess*) ) );
+ this, SLOT(slotSignalStrengthExited( Opie::Core::OProcess*) ) );
connect(sig_proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ),
- this, SLOT(slotSignalStrengthOutput(OProcess*, char*, int) ) );
+ this, SLOT(slotSignalStrengthOutput(Opie::Core::OProcess*, char*, int) ) );
*sig_proc << "hcitool";
*sig_proc << "lq";
*sig_proc << mac;
sig_proc->setName( mac.latin1() );
if (!sig_proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
emit signalStrength( mac, "-1" );
delete sig_proc;
}
}
void Manager::slotSignalStrengthOutput(OProcess* proc, char* cha, int len) {
QCString str(cha, len );
QString temp = QString(str).stripWhiteSpace();
QStringList value = QStringList::split(' ', temp );
emit signalStrength( proc->name(), value[2].latin1() );
}
void Manager::slotSignalStrengthExited( OProcess* proc ) {
delete proc;
}
diff --git a/noncore/net/opietooth/lib/startdunconnection.cpp b/noncore/net/opietooth/lib/startdunconnection.cpp
index 90ef04a..09b19d2 100644
--- a/noncore/net/opietooth/lib/startdunconnection.cpp
+++ b/noncore/net/opietooth/lib/startdunconnection.cpp
@@ -1,69 +1,68 @@
#include "startdunconnection.h"
using namespace OpieTooth;
using namespace Opie::Core;
-using namespace Opie::Core;
StartDunConnection::StartDunConnection() {
m_dunConnect = 0l;
setConnectionType();
}
StartDunConnection::~StartDunConnection() {
delete m_dunConnect;
}
StartDunConnection::StartDunConnection( QString mac ) {
m_dunConnect = 0l;
m_mac = mac;
setConnectionType();
}
void StartDunConnection::setName( QString name ) {
m_name = name;
}
QString StartDunConnection::name() {
return m_name;
}
void StartDunConnection::setConnectionType() {
m_connectionType = Pan;
}
StartConnection::ConnectionType StartDunConnection::type() {
return m_connectionType;
}
void StartDunConnection::start() {
m_dunConnect = new OProcess();
*m_dunConnect << "dund" << "--listen" << "--connect" << m_mac;
connect( m_dunConnect, SIGNAL( processExited(Opie::Core::OProcess*) ) ,
- this, SLOT( slotExited(OProcess*) ) );
+ this, SLOT( slotExited(Opie::Core::OProcess*) ) );
connect( m_dunConnect, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
- this, SLOT( slotStdOut(OProcess*,char*,int) ) );
+ this, SLOT( slotStdOut(Opie::Core::OProcess*,char*,int) ) );
if (!m_dunConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) {
qWarning( "could not start" );
delete m_dunConnect;
}
}
void StartDunConnection::slotExited( OProcess* proc ) {
delete m_dunConnect;
}
void StartDunConnection::slotStdOut(OProcess* proc, char* chars, int len)
{}
void StartDunConnection::stop() {
if ( m_dunConnect ) {
delete m_dunConnect;
m_dunConnect = 0l;
}
}
diff --git a/noncore/net/opietooth/lib/startpanconnection.cpp b/noncore/net/opietooth/lib/startpanconnection.cpp
index fef35d9..24ac530 100644
--- a/noncore/net/opietooth/lib/startpanconnection.cpp
+++ b/noncore/net/opietooth/lib/startpanconnection.cpp
@@ -22,63 +22,63 @@ StartPanConnection::StartPanConnection( QString mac ) {
}
void StartPanConnection::setName( QString name ) {
m_name = name;
}
QString StartPanConnection::name() {
return m_name;
}
void StartPanConnection::setConnectionType() {
m_connectionType = Pan;
}
StartConnection::ConnectionType StartPanConnection::type() {
return m_connectionType;
}
void StartPanConnection::start() {
m_panConnect = new OProcess();
qDebug( "IM START " + m_mac );
*m_panConnect << "pand" << "--connect" << m_mac;
connect( m_panConnect, SIGNAL( processExited(Opie::Core::OProcess*) ) ,
- this, SLOT( slotExited(OProcess*) ) );
+ this, SLOT( slotExited(Opie::Core::OProcess*) ) );
connect( m_panConnect, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
- this, SLOT( slotStdOut(OProcess*,char*,int) ) );
+ this, SLOT( slotStdOut(Opie::Core::OProcess*,char*,int) ) );
if (!m_panConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) {
qWarning( "could not start" );
delete m_panConnect;
}
}
void StartPanConnection::slotExited( OProcess* proc ) {
delete m_panConnect;
m_panConnect = 0l;
}
void StartPanConnection::slotStdOut(OProcess* proc, char* chars, int len)
{}
void StartPanConnection::stop() {
if ( m_panConnect ) {
delete m_panConnect;
m_panConnect = 0l;
}
m_panConnect = new OProcess();
qDebug("IM STOP " + m_mac);
*m_panConnect << "pand" << "--kill" << m_mac;
connect( m_panConnect, SIGNAL( processExited(Opie::Core::OProcess*) ) ,
- this, SLOT( slotExited(OProcess*) ) );
+ this, SLOT( slotExited(Opie::Core::OProcess*) ) );
connect( m_panConnect, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
- this, SLOT( slotStdOut(OProcess*,char*,int) ) );
+ this, SLOT( slotStdOut(Opie::Core::OProcess*,char*,int) ) );
if (!m_panConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) {
qWarning( "could not stop" );
delete m_panConnect;
}
}
diff --git a/noncore/net/opietooth/manager/pppdialog.cpp b/noncore/net/opietooth/manager/pppdialog.cpp
index 870e7fd..78c1501 100644
--- a/noncore/net/opietooth/manager/pppdialog.cpp
+++ b/noncore/net/opietooth/manager/pppdialog.cpp
@@ -1,70 +1,69 @@
#include "pppdialog.h"
#include <qpushbutton.h>
#include <qmultilineedit.h>
#include <qlineedit.h>
#include <qlayout.h>
#include <qlabel.h>
#include <opie2/oprocess.h>
using namespace OpieTooth;
using namespace Opie::Core;
-using namespace Opie::Core;
PPPDialog::PPPDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QString& device )
: QDialog( parent, name, modal, fl ) {
if ( !name )
setName( "PPPDialog" );
setCaption( tr( "ppp connection " ) ) ;
m_device = device;
layout = new QVBoxLayout( this );
QLabel* info = new QLabel( this );
info->setText( tr("Enter an ppp script name:") );
cmdLine = new QLineEdit( this );
outPut = new QMultiLineEdit( this );
QFont outPut_font( outPut->font() );
outPut_font.setPointSize( 8 );
outPut->setFont( outPut_font );
outPut->setWordWrap( QMultiLineEdit::WidgetWidth );
connectButton = new QPushButton( this );
connectButton->setText( tr( "Connect" ) );
layout->addWidget(info);
layout->addWidget(cmdLine);
layout->addWidget(outPut);
layout->addWidget(connectButton);
connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) );
}
PPPDialog::~PPPDialog() {
}
void PPPDialog::connectToDevice() {
outPut->clear();
// vom popupmenu beziehen
QString connectScript = "/etc/ppp/peers/" + cmdLine->text();
OProcess* pppDial = new OProcess();
*pppDial << "pppd" << m_device << "call" << connectScript;
connect( pppDial, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int) ),
- this, SLOT(fillOutPut(OProcess*,char*,int) ) );
+ this, SLOT(fillOutPut(Opie::Core::OProcess*,char*,int) ) );
if (!pppDial->start(OProcess::DontCare, OProcess::AllOutput) ) {
qWarning("could not start");
delete pppDial;
}
}
void PPPDialog::fillOutPut( OProcess* pppDial, char* cha, int len ) {
QCString str(cha, len );
outPut->insertLine( str );
delete pppDial;
}