summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-06-23 21:19:31 (UTC)
committer harlekin <harlekin>2002-06-23 21:19:31 (UTC)
commit8e6c9f9b93d5c95fe1a40689817e86d478a8c944 (patch) (unidiff)
tree8b08cd78ba324798d3a83b0da701bb803889bdb5
parenta4a8c8b51088f47b2c95cbf255e4b63865461c09 (diff)
downloadopie-8e6c9f9b93d5c95fe1a40689817e86d478a8c944.zip
opie-8e6c9f9b93d5c95fe1a40689817e86d478a8c944.tar.gz
opie-8e6c9f9b93d5c95fe1a40689817e86d478a8c944.tar.bz2
usual fault in connect .-(
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 910bb8c..af65f14 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -1,322 +1,322 @@
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#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
46namespace OpieTooth { 46namespace 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 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), 61 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ),
62 this, SLOT(startServiceActionHold( BTListItem *, const QPoint &, int) ) ); 62 this, SLOT(startServiceActionHold( BTListItem *, const QPoint &, int) ) );
63 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), 63 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
64 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); 64 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
65 connect( localDevice, SIGNAL( available( const QString& device, bool connected ) ), 65 connect( localDevice, SIGNAL( available( const QString&, bool ) ),
66 this, SLOT( deviceActive( const QString& mac, bool connected ) ) ); 66 this, SLOT( deviceActive( const QString& , bool ) ) );
67 67
68 //Load all icons needed 68 //Load all icons needed
69 69
70 offPix = Resource::loadPixmap( "editdelete" ); 70 offPix = Resource::loadPixmap( "editdelete" );
71 onPix = Resource::loadPixmap( "installed" ); 71 onPix = Resource::loadPixmap( "installed" );
72 72
73 QPalette pal = this->palette(); 73 QPalette pal = this->palette();
74 QColor col = pal.color( QPalette::Active, QColorGroup::Background ); 74 QColor col = pal.color( QPalette::Active, QColorGroup::Background );
75 pal.setColor( QPalette::Active, QColorGroup::Button, col ); 75 pal.setColor( QPalette::Active, QColorGroup::Button, col );
76 pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); 76 pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
77 pal.setColor( QPalette::Normal, QColorGroup::Button, col ); 77 pal.setColor( QPalette::Normal, QColorGroup::Button, col );
78 pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); 78 pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
79 this->setPalette( pal ); 79 this->setPalette( pal );
80 80
81 setCaption( tr( "Bluetooth Manager" ) ); 81 setCaption( tr( "Bluetooth Manager" ) );
82 82
83 readConfig(); 83 readConfig();
84 initGui(); 84 initGui();
85 85
86 //TESTING 86 //TESTING
87 ListView2->setRootIsDecorated(true); 87 ListView2->setRootIsDecorated(true);
88 88
89 BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); 89 BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" );
90 topLV2->setPixmap( 1, onPix ); 90 topLV2->setPixmap( 1, onPix );
91 (void) new BTListItem( topLV2, "Serial" ,"", "service" ); 91 (void) new BTListItem( topLV2, "Serial" ,"", "service" );
92 (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); 92 (void) new BTListItem( topLV2, "BlueNiC" , "", "service" );
93 } 93 }
94 94
95 95
96 /** 96 /**
97 * Reads all options from the config file 97 * Reads all options from the config file
98 */ 98 */
99 void BlueBase::readConfig() { 99 void BlueBase::readConfig() {
100 100
101 Config cfg( "bluetoothmanager" ); 101 Config cfg( "bluetoothmanager" );
102 cfg.setGroup( "bluezsettings" ); 102 cfg.setGroup( "bluezsettings" );
103 103
104 104
105 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 105 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 106 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
107 useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); 107 useEncryption = cfg.readNumEntry( "useEncryption" , 1 );
108 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); 108 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 );
109 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); 109 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 );
110 enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); 110 enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 );
111 111
112 } 112 }
113 113
114 /** 114 /**
115 * Writes all options to the config file 115 * Writes all options to the config file
116 */ 116 */
117 void BlueBase::writeConfig() { 117 void BlueBase::writeConfig() {
118 118
119 119
120 Config cfg( "bluetoothmanager" ); 120 Config cfg( "bluetoothmanager" );
121 cfg.setGroup( "bluezsettings" ); 121 cfg.setGroup( "bluezsettings" );
122 122
123 cfg.writeEntry( "name" , deviceName ); 123 cfg.writeEntry( "name" , deviceName );
124 cfg.writeEntryCrypt( "passkey" , defaultPasskey ); 124 cfg.writeEntryCrypt( "passkey" , defaultPasskey );
125 cfg.writeEntry( "useEncryption" , useEncryption ); 125 cfg.writeEntry( "useEncryption" , useEncryption );
126 cfg.writeEntry( "enableAuthentification" , enableAuthentification ); 126 cfg.writeEntry( "enableAuthentification" , enableAuthentification );
127 cfg.writeEntry( "enablePagescan" , enablePagescan ); 127 cfg.writeEntry( "enablePagescan" , enablePagescan );
128 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); 128 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan );
129} 129}
130 130
131 131
132 /** 132 /**
133 * Read the list of allready known devices 133 * Read the list of allready known devices
134 * 134 *
135 */ 135 */
136 void BlueBase::readSavedDevices() { 136 void BlueBase::readSavedDevices() {
137 137
138 QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; 138 QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>;
139 139
140 QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/"); 140 QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/");
141 // list of .conf files 141 // list of .conf files
142 QStringList devicesFileList = deviceListSave.entryList(); 142 QStringList devicesFileList = deviceListSave.entryList();
143 143
144 // cut .conf of to get the mac and also read the name entry in it. 144 // cut .conf of to get the mac and also read the name entry in it.
145 145
146 for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { 146 for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) {
147 147
148 QString name; 148 QString name;
149 QString mac; 149 QString mac;
150 qDebug((*it).latin1() ); 150 qDebug((*it).latin1() );
151 Config conf((*it)); 151 Config conf((*it));
152 conf.setGroup("Info"); 152 conf.setGroup("Info");
153 name = conf.readEntry("name", "Error"); 153 name = conf.readEntry("name", "Error");
154 qDebug("MAC: " + mac); 154 qDebug("MAC: " + mac);
155 qDebug("NAME: " + name); 155 qDebug("NAME: " + name);
156 RemoteDevice currentDevice = RemoteDevice( mac , name ); 156 RemoteDevice currentDevice = RemoteDevice( mac , name );
157 loadedDevices->append( &currentDevice ); 157 loadedDevices->append( &currentDevice );
158 } 158 }
159 addSearchedDevices( *loadedDevices ); 159 addSearchedDevices( *loadedDevices );
160 } 160 }
161 161
162 /** 162 /**
163 * Write the list of allready known devices 163 * Write the list of allready known devices
164 * 164 *
165 */ 165 */
166 void BlueBase::writeSavedDevices() { 166 void BlueBase::writeSavedDevices() {
167 167
168 QListViewItemIterator it( ListView2 ); 168 QListViewItemIterator it( ListView2 );
169 169
170 for ( ; it.current(); ++it ) { 170 for ( ; it.current(); ++it ) {
171 171
172 // seperate config file for each device, to store more information in future. 172 // seperate config file for each device, to store more information in future.
173// TO FIX: BTLISTITEM!!! 173// TO FIX: BTLISTITEM!!!
174 174
175 // Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem)it.current())->mac()) + ".conf", Config::File ); 175 // Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem)it.current())->mac()) + ".conf", Config::File );
176 // conf.setGroup( "Info" ); 176 // conf.setGroup( "Info" );
177 // conf.writeEntry( "name", it.current()->name() ); 177 // conf.writeEntry( "name", it.current()->name() );
178 } 178 }
179 } 179 }
180 180
181 181
182 /** 182 /**
183 * Set up the gui 183 * Set up the gui
184 */ 184 */
185 void BlueBase::initGui() { 185 void BlueBase::initGui() {
186 186
187 StatusLabel->setText( getStatus() ); // maybe move it to getStatus() 187 StatusLabel->setText( getStatus() ); // maybe move it to getStatus()
188 188
189 cryptCheckBox->setChecked( useEncryption ); 189 cryptCheckBox->setChecked( useEncryption );
190 authCheckBox->setChecked( enableAuthentification ); 190 authCheckBox->setChecked( enableAuthentification );
191 pagescanCheckBox->setChecked( enablePagescan ); 191 pagescanCheckBox->setChecked( enablePagescan );
192 inquiryscanCheckBox->setChecked( enableInquiryscan ); 192 inquiryscanCheckBox->setChecked( enableInquiryscan );
193 deviceNameLine->setText( deviceName ); 193 deviceNameLine->setText( deviceName );
194 passkeyLine->setText( defaultPasskey ); 194 passkeyLine->setText( defaultPasskey );
195 // set info tab 195 // set info tab
196 setInfo(); 196 setInfo();
197 } 197 }
198 198
199 199
200 /** 200 /**
201 * Get the status informations and returns it 201 * Get the status informations and returns it
202 * @return QString the status informations gathered 202 * @return QString the status informations gathered
203 */ 203 */
204 QString BlueBase::getStatus(){ 204 QString BlueBase::getStatus(){
205 205
206 QString infoString = tr( "<b>Device name : </b> Ipaq" ); 206 QString infoString = tr( "<b>Device name : </b> Ipaq" );
207 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); 207 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" );
208 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); 208 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" );
209 209
210 return (infoString); 210 return (infoString);
211 } 211 }
212 212
213 213
214 /** 214 /**
215 * Read the current values from the gui and invoke writeConfig() 215 * Read the current values from the gui and invoke writeConfig()
216 */ 216 */
217 void BlueBase::applyConfigChanges() { 217 void BlueBase::applyConfigChanges() {
218 218
219 deviceName = deviceNameLine->text(); 219 deviceName = deviceNameLine->text();
220 defaultPasskey = passkeyLine->text(); 220 defaultPasskey = passkeyLine->text();
221 useEncryption = cryptCheckBox->isChecked(); 221 useEncryption = cryptCheckBox->isChecked();
222 enableAuthentification = authCheckBox->isChecked(); 222 enableAuthentification = authCheckBox->isChecked();
223 enablePagescan = pagescanCheckBox->isChecked(); 223 enablePagescan = pagescanCheckBox->isChecked();
224 enableInquiryscan = inquiryscanCheckBox->isChecked(); 224 enableInquiryscan = inquiryscanCheckBox->isChecked();
225 225
226 writeConfig(); 226 writeConfig();
227 227
228 QMessageBox* box = new QMessageBox( this, "Test" ); 228 QMessageBox* box = new QMessageBox( this, "Test" );
229 box->setText( tr( "Changes applied" ) ); 229 box->setText( tr( "Changes applied" ) );
230 box->show(); 230 box->show();
231 // falls nötig hcid killhupen - die funktionalität adden 231 // falls nötig hcid killhupen - die funktionalität adden
232 } 232 }
233 233
234 234
235 /** 235 /**
236 * Add fresh found devices from scan dialog to the listing 236 * Add fresh found devices from scan dialog to the listing
237 * 237 *
238 */ 238 */
239 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { 239 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) {
240 240
241 BTListItem * deviceItem; 241 BTListItem * deviceItem;
242 242
243 QListIterator<RemoteDevice> it( newDevices ); 243 QListIterator<RemoteDevice> it( newDevices );
244 244
245 for( ; it.current() ; ++it ) { 245 for( ; it.current() ; ++it ) {
246 246
247 247
248 RemoteDevice *dev = it.current(); 248 RemoteDevice *dev = it.current();
249 deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" ); 249 deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" );
250 deviceItem->setExpandable ( true ); 250 deviceItem->setExpandable ( true );
251 251
252 // look if device is avail. atm, async 252 // look if device is avail. atm, async
253 deviceActive( dev ); 253 deviceActive( dev );
254 254
255 // move into the c'tor 255 // move into the c'tor
256 // deviceItem->setMac( dev->mac() ); 256 // deviceItem->setMac( dev->mac() );
257 // what kind of entry is it. 257 // what kind of entry is it.
258 //deviceItem->setType( "device"); 258 //deviceItem->setType( "device");
259 259
260 // ggf auch hier? 260 // ggf auch hier?
261 addServicesToDevice( deviceItem ); 261 addServicesToDevice( deviceItem );
262 } 262 }
263 } 263 }
264 264
265 265
266 /** 266 /**
267 * Action that is toggled on entrys on click 267 * Action that is toggled on entrys on click
268 */ 268 */
269 void BlueBase::startServiceActionClicked( QListViewItem *item ) { 269 void BlueBase::startServiceActionClicked( QListViewItem *item ) {
270 270
271 271
272 } 272 }
273 273
274 /** 274 /**
275 * Action that are toggled on hold (mostly QPopups i guess) 275 * Action that are toggled on hold (mostly QPopups i guess)
276 */ 276 */
277 void BlueBase::startServiceActionHold( BTListItem * item, const QPoint & point, int column ) { 277 void BlueBase::startServiceActionHold( BTListItem * item, const QPoint & point, int column ) {
278 278
279 QPopupMenu *menu = new QPopupMenu(); 279 QPopupMenu *menu = new QPopupMenu();
280 280
281 int ret=0; 281 int ret=0;
282 282
283 //QSize s = menu->sizeHint ( ); 283 //QSize s = menu->sizeHint ( );
284 284
285 if ( item->type() == "device") { 285 if ( item->type() == "device") {
286 286
287 QPopupMenu *groups = new QPopupMenu(); 287 QPopupMenu *groups = new QPopupMenu();
288 288
289 menu->insertItem( tr("rescan sevices:"), 0); 289 menu->insertItem( tr("rescan sevices:"), 0);
290 menu->insertItem( tr("to group"), groups , 1); 290 menu->insertItem( tr("to group"), groups , 1);
291 menu->insertItem( tr("delete"), 2); 291 menu->insertItem( tr("delete"), 2);
292 292
293 293
294 ret = menu->exec( point , 0); 294 ret = menu->exec( point , 0);
295 295
296 switch(ret) { 296 switch(ret) {
297 case 0: 297 case 0:
298 break; 298 break;
299 case 1: 299 case 1:
300 break; 300 break;
301 case 2: 301 case 2:
302 // delete childs too 302 // delete childs too
303 delete item; 303 delete item;
304 break; 304 break;
305 } 305 }
306 delete groups; 306 delete groups;
307 307
308 } else if ( item->type() == "service") { 308 } else if ( item->type() == "service") {
309 menu->insertItem( tr("Test1:"), 0); 309 menu->insertItem( tr("Test1:"), 0);
310 menu->insertItem( tr("connect"), 1); 310 menu->insertItem( tr("connect"), 1);
311 menu->insertItem( tr("delete"), 2); 311 menu->insertItem( tr("delete"), 2);
312 312
313 ret = menu->exec( point , 0); 313 ret = menu->exec( point , 0);
314 314
315 switch(ret) { 315 switch(ret) {
316 case 0: 316 case 0:
317 break; 317 break;
318 case 1: 318 case 1:
319 break; 319 break;
320 case 2: 320 case 2:
321 // delete childs too 321 // delete childs too
322 delete item; 322 delete item;