summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/device.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc
index 0c552ea..468f191 100644
--- a/noncore/net/opietooth/lib/device.cc
+++ b/noncore/net/opietooth/lib/device.cc
@@ -1,17 +1,19 @@
+#include <signal.h>
+
#include "kprocess.h"
#include "device.h"
using namespace OpieTooth;
Device::Device(const QString &device, const QString &mode )
: QObject(0, "device" ) {
m_hci = 0;
m_process = 0;
m_attached = false;
m_device = device;
m_mode = mode;
attach();
}
Device::~Device(){
@@ -28,33 +30,33 @@ void Device::attach(){
connect(m_process, SIGNAL( receivedStdout(KProcess*, char*, int) ),
this, SLOT(slotStdOut(KProcess*,char*,int ) ) );
connect(m_process, SIGNAL(receivedStderr(KProcess*, char*, int ) ),
this, SLOT(slotStdErr(KProcess*,char*,int) ) );
if(!m_process->start(KProcess::NotifyOnExit, KProcess::AllOutput ) ){
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
- ;
+ kill(pid, 9);
}
bool Device::isLoaded()const{
return m_attached;
}
QString Device::devName()const {
return QString::fromLatin1("hci0");
};
void Device::slotExited( KProcess* proc)
{
if(proc== m_process ){
if( m_process->normalExit() ){ // normal exit
int ret = m_process->exitStatus();
if( ret == 0 ){ // attached
// now hciconfig hci0 up ( determine hciX FIXME)
// and call hciconfig hci0 up
// FIXME hardcoded to hci0 now :(
@@ -77,26 +79,26 @@ void Device::slotExited( KProcess* proc)
if( ret == 0 ){
emit device("hci0", true );
}else{
emit device("hci0", false );
m_attached = false;
}
}// normal exit
delete m_hci;
m_hci = 0;
}
}
void Device::slotStdOut(KProcess* proc, char* chars, int len)
{
if( len <1 )
return;
if(proc == m_process ){
- QCString string( chars );
+ QCString string( chars, len+1 );
if(string.left(3) != "CSR" ){ // it's the pid
pid = string.toInt();
};
}
}
void Device::slotStdErr(KProcess*, char*, int )
{
}