summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-03-06 22:22:51 (UTC)
committer harlekin <harlekin>2003-03-06 22:22:51 (UTC)
commite2165a29b9fc618037295fc7515e0364b9a3da4f (patch) (unidiff)
tree72dfa3c16132e83f84c8300150c47c05e0da7cde
parent56eadb23f09da3823da787d98c0f2478620a15b3 (diff)
downloadopie-e2165a29b9fc618037295fc7515e0364b9a3da4f.zip
opie-e2165a29b9fc618037295fc7515e0364b9a3da4f.tar.gz
opie-e2165a29b9fc618037295fc7515e0364b9a3da4f.tar.bz2
activate connections tab
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/manager.cc7
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp2
-rw-r--r--noncore/net/opietooth/manager/btconnectionitem.cpp1
3 files changed, 6 insertions, 4 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index 1281116..59ade6d 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -214,86 +214,87 @@ RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) {
214 qWarning("OpieTooth %s", str.latin1() ); 214 qWarning("OpieTooth %s", str.latin1() );
215 int pos = str.findRev(':' ); 215 int pos = str.findRev(':' );
216 if ( pos > 0 ) { 216 if ( pos > 0 ) {
217 QString mac = str.left(17 ); 217 QString mac = str.left(17 );
218 str.remove( 0, 17 ); 218 str.remove( 0, 17 );
219 qWarning("mac %s", mac.latin1() ); 219 qWarning("mac %s", mac.latin1() );
220 qWarning("rest:%s", str.latin1() ); 220 qWarning("rest:%s", str.latin1() );
221 RemoteDevice rem( mac , str.stripWhiteSpace() ); 221 RemoteDevice rem( mac , str.stripWhiteSpace() );
222 list.append( rem ); 222 list.append( rem );
223 } 223 }
224 } 224 }
225 return list; 225 return list;
226} 226}
227 227
228////// hcitool cc and hcitool con 228////// hcitool cc and hcitool con
229 229
230/** 230/**
231 * Create it on the stack as don't care 231 * Create it on the stack as don't care
232 * so we don't need to care for it 232 * so we don't need to care for it
233 * cause hcitool gets reparented 233 * cause hcitool gets reparented
234 */ 234 */
235void Manager::connectTo( const QString& mac) { 235void Manager::connectTo( const QString& mac) {
236 OProcess proc; 236 OProcess proc;
237 proc << "hcitool"; 237 proc << "hcitool";
238 proc << "cc"; 238 proc << "cc";
239 proc << mac; 239 proc << mac;
240 proc.start(OProcess::DontCare); // the lib does not care at this point 240 proc.start(OProcess::DontCare); // the lib does not care at this point
241} 241}
242 242
243 243
244void Manager::searchConnections() { 244void Manager::searchConnections() {
245 qWarning("searching connections?"); 245 qWarning("searching connections?");
246 OProcess* proc = new OProcess(); 246 OProcess* proc = new OProcess();
247 m_hcitoolCon = QString::null; 247 m_hcitoolCon = QString::null;
248 248
249 connect(proc, SIGNAL(processExited(OProcess*) ), 249 connect(proc, SIGNAL(processExited(OProcess*) ),
250 this, SLOT(slotConnectionExited( OProcess*) ) ); 250 this, SLOT(slotConnectionExited( OProcess*) ) );
251 connect(proc, SIGNAL(receivedStdout(OProcess*, char*, int) ), 251 connect(proc, SIGNAL(receivedStdout(OProcess*, char*, int) ),
252 this, SLOT(slotConnectionOutput(OProcess*, char*, int) ) ); 252 this, SLOT(slotConnectionOutput(OProcess*, char*, int) ) );
253 *proc << "hcitool"; 253 *proc << "hcitool";
254 *proc << "con"; 254 *proc << "con";
255 255
256 if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 256 if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
257 ConnectionState::ValueList list; 257 ConnectionState::ValueList list;
258 emit connections( list ); 258 emit connections( list );
259 delete proc; 259 delete proc;
260 } 260 }
261} 261}
262void Manager::slotConnectionExited( OProcess* /*proc*/ ) { 262void Manager::slotConnectionExited( OProcess* proc ) {
263 qWarning("exited"); 263 qWarning("<<<<<<<<<<<<<<<<<exited");
264 ConnectionState::ValueList list; 264 ConnectionState::ValueList list;
265 list = parseConnections( m_hcitoolCon ); 265 list = parseConnections( m_hcitoolCon );
266 emit connections(list ); 266 emit connections(list );
267 delete proc;
267} 268}
268void Manager::slotConnectionOutput(OProcess* proc, char* cha, int len) { 269void Manager::slotConnectionOutput(OProcess* proc, char* cha, int len) {
269 QCString str(cha, len ); 270 QCString str(cha, len );
270 m_hcitoolCon.append( str ); 271 m_hcitoolCon.append( str );
271 delete proc; 272 //delete proc;
272} 273}
273ConnectionState::ValueList Manager::parseConnections( const QString& out ) { 274ConnectionState::ValueList Manager::parseConnections( const QString& out ) {
274 ConnectionState::ValueList list2; 275 ConnectionState::ValueList list2;
275 QStringList list = QStringList::split('\n', out ); 276 QStringList list = QStringList::split('\n', out );
276 QStringList::Iterator it; 277 QStringList::Iterator it;
277 for (it = list.begin(); it != list.end(); ++it ) { 278 for (it = list.begin(); it != list.end(); ++it ) {
278 QString row = (*it).stripWhiteSpace(); 279 QString row = (*it).stripWhiteSpace();
279 QStringList value = QStringList::split(' ', row ); 280 QStringList value = QStringList::split(' ', row );
280 qWarning("0: %s", value[0].latin1() ); 281 qWarning("0: %s", value[0].latin1() );
281 qWarning("1: %s", value[1].latin1() ); 282 qWarning("1: %s", value[1].latin1() );
282 qWarning("2: %s", value[2].latin1() ); 283 qWarning("2: %s", value[2].latin1() );
283 qWarning("3: %s", value[3].latin1() ); 284 qWarning("3: %s", value[3].latin1() );
284 qWarning("4: %s", value[4].latin1() ); 285 qWarning("4: %s", value[4].latin1() );
285 qWarning("5: %s", value[5].latin1() ); 286 qWarning("5: %s", value[5].latin1() );
286 qWarning("6: %s", value[6].latin1() ); 287 qWarning("6: %s", value[6].latin1() );
287 qWarning("7: %s", value[7].latin1() ); 288 qWarning("7: %s", value[7].latin1() );
288 qWarning("8: %s", value[8].latin1() ); 289 qWarning("8: %s", value[8].latin1() );
289 ConnectionState con; 290 ConnectionState con;
290 con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming ); 291 con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming );
291 con.setConnectionMode( value[1] ); 292 con.setConnectionMode( value[1] );
292 con.setMac( value[2] ); 293 con.setMac( value[2] );
293 con.setHandle( value[4].toInt() ); 294 con.setHandle( value[4].toInt() );
294 con.setState( value[6].toInt() ); 295 con.setState( value[6].toInt() );
295 con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client ); 296 con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client );
296 list2.append( con ); 297 list2.append( con );
297 } 298 }
298 return list2; 299 return list2;
299} 300}
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index d3abb54..5c5f069 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -373,97 +373,97 @@ void BlueBase::addServicesToDevice( BTDeviceItem * item ) {
373 * @param device the mac address of the remote device 373 * @param device the mac address of the remote device
374 * @param servicesList the list with the service the device has. 374 * @param servicesList the list with the service the device has.
375 */ 375 */
376void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 376void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
377 qDebug("fill services list"); 377 qDebug("fill services list");
378 378
379 QMap<QString,BTDeviceItem*>::Iterator it; 379 QMap<QString,BTDeviceItem*>::Iterator it;
380 BTDeviceItem* deviceItem = 0; 380 BTDeviceItem* deviceItem = 0;
381 381
382 // get the right devices which requested the search 382 // get the right devices which requested the search
383 it = m_deviceList.find( device ); 383 it = m_deviceList.find( device );
384 if( it == m_deviceList.end() ) 384 if( it == m_deviceList.end() )
385 return; 385 return;
386 deviceItem = it.data(); 386 deviceItem = it.data();
387 387
388 QValueList<OpieTooth::Services>::Iterator it2; 388 QValueList<OpieTooth::Services>::Iterator it2;
389 BTServiceItem * serviceItem; 389 BTServiceItem * serviceItem;
390 390
391 if (!servicesList.isEmpty() ) { 391 if (!servicesList.isEmpty() ) {
392 // add services 392 // add services
393 QMap<int, QString> list; 393 QMap<int, QString> list;
394 QMap<int, QString>::Iterator classIt; 394 QMap<int, QString>::Iterator classIt;
395 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 395 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
396 serviceItem = new BTServiceItem( deviceItem , (*it2) ); 396 serviceItem = new BTServiceItem( deviceItem , (*it2) );
397 list = (*it2).classIdList(); 397 list = (*it2).classIdList();
398 classIt = list.begin(); 398 classIt = list.begin();
399 int classId=0; 399 int classId=0;
400 if ( classIt != list.end() ) { 400 if ( classIt != list.end() ) {
401 classId = classIt.key(); 401 classId = classIt.key();
402 } 402 }
403 403
404 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); 404 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) );
405 } 405 }
406 } else { 406 } else {
407 Services s1; 407 Services s1;
408 s1.setServiceName( tr("no serives found") ); 408 s1.setServiceName( tr("no serives found") );
409 serviceItem = new BTServiceItem( deviceItem, s1 ); 409 serviceItem = new BTServiceItem( deviceItem, s1 );
410 } 410 }
411 // now remove them from the list 411 // now remove them from the list
412 m_deviceList.remove( it ); 412 m_deviceList.remove( it );
413} 413}
414 414
415 415
416/** 416/**
417 * Add the existing connections (pairs) to the connections tab. 417 * Add the existing connections (pairs) to the connections tab.
418 * This one triggers the search 418 * This one triggers the search
419 */ 419 */
420void BlueBase::addConnectedDevices() { 420void BlueBase::addConnectedDevices() {
421 m_localDevice->searchConnections(); 421 m_localDevice->searchConnections();
422} 422}
423 423
424 424
425/** 425/**
426 * This adds the found connections to the connection tab. 426 * This adds the found connections to the connection tab.
427 * @param connectionList the ValueList with all current connections 427 * @param connectionList the ValueList with all current connections
428 */ 428 */
429void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { 429void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) {
430 430
431 // clear the ListView first 431 // clear the ListView first
432 ListView4->clear(); 432 ListView4->clear();
433 433
434 QValueList<OpieTooth::ConnectionState>::Iterator it; 434 QValueList<OpieTooth::ConnectionState>::Iterator it;
435 BTConnectionItem * connectionItem; 435 BTConnectionItem * connectionItem;
436 436
437 if ( !connectionList.isEmpty() ) { 437 if ( !connectionList.isEmpty() ) {
438 438
439 for (it = connectionList.begin(); it != connectionList.end(); ++it) { 439 for (it = connectionList.begin(); it != connectionList.end(); ++it) {
440 connectionItem = new BTConnectionItem( ListView4 , (*it) ); 440 connectionItem = new BTConnectionItem( ListView4 , (*it) );
441 } 441 }
442 } else { 442 } else {
443 ConnectionState con; 443 ConnectionState con;
444 con.setMac( tr("No connections found") ); 444 con.setMac( tr("No connections found") );
445 connectionItem = new BTConnectionItem( ListView4 , con ); 445 connectionItem = new BTConnectionItem( ListView4 , con );
446 } 446 }
447 447
448 // recall connection search after some time 448 // recall connection search after some time
449 QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); 449 QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) );
450} 450}
451 451
452 452
453/** 453/**
454 * Find out if a device can currently be reached 454 * Find out if a device can currently be reached
455 * @param device 455 * @param device
456 */ 456 */
457void BlueBase::deviceActive( const RemoteDevice &device ) { 457void BlueBase::deviceActive( const RemoteDevice &device ) {
458 // search by mac, async, gets a signal back 458 // search by mac, async, gets a signal back
459 // We should have a BTDeviceItem there or where does it get added to the map -zecke 459 // We should have a BTDeviceItem there or where does it get added to the map -zecke
460 m_localDevice->isAvailable( device.mac() ); 460 m_localDevice->isAvailable( device.mac() );
461} 461}
462 462
463 463
464/** 464/**
465 * The signal catcher. Set the avail. status on device. 465 * The signal catcher. Set the avail. status on device.
466 * @param device - the mac address 466 * @param device - the mac address
467 * @param connected - if it is avail. or not 467 * @param connected - if it is avail. or not
468 */ 468 */
469void BlueBase::deviceActive( const QString& device, bool connected ) { 469void BlueBase::deviceActive( const QString& device, bool connected ) {
diff --git a/noncore/net/opietooth/manager/btconnectionitem.cpp b/noncore/net/opietooth/manager/btconnectionitem.cpp
index 6fb9c11..b57d1b3 100644
--- a/noncore/net/opietooth/manager/btconnectionitem.cpp
+++ b/noncore/net/opietooth/manager/btconnectionitem.cpp
@@ -1,23 +1,24 @@
1#include <connection.h> 1#include <connection.h>
2#include "btconnectionitem.h" 2#include "btconnectionitem.h"
3 3
4using namespace OpieTooth; 4using namespace OpieTooth;
5 5
6BTConnectionItem::BTConnectionItem( QListView* parent, const ConnectionState& con ) 6BTConnectionItem::BTConnectionItem( QListView* parent, const ConnectionState& con )
7 : BTListItem( parent ){ 7 : BTListItem( parent ){
8 m_con = con; 8 m_con = con;
9 setText(0, m_con.mac() ); 9 setText(0, m_con.mac() );
10 setText(1, m_con.connectionMode() );
10} 11}
11BTConnectionItem::~BTConnectionItem() { 12BTConnectionItem::~BTConnectionItem() {
12 13
13} 14}
14QString BTConnectionItem::type() const { 15QString BTConnectionItem::type() const {
15 return QString::fromLatin1("connection"); 16 return QString::fromLatin1("connection");
16} 17}
17int BTConnectionItem::typeId() const { 18int BTConnectionItem::typeId() const {
18 return Connection; 19 return Connection;
19} 20}
20ConnectionState BTConnectionItem::connection() const { 21ConnectionState BTConnectionItem::connection() const {
21 return m_con; 22 return m_con;
22} 23}
23 24