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