author | harlekin <harlekin> | 2002-06-28 12:35:57 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-06-28 12:35:57 (UTC) |
commit | f67804b04c2acac7c4d9fd854eaee3501fd3915d (patch) (unidiff) | |
tree | 1c1b706ee826e38173677696a5c93c9d2d64cefd | |
parent | ffcfdb4e932dcbd147b0294aeb70762927cdbc5f (diff) | |
download | opie-f67804b04c2acac7c4d9fd854eaee3501fd3915d.zip opie-f67804b04c2acac7c4d9fd854eaee3501fd3915d.tar.gz opie-f67804b04c2acac7c4d9fd854eaee3501fd3915d.tar.bz2 |
updates like editing hcid.conf and cleanups
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 54 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 3 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/manager.pro | 4 |
3 files changed, 52 insertions, 9 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index af65f14..b4b59c3 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -1,473 +1,515 @@ | |||
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 | 21 | ||
21 | #include <qframe.h> | 22 | #include <qframe.h> |
22 | #include <qlabel.h> | 23 | #include <qlabel.h> |
23 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
24 | #include <qlayout.h> | 25 | #include <qlayout.h> |
25 | #include <qvariant.h> | 26 | #include <qvariant.h> |
26 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
27 | #include <qimage.h> | 28 | #include <qimage.h> |
28 | #include <qpixmap.h> | 29 | #include <qpixmap.h> |
29 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
30 | #include <qscrollview.h> | 31 | #include <qscrollview.h> |
31 | #include <qvbox.h> | 32 | #include <qvbox.h> |
32 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
33 | #include <qapplication.h> | ||
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
36 | #include <qlistview.h> | 36 | #include <qlistview.h> |
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qpopupmenu.h> | 38 | #include <qpopupmenu.h> |
39 | 39 | ||
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/config.h> | 41 | #include <qpe/config.h> |
42 | 42 | ||
43 | #include <remotedevice.h> | 43 | #include <remotedevice.h> |
44 | 44 | ||
45 | 45 | ||
46 | namespace OpieTooth { | 46 | namespace OpieTooth { |
47 | 47 | ||
48 | 48 | ||
49 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 49 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
50 | : BluetoothBase( parent, name, fl ) { | 50 | : BluetoothBase( parent, name, fl ) { |
51 | 51 | ||
52 | localDevice = new Manager( "hci0" ); | 52 | localDevice = new Manager( "hci0" ); |
53 | 53 | ||
54 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 54 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
55 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 55 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
56 | // not good since lib is async | 56 | // not good since lib is async |
57 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), | 57 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), |
58 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); | 58 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); |
59 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), | 59 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), |
60 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); | 60 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); |
61 | // hehe, cast right later | ||
61 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), | 62 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), |
62 | this, SLOT(startServiceActionHold( BTListItem *, const QPoint &, int) ) ); | 63 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); |
63 | connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), | 64 | connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), |
64 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); | 65 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); |
65 | connect( localDevice, SIGNAL( available( const QString&, bool ) ), | 66 | connect( localDevice, SIGNAL( available( const QString&, bool ) ), |
66 | this, SLOT( deviceActive( const QString& , bool ) ) ); | 67 | this, SLOT( deviceActive( const QString& , bool ) ) ); |
67 | 68 | ||
68 | //Load all icons needed | 69 | //Load all icons needed |
69 | 70 | ||
70 | offPix = Resource::loadPixmap( "editdelete" ); | 71 | offPix = Resource::loadPixmap( "editdelete" ); |
71 | onPix = Resource::loadPixmap( "installed" ); | 72 | onPix = Resource::loadPixmap( "installed" ); |
72 | 73 | ||
73 | QPalette pal = this->palette(); | 74 | QPalette pal = this->palette(); |
74 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); | 75 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); |
75 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); | 76 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); |
76 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); | 77 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); |
77 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); | 78 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); |
78 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); | 79 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); |
79 | this->setPalette( pal ); | 80 | this->setPalette( pal ); |
80 | 81 | ||
81 | setCaption( tr( "Bluetooth Manager" ) ); | 82 | setCaption( tr( "Bluetooth Manager" ) ); |
82 | 83 | ||
83 | readConfig(); | 84 | readConfig(); |
84 | initGui(); | 85 | initGui(); |
85 | 86 | ||
86 | //TESTING | 87 | //TESTING |
87 | ListView2->setRootIsDecorated(true); | 88 | ListView2->setRootIsDecorated(true); |
88 | 89 | ||
89 | BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); | 90 | BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); |
90 | topLV2->setPixmap( 1, onPix ); | 91 | topLV2->setPixmap( 1, onPix ); |
91 | (void) new BTListItem( topLV2, "Serial" ,"", "service" ); | 92 | (void) new BTListItem( topLV2, "Serial" ,"", "service" ); |
92 | (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); | 93 | (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); |
94 | writeToHciConfig(); | ||
93 | } | 95 | } |
94 | 96 | ||
95 | 97 | ||
96 | /** | 98 | /** |
97 | * Reads all options from the config file | 99 | * Reads all options from the config file |
98 | */ | 100 | */ |
99 | void BlueBase::readConfig() { | 101 | void BlueBase::readConfig() { |
100 | 102 | ||
101 | Config cfg( "bluetoothmanager" ); | 103 | Config cfg( "bluetoothmanager" ); |
102 | cfg.setGroup( "bluezsettings" ); | 104 | cfg.setGroup( "bluezsettings" ); |
103 | 105 | ||
104 | 106 | ||
105 | deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with | 107 | deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with |
106 | defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak | 108 | defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak |
107 | useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); | 109 | useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); |
108 | enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); | 110 | enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); |
109 | enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); | 111 | enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); |
110 | enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); | 112 | enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); |
111 | 113 | ||
112 | } | 114 | } |
113 | 115 | ||
114 | /** | 116 | /** |
115 | * Writes all options to the config file | 117 | * Writes all options to the config file |
116 | */ | 118 | */ |
117 | void BlueBase::writeConfig() { | 119 | void BlueBase::writeConfig() { |
118 | 120 | ||
119 | 121 | ||
120 | Config cfg( "bluetoothmanager" ); | 122 | Config cfg( "bluetoothmanager" ); |
121 | cfg.setGroup( "bluezsettings" ); | 123 | cfg.setGroup( "bluezsettings" ); |
122 | 124 | ||
123 | cfg.writeEntry( "name" , deviceName ); | 125 | cfg.writeEntry( "name" , deviceName ); |
124 | cfg.writeEntryCrypt( "passkey" , defaultPasskey ); | 126 | cfg.writeEntryCrypt( "passkey" , defaultPasskey ); |
125 | cfg.writeEntry( "useEncryption" , useEncryption ); | 127 | cfg.writeEntry( "useEncryption" , useEncryption ); |
126 | cfg.writeEntry( "enableAuthentification" , enableAuthentification ); | 128 | cfg.writeEntry( "enableAuthentification" , enableAuthentification ); |
127 | cfg.writeEntry( "enablePagescan" , enablePagescan ); | 129 | cfg.writeEntry( "enablePagescan" , enablePagescan ); |
128 | cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); | 130 | cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); |
129 | } | 131 | |
132 | writeToHciConfig(); | ||
133 | } | ||
134 | |||
135 | void BlueBase::writeToHciConfig() { | ||
136 | |||
137 | HciConfWrapper *hciconf = new HciConfWrapper( "/tmp/hcid.conf" ); | ||
138 | hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | ||
139 | |||
140 | |||
141 | // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | ||
142 | |||
143 | hciconf->setName( deviceName ); | ||
144 | |||
145 | if ( useEncryption == 1) { | ||
146 | hciconf->setEncrypt( true ); | ||
147 | } else { | ||
148 | hciconf->setEncrypt( false ); | ||
149 | } | ||
150 | |||
151 | |||
152 | if ( enableAuthentification == 1) { | ||
153 | hciconf->setAuth( true ); | ||
154 | } else { | ||
155 | hciconf->setAuth( false ); | ||
156 | } | ||
157 | |||
158 | if ( enablePagescan == 1) { | ||
159 | hciconf->setPscan( true ); | ||
160 | } else { | ||
161 | hciconf->setPscan( false ); | ||
162 | } | ||
163 | |||
164 | if ( enableInquiryscan == 1) { | ||
165 | hciconf->setIscan( true ); | ||
166 | } else { | ||
167 | hciconf->setIscan( false ); | ||
168 | } | ||
169 | } | ||
130 | 170 | ||
131 | 171 | ||
132 | /** | 172 | /** |
133 | * Read the list of allready known devices | 173 | * Read the list of allready known devices |
134 | * | 174 | * |
135 | */ | 175 | */ |
136 | void BlueBase::readSavedDevices() { | 176 | void BlueBase::readSavedDevices() { |
137 | 177 | ||
138 | QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; | 178 | QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; |
139 | 179 | ||
140 | QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/"); | 180 | QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/"); |
141 | // list of .conf files | 181 | // list of .conf files |
142 | QStringList devicesFileList = deviceListSave.entryList(); | 182 | QStringList devicesFileList = deviceListSave.entryList(); |
143 | 183 | ||
144 | // cut .conf of to get the mac and also read the name entry in it. | 184 | // cut .conf of to get the mac and also read the name entry in it. |
145 | 185 | ||
146 | for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { | 186 | for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { |
147 | 187 | ||
148 | QString name; | 188 | QString name; |
149 | QString mac; | 189 | QString mac; |
150 | qDebug((*it).latin1() ); | 190 | qDebug((*it).latin1() ); |
151 | Config conf((*it)); | 191 | Config conf((*it)); |
152 | conf.setGroup("Info"); | 192 | conf.setGroup("Info"); |
153 | name = conf.readEntry("name", "Error"); | 193 | name = conf.readEntry("name", "Error"); |
154 | qDebug("MAC: " + mac); | 194 | qDebug("MAC: " + mac); |
155 | qDebug("NAME: " + name); | 195 | qDebug("NAME: " + name); |
156 | RemoteDevice currentDevice = RemoteDevice( mac , name ); | 196 | RemoteDevice currentDevice = RemoteDevice( mac , name ); |
157 | loadedDevices->append( ¤tDevice ); | 197 | loadedDevices->append( ¤tDevice ); |
158 | } | 198 | } |
159 | addSearchedDevices( *loadedDevices ); | 199 | addSearchedDevices( *loadedDevices ); |
160 | } | 200 | } |
161 | 201 | ||
162 | /** | 202 | /** |
163 | * Write the list of allready known devices | 203 | * Write the list of allready known devices |
164 | * | 204 | * |
165 | */ | 205 | */ |
166 | void BlueBase::writeSavedDevices() { | 206 | void BlueBase::writeSavedDevices() { |
167 | 207 | ||
168 | QListViewItemIterator it( ListView2 ); | 208 | QListViewItemIterator it( ListView2 ); |
169 | 209 | ||
170 | for ( ; it.current(); ++it ) { | 210 | for ( ; it.current(); ++it ) { |
171 | 211 | ||
172 | // seperate config file for each device, to store more information in future. | 212 | // seperate config file for each device, to store more information in future. |
173 | // TO FIX: BTLISTITEM!!! | 213 | // TO FIX: BTLISTITEM!!! |
174 | 214 | ||
175 | // Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem)it.current())->mac()) + ".conf", Config::File ); | 215 | // Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem)it.current())->mac()) + ".conf", Config::File ); |
176 | // conf.setGroup( "Info" ); | 216 | // conf.setGroup( "Info" ); |
177 | // conf.writeEntry( "name", it.current()->name() ); | 217 | // conf.writeEntry( "name", it.current()->name() ); |
178 | } | 218 | } |
179 | } | 219 | } |
180 | 220 | ||
181 | 221 | ||
182 | /** | 222 | /** |
183 | * Set up the gui | 223 | * Set up the gui |
184 | */ | 224 | */ |
185 | void BlueBase::initGui() { | 225 | void BlueBase::initGui() { |
186 | 226 | ||
187 | StatusLabel->setText( getStatus() ); // maybe move it to getStatus() | 227 | StatusLabel->setText( getStatus() ); // maybe move it to getStatus() |
188 | 228 | ||
189 | cryptCheckBox->setChecked( useEncryption ); | 229 | cryptCheckBox->setChecked( useEncryption ); |
190 | authCheckBox->setChecked( enableAuthentification ); | 230 | authCheckBox->setChecked( enableAuthentification ); |
191 | pagescanCheckBox->setChecked( enablePagescan ); | 231 | pagescanCheckBox->setChecked( enablePagescan ); |
192 | inquiryscanCheckBox->setChecked( enableInquiryscan ); | 232 | inquiryscanCheckBox->setChecked( enableInquiryscan ); |
193 | deviceNameLine->setText( deviceName ); | 233 | deviceNameLine->setText( deviceName ); |
194 | passkeyLine->setText( defaultPasskey ); | 234 | passkeyLine->setText( defaultPasskey ); |
195 | // set info tab | 235 | // set info tab |
196 | setInfo(); | 236 | setInfo(); |
197 | } | 237 | } |
198 | 238 | ||
199 | 239 | ||
200 | /** | 240 | /** |
201 | * Get the status informations and returns it | 241 | * Get the status informations and returns it |
202 | * @return QString the status informations gathered | 242 | * @return QString the status informations gathered |
203 | */ | 243 | */ |
204 | QString BlueBase::getStatus(){ | 244 | QString BlueBase::getStatus(){ |
205 | 245 | ||
206 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); | 246 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); |
207 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); | 247 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); |
208 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); | 248 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); |
209 | 249 | ||
210 | return (infoString); | 250 | return (infoString); |
211 | } | 251 | } |
212 | 252 | ||
213 | 253 | ||
214 | /** | 254 | /** |
215 | * Read the current values from the gui and invoke writeConfig() | 255 | * Read the current values from the gui and invoke writeConfig() |
216 | */ | 256 | */ |
217 | void BlueBase::applyConfigChanges() { | 257 | void BlueBase::applyConfigChanges() { |
218 | 258 | ||
219 | deviceName = deviceNameLine->text(); | 259 | deviceName = deviceNameLine->text(); |
220 | defaultPasskey = passkeyLine->text(); | 260 | defaultPasskey = passkeyLine->text(); |
221 | useEncryption = cryptCheckBox->isChecked(); | 261 | useEncryption = cryptCheckBox->isChecked(); |
222 | enableAuthentification = authCheckBox->isChecked(); | 262 | enableAuthentification = authCheckBox->isChecked(); |
223 | enablePagescan = pagescanCheckBox->isChecked(); | 263 | enablePagescan = pagescanCheckBox->isChecked(); |
224 | enableInquiryscan = inquiryscanCheckBox->isChecked(); | 264 | enableInquiryscan = inquiryscanCheckBox->isChecked(); |
225 | 265 | ||
226 | writeConfig(); | 266 | writeConfig(); |
227 | 267 | ||
268 | |||
228 | QMessageBox* box = new QMessageBox( this, "Test" ); | 269 | QMessageBox* box = new QMessageBox( this, "Test" ); |
229 | box->setText( tr( "Changes applied" ) ); | 270 | box->setText( tr( "Changes applied" ) ); |
230 | box->show(); | 271 | box->show(); |
231 | // falls nötig hcid killhupen - die funktionalität adden | 272 | // falls nötig hcid killhupen - die funktionalität adden |
232 | } | 273 | } |
233 | 274 | ||
234 | 275 | ||
235 | /** | 276 | /** |
236 | * Add fresh found devices from scan dialog to the listing | 277 | * Add fresh found devices from scan dialog to the listing |
237 | * | 278 | * |
238 | */ | 279 | */ |
239 | void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { | 280 | void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { |
240 | 281 | ||
241 | BTListItem * deviceItem; | 282 | BTListItem * deviceItem; |
242 | 283 | ||
243 | QListIterator<RemoteDevice> it( newDevices ); | 284 | QListIterator<RemoteDevice> it( newDevices ); |
244 | 285 | ||
245 | for( ; it.current() ; ++it ) { | 286 | for( ; it.current() ; ++it ) { |
246 | 287 | ||
247 | 288 | ||
248 | RemoteDevice *dev = it.current(); | 289 | RemoteDevice *dev = it.current(); |
249 | deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" ); | 290 | deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" ); |
250 | deviceItem->setExpandable ( true ); | 291 | deviceItem->setExpandable ( true ); |
251 | 292 | ||
252 | // look if device is avail. atm, async | 293 | // look if device is avail. atm, async |
253 | deviceActive( dev ); | 294 | deviceActive( dev ); |
254 | 295 | ||
255 | // move into the c'tor | 296 | // move into the c'tor |
256 | // deviceItem->setMac( dev->mac() ); | 297 | // deviceItem->setMac( dev->mac() ); |
257 | // what kind of entry is it. | 298 | // what kind of entry is it. |
258 | //deviceItem->setType( "device"); | 299 | //deviceItem->setType( "device"); |
259 | 300 | ||
260 | // ggf auch hier? | 301 | // ggf auch hier? |
261 | addServicesToDevice( deviceItem ); | 302 | addServicesToDevice( deviceItem ); |
262 | } | 303 | } |
263 | } | 304 | } |
264 | 305 | ||
265 | 306 | ||
266 | /** | 307 | /** |
267 | * Action that is toggled on entrys on click | 308 | * Action that is toggled on entrys on click |
268 | */ | 309 | */ |
269 | void BlueBase::startServiceActionClicked( QListViewItem *item ) { | 310 | void BlueBase::startServiceActionClicked( QListViewItem *item ) { |
270 | 311 | ||
271 | 312 | ||
272 | } | 313 | } |
273 | 314 | ||
274 | /** | 315 | /** |
275 | * Action that are toggled on hold (mostly QPopups i guess) | 316 | * Action that are toggled on hold (mostly QPopups i guess) |
276 | */ | 317 | */ |
277 | void BlueBase::startServiceActionHold( BTListItem * item, const QPoint & point, int column ) { | 318 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { |
278 | 319 | ||
279 | QPopupMenu *menu = new QPopupMenu(); | 320 | QPopupMenu *menu = new QPopupMenu(); |
280 | 321 | ||
281 | int ret=0; | 322 | int ret=0; |
282 | 323 | ||
324 | |||
283 | //QSize s = menu->sizeHint ( ); | 325 | //QSize s = menu->sizeHint ( ); |
284 | 326 | ||
285 | if ( item->type() == "device") { | 327 | if ( ((BTListItem*)item)->type() == "device") { |
286 | 328 | ||
287 | QPopupMenu *groups = new QPopupMenu(); | 329 | QPopupMenu *groups = new QPopupMenu(); |
288 | 330 | ||
289 | menu->insertItem( tr("rescan sevices:"), 0); | 331 | menu->insertItem( tr("rescan sevices:"), 0); |
290 | menu->insertItem( tr("to group"), groups , 1); | 332 | menu->insertItem( tr("to group"), groups , 1); |
291 | menu->insertItem( tr("delete"), 2); | 333 | menu->insertItem( tr("delete"), 2); |
292 | 334 | ||
293 | 335 | ||
294 | ret = menu->exec( point , 0); | 336 | ret = menu->exec( point , 0); |
295 | 337 | ||
296 | switch(ret) { | 338 | switch(ret) { |
297 | case 0: | 339 | case 0: |
298 | break; | 340 | break; |
299 | case 1: | 341 | case 1: |
300 | break; | 342 | break; |
301 | case 2: | 343 | case 2: |
302 | // delete childs too | 344 | // delete childs too |
303 | delete item; | 345 | delete item; |
304 | break; | 346 | break; |
305 | } | 347 | } |
306 | delete groups; | 348 | delete groups; |
307 | 349 | ||
308 | } else if ( item->type() == "service") { | 350 | } else if ( ((BTListItem*)item)->type() == "service") { |
309 | menu->insertItem( tr("Test1:"), 0); | 351 | menu->insertItem( tr("Test1:"), 0); |
310 | menu->insertItem( tr("connect"), 1); | 352 | menu->insertItem( tr("connect"), 1); |
311 | menu->insertItem( tr("delete"), 2); | 353 | menu->insertItem( tr("delete"), 2); |
312 | 354 | ||
313 | ret = menu->exec( point , 0); | 355 | ret = menu->exec( point , 0); |
314 | 356 | ||
315 | switch(ret) { | 357 | switch(ret) { |
316 | case 0: | 358 | case 0: |
317 | break; | 359 | break; |
318 | case 1: | 360 | case 1: |
319 | break; | 361 | break; |
320 | case 2: | 362 | case 2: |
321 | // delete childs too | 363 | // delete childs too |
322 | delete item; | 364 | delete item; |
323 | break; | 365 | break; |
324 | } | 366 | } |
325 | } | 367 | } |
326 | 368 | ||
327 | delete menu; | 369 | delete menu; |
328 | } | 370 | } |
329 | 371 | ||
330 | /** | 372 | /** |
331 | * Search and display avail. services for a device (on expand from device listing) | 373 | * Search and display avail. services for a device (on expand from device listing) |
332 | * | 374 | * |
333 | */ | 375 | */ |
334 | void BlueBase::addServicesToDevice( BTListItem * item ) { | 376 | void BlueBase::addServicesToDevice( BTListItem * item ) { |
335 | 377 | ||
336 | qDebug("addServicesToDevice"); | 378 | qDebug("addServicesToDevice"); |
337 | // row of mac adress text(3) | 379 | // row of mac adress text(3) |
338 | RemoteDevice *device = new RemoteDevice( item->mac(), item->name() ); | 380 | RemoteDevice *device = new RemoteDevice( item->mac(), item->name() ); |
339 | 381 | ||
340 | deviceList.insert( item->mac() , item ); | 382 | deviceList.insert( item->mac() , item ); |
341 | 383 | ||
342 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 384 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
343 | localDevice->searchServices( *device ); | 385 | localDevice->searchServices( *device ); |
344 | 386 | ||
345 | // delete | 387 | // delete |
346 | } | 388 | } |
347 | 389 | ||
348 | 390 | ||
349 | /** | 391 | /** |
350 | * Overloaded. This one it the one that is connected to the foundServices signal | 392 | * Overloaded. This one it the one that is connected to the foundServices signal |
351 | * @param device the mac address of the remote device | 393 | * @param device the mac address of the remote device |
352 | * @param servicesList the list with the service the device has. | 394 | * @param servicesList the list with the service the device has. |
353 | */ | 395 | */ |
354 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 396 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { |
355 | 397 | ||
356 | qDebug("fill services list"); | 398 | qDebug("fill services list"); |
357 | 399 | ||
358 | QMap<QString,BTListItem*>::Iterator it; | 400 | QMap<QString,BTListItem*>::Iterator it; |
359 | 401 | ||
360 | BTListItem* deviceItem; | 402 | BTListItem* deviceItem; |
361 | 403 | ||
362 | // get the right devices which requested the search | 404 | // get the right devices which requested the search |
363 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 405 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
364 | if ( it.key() == device ) { | 406 | if ( it.key() == device ) { |
365 | deviceItem = it.data(); | 407 | deviceItem = it.data(); |
366 | } | 408 | } |
367 | } | 409 | } |
368 | 410 | ||
369 | 411 | ||
370 | // empty entries | 412 | // empty entries |
371 | // QListViewItem * myChild = deviceItem->firstChild(); | 413 | // QListViewItem * myChild = deviceItem->firstChild(); |
372 | //QList<QListViewItem*> tmpList; | 414 | //QList<QListViewItem*> tmpList; |
373 | //while( myChild ) { | 415 | //while( myChild ) { |
374 | // tmpList.append(myChild); | 416 | // tmpList.append(myChild); |
375 | // myChild = myChild->nextSibling(); | 417 | // myChild = myChild->nextSibling(); |
376 | // } | 418 | // } |
377 | 419 | ||
378 | 420 | ||
379 | QValueList<OpieTooth::Services>::Iterator it2; | 421 | QValueList<OpieTooth::Services>::Iterator it2; |
380 | 422 | ||
381 | BTListItem * serviceItem; | 423 | BTListItem * serviceItem; |
382 | 424 | ||
383 | if (!servicesList.isEmpty() ) { | 425 | if (!servicesList.isEmpty() ) { |
384 | // add services | 426 | // add services |
385 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { | 427 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { |
386 | serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); | 428 | serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); |
387 | //serviceItem->setText(4, "service"); | 429 | //serviceItem->setText(4, "service"); |
388 | } | 430 | } |
389 | } else { | 431 | } else { |
390 | serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" ); | 432 | serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" ); |
391 | //serviceItem->setText(4, "service"); | 433 | //serviceItem->setText(4, "service"); |
392 | } | 434 | } |
393 | } | 435 | } |
394 | 436 | ||
395 | 437 | ||
396 | /** | 438 | /** |
397 | * Add the existing connections (pairs) to the connections tab. | 439 | * Add the existing connections (pairs) to the connections tab. |
398 | * | 440 | * |
399 | */ | 441 | */ |
400 | void BlueBase::addConnectedDevices() { | 442 | void BlueBase::addConnectedDevices() { |
401 | 443 | ||
402 | 444 | ||
403 | //mac address | 445 | //mac address |
404 | 446 | ||
405 | } | 447 | } |
406 | 448 | ||
407 | /** | 449 | /** |
408 | * Find out if a device can currently be reached | 450 | * Find out if a device can currently be reached |
409 | */ | 451 | */ |
410 | void BlueBase::deviceActive( RemoteDevice *device ) { | 452 | void BlueBase::deviceActive( RemoteDevice *device ) { |
411 | 453 | ||
412 | // search by mac, async, gets a signal back | 454 | // search by mac, async, gets a signal back |
413 | localDevice->isAvailable( device->mac() ); | 455 | localDevice->isAvailable( device->mac() ); |
414 | } | 456 | } |
415 | 457 | ||
416 | /** | 458 | /** |
417 | * The signal catcher. Set the avail. status on device. | 459 | * The signal catcher. Set the avail. status on device. |
418 | * @param device - the mac address | 460 | * @param device - the mac address |
419 | * @param connected - if it is avail. or not | 461 | * @param connected - if it is avail. or not |
420 | */ | 462 | */ |
421 | void BlueBase::deviceActive( const QString& device, bool connected ) { | 463 | void BlueBase::deviceActive( const QString& device, bool connected ) { |
422 | 464 | ||
423 | qDebug("deviceActive slot"); | 465 | qDebug("deviceActive slot"); |
424 | 466 | ||
425 | QMap<QString,BTListItem*>::Iterator it; | 467 | QMap<QString,BTListItem*>::Iterator it; |
426 | 468 | ||
427 | BTListItem* deviceItem; | 469 | BTListItem* deviceItem; |
428 | 470 | ||
429 | // get the right devices which requested the search | 471 | // get the right devices which requested the search |
430 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 472 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
431 | if ( it.key() == device ) { | 473 | if ( it.key() == device ) { |
432 | deviceItem = it.data(); | 474 | deviceItem = it.data(); |
433 | } | 475 | } |
434 | } | 476 | } |
435 | 477 | ||
436 | if ( connected ) { | 478 | if ( connected ) { |
437 | deviceItem->setPixmap( 1, onPix ); | 479 | deviceItem->setPixmap( 1, onPix ); |
438 | } else { | 480 | } else { |
439 | deviceItem->setPixmap( 1, offPix ); | 481 | deviceItem->setPixmap( 1, offPix ); |
440 | } | 482 | } |
441 | 483 | ||
442 | } | 484 | } |
443 | 485 | ||
444 | 486 | ||
445 | 487 | ||
446 | /** | 488 | /** |
447 | * Open the "scan for devices" dialog | 489 | * Open the "scan for devices" dialog |
448 | */ | 490 | */ |
449 | void BlueBase::startScan() { | 491 | void BlueBase::startScan() { |
450 | 492 | ||
451 | ScanDialog *scan = new ScanDialog( this, "", true); | 493 | ScanDialog *scan = new ScanDialog( this, "", true); |
452 | QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ), | 494 | QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ), |
453 | this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) ); | 495 | this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) ); |
454 | 496 | ||
455 | scan->showMaximized(); | 497 | scan->showMaximized(); |
456 | } | 498 | } |
457 | 499 | ||
458 | 500 | ||
459 | /** | 501 | /** |
460 | * Set the informations about the local device in information Tab | 502 | * Set the informations about the local device in information Tab |
461 | */ | 503 | */ |
462 | void BlueBase::setInfo() { | 504 | void BlueBase::setInfo() { |
463 | StatusLabel->setText( getStatus() ); | 505 | StatusLabel->setText( getStatus() ); |
464 | } | 506 | } |
465 | 507 | ||
466 | /** | 508 | /** |
467 | * Decontructor | 509 | * Decontructor |
468 | */ | 510 | */ |
469 | BlueBase::~BlueBase() { | 511 | BlueBase::~BlueBase() { |
470 | writeSavedDevices(); | 512 | writeSavedDevices(); |
471 | } | 513 | } |
472 | } | 514 | } |
473 | 515 | ||
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index 481f0c9..ef67aa2 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h | |||
@@ -1,80 +1,81 @@ | |||
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 | #include "btlistitem.h" | 13 | #include "btlistitem.h" |
14 | 14 | ||
15 | #include <remotedevice.h> | 15 | #include <remotedevice.h> |
16 | #include <manager.h> | 16 | #include <manager.h> |
17 | 17 | ||
18 | class QVBox; | 18 | class QVBox; |
19 | class QHBoxLayout; | 19 | class QHBoxLayout; |
20 | class QGridLayout; | 20 | class QGridLayout; |
21 | class QFrame; | 21 | class QFrame; |
22 | class QLabel; | 22 | class QLabel; |
23 | class QPushButton; | 23 | class QPushButton; |
24 | class QTabWidget; | 24 | class QTabWidget; |
25 | class QCheckBox; | 25 | class QCheckBox; |
26 | 26 | ||
27 | 27 | ||
28 | namespace OpieTooth { | 28 | namespace OpieTooth { |
29 | 29 | ||
30 | class BlueBase : public BluetoothBase { | 30 | class BlueBase : public BluetoothBase { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | 32 | ||
33 | public: | 33 | public: |
34 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 34 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
35 | ~BlueBase(); | 35 | ~BlueBase(); |
36 | 36 | ||
37 | protected: | 37 | protected: |
38 | 38 | ||
39 | 39 | ||
40 | private slots: | 40 | private slots: |
41 | void startScan(); | 41 | void startScan(); |
42 | 42 | ||
43 | private: | 43 | private: |
44 | void readConfig(); | 44 | void readConfig(); |
45 | void writeConfig(); | 45 | void writeConfig(); |
46 | void readSavedDevices(); | 46 | void readSavedDevices(); |
47 | void writeSavedDevices(); | 47 | void writeSavedDevices(); |
48 | void writeToHciConfig(); | ||
48 | QString getStatus(); | 49 | QString getStatus(); |
49 | void initGui(); | 50 | void initGui(); |
50 | void setInfo(); | 51 | void setInfo(); |
51 | Manager *localDevice; | 52 | Manager *localDevice; |
52 | QMap<QString,BTListItem*> deviceList; | 53 | QMap<QString,BTListItem*> deviceList; |
53 | 54 | ||
54 | void deviceActive( RemoteDevice *device ); | 55 | void deviceActive( RemoteDevice *device ); |
55 | 56 | ||
56 | QString deviceName; | 57 | QString deviceName; |
57 | QString defaultPasskey; | 58 | QString defaultPasskey; |
58 | int useEncryption; | 59 | int useEncryption; |
59 | int enableAuthentification; | 60 | int enableAuthentification; |
60 | int enablePagescan; | 61 | int enablePagescan; |
61 | int enableInquiryscan; | 62 | int enableInquiryscan; |
62 | 63 | ||
63 | QPixmap offPix; | 64 | QPixmap offPix; |
64 | QPixmap onPix; | 65 | QPixmap onPix; |
65 | 66 | ||
66 | private slots: | 67 | private slots: |
67 | void addSearchedDevices( QList<RemoteDevice> &newDevices ); | 68 | void addSearchedDevices( QList<RemoteDevice> &newDevices ); |
68 | void addServicesToDevice( BTListItem *item ); | 69 | void addServicesToDevice( BTListItem *item ); |
69 | void addServicesToDevice( const QString& device, Services::ValueList ); | 70 | void addServicesToDevice( const QString& device, Services::ValueList ); |
70 | void addConnectedDevices(); | 71 | void addConnectedDevices(); |
71 | void startServiceActionClicked( QListViewItem *item ); | 72 | void startServiceActionClicked( QListViewItem *item ); |
72 | void startServiceActionHold( BTListItem *, const QPoint &, int ); | 73 | void startServiceActionHold( QListViewItem *, const QPoint &, int ); |
73 | void deviceActive( const QString& mac, bool connected ); | 74 | void deviceActive( const QString& mac, bool connected ); |
74 | void applyConfigChanges(); | 75 | void applyConfigChanges(); |
75 | 76 | ||
76 | }; | 77 | }; |
77 | 78 | ||
78 | } | 79 | } |
79 | 80 | ||
80 | #endif | 81 | #endif |
diff --git a/noncore/net/opietooth/manager/manager.pro b/noncore/net/opietooth/manager/manager.pro index 39ddcaf..4fcf010 100644 --- a/noncore/net/opietooth/manager/manager.pro +++ b/noncore/net/opietooth/manager/manager.pro | |||
@@ -1,27 +1,27 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on debug | 2 | CONFIG = qt warn_on debug |
3 | #CONFIG = qt warn_on release | 3 | #CONFIG = qt warn_on release |
4 | HEADERS = bluebase.h scandialog.h btlistitem.h | 4 | HEADERS = bluebase.h scandialog.h btlistitem.h hciconfwrapper.h |
5 | SOURCES = main.cpp bluebase.cpp scandialog.cpp btlistitem.cpp | 5 | SOURCES = main.cpp bluebase.cpp scandialog.cpp btlistitem.cpp hciconfwrapper.cpp |
6 | INCLUDEPATH += $(OPIEDIR)/include | 6 | INCLUDEPATH += $(OPIEDIR)/include |
7 | INCLUDEPATH += $(OPIEDIR)/noncore/net/opietooth/lib | 7 | INCLUDEPATH += $(OPIEDIR)/noncore/net/opietooth/lib |
8 | DEPENDPATH += $(OPIEDIR)/include | 8 | DEPENDPATH += $(OPIEDIR)/include |
9 | LIBS += -lqpe -lopietooth -lopie | 9 | LIBS += -lqpe -lopietooth -lopie |
10 | INTERFACES = bluetoothbase.ui devicedialog.ui | 10 | INTERFACES = bluetoothbase.ui devicedialog.ui |
11 | DESTDIR = $(OPIEDIR)/bin | 11 | DESTDIR = $(OPIEDIR)/bin |
12 | TARGET = bluetooth-manager | 12 | TARGET = bluetooth-manager |
13 | 13 | ||
14 | TRANSLATIONS = ../../../../i18n/de/bluetooth-manager.ts \ | 14 | TRANSLATIONS = ../../../../i18n/de/bluetooth-manager.ts \ |
15 | ../../../../i18n/en/bluetooth-manager.ts \ | 15 | ../../../../i18n/en/bluetooth-manager.ts \ |
16 | ../../../../i18n/es/bluetooth-manager.ts \ | 16 | ../../../../i18n/es/bluetooth-manager.ts \ |
17 | ../../../../i18n/fr/bluetooth-manager.ts \ | 17 | ../../../../i18n/fr/bluetooth-manager.ts \ |
18 | ../../../../i18n/hu/bluetooth-manager.ts \ | 18 | ../../../../i18n/hu/bluetooth-manager.ts \ |
19 | ../../../../i18n/ja/bluetooth-manager.ts \ | 19 | ../../../../i18n/ja/bluetooth-manager.ts \ |
20 | ../../../../i18n/ko/bluetooth-manager.ts \ | 20 | ../../../../i18n/ko/bluetooth-manager.ts \ |
21 | ../../../../i18n/no/bluetooth-manager.ts \ | 21 | ../../../../i18n/no/bluetooth-manager.ts \ |
22 | ../../../../i18n/pl/bluetooth-manager.ts \ | 22 | ../../../../i18n/pl/bluetooth-manager.ts \ |
23 | ../../../../i18n/pt/bluetooth-manager.ts \ | 23 | ../../../../i18n/pt/bluetooth-manager.ts \ |
24 | ../../../../i18n/pt_BR/bluetooth-manager.ts \ | 24 | ../../../../i18n/pt_BR/bluetooth-manager.ts \ |
25 | ../../../../i18n/sl/bluetooth-manager.ts \ | 25 | ../../../../i18n/sl/bluetooth-manager.ts \ |
26 | ../../../../i18n/zh_CN/bluetooth-manager.ts \ | 26 | ../../../../i18n/zh_CN/bluetooth-manager.ts \ |
27 | ../../../../i18n/zh_TW/bluetooth-manager.ts | 27 | ../../../../i18n/zh_TW/bluetooth-manager.ts |