Diffstat (limited to 'noncore/net/opietooth/manager/bluebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 54808fa..2e68984 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -1,86 +1,89 @@ | |||
1 | /* | 1 | /* |
2 | * bluebase.cpp * | 2 | * bluebase.cpp * |
3 | * --------------------- | 3 | * --------------------- |
4 | * | 4 | * |
5 | * copyright : (c) 2002 by Maximilian Reiß | 5 | * copyright : (c) 2002 by Maximilian Reiß |
6 | * email : max.reiss@gmx.de | 6 | * email : max.reiss@gmx.de |
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include "bluebase.h" | 18 | #include "bluebase.h" |
19 | #include "scandialog.h" | 19 | #include "scandialog.h" |
20 | #include "hciconfwrapper.h" | 20 | #include "hciconfwrapper.h" |
21 | #include "devicehandler.h" | 21 | #include "devicehandler.h" |
22 | #include "btconnectionitem.h" | 22 | #include "btconnectionitem.h" |
23 | #include "rfcommassigndialogimpl.h" | ||
23 | 24 | ||
24 | #include <remotedevice.h> | 25 | #include <remotedevice.h> |
25 | #include <services.h> | 26 | #include <services.h> |
26 | 27 | ||
27 | #include <stdlib.h> | 28 | #include <stdlib.h> |
28 | 29 | ||
29 | #include <qframe.h> | 30 | #include <qframe.h> |
30 | #include <qlabel.h> | 31 | #include <qlabel.h> |
31 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
32 | #include <qlayout.h> | 33 | #include <qlayout.h> |
33 | #include <qvariant.h> | 34 | #include <qvariant.h> |
34 | #include <qimage.h> | 35 | #include <qimage.h> |
35 | #include <qpixmap.h> | 36 | #include <qpixmap.h> |
36 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
37 | #include <qscrollview.h> | 38 | #include <qscrollview.h> |
38 | #include <qvbox.h> | 39 | #include <qvbox.h> |
39 | #include <qmessagebox.h> | 40 | #include <qmessagebox.h> |
40 | #include <qcheckbox.h> | 41 | #include <qcheckbox.h> |
41 | #include <qlineedit.h> | 42 | #include <qlineedit.h> |
42 | #include <qlistview.h> | 43 | #include <qlistview.h> |
43 | #include <qdir.h> | 44 | #include <qdir.h> |
44 | #include <qpopupmenu.h> | 45 | #include <qpopupmenu.h> |
45 | #include <qtimer.h> | 46 | #include <qtimer.h> |
46 | #include <qlist.h> | 47 | #include <qlist.h> |
47 | 48 | ||
48 | #include <qpe/qpeapplication.h> | 49 | #include <qpe/qpeapplication.h> |
49 | #include <qpe/resource.h> | 50 | #include <qpe/resource.h> |
50 | #include <qpe/config.h> | 51 | #include <qpe/config.h> |
51 | 52 | ||
52 | 53 | ||
53 | using namespace OpieTooth; | 54 | using namespace OpieTooth; |
54 | 55 | ||
55 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 56 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
56 | : BluetoothBase( parent, name, fl ) { | 57 | : BluetoothBase( parent, name, fl ) { |
57 | 58 | ||
58 | m_localDevice = new Manager( "hci0" ); | 59 | m_localDevice = new Manager( "hci0" ); |
59 | 60 | ||
60 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 61 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
61 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 62 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
62 | // not good since lib is async | 63 | |
64 | connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) ); | ||
65 | // not good since lib is async | ||
63 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), | 66 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), |
64 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); | 67 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); |
65 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), | 68 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), |
66 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); | 69 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); |
67 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), | 70 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), |
68 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); | 71 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); |
69 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), | 72 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), |
70 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); | 73 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); |
71 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), | 74 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), |
72 | this, SLOT( deviceActive( const QString& , bool ) ) ); | 75 | this, SLOT( deviceActive( const QString& , bool ) ) ); |
73 | connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), | 76 | connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), |
74 | this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); | 77 | this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); |
75 | connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ), | 78 | connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ), |
76 | this, SLOT( addSignalStrength( const QString&, const QString& ) ) ); | 79 | this, SLOT( addSignalStrength( const QString&, const QString& ) ) ); |
77 | 80 | ||
78 | 81 | ||
79 | // let hold be rightButtonClicked() | 82 | // let hold be rightButtonClicked() |
80 | QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); | 83 | QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); |
81 | QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); | 84 | QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); |
82 | 85 | ||
83 | //Load all icons needed | 86 | //Load all icons needed |
84 | m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); | 87 | m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); |
85 | m_onPix = Resource::loadPixmap( "opietooth/connected" ); | 88 | m_onPix = Resource::loadPixmap( "opietooth/connected" ); |
86 | m_findPix = Resource::loadPixmap( "opietooth/find" ); | 89 | m_findPix = Resource::loadPixmap( "opietooth/find" ); |
@@ -201,71 +204,85 @@ void BlueBase::writeSavedDevices() { | |||
201 | 204 | ||
202 | /** | 205 | /** |
203 | * Set up the gui | 206 | * Set up the gui |
204 | */ | 207 | */ |
205 | void BlueBase::initGui() { | 208 | void BlueBase::initGui() { |
206 | StatusLabel->setText( status() ); // maybe move it to getStatus() | 209 | StatusLabel->setText( status() ); // maybe move it to getStatus() |
207 | cryptCheckBox->setChecked( m_useEncryption ); | 210 | cryptCheckBox->setChecked( m_useEncryption ); |
208 | authCheckBox->setChecked( m_enableAuthentification ); | 211 | authCheckBox->setChecked( m_enableAuthentification ); |
209 | pagescanCheckBox->setChecked( m_enablePagescan ); | 212 | pagescanCheckBox->setChecked( m_enablePagescan ); |
210 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); | 213 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); |
211 | deviceNameLine->setText( m_deviceName ); | 214 | deviceNameLine->setText( m_deviceName ); |
212 | passkeyLine->setText( m_defaultPasskey ); | 215 | passkeyLine->setText( m_defaultPasskey ); |
213 | // set info tab | 216 | // set info tab |
214 | setInfo(); | 217 | setInfo(); |
215 | } | 218 | } |
216 | 219 | ||
217 | 220 | ||
218 | /** | 221 | /** |
219 | * Get the status informations and returns it | 222 | * Get the status informations and returns it |
220 | * @return QString the status informations gathered | 223 | * @return QString the status informations gathered |
221 | */ | 224 | */ |
222 | QString BlueBase::status()const{ | 225 | QString BlueBase::status()const{ |
223 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); | 226 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); |
224 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); | 227 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); |
225 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); | 228 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); |
226 | 229 | ||
227 | return (infoString); | 230 | return (infoString); |
228 | } | 231 | } |
229 | 232 | ||
230 | 233 | ||
231 | /** | 234 | /** |
232 | * Read the current values from the gui and invoke writeConfig() | 235 | * Read the current values from the gui and invoke writeConfig() |
233 | */ | 236 | */ |
234 | void BlueBase::applyConfigChanges() { | 237 | void BlueBase::applyConfigChanges() { |
235 | m_deviceName = deviceNameLine->text(); | 238 | m_deviceName = deviceNameLine->text(); |
236 | m_defaultPasskey = passkeyLine->text(); | 239 | m_defaultPasskey = passkeyLine->text(); |
237 | m_useEncryption = cryptCheckBox->isChecked(); | 240 | m_useEncryption = cryptCheckBox->isChecked(); |
238 | m_enableAuthentification = authCheckBox->isChecked(); | 241 | m_enableAuthentification = authCheckBox->isChecked(); |
239 | m_enablePagescan = pagescanCheckBox->isChecked(); | 242 | m_enablePagescan = pagescanCheckBox->isChecked(); |
240 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); | 243 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); |
241 | 244 | ||
242 | writeConfig(); | 245 | writeConfig(); |
243 | 246 | ||
244 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); | 247 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); |
245 | } | 248 | } |
246 | 249 | ||
247 | /** | 250 | /** |
251 | * Launch Rfcomm Bind dialog | ||
252 | * | ||
253 | */ | ||
254 | void BlueBase::rfcommDialog() { | ||
255 | RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); | ||
256 | |||
257 | rfcommAssign.showMaximized(); | ||
258 | |||
259 | if ( rfcommAssign.exec() == QDialog::Accepted ) { | ||
260 | rfcommAssign.saveConfig(); | ||
261 | } | ||
262 | } | ||
263 | |||
264 | /** | ||
248 | * Add fresh found devices from scan dialog to the listing | 265 | * Add fresh found devices from scan dialog to the listing |
249 | * | 266 | * |
250 | */ | 267 | */ |
251 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { | 268 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { |
252 | BTDeviceItem * deviceItem; | 269 | BTDeviceItem * deviceItem; |
253 | QValueList<RemoteDevice>::ConstIterator it; | 270 | QValueList<RemoteDevice>::ConstIterator it; |
254 | 271 | ||
255 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { | 272 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { |
256 | 273 | ||
257 | if (find( (*it) )) // is already inserted | 274 | if (find( (*it) )) // is already inserted |
258 | continue; | 275 | continue; |
259 | 276 | ||
260 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); | 277 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); |
261 | deviceItem->setPixmap( 1, m_findPix ); | 278 | deviceItem->setPixmap( 1, m_findPix ); |
262 | deviceItem->setExpandable ( true ); | 279 | deviceItem->setExpandable ( true ); |
263 | 280 | ||
264 | // look if device is avail. atm, async | 281 | // look if device is avail. atm, async |
265 | deviceActive( (*it) ); | 282 | deviceActive( (*it) ); |
266 | 283 | ||
267 | // ggf auch hier? | 284 | // ggf auch hier? |
268 | addServicesToDevice( deviceItem ); | 285 | addServicesToDevice( deviceItem ); |
269 | } | 286 | } |
270 | } | 287 | } |
271 | 288 | ||