author | korovkin <korovkin> | 2006-05-10 13:32:46 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-05-10 13:32:46 (UTC) |
commit | 5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f (patch) (unidiff) | |
tree | e9ea63a2fe15982e98886af727649dc6a513faac /noncore/net/opietooth/lib/device.cc | |
parent | 620d55ae3b94fa8d2fa696b6626893e4520c3a02 (diff) | |
download | opie-5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f.zip opie-5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f.tar.gz opie-5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f.tar.bz2 |
OBEX push functionality moved to libbluetooth1.
Made some reformatting in device.cc
In bluezapplet.cpp /etc/init.d/bluetooth is started synchronously if it's called from QCopMessage.
Diffstat (limited to 'noncore/net/opietooth/lib/device.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/lib/device.cc | 108 |
1 files changed, 52 insertions, 56 deletions
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc index 40acbd2..2f04d46 100644 --- a/noncore/net/opietooth/lib/device.cc +++ b/noncore/net/opietooth/lib/device.cc | |||
@@ -17,31 +17,29 @@ using namespace OpieTooth; | |||
17 | using Opie::Core::OProcess; | 17 | using Opie::Core::OProcess; |
18 | namespace { | 18 | namespace { |
19 | int parsePid( const QCString& par ) | 19 | int parsePid( const QCString& par ) |
20 | { | 20 | { |
21 | int id=0; | 21 | int id = 0; |
22 | QString string( par ); | 22 | QString string( par ); |
23 | QStringList list = QStringList::split( '\n', string ); | 23 | QStringList list = QStringList::split( '\n', string ); |
24 | 24 | ||
25 | for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 25 | for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
26 | { | 26 | owarn << "parsePID: " << (*it).latin1() << oendl; |
27 | owarn << "parsePID: " << (*it).latin1() << oendl; | ||
28 | 27 | ||
29 | // FIXME mbhaynie: Surely there is a better way to skip | 28 | // FIXME mbhaynie: Surely there is a better way to skip |
30 | // verbosity (E.g. the TI device configuration | 29 | // verbosity (E.g. the TI device configuration |
31 | // script). Apparently the PID is always on a line by | 30 | // script). Apparently the PID is always on a line by |
32 | // itself, or is at least the first word of a line. Does | 31 | // itself, or is at least the first word of a line. Does |
33 | // QString have somethine like startsWithRegex("[0-9]+")? | 32 | // QString have somethine like startsWithRegex("[0-9]+")? |
34 | if( (*it).startsWith("#") ) continue; | 33 | if( (*it).startsWith("#") ) continue; |
35 | if( (*it).startsWith("TI") ) continue; | 34 | if( (*it).startsWith("TI") ) continue; |
36 | if( (*it).startsWith("Loading") ) continue; | 35 | if( (*it).startsWith("Loading") ) continue; |
37 | if( (*it).startsWith("BTS") ) continue; | 36 | if( (*it).startsWith("BTS") ) continue; |
38 | if( !(*it).startsWith("CSR") ) | 37 | if( !(*it).startsWith("CSR") ) { |
39 | { | 38 | id = (*it).toInt(); |
40 | id = (*it).toInt(); | 39 | break; |
41 | break; | 40 | } |
42 | } | ||
43 | } | ||
44 | return id; | ||
45 | } | 41 | } |
42 | return id; | ||
43 | } | ||
46 | } | 44 | } |
47 | 45 | ||
@@ -76,11 +74,7 @@ void Device::attach(){ | |||
76 | // FIXME -- this is a hack for an odd hciattach interface. | 74 | // FIXME -- this is a hack for an odd hciattach interface. |
77 | if ( ODevice::inst()->modelString() == "HX4700" ) | 75 | if ( ODevice::inst()->modelString() == "HX4700" ) |
78 | { | 76 | *m_process << "-S" << "/etc/bluetooth/TIInit_3.2.26.bts" << "/dev/ttyS1" << "texas"; |
79 | *m_process << "-S" << "/etc/bluetooth/TIInit_3.2.26.bts" << "/dev/ttyS1" << "texas"; | ||
80 | } | ||
81 | else | 77 | else |
82 | { | 78 | *m_process << m_device << m_mode << m_speed; |
83 | *m_process << m_device << m_mode << m_speed; | ||
84 | } | ||
85 | connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ), | 79 | connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ), |
86 | this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); | 80 | this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); |
@@ -94,14 +88,16 @@ void Device::attach(){ | |||
94 | m_process = 0; | 88 | m_process = 0; |
95 | } | 89 | } |
96 | }; | 90 | } |
97 | } | 91 | } |
98 | void Device::detach(){ | 92 | void Device::detach(){ |
99 | delete m_hci; | 93 | delete m_hci; |
94 | m_hci = 0; | ||
100 | delete m_process; | 95 | delete m_process; |
96 | m_process = 0; | ||
101 | // kill the pid we got | 97 | // kill the pid we got |
102 | if(m_attached ){ | 98 | if(m_attached ){ |
103 | //kill the pid | 99 | //kill the pid |
104 | owarn << "killing" << oendl; | 100 | owarn << "killing" << oendl; |
105 | kill(pid, 9); | 101 | ::kill(pid, 9); |
106 | } | 102 | } |
107 | owarn << "detached" << oendl; | 103 | owarn << "detached" << oendl; |
@@ -122,25 +118,25 @@ void Device::slotExited( OProcess* proc) | |||
122 | int ret = m_process->exitStatus(); | 118 | int ret = m_process->exitStatus(); |
123 | if( ret == 0 ){ // attached | 119 | if( ret == 0 ){ // attached |
124 | owarn << "attached" << oendl; | 120 | owarn << "attached" << oendl; |
125 | owarn << "Output: " << m_output.data() << oendl; | 121 | owarn << "Output: " << m_output.data() << oendl; |
126 | pid = parsePid( m_output ); | 122 | pid = parsePid( m_output ); |
127 | owarn << "Pid = " << pid << oendl; | 123 | owarn << "Pid = " << pid << oendl; |
128 | // now hciconfig hci0 up ( determine hciX FIXME) | 124 | // now hciconfig hci0 up ( determine hciX FIXME) |
129 | // and call hciconfig hci0 up | 125 | // and call hciconfig hci0 up |
130 | // FIXME hardcoded to hci0 now :( | 126 | // FIXME hardcoded to hci0 now :( |
131 | m_hci = new OProcess( ); | 127 | m_hci = new OProcess( ); |
132 | *m_hci << "hciconfig"; | 128 | *m_hci << "hciconfig"; |
133 | *m_hci << "hci0 up"; | 129 | *m_hci << "hci0 up"; |
134 | connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ), | 130 | connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ), |
135 | this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); | 131 | this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); |
136 | if(!m_hci->start() ){ | 132 | if(!m_hci->start() ){ |
137 | owarn << "could not start" << oendl; | 133 | owarn << "could not start" << oendl; |
138 | m_attached = false; | 134 | m_attached = false; |
139 | emit device("hci0", false ); | 135 | emit device("hci0", false ); |
140 | } | 136 | } |
141 | }else{ | 137 | }else{ |
142 | owarn << "crass" << oendl; | 138 | owarn << "crass" << oendl; |
143 | m_attached = false; | 139 | m_attached = false; |
144 | emit device("hci0", false ); | 140 | emit device("hci0", false ); |
145 | 141 | ||
146 | } | 142 | } |
@@ -154,11 +150,11 @@ void Device::slotExited( OProcess* proc) | |||
154 | int ret = m_hci->exitStatus(); | 150 | int ret = m_hci->exitStatus(); |
155 | if( ret == 0 ){ | 151 | if( ret == 0 ){ |
156 | owarn << "attached really really attached" << oendl; | 152 | owarn << "attached really really attached" << oendl; |
157 | m_attached = true; | 153 | m_attached = true; |
158 | emit device("hci0", true ); | 154 | emit device("hci0", true ); |
159 | }else{ | 155 | }else{ |
160 | owarn << "failed" << oendl; | 156 | owarn << "failed" << oendl; |
161 | emit device("hci0", false ); | 157 | emit device("hci0", false ); |
162 | m_attached = false; | 158 | m_attached = false; |
163 | } | 159 | } |
164 | }// normal exit | 160 | }// normal exit |