summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/lib/device.cc
Unidiff
Diffstat (limited to 'noncore/net/opietooth/lib/device.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/device.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc
index bae1c47..d913853 100644
--- a/noncore/net/opietooth/lib/device.cc
+++ b/noncore/net/opietooth/lib/device.cc
@@ -1,21 +1,23 @@
1 1
2#include <signal.h> 2#include <signal.h>
3 3
4#include <opie/oprocess.h> 4#include <opie2/oprocess.h>
5 5
6#include "device.h" 6#include "device.h"
7 7
8using namespace OpieTooth; 8using namespace OpieTooth;
9 9
10using namespace Opie::Core;
11using namespace Opie::Core;
10namespace { 12namespace {
11 int parsePid( const QCString& par ){ 13 int parsePid( const QCString& par ){
12 int id=0; 14 int id=0;
13 QString string( par ); 15 QString string( par );
14 QStringList list = QStringList::split( '\n', string ); 16 QStringList list = QStringList::split( '\n', string );
15 for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ 17 for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ){
16 qWarning("parsePID: %s", (*it).latin1() ); 18 qWarning("parsePID: %s", (*it).latin1() );
17 if( !(*it).startsWith("CSR") ){ 19 if( !(*it).startsWith("CSR") ){
18 id = (*it).toInt(); 20 id = (*it).toInt();
19 break; 21 break;
20 } 22 }
21 } 23 }
@@ -38,29 +40,29 @@ Device::Device(const QString &device, const QString &mode, const QString &speed
38Device::~Device(){ 40Device::~Device(){
39 detach(); 41 detach();
40} 42}
41void Device::attach(){ 43void Device::attach(){
42 qWarning("attaching %s %s %s", m_device.latin1(), m_mode.latin1(), m_speed.latin1() ); 44 qWarning("attaching %s %s %s", m_device.latin1(), m_mode.latin1(), m_speed.latin1() );
43 if(m_process == 0 ){ 45 if(m_process == 0 ){
44 m_output.resize(0); 46 m_output.resize(0);
45 qWarning("new process to create" ); 47 qWarning("new process to create" );
46 m_process = new OProcess(); 48 m_process = new OProcess();
47 *m_process << "hciattach"; 49 *m_process << "hciattach";
48 *m_process << "-p"; 50 *m_process << "-p";
49 *m_process << m_device << m_mode << m_speed; 51 *m_process << m_device << m_mode << m_speed;
50 connect(m_process, SIGNAL( processExited(OProcess*) ), 52 connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ),
51 this, SLOT( slotExited(OProcess* ) ) ); 53 this, SLOT( slotExited(OProcess* ) ) );
52 connect(m_process, SIGNAL( receivedStdout(OProcess*, char*, int) ), 54 connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ),
53 this, SLOT(slotStdOut(OProcess*,char*,int ) ) ); 55 this, SLOT(slotStdOut(OProcess*,char*,int ) ) );
54 connect(m_process, SIGNAL(receivedStderr(OProcess*, char*, int ) ), 56 connect(m_process, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ),
55 this, SLOT(slotStdErr(OProcess*,char*,int) ) ); 57 this, SLOT(slotStdErr(OProcess*,char*,int) ) );
56 if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){ 58 if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){
57 qWarning("Could not start" ); 59 qWarning("Could not start" );
58 delete m_process; 60 delete m_process;
59 m_process = 0; 61 m_process = 0;
60 } 62 }
61 }; 63 };
62} 64}
63void Device::detach(){ 65void Device::detach(){
64 delete m_hci; 66 delete m_hci;
65 delete m_process; 67 delete m_process;
66 // kill the pid we got 68 // kill the pid we got
@@ -87,25 +89,25 @@ void Device::slotExited( OProcess* proc)
87 int ret = m_process->exitStatus(); 89 int ret = m_process->exitStatus();
88 if( ret == 0 ){ // attached 90 if( ret == 0 ){ // attached
89 qWarning("attached" ); 91 qWarning("attached" );
90 qWarning("Output: %s", m_output.data() ); 92 qWarning("Output: %s", m_output.data() );
91 pid = parsePid( m_output ); 93 pid = parsePid( m_output );
92 qWarning("Pid = %d", pid ); 94 qWarning("Pid = %d", pid );
93 // now hciconfig hci0 up ( determine hciX FIXME) 95 // now hciconfig hci0 up ( determine hciX FIXME)
94 // and call hciconfig hci0 up 96 // and call hciconfig hci0 up
95 // FIXME hardcoded to hci0 now :( 97 // FIXME hardcoded to hci0 now :(
96 m_hci = new OProcess( ); 98 m_hci = new OProcess( );
97 *m_hci << "hciconfig"; 99 *m_hci << "hciconfig";
98 *m_hci << "hci0 up"; 100 *m_hci << "hci0 up";
99 connect(m_hci, SIGNAL( processExited(OProcess*) ), 101 connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ),
100 this, SLOT( slotExited(OProcess* ) ) ); 102 this, SLOT( slotExited(OProcess* ) ) );
101 if(!m_hci->start() ){ 103 if(!m_hci->start() ){
102 qWarning("could not start" ); 104 qWarning("could not start" );
103 m_attached = false; 105 m_attached = false;
104 emit device("hci0", false ); 106 emit device("hci0", false );
105 } 107 }
106 }else{ 108 }else{
107 qWarning("crass" ); 109 qWarning("crass" );
108 m_attached = false; 110 m_attached = false;
109 emit device("hci0", false ); 111 emit device("hci0", false );
110 112
111 } 113 }