author | zecke <zecke> | 2002-06-15 23:07:12 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-15 23:07:12 (UTC) |
commit | 0675d8e8ea5f599af9f433e1e86b63953b26639d (patch) (side-by-side diff) | |
tree | fb3aaa512aa8f4600de119574999749758d38139 /noncore/net/opietooth/lib/device.cc | |
parent | 3f49c8a3006c4c51cf7d4a2f84a3926efd3e1820 (diff) | |
download | opie-0675d8e8ea5f599af9f433e1e86b63953b26639d.zip opie-0675d8e8ea5f599af9f433e1e86b63953b26639d.tar.gz opie-0675d8e8ea5f599af9f433e1e86b63953b26639d.tar.bz2 |
fix it
Diffstat (limited to 'noncore/net/opietooth/lib/device.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/lib/device.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc index 5234996..5edfc03 100644 --- a/noncore/net/opietooth/lib/device.cc +++ b/noncore/net/opietooth/lib/device.cc @@ -1,39 +1,40 @@ #include <signal.h> #include <opie/oprocess.h> #include "device.h" using namespace OpieTooth; 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 ) : QObject(0, "device" ) { qWarning("OpieTooth::Device create" ); m_hci = 0; m_process = 0; m_attached = false; m_device = device; m_mode = mode; attach(); } Device::~Device(){ detach(); } void Device::attach(){ qWarning("attaching %s %s", m_device.latin1(), m_mode.latin1() ); @@ -57,86 +58,92 @@ void Device::attach(){ } }; } 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(OProcess*) ), this, SLOT( slotExited(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{ qWarning( "failed" ); emit device("hci0", false ); m_attached = false; } }// normal exit delete m_hci; m_hci = 0; } } void Device::slotStdOut(OProcess* proc, char* chars, int len) { qWarning("std out" ); - if( len <1 ) + if( len <1 ){ + qWarning( "len < 1 " ); return; + } if(proc == m_process ){ QCString string( chars, len+1 ); // \0 == +1 qWarning("output: %s", string.data() ); m_output.append( string.data() ); } } -void Device::slotStdErr(OProcess*, char*, int ) +void Device::slotStdErr(OProcess* proc, char* chars, int len) { qWarning("std err" ); + slotStdOut( proc, chars, len ); } |