author | zecke <zecke> | 2002-07-08 17:58:50 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-07-08 17:58:50 (UTC) |
commit | 35d0ca5cc59b82af7b7ddb343ec092c3171b11ef (patch) (unidiff) | |
tree | 8a7dac4bef44014c262c4b5549697229cbecc084 | |
parent | 078242aa3182fa98582a4881767f3aa1ff22b165 (diff) | |
download | opie-35d0ca5cc59b82af7b7ddb343ec092c3171b11ef.zip opie-35d0ca5cc59b82af7b7ddb343ec092c3171b11ef.tar.gz opie-35d0ca5cc59b82af7b7ddb343ec092c3171b11ef.tar.bz2 |
fix memleaks
fix possible crashes
clean up
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 162 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 28 |
2 files changed, 81 insertions, 109 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 2001db1..ff6981b 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -46,3 +46,3 @@ | |||
46 | 46 | ||
47 | namespace OpieTooth { | 47 | using namespace OpieTooth; |
48 | 48 | ||
@@ -51,3 +51,3 @@ namespace OpieTooth { | |||
51 | 51 | ||
52 | localDevice = new Manager( "hci0" ); | 52 | m_localDevice = new Manager( "hci0" ); |
53 | 53 | ||
@@ -62,7 +62,7 @@ namespace OpieTooth { | |||
62 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); | 62 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); |
63 | connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), | 63 | connect( m_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&, bool ) ), | 65 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), |
66 | this, SLOT( deviceActive( const QString& , bool ) ) ); | 66 | this, SLOT( deviceActive( const QString& , bool ) ) ); |
67 | connect( localDevice, SIGNAL( connections( Connection::ValueList ) ), | 67 | connect( m_localDevice, SIGNAL( connections( Connection::ValueList ) ), |
68 | this, SLOT( addConnectedDevices( Connection::ValueList ) ) ); | 68 | this, SLOT( addConnectedDevices( Connection::ValueList ) ) ); |
@@ -70,4 +70,4 @@ namespace OpieTooth { | |||
70 | //Load all icons needed | 70 | //Load all icons needed |
71 | offPix = Resource::loadPixmap( "editdelete" ); | 71 | m_offPix = Resource::loadPixmap( "editdelete" ); |
72 | onPix = Resource::loadPixmap( "installed" ); | 72 | m_onPix = Resource::loadPixmap( "installed" ); |
73 | 73 | ||
@@ -90,3 +90,3 @@ namespace OpieTooth { | |||
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, m_onPix ); |
92 | (void) new BTListItem( topLV2, "Serial" ,"", "service" ); | 92 | (void) new BTListItem( topLV2, "Serial" ,"", "service" ); |
@@ -97,3 +97,3 @@ namespace OpieTooth { | |||
97 | addConnectedDevices(); | 97 | addConnectedDevices(); |
98 | iconLoader = new BTIconLoader(); | 98 | m_iconLoader = new BTIconLoader(); |
99 | } | 99 | } |
@@ -108,8 +108,8 @@ namespace OpieTooth { | |||
108 | 108 | ||
109 | deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with | 109 | m_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 | m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak |
111 | useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); | 111 | m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); |
112 | enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); | 112 | m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); |
113 | enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); | 113 | m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); |
114 | enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); | 114 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); |
115 | } | 115 | } |
@@ -124,8 +124,8 @@ namespace OpieTooth { | |||
124 | 124 | ||
125 | cfg.writeEntry( "name" , deviceName ); | 125 | cfg.writeEntry( "name" , m_deviceName ); |
126 | cfg.writeEntryCrypt( "passkey" , defaultPasskey ); | 126 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); |
127 | cfg.writeEntry( "useEncryption" , useEncryption ); | 127 | cfg.writeEntry( "useEncryption" , m_useEncryption ); |
128 | cfg.writeEntry( "enableAuthentification" , enableAuthentification ); | 128 | cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); |
129 | cfg.writeEntry( "enablePagescan" , enablePagescan ); | 129 | cfg.writeEntry( "enablePagescan" , m_enablePagescan ); |
130 | cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); | 130 | cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); |
131 | 131 | ||
@@ -136,4 +136,4 @@ namespace OpieTooth { | |||
136 | 136 | ||
137 | HciConfWrapper *hciconf = new HciConfWrapper( "/tmp/hcid.conf" ); | 137 | HciConfWrapper hciconf ( "/tmp/hcid.conf" ); |
138 | hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | 138 | hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); |
139 | 139 | ||
@@ -142,29 +142,7 @@ namespace OpieTooth { | |||
142 | 142 | ||
143 | hciconf->setName( deviceName ); | 143 | hciconf.setName( m_deviceName ); |
144 | 144 | hciconf.setEncrypt( m_useEncryption ); | |
145 | if ( useEncryption == 1) { | 145 | hciconf.setAuth( m_enableAuthentification ); |
146 | hciconf->setEncrypt( true ); | 146 | hciconf.setPscan( m_enablePagescan ); |
147 | } else { | 147 | hciconf.setIscan( m_enableInquiryscan ); |
148 | hciconf->setEncrypt( false ); | ||
149 | } | ||
150 | |||
151 | |||
152 | if ( enableAuthentification == 1) { | ||
153 | hciconf->setAuth( true ); | ||
154 | } else { | ||
155 | hciconf->setAuth( false ); | ||
156 | } | ||
157 | |||
158 | if ( enablePagescan == 1) { | ||
159 | hciconf->setPscan( true ); | ||
160 | } else { | ||
161 | hciconf->setPscan( false ); | ||
162 | } | ||
163 | |||
164 | if ( enableInquiryscan == 1) { | ||
165 | hciconf->setIscan( true ); | ||
166 | } else { | ||
167 | hciconf->setIscan( false ); | ||
168 | } | ||
169 | delete hciconf; | ||
170 | } | 148 | } |
@@ -178,3 +156,3 @@ namespace OpieTooth { | |||
178 | 156 | ||
179 | QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; | 157 | QValueList<RemoteDevice> loadedDevices; |
180 | 158 | ||
@@ -196,6 +174,6 @@ namespace OpieTooth { | |||
196 | qDebug("NAME: " + name); | 174 | qDebug("NAME: " + name); |
197 | RemoteDevice currentDevice = RemoteDevice( mac , name ); | 175 | RemoteDevice currentDevice( mac , name ); |
198 | loadedDevices->append( ¤tDevice ); | 176 | loadedDevices.append( currentDevice ); |
199 | } | 177 | } |
200 | addSearchedDevices( *loadedDevices ); | 178 | addSearchedDevices( loadedDevices ); |
201 | } | 179 | } |
@@ -223,9 +201,9 @@ namespace OpieTooth { | |||
223 | void BlueBase::initGui() { | 201 | void BlueBase::initGui() { |
224 | StatusLabel->setText( getStatus() ); // maybe move it to getStatus() | 202 | StatusLabel->setText( status() ); // maybe move it to getStatus() |
225 | cryptCheckBox->setChecked( useEncryption ); | 203 | cryptCheckBox->setChecked( m_useEncryption ); |
226 | authCheckBox->setChecked( enableAuthentification ); | 204 | authCheckBox->setChecked( m_enableAuthentification ); |
227 | pagescanCheckBox->setChecked( enablePagescan ); | 205 | pagescanCheckBox->setChecked( m_enablePagescan ); |
228 | inquiryscanCheckBox->setChecked( enableInquiryscan ); | 206 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); |
229 | deviceNameLine->setText( deviceName ); | 207 | deviceNameLine->setText( m_deviceName ); |
230 | passkeyLine->setText( defaultPasskey ); | 208 | passkeyLine->setText( m_defaultPasskey ); |
231 | // set info tab | 209 | // set info tab |
@@ -239,3 +217,3 @@ namespace OpieTooth { | |||
239 | */ | 217 | */ |
240 | QString BlueBase::getStatus(){ | 218 | QString BlueBase::status()const{ |
241 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); | 219 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); |
@@ -252,8 +230,8 @@ namespace OpieTooth { | |||
252 | void BlueBase::applyConfigChanges() { | 230 | void BlueBase::applyConfigChanges() { |
253 | deviceName = deviceNameLine->text(); | 231 | m_deviceName = deviceNameLine->text(); |
254 | defaultPasskey = passkeyLine->text(); | 232 | m_defaultPasskey = passkeyLine->text(); |
255 | useEncryption = cryptCheckBox->isChecked(); | 233 | m_useEncryption = cryptCheckBox->isChecked(); |
256 | enableAuthentification = authCheckBox->isChecked(); | 234 | m_enableAuthentification = authCheckBox->isChecked(); |
257 | enablePagescan = pagescanCheckBox->isChecked(); | 235 | m_enablePagescan = pagescanCheckBox->isChecked(); |
258 | enableInquiryscan = inquiryscanCheckBox->isChecked(); | 236 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); |
259 | 237 | ||
@@ -261,5 +239,3 @@ namespace OpieTooth { | |||
261 | 239 | ||
262 | QMessageBox* box = new QMessageBox( this, "Test" ); | 240 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); |
263 | box->setText( tr( "Changes applied" ) ); | ||
264 | box->show(); | ||
265 | } | 241 | } |
@@ -270,10 +246,8 @@ namespace OpieTooth { | |||
270 | */ | 246 | */ |
271 | void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { | 247 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { |
272 | BTListItem * deviceItem; | 248 | BTListItem * deviceItem; |
273 | QListIterator<RemoteDevice> it( newDevices ); | 249 | QValueList<RemoteDevice>::ConstIterator it; |
274 | |||
275 | for( ; it.current() ; ++it ) { | ||
276 | 250 | ||
277 | RemoteDevice *dev = it.current(); | 251 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { |
278 | deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" ); | 252 | deviceItem = new BTListItem( ListView2 , (*it).name(), (*it).mac(), "device" ); |
279 | deviceItem->setExpandable ( true ); | 253 | deviceItem->setExpandable ( true ); |
@@ -281,3 +255,3 @@ namespace OpieTooth { | |||
281 | // look if device is avail. atm, async | 255 | // look if device is avail. atm, async |
282 | deviceActive( dev ); | 256 | deviceActive( (*it) ); |
283 | 257 | ||
@@ -292,3 +266,3 @@ namespace OpieTooth { | |||
292 | */ | 266 | */ |
293 | void BlueBase::startServiceActionClicked( QListViewItem *item ) { | 267 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { |
294 | } | 268 | } |
@@ -298,3 +272,3 @@ namespace OpieTooth { | |||
298 | */ | 272 | */ |
299 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { | 273 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { |
300 | 274 | ||
@@ -357,7 +331,6 @@ namespace OpieTooth { | |||
357 | // row of mac adress text(3) | 331 | // row of mac adress text(3) |
358 | RemoteDevice *device = new RemoteDevice( item->mac(), item->name() ); | 332 | RemoteDevice device( item->mac(), item->name() ); |
359 | deviceList.insert( item->mac() , item ); | 333 | m_deviceList.insert( item->mac() , item ); |
360 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 334 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
361 | localDevice->searchServices( *device ); | 335 | m_localDevice->searchServices( device ); |
362 | delete device; | ||
363 | } | 336 | } |
@@ -377,3 +350,3 @@ namespace OpieTooth { | |||
377 | // get the right devices which requested the search | 350 | // get the right devices which requested the search |
378 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 351 | for( it = m_deviceList.begin(); it != m_deviceList.end(); ++it ) { |
379 | if ( it.key() == device ) { | 352 | if ( it.key() == device ) { |
@@ -390,3 +363,3 @@ namespace OpieTooth { | |||
390 | serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); | 363 | serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); |
391 | serviceItem->setPixmap( 0, iconLoader->serviceIcon( (*it2).classIdList() ) ); | 364 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( (*it2).classIdList() ) ); |
392 | } | 365 | } |
@@ -403,3 +376,3 @@ namespace OpieTooth { | |||
403 | void BlueBase::addConnectedDevices() { | 376 | void BlueBase::addConnectedDevices() { |
404 | localDevice->searchConnections(); | 377 | m_localDevice->searchConnections(); |
405 | } | 378 | } |
@@ -427,5 +400,5 @@ namespace OpieTooth { | |||
427 | */ | 400 | */ |
428 | void BlueBase::deviceActive( RemoteDevice *device ) { | 401 | void BlueBase::deviceActive( const RemoteDevice &device ) { |
429 | // search by mac, async, gets a signal back | 402 | // search by mac, async, gets a signal back |
430 | localDevice->isAvailable( device->mac() ); | 403 | m_localDevice->isAvailable( device.mac() ); |
431 | } | 404 | } |
@@ -444,3 +417,3 @@ namespace OpieTooth { | |||
444 | // get the right devices which requested the search | 417 | // get the right devices which requested the search |
445 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 418 | for( it = m_deviceList.begin(); it != m_deviceList.end(); ++it ) { |
446 | if ( it.key() == device ) { | 419 | if ( it.key() == device ) { |
@@ -451,5 +424,5 @@ namespace OpieTooth { | |||
451 | if ( connected ) { | 424 | if ( connected ) { |
452 | deviceItem->setPixmap( 1, onPix ); | 425 | deviceItem->setPixmap( 1, m_onPix ); |
453 | } else { | 426 | } else { |
454 | deviceItem->setPixmap( 1, offPix ); | 427 | deviceItem->setPixmap( 1, m_offPix ); |
455 | } | 428 | } |
@@ -473,3 +446,3 @@ namespace OpieTooth { | |||
473 | void BlueBase::setInfo() { | 446 | void BlueBase::setInfo() { |
474 | StatusLabel->setText( getStatus() ); | 447 | StatusLabel->setText( status() ); |
475 | } | 448 | } |
@@ -481,4 +454,3 @@ namespace OpieTooth { | |||
481 | writeSavedDevices(); | 454 | writeSavedDevices(); |
482 | delete iconLoader; | 455 | delete m_iconLoader; |
483 | } | ||
484 | } | 456 | } |
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index ce0483f..73fac97 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h | |||
@@ -49,24 +49,24 @@ namespace OpieTooth { | |||
49 | void writeToHciConfig(); | 49 | void writeToHciConfig(); |
50 | QString getStatus(); | 50 | QString status()const; |
51 | void initGui(); | 51 | void initGui(); |
52 | void setInfo(); | 52 | void setInfo(); |
53 | Manager *localDevice; | 53 | Manager *m_localDevice; |
54 | QMap<QString,BTListItem*> deviceList; | 54 | QMap<QString,BTListItem*> m_deviceList; |
55 | 55 | ||
56 | void deviceActive( RemoteDevice *device ); | 56 | void deviceActive( const RemoteDevice &device ); |
57 | 57 | ||
58 | QString deviceName; | 58 | QString m_deviceName; |
59 | QString defaultPasskey; | 59 | QString m_defaultPasskey; |
60 | int useEncryption; | 60 | bool m_useEncryption; |
61 | int enableAuthentification; | 61 | bool m_enableAuthentification; |
62 | int enablePagescan; | 62 | bool m_enablePagescan; |
63 | int enableInquiryscan; | 63 | bool m_enableInquiryscan; |
64 | 64 | ||
65 | QPixmap offPix; | 65 | QPixmap m_offPix; |
66 | QPixmap onPix; | 66 | QPixmap m_onPix; |
67 | 67 | ||
68 | BTIconLoader *iconLoader; | 68 | BTIconLoader *m_iconLoader; |
69 | 69 | ||
70 | private slots: | 70 | private slots: |
71 | void addSearchedDevices( QList<RemoteDevice> &newDevices ); | 71 | void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); |
72 | void addServicesToDevice( BTListItem *item ); | 72 | void addServicesToDevice( BTListItem *item ); |