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