author | zecke <zecke> | 2002-06-01 12:46:35 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-01 12:46:35 (UTC) |
commit | 2815c0b50bd52d58022eb1d5f4364079a0e99e0a (patch) (unidiff) | |
tree | 587120ac88d743cb2a4a160df5cbe747db879b38 | |
parent | f386b95e1c9763bb9c5ea404c0824b45a744e151 (diff) | |
download | opie-2815c0b50bd52d58022eb1d5f4364079a0e99e0a.zip opie-2815c0b50bd52d58022eb1d5f4364079a0e99e0a.tar.gz opie-2815c0b50bd52d58022eb1d5f4364079a0e99e0a.tar.bz2 |
Small adjustments
-rw-r--r-- | noncore/net/opietooth/lib/device.cc | 6 |
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 @@ | |||
1 | 1 | ||
2 | #include <signal.h> | ||
3 | |||
2 | #include "kprocess.h" | 4 | #include "kprocess.h" |
3 | 5 | ||
4 | #include "device.h" | 6 | #include "device.h" |
5 | 7 | ||
6 | using namespace OpieTooth; | 8 | using namespace OpieTooth; |
7 | 9 | ||
8 | Device::Device(const QString &device, const QString &mode ) | 10 | Device::Device(const QString &device, const QString &mode ) |
9 | : QObject(0, "device" ) { | 11 | : QObject(0, "device" ) { |
10 | m_hci = 0; | 12 | m_hci = 0; |
11 | m_process = 0; | 13 | m_process = 0; |
12 | m_attached = false; | 14 | m_attached = false; |
13 | m_device = device; | 15 | m_device = device; |
14 | m_mode = mode; | 16 | m_mode = mode; |
15 | attach(); | 17 | attach(); |
16 | } | 18 | } |
17 | Device::~Device(){ | 19 | Device::~Device(){ |
@@ -28,33 +30,33 @@ void Device::attach(){ | |||
28 | connect(m_process, SIGNAL( receivedStdout(KProcess*, char*, int) ), | 30 | connect(m_process, SIGNAL( receivedStdout(KProcess*, char*, int) ), |
29 | this, SLOT(slotStdOut(KProcess*,char*,int ) ) ); | 31 | this, SLOT(slotStdOut(KProcess*,char*,int ) ) ); |
30 | connect(m_process, SIGNAL(receivedStderr(KProcess*, char*, int ) ), | 32 | connect(m_process, SIGNAL(receivedStderr(KProcess*, char*, int ) ), |
31 | this, SLOT(slotStdErr(KProcess*,char*,int) ) ); | 33 | this, SLOT(slotStdErr(KProcess*,char*,int) ) ); |
32 | if(!m_process->start(KProcess::NotifyOnExit, KProcess::AllOutput ) ){ | 34 | if(!m_process->start(KProcess::NotifyOnExit, KProcess::AllOutput ) ){ |
33 | delete m_process; | 35 | delete m_process; |
34 | m_process = 0; | 36 | m_process = 0; |
35 | } | 37 | } |
36 | }; | 38 | }; |
37 | } | 39 | } |
38 | void Device::detach(){ | 40 | void Device::detach(){ |
39 | delete m_hci; | 41 | delete m_hci; |
40 | delete m_process; | 42 | delete m_process; |
41 | // kill the pid we got | 43 | // kill the pid we got |
42 | if(m_attached ) | 44 | if(m_attached ) |
43 | //kill the pid | 45 | //kill the pid |
44 | ; | 46 | kill(pid, 9); |
45 | } | 47 | } |
46 | bool Device::isLoaded()const{ | 48 | bool Device::isLoaded()const{ |
47 | return m_attached; | 49 | return m_attached; |
48 | } | 50 | } |
49 | QString Device::devName()const { | 51 | QString Device::devName()const { |
50 | return QString::fromLatin1("hci0"); | 52 | return QString::fromLatin1("hci0"); |
51 | }; | 53 | }; |
52 | void Device::slotExited( KProcess* proc) | 54 | void Device::slotExited( KProcess* proc) |
53 | { | 55 | { |
54 | if(proc== m_process ){ | 56 | if(proc== m_process ){ |
55 | if( m_process->normalExit() ){ // normal exit | 57 | if( m_process->normalExit() ){ // normal exit |
56 | int ret = m_process->exitStatus(); | 58 | int ret = m_process->exitStatus(); |
57 | if( ret == 0 ){ // attached | 59 | if( ret == 0 ){ // attached |
58 | // now hciconfig hci0 up ( determine hciX FIXME) | 60 | // now hciconfig hci0 up ( determine hciX FIXME) |
59 | // and call hciconfig hci0 up | 61 | // and call hciconfig hci0 up |
60 | // FIXME hardcoded to hci0 now :( | 62 | // FIXME hardcoded to hci0 now :( |
@@ -77,26 +79,26 @@ void Device::slotExited( KProcess* proc) | |||
77 | if( ret == 0 ){ | 79 | if( ret == 0 ){ |
78 | emit device("hci0", true ); | 80 | emit device("hci0", true ); |
79 | }else{ | 81 | }else{ |
80 | emit device("hci0", false ); | 82 | emit device("hci0", false ); |
81 | m_attached = false; | 83 | m_attached = false; |
82 | } | 84 | } |
83 | }// normal exit | 85 | }// normal exit |
84 | delete m_hci; | 86 | delete m_hci; |
85 | m_hci = 0; | 87 | m_hci = 0; |
86 | } | 88 | } |
87 | } | 89 | } |
88 | void Device::slotStdOut(KProcess* proc, char* chars, int len) | 90 | void Device::slotStdOut(KProcess* proc, char* chars, int len) |
89 | { | 91 | { |
90 | if( len <1 ) | 92 | if( len <1 ) |
91 | return; | 93 | return; |
92 | if(proc == m_process ){ | 94 | if(proc == m_process ){ |
93 | QCString string( chars ); | 95 | QCString string( chars, len+1 ); |
94 | if(string.left(3) != "CSR" ){ // it's the pid | 96 | if(string.left(3) != "CSR" ){ // it's the pid |
95 | pid = string.toInt(); | 97 | pid = string.toInt(); |
96 | }; | 98 | }; |
97 | } | 99 | } |
98 | } | 100 | } |
99 | void Device::slotStdErr(KProcess*, char*, int ) | 101 | void Device::slotStdErr(KProcess*, char*, int ) |
100 | { | 102 | { |
101 | 103 | ||
102 | } | 104 | } |