-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 598ce16..d2854a1 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -98,127 +98,127 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | |||
98 | s1.setServiceName( "Serial" ); | 98 | s1.setServiceName( "Serial" ); |
99 | s1.insertClassId(1, "BlueNic"); | 99 | s1.insertClassId(1, "BlueNic"); |
100 | (void) new BTServiceItem( topLV2, s1 ); | 100 | (void) new BTServiceItem( topLV2, s1 ); |
101 | s1.setServiceName( "BlueNic" ); | 101 | s1.setServiceName( "BlueNic" ); |
102 | s1.insertClassId(2, "Obex"); | 102 | s1.insertClassId(2, "Obex"); |
103 | (void) new BTServiceItem( topLV2, s1 ); | 103 | (void) new BTServiceItem( topLV2, s1 ); |
104 | 104 | ||
105 | writeToHciConfig(); | 105 | writeToHciConfig(); |
106 | // search conncetions | 106 | // search conncetions |
107 | addConnectedDevices(); | 107 | addConnectedDevices(); |
108 | m_iconLoader = new BTIconLoader(); | 108 | m_iconLoader = new BTIconLoader(); |
109 | readSavedDevices(); | 109 | readSavedDevices(); |
110 | } | 110 | } |
111 | 111 | ||
112 | /** | 112 | /** |
113 | * Reads all options from the config file | 113 | * Reads all options from the config file |
114 | */ | 114 | */ |
115 | void BlueBase::readConfig() { | 115 | void BlueBase::readConfig() { |
116 | 116 | ||
117 | Config cfg( "bluetoothmanager" ); | 117 | Config cfg( "bluetoothmanager" ); |
118 | cfg.setGroup( "bluezsettings" ); | 118 | cfg.setGroup( "bluezsettings" ); |
119 | 119 | ||
120 | 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 |
121 | 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 |
122 | m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); | 122 | m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); |
123 | m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); | 123 | m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); |
124 | m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); | 124 | m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); |
125 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); | 125 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); |
126 | } | 126 | } |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * Writes all options to the config file | 129 | * Writes all options to the config file |
130 | */ | 130 | */ |
131 | void BlueBase::writeConfig() { | 131 | void BlueBase::writeConfig() { |
132 | 132 | ||
133 | Config cfg( "bluetoothmanager" ); | 133 | Config cfg( "bluetoothmanager" ); |
134 | cfg.setGroup( "bluezsettings" ); | 134 | cfg.setGroup( "bluezsettings" ); |
135 | 135 | ||
136 | cfg.writeEntry( "name" , m_deviceName ); | 136 | cfg.writeEntry( "name" , m_deviceName ); |
137 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); | 137 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); |
138 | cfg.writeEntry( "useEncryption" , m_useEncryption ); | 138 | cfg.writeEntry( "useEncryption" , m_useEncryption ); |
139 | cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); | 139 | cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); |
140 | cfg.writeEntry( "enablePagescan" , m_enablePagescan ); | 140 | cfg.writeEntry( "enablePagescan" , m_enablePagescan ); |
141 | cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); | 141 | cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); |
142 | 142 | ||
143 | writeToHciConfig(); | 143 | writeToHciConfig(); |
144 | } | 144 | } |
145 | 145 | ||
146 | /** | ||
147 | * Modify the hcid.conf file to our needs | ||
148 | */ | ||
146 | void BlueBase::writeToHciConfig() { | 149 | void BlueBase::writeToHciConfig() { |
147 | qWarning("writeToHciConfig"); | 150 | qWarning("writeToHciConfig"); |
148 | HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); | 151 | HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); |
149 | hciconf.load(); | 152 | hciconf.load(); |
150 | hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | 153 | hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); |
151 | |||
152 | |||
153 | // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | ||
154 | |||
155 | hciconf.setName( m_deviceName ); | 154 | hciconf.setName( m_deviceName ); |
156 | hciconf.setEncrypt( m_useEncryption ); | 155 | hciconf.setEncrypt( m_useEncryption ); |
157 | hciconf.setAuth( m_enableAuthentification ); | 156 | hciconf.setAuth( m_enableAuthentification ); |
158 | hciconf.setPscan( m_enablePagescan ); | 157 | hciconf.setPscan( m_enablePagescan ); |
159 | hciconf.setIscan( m_enableInquiryscan ); | 158 | hciconf.setIscan( m_enableInquiryscan ); |
160 | hciconf.save(); | 159 | hciconf.save(); |
161 | } | 160 | } |
162 | 161 | ||
163 | 162 | ||
164 | /** | 163 | /** |
165 | * Read the list of allready known devices | 164 | * Read the list of allready known devices |
166 | * | 165 | * |
167 | */ | 166 | */ |
168 | void BlueBase::readSavedDevices() { | 167 | void BlueBase::readSavedDevices() { |
169 | 168 | ||
170 | QValueList<RemoteDevice> loadedDevices; | 169 | QValueList<RemoteDevice> loadedDevices; |
171 | DeviceHandler handler; | 170 | DeviceHandler handler; |
172 | loadedDevices = handler.load(); | 171 | loadedDevices = handler.load(); |
173 | 172 | ||
174 | addSearchedDevices( loadedDevices ); | 173 | addSearchedDevices( loadedDevices ); |
175 | } | 174 | } |
176 | 175 | ||
176 | |||
177 | /** | 177 | /** |
178 | * Write the list of allready known devices | 178 | * Write the list of allready known devices |
179 | * | 179 | * |
180 | */ | 180 | */ |
181 | void BlueBase::writeSavedDevices() { | 181 | void BlueBase::writeSavedDevices() { |
182 | QListViewItemIterator it( ListView2 ); | 182 | QListViewItemIterator it( ListView2 ); |
183 | BTListItem* item; | 183 | BTListItem* item; |
184 | BTDeviceItem* device; | 184 | BTDeviceItem* device; |
185 | RemoteDevice::ValueList list; | 185 | RemoteDevice::ValueList list; |
186 | for ( ; it.current(); ++it ) { | 186 | for ( ; it.current(); ++it ) { |
187 | item = (BTListItem*)it.current(); | 187 | item = (BTListItem*)it.current(); |
188 | if(item->typeId() != BTListItem::Device ) | 188 | if(item->typeId() != BTListItem::Device ) |
189 | continue; | 189 | continue; |
190 | device = (BTDeviceItem*)item; | 190 | device = (BTDeviceItem*)item; |
191 | 191 | ||
192 | list.append( device->remoteDevice() ); | 192 | list.append( device->remoteDevice() ); |
193 | } | 193 | } |
194 | /* | 194 | /* |
195 | * if not empty save the List through DeviceHandler | 195 | * if not empty save the List through DeviceHandler |
196 | */ | 196 | */ |
197 | if ( list.isEmpty() ) | 197 | if ( list.isEmpty() ) |
198 | return; | 198 | return; |
199 | DeviceHandler handler; | 199 | DeviceHandler handler; |
200 | handler.save( list ); | 200 | handler.save( list ); |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | /** | 204 | /** |
205 | * Set up the gui | 205 | * Set up the gui |
206 | */ | 206 | */ |
207 | void BlueBase::initGui() { | 207 | void BlueBase::initGui() { |
208 | StatusLabel->setText( status() ); // maybe move it to getStatus() | 208 | StatusLabel->setText( status() ); // maybe move it to getStatus() |
209 | cryptCheckBox->setChecked( m_useEncryption ); | 209 | cryptCheckBox->setChecked( m_useEncryption ); |
210 | authCheckBox->setChecked( m_enableAuthentification ); | 210 | authCheckBox->setChecked( m_enableAuthentification ); |
211 | pagescanCheckBox->setChecked( m_enablePagescan ); | 211 | pagescanCheckBox->setChecked( m_enablePagescan ); |
212 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); | 212 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); |
213 | deviceNameLine->setText( m_deviceName ); | 213 | deviceNameLine->setText( m_deviceName ); |
214 | passkeyLine->setText( m_defaultPasskey ); | 214 | passkeyLine->setText( m_defaultPasskey ); |
215 | // set info tab | 215 | // set info tab |
216 | setInfo(); | 216 | setInfo(); |
217 | } | 217 | } |
218 | 218 | ||
219 | 219 | ||
220 | /** | 220 | /** |
221 | * Get the status informations and returns it | 221 | * Get the status informations and returns it |
222 | * @return QString the status informations gathered | 222 | * @return QString the status informations gathered |
223 | */ | 223 | */ |
224 | QString BlueBase::status()const{ | 224 | QString BlueBase::status()const{ |
@@ -232,303 +232,320 @@ QString BlueBase::status()const{ | |||
232 | 232 | ||
233 | /** | 233 | /** |
234 | * Read the current values from the gui and invoke writeConfig() | 234 | * Read the current values from the gui and invoke writeConfig() |
235 | */ | 235 | */ |
236 | void BlueBase::applyConfigChanges() { | 236 | void BlueBase::applyConfigChanges() { |
237 | m_deviceName = deviceNameLine->text(); | 237 | m_deviceName = deviceNameLine->text(); |
238 | m_defaultPasskey = passkeyLine->text(); | 238 | m_defaultPasskey = passkeyLine->text(); |
239 | m_useEncryption = cryptCheckBox->isChecked(); | 239 | m_useEncryption = cryptCheckBox->isChecked(); |
240 | m_enableAuthentification = authCheckBox->isChecked(); | 240 | m_enableAuthentification = authCheckBox->isChecked(); |
241 | m_enablePagescan = pagescanCheckBox->isChecked(); | 241 | m_enablePagescan = pagescanCheckBox->isChecked(); |
242 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); | 242 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); |
243 | 243 | ||
244 | writeConfig(); | 244 | writeConfig(); |
245 | 245 | ||
246 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); | 246 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); |
247 | } | 247 | } |
248 | 248 | ||
249 | /** | 249 | /** |
250 | * Add fresh found devices from scan dialog to the listing | 250 | * Add fresh found devices from scan dialog to the listing |
251 | * | 251 | * |
252 | */ | 252 | */ |
253 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { | 253 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { |
254 | BTDeviceItem * deviceItem; | 254 | BTDeviceItem * deviceItem; |
255 | QValueList<RemoteDevice>::ConstIterator it; | 255 | QValueList<RemoteDevice>::ConstIterator it; |
256 | 256 | ||
257 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { | 257 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { |
258 | 258 | ||
259 | if (find( (*it) )) // is already inserted | 259 | if (find( (*it) )) // is already inserted |
260 | continue; | 260 | continue; |
261 | 261 | ||
262 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); | 262 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); |
263 | deviceItem->setExpandable ( true ); | 263 | deviceItem->setExpandable ( true ); |
264 | 264 | ||
265 | // look if device is avail. atm, async | 265 | // look if device is avail. atm, async |
266 | deviceActive( (*it) ); | 266 | deviceActive( (*it) ); |
267 | 267 | ||
268 | // ggf auch hier? | 268 | // ggf auch hier? |
269 | addServicesToDevice( deviceItem ); | 269 | addServicesToDevice( deviceItem ); |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | 273 | ||
274 | /** | 274 | /** |
275 | * Action that is toggled on entrys on click | 275 | * Action that is toggled on entrys on click |
276 | */ | 276 | */ |
277 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { | 277 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { |
278 | } | 278 | } |
279 | 279 | ||
280 | |||
280 | /** | 281 | /** |
281 | * Action that are toggled on hold (mostly QPopups i guess) | 282 | * Action that are toggled on hold (mostly QPopups i guess) |
282 | */ | 283 | */ |
283 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { | 284 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { |
284 | 285 | ||
285 | QPopupMenu *menu = new QPopupMenu(); | 286 | QPopupMenu *menu = new QPopupMenu(); |
286 | int ret=0; | 287 | int ret=0; |
287 | 288 | ||
288 | if ( ((BTListItem*)item)->type() == "device") { | 289 | if ( ((BTListItem*)item)->type() == "device") { |
289 | 290 | ||
290 | QPopupMenu *groups = new QPopupMenu(); | 291 | QPopupMenu *groups = new QPopupMenu(); |
291 | 292 | ||
292 | menu->insertItem( tr("rescan sevices:"), 0); | 293 | menu->insertItem( tr("rescan sevices:"), 0); |
293 | menu->insertItem( tr("to group"), groups , 1); | 294 | menu->insertItem( tr("to group"), groups , 1); |
294 | menu->insertItem( tr("bound device"), 2); | 295 | menu->insertItem( tr("bound device"), 2); |
295 | menu->insertItem( tr("delete"), 3); | 296 | menu->insertItem( tr("delete"), 3); |
296 | 297 | ||
297 | ret = menu->exec( point , 0); | 298 | ret = menu->exec( point , 0); |
298 | 299 | ||
299 | switch(ret) { | 300 | switch(ret) { |
300 | case -1: | 301 | case -1: |
301 | 302 | ||
302 | break; | 303 | break; |
303 | case 1: | 304 | case 1: |
304 | break; | 305 | break; |
305 | case 2: | 306 | case 2: |
306 | // make connection | 307 | // make connection |
307 | break; | 308 | break; |
308 | case 3: | 309 | case 3: |
309 | // delete childs too | 310 | // delete childs too |
310 | delete item; | 311 | delete item; |
311 | break; | 312 | break; |
312 | } | 313 | } |
313 | delete groups; | 314 | delete groups; |
314 | 315 | ||
315 | } | 316 | } |
316 | /** | 317 | |
318 | /* | ||
317 | * We got service sensitive PopupMenus in our factory | 319 | * We got service sensitive PopupMenus in our factory |
318 | * We will create one through the factory and will insert | 320 | * We will create one through the factory and will insert |
319 | * our Separator + ShowInfo into the menu or create a new | 321 | * our Separator + ShowInfo into the menu or create a new |
320 | * one if the factory returns 0 | 322 | * one if the factory returns 0 |
321 | * PopupMenu deletion is kind of weird. | 323 | * PopupMenu deletion is kind of weird. |
322 | * If escaped( -1 ) or any of our items were chosen we'll | 324 | * If escaped( -1 ) or any of our items were chosen we'll |
323 | * delete the PopupMenu otherwise it's the responsibility of | 325 | * delete the PopupMenu otherwise it's the responsibility of |
324 | * the PopupMenu to delete itself | 326 | * the PopupMenu to delete itself |
325 | * | 327 | * |
326 | */ | 328 | */ |
327 | else if ( ((BTListItem*)item)->type() == "service") { | 329 | else if ( ((BTListItem*)item)->type() == "service") { |
328 | BTServiceItem* service = (BTServiceItem*)item; | 330 | BTServiceItem* service = (BTServiceItem*)item; |
329 | QMap<int, QString> list = service->services().classIdList(); | 331 | QMap<int, QString> list = service->services().classIdList(); |
330 | QMap<int, QString>::Iterator it = list.begin(); | 332 | QMap<int, QString>::Iterator it = list.begin(); |
331 | QPopupMenu *popup =0l; | 333 | QPopupMenu *popup =0l; |
332 | if ( it != list.end() ) { | 334 | if ( it != list.end() ) { |
333 | qWarning("Searching id %d %s", it.key(), it.data().latin1() ); | 335 | qWarning("Searching id %d %s", it.key(), it.data().latin1() ); |
334 | popup = m_popHelper.find( it.key(), | 336 | popup = m_popHelper.find( it.key(), |
335 | service->services(), | 337 | service->services(), |
336 | service->parent() ); | 338 | service->parent() ); |
337 | }else { | 339 | }else { |
338 | qWarning("Empty"); | 340 | qWarning("Empty"); |
339 | } | 341 | } |
340 | 342 | ||
341 | if ( popup == 0l ) { | 343 | if ( popup == 0l ) { |
342 | qWarning("factory returned 0l"); | 344 | qWarning("factory returned 0l"); |
343 | popup = new QPopupMenu(); | 345 | popup = new QPopupMenu(); |
344 | } | 346 | } |
345 | 347 | ||
346 | int test1 = popup->insertItem( tr("Test1:"), 0); | 348 | int test1 = popup->insertItem( tr("Test1:"), 0); |
347 | int con = popup->insertItem( tr("connect"), 1); | 349 | int con = popup->insertItem( tr("connect"), 1); |
348 | int del = popup->insertItem( tr("delete"), 2); | 350 | int del = popup->insertItem( tr("delete"), 2); |
349 | 351 | ||
350 | ret = popup->exec( point ); | 352 | ret = popup->exec( point ); |
351 | 353 | ||
352 | if ( ret == -1 ) | 354 | if ( ret == -1 ) |
353 | delete popup; | 355 | delete popup; |
354 | else if ( ret == test1 ) | 356 | else if ( ret == test1 ) |
355 | delete popup; | 357 | delete popup; |
356 | else if ( ret == con ) | 358 | else if ( ret == con ) |
357 | delete popup; | 359 | delete popup; |
358 | else if ( ret == del ) { | 360 | else if ( ret == del ) { |
359 | // take item first? -zecke | 361 | // take item first? -zecke |
360 | delete item; | 362 | delete item; |
361 | } | 363 | } |
362 | } | 364 | } |
363 | delete menu; | 365 | delete menu; |
364 | } | 366 | } |
365 | 367 | ||
366 | /** | 368 | |
367 | * Search and display avail. services for a device (on expand from device listing) | 369 | /** |
368 | * | 370 | * Search and display avail. services for a device (on expand from device listing) |
369 | */ | 371 | * @param item the service item returned |
372 | */ | ||
370 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { | 373 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { |
371 | qDebug("addServicesToDevice"); | 374 | qDebug("addServicesToDevice"); |
372 | // row of mac adress text(3) | 375 | // row of mac adress text(3) |
373 | RemoteDevice device = item->remoteDevice(); | 376 | RemoteDevice device = item->remoteDevice(); |
374 | m_deviceList.insert( item->mac() , item ); | 377 | m_deviceList.insert( item->mac() , item ); |
375 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 378 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
376 | m_localDevice->searchServices( device ); | 379 | m_localDevice->searchServices( device ); |
377 | } | 380 | } |
378 | 381 | ||
379 | 382 | ||
380 | /** | 383 | /** |
381 | * Overloaded. This one it the one that is connected to the foundServices signal | 384 | * Overloaded. This one it the one that is connected to the foundServices signal |
382 | * @param device the mac address of the remote device | 385 | * @param device the mac address of the remote device |
383 | * @param servicesList the list with the service the device has. | 386 | * @param servicesList the list with the service the device has. |
384 | */ | 387 | */ |
385 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 388 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { |
386 | qDebug("fill services list"); | 389 | qDebug("fill services list"); |
387 | 390 | ||
388 | QMap<QString,BTDeviceItem*>::Iterator it; | 391 | QMap<QString,BTDeviceItem*>::Iterator it; |
389 | BTDeviceItem* deviceItem = 0; | 392 | BTDeviceItem* deviceItem = 0; |
390 | 393 | ||
391 | // get the right devices which requested the search | 394 | // get the right devices which requested the search |
392 | it = m_deviceList.find( device ); | 395 | it = m_deviceList.find( device ); |
393 | if( it == m_deviceList.end() ) | 396 | if( it == m_deviceList.end() ) |
394 | return; | 397 | return; |
395 | deviceItem = it.data(); | 398 | deviceItem = it.data(); |
396 | 399 | ||
397 | QValueList<OpieTooth::Services>::Iterator it2; | 400 | QValueList<OpieTooth::Services>::Iterator it2; |
398 | BTServiceItem * serviceItem; | 401 | BTServiceItem * serviceItem; |
399 | 402 | ||
400 | if (!servicesList.isEmpty() ) { | 403 | if (!servicesList.isEmpty() ) { |
401 | // add services | 404 | // add services |
402 | QMap<int, QString> list; | 405 | QMap<int, QString> list; |
403 | QMap<int, QString>::Iterator classIt; | 406 | QMap<int, QString>::Iterator classIt; |
404 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { | 407 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { |
405 | serviceItem = new BTServiceItem( deviceItem , (*it2) ); | 408 | serviceItem = new BTServiceItem( deviceItem , (*it2) ); |
406 | list = (*it2).classIdList(); | 409 | list = (*it2).classIdList(); |
407 | classIt = list.begin(); | 410 | classIt = list.begin(); |
408 | int classId=0; | 411 | int classId=0; |
409 | if ( classIt != list.end() ) | 412 | if ( classIt != list.end() ) |
410 | classId = classIt.key(); | 413 | classId = classIt.key(); |
411 | 414 | ||
412 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); | 415 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); |
413 | } | 416 | } |
414 | } else { | 417 | } else { |
415 | Services s1; | 418 | Services s1; |
416 | s1.setServiceName( tr("no serives found") ); | 419 | s1.setServiceName( tr("no serives found") ); |
417 | serviceItem = new BTServiceItem( deviceItem, s1 ); | 420 | serviceItem = new BTServiceItem( deviceItem, s1 ); |
418 | } | 421 | } |
419 | // now remove them from the list | 422 | // now remove them from the list |
420 | m_deviceList.remove( it ); | 423 | m_deviceList.remove( it ); |
421 | } | 424 | } |
422 | 425 | ||
423 | 426 | ||
424 | /** | 427 | /** |
425 | * Add the existing connections (pairs) to the connections tab. | 428 | * Add the existing connections (pairs) to the connections tab. |
426 | * This one triggers the search | 429 | * This one triggers the search |
427 | */ | 430 | */ |
428 | void BlueBase::addConnectedDevices() { | 431 | void BlueBase::addConnectedDevices() { |
429 | m_localDevice->searchConnections(); | 432 | m_localDevice->searchConnections(); |
430 | } | 433 | } |
431 | 434 | ||
432 | 435 | ||
436 | /** | ||
437 | * This adds the found connections to the connection tab. | ||
438 | * @param connectionList the ValueList with all current connections | ||
439 | */ | ||
433 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { | 440 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { |
441 | |||
442 | // clear the ListView first | ||
443 | ListView4->clear(); | ||
444 | |||
434 | QValueList<OpieTooth::ConnectionState>::Iterator it; | 445 | QValueList<OpieTooth::ConnectionState>::Iterator it; |
435 | BTConnectionItem * connectionItem; | 446 | BTConnectionItem * connectionItem; |
436 | 447 | ||
437 | if ( !connectionList.isEmpty() ) { | 448 | if ( !connectionList.isEmpty() ) { |
438 | 449 | ||
439 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | 450 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { |
440 | connectionItem = new BTConnectionItem( ListView4 , (*it) ); | 451 | connectionItem = new BTConnectionItem( ListView4 , (*it) ); |
441 | } | 452 | } |
442 | } else { | 453 | } else { |
443 | ConnectionState con; | 454 | ConnectionState con; |
444 | con.setMac( tr("No connections found") ); | 455 | con.setMac( tr("No connections found") ); |
445 | connectionItem = new BTConnectionItem( ListView4 , con ); | 456 | connectionItem = new BTConnectionItem( ListView4 , con ); |
446 | } | 457 | } |
447 | 458 | ||
448 | // recall connection search after some time | 459 | // recall connection search after some time |
449 | QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); | 460 | QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); |
450 | } | 461 | } |
451 | 462 | ||
463 | |||
452 | /** | 464 | /** |
453 | * Find out if a device can currently be reached | 465 | * Find out if a device can currently be reached |
466 | * @param device | ||
454 | */ | 467 | */ |
455 | void BlueBase::deviceActive( const RemoteDevice &device ) { | 468 | void BlueBase::deviceActive( const RemoteDevice &device ) { |
456 | // search by mac, async, gets a signal back | 469 | // search by mac, async, gets a signal back |
457 | // We should have a BTDeviceItem there or where does it get added to the map -zecke | 470 | // We should have a BTDeviceItem there or where does it get added to the map -zecke |
458 | m_localDevice->isAvailable( device.mac() ); | 471 | m_localDevice->isAvailable( device.mac() ); |
459 | } | 472 | } |
460 | 473 | ||
474 | |||
461 | /** | 475 | /** |
462 | * The signal catcher. Set the avail. status on device. | 476 | * The signal catcher. Set the avail. status on device. |
463 | * @param device - the mac address | 477 | * @param device - the mac address |
464 | * @param connected - if it is avail. or not | 478 | * @param connected - if it is avail. or not |
465 | */ | 479 | */ |
466 | void BlueBase::deviceActive( const QString& device, bool connected ) { | 480 | void BlueBase::deviceActive( const QString& device, bool connected ) { |
467 | qDebug("deviceActive slot"); | 481 | qDebug("deviceActive slot"); |
468 | 482 | ||
469 | QMap<QString,BTDeviceItem*>::Iterator it; | 483 | QMap<QString,BTDeviceItem*>::Iterator it; |
470 | 484 | ||
471 | it = m_deviceList.find( device ); | 485 | it = m_deviceList.find( device ); |
472 | if( it == m_deviceList.end() ) | 486 | if( it == m_deviceList.end() ) |
473 | return; | 487 | return; |
474 | 488 | ||
475 | BTDeviceItem* deviceItem = it.data(); | 489 | BTDeviceItem* deviceItem = it.data(); |
476 | 490 | ||
477 | 491 | ||
478 | if ( connected ) { | 492 | if ( connected ) { |
479 | deviceItem->setPixmap( 1, m_onPix ); | 493 | deviceItem->setPixmap( 1, m_onPix ); |
480 | } else { | 494 | } else { |
481 | deviceItem->setPixmap( 1, m_offPix ); | 495 | deviceItem->setPixmap( 1, m_offPix ); |
482 | } | 496 | } |
483 | m_deviceList.remove( it ); | 497 | m_deviceList.remove( it ); |
484 | } | 498 | } |
485 | 499 | ||
500 | |||
486 | /** | 501 | /** |
487 | * Open the "scan for devices" dialog | 502 | * Open the "scan for devices" dialog |
488 | */ | 503 | */ |
489 | void BlueBase::startScan() { | 504 | void BlueBase::startScan() { |
490 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", | 505 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", |
491 | true, WDestructiveClose ); | 506 | true, WDestructiveClose ); |
492 | QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), | 507 | QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), |
493 | this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); | 508 | this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); |
494 | 509 | ||
495 | scan->showMaximized(); | 510 | scan->showMaximized(); |
496 | } | 511 | } |
497 | 512 | ||
498 | 513 | ||
499 | /** | 514 | /** |
500 | * Set the informations about the local device in information Tab | 515 | * Set the informations about the local device in information Tab |
501 | */ | 516 | */ |
502 | void BlueBase::setInfo() { | 517 | void BlueBase::setInfo() { |
503 | StatusLabel->setText( status() ); | 518 | StatusLabel->setText( status() ); |
504 | } | 519 | } |
505 | 520 | ||
521 | |||
506 | /** | 522 | /** |
507 | * Decontructor | 523 | * Decontructor |
508 | */ | 524 | */ |
509 | BlueBase::~BlueBase() { | 525 | BlueBase::~BlueBase() { |
510 | writeSavedDevices(); | 526 | writeSavedDevices(); |
511 | delete m_iconLoader; | 527 | delete m_iconLoader; |
512 | } | 528 | } |
513 | 529 | ||
530 | |||
514 | /** | 531 | /** |
515 | * find searches the ListView for a BTDeviceItem containig | 532 | * find searches the ListView for a BTDeviceItem containig |
516 | * the same Device if found return true else false | 533 | * the same Device if found return true else false |
517 | * @param dev RemoteDevice to find | 534 | * @param dev RemoteDevice to find |
518 | * @return returns true if found | 535 | * @return returns true if found |
519 | */ | 536 | */ |
520 | bool BlueBase::find( const RemoteDevice& rem ) { | 537 | bool BlueBase::find( const RemoteDevice& rem ) { |
521 | QListViewItemIterator it( ListView2 ); | 538 | QListViewItemIterator it( ListView2 ); |
522 | BTListItem* item; | 539 | BTListItem* item; |
523 | BTDeviceItem* device; | 540 | BTDeviceItem* device; |
524 | for (; it.current(); ++it ) { | 541 | for (; it.current(); ++it ) { |
525 | item = (BTListItem*) it.current(); | 542 | item = (BTListItem*) it.current(); |
526 | if ( item->typeId() != BTListItem::Device ) | 543 | if ( item->typeId() != BTListItem::Device ) |
527 | continue; | 544 | continue; |
528 | 545 | ||
529 | device = (BTDeviceItem*)item; | 546 | device = (BTDeviceItem*)item; |
530 | if ( rem.equals( device->remoteDevice() ) ) | 547 | if ( rem.equals( device->remoteDevice() ) ) |
531 | return true; | 548 | return true; |
532 | } | 549 | } |
533 | return false; // not found | 550 | return false; // not found |
534 | } | 551 | } |