summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-06-19 22:36:08 (UTC)
committer harlekin <harlekin>2002-06-19 22:36:08 (UTC)
commitce6d4880d3d78fb569322c14e425654785de980d (patch) (unidiff)
treee1515034b27b6a07b879031fbebac8126c184000
parent3cff4da41a61679e0222be190af8a98682f07393 (diff)
downloadopie-ce6d4880d3d78fb569322c14e425654785de980d.zip
opie-ce6d4880d3d78fb569322c14e425654785de980d.tar.gz
opie-ce6d4880d3d78fb569322c14e425654785de980d.tar.bz2
update
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp20
-rw-r--r--noncore/net/opietooth/manager/scandialog.cpp2
2 files changed, 11 insertions, 11 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 6328b59..7a92dc3 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -1,359 +1,359 @@
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 20
21#include <qframe.h> 21#include <qframe.h>
22#include <qlabel.h> 22#include <qlabel.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qvariant.h> 25#include <qvariant.h>
26#include <qwhatsthis.h> 26#include <qwhatsthis.h>
27#include <qimage.h> 27#include <qimage.h>
28#include <qpixmap.h> 28#include <qpixmap.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qscrollview.h> 30#include <qscrollview.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmessagebox.h> 32#include <qmessagebox.h>
33#include <qapplication.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 38
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40#include <qpe/config.h> 40#include <qpe/config.h>
41 41
42#include <remotedevice.h> 42#include <remotedevice.h>
43 43
44 44
45namespace OpieTooth { 45namespace OpieTooth {
46 46
47 47
48 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 48 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
49 : BluetoothBase( parent, name, fl ) { 49 : BluetoothBase( parent, name, fl ) {
50 50
51 localDevice = new Manager( "hci0" ); 51 localDevice = new Manager( "hci0" );
52 52
53 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 53 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
54 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 54 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
55 connect( ListView2, SIGNAL( expanded ( QListViewItem *item ) ), 55 connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ),
56 this, SLOT( addServicesToDevice( QListViewItem *item ) ) ); 56 this, SLOT( addServicesToDevice( QListViewItem * ) ) );
57 connect( ListView2, SIGNAL( clicked( QListViewItem* )), 57 connect( ListView2, SIGNAL( clicked( QListViewItem* )),
58 this, SLOT( startServiceActionClicked( QListViewItem *item ) ) ); 58 this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
59 connect( localDevice, SIGNAL( foundServices( const QString& device, Services::ValueList ) ), 59 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
60 this, SLOT( addServicesToDevice( const QString& device, Services::ValueList ) ) ); 60 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
61 61
62 62
63 //Load all icons needed 63 //Load all icons needed
64 64
65 65
66 QPixmap offPix = Resource::loadPixmap( "editdelete" ); 66 offPix = Resource::loadPixmap( "editdelete" );
67 QPixmap onPix = Resource::loadPixmap( "installed" ); 67 onPix = Resource::loadPixmap( "installed" );
68 68
69 QPalette pal = this->palette(); 69 QPalette pal = this->palette();
70 QColor col = pal.color(QPalette::Active, QColorGroup::Background); 70 QColor col = pal.color(QPalette::Active, QColorGroup::Background);
71 pal.setColor(QPalette::Active, QColorGroup::Button, col); 71 pal.setColor(QPalette::Active, QColorGroup::Button, col);
72 pal.setColor(QPalette::Inactive, QColorGroup::Button, col); 72 pal.setColor(QPalette::Inactive, QColorGroup::Button, col);
73 pal.setColor(QPalette::Normal, QColorGroup::Button, col); 73 pal.setColor(QPalette::Normal, QColorGroup::Button, col);
74 pal.setColor(QPalette::Disabled, QColorGroup::Button, col); 74 pal.setColor(QPalette::Disabled, QColorGroup::Button, col);
75 this->setPalette(pal); 75 this->setPalette(pal);
76 76
77 setCaption( tr( "Bluetooth Manager" ) ); 77 setCaption( tr( "Bluetooth Manager" ) );
78 78
79 readConfig(); 79 readConfig();
80 initGui(); 80 initGui();
81 81
82 82
83 //TESTING 83 //TESTING
84 84
85 ListView2->setRootIsDecorated(true); 85 ListView2->setRootIsDecorated(true);
86 86
87 QListViewItem *topLV = new QListViewItem( ListView2, "Harlekins Dongle" , "yes"); 87 QListViewItem *topLV = new QListViewItem( ListView2, "Harlekins Dongle" , "yes");
88 topLV->setPixmap( 0, offPix ); 88 topLV->setPixmap( 1, offPix );
89 // (void) new QListViewItem( topLV, "on" ); 89 // (void) new QListViewItem( topLV, "on" );
90 //(void) new QListViewItem( topLV, "off" ); 90 //(void) new QListViewItem( topLV, "off" );
91 91
92 QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" ); 92 QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" );
93 topLV2->setPixmap( 0, onPix ); 93 topLV2->setPixmap( 1, onPix );
94 (void) new QListViewItem( topLV2, "on" ); 94 (void) new QListViewItem( topLV2, "on" );
95 (void) new QListViewItem( topLV2, "off" ); 95 (void) new QListViewItem( topLV2, "off" );
96 96
97 } 97 }
98 98
99 99
100 /** 100 /**
101 * Reads all options from the config file 101 * Reads all options from the config file
102 */ 102 */
103 void BlueBase::readConfig() { 103 void BlueBase::readConfig() {
104 104
105 Config cfg( "bluetoothmanager" ); 105 Config cfg( "bluetoothmanager" );
106 cfg.setGroup( "bluezsettings" ); 106 cfg.setGroup( "bluezsettings" );
107 107
108 108
109 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 109 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 110 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
111 useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); 111 useEncryption = cfg.readNumEntry( "useEncryption" , 1 );
112 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); 112 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 );
113 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); 113 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 );
114 enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); 114 enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 );
115 115
116 } 116 }
117 117
118 /** 118 /**
119 * Writes all options to the config file 119 * Writes all options to the config file
120 */ 120 */
121 void BlueBase::writeConfig() { 121 void BlueBase::writeConfig() {
122 122
123 123
124 Config cfg( "bluetoothmanager" ); 124 Config cfg( "bluetoothmanager" );
125 cfg.setGroup( "bluezsettings" ); 125 cfg.setGroup( "bluezsettings" );
126 126
127 cfg.writeEntry( "name" , deviceName ); 127 cfg.writeEntry( "name" , deviceName );
128 cfg.writeEntryCrypt( "passkey" , defaultPasskey ); 128 cfg.writeEntryCrypt( "passkey" , defaultPasskey );
129 cfg.writeEntry( "useEncryption" , useEncryption ); 129 cfg.writeEntry( "useEncryption" , useEncryption );
130 cfg.writeEntry( "enableAuthentification" , enableAuthentification ); 130 cfg.writeEntry( "enableAuthentification" , enableAuthentification );
131 cfg.writeEntry( "enablePagescan" , enablePagescan ); 131 cfg.writeEntry( "enablePagescan" , enablePagescan );
132 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); 132 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan );
133} 133}
134 134
135 135
136 /* 136 /*
137 * Read the list of allready known devices 137 * Read the list of allready known devices
138 * 138 *
139 */ 139 */
140 void BlueBase::readSavedDevices() { 140 void BlueBase::readSavedDevices() {
141 141
142 QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; 142 QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>;
143 143
144 Config deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/devicelist.conf", Config::File ); 144 Config deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/devicelist.conf", Config::File );
145 145
146 146
147 // RemoteDevice *currentDevice = RemoteDevice( , ); 147 // RemoteDevice *currentDevice = RemoteDevice( , );
148 //loadedDevices->append( currentDevice ); 148 //loadedDevices->append( currentDevice );
149 149
150 addSearchedDevices( *loadedDevices ); 150 addSearchedDevices( *loadedDevices );
151 } 151 }
152 152
153 /* 153 /*
154 * Write the list of allready known devices 154 * Write the list of allready known devices
155 * 155 *
156 */ 156 */
157 void BlueBase::writeSavedDevices() { 157 void BlueBase::writeSavedDevices() {
158 158
159 QListViewItemIterator it( ListView2 ); 159 QListViewItemIterator it( ListView2 );
160 160
161 for ( ; it.current(); ++it ) { 161 for ( ; it.current(); ++it ) {
162 162
163 // seperate config file for each device, to store more information in future. 163 // seperate config file for each device, to store more information in future.
164 164
165 Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (it.current()->text(3)) + ".conf", Config::File ); 165 Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (it.current()->text(3)) + ".conf", Config::File );
166 conf.setGroup( "Info" ); 166 conf.setGroup( "Info" );
167 conf.writeEntry( "name", it.current()->text(0) ); 167 conf.writeEntry( "name", it.current()->text(0) );
168 } 168 }
169 } 169 }
170 170
171 171
172 /** 172 /**
173 * Set up the gui 173 * Set up the gui
174 */ 174 */
175 void BlueBase::initGui() { 175 void BlueBase::initGui() {
176 176
177 StatusLabel->setText(getStatus()); // maybe move it to getStatus() 177 StatusLabel->setText(getStatus()); // maybe move it to getStatus()
178 178
179 cryptCheckBox->setChecked(useEncryption); 179 cryptCheckBox->setChecked(useEncryption);
180 authCheckBox->setChecked(enableAuthentification); 180 authCheckBox->setChecked(enableAuthentification);
181 pagescanCheckBox->setChecked(enablePagescan); 181 pagescanCheckBox->setChecked(enablePagescan);
182 inquiryscanCheckBox->setChecked(enableInquiryscan); 182 inquiryscanCheckBox->setChecked(enableInquiryscan);
183 deviceNameLine->setText(deviceName); 183 deviceNameLine->setText(deviceName);
184 passkeyLine->setText(defaultPasskey); 184 passkeyLine->setText(defaultPasskey);
185 // set info tab 185 // set info tab
186 setInfo(); 186 setInfo();
187 } 187 }
188 188
189 189
190 /** 190 /**
191 * Get the status informations and returns it 191 * Get the status informations and returns it
192 * @return QString the status informations gathered 192 * @return QString the status informations gathered
193 */ 193 */
194 QString BlueBase::getStatus(){ 194 QString BlueBase::getStatus(){
195 195
196 QString infoString = tr("<b>Device name : </b> Ipaq" ); 196 QString infoString = tr("<b>Device name : </b> Ipaq" );
197 infoString += QString("<br><b>" + tr("MAC adress: ") +"</b> No idea"); 197 infoString += QString("<br><b>" + tr("MAC adress: ") +"</b> No idea");
198 infoString += QString("<br><b>" + tr("Class") + "</b> PDA"); 198 infoString += QString("<br><b>" + tr("Class") + "</b> PDA");
199 199
200 return (infoString); 200 return (infoString);
201 201
202 } 202 }
203 203
204 204
205 /** 205 /**
206 * Read the current values from the gui and invoke writeConfig() 206 * Read the current values from the gui and invoke writeConfig()
207 */ 207 */
208 void BlueBase::applyConfigChanges() { 208 void BlueBase::applyConfigChanges() {
209 209
210 deviceName = deviceNameLine->text(); 210 deviceName = deviceNameLine->text();
211 defaultPasskey = passkeyLine->text(); 211 defaultPasskey = passkeyLine->text();
212 useEncryption = cryptCheckBox->isChecked(); 212 useEncryption = cryptCheckBox->isChecked();
213 enableAuthentification = authCheckBox->isChecked(); 213 enableAuthentification = authCheckBox->isChecked();
214 enablePagescan = pagescanCheckBox->isChecked(); 214 enablePagescan = pagescanCheckBox->isChecked();
215 enableInquiryscan = inquiryscanCheckBox->isChecked(); 215 enableInquiryscan = inquiryscanCheckBox->isChecked();
216 216
217 writeConfig(); 217 writeConfig();
218 218
219 QMessageBox* box = new QMessageBox( this, "Test" ); 219 QMessageBox* box = new QMessageBox( this, "Test" );
220 box->setText( tr( "Changes applied" ) ); 220 box->setText( tr( "Changes applied" ) );
221 box->show(); 221 box->show();
222 222
223 // falls nötig hcid killhupen - die funktionalität adden 223 // falls nötig hcid killhupen - die funktionalität adden
224} 224}
225 225
226 226
227 /* 227 /*
228 * Add fresh found devices from scan dialog to the listing 228 * Add fresh found devices from scan dialog to the listing
229 * 229 *
230 */ 230 */
231 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { 231 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) {
232 232
233 QListViewItem * deviceItem; 233 QListViewItem * deviceItem;
234 234
235 QListIterator<RemoteDevice> it( newDevices ); 235 QListIterator<RemoteDevice> it( newDevices );
236 236
237 for( ; it.current() ; ++it ) { 237 for( ; it.current() ; ++it ) {
238 238
239 239
240 RemoteDevice *dev = it.current(); 240 RemoteDevice *dev = it.current();
241 deviceItem = new QListViewItem( ListView2 , dev->name() ); 241 deviceItem = new QListViewItem( ListView2 , dev->name() );
242 242
243 if ( deviceActive( dev ) ) { 243 if ( deviceActive( dev ) ) {
244 deviceItem->setPixmap( 1 , onPix ); 244 deviceItem->setPixmap( 1 , onPix );
245 } else { 245 } else {
246 deviceItem->setPixmap( 1, offPix ); 246 deviceItem->setPixmap( 1, offPix );
247 } 247 }
248 248
249 deviceItem->setText( 3, dev->mac() ); 249 deviceItem->setText( 3, dev->mac() );
250 250
251 // ggf auch hier? 251 // ggf auch hier?
252 addServicesToDevice( deviceItem ); 252 addServicesToDevice( deviceItem );
253 } 253 }
254 } 254 }
255 255
256 256
257 /* 257 /*
258 * Action that is toggled on entrys on click 258 * Action that is toggled on entrys on click
259 */ 259 */
260 void BlueBase::startServiceActionClicked( QListViewItem * item ) { 260 void BlueBase::startServiceActionClicked( QListViewItem *item ) {
261 261
262 262
263 } 263 }
264 264
265 /* 265 /*
266 * Action that are toggled on hold (mostly QPopups i guess) 266 * Action that are toggled on hold (mostly QPopups i guess)
267 */ 267 */
268 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { 268 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) {
269 269
270 270
271 } 271 }
272 272
273 /* 273 /*
274 * Search and display avail. services for a device (on expand from device listing) 274 * Search and display avail. services for a device (on expand from device listing)
275 * 275 *
276 */ 276 */
277 void BlueBase::addServicesToDevice( QListViewItem * item ) { 277 void BlueBase::addServicesToDevice( QListViewItem * item ) {
278 278
279 qDebug("addServicesToDevice"); 279 qDebug("addServicesToDevice");
280 // row of mac adress 280 // row of mac adress
281 RemoteDevice *device = new RemoteDevice(item->text(3), item->text(0)); 281 RemoteDevice *device = new RemoteDevice(item->text(3), item->text(0));
282 282
283 deviceList.insert( item->text(3) , item ); 283 deviceList.insert( item->text(3) , item );
284 284
285// and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 285// and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
286 localDevice->searchServices( *device ); 286 localDevice->searchServices( *device );
287 287
288 // delete 288 // delete
289 } 289 }
290 290
291 291
292 /** 292 /**
293 * Overloaded. This one it the one that is connected to the foundServices signal 293 * Overloaded. This one it the one that is connected to the foundServices signal
294 * @param device the mac address of the remote device 294 * @param device the mac address of the remote device
295 * @param servicesList the list with the service the device has. 295 * @param servicesList the list with the service the device has.
296 */ 296 */
297 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 297 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
298 298
299 qDebug("fill services list"); 299 qDebug("fill services list");
300 300
301 301
302 QMap<QString,QListViewItem*>::Iterator it; 302 QMap<QString,QListViewItem*>::Iterator it;
303 303
304 QListViewItem* deviceItem; 304 QListViewItem* deviceItem;
305 305
306 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 306 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
307 if (it.key() == device ) { 307 if (it.key() == device ) {
308 deviceItem = it.data(); 308 deviceItem = it.data();
309 } 309 }
310 } 310 }
311 311
312 QValueList<OpieTooth::Services>::Iterator it2; 312 QValueList<OpieTooth::Services>::Iterator it2;
313 313
314 314
315 315
316 QListViewItem * serviceItem; 316 QListViewItem * serviceItem;
317 317
318 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 318 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
319// it2.serviceName() 319// it2.serviceName()
320 serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() ); 320 serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() );
321 } 321 }
322 322
323 } 323 }
324 324
325 325
326 /* 326 /*
327 * Find out if a device can currently be reached 327 * Find out if a device can currently be reached
328 */ 328 */
329 bool BlueBase::deviceActive( RemoteDevice *device ) { 329 bool BlueBase::deviceActive( RemoteDevice *device ) {
330 return true; 330 return true;
331 } 331 }
332 332
333 333
334 /** 334 /**
335 * Open the "scan for devices" dialog 335 * Open the "scan for devices" dialog
336 */ 336 */
337 void BlueBase::startScan() { 337 void BlueBase::startScan() {
338 338
339 ScanDialog *scan = new ScanDialog( this, "", true); 339 ScanDialog *scan = new ScanDialog( this, "", true);
340 QObject::connect( scan, SIGNAL( selectedDevices(QList<RemoteDevice>&) ), 340 QObject::connect( scan, SIGNAL( selectedDevices(QList<RemoteDevice>&) ),
341 this, SLOT( addSearchedDevices(QList<RemoteDevice>& ) )); 341 this, SLOT( addSearchedDevices(QList<RemoteDevice>& ) ));
342 342
343 scan->showMaximized(); 343 scan->showMaximized();
344 } 344 }
345 345
346 346
347 void BlueBase::setInfo() { 347 void BlueBase::setInfo() {
348 StatusLabel->setText( getStatus() ); 348 StatusLabel->setText( getStatus() );
349 } 349 }
350 350
351 /** 351 /**
352 * Decontructor 352 * Decontructor
353 */ 353 */
354 BlueBase::~BlueBase() { 354 BlueBase::~BlueBase() {
355 writeSavedDevices(); 355 writeSavedDevices();
356 } 356 }
357 357
358} 358}
359 359
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp
index ec8df82..9520e73 100644
--- a/noncore/net/opietooth/manager/scandialog.cpp
+++ b/noncore/net/opietooth/manager/scandialog.cpp
@@ -1,180 +1,180 @@
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
38namespace OpieTooth { 38namespace 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( StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); 91 connect( StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) );
92 connect( StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); 92 connect( StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) );
93 connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ), 93 connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ),
94 this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ; 94 this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ;
95 // connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() )); 95 // connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() ));
96 progressStat = 0; 96 progressStat = 0;
97 } 97 }
98 98
99// hack, make cleaner later 99// hack, make cleaner later
100 void ScanDialog::progressTimer() { 100 void ScanDialog::progressTimer() {
101 101
102 progressStat++; 102 progressStat++;
103 if (progressStat++ < 20) { 103 if (progressStat++ < 20) {
104 QTimer::singleShot( 1000, this, SLOT(progressTimer() ) ); 104 QTimer::singleShot( 2000, this, SLOT(progressTimer() ) );
105 } 105 }
106 progress->setProgress(progressStat++); 106 progress->setProgress(progressStat++);
107 107
108 } 108 }
109 109
110 void ScanDialog::accept() { 110 void ScanDialog::accept() {
111 emitToManager(); 111 emitToManager();
112 QDialog::accept(); 112 QDialog::accept();
113 } 113 }
114 114
115 115
116 void ScanDialog::startSearch() { 116 void ScanDialog::startSearch() {
117 progress->setProgress(0); 117 progress->setProgress(0);
118 progressStat = 0; 118 progressStat = 0;
119 119
120 QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); 120 QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox );
121 deviceItem2->setText(1, "BLAH" ); 121 deviceItem2->setText(1, "BLAH" );
122 122
123 progressTimer(); 123 progressTimer();
124 // when finished, it emmite foundDevices() 124 // when finished, it emmite foundDevices()
125 // checken ob initialisiert , qcop ans applet. 125 // checken ob initialisiert , qcop ans applet.
126 localDevice->searchDevices(); 126 localDevice->searchDevices();
127 127
128 } 128 }
129 129
130 void ScanDialog::stopSearch() { 130 void ScanDialog::stopSearch() {
131 131
132 } 132 }
133 133
134 void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) { 134 void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) {
135 135
136 qDebug("fill List"); 136 qDebug("fill List");
137 QCheckListItem * deviceItem; 137 QCheckListItem * deviceItem;
138 138
139 RemoteDevice::ValueList::Iterator it; 139 RemoteDevice::ValueList::Iterator it;
140 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 140 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
141 141
142 deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox ); 142 deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox );
143 deviceItem->setText(1, (*it).mac() ); 143 deviceItem->setText(1, (*it).mac() );
144 } 144 }
145 } 145 }
146 146
147/* 147/*
148 * Iterates trough the items, and collects the checked items. 148 * Iterates trough the items, and collects the checked items.
149 * Then it emits it, so the manager can connect to the signal to fill the listing. 149 * Then it emits it, so the manager can connect to the signal to fill the listing.
150 */ 150 */
151 void ScanDialog::emitToManager() { 151 void ScanDialog::emitToManager() {
152 qDebug("vor liste durchsuchen"); 152 qDebug("vor liste durchsuchen");
153 153
154 if (!ListView1) { 154 if (!ListView1) {
155 return; 155 return;
156 } 156 }
157 157
158 QList<RemoteDevice> *deviceList = new QList<RemoteDevice>; 158 QList<RemoteDevice> *deviceList = new QList<RemoteDevice>;
159 deviceList->setAutoDelete(true); 159 deviceList->setAutoDelete(true);
160 160
161 QListViewItemIterator it( ListView1 ); 161 QListViewItemIterator it( ListView1 );
162 for ( ; it.current(); ++it ) { 162 for ( ; it.current(); ++it ) {
163 if ( ((QCheckListItem*)it.current())->isOn() ) { 163 if ( ((QCheckListItem*)it.current())->isOn() ) {
164 RemoteDevice * device = new RemoteDevice( it.current()->text(1), it.current()->text(0)); 164 RemoteDevice * device = new RemoteDevice( it.current()->text(1), it.current()->text(0));
165 deviceList->append( device ); 165 deviceList->append( device );
166 } 166 }
167 } 167 }
168 qDebug("vor emit"); 168 qDebug("vor emit");
169 emit selectedDevices( *deviceList ); 169 emit selectedDevices( *deviceList );
170 delete deviceList; 170 delete deviceList;
171 } 171 }
172 172
173/* 173/*
174 * Cleanup 174 * Cleanup
175 */ 175 */
176 ScanDialog::~ScanDialog() { 176 ScanDialog::~ScanDialog() {
177 delete localDevice; 177 delete localDevice;
178 } 178 }
179 179
180} 180}