-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 3 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.cpp | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 4d476ac..22b16d2 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -1,323 +1,322 @@ | |||
1 | /* | 1 | /* |
2 | * bluebase.cpp * | 2 | * bluebase.cpp * |
3 | * --------------------- | 3 | * --------------------- |
4 | * | 4 | * |
5 | * begin : Sun 10 17:20:00 CEST 2002 | ||
6 | * copyright : (c) 2002 by Maximilian Reiß | 5 | * copyright : (c) 2002 by Maximilian Reiß |
7 | * email : max.reiss@gmx.de | 6 | * email : max.reiss@gmx.de |
8 | * | 7 | * |
9 | */ | 8 | */ |
10 | /*************************************************************************** | 9 | /*************************************************************************** |
11 | * * | 10 | * * |
12 | * 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 * |
13 | * 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 * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
16 | * * | 15 | * * |
17 | ***************************************************************************/ | 16 | ***************************************************************************/ |
18 | 17 | ||
19 | #include "bluebase.h" | 18 | #include "bluebase.h" |
20 | #include "scandialog.h" | 19 | #include "scandialog.h" |
21 | 20 | ||
22 | #include <qframe.h> | 21 | #include <qframe.h> |
23 | #include <qlabel.h> | 22 | #include <qlabel.h> |
24 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
25 | #include <qlayout.h> | 24 | #include <qlayout.h> |
26 | #include <qvariant.h> | 25 | #include <qvariant.h> |
27 | #include <qwhatsthis.h> | 26 | #include <qwhatsthis.h> |
28 | #include <qimage.h> | 27 | #include <qimage.h> |
29 | #include <qpixmap.h> | 28 | #include <qpixmap.h> |
30 | #include <qtabwidget.h> | 29 | #include <qtabwidget.h> |
31 | #include <qscrollview.h> | 30 | #include <qscrollview.h> |
32 | #include <qvbox.h> | 31 | #include <qvbox.h> |
33 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
34 | #include <qapplication.h> | 33 | #include <qapplication.h> |
35 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
36 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
37 | #include <qlistview.h> | 36 | #include <qlistview.h> |
38 | #include <qdir.h> | 37 | #include <qdir.h> |
39 | 38 | ||
40 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
41 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
42 | 41 | ||
43 | #include <remotedevice.h> | 42 | #include <remotedevice.h> |
44 | 43 | ||
45 | 44 | ||
46 | namespace OpieTooth { | 45 | namespace OpieTooth { |
47 | 46 | ||
48 | 47 | ||
49 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 48 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
50 | : BluetoothBase( parent, name, fl ) { | 49 | : BluetoothBase( parent, name, fl ) { |
51 | 50 | ||
52 | 51 | ||
53 | QObject::connect( (QObject*)PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 52 | QObject::connect( (QObject*)PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
54 | QObject::connect( (QObject*)configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 53 | QObject::connect( (QObject*)configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
55 | QObject::connect( (QObject*)ListView2, SIGNAL( expanded( QListViewItem * item ) ), | 54 | QObject::connect( (QObject*)ListView2, SIGNAL( expanded( QListViewItem * item ) ), |
56 | this, SLOT( addServicesToDevice( QListViewItem * item ) ) ); | 55 | this, SLOT( addServicesToDevice( QListViewItem * item ) ) ); |
57 | QObject::connect( (QObject*)ListView2, SIGNAL( clicked( QListViewItem * )), | 56 | QObject::connect( (QObject*)ListView2, SIGNAL( clicked( QListViewItem * )), |
58 | this, SLOT( startServiceActionClicked( QListViewItem * item ) ) ); | 57 | this, SLOT( startServiceActionClicked( QListViewItem * item ) ) ); |
59 | 58 | ||
60 | // | 59 | // |
61 | // QObject::connect( (QObject*) Manager, SIGNAL (foundServices( const QString& device, Services::ValueList ), this () ) ); | 60 | // QObject::connect( (QObject*) Manager, SIGNAL (foundServices( const QString& device, Services::ValueList ), this () ) ); |
62 | 61 | ||
63 | //Load all icons needed | 62 | //Load all icons needed |
64 | 63 | ||
65 | 64 | ||
66 | QPixmap offPix = Resource::loadPixmap( "editdelete" ); | 65 | QPixmap offPix = Resource::loadPixmap( "editdelete" ); |
67 | QPixmap onPix = Resource::loadPixmap( "installed" ); | 66 | QPixmap onPix = Resource::loadPixmap( "installed" ); |
68 | 67 | ||
69 | QPalette pal = this->palette(); | 68 | QPalette pal = this->palette(); |
70 | QColor col = pal.color(QPalette::Active, QColorGroup::Background); | 69 | QColor col = pal.color(QPalette::Active, QColorGroup::Background); |
71 | pal.setColor(QPalette::Active, QColorGroup::Button, col); | 70 | pal.setColor(QPalette::Active, QColorGroup::Button, col); |
72 | pal.setColor(QPalette::Inactive, QColorGroup::Button, col); | 71 | pal.setColor(QPalette::Inactive, QColorGroup::Button, col); |
73 | pal.setColor(QPalette::Normal, QColorGroup::Button, col); | 72 | pal.setColor(QPalette::Normal, QColorGroup::Button, col); |
74 | pal.setColor(QPalette::Disabled, QColorGroup::Button, col); | 73 | pal.setColor(QPalette::Disabled, QColorGroup::Button, col); |
75 | this->setPalette(pal); | 74 | this->setPalette(pal); |
76 | 75 | ||
77 | setCaption( tr( "Bluetooth Manager" ) ); | 76 | setCaption( tr( "Bluetooth Manager" ) ); |
78 | 77 | ||
79 | readConfig(); | 78 | readConfig(); |
80 | initGui(); | 79 | initGui(); |
81 | 80 | ||
82 | 81 | ||
83 | //TESTING | 82 | //TESTING |
84 | 83 | ||
85 | ListView2->setRootIsDecorated(true); | 84 | ListView2->setRootIsDecorated(true); |
86 | 85 | ||
87 | QListViewItem *topLV = new QListViewItem( ListView2, "Harlekins Dongle" , "yes"); | 86 | QListViewItem *topLV = new QListViewItem( ListView2, "Harlekins Dongle" , "yes"); |
88 | topLV->setPixmap(0, offPix); | 87 | topLV->setPixmap(0, offPix); |
89 | (void) new QListViewItem( topLV, "on" ); | 88 | (void) new QListViewItem( topLV, "on" ); |
90 | (void) new QListViewItem( topLV, "off" ); | 89 | (void) new QListViewItem( topLV, "off" ); |
91 | 90 | ||
92 | QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" ); | 91 | QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" ); |
93 | topLV2->setPixmap(0, onPix); | 92 | topLV2->setPixmap(0, onPix); |
94 | (void) new QListViewItem( topLV2, "on" ); | 93 | (void) new QListViewItem( topLV2, "on" ); |
95 | (void) new QListViewItem( topLV2, "off" ); | 94 | (void) new QListViewItem( topLV2, "off" ); |
96 | 95 | ||
97 | } | 96 | } |
98 | 97 | ||
99 | 98 | ||
100 | /** | 99 | /** |
101 | * Reads all options from the config file | 100 | * Reads all options from the config file |
102 | */ | 101 | */ |
103 | void BlueBase::readConfig() { | 102 | void BlueBase::readConfig() { |
104 | 103 | ||
105 | Config cfg("bluetoothmanager"); | 104 | Config cfg("bluetoothmanager"); |
106 | cfg.setGroup("bluezsettings"); | 105 | cfg.setGroup("bluezsettings"); |
107 | 106 | ||
108 | 107 | ||
109 | deviceName = cfg.readEntry("name", "No name"); // name the device should identify with | 108 | deviceName = cfg.readEntry("name", "No name"); // name the device should identify with |
110 | defaultPasskey = cfg.readEntryCrypt("passkey", ""); // <- hmm, look up how good the trolls did that, maybe too weak | 109 | defaultPasskey = cfg.readEntryCrypt("passkey", ""); // <- hmm, look up how good the trolls did that, maybe too weak |
111 | useEncryption = cfg.readNumEntry("useEncryption", 1); | 110 | useEncryption = cfg.readNumEntry("useEncryption", 1); |
112 | enableAuthentification = cfg.readNumEntry("enableAuthentification", 1); | 111 | enableAuthentification = cfg.readNumEntry("enableAuthentification", 1); |
113 | enablePagescan = cfg.readNumEntry("enablePagescan",1); | 112 | enablePagescan = cfg.readNumEntry("enablePagescan",1); |
114 | enableInquiryscan = cfg.readNumEntry("enableInquiryscan", 1); | 113 | enableInquiryscan = cfg.readNumEntry("enableInquiryscan", 1); |
115 | 114 | ||
116 | } | 115 | } |
117 | 116 | ||
118 | /** | 117 | /** |
119 | * Writes all options to the config file | 118 | * Writes all options to the config file |
120 | */ | 119 | */ |
121 | void BlueBase::writeConfig() { | 120 | void BlueBase::writeConfig() { |
122 | 121 | ||
123 | 122 | ||
124 | Config cfg("bluetoothmanager"); | 123 | Config cfg("bluetoothmanager"); |
125 | cfg.setGroup("bluezsettings"); | 124 | cfg.setGroup("bluezsettings"); |
126 | 125 | ||
127 | cfg.writeEntry("name", deviceName); | 126 | cfg.writeEntry("name", deviceName); |
128 | cfg.writeEntryCrypt("passkey", defaultPasskey); | 127 | cfg.writeEntryCrypt("passkey", defaultPasskey); |
129 | cfg.writeEntry("useEncryption", useEncryption); | 128 | cfg.writeEntry("useEncryption", useEncryption); |
130 | cfg.writeEntry("enableAuthentification", enableAuthentification); | 129 | cfg.writeEntry("enableAuthentification", enableAuthentification); |
131 | cfg.writeEntry("enablePagescan",enablePagescan); | 130 | cfg.writeEntry("enablePagescan",enablePagescan); |
132 | cfg.writeEntry("enableInquiryscan", enableInquiryscan); | 131 | cfg.writeEntry("enableInquiryscan", enableInquiryscan); |
133 | } | 132 | } |
134 | 133 | ||
135 | 134 | ||
136 | /* | 135 | /* |
137 | * Read the list of allready known devices | 136 | * Read the list of allready known devices |
138 | * | 137 | * |
139 | */ | 138 | */ |
140 | void BlueBase::readSavedDevices() { | 139 | void BlueBase::readSavedDevices() { |
141 | 140 | ||
142 | QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; | 141 | QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; |
143 | 142 | ||
144 | Config deviceList( QDir::homeDirPath() + "/Settings/bluetooth/devicelist.conf", Config::File ); | 143 | Config deviceList( QDir::homeDirPath() + "/Settings/bluetooth/devicelist.conf", Config::File ); |
145 | 144 | ||
146 | 145 | ||
147 | // RemoteDevice *currentDevice = RemoteDevice( , ); | 146 | // RemoteDevice *currentDevice = RemoteDevice( , ); |
148 | //loadedDevices->append( currentDevice ); | 147 | //loadedDevices->append( currentDevice ); |
149 | 148 | ||
150 | addSearchedDevices( *loadedDevices ); | 149 | addSearchedDevices( *loadedDevices ); |
151 | } | 150 | } |
152 | 151 | ||
153 | /* | 152 | /* |
154 | * Write the list of allready known devices | 153 | * Write the list of allready known devices |
155 | * | 154 | * |
156 | */ | 155 | */ |
157 | void BlueBase::writeSavedDevices() { | 156 | void BlueBase::writeSavedDevices() { |
158 | 157 | ||
159 | QListViewItemIterator it( ListView2 ); | 158 | QListViewItemIterator it( ListView2 ); |
160 | 159 | ||
161 | // one top conf file with all decices (by mac adress) | 160 | // one top conf file with all decices (by mac adress) |
162 | Config deviceList( QDir::homeDirPath() + "/Settings/bluetooth/devicelist.conf", Config::File ); | 161 | Config deviceList( QDir::homeDirPath() + "/Settings/bluetooth/devicelist.conf", Config::File ); |
163 | 162 | ||
164 | for ( ; it.current(); ++it ) { | 163 | for ( ; it.current(); ++it ) { |
165 | 164 | ||
166 | // MAC adress as group | 165 | // MAC adress as group |
167 | deviceList.setGroup( it.current()->text(1) ); | 166 | deviceList.setGroup( it.current()->text(1) ); |
168 | deviceList.writeEntry("inList", 1); | 167 | deviceList.writeEntry("inList", 1); |
169 | 168 | ||
170 | // seperate config file for each device, to store more information in future. | 169 | // seperate config file for each device, to store more information in future. |
171 | 170 | ||
172 | Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (it.current()->text(1)) + ".conf", Config::File ); | 171 | Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (it.current()->text(1)) + ".conf", Config::File ); |
173 | conf.setGroup("Info"); | 172 | conf.setGroup("Info"); |
174 | conf.writeEntry("name", it.current()->text(0) ); | 173 | conf.writeEntry("name", it.current()->text(0) ); |
175 | } | 174 | } |
176 | } | 175 | } |
177 | 176 | ||
178 | 177 | ||
179 | /** | 178 | /** |
180 | * Set up the gui | 179 | * Set up the gui |
181 | */ | 180 | */ |
182 | void BlueBase::initGui() { | 181 | void BlueBase::initGui() { |
183 | 182 | ||
184 | StatusLabel->setText(getStatus()); // maybe move it to getStatus() | 183 | StatusLabel->setText(getStatus()); // maybe move it to getStatus() |
185 | 184 | ||
186 | cryptCheckBox->setChecked(useEncryption); | 185 | cryptCheckBox->setChecked(useEncryption); |
187 | authCheckBox->setChecked(enableAuthentification); | 186 | authCheckBox->setChecked(enableAuthentification); |
188 | pagescanCheckBox->setChecked(enablePagescan); | 187 | pagescanCheckBox->setChecked(enablePagescan); |
189 | inquiryscanCheckBox->setChecked(enableInquiryscan); | 188 | inquiryscanCheckBox->setChecked(enableInquiryscan); |
190 | deviceNameLine->setText(deviceName); | 189 | deviceNameLine->setText(deviceName); |
191 | passkeyLine->setText(defaultPasskey); | 190 | passkeyLine->setText(defaultPasskey); |
192 | // set info tab | 191 | // set info tab |
193 | setInfo(); | 192 | setInfo(); |
194 | } | 193 | } |
195 | 194 | ||
196 | 195 | ||
197 | /** | 196 | /** |
198 | * Get the status informations and returns it | 197 | * Get the status informations and returns it |
199 | * @return QString the status informations gathered | 198 | * @return QString the status informations gathered |
200 | */ | 199 | */ |
201 | QString BlueBase::getStatus(){ | 200 | QString BlueBase::getStatus(){ |
202 | 201 | ||
203 | QString infoString = tr("<b>Device name : </b> Ipaq" ); | 202 | QString infoString = tr("<b>Device name : </b> Ipaq" ); |
204 | infoString += QString("<br><b>" + tr("MAC adress: ") +"</b> No idea"); | 203 | infoString += QString("<br><b>" + tr("MAC adress: ") +"</b> No idea"); |
205 | infoString += QString("<br><b>" + tr("Class") + "</b> PDA"); | 204 | infoString += QString("<br><b>" + tr("Class") + "</b> PDA"); |
206 | 205 | ||
207 | return (infoString); | 206 | return (infoString); |
208 | 207 | ||
209 | } | 208 | } |
210 | 209 | ||
211 | 210 | ||
212 | /** | 211 | /** |
213 | * Read the current values from the gui and invoke writeConfig() | 212 | * Read the current values from the gui and invoke writeConfig() |
214 | */ | 213 | */ |
215 | void BlueBase::applyConfigChanges() { | 214 | void BlueBase::applyConfigChanges() { |
216 | 215 | ||
217 | deviceName = deviceNameLine->text(); | 216 | deviceName = deviceNameLine->text(); |
218 | defaultPasskey = passkeyLine->text(); | 217 | defaultPasskey = passkeyLine->text(); |
219 | useEncryption = cryptCheckBox->isChecked(); | 218 | useEncryption = cryptCheckBox->isChecked(); |
220 | enableAuthentification = authCheckBox->isChecked(); | 219 | enableAuthentification = authCheckBox->isChecked(); |
221 | enablePagescan = pagescanCheckBox->isChecked(); | 220 | enablePagescan = pagescanCheckBox->isChecked(); |
222 | enableInquiryscan = inquiryscanCheckBox->isChecked(); | 221 | enableInquiryscan = inquiryscanCheckBox->isChecked(); |
223 | 222 | ||
224 | writeConfig(); | 223 | writeConfig(); |
225 | 224 | ||
226 | QMessageBox* box = new QMessageBox(this, "Test"); | 225 | QMessageBox* box = new QMessageBox(this, "Test"); |
227 | box->setText(tr("Changes applied")); | 226 | box->setText(tr("Changes applied")); |
228 | box->show(); | 227 | box->show(); |
229 | 228 | ||
230 | // falls nötig hcid killhupen - die funktionalität adden | 229 | // falls nötig hcid killhupen - die funktionalität adden |
231 | } | 230 | } |
232 | 231 | ||
233 | 232 | ||
234 | /* | 233 | /* |
235 | * Add fresh found devices from scan dialog to the listing | 234 | * Add fresh found devices from scan dialog to the listing |
236 | * | 235 | * |
237 | */ | 236 | */ |
238 | void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { | 237 | void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { |
239 | 238 | ||
240 | QListViewItem * deviceItem; | 239 | QListViewItem * deviceItem; |
241 | 240 | ||
242 | QListIterator<RemoteDevice> it(newDevices); | 241 | QListIterator<RemoteDevice> it(newDevices); |
243 | 242 | ||
244 | for( ; it.current(); ++it ) { | 243 | for( ; it.current(); ++it ) { |
245 | 244 | ||
246 | 245 | ||
247 | RemoteDevice *dev = it.current(); | 246 | RemoteDevice *dev = it.current(); |
248 | deviceItem = new QListViewItem( ListView2, dev->name() ); | 247 | deviceItem = new QListViewItem( ListView2, dev->name() ); |
249 | 248 | ||
250 | if (deviceActive( dev ) ) { | 249 | if (deviceActive( dev ) ) { |
251 | deviceItem->setPixmap(0, onPix); | 250 | deviceItem->setPixmap(0, onPix); |
252 | } else { | 251 | } else { |
253 | deviceItem->setPixmap(0, offPix); | 252 | deviceItem->setPixmap(0, offPix); |
254 | } | 253 | } |
255 | 254 | ||
256 | deviceItem->setText(1, dev->mac() ); | 255 | deviceItem->setText(1, dev->mac() ); |
257 | } | 256 | } |
258 | } | 257 | } |
259 | 258 | ||
260 | 259 | ||
261 | /* | 260 | /* |
262 | * Action that is toggled on entrys on click | 261 | * Action that is toggled on entrys on click |
263 | */ | 262 | */ |
264 | void BlueBase::startServiceActionClicked( QListViewItem * item ) { | 263 | void BlueBase::startServiceActionClicked( QListViewItem * item ) { |
265 | 264 | ||
266 | 265 | ||
267 | } | 266 | } |
268 | 267 | ||
269 | /* | 268 | /* |
270 | * Action that are toggled on hold (mostly QPopups i guess) | 269 | * Action that are toggled on hold (mostly QPopups i guess) |
271 | */ | 270 | */ |
272 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column) { | 271 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column) { |
273 | 272 | ||
274 | 273 | ||
275 | } | 274 | } |
276 | 275 | ||
277 | /* | 276 | /* |
278 | * Search and display avail. services for a device (on expand from device listing) | 277 | * Search and display avail. services for a device (on expand from device listing) |
279 | * | 278 | * |
280 | */ | 279 | */ |
281 | void BlueBase::addServicesToDevice( QListViewItem * item ) { | 280 | void BlueBase::addServicesToDevice( QListViewItem * item ) { |
282 | // row of mac adress | 281 | // row of mac adress |
283 | RemoteDevice *device = new RemoteDevice(item->text(1), item->text(0)); | 282 | RemoteDevice *device = new RemoteDevice(item->text(1), item->text(0)); |
284 | //dann nen manager und darauf dann searchServises, das liefert nen signal, das wieder connected | 283 | //dann nen manager und darauf dann searchServises, das liefert nen signal, das wieder connected |
285 | // werden muss. | 284 | // werden muss. |
286 | 285 | ||
287 | // delete | 286 | // delete |
288 | } | 287 | } |
289 | 288 | ||
290 | /* | 289 | /* |
291 | * Find out if a device can currently be reached | 290 | * Find out if a device can currently be reached |
292 | */ | 291 | */ |
293 | bool BlueBase::deviceActive( RemoteDevice *device ) { | 292 | bool BlueBase::deviceActive( RemoteDevice *device ) { |
294 | 293 | ||
295 | return true; | 294 | return true; |
296 | } | 295 | } |
297 | 296 | ||
298 | /** | 297 | /** |
299 | * Open the "scan for devices" dialog | 298 | * Open the "scan for devices" dialog |
300 | */ | 299 | */ |
301 | void BlueBase::startScan() { | 300 | void BlueBase::startScan() { |
302 | 301 | ||
303 | ScanDialog *scan = new ScanDialog( this, "", true); | 302 | ScanDialog *scan = new ScanDialog( this, "", true); |
304 | QObject::connect((QObject*)scan, SIGNAL( selectedDevices(QList<RemoteDevice>&) ), | 303 | QObject::connect( scan, SIGNAL( selectedDevices(QList<RemoteDevice>&) ), |
305 | this, SLOT( addSearchedDevices(QList<RemoteDevice>& ) )); | 304 | this, SLOT( addSearchedDevices(QList<RemoteDevice>& ) )); |
306 | 305 | ||
307 | scan->showMaximized(); | 306 | scan->showMaximized(); |
308 | } | 307 | } |
309 | 308 | ||
310 | 309 | ||
311 | void BlueBase::setInfo() { | 310 | void BlueBase::setInfo() { |
312 | StatusLabel->setText(getStatus()); | 311 | StatusLabel->setText(getStatus()); |
313 | } | 312 | } |
314 | 313 | ||
315 | /** | 314 | /** |
316 | * Decontructor | 315 | * Decontructor |
317 | */ | 316 | */ |
318 | BlueBase::~BlueBase(){ | 317 | BlueBase::~BlueBase(){ |
319 | writeSavedDevices(); | 318 | writeSavedDevices(); |
320 | } | 319 | } |
321 | 320 | ||
322 | } | 321 | } |
323 | 322 | ||
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp index bd7d23c..f8f7b15 100644 --- a/noncore/net/opietooth/manager/scandialog.cpp +++ b/noncore/net/opietooth/manager/scandialog.cpp | |||
@@ -1,169 +1,171 @@ | |||
1 | /* main.cpp | 1 | /* main.cpp |
2 | * | 2 | * |
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 | 18 | ||
19 | #include "scandialog.h" | 19 | #include "scandialog.h" |
20 | 20 | ||
21 | #include <qframe.h> | 21 | #include <qframe.h> |
22 | #include <qheader.h> | 22 | #include <qheader.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvariant.h> | 27 | #include <qvariant.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | #include <qprogressbar.h> | 30 | #include <qprogressbar.h> |
31 | #include <qlist.h> | 31 | #include <qlist.h> |
32 | 32 | ||
33 | #include <manager.h> | 33 | #include <manager.h> |
34 | #include <device.h> | 34 | #include <device.h> |
35 | 35 | ||
36 | 36 | ||
37 | 37 | ||
38 | namespace OpieTooth { | 38 | namespace OpieTooth { |
39 | 39 | ||
40 | #include <remotedevice.h> | 40 | #include <remotedevice.h> |
41 | 41 | ||
42 | /* | 42 | /* |
43 | */ | 43 | */ |
44 | ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 44 | ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
45 | : QDialog( parent, name, modal, fl ) { | 45 | : QDialog( parent, name, modal, fl ) { |
46 | 46 | ||
47 | if ( !name ) | 47 | if ( !name ) |
48 | setName( "ScanDialog" ); | 48 | setName( "ScanDialog" ); |
49 | resize( 240, 320 ); | 49 | resize( 240, 320 ); |
50 | setCaption( tr( "Scan for devices" ) ); | 50 | setCaption( tr( "Scan for devices" ) ); |
51 | 51 | ||
52 | Frame7 = new QFrame( this, "Frame7" ); | 52 | Frame7 = new QFrame( this, "Frame7" ); |
53 | Frame7->setGeometry( QRect( 0, 0, 240, 331 ) ); | 53 | Frame7->setGeometry( QRect( 0, 0, 240, 331 ) ); |
54 | Frame7->setFrameShape( QFrame::StyledPanel ); | 54 | Frame7->setFrameShape( QFrame::StyledPanel ); |
55 | Frame7->setFrameShadow( QFrame::Raised ); | 55 | Frame7->setFrameShadow( QFrame::Raised ); |
56 | 56 | ||
57 | QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); | 57 | QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); |
58 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); | 58 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); |
59 | Layout11 = new QVBoxLayout( privateLayoutWidget ); | 59 | Layout11 = new QVBoxLayout( privateLayoutWidget ); |
60 | Layout11->setSpacing( 6 ); | 60 | Layout11->setSpacing( 6 ); |
61 | Layout11->setMargin( 0 ); | 61 | Layout11->setMargin( 0 ); |
62 | 62 | ||
63 | progress = new QProgressBar(privateLayoutWidget, "progbar"); | 63 | progress = new QProgressBar(privateLayoutWidget, "progbar"); |
64 | progress->setTotalSteps(20); | 64 | progress->setTotalSteps(20); |
65 | 65 | ||
66 | QFrame *buttonFrame = new QFrame(Frame7, ""); | 66 | QFrame *buttonFrame = new QFrame(Frame7, ""); |
67 | 67 | ||
68 | StartButton = new QPushButton( buttonFrame, "StartButton" ); | 68 | StartButton = new QPushButton( buttonFrame, "StartButton" ); |
69 | StartButton->setText( tr( "Start scan" ) ); | 69 | StartButton->setText( tr( "Start scan" ) ); |
70 | 70 | ||
71 | StopButton = new QPushButton( buttonFrame, "StopButton" ); | 71 | StopButton = new QPushButton( buttonFrame, "StopButton" ); |
72 | StopButton->setText( tr( "Cancel scan" ) ); | 72 | StopButton->setText( tr( "Cancel scan" ) ); |
73 | 73 | ||
74 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); | 74 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); |
75 | 75 | ||
76 | buttonLayout->addWidget(StartButton); | 76 | buttonLayout->addWidget(StartButton); |
77 | buttonLayout->addWidget(StopButton); | 77 | buttonLayout->addWidget(StopButton); |
78 | 78 | ||
79 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); | 79 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); |
80 | 80 | ||
81 | //ListView1->addColumn( tr( "Add" ) ); | 81 | //ListView1->addColumn( tr( "Add" ) ); |
82 | ListView1->addColumn( tr( "Add Device" ) ); | 82 | ListView1->addColumn( tr( "Add Device" ) ); |
83 | //ListView1->addColumn( tr( "Type" ) ); | 83 | //ListView1->addColumn( tr( "Type" ) ); |
84 | 84 | ||
85 | Layout11->addWidget( ListView1); | 85 | Layout11->addWidget( ListView1); |
86 | Layout11->addWidget(progress); | 86 | Layout11->addWidget(progress); |
87 | Layout11->addWidget( buttonFrame); | 87 | Layout11->addWidget( buttonFrame); |
88 | 88 | ||
89 | localDevice = new Manager( "hci0" ); | 89 | localDevice = new Manager( "hci0" ); |
90 | 90 | ||
91 | connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); | 91 | connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); |
92 | connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); | 92 | connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); |
93 | connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), | 93 | connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), |
94 | this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; | 94 | this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; |
95 | progressStat = 0; | 95 | progressStat = 0; |
96 | } | 96 | } |
97 | 97 | ||
98 | // hack, make cleaner later | 98 | // hack, make cleaner later |
99 | void ScanDialog::progressTimer() { | 99 | void ScanDialog::progressTimer() { |
100 | 100 | ||
101 | progressStat++; | 101 | progressStat++; |
102 | if (progressStat++ < 20) { | 102 | if (progressStat++ < 20) { |
103 | QTimer::singleShot( 1000, this, SLOT(progressTimer() ) ); | 103 | QTimer::singleShot( 1000, this, SLOT(progressTimer() ) ); |
104 | } | 104 | } |
105 | progress->setProgress(progressStat++); | 105 | progress->setProgress(progressStat++); |
106 | 106 | ||
107 | } | 107 | } |
108 | 108 | ||
109 | void ScanDialog::startSearch() { | 109 | void ScanDialog::startSearch() { |
110 | progress->setProgress(0); | 110 | progress->setProgress(0); |
111 | progressStat = 0; | 111 | progressStat = 0; |
112 | 112 | ||
113 | QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); | 113 | QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); |
114 | deviceItem2->setText(1, "BLAH" ); | 114 | deviceItem2->setText(1, "BLAH" ); |
115 | 115 | ||
116 | progressTimer(); | 116 | progressTimer(); |
117 | // when finished, it emmite foundDevices() | 117 | // when finished, it emmite foundDevices() |
118 | // checken ob initialisiert , qcop ans applet. | 118 | // checken ob initialisiert , qcop ans applet. |
119 | localDevice->searchDevices(); | 119 | localDevice->searchDevices(); |
120 | 120 | ||
121 | } | 121 | } |
122 | 122 | ||
123 | void ScanDialog::stopSearch() { | 123 | void ScanDialog::stopSearch() { |
124 | 124 | ||
125 | } | 125 | } |
126 | 126 | ||
127 | void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) { | 127 | void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) { |
128 | 128 | ||
129 | QCheckListItem * deviceItem; | 129 | QCheckListItem * deviceItem; |
130 | 130 | ||
131 | RemoteDevice::ValueList::Iterator it; | 131 | RemoteDevice::ValueList::Iterator it; |
132 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 132 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
133 | 133 | ||
134 | deviceItem = new QCheckListItem( ListView1, (*it).name() ); | 134 | deviceItem = new QCheckListItem( ListView1, (*it).name() ); |
135 | deviceItem->setText(1, (*it).mac() ); | 135 | deviceItem->setText(1, (*it).mac() ); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | /* | 139 | /* |
140 | * Iterates trough the items, and collects the checked items. | 140 | * Iterates trough the items, and collects the checked items. |
141 | * Then it emits it, so the manager can connect to the signal to fill the listing. | 141 | * Then it emits it, so the manager can connect to the signal to fill the listing. |
142 | */ | 142 | */ |
143 | void ScanDialog::emitToManager() { | 143 | void ScanDialog::emitToManager() { |
144 | 144 | ||
145 | if (!ListView1) { | 145 | if (!ListView1) { |
146 | return; | 146 | return; |
147 | } | 147 | } |
148 | 148 | ||
149 | QList<RemoteDevice> *deviceList = new QList<RemoteDevice>; | 149 | QList<RemoteDevice> *deviceList = new QList<RemoteDevice>; |
150 | deviceList->setAutoDelete(true); | ||
150 | 151 | ||
151 | QListViewItemIterator it( ListView1 ); | 152 | QListViewItemIterator it( ListView1 ); |
152 | for ( ; it.current(); ++it ) { | 153 | for ( ; it.current(); ++it ) { |
153 | if ( ((QCheckListItem*)it.current())->isOn() ) { | 154 | if ( ((QCheckListItem*)it.current())->isOn() ) { |
154 | RemoteDevice * device = new RemoteDevice( it.current()->text(1), it.current()->text(0)); | 155 | RemoteDevice * device = new RemoteDevice( it.current()->text(1), it.current()->text(0)); |
155 | deviceList->append( device ); | 156 | deviceList->append( device ); |
156 | } | 157 | } |
157 | } | 158 | } |
158 | emit selectedDevices( *deviceList ); | 159 | emit selectedDevices( *deviceList ); |
160 | delete deviceList; | ||
159 | } | 161 | } |
160 | 162 | ||
161 | /* | 163 | /* |
162 | * Cleanup | 164 | * Cleanup |
163 | */ | 165 | */ |
164 | ScanDialog::~ScanDialog() { | 166 | ScanDialog::~ScanDialog() { |
165 | emitToManager(); | 167 | emitToManager(); |
166 | delete localDevice; | 168 | delete localDevice; |
167 | } | 169 | } |
168 | 170 | ||
169 | } | 171 | } |