summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/manager.cc58
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp44
-rw-r--r--noncore/net/opietooth/manager/bluebase.h9
3 files changed, 54 insertions, 57 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index 53122c1..83100f1 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -13,7 +13,7 @@ using Opie::Core::OProcess;
13Manager::Manager( const QString& dev ) 13Manager::Manager( const QString& dev )
14 : QObject() 14 : QObject()
15{ 15{
16 owarn << "created" << oendl; 16 odebug << "Manager: created" << oendl;
17 m_device = dev; 17 m_device = dev;
18 m_hcitool = 0; 18 m_hcitool = 0;
19 m_sdp = 0; 19 m_sdp = 0;
@@ -58,7 +58,7 @@ void Manager::isAvailable( Device* /*dev*/ ){
58 58
59} 59}
60void Manager::searchDevices( const QString& device ){ 60void Manager::searchDevices( const QString& device ){
61 owarn << "search devices" << oendl; 61 odebug << "Manager: search devices" << oendl;
62 OProcess* hcitool = new OProcess(); 62 OProcess* hcitool = new OProcess();
63 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); 63 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() );
64 *hcitool << "hcitool" << "scan"; 64 *hcitool << "hcitool" << "scan";
@@ -67,7 +67,7 @@ void Manager::searchDevices( const QString& device ){
67 connect( hcitool, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), 67 connect( hcitool, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
68 this, SLOT(slotHCIOut(Opie::Core::OProcess*, char*, int ) ) ); 68 this, SLOT(slotHCIOut(Opie::Core::OProcess*, char*, int ) ) );
69 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 69 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
70 owarn << "could not start" << oendl; 70 odebug << "Manager: could not start" << oendl;
71 RemoteDevice::ValueList list; 71 RemoteDevice::ValueList list;
72 emit foundDevices( device, list ); 72 emit foundDevices( device, list );
73 delete hcitool; 73 delete hcitool;
@@ -108,13 +108,13 @@ void Manager::searchServices( const QString& remDevice ){
108 OProcess *m_sdp =new OProcess(); 108 OProcess *m_sdp =new OProcess();
109 *m_sdp << "sdptool" << "browse" << remDevice; 109 *m_sdp << "sdptool" << "browse" << remDevice;
110 m_sdp->setName( remDevice.latin1() ); 110 m_sdp->setName( remDevice.latin1() );
111 owarn << "search Services for " << remDevice.latin1() << oendl; 111 odebug << "Manager: search Services for " << remDevice.latin1() << oendl;
112 connect(m_sdp, SIGNAL(processExited(Opie::Core::OProcess*) ), 112 connect(m_sdp, SIGNAL(processExited(Opie::Core::OProcess*) ),
113 this, SLOT(slotSDPExited(Opie::Core::OProcess* ) ) ); 113 this, SLOT(slotSDPExited(Opie::Core::OProcess* ) ) );
114 connect(m_sdp, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), 114 connect(m_sdp, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
115 this, SLOT(slotSDPOut(Opie::Core::OProcess*, char*, int) ) ); 115 this, SLOT(slotSDPOut(Opie::Core::OProcess*, char*, int) ) );
116 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 116 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
117 owarn << "could not start sdptool" << oendl; 117 odebug << "Manager: could not start sdptool" << oendl;
118 delete m_sdp; 118 delete m_sdp;
119 Services::ValueList list; 119 Services::ValueList list;
120 emit foundServices( remDevice, list ); 120 emit foundServices( remDevice, list );
@@ -141,7 +141,7 @@ void Manager::slotProcessExited(OProcess* proc ) {
141void Manager::slotSDPOut(OProcess* proc, char* ch, int len) 141void Manager::slotSDPOut(OProcess* proc, char* ch, int len)
142{ 142{
143 QCString str(ch, len+1 ); 143 QCString str(ch, len+1 );
144 owarn << "SDP:" << str.data() << oendl; 144 odebug << "Manager: SDP:" << str.data() << oendl;
145 QMap<QString, QString>::Iterator it; 145 QMap<QString, QString>::Iterator it;
146 it = m_out.find(proc->name() ); 146 it = m_out.find(proc->name() );
147 QString string; 147 QString string;
@@ -154,12 +154,12 @@ void Manager::slotSDPOut(OProcess* proc, char* ch, int len)
154} 154}
155void Manager::slotSDPExited( OProcess* proc) 155void Manager::slotSDPExited( OProcess* proc)
156{ 156{
157 owarn << "proc name " << proc->name() << oendl; 157 odebug << "Manager: proc name " << proc->name() << oendl;
158 Services::ValueList list; 158 Services::ValueList list;
159 if (proc->normalExit() ) { 159 if (proc->normalExit() ) {
160 QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); 160 QMap<QString, QString>::Iterator it = m_out.find( proc->name() );
161 if ( it != m_out.end() ) { 161 if ( it != m_out.end() ) {
162 owarn << "found process" << oendl; 162 odebug << "Manager: found process" << oendl;
163 list = parseSDPOutput( it.data() ); 163 list = parseSDPOutput( it.data() );
164 m_out.remove( it ); 164 m_out.remove( it );
165 } 165 }
@@ -169,20 +169,20 @@ void Manager::slotSDPExited( OProcess* proc)
169} 169}
170Services::ValueList Manager::parseSDPOutput( const QString& out ) { 170Services::ValueList Manager::parseSDPOutput( const QString& out ) {
171 Services::ValueList list; 171 Services::ValueList list;
172 owarn << "parsing output" << oendl; 172 odebug << "Manager: 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 odebug << "Manager: 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 odebug << "Manager: 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 odebug << "Manager: != end ;)" << oendl;
186 list = parseHCIOutput( it.data() ); 186 list = parseHCIOutput( it.data() );
187 m_devices.remove( it ); 187 m_devices.remove( it );
188 } 188 }
@@ -192,13 +192,13 @@ void Manager::slotHCIExited(OProcess* 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 odebug << "Manager: 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 odebug << "Manager: 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 odebug << "Manager: slotHCIOut " << oendl;
202 string = it.data(); 202 string = it.data();
203 } 203 }
204 string.append( str ); 204 string.append( str );
@@ -206,20 +206,20 @@ void Manager::slotHCIOut(OProcess* proc, char* ch, int len) {
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 odebug << "Manager: 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 odebug << "Manager: 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 );
220 str.remove( 0, 17 ); 220 str.remove( 0, 17 );
221 owarn << "mac " << mac.latin1() << oendl; 221 odebug << "Manager: mac " << mac.latin1() << oendl;
222 owarn << "rest: " << str.latin1() << oendl; 222 odebug << "Manager: rest: " << str.latin1() << oendl;
223 RemoteDevice rem( mac , str.stripWhiteSpace() ); 223 RemoteDevice rem( mac , str.stripWhiteSpace() );
224 list.append( rem ); 224 list.append( rem );
225 } 225 }
@@ -244,7 +244,7 @@ void Manager::connectTo( const QString& mac) {
244 244
245 245
246void Manager::searchConnections() { 246void Manager::searchConnections() {
247 owarn << "searching connections?" << oendl; 247 odebug << "Manager: searchConnections()" << oendl;
248 OProcess* proc = new OProcess(); 248 OProcess* proc = new OProcess();
249 m_hcitoolCon = QString::null; 249 m_hcitoolCon = QString::null;
250 250
@@ -282,15 +282,15 @@ ConnectionState::ValueList Manager::parseConnections( const QString& out ) {
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 owarn << "0: %s" << value[0].latin1() << oendl; 285 odebug << "Manager: 0: " << value[0].latin1() << oendl;
286 owarn << "1: %s" << value[1].latin1() << oendl; 286 odebug << "Manager: 1: " << value[1].latin1() << oendl;
287 owarn << "2: %s" << value[2].latin1() << oendl; 287 odebug << "Manager: 2: " << value[2].latin1() << oendl;
288 owarn << "3: %s" << value[3].latin1() << oendl; 288 odebug << "Manager: 3: " << value[3].latin1() << oendl;
289 owarn << "4: %s" << value[4].latin1() << oendl; 289 odebug << "Manager: 4: " << value[4].latin1() << oendl;
290 owarn << "5: %s" << value[5].latin1() << oendl; 290 odebug << "Manager: 5: " << value[5].latin1() << oendl;
291 owarn << "6: %s" << value[6].latin1() << oendl; 291 odebug << "Manager: 6: " << value[6].latin1() << oendl;
292 owarn << "7: %s" << value[7].latin1() << oendl; 292 odebug << "Manager: 7: " << value[7].latin1() << oendl;
293 owarn << "8: %s" << value[8].latin1() << oendl; 293 odebug << "Manager: 8: " << 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] );
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index af1cd23..0649514 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -59,16 +59,13 @@ using namespace OpieTooth;
59BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 59BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
60 : BluetoothBase( parent, name, fl ) 60 : BluetoothBase( parent, name, fl )
61{ 61{
62
63 m_localDevice = new Manager( "hci0" ); 62 m_localDevice = new Manager( "hci0" );
64 63
65 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 64 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
66 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 65 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
67 66
68 connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) ); 67 connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) );
69 // not good since lib is async 68
70 // connect( devicesView, SIGNAL( expanded(QListViewItem*) ),
71 // this, SLOT( addServicesToDevice(QListViewItem*) ) );
72 connect( devicesView, SIGNAL( clicked(QListViewItem*)), 69 connect( devicesView, SIGNAL( clicked(QListViewItem*)),
73 this, SLOT( startServiceActionClicked(QListViewItem*) ) ); 70 this, SLOT( startServiceActionClicked(QListViewItem*) ) );
74 connect( devicesView, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), 71 connect( devicesView, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ),
@@ -82,7 +79,6 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
82 connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ), 79 connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ),
83 this, SLOT( addSignalStrength(const QString&,const QString&) ) ); 80 this, SLOT( addSignalStrength(const QString&,const QString&) ) );
84 81
85
86 // let hold be rightButtonClicked() 82 // let hold be rightButtonClicked()
87 QPEApplication::setStylusOperation( devicesView->viewport(), QPEApplication::RightOnHold); 83 QPEApplication::setStylusOperation( devicesView->viewport(), QPEApplication::RightOnHold);
88 QPEApplication::setStylusOperation( connectionsView->viewport(), QPEApplication::RightOnHold); 84 QPEApplication::setStylusOperation( connectionsView->viewport(), QPEApplication::RightOnHold);
@@ -106,14 +102,12 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
106 initGui(); 102 initGui();
107 103
108 devicesView->setRootIsDecorated(true); 104 devicesView->setRootIsDecorated(true);
109 105 m_iconLoader = new BTIconLoader();
110
111 writeToHciConfig(); 106 writeToHciConfig();
112 // search conncetions
113 addConnectedDevices(); 107 addConnectedDevices();
114 addSignalStrength();
115 m_iconLoader = new BTIconLoader();
116 readSavedDevices(); 108 readSavedDevices();
109 addServicesToDevices();
110 QTimer::singleShot( 3000, this, SLOT( addServicesToDevices() ) );
117} 111}
118 112
119/** 113/**
@@ -171,7 +165,7 @@ void BlueBase::writeToHciConfig()
171 165
172 166
173/** 167/**
174 * Read the list of allready known devices 168 * Read the list of already known devices
175 */ 169 */
176void BlueBase::readSavedDevices() 170void BlueBase::readSavedDevices()
177{ 171{
@@ -185,7 +179,7 @@ void BlueBase::readSavedDevices()
185 179
186 180
187/** 181/**
188 * Write the list of allready known devices 182 * Write the list of already known devices
189 */ 183 */
190void BlueBase::writeSavedDevices() 184void BlueBase::writeSavedDevices()
191{ 185{
@@ -295,9 +289,6 @@ void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices )
295 289
296 // look if device is avail. atm, async 290 // look if device is avail. atm, async
297 deviceActive( (*it) ); 291 deviceActive( (*it) );
298
299 // ggf auch hier?
300 addServicesToDevice( deviceItem );
301 } 292 }
302} 293}
303 294
@@ -398,13 +389,24 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
398} 389}
399 390
400 391
392void BlueBase::addServicesToDevices()
393{
394 odebug << "BlueBase::addServicesToDevices()" << oendl;
395 BTDeviceItem* item = (BTDeviceItem*) devicesView->firstChild();
396 while ( item )
397 {
398 addServicesToDevice( item );
399 item = (BTDeviceItem*) static_cast<QListViewItem*>( item )->nextSibling();
400 }
401}
402
401/** 403/**
402 * Search and display avail. services for a device (on expand from device listing) 404 * Search and display avail. services for a device (on expand from device listing)
403 * @param item the service item returned 405 * @param item the service item returned
404 */ 406 */
405void BlueBase::addServicesToDevice( BTDeviceItem * item ) 407void BlueBase::addServicesToDevice( BTDeviceItem * item )
406{ 408{
407 odebug << "addServicesToDevice" << oendl; 409 odebug << "BlueBase::addServicesToDevice" << oendl;
408 // row of mac adress text(3) 410 // row of mac adress text(3)
409 RemoteDevice device = item->remoteDevice(); 411 RemoteDevice device = item->remoteDevice();
410 m_deviceList.insert( item->mac() , item ); 412 m_deviceList.insert( item->mac() , item );
@@ -414,14 +416,12 @@ void BlueBase::addServicesToDevice( BTDeviceItem * item )
414 416
415 417
416/** 418/**
417 * Overloaded. This one it the one that is
418 ted to the foundServices signal
419 * @param device the mac address of the remote device 419 * @param device the mac address of the remote device
420 * @param servicesList the list with the service the device has. 420 * @param servicesList the list with the service the device has.
421 */ 421 */
422void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) 422void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList )
423{ 423{
424 odebug << "fill services list" << oendl; 424 odebug << "BlueBase::fill services list" << oendl;
425 425
426 QMap<QString,BTDeviceItem*>::Iterator it; 426 QMap<QString,BTDeviceItem*>::Iterator it;
427 BTDeviceItem* deviceItem = 0; 427 BTDeviceItem* deviceItem = 0;
@@ -476,10 +476,6 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s
476 m_deviceList.remove( it ); 476 m_deviceList.remove( it );
477} 477}
478 478
479
480
481
482
483void BlueBase::addSignalStrength() 479void BlueBase::addSignalStrength()
484{ 480{
485 481
@@ -512,6 +508,7 @@ void BlueBase::addSignalStrength( const QString& mac, const QString& strength )
512void BlueBase::addConnectedDevices() 508void BlueBase::addConnectedDevices()
513{ 509{
514 m_localDevice->searchConnections(); 510 m_localDevice->searchConnections();
511 QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) );
515} 512}
516 513
517/** 514/**
@@ -615,7 +612,6 @@ void BlueBase::deviceActive( const QString& device, bool connected )
615 612
616 BTDeviceItem* deviceItem = it.data(); 613 BTDeviceItem* deviceItem = it.data();
617 614
618
619 if ( connected ) 615 if ( connected )
620 { 616 {
621 deviceItem->setPixmap( 1, m_onPix ); 617 deviceItem->setPixmap( 1, m_onPix );
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h
index a8ab3db..48883d2 100644
--- a/noncore/net/opietooth/manager/bluebase.h
+++ b/noncore/net/opietooth/manager/bluebase.h
@@ -40,16 +40,16 @@ namespace OpieTooth {
40 public: 40 public:
41 BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 41 BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
42 ~BlueBase(); 42 ~BlueBase();
43 43
44 static QString appName() { return QString::fromLatin1("bluetooth-manager"); } 44 static QString appName() { return QString::fromLatin1("bluetooth-manager"); }
45 45
46 protected: 46 protected:
47 47
48 48
49 private slots: 49 private slots:
50 void startScan(); 50 void startScan();
51 51
52 52
53 private: 53 private:
54 bool find( const RemoteDevice& device ); 54 bool find( const RemoteDevice& device );
55 void readConfig(); 55 void readConfig();
@@ -82,6 +82,7 @@ namespace OpieTooth {
82 82
83 private slots: 83 private slots:
84 void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); 84 void addSearchedDevices( const QValueList<RemoteDevice> &newDevices );
85 void addServicesToDevices();
85 void addServicesToDevice( BTDeviceItem *item ); 86 void addServicesToDevice( BTDeviceItem *item );
86 void addServicesToDevice( const QString& device, Services::ValueList ); 87 void addServicesToDevice( const QString& device, Services::ValueList );
87 void addConnectedDevices(); 88 void addConnectedDevices();