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