summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/device.cc2
-rw-r--r--noncore/net/opietooth/lib/manager.cc20
2 files changed, 11 insertions, 11 deletions
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc
index f81066e..eea1178 100644
--- a/noncore/net/opietooth/lib/device.cc
+++ b/noncore/net/opietooth/lib/device.cc
@@ -51,49 +51,49 @@ void Device::attach(){
51 owarn << "new process to create" << oendl; 51 owarn << "new process to create" << oendl;
52 m_process = new OProcess(); 52 m_process = new OProcess();
53 *m_process << "hciattach"; 53 *m_process << "hciattach";
54 *m_process << "-p"; 54 *m_process << "-p";
55 *m_process << m_device << m_mode << m_speed; 55 *m_process << m_device << m_mode << m_speed;
56 connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ), 56 connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ),
57 this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); 57 this, SLOT( slotExited(Opie::Core::OProcess* ) ) );
58 connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ), 58 connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ),
59 this, SLOT(slotStdOut(Opie::Core::OProcess*,char*,int ) ) ); 59 this, SLOT(slotStdOut(Opie::Core::OProcess*,char*,int ) ) );
60 connect(m_process, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ), 60 connect(m_process, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ),
61 this, SLOT(slotStdErr(Opie::Core::OProcess*,char*,int) ) ); 61 this, SLOT(slotStdErr(Opie::Core::OProcess*,char*,int) ) );
62 if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){ 62 if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){
63 owarn << "Could not start" << oendl; 63 owarn << "Could not start" << oendl;
64 delete m_process; 64 delete m_process;
65 m_process = 0; 65 m_process = 0;
66 } 66 }
67 }; 67 };
68} 68}
69void Device::detach(){ 69void Device::detach(){
70 delete m_hci; 70 delete m_hci;
71 delete m_process; 71 delete m_process;
72 // kill the pid we got 72 // kill the pid we got
73 if(m_attached ){ 73 if(m_attached ){
74 //kill the pid 74 //kill the pid
75 warn << "killing" << oendl; 75 owarn << "killing" << oendl;
76 kill(pid, 9); 76 kill(pid, 9);
77 } 77 }
78 owarn << "detached" << oendl; 78 owarn << "detached" << oendl;
79} 79}
80bool Device::isLoaded()const{ 80bool Device::isLoaded()const{
81 return m_attached; 81 return m_attached;
82} 82}
83QString Device::devName()const { 83QString Device::devName()const {
84 return QString::fromLatin1("hci0"); 84 return QString::fromLatin1("hci0");
85}; 85};
86void Device::slotExited( OProcess* proc) 86void Device::slotExited( OProcess* proc)
87{ 87{
88 owarn << "prcess exited" << oendl; 88 owarn << "prcess exited" << oendl;
89 if(proc== m_process ){ 89 if(proc== m_process ){
90 owarn << "proc == m_process" << oendl; 90 owarn << "proc == m_process" << oendl;
91 if( m_process->normalExit() ){ // normal exit 91 if( m_process->normalExit() ){ // normal exit
92 owarn << "normalExit" << oendl; 92 owarn << "normalExit" << oendl;
93 int ret = m_process->exitStatus(); 93 int ret = m_process->exitStatus();
94 if( ret == 0 ){ // attached 94 if( ret == 0 ){ // attached
95 owarn << "attached" << oendl; 95 owarn << "attached" << oendl;
96 owarn << "Output: " << m_output.data() << oendl; 96 owarn << "Output: " << m_output.data() << oendl;
97 pid = parsePid( m_output ); 97 pid = parsePid( m_output );
98 owarn << "Pid = " << pid << oendl; 98 owarn << "Pid = " << pid << oendl;
99 // now hciconfig hci0 up ( determine hciX FIXME) 99 // now hciconfig hci0 up ( determine hciX FIXME)
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index 76d9127..53122c1 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -171,49 +171,49 @@ Services::ValueList Manager::parseSDPOutput( const QString& out ) {
171 Services::ValueList list; 171 Services::ValueList list;
172 owarn << "parsing output" << oendl; 172 owarn << "parsing output" << oendl;
173 Parser parser( out ); 173 Parser parser( out );
174 list = parser.services(); 174 list = parser.services();
175 return list; 175 return list;
176} 176}
177 177
178void Manager::slotHCIExited(OProcess* proc ) { 178void Manager::slotHCIExited(OProcess* proc ) {
179 owarn << "process exited" << oendl; 179 owarn << "process exited" << oendl;
180 RemoteDevice::ValueList list; 180 RemoteDevice::ValueList list;
181 if (proc->normalExit() ) { 181 if (proc->normalExit() ) {
182 owarn << "normalExit " << proc->name() << oendl; 182 owarn << "normalExit " << proc->name() << oendl;
183 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); 183 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() );
184 if (it != m_devices.end() ) { 184 if (it != m_devices.end() ) {
185 owarn << "!= end ;)" << oendl; 185 owarn << "!= end ;)" << oendl;
186 list = parseHCIOutput( it.data() ); 186 list = parseHCIOutput( it.data() );
187 m_devices.remove( it ); 187 m_devices.remove( it );
188 } 188 }
189 } 189 }
190 emit foundDevices( proc->name(), list ); 190 emit foundDevices( proc->name(), list );
191 delete proc; 191 delete proc;
192} 192}
193void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { 193void Manager::slotHCIOut(OProcess* proc, char* ch, int len) {
194 QCString str( ch, len+1 ); 194 QCString str( ch, len+1 );
195 owarn << "hci: " << str.data() oendl; 195 owarn << "hci: " << str.data() << oendl;
196 QMap<QString, QString>::Iterator it; 196 QMap<QString, QString>::Iterator it;
197 it = m_devices.find( proc->name() ); 197 it = m_devices.find( proc->name() );
198 owarn << "proc->name " << proc->name() << oendl; 198 owarn << "proc->name " << proc->name() << oendl;
199 QString string; 199 QString string;
200 if (it != m_devices.end() ) { 200 if (it != m_devices.end() ) {
201 owarn << "slotHCIOut " << oendl; 201 owarn << "slotHCIOut " << oendl;
202 string = it.data(); 202 string = it.data();
203 } 203 }
204 string.append( str ); 204 string.append( str );
205 205
206 m_devices.replace( proc->name(), string ); 206 m_devices.replace( proc->name(), string );
207} 207}
208RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) { 208RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) {
209 owarn << "parseHCI " << output.latin1() << oendl; 209 owarn << "parseHCI " << output.latin1() << oendl;
210 RemoteDevice::ValueList list; 210 RemoteDevice::ValueList list;
211 QStringList strList = QStringList::split('\n', output ); 211 QStringList strList = QStringList::split('\n', output );
212 QStringList::Iterator it; 212 QStringList::Iterator it;
213 QString str; 213 QString str;
214 for ( it = strList.begin(); it != strList.end(); ++it ) { 214 for ( it = strList.begin(); it != strList.end(); ++it ) {
215 str = (*it).stripWhiteSpace(); 215 str = (*it).stripWhiteSpace();
216 owarn << "OpieTooth " << str.latin1() << oendl; 216 owarn << "OpieTooth " << str.latin1() << oendl;
217 int pos = str.findRev(':' ); 217 int pos = str.findRev(':' );
218 if ( pos > 0 ) { 218 if ( pos > 0 ) {
219 QString mac = str.left(17 ); 219 QString mac = str.left(17 );
@@ -261,57 +261,57 @@ void Manager::searchConnections() {
261 delete proc; 261 delete proc;
262 } 262 }
263} 263}
264void Manager::slotConnectionExited( OProcess* proc ) { 264void Manager::slotConnectionExited( OProcess* proc ) {
265 ConnectionState::ValueList list; 265 ConnectionState::ValueList list;
266 list = parseConnections( m_hcitoolCon ); 266 list = parseConnections( m_hcitoolCon );
267 emit connections(list ); 267 emit connections(list );
268 delete proc; 268 delete proc;
269} 269}
270void Manager::slotConnectionOutput(OProcess* /*proc*/, char* cha, int len) { 270void Manager::slotConnectionOutput(OProcess* /*proc*/, char* cha, int len) {
271 QCString str(cha, len ); 271 QCString str(cha, len );
272 m_hcitoolCon.append( str ); 272 m_hcitoolCon.append( str );
273 //delete proc; 273 //delete proc;
274} 274}
275ConnectionState::ValueList Manager::parseConnections( const QString& out ) { 275ConnectionState::ValueList Manager::parseConnections( const QString& out ) {
276 ConnectionState::ValueList list2; 276 ConnectionState::ValueList list2;
277 QStringList list = QStringList::split('\n', out ); 277 QStringList list = QStringList::split('\n', out );
278 QStringList::Iterator it; 278 QStringList::Iterator it;
279 // remove the first line ( "Connections:") 279 // remove the first line ( "Connections:")
280 it = list.begin(); 280 it = list.begin();
281 it = list.remove( it ); 281 it = list.remove( it );
282 for (; it != list.end(); ++it ) { 282 for (; it != list.end(); ++it ) {
283 QString row = (*it).stripWhiteSpace(); 283 QString row = (*it).stripWhiteSpace();
284 QStringList value = QStringList::split(' ', row ); 284 QStringList value = QStringList::split(' ', row );
285 owan << "0: %s" << value[0].latin1() << oendl; 285 owarn << "0: %s" << value[0].latin1() << oendl;
286 owan << "1: %s" << value[1].latin1() << oendl; 286 owarn << "1: %s" << value[1].latin1() << oendl;
287 owan << "2: %s" << value[2].latin1() << oendl; 287 owarn << "2: %s" << value[2].latin1() << oendl;
288 owan << "3: %s" << value[3].latin1() << oendl; 288 owarn << "3: %s" << value[3].latin1() << oendl;
289 owan << "4: %s" << value[4].latin1() << oendl; 289 owarn << "4: %s" << value[4].latin1() << oendl;
290 owan << "5: %s" << value[5].latin1() << oendl; 290 owarn << "5: %s" << value[5].latin1() << oendl;
291 owan << "6: %s" << value[6].latin1() << oendl; 291 owarn << "6: %s" << value[6].latin1() << oendl;
292 owan << "7: %s" << value[7].latin1() << oendl; 292 owarn << "7: %s" << value[7].latin1() << oendl;
293 owan << "8: %s" << value[8].latin1() << oendl; 293 owarn << "8: %s" << value[8].latin1() << oendl;
294 ConnectionState con; 294 ConnectionState con;
295 con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming ); 295 con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming );
296 con.setConnectionMode( value[1] ); 296 con.setConnectionMode( value[1] );
297 con.setMac( value[2] ); 297 con.setMac( value[2] );
298 con.setHandle( value[4].toInt() ); 298 con.setHandle( value[4].toInt() );
299 con.setState( value[6].toInt() ); 299 con.setState( value[6].toInt() );
300 con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client ); 300 con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client );
301 list2.append( con ); 301 list2.append( con );
302 } 302 }
303 return list2; 303 return list2;
304} 304}
305 305
306void Manager::signalStrength( const QString &mac ) { 306void Manager::signalStrength( const QString &mac ) {
307 307
308 OProcess* sig_proc = new OProcess(); 308 OProcess* sig_proc = new OProcess();
309 309
310 connect(sig_proc, SIGNAL(processExited(Opie::Core::OProcess*) ), 310 connect(sig_proc, SIGNAL(processExited(Opie::Core::OProcess*) ),
311 this, SLOT(slotSignalStrengthExited( Opie::Core::OProcess*) ) ); 311 this, SLOT(slotSignalStrengthExited( Opie::Core::OProcess*) ) );
312 connect(sig_proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ), 312 connect(sig_proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ),
313 this, SLOT(slotSignalStrengthOutput(Opie::Core::OProcess*, char*, int) ) ); 313 this, SLOT(slotSignalStrengthOutput(Opie::Core::OProcess*, char*, int) ) );
314 *sig_proc << "hcitool"; 314 *sig_proc << "hcitool";
315 *sig_proc << "lq"; 315 *sig_proc << "lq";
316 *sig_proc << mac; 316 *sig_proc << mac;
317 317