summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth
authorharlekin <harlekin>2002-06-23 09:10:55 (UTC)
committer harlekin <harlekin>2002-06-23 09:10:55 (UTC)
commit1d773d5df7038410c498d38a68a9569c1350975a (patch) (unidiff)
treea14334997864cf5b01302e9aa05c0c09c72a86b3 /noncore/net/opietooth
parente9f053439c8409ea2e1e57de9bf6f764f994b222 (diff)
downloadopie-1d773d5df7038410c498d38a68a9569c1350975a.zip
opie-1d773d5df7038410c498d38a68a9569c1350975a.tar.gz
opie-1d773d5df7038410c498d38a68a9569c1350975a.tar.bz2
small load save update
Diffstat (limited to 'noncore/net/opietooth') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 5d742b7..cc51405 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -58,49 +58,48 @@ namespace OpieTooth {
58 this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); 58 this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
59 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), 59 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
60 this, SLOT( addServicesToDevice( const QString& , 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 offPix = Resource::loadPixmap( "editdelete" ); 66 offPix = Resource::loadPixmap( "editdelete" );
67 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
83 //TESTING 82 //TESTING
84 ListView2->setRootIsDecorated(true); 83 ListView2->setRootIsDecorated(true);
85 84
86 QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" ); 85 QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" );
87 topLV2->setPixmap( 1, onPix ); 86 topLV2->setPixmap( 1, onPix );
88 (void) new QListViewItem( topLV2, "Serial" ); 87 (void) new QListViewItem( topLV2, "Serial" );
89 (void) new QListViewItem( topLV2, "BlueNiC" ); 88 (void) new QListViewItem( topLV2, "BlueNiC" );
90 } 89 }
91 90
92 91
93 /** 92 /**
94 * Reads all options from the config file 93 * Reads all options from the config file
95 */ 94 */
96 void BlueBase::readConfig() { 95 void BlueBase::readConfig() {
97 96
98 Config cfg( "bluetoothmanager" ); 97 Config cfg( "bluetoothmanager" );
99 cfg.setGroup( "bluezsettings" ); 98 cfg.setGroup( "bluezsettings" );
100 99
101 100
102 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 101 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
103 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak 102 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
104 useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); 103 useEncryption = cfg.readNumEntry( "useEncryption" , 1 );
105 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); 104 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 );
106 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); 105 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 );
@@ -113,54 +112,67 @@ namespace OpieTooth {
113 */ 112 */
114 void BlueBase::writeConfig() { 113 void BlueBase::writeConfig() {
115 114
116 115
117 Config cfg( "bluetoothmanager" ); 116 Config cfg( "bluetoothmanager" );
118 cfg.setGroup( "bluezsettings" ); 117 cfg.setGroup( "bluezsettings" );
119 118
120 cfg.writeEntry( "name" , deviceName ); 119 cfg.writeEntry( "name" , deviceName );
121 cfg.writeEntryCrypt( "passkey" , defaultPasskey ); 120 cfg.writeEntryCrypt( "passkey" , defaultPasskey );
122 cfg.writeEntry( "useEncryption" , useEncryption ); 121 cfg.writeEntry( "useEncryption" , useEncryption );
123 cfg.writeEntry( "enableAuthentification" , enableAuthentification ); 122 cfg.writeEntry( "enableAuthentification" , enableAuthentification );
124 cfg.writeEntry( "enablePagescan" , enablePagescan ); 123 cfg.writeEntry( "enablePagescan" , enablePagescan );
125 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); 124 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan );
126} 125}
127 126
128 127
129 /** 128 /**
130 * Read the list of allready known devices 129 * Read the list of allready known devices
131 * 130 *
132 */ 131 */
133 void BlueBase::readSavedDevices() { 132 void BlueBase::readSavedDevices() {
134 133
135 QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; 134 QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>;
136 135
137 Config deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/devicelist.conf", Config::File ); 136 QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/");
137 // list of .conf files
138 QStringList devicesFileList = deviceListSave.entryList();
138 139
140 // cut .conf of to get the mac and also read the name entry in it.
139 141
140 // RemoteDevice *currentDevice = RemoteDevice( , ); 142 for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) {
141 //loadedDevices->append( currentDevice );
142 143
144 QString name;
145 QString mac;
146 qDebug((*it).latin1() );
147 Config conf((*it));
148 conf.setGroup("Info");
149 name = conf.readEntry("name", "Error");
150 qDebug("MAC: " + mac);
151 qDebug("NAME: " + name);
152 RemoteDevice currentDevice = RemoteDevice( mac , name );
153 loadedDevices->append( &currentDevice );
154 }
143 addSearchedDevices( *loadedDevices ); 155 addSearchedDevices( *loadedDevices );
144 } 156 }
145 157
146 /** 158 /**
147 * Write the list of allready known devices 159 * Write the list of allready known devices
148 * 160 *
149 */ 161 */
150 void BlueBase::writeSavedDevices() { 162 void BlueBase::writeSavedDevices() {
151 163
152 QListViewItemIterator it( ListView2 ); 164 QListViewItemIterator it( ListView2 );
153 165
154 for ( ; it.current(); ++it ) { 166 for ( ; it.current(); ++it ) {
155 167
156 // seperate config file for each device, to store more information in future. 168 // seperate config file for each device, to store more information in future.
157 169
158 Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (it.current()->text(3)) + ".conf", Config::File ); 170 Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (it.current()->text(3)) + ".conf", Config::File );
159 conf.setGroup( "Info" ); 171 conf.setGroup( "Info" );
160 conf.writeEntry( "name", it.current()->text(0) ); 172 conf.writeEntry( "name", it.current()->text(0) );
161 } 173 }
162 } 174 }
163 175
164 176
165 /** 177 /**
166 * Set up the gui 178 * Set up the gui
@@ -170,201 +182,194 @@ namespace OpieTooth {
170 StatusLabel->setText( getStatus() ); // maybe move it to getStatus() 182 StatusLabel->setText( getStatus() ); // maybe move it to getStatus()
171 183
172 cryptCheckBox->setChecked( useEncryption ); 184 cryptCheckBox->setChecked( useEncryption );
173 authCheckBox->setChecked( enableAuthentification ); 185 authCheckBox->setChecked( enableAuthentification );
174 pagescanCheckBox->setChecked( enablePagescan ); 186 pagescanCheckBox->setChecked( enablePagescan );
175 inquiryscanCheckBox->setChecked( enableInquiryscan ); 187 inquiryscanCheckBox->setChecked( enableInquiryscan );
176 deviceNameLine->setText( deviceName ); 188 deviceNameLine->setText( deviceName );
177 passkeyLine->setText( defaultPasskey ); 189 passkeyLine->setText( defaultPasskey );
178 // set info tab 190 // set info tab
179 setInfo(); 191 setInfo();
180 } 192 }
181 193
182 194
183 /** 195 /**
184 * Get the status informations and returns it 196 * Get the status informations and returns it
185 * @return QString the status informations gathered 197 * @return QString the status informations gathered
186 */ 198 */
187 QString BlueBase::getStatus(){ 199 QString BlueBase::getStatus(){
188 200
189 QString infoString = tr( "<b>Device name : </b> Ipaq" ); 201 QString infoString = tr( "<b>Device name : </b> Ipaq" );
190 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); 202 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" );
191 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); 203 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" );
192 204
193 return (infoString); 205 return (infoString);
194
195 } 206 }
196 207
197 208
198 /** 209 /**
199 * Read the current values from the gui and invoke writeConfig() 210 * Read the current values from the gui and invoke writeConfig()
200 */ 211 */
201 void BlueBase::applyConfigChanges() { 212 void BlueBase::applyConfigChanges() {
202 213
203 deviceName = deviceNameLine->text(); 214 deviceName = deviceNameLine->text();
204 defaultPasskey = passkeyLine->text(); 215 defaultPasskey = passkeyLine->text();
205 useEncryption = cryptCheckBox->isChecked(); 216 useEncryption = cryptCheckBox->isChecked();
206 enableAuthentification = authCheckBox->isChecked(); 217 enableAuthentification = authCheckBox->isChecked();
207 enablePagescan = pagescanCheckBox->isChecked(); 218 enablePagescan = pagescanCheckBox->isChecked();
208 enableInquiryscan = inquiryscanCheckBox->isChecked(); 219 enableInquiryscan = inquiryscanCheckBox->isChecked();
209 220
210 writeConfig(); 221 writeConfig();
211 222
212 QMessageBox* box = new QMessageBox( this, "Test" ); 223 QMessageBox* box = new QMessageBox( this, "Test" );
213 box->setText( tr( "Changes applied" ) ); 224 box->setText( tr( "Changes applied" ) );
214 box->show(); 225 box->show();
215
216 // falls nötig hcid killhupen - die funktionalität adden 226 // falls nötig hcid killhupen - die funktionalität adden
217 } 227 }
218 228
219 229
220 /** 230 /**
221 * Add fresh found devices from scan dialog to the listing 231 * Add fresh found devices from scan dialog to the listing
222 * 232 *
223 */ 233 */
224 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { 234 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) {
225 235
226 QListViewItem * deviceItem; 236 QListViewItem * deviceItem;
227 237
228 QListIterator<RemoteDevice> it( newDevices ); 238 QListIterator<RemoteDevice> it( newDevices );
229 239
230 for( ; it.current() ; ++it ) { 240 for( ; it.current() ; ++it ) {
231 241
232 242
233 RemoteDevice *dev = it.current(); 243 RemoteDevice *dev = it.current();
234 deviceItem = new QListViewItem( ListView2 , dev->name() ); 244 deviceItem = new QListViewItem( ListView2 , dev->name() );
235 deviceItem->setExpandable ( true ); 245 deviceItem->setExpandable ( true );
236 246
237 if ( deviceActive( dev ) ) { 247 if ( deviceActive( dev ) ) {
238 deviceItem->setPixmap( 1 , onPix ); 248 deviceItem->setPixmap( 1 , onPix );
239 } else { 249 } else {
240 deviceItem->setPixmap( 1, offPix ); 250 deviceItem->setPixmap( 1, offPix );
241 } 251 }
242 252
243 deviceItem->setText( 3, dev->mac() ); 253 deviceItem->setText( 3, dev->mac() );
244 254
245 // ggf auch hier? 255 // ggf auch hier?
246 addServicesToDevice( deviceItem ); 256 addServicesToDevice( deviceItem );
247 } 257 }
248 } 258 }
249 259
250 260
251 /** 261 /**
252 * Action that is toggled on entrys on click 262 * Action that is toggled on entrys on click
253 */ 263 */
254 void BlueBase::startServiceActionClicked( QListViewItem *item ) { 264 void BlueBase::startServiceActionClicked( QListViewItem *item ) {
255 265
256 266
257 } 267 }
258 268
259 /** 269 /**
260 * Action that are toggled on hold (mostly QPopups i guess) 270 * Action that are toggled on hold (mostly QPopups i guess)
261 */ 271 */
262 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { 272 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) {
263 273
264
265 } 274 }
266 275
267 /** 276 /**
268 * 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)
269 * 278 *
270 */ 279 */
271 void BlueBase::addServicesToDevice( QListViewItem * item ) { 280 void BlueBase::addServicesToDevice( QListViewItem * item ) {
272 281
273 qDebug("addServicesToDevice"); 282 qDebug("addServicesToDevice");
274 // row of mac adress 283 // row of mac adress
275 RemoteDevice *device = new RemoteDevice( item->text(3), item->text(0) ); 284 RemoteDevice *device = new RemoteDevice( item->text(3), item->text(0) );
276 285
277 deviceList.insert( item->text(3) , item ); 286 deviceList.insert( item->text(3) , item );
278 287
279 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 288 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
280 localDevice->searchServices( *device ); 289 localDevice->searchServices( *device );
281 290
282 // delete 291 // delete
283 } 292 }
284 293
285 294
286 /** 295 /**
287 * Overloaded. This one it the one that is connected to the foundServices signal 296 * Overloaded. This one it the one that is connected to the foundServices signal
288 * @param device the mac address of the remote device 297 * @param device the mac address of the remote device
289 * @param servicesList the list with the service the device has. 298 * @param servicesList the list with the service the device has.
290 */ 299 */
291 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 300 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
292 301
293 qDebug("fill services list"); 302 qDebug("fill services list");
294 303
295 304
296 QMap<QString,QListViewItem*>::Iterator it; 305 QMap<QString,QListViewItem*>::Iterator it;
297 306
298 QListViewItem* deviceItem; 307 QListViewItem* deviceItem;
299 308
300 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 309 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
301 if ( it.key() == device ) { 310 if ( it.key() == device ) {
302 deviceItem = it.data(); 311 deviceItem = it.data();
303 } 312 }
304 } 313 }
305 314
306 QValueList<OpieTooth::Services>::Iterator it2; 315 QValueList<OpieTooth::Services>::Iterator it2;
307 316
308
309
310 QListViewItem * serviceItem; 317 QListViewItem * serviceItem;
311 318
312 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 319 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
313 serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() ); 320 serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() );
314 } 321 }
315 } 322 }
316 323
317 324
318 /** 325 /**
319 * Add the existing connections (pairs) to the connections tab. 326 * Add the existing connections (pairs) to the connections tab.
320 * 327 *
321 */ 328 */
322 void BlueBase::addConnectedDevices() { 329 void BlueBase::addConnectedDevices() {
323 330
324 331
325 //mac address 332 //mac address
326 333
327 } 334 }
328 335
329 /** 336 /**
330 * Find out if a device can currently be reached 337 * Find out if a device can currently be reached
331 */ 338 */
332 bool BlueBase::deviceActive( RemoteDevice *device ) { 339 bool BlueBase::deviceActive( RemoteDevice *device ) {
333 340
334 // search by mac 341 // search by mac
335 //
336 localDevice->isAvailable( device->mac() ); 342 localDevice->isAvailable( device->mac() );
337 343
338 return true; 344 return true;
339 } 345 }
340 346
341 347
342 /** 348 /**
343 * Open the "scan for devices" dialog 349 * Open the "scan for devices" dialog
344 */ 350 */
345 void BlueBase::startScan() { 351 void BlueBase::startScan() {
346 352
347 ScanDialog *scan = new ScanDialog( this, "", true); 353 ScanDialog *scan = new ScanDialog( this, "", true);
348 QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ), 354 QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ),
349 this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) ); 355 this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) );
350 356
351 scan->showMaximized(); 357 scan->showMaximized();
352 } 358 }
353 359
354 360
355 /** 361 /**
356 * Set the informations about the local device in information Tab 362 * Set the informations about the local device in information Tab
357 */ 363 */
358 void BlueBase::setInfo() { 364 void BlueBase::setInfo() {
359 StatusLabel->setText( getStatus() ); 365 StatusLabel->setText( getStatus() );
360 } 366 }
361 367
362 /** 368 /**
363 * Decontructor 369 * Decontructor
364 */ 370 */
365 BlueBase::~BlueBase() { 371 BlueBase::~BlueBase() {
366 writeSavedDevices(); 372 writeSavedDevices();
367 } 373 }
368
369} 374}
370 375