author | zecke <zecke> | 2002-06-28 16:30:08 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-28 16:30:08 (UTC) |
commit | e72d93a703f4b38109f8f02ec96a759d93b8f91c (patch) (unidiff) | |
tree | 39d6725fa1061965c64c42dabb663a3cfdc1c976 | |
parent | ce221c2cf5b003f1033e6f0b603670ceb0bff7c7 (diff) | |
download | opie-e72d93a703f4b38109f8f02ec96a759d93b8f91c.zip opie-e72d93a703f4b38109f8f02ec96a759d93b8f91c.tar.gz opie-e72d93a703f4b38109f8f02ec96a759d93b8f91c.tar.bz2 |
Don't leak
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index b4b59c3..0385cb1 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -1,360 +1,361 @@ | |||
1 | /* | 1 | /* |
2 | * bluebase.cpp * | 2 | * bluebase.cpp * |
3 | * --------------------- | 3 | * --------------------- |
4 | * | 4 | * |
5 | * copyright : (c) 2002 by Maximilian Reiß | 5 | * copyright : (c) 2002 by Maximilian Reiß |
6 | * email : max.reiss@gmx.de | 6 | * email : max.reiss@gmx.de |
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include "bluebase.h" | 18 | #include "bluebase.h" |
19 | #include "scandialog.h" | 19 | #include "scandialog.h" |
20 | #include "hciconfwrapper.h" | 20 | #include "hciconfwrapper.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 <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
36 | #include <qlistview.h> | 36 | #include <qlistview.h> |
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qpopupmenu.h> | 38 | #include <qpopupmenu.h> |
39 | 39 | ||
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/config.h> | 41 | #include <qpe/config.h> |
42 | 42 | ||
43 | #include <remotedevice.h> | 43 | #include <remotedevice.h> |
44 | 44 | ||
45 | 45 | ||
46 | namespace OpieTooth { | 46 | namespace OpieTooth { |
47 | 47 | ||
48 | 48 | ||
49 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 49 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
50 | : BluetoothBase( parent, name, fl ) { | 50 | : BluetoothBase( parent, name, fl ) { |
51 | 51 | ||
52 | localDevice = new Manager( "hci0" ); | 52 | localDevice = new Manager( "hci0" ); |
53 | 53 | ||
54 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 54 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
55 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 55 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
56 | // not good since lib is async | 56 | // not good since lib is async |
57 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), | 57 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), |
58 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); | 58 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); |
59 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), | 59 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), |
60 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); | 60 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); |
61 | // hehe, cast right later | 61 | // hehe, cast right later |
62 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), | 62 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), |
63 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); | 63 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); |
64 | connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), | 64 | connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), |
65 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); | 65 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); |
66 | connect( localDevice, SIGNAL( available( const QString&, bool ) ), | 66 | connect( localDevice, SIGNAL( available( const QString&, bool ) ), |
67 | this, SLOT( deviceActive( const QString& , bool ) ) ); | 67 | this, SLOT( deviceActive( const QString& , bool ) ) ); |
68 | 68 | ||
69 | //Load all icons needed | 69 | //Load all icons needed |
70 | 70 | ||
71 | offPix = Resource::loadPixmap( "editdelete" ); | 71 | offPix = Resource::loadPixmap( "editdelete" ); |
72 | onPix = Resource::loadPixmap( "installed" ); | 72 | onPix = Resource::loadPixmap( "installed" ); |
73 | 73 | ||
74 | QPalette pal = this->palette(); | 74 | QPalette pal = this->palette(); |
75 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); | 75 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); |
76 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); | 76 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); |
77 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); | 77 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); |
78 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); | 78 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); |
79 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); | 79 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); |
80 | this->setPalette( pal ); | 80 | this->setPalette( pal ); |
81 | 81 | ||
82 | setCaption( tr( "Bluetooth Manager" ) ); | 82 | setCaption( tr( "Bluetooth Manager" ) ); |
83 | 83 | ||
84 | readConfig(); | 84 | readConfig(); |
85 | initGui(); | 85 | initGui(); |
86 | 86 | ||
87 | //TESTING | 87 | //TESTING |
88 | ListView2->setRootIsDecorated(true); | 88 | ListView2->setRootIsDecorated(true); |
89 | 89 | ||
90 | BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); | 90 | BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); |
91 | topLV2->setPixmap( 1, onPix ); | 91 | topLV2->setPixmap( 1, onPix ); |
92 | (void) new BTListItem( topLV2, "Serial" ,"", "service" ); | 92 | (void) new BTListItem( topLV2, "Serial" ,"", "service" ); |
93 | (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); | 93 | (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); |
94 | writeToHciConfig(); | 94 | writeToHciConfig(); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | /** | 98 | /** |
99 | * Reads all options from the config file | 99 | * Reads all options from the config file |
100 | */ | 100 | */ |
101 | void BlueBase::readConfig() { | 101 | void BlueBase::readConfig() { |
102 | 102 | ||
103 | Config cfg( "bluetoothmanager" ); | 103 | Config cfg( "bluetoothmanager" ); |
104 | cfg.setGroup( "bluezsettings" ); | 104 | cfg.setGroup( "bluezsettings" ); |
105 | 105 | ||
106 | 106 | ||
107 | deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with | 107 | deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with |
108 | defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak | 108 | defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak |
109 | useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); | 109 | useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); |
110 | enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); | 110 | enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); |
111 | enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); | 111 | enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); |
112 | enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); | 112 | enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); |
113 | 113 | ||
114 | } | 114 | } |
115 | 115 | ||
116 | /** | 116 | /** |
117 | * Writes all options to the config file | 117 | * Writes all options to the config file |
118 | */ | 118 | */ |
119 | void BlueBase::writeConfig() { | 119 | void BlueBase::writeConfig() { |
120 | 120 | ||
121 | 121 | ||
122 | Config cfg( "bluetoothmanager" ); | 122 | Config cfg( "bluetoothmanager" ); |
123 | cfg.setGroup( "bluezsettings" ); | 123 | cfg.setGroup( "bluezsettings" ); |
124 | 124 | ||
125 | cfg.writeEntry( "name" , deviceName ); | 125 | cfg.writeEntry( "name" , deviceName ); |
126 | cfg.writeEntryCrypt( "passkey" , defaultPasskey ); | 126 | cfg.writeEntryCrypt( "passkey" , defaultPasskey ); |
127 | cfg.writeEntry( "useEncryption" , useEncryption ); | 127 | cfg.writeEntry( "useEncryption" , useEncryption ); |
128 | cfg.writeEntry( "enableAuthentification" , enableAuthentification ); | 128 | cfg.writeEntry( "enableAuthentification" , enableAuthentification ); |
129 | cfg.writeEntry( "enablePagescan" , enablePagescan ); | 129 | cfg.writeEntry( "enablePagescan" , enablePagescan ); |
130 | cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); | 130 | cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); |
131 | 131 | ||
132 | writeToHciConfig(); | 132 | writeToHciConfig(); |
133 | } | 133 | } |
134 | 134 | ||
135 | void BlueBase::writeToHciConfig() { | 135 | void BlueBase::writeToHciConfig() { |
136 | 136 | ||
137 | HciConfWrapper *hciconf = new HciConfWrapper( "/tmp/hcid.conf" ); | 137 | HciConfWrapper *hciconf = new HciConfWrapper( "/tmp/hcid.conf" ); |
138 | hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | 138 | hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); |
139 | 139 | ||
140 | 140 | ||
141 | // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | 141 | // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); |
142 | 142 | ||
143 | hciconf->setName( deviceName ); | 143 | hciconf->setName( deviceName ); |
144 | 144 | ||
145 | if ( useEncryption == 1) { | 145 | if ( useEncryption == 1) { |
146 | hciconf->setEncrypt( true ); | 146 | hciconf->setEncrypt( true ); |
147 | } else { | 147 | } else { |
148 | hciconf->setEncrypt( false ); | 148 | hciconf->setEncrypt( false ); |
149 | } | 149 | } |
150 | 150 | ||
151 | 151 | ||
152 | if ( enableAuthentification == 1) { | 152 | if ( enableAuthentification == 1) { |
153 | hciconf->setAuth( true ); | 153 | hciconf->setAuth( true ); |
154 | } else { | 154 | } else { |
155 | hciconf->setAuth( false ); | 155 | hciconf->setAuth( false ); |
156 | } | 156 | } |
157 | 157 | ||
158 | if ( enablePagescan == 1) { | 158 | if ( enablePagescan == 1) { |
159 | hciconf->setPscan( true ); | 159 | hciconf->setPscan( true ); |
160 | } else { | 160 | } else { |
161 | hciconf->setPscan( false ); | 161 | hciconf->setPscan( false ); |
162 | } | 162 | } |
163 | 163 | ||
164 | if ( enableInquiryscan == 1) { | 164 | if ( enableInquiryscan == 1) { |
165 | hciconf->setIscan( true ); | 165 | hciconf->setIscan( true ); |
166 | } else { | 166 | } else { |
167 | hciconf->setIscan( false ); | 167 | hciconf->setIscan( false ); |
168 | } | 168 | } |
169 | delete hciconf; | ||
169 | } | 170 | } |
170 | 171 | ||
171 | 172 | ||
172 | /** | 173 | /** |
173 | * Read the list of allready known devices | 174 | * Read the list of allready known devices |
174 | * | 175 | * |
175 | */ | 176 | */ |
176 | void BlueBase::readSavedDevices() { | 177 | void BlueBase::readSavedDevices() { |
177 | 178 | ||
178 | QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; | 179 | QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; |
179 | 180 | ||
180 | QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/"); | 181 | QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/"); |
181 | // list of .conf files | 182 | // list of .conf files |
182 | QStringList devicesFileList = deviceListSave.entryList(); | 183 | QStringList devicesFileList = deviceListSave.entryList(); |
183 | 184 | ||
184 | // cut .conf of to get the mac and also read the name entry in it. | 185 | // cut .conf of to get the mac and also read the name entry in it. |
185 | 186 | ||
186 | for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { | 187 | for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { |
187 | 188 | ||
188 | QString name; | 189 | QString name; |
189 | QString mac; | 190 | QString mac; |
190 | qDebug((*it).latin1() ); | 191 | qDebug((*it).latin1() ); |
191 | Config conf((*it)); | 192 | Config conf((*it)); |
192 | conf.setGroup("Info"); | 193 | conf.setGroup("Info"); |
193 | name = conf.readEntry("name", "Error"); | 194 | name = conf.readEntry("name", "Error"); |
194 | qDebug("MAC: " + mac); | 195 | qDebug("MAC: " + mac); |
195 | qDebug("NAME: " + name); | 196 | qDebug("NAME: " + name); |
196 | RemoteDevice currentDevice = RemoteDevice( mac , name ); | 197 | RemoteDevice currentDevice = RemoteDevice( mac , name ); |
197 | loadedDevices->append( ¤tDevice ); | 198 | loadedDevices->append( ¤tDevice ); |
198 | } | 199 | } |
199 | addSearchedDevices( *loadedDevices ); | 200 | addSearchedDevices( *loadedDevices ); |
200 | } | 201 | } |
201 | 202 | ||
202 | /** | 203 | /** |
203 | * Write the list of allready known devices | 204 | * Write the list of allready known devices |
204 | * | 205 | * |
205 | */ | 206 | */ |
206 | void BlueBase::writeSavedDevices() { | 207 | void BlueBase::writeSavedDevices() { |
207 | 208 | ||
208 | QListViewItemIterator it( ListView2 ); | 209 | QListViewItemIterator it( ListView2 ); |
209 | 210 | ||
210 | for ( ; it.current(); ++it ) { | 211 | for ( ; it.current(); ++it ) { |
211 | 212 | ||
212 | // seperate config file for each device, to store more information in future. | 213 | // seperate config file for each device, to store more information in future. |
213 | // TO FIX: BTLISTITEM!!! | 214 | // TO FIX: BTLISTITEM!!! |
214 | 215 | ||
215 | // Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem)it.current())->mac()) + ".conf", Config::File ); | 216 | // Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem)it.current())->mac()) + ".conf", Config::File ); |
216 | // conf.setGroup( "Info" ); | 217 | // conf.setGroup( "Info" ); |
217 | // conf.writeEntry( "name", it.current()->name() ); | 218 | // conf.writeEntry( "name", it.current()->name() ); |
218 | } | 219 | } |
219 | } | 220 | } |
220 | 221 | ||
221 | 222 | ||
222 | /** | 223 | /** |
223 | * Set up the gui | 224 | * Set up the gui |
224 | */ | 225 | */ |
225 | void BlueBase::initGui() { | 226 | void BlueBase::initGui() { |
226 | 227 | ||
227 | StatusLabel->setText( getStatus() ); // maybe move it to getStatus() | 228 | StatusLabel->setText( getStatus() ); // maybe move it to getStatus() |
228 | 229 | ||
229 | cryptCheckBox->setChecked( useEncryption ); | 230 | cryptCheckBox->setChecked( useEncryption ); |
230 | authCheckBox->setChecked( enableAuthentification ); | 231 | authCheckBox->setChecked( enableAuthentification ); |
231 | pagescanCheckBox->setChecked( enablePagescan ); | 232 | pagescanCheckBox->setChecked( enablePagescan ); |
232 | inquiryscanCheckBox->setChecked( enableInquiryscan ); | 233 | inquiryscanCheckBox->setChecked( enableInquiryscan ); |
233 | deviceNameLine->setText( deviceName ); | 234 | deviceNameLine->setText( deviceName ); |
234 | passkeyLine->setText( defaultPasskey ); | 235 | passkeyLine->setText( defaultPasskey ); |
235 | // set info tab | 236 | // set info tab |
236 | setInfo(); | 237 | setInfo(); |
237 | } | 238 | } |
238 | 239 | ||
239 | 240 | ||
240 | /** | 241 | /** |
241 | * Get the status informations and returns it | 242 | * Get the status informations and returns it |
242 | * @return QString the status informations gathered | 243 | * @return QString the status informations gathered |
243 | */ | 244 | */ |
244 | QString BlueBase::getStatus(){ | 245 | QString BlueBase::getStatus(){ |
245 | 246 | ||
246 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); | 247 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); |
247 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); | 248 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); |
248 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); | 249 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); |
249 | 250 | ||
250 | return (infoString); | 251 | return (infoString); |
251 | } | 252 | } |
252 | 253 | ||
253 | 254 | ||
254 | /** | 255 | /** |
255 | * Read the current values from the gui and invoke writeConfig() | 256 | * Read the current values from the gui and invoke writeConfig() |
256 | */ | 257 | */ |
257 | void BlueBase::applyConfigChanges() { | 258 | void BlueBase::applyConfigChanges() { |
258 | 259 | ||
259 | deviceName = deviceNameLine->text(); | 260 | deviceName = deviceNameLine->text(); |
260 | defaultPasskey = passkeyLine->text(); | 261 | defaultPasskey = passkeyLine->text(); |
261 | useEncryption = cryptCheckBox->isChecked(); | 262 | useEncryption = cryptCheckBox->isChecked(); |
262 | enableAuthentification = authCheckBox->isChecked(); | 263 | enableAuthentification = authCheckBox->isChecked(); |
263 | enablePagescan = pagescanCheckBox->isChecked(); | 264 | enablePagescan = pagescanCheckBox->isChecked(); |
264 | enableInquiryscan = inquiryscanCheckBox->isChecked(); | 265 | enableInquiryscan = inquiryscanCheckBox->isChecked(); |
265 | 266 | ||
266 | writeConfig(); | 267 | writeConfig(); |
267 | 268 | ||
268 | 269 | ||
269 | QMessageBox* box = new QMessageBox( this, "Test" ); | 270 | QMessageBox* box = new QMessageBox( this, "Test" ); |
270 | box->setText( tr( "Changes applied" ) ); | 271 | box->setText( tr( "Changes applied" ) ); |
271 | box->show(); | 272 | box->show(); |
272 | // falls nötig hcid killhupen - die funktionalität adden | 273 | // falls nötig hcid killhupen - die funktionalität adden |
273 | } | 274 | } |
274 | 275 | ||
275 | 276 | ||
276 | /** | 277 | /** |
277 | * Add fresh found devices from scan dialog to the listing | 278 | * Add fresh found devices from scan dialog to the listing |
278 | * | 279 | * |
279 | */ | 280 | */ |
280 | void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { | 281 | void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { |
281 | 282 | ||
282 | BTListItem * deviceItem; | 283 | BTListItem * deviceItem; |
283 | 284 | ||
284 | QListIterator<RemoteDevice> it( newDevices ); | 285 | QListIterator<RemoteDevice> it( newDevices ); |
285 | 286 | ||
286 | for( ; it.current() ; ++it ) { | 287 | for( ; it.current() ; ++it ) { |
287 | 288 | ||
288 | 289 | ||
289 | RemoteDevice *dev = it.current(); | 290 | RemoteDevice *dev = it.current(); |
290 | deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" ); | 291 | deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" ); |
291 | deviceItem->setExpandable ( true ); | 292 | deviceItem->setExpandable ( true ); |
292 | 293 | ||
293 | // look if device is avail. atm, async | 294 | // look if device is avail. atm, async |
294 | deviceActive( dev ); | 295 | deviceActive( dev ); |
295 | 296 | ||
296 | // move into the c'tor | 297 | // move into the c'tor |
297 | // deviceItem->setMac( dev->mac() ); | 298 | // deviceItem->setMac( dev->mac() ); |
298 | // what kind of entry is it. | 299 | // what kind of entry is it. |
299 | //deviceItem->setType( "device"); | 300 | //deviceItem->setType( "device"); |
300 | 301 | ||
301 | // ggf auch hier? | 302 | // ggf auch hier? |
302 | addServicesToDevice( deviceItem ); | 303 | addServicesToDevice( deviceItem ); |
303 | } | 304 | } |
304 | } | 305 | } |
305 | 306 | ||
306 | 307 | ||
307 | /** | 308 | /** |
308 | * Action that is toggled on entrys on click | 309 | * Action that is toggled on entrys on click |
309 | */ | 310 | */ |
310 | void BlueBase::startServiceActionClicked( QListViewItem *item ) { | 311 | void BlueBase::startServiceActionClicked( QListViewItem *item ) { |
311 | 312 | ||
312 | 313 | ||
313 | } | 314 | } |
314 | 315 | ||
315 | /** | 316 | /** |
316 | * Action that are toggled on hold (mostly QPopups i guess) | 317 | * Action that are toggled on hold (mostly QPopups i guess) |
317 | */ | 318 | */ |
318 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { | 319 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { |
319 | 320 | ||
320 | QPopupMenu *menu = new QPopupMenu(); | 321 | QPopupMenu *menu = new QPopupMenu(); |
321 | 322 | ||
322 | int ret=0; | 323 | int ret=0; |
323 | 324 | ||
324 | 325 | ||
325 | //QSize s = menu->sizeHint ( ); | 326 | //QSize s = menu->sizeHint ( ); |
326 | 327 | ||
327 | if ( ((BTListItem*)item)->type() == "device") { | 328 | if ( ((BTListItem*)item)->type() == "device") { |
328 | 329 | ||
329 | QPopupMenu *groups = new QPopupMenu(); | 330 | QPopupMenu *groups = new QPopupMenu(); |
330 | 331 | ||
331 | menu->insertItem( tr("rescan sevices:"), 0); | 332 | menu->insertItem( tr("rescan sevices:"), 0); |
332 | menu->insertItem( tr("to group"), groups , 1); | 333 | menu->insertItem( tr("to group"), groups , 1); |
333 | menu->insertItem( tr("delete"), 2); | 334 | menu->insertItem( tr("delete"), 2); |
334 | 335 | ||
335 | 336 | ||
336 | ret = menu->exec( point , 0); | 337 | ret = menu->exec( point , 0); |
337 | 338 | ||
338 | switch(ret) { | 339 | switch(ret) { |
339 | case 0: | 340 | case 0: |
340 | break; | 341 | break; |
341 | case 1: | 342 | case 1: |
342 | break; | 343 | break; |
343 | case 2: | 344 | case 2: |
344 | // delete childs too | 345 | // delete childs too |
345 | delete item; | 346 | delete item; |
346 | break; | 347 | break; |
347 | } | 348 | } |
348 | delete groups; | 349 | delete groups; |
349 | 350 | ||
350 | } else if ( ((BTListItem*)item)->type() == "service") { | 351 | } else if ( ((BTListItem*)item)->type() == "service") { |
351 | menu->insertItem( tr("Test1:"), 0); | 352 | menu->insertItem( tr("Test1:"), 0); |
352 | menu->insertItem( tr("connect"), 1); | 353 | menu->insertItem( tr("connect"), 1); |
353 | menu->insertItem( tr("delete"), 2); | 354 | menu->insertItem( tr("delete"), 2); |
354 | 355 | ||
355 | ret = menu->exec( point , 0); | 356 | ret = menu->exec( point , 0); |
356 | 357 | ||
357 | switch(ret) { | 358 | switch(ret) { |
358 | case 0: | 359 | case 0: |
359 | break; | 360 | break; |
360 | case 1: | 361 | case 1: |