-rw-r--r-- | noncore/net/opietooth/lib/manager.cc | 33 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/manager.h | 7 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 40 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 5 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluetoothbase.ui | 14 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/btconnectionitem.cpp | 18 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/btconnectionitem.h | 8 |
7 files changed, 119 insertions, 6 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc index 8ddcfe8..c89d325 100644 --- a/noncore/net/opietooth/lib/manager.cc +++ b/noncore/net/opietooth/lib/manager.cc | |||
@@ -239,65 +239,96 @@ void Manager::connectTo( const QString& mac) { | |||
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 | ||
244 | void Manager::searchConnections() { | 244 | void 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 | } |
262 | void Manager::slotConnectionExited( OProcess* proc ) { | 262 | void Manager::slotConnectionExited( OProcess* proc ) { |
263 | qWarning("<<<<<<<<<<<<<<<<<exited"); | ||
264 | ConnectionState::ValueList list; | 263 | ConnectionState::ValueList list; |
265 | list = parseConnections( m_hcitoolCon ); | 264 | list = parseConnections( m_hcitoolCon ); |
266 | emit connections(list ); | 265 | emit connections(list ); |
267 | delete proc; | 266 | delete proc; |
268 | } | 267 | } |
269 | void Manager::slotConnectionOutput(OProcess* /*proc*/, char* cha, int len) { | 268 | void Manager::slotConnectionOutput(OProcess* /*proc*/, char* cha, int len) { |
270 | QCString str(cha, len ); | 269 | QCString str(cha, len ); |
271 | m_hcitoolCon.append( str ); | 270 | m_hcitoolCon.append( str ); |
272 | //delete proc; | 271 | //delete proc; |
273 | } | 272 | } |
274 | ConnectionState::ValueList Manager::parseConnections( const QString& out ) { | 273 | ConnectionState::ValueList Manager::parseConnections( const QString& out ) { |
275 | ConnectionState::ValueList list2; | 274 | ConnectionState::ValueList list2; |
276 | QStringList list = QStringList::split('\n', out ); | 275 | QStringList list = QStringList::split('\n', out ); |
277 | QStringList::Iterator it; | 276 | QStringList::Iterator it; |
278 | // remove the first line ( "Connections:") | 277 | // remove the first line ( "Connections:") |
279 | it = list.begin(); | 278 | it = list.begin(); |
280 | it = list.remove( it ); | 279 | it = list.remove( it ); |
281 | for (; it != list.end(); ++it ) { | 280 | for (; it != list.end(); ++it ) { |
282 | QString row = (*it).stripWhiteSpace(); | 281 | QString row = (*it).stripWhiteSpace(); |
283 | QStringList value = QStringList::split(' ', row ); | 282 | QStringList value = QStringList::split(' ', row ); |
284 | qWarning("0: %s", value[0].latin1() ); | 283 | qWarning("0: %s", value[0].latin1() ); |
285 | qWarning("1: %s", value[1].latin1() ); | 284 | qWarning("1: %s", value[1].latin1() ); |
286 | qWarning("2: %s", value[2].latin1() ); | 285 | qWarning("2: %s", value[2].latin1() ); |
287 | qWarning("3: %s", value[3].latin1() ); | 286 | qWarning("3: %s", value[3].latin1() ); |
288 | qWarning("4: %s", value[4].latin1() ); | 287 | qWarning("4: %s", value[4].latin1() ); |
289 | qWarning("5: %s", value[5].latin1() ); | 288 | qWarning("5: %s", value[5].latin1() ); |
290 | qWarning("6: %s", value[6].latin1() ); | 289 | qWarning("6: %s", value[6].latin1() ); |
291 | qWarning("7: %s", value[7].latin1() ); | 290 | qWarning("7: %s", value[7].latin1() ); |
292 | qWarning("8: %s", value[8].latin1() ); | 291 | qWarning("8: %s", value[8].latin1() ); |
293 | ConnectionState con; | 292 | ConnectionState con; |
294 | con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming ); | 293 | con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming ); |
295 | con.setConnectionMode( value[1] ); | 294 | con.setConnectionMode( value[1] ); |
296 | con.setMac( value[2] ); | 295 | con.setMac( value[2] ); |
297 | con.setHandle( value[4].toInt() ); | 296 | con.setHandle( value[4].toInt() ); |
298 | con.setState( value[6].toInt() ); | 297 | con.setState( value[6].toInt() ); |
299 | con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client ); | 298 | con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client ); |
300 | list2.append( con ); | 299 | list2.append( con ); |
301 | } | 300 | } |
302 | return list2; | 301 | return list2; |
303 | } | 302 | } |
303 | |||
304 | void Manager::signalStrength( const QString &mac ) { | ||
305 | |||
306 | OProcess* sig_proc = new OProcess(); | ||
307 | |||
308 | connect(sig_proc, SIGNAL(processExited(OProcess*) ), | ||
309 | this, SLOT(slotSignalStrengthExited( OProcess*) ) ); | ||
310 | connect(sig_proc, SIGNAL(receivedStdout(OProcess*, char*, int) ), | ||
311 | this, SLOT(slotSignalStrengthOutput(OProcess*, char*, int) ) ); | ||
312 | *sig_proc << "hcitool"; | ||
313 | *sig_proc << "lq"; | ||
314 | *sig_proc << mac; | ||
315 | |||
316 | sig_proc->setName( mac.latin1() ); | ||
317 | |||
318 | if (!sig_proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | ||
319 | emit signalStrength( mac, "-1" ); | ||
320 | delete sig_proc; | ||
321 | } | ||
322 | } | ||
323 | |||
324 | void Manager::slotSignalStrengthOutput(OProcess* proc, char* cha, int len) { | ||
325 | QCString str(cha, len ); | ||
326 | QString temp = QString(str).stripWhiteSpace(); | ||
327 | QStringList value = QStringList::split(' ', temp ); | ||
328 | emit signalStrength( proc->name(), value[2].latin1() ); | ||
329 | } | ||
330 | |||
331 | |||
332 | void Manager::slotSignalStrengthExited( OProcess* proc ) { | ||
333 | delete proc; | ||
334 | } | ||
diff --git a/noncore/net/opietooth/lib/manager.h b/noncore/net/opietooth/lib/manager.h index 0ebe1b3..abc8ba1 100644 --- a/noncore/net/opietooth/lib/manager.h +++ b/noncore/net/opietooth/lib/manager.h | |||
@@ -103,64 +103,71 @@ namespace OpieTooth { | |||
103 | /** | 103 | /** |
104 | * search for services on a remote device | 104 | * search for services on a remote device |
105 | * | 105 | * |
106 | */ | 106 | */ |
107 | void searchServices( const QString& remDevice ); | 107 | void searchServices( const QString& remDevice ); |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * search for services on a remote device | 110 | * search for services on a remote device |
111 | */ | 111 | */ |
112 | void searchServices( const RemoteDevice& ); | 112 | void searchServices( const RemoteDevice& ); |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Starts to connect to the device | 115 | * Starts to connect to the device |
116 | * in @param | 116 | * in @param |
117 | */ | 117 | */ |
118 | void connectTo(const QString& ); | 118 | void connectTo(const QString& ); |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * Searches for active connections | 121 | * Searches for active connections |
122 | * the result is emitted with the | 122 | * the result is emitted with the |
123 | * connections signal | 123 | * connections signal |
124 | */ | 124 | */ |
125 | void searchConnections(); | 125 | void searchConnections(); |
126 | 126 | ||
127 | void signalStrength( const QString &mac ); | ||
127 | //// not implemented yet | 128 | //// not implemented yet |
128 | /*static*/ QString toDevice( const QString& mac ); | 129 | /*static*/ QString toDevice( const QString& mac ); |
129 | /*static*/ QString toMac( const QString &device ); | 130 | /*static*/ QString toMac( const QString &device ); |
130 | //// not implemented yet over | 131 | //// not implemented yet over |
131 | 132 | ||
132 | signals: | 133 | signals: |
133 | // device either mac or dev name | 134 | // device either mac or dev name |
134 | // the first device is the device which you access | 135 | // the first device is the device which you access |
135 | void available( const QString& device, bool connected ); | 136 | void available( const QString& device, bool connected ); |
136 | void addedService( const QString& service, bool added ); | 137 | void addedService( const QString& service, bool added ); |
137 | void removedService( const QString& service, bool removed ); | 138 | void removedService( const QString& service, bool removed ); |
138 | void foundServices( const QString& device, Services::ValueList ); | 139 | void foundServices( const QString& device, Services::ValueList ); |
139 | void foundDevices( const QString& device, RemoteDevice::ValueList ); | 140 | void foundDevices( const QString& device, RemoteDevice::ValueList ); |
140 | void connections( ConnectionState::ValueList ); | 141 | void connections( ConnectionState::ValueList ); |
142 | void signalStrength( const QString& mac, const QString& strengh ); | ||
141 | 143 | ||
142 | private slots: | 144 | private slots: |
143 | void slotProcessExited(OProcess* ); | 145 | void slotProcessExited(OProcess* ); |
144 | 146 | ||
145 | void slotSDPExited(OProcess*); | 147 | void slotSDPExited(OProcess*); |
146 | void slotSDPOut(OProcess*, char*, int); | 148 | void slotSDPOut(OProcess*, char*, int); |
147 | 149 | ||
148 | void slotHCIExited(OProcess* ); | 150 | void slotHCIExited(OProcess* ); |
149 | void slotHCIOut(OProcess*, char*, int ); | 151 | void slotHCIOut(OProcess*, char*, int ); |
150 | 152 | ||
151 | void slotConnectionExited(OProcess* ); | 153 | void slotConnectionExited(OProcess* ); |
152 | void slotConnectionOutput(OProcess*, char*, int ); | 154 | void slotConnectionOutput(OProcess*, char*, int ); |
155 | |||
156 | void slotSignalStrengthOutput( OProcess*, char*, int ); | ||
157 | void slotSignalStrengthExited( OProcess* ); | ||
153 | private: | 158 | private: |
154 | Services::ValueList parseSDPOutput( const QString& ); | 159 | Services::ValueList parseSDPOutput( const QString& ); |
155 | RemoteDevice::ValueList parseHCIOutput( const QString& ); | 160 | RemoteDevice::ValueList parseHCIOutput( const QString& ); |
156 | ConnectionState::ValueList parseConnections( const QString& ); | 161 | ConnectionState::ValueList parseConnections( const QString& ); |
157 | OProcess *m_hcitool; | 162 | OProcess *m_hcitool; |
158 | OProcess *m_sdp; // not only one | 163 | OProcess *m_sdp; // not only one |
159 | QString m_device; | 164 | QString m_device; |
165 | QMap<QString, int> m_signalStrength; | ||
160 | QMap<QString, QString> m_out; | 166 | QMap<QString, QString> m_out; |
161 | QMap<QString, QString> m_devices; | 167 | QMap<QString, QString> m_devices; |
168 | QMap<OProcess*, QString> m_signalMac; | ||
162 | QString m_hcitoolCon; | 169 | QString m_hcitoolCon; |
163 | }; | 170 | }; |
164 | }; | 171 | }; |
165 | 172 | ||
166 | #endif | 173 | #endif |
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 8b15c4f..9663b52 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -51,77 +51,81 @@ | |||
51 | 51 | ||
52 | 52 | ||
53 | using namespace OpieTooth; | 53 | using namespace OpieTooth; |
54 | 54 | ||
55 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 55 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
56 | : BluetoothBase( parent, name, fl ) { | 56 | : BluetoothBase( parent, name, fl ) { |
57 | 57 | ||
58 | m_localDevice = new Manager( "hci0" ); | 58 | m_localDevice = new Manager( "hci0" ); |
59 | 59 | ||
60 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 60 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
61 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 61 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
62 | // not good since lib is async | 62 | // not good since lib is async |
63 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), | 63 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), |
64 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); | 64 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); |
65 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), | 65 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), |
66 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); | 66 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); |
67 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), | 67 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), |
68 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); | 68 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); |
69 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), | 69 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), |
70 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); | 70 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); |
71 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), | 71 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), |
72 | this, SLOT( deviceActive( const QString& , bool ) ) ); | 72 | this, SLOT( deviceActive( const QString& , bool ) ) ); |
73 | connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), | 73 | connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), |
74 | this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); | 74 | this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); |
75 | connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ), | ||
76 | this, SLOT( addSignalStrength( const QString&, const QString& ) ) ); | ||
75 | 77 | ||
76 | 78 | ||
77 | // let hold be rightButtonClicked() | 79 | // let hold be rightButtonClicked() |
78 | QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); | 80 | QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); |
79 | QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); | 81 | QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); |
80 | 82 | ||
81 | //Load all icons needed | 83 | //Load all icons needed |
82 | m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); | 84 | m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); |
83 | m_onPix = Resource::loadPixmap( "opietooth/connected" ); | 85 | m_onPix = Resource::loadPixmap( "opietooth/connected" ); |
84 | m_findPix = Resource::loadPixmap( "opietooth/find" ); | 86 | m_findPix = Resource::loadPixmap( "opietooth/find" ); |
85 | 87 | ||
86 | QPalette pal = this->palette(); | 88 | QPalette pal = this->palette(); |
87 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); | 89 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); |
88 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); | 90 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); |
89 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); | 91 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); |
90 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); | 92 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); |
91 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); | 93 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); |
92 | this->setPalette( pal ); | 94 | this->setPalette( pal ); |
93 | 95 | ||
94 | setCaption( tr( "Bluetooth Manager" ) ); | 96 | setCaption( tr( "Bluetooth Manager" ) ); |
95 | 97 | ||
96 | readConfig(); | 98 | readConfig(); |
97 | initGui(); | 99 | initGui(); |
98 | 100 | ||
99 | ListView2->setRootIsDecorated(true); | 101 | ListView2->setRootIsDecorated(true); |
100 | 102 | ||
103 | |||
101 | writeToHciConfig(); | 104 | writeToHciConfig(); |
102 | // search conncetions | 105 | // search conncetions |
103 | addConnectedDevices(); | 106 | addConnectedDevices(); |
107 | addSignalStrength(); | ||
104 | m_iconLoader = new BTIconLoader(); | 108 | m_iconLoader = new BTIconLoader(); |
105 | readSavedDevices(); | 109 | readSavedDevices(); |
106 | } | 110 | } |
107 | 111 | ||
108 | /** | 112 | /** |
109 | * Reads all options from the config file | 113 | * Reads all options from the config file |
110 | */ | 114 | */ |
111 | void BlueBase::readConfig() { | 115 | void BlueBase::readConfig() { |
112 | 116 | ||
113 | Config cfg( "bluetoothmanager" ); | 117 | Config cfg( "bluetoothmanager" ); |
114 | cfg.setGroup( "bluezsettings" ); | 118 | cfg.setGroup( "bluezsettings" ); |
115 | 119 | ||
116 | m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with | 120 | m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with |
117 | m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak | 121 | m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak |
118 | m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); | 122 | m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); |
119 | m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); | 123 | m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); |
120 | m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); | 124 | m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); |
121 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); | 125 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); |
122 | } | 126 | } |
123 | 127 | ||
124 | /** | 128 | /** |
125 | * Writes all options to the config file | 129 | * Writes all options to the config file |
126 | */ | 130 | */ |
127 | void BlueBase::writeConfig() { | 131 | void BlueBase::writeConfig() { |
@@ -349,49 +353,50 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin | |||
349 | } else if ( ret == test1 ) { | 353 | } else if ( ret == test1 ) { |
350 | ; | 354 | ; |
351 | } | 355 | } |
352 | delete popup; | 356 | delete popup; |
353 | } | 357 | } |
354 | delete menu; | 358 | delete menu; |
355 | } | 359 | } |
356 | 360 | ||
357 | 361 | ||
358 | /** | 362 | /** |
359 | * Search and display avail. services for a device (on expand from device listing) | 363 | * Search and display avail. services for a device (on expand from device listing) |
360 | * @param item the service item returned | 364 | * @param item the service item returned |
361 | */ | 365 | */ |
362 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { | 366 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { |
363 | qDebug("addServicesToDevice"); | 367 | qDebug("addServicesToDevice"); |
364 | // row of mac adress text(3) | 368 | // row of mac adress text(3) |
365 | RemoteDevice device = item->remoteDevice(); | 369 | RemoteDevice device = item->remoteDevice(); |
366 | m_deviceList.insert( item->mac() , item ); | 370 | m_deviceList.insert( item->mac() , item ); |
367 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 371 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
368 | m_localDevice->searchServices( device ); | 372 | m_localDevice->searchServices( device ); |
369 | } | 373 | } |
370 | 374 | ||
371 | 375 | ||
372 | /** | 376 | /** |
373 | * Overloaded. This one it the one that is connected to the foundServices signal | 377 | * Overloaded. This one it the one that is |
378 | ted to the foundServices signal | ||
374 | * @param device the mac address of the remote device | 379 | * @param device the mac address of the remote device |
375 | * @param servicesList the list with the service the device has. | 380 | * @param servicesList the list with the service the device has. |
376 | */ | 381 | */ |
377 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 382 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { |
378 | qDebug("fill services list"); | 383 | qDebug("fill services list"); |
379 | 384 | ||
380 | QMap<QString,BTDeviceItem*>::Iterator it; | 385 | QMap<QString,BTDeviceItem*>::Iterator it; |
381 | BTDeviceItem* deviceItem = 0; | 386 | BTDeviceItem* deviceItem = 0; |
382 | 387 | ||
383 | // get the right devices which requested the search | 388 | // get the right devices which requested the search |
384 | it = m_deviceList.find( device ); | 389 | it = m_deviceList.find( device ); |
385 | if( it == m_deviceList.end() ) | 390 | if( it == m_deviceList.end() ) |
386 | return; | 391 | return; |
387 | deviceItem = it.data(); | 392 | deviceItem = it.data(); |
388 | 393 | ||
389 | // remove previous entries | 394 | // remove previous entries |
390 | QList<QListViewItem> tempList; | 395 | QList<QListViewItem> tempList; |
391 | tempList.setAutoDelete( true ); | 396 | tempList.setAutoDelete( true ); |
392 | QListViewItem * child = deviceItem->firstChild(); | 397 | QListViewItem * child = deviceItem->firstChild(); |
393 | while( child ) { | 398 | while( child ) { |
394 | tempList.append( child ); | 399 | tempList.append( child ); |
395 | child = child->nextSibling(); | 400 | child = child->nextSibling(); |
396 | } | 401 | } |
397 | tempList.clear(); | 402 | tempList.clear(); |
@@ -404,74 +409,101 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s | |||
404 | // add services | 409 | // add services |
405 | QMap<int, QString> list; | 410 | QMap<int, QString> list; |
406 | QMap<int, QString>::Iterator classIt; | 411 | QMap<int, QString>::Iterator classIt; |
407 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { | 412 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { |
408 | serviceItem = new BTServiceItem( deviceItem, (*it2) ); | 413 | serviceItem = new BTServiceItem( deviceItem, (*it2) ); |
409 | list = (*it2).classIdList(); | 414 | list = (*it2).classIdList(); |
410 | classIt = list.begin(); | 415 | classIt = list.begin(); |
411 | int classId=0; | 416 | int classId=0; |
412 | if ( classIt != list.end() ) { | 417 | if ( classIt != list.end() ) { |
413 | classId = classIt.key(); | 418 | classId = classIt.key(); |
414 | } | 419 | } |
415 | 420 | ||
416 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); | 421 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); |
417 | } | 422 | } |
418 | } else { | 423 | } else { |
419 | Services s1; | 424 | Services s1; |
420 | s1.setServiceName( tr("no services found") ); | 425 | s1.setServiceName( tr("no services found") ); |
421 | serviceItem = new BTServiceItem( deviceItem, s1 ); | 426 | serviceItem = new BTServiceItem( deviceItem, s1 ); |
422 | } | 427 | } |
423 | // now remove them from the list | 428 | // now remove them from the list |
424 | m_deviceList.remove( it ); | 429 | m_deviceList.remove( it ); |
425 | } | 430 | } |
426 | 431 | ||
427 | 432 | ||
433 | |||
434 | |||
435 | |||
436 | void BlueBase::addSignalStrength() { | ||
437 | |||
438 | QListViewItemIterator it( ListView4 ); | ||
439 | for ( ; it.current(); ++it ) { | ||
440 | m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() ); | ||
441 | } | ||
442 | |||
443 | QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); | ||
444 | } | ||
445 | |||
446 | void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) { | ||
447 | |||
448 | QListViewItemIterator it( ListView4 ); | ||
449 | for ( ; it.current(); ++it ) { | ||
450 | if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) { | ||
451 | ((BTConnectionItem*)it.current() )->setSignalStrength( strength ); | ||
452 | } | ||
453 | } | ||
454 | } | ||
455 | |||
428 | /** | 456 | /** |
429 | * Add the existing connections (pairs) to the connections tab. | 457 | * Add the existing connections (pairs) to the connections tab. |
430 | * This one triggers the search | 458 | * This one triggers the search |
431 | */ | 459 | */ |
432 | void BlueBase::addConnectedDevices() { | 460 | void BlueBase::addConnectedDevices() { |
433 | m_localDevice->searchConnections(); | 461 | m_localDevice->searchConnections(); |
434 | } | 462 | } |
435 | 463 | ||
436 | |||
437 | /** | 464 | /** |
438 | * This adds the found connections to the connection tab. | 465 | * This adds the found connections to the connection tab. |
439 | * @param connectionList the ValueList with all current connections | 466 | * @param connectionList the ValueList with all current connections |
440 | */ | 467 | */ |
441 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { | 468 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { |
442 | 469 | ||
443 | // clear the ListView first | 470 | // clear the ListView first |
444 | ListView4->clear(); | 471 | ListView4->clear(); |
445 | 472 | ||
446 | QValueList<OpieTooth::ConnectionState>::Iterator it; | 473 | QValueList<OpieTooth::ConnectionState>::Iterator it; |
447 | BTConnectionItem * connectionItem; | 474 | BTConnectionItem * connectionItem; |
448 | 475 | ||
449 | if ( !connectionList.isEmpty() ) { | 476 | if ( !connectionList.isEmpty() ) { |
450 | 477 | ||
451 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | 478 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { |
452 | connectionItem = new BTConnectionItem( ListView4 , (*it) ); | 479 | connectionItem = new BTConnectionItem( ListView4, (*it) ); |
453 | } | 480 | |
481 | if( m_deviceList.find((*it).mac()).data() ) { | ||
482 | |||
483 | connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); | ||
484 | } | ||
485 | } | ||
454 | } else { | 486 | } else { |
455 | ConnectionState con; | 487 | ConnectionState con; |
456 | con.setMac( tr("No connections found") ); | 488 | con.setMac( tr("No connections found") ); |
457 | connectionItem = new BTConnectionItem( ListView4 , con ); | 489 | connectionItem = new BTConnectionItem( ListView4 , con ); |
458 | } | 490 | } |
459 | 491 | ||
460 | // recall connection search after some time | 492 | // recall connection search after some time |
461 | QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) ); | 493 | QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) ); |
462 | } | 494 | } |
463 | 495 | ||
464 | 496 | ||
465 | /** | 497 | /** |
466 | * Find out if a device can currently be reached | 498 | * Find out if a device can currently be reached |
467 | * @param device | 499 | * @param device |
468 | */ | 500 | */ |
469 | void BlueBase::deviceActive( const RemoteDevice &device ) { | 501 | void BlueBase::deviceActive( const RemoteDevice &device ) { |
470 | // search by mac, async, gets a signal back | 502 | // search by mac, async, gets a signal back |
471 | // We should have a BTDeviceItem there or where does it get added to the map -zecke | 503 | // We should have a BTDeviceItem there or where does it get added to the map -zecke |
472 | m_localDevice->isAvailable( device.mac() ); | 504 | m_localDevice->isAvailable( device.mac() ); |
473 | } | 505 | } |
474 | 506 | ||
475 | 507 | ||
476 | /** | 508 | /** |
477 | * The signal catcher. Set the avail. status on device. | 509 | * The signal catcher. Set the avail. status on device. |
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index 0326daf..743062c 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h | |||
@@ -1,92 +1,97 @@ | |||
1 | 1 | ||
2 | #ifndef BLUEBASE_H | 2 | #ifndef BLUEBASE_H |
3 | #define BLUEBASE_H | 3 | #define BLUEBASE_H |
4 | 4 | ||
5 | #include <qvariant.h> | 5 | #include <qvariant.h> |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #include <qscrollview.h> | 7 | #include <qscrollview.h> |
8 | #include <qsplitter.h> | 8 | #include <qsplitter.h> |
9 | #include <qlist.h> | 9 | #include <qlist.h> |
10 | #include <qpixmap.h> | 10 | #include <qpixmap.h> |
11 | 11 | ||
12 | #include "bluetoothbase.h" | 12 | #include "bluetoothbase.h" |
13 | 13 | ||
14 | #include "btserviceitem.h" | 14 | #include "btserviceitem.h" |
15 | #include "btdeviceitem.h" | 15 | #include "btdeviceitem.h" |
16 | |||
16 | #include "popuphelper.h" | 17 | #include "popuphelper.h" |
17 | 18 | ||
18 | #include "bticonloader.h" | 19 | #include "bticonloader.h" |
19 | 20 | ||
20 | #include <remotedevice.h> | 21 | #include <remotedevice.h> |
21 | #include <manager.h> | 22 | #include <manager.h> |
22 | 23 | ||
23 | class QVBox; | 24 | class QVBox; |
24 | class QHBoxLayout; | 25 | class QHBoxLayout; |
25 | class QGridLayout; | 26 | class QGridLayout; |
26 | class QFrame; | 27 | class QFrame; |
27 | class QLabel; | 28 | class QLabel; |
28 | class QPushButton; | 29 | class QPushButton; |
29 | class QTabWidget; | 30 | class QTabWidget; |
30 | class QCheckBox; | 31 | class QCheckBox; |
32 | class BTConnectionItem; | ||
31 | 33 | ||
32 | 34 | ||
33 | namespace OpieTooth { | 35 | namespace OpieTooth { |
34 | 36 | ||
35 | class BlueBase : public BluetoothBase { | 37 | class BlueBase : public BluetoothBase { |
36 | Q_OBJECT | 38 | Q_OBJECT |
37 | 39 | ||
38 | public: | 40 | public: |
39 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 41 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
40 | ~BlueBase(); | 42 | ~BlueBase(); |
41 | 43 | ||
42 | protected: | 44 | protected: |
43 | 45 | ||
44 | 46 | ||
45 | private slots: | 47 | private slots: |
46 | void startScan(); | 48 | void startScan(); |
47 | 49 | ||
48 | private: | 50 | private: |
49 | bool find( const RemoteDevice& device ); | 51 | bool find( const RemoteDevice& device ); |
50 | void readConfig(); | 52 | void readConfig(); |
51 | void writeConfig(); | 53 | void writeConfig(); |
52 | void readSavedDevices(); | 54 | void readSavedDevices(); |
53 | void writeSavedDevices(); | 55 | void writeSavedDevices(); |
54 | void writeToHciConfig(); | 56 | void writeToHciConfig(); |
55 | QString status()const; | 57 | QString status()const; |
56 | void initGui(); | 58 | void initGui(); |
57 | void setInfo(); | 59 | void setInfo(); |
60 | |||
58 | PopupHelper m_popHelper; | 61 | PopupHelper m_popHelper; |
59 | Manager *m_localDevice; | 62 | Manager *m_localDevice; |
60 | QMap<QString,BTDeviceItem*> m_deviceList; | 63 | QMap<QString,BTDeviceItem*> m_deviceList; |
61 | 64 | ||
62 | void deviceActive( const RemoteDevice &device ); | 65 | void deviceActive( const RemoteDevice &device ); |
63 | 66 | ||
64 | QString m_deviceName; | 67 | QString m_deviceName; |
65 | QString m_defaultPasskey; | 68 | QString m_defaultPasskey; |
66 | bool m_useEncryption; | 69 | bool m_useEncryption; |
67 | bool m_enableAuthentification; | 70 | bool m_enableAuthentification; |
68 | bool m_enablePagescan; | 71 | bool m_enablePagescan; |
69 | bool m_enableInquiryscan; | 72 | bool m_enableInquiryscan; |
70 | 73 | ||
71 | QPixmap m_offPix; | 74 | QPixmap m_offPix; |
72 | QPixmap m_onPix; | 75 | QPixmap m_onPix; |
73 | QPixmap m_findPix; | 76 | QPixmap m_findPix; |
74 | 77 | ||
75 | BTIconLoader *m_iconLoader; | 78 | BTIconLoader *m_iconLoader; |
76 | 79 | ||
77 | private slots: | 80 | private slots: |
78 | void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); | 81 | void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); |
79 | void addServicesToDevice( BTDeviceItem *item ); | 82 | void addServicesToDevice( BTDeviceItem *item ); |
80 | void addServicesToDevice( const QString& device, Services::ValueList ); | 83 | void addServicesToDevice( const QString& device, Services::ValueList ); |
81 | void addConnectedDevices(); | 84 | void addConnectedDevices(); |
82 | void addConnectedDevices( ConnectionState::ValueList ); | 85 | void addConnectedDevices( ConnectionState::ValueList ); |
83 | void startServiceActionClicked( QListViewItem *item ); | 86 | void startServiceActionClicked( QListViewItem *item ); |
84 | void startServiceActionHold( QListViewItem *, const QPoint &, int ); | 87 | void startServiceActionHold( QListViewItem *, const QPoint &, int ); |
85 | void deviceActive( const QString& mac, bool connected ); | 88 | void deviceActive( const QString& mac, bool connected ); |
86 | void applyConfigChanges(); | 89 | void applyConfigChanges(); |
90 | void addSignalStrength(); | ||
91 | void addSignalStrength( const QString& mac, const QString& strengh ); | ||
87 | 92 | ||
88 | }; | 93 | }; |
89 | 94 | ||
90 | } | 95 | } |
91 | 96 | ||
92 | #endif | 97 | #endif |
diff --git a/noncore/net/opietooth/manager/bluetoothbase.ui b/noncore/net/opietooth/manager/bluetoothbase.ui index 869a9cb..b51c8c6 100644 --- a/noncore/net/opietooth/manager/bluetoothbase.ui +++ b/noncore/net/opietooth/manager/bluetoothbase.ui | |||
@@ -177,48 +177,62 @@ | |||
177 | </property> | 177 | </property> |
178 | <property> | 178 | <property> |
179 | <name>clickable</name> | 179 | <name>clickable</name> |
180 | <bool>true</bool> | 180 | <bool>true</bool> |
181 | </property> | 181 | </property> |
182 | <property> | 182 | <property> |
183 | <name>resizeable</name> | 183 | <name>resizeable</name> |
184 | <bool>true</bool> | 184 | <bool>true</bool> |
185 | </property> | 185 | </property> |
186 | </column> | 186 | </column> |
187 | <column> | 187 | <column> |
188 | <property> | 188 | <property> |
189 | <name>text</name> | 189 | <name>text</name> |
190 | <string>Connection type</string> | 190 | <string>Connection type</string> |
191 | </property> | 191 | </property> |
192 | <property> | 192 | <property> |
193 | <name>clickable</name> | 193 | <name>clickable</name> |
194 | <bool>true</bool> | 194 | <bool>true</bool> |
195 | </property> | 195 | </property> |
196 | <property> | 196 | <property> |
197 | <name>resizeable</name> | 197 | <name>resizeable</name> |
198 | <bool>true</bool> | 198 | <bool>true</bool> |
199 | </property> | 199 | </property> |
200 | </column> | 200 | </column> |
201 | <column> | ||
202 | <property> | ||
203 | <name>text</name> | ||
204 | <string>Signal</string> | ||
205 | </property> | ||
206 | <property> | ||
207 | <name>clickable</name> | ||
208 | <bool>true</bool> | ||
209 | </property> | ||
210 | <property> | ||
211 | <name>resizeable</name> | ||
212 | <bool>true</bool> | ||
213 | </property> | ||
214 | </column> | ||
201 | <property stdset="1"> | 215 | <property stdset="1"> |
202 | <name>name</name> | 216 | <name>name</name> |
203 | <cstring>ListView4</cstring> | 217 | <cstring>ListView4</cstring> |
204 | </property> | 218 | </property> |
205 | <property stdset="1"> | 219 | <property stdset="1"> |
206 | <name>geometry</name> | 220 | <name>geometry</name> |
207 | <rect> | 221 | <rect> |
208 | <x>0</x> | 222 | <x>0</x> |
209 | <y>0</y> | 223 | <y>0</y> |
210 | <width>240</width> | 224 | <width>240</width> |
211 | <height>240</height> | 225 | <height>240</height> |
212 | </rect> | 226 | </rect> |
213 | </property> | 227 | </property> |
214 | </widget> | 228 | </widget> |
215 | </widget> | 229 | </widget> |
216 | <widget> | 230 | <widget> |
217 | <class>QWidget</class> | 231 | <class>QWidget</class> |
218 | <property stdset="1"> | 232 | <property stdset="1"> |
219 | <name>name</name> | 233 | <name>name</name> |
220 | <cstring>tab</cstring> | 234 | <cstring>tab</cstring> |
221 | </property> | 235 | </property> |
222 | <attribute> | 236 | <attribute> |
223 | <name>title</name> | 237 | <name>title</name> |
224 | <string>Config</string> | 238 | <string>Config</string> |
diff --git a/noncore/net/opietooth/manager/btconnectionitem.cpp b/noncore/net/opietooth/manager/btconnectionitem.cpp index b57d1b3..c565c47 100644 --- a/noncore/net/opietooth/manager/btconnectionitem.cpp +++ b/noncore/net/opietooth/manager/btconnectionitem.cpp | |||
@@ -1,24 +1,42 @@ | |||
1 | #include <connection.h> | 1 | #include <connection.h> |
2 | #include "btconnectionitem.h" | 2 | #include "btconnectionitem.h" |
3 | 3 | ||
4 | using namespace OpieTooth; | 4 | using namespace OpieTooth; |
5 | 5 | ||
6 | BTConnectionItem::BTConnectionItem( QListView* parent, const ConnectionState& con ) | 6 | BTConnectionItem::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 | setText(1, m_con.connectionMode() ); |
11 | } | 11 | } |
12 | BTConnectionItem::~BTConnectionItem() { | 12 | BTConnectionItem::~BTConnectionItem() { |
13 | 13 | ||
14 | } | 14 | } |
15 | QString BTConnectionItem::type() const { | 15 | QString BTConnectionItem::type() const { |
16 | return QString::fromLatin1("connection"); | 16 | return QString::fromLatin1("connection"); |
17 | } | 17 | } |
18 | int BTConnectionItem::typeId() const { | 18 | int BTConnectionItem::typeId() const { |
19 | return Connection; | 19 | return Connection; |
20 | } | 20 | } |
21 | ConnectionState BTConnectionItem::connection() const { | 21 | ConnectionState BTConnectionItem::connection() const { |
22 | return m_con; | 22 | return m_con; |
23 | } | 23 | } |
24 | 24 | ||
25 | void BTConnectionItem::setName( QString name ) { | ||
26 | m_name = name; | ||
27 | setText( 0, m_name ); | ||
28 | } | ||
29 | |||
30 | QString BTConnectionItem::name() { | ||
31 | return m_name; | ||
32 | } | ||
33 | |||
34 | |||
35 | void BTConnectionItem::setSignalStrength( QString strength ) { | ||
36 | m_signalStrength = strength; | ||
37 | setText( 2, m_signalStrength ); | ||
38 | } | ||
39 | |||
40 | QString BTConnectionItem::signalStrength() { | ||
41 | return m_signalStrength; | ||
42 | } | ||
diff --git a/noncore/net/opietooth/manager/btconnectionitem.h b/noncore/net/opietooth/manager/btconnectionitem.h index 3c0cd79..9ab745e 100644 --- a/noncore/net/opietooth/manager/btconnectionitem.h +++ b/noncore/net/opietooth/manager/btconnectionitem.h | |||
@@ -1,26 +1,32 @@ | |||
1 | 1 | ||
2 | #ifndef OPIE_TOOTH_BT_CONNECTION_ITEM_H | 2 | #ifndef OPIE_TOOTH_BT_CONNECTION_ITEM_H |
3 | #define OPIE_TOOTH_BT_CONNECTION_ITEM_H | 3 | #define OPIE_TOOTH_BT_CONNECTION_ITEM_H |
4 | 4 | ||
5 | 5 | ||
6 | #include "btlistitem.h" | 6 | #include "btlistitem.h" |
7 | 7 | ||
8 | namespace OpieTooth { | 8 | namespace OpieTooth { |
9 | 9 | ||
10 | class ConnectionState; | 10 | class ConnectionState; |
11 | class BTConnectionItem : public BTListItem { | 11 | class BTConnectionItem : public BTListItem { |
12 | public: | 12 | public: |
13 | BTConnectionItem( QListView* parent, const ConnectionState& state ); | 13 | BTConnectionItem( QListView* parent, const ConnectionState& state ); |
14 | ~BTConnectionItem(); | 14 | ~BTConnectionItem(); |
15 | QString type()const; | 15 | QString type()const; |
16 | QString name(); | ||
17 | QString signalStrength(); | ||
16 | int typeId() const; | 18 | int typeId() const; |
17 | ConnectionState connection()const; | 19 | ConnectionState connection()const; |
20 | void setSignalStrength( QString ); | ||
21 | void setName( QString ); | ||
22 | |||
18 | private: | 23 | private: |
19 | ConnectionState m_con; | 24 | ConnectionState m_con; |
20 | 25 | QString m_name; | |
26 | QString m_signalStrength; | ||
21 | }; | 27 | }; |
22 | 28 | ||
23 | }; | 29 | }; |
24 | 30 | ||
25 | 31 | ||
26 | #endif | 32 | #endif |