author | harlekin <harlekin> | 2002-07-21 20:58:37 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-07-21 20:58:37 (UTC) |
commit | 2fb3b8fdf9cb4e660e217ae563a1a49557864ca9 (patch) (unidiff) | |
tree | 975738ed841eb216946191a12d5dd19585fd738d | |
parent | 99e354d845a38e5366d954c7f8f9c71b65ad0820 (diff) | |
download | opie-2fb3b8fdf9cb4e660e217ae563a1a49557864ca9.zip opie-2fb3b8fdf9cb4e660e217ae563a1a49557864ca9.tar.gz opie-2fb3b8fdf9cb4e660e217ae563a1a49557864ca9.tar.bz2 |
nicer connection state icons
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 18 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 1 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/pppdialog.h | 2 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/rfcpopup.cpp | 4 |
4 files changed, 12 insertions, 13 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index ec05a95..f400ce6 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -1,178 +1,179 @@ | |||
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 | #include "devicehandler.h" | 21 | #include "devicehandler.h" |
22 | #include "btconnectionitem.h" | 22 | #include "btconnectionitem.h" |
23 | 23 | ||
24 | #include <remotedevice.h> | 24 | #include <remotedevice.h> |
25 | #include <services.h> | 25 | #include <services.h> |
26 | 26 | ||
27 | #include <stdlib.h> | 27 | #include <stdlib.h> |
28 | 28 | ||
29 | #include <qframe.h> | 29 | #include <qframe.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <qvariant.h> | 33 | #include <qvariant.h> |
34 | #include <qimage.h> | 34 | #include <qimage.h> |
35 | #include <qpixmap.h> | 35 | #include <qpixmap.h> |
36 | #include <qtabwidget.h> | 36 | #include <qtabwidget.h> |
37 | #include <qscrollview.h> | 37 | #include <qscrollview.h> |
38 | #include <qvbox.h> | 38 | #include <qvbox.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
42 | #include <qlistview.h> | 42 | #include <qlistview.h> |
43 | #include <qdir.h> | 43 | #include <qdir.h> |
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qtimer.h> | 45 | #include <qtimer.h> |
46 | 46 | ||
47 | #include <qpe/qpeapplication.h> | 47 | #include <qpe/qpeapplication.h> |
48 | #include <qpe/resource.h> | 48 | #include <qpe/resource.h> |
49 | #include <qpe/config.h> | 49 | #include <qpe/config.h> |
50 | 50 | ||
51 | 51 | ||
52 | using namespace OpieTooth; | 52 | using namespace OpieTooth; |
53 | 53 | ||
54 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 54 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
55 | : BluetoothBase( parent, name, fl ) { | 55 | : BluetoothBase( parent, name, fl ) { |
56 | 56 | ||
57 | m_localDevice = new Manager( "hci0" ); | 57 | m_localDevice = new Manager( "hci0" ); |
58 | 58 | ||
59 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 59 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
60 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 60 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
61 | // not good since lib is async | 61 | // not good since lib is async |
62 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), | 62 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), |
63 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); | 63 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); |
64 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), | 64 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), |
65 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); | 65 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); |
66 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), | 66 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), |
67 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); | 67 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); |
68 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), | 68 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), |
69 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); | 69 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); |
70 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), | 70 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), |
71 | this, SLOT( deviceActive( const QString& , bool ) ) ); | 71 | this, SLOT( deviceActive( const QString& , bool ) ) ); |
72 | connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), | 72 | connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), |
73 | this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); | 73 | this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); |
74 | 74 | ||
75 | 75 | ||
76 | // let hold be rightButtonClicked() | 76 | // let hold be rightButtonClicked() |
77 | QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); | 77 | QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); |
78 | QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); | 78 | QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); |
79 | 79 | ||
80 | //Load all icons needed | 80 | //Load all icons needed |
81 | m_offPix = Resource::loadPixmap( "editdelete" ); | 81 | m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); |
82 | m_onPix = Resource::loadPixmap( "installed" ); | 82 | m_onPix = Resource::loadPixmap( "opietooth/connected" ); |
83 | m_findPix = Resource::loadPixmap( "opietooth/find" ); | ||
83 | 84 | ||
84 | QPalette pal = this->palette(); | 85 | QPalette pal = this->palette(); |
85 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); | 86 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); |
86 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); | 87 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); |
87 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); | 88 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); |
88 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); | 89 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); |
89 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); | 90 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); |
90 | this->setPalette( pal ); | 91 | this->setPalette( pal ); |
91 | 92 | ||
92 | setCaption( tr( "Bluetooth Manager" ) ); | 93 | setCaption( tr( "Bluetooth Manager" ) ); |
93 | 94 | ||
94 | readConfig(); | 95 | readConfig(); |
95 | initGui(); | 96 | initGui(); |
96 | 97 | ||
97 | //TESTING | 98 | //TESTING |
98 | ListView2->setRootIsDecorated(true); | 99 | ListView2->setRootIsDecorated(true); |
99 | 100 | ||
100 | BTDeviceItem *topLV2 = new BTDeviceItem( ListView2, RemoteDevice("xx:", "Siemens S45" ) ); | 101 | BTDeviceItem *topLV2 = new BTDeviceItem( ListView2, RemoteDevice("xx:", "Siemens S45" ) ); |
101 | topLV2->setPixmap( 1, m_onPix ); | 102 | topLV2->setPixmap( 1, m_onPix ); |
102 | Services s1; | 103 | Services s1; |
103 | s1.setServiceName( "Serial" ); | 104 | s1.setServiceName( "Serial" ); |
104 | s1.insertClassId(1, "BlueNic"); | 105 | s1.insertClassId(1, "BlueNic"); |
105 | (void) new BTServiceItem( topLV2, s1 ); | 106 | (void) new BTServiceItem( topLV2, s1 ); |
106 | s1.setServiceName( "BlueNic" ); | 107 | s1.setServiceName( "BlueNic" ); |
107 | s1.insertClassId(2, "Obex"); | 108 | s1.insertClassId(2, "Obex"); |
108 | (void) new BTServiceItem( topLV2, s1 ); | 109 | (void) new BTServiceItem( topLV2, s1 ); |
109 | 110 | ||
110 | writeToHciConfig(); | 111 | writeToHciConfig(); |
111 | // search conncetions | 112 | // search conncetions |
112 | addConnectedDevices(); | 113 | addConnectedDevices(); |
113 | m_iconLoader = new BTIconLoader(); | 114 | m_iconLoader = new BTIconLoader(); |
114 | readSavedDevices(); | 115 | readSavedDevices(); |
115 | } | 116 | } |
116 | 117 | ||
117 | /** | 118 | /** |
118 | * Reads all options from the config file | 119 | * Reads all options from the config file |
119 | */ | 120 | */ |
120 | void BlueBase::readConfig() { | 121 | void BlueBase::readConfig() { |
121 | 122 | ||
122 | Config cfg( "bluetoothmanager" ); | 123 | Config cfg( "bluetoothmanager" ); |
123 | cfg.setGroup( "bluezsettings" ); | 124 | cfg.setGroup( "bluezsettings" ); |
124 | 125 | ||
125 | m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with | 126 | m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with |
126 | m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak | 127 | m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak |
127 | m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); | 128 | m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); |
128 | m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); | 129 | m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); |
129 | m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); | 130 | m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); |
130 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); | 131 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); |
131 | } | 132 | } |
132 | 133 | ||
133 | /** | 134 | /** |
134 | * Writes all options to the config file | 135 | * Writes all options to the config file |
135 | */ | 136 | */ |
136 | void BlueBase::writeConfig() { | 137 | void BlueBase::writeConfig() { |
137 | 138 | ||
138 | Config cfg( "bluetoothmanager" ); | 139 | Config cfg( "bluetoothmanager" ); |
139 | cfg.setGroup( "bluezsettings" ); | 140 | cfg.setGroup( "bluezsettings" ); |
140 | 141 | ||
141 | cfg.writeEntry( "name" , m_deviceName ); | 142 | cfg.writeEntry( "name" , m_deviceName ); |
142 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); | 143 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); |
143 | cfg.writeEntry( "useEncryption" , m_useEncryption ); | 144 | cfg.writeEntry( "useEncryption" , m_useEncryption ); |
144 | cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); | 145 | cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); |
145 | cfg.writeEntry( "enablePagescan" , m_enablePagescan ); | 146 | cfg.writeEntry( "enablePagescan" , m_enablePagescan ); |
146 | cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); | 147 | cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); |
147 | 148 | ||
148 | writeToHciConfig(); | 149 | writeToHciConfig(); |
149 | } | 150 | } |
150 | 151 | ||
151 | /** | 152 | /** |
152 | * Modify the hcid.conf file to our needs | 153 | * Modify the hcid.conf file to our needs |
153 | */ | 154 | */ |
154 | void BlueBase::writeToHciConfig() { | 155 | void BlueBase::writeToHciConfig() { |
155 | qWarning("writeToHciConfig"); | 156 | qWarning("writeToHciConfig"); |
156 | HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); | 157 | HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); |
157 | hciconf.load(); | 158 | hciconf.load(); |
158 | hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | 159 | hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); |
159 | hciconf.setName( m_deviceName ); | 160 | hciconf.setName( m_deviceName ); |
160 | hciconf.setEncrypt( m_useEncryption ); | 161 | hciconf.setEncrypt( m_useEncryption ); |
161 | hciconf.setAuth( m_enableAuthentification ); | 162 | hciconf.setAuth( m_enableAuthentification ); |
162 | hciconf.setPscan( m_enablePagescan ); | 163 | hciconf.setPscan( m_enablePagescan ); |
163 | hciconf.setIscan( m_enableInquiryscan ); | 164 | hciconf.setIscan( m_enableInquiryscan ); |
164 | hciconf.save(); | 165 | hciconf.save(); |
165 | } | 166 | } |
166 | 167 | ||
167 | 168 | ||
168 | /** | 169 | /** |
169 | * Read the list of allready known devices | 170 | * Read the list of allready known devices |
170 | */ | 171 | */ |
171 | void BlueBase::readSavedDevices() { | 172 | void BlueBase::readSavedDevices() { |
172 | 173 | ||
173 | QValueList<RemoteDevice> loadedDevices; | 174 | QValueList<RemoteDevice> loadedDevices; |
174 | DeviceHandler handler; | 175 | DeviceHandler handler; |
175 | loadedDevices = handler.load(); | 176 | loadedDevices = handler.load(); |
176 | 177 | ||
177 | addSearchedDevices( loadedDevices ); | 178 | addSearchedDevices( loadedDevices ); |
178 | } | 179 | } |
@@ -264,222 +265,215 @@ void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) | |||
264 | 265 | ||
265 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); | 266 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); |
266 | deviceItem->setExpandable ( true ); | 267 | deviceItem->setExpandable ( true ); |
267 | 268 | ||
268 | // look if device is avail. atm, async | 269 | // look if device is avail. atm, async |
269 | deviceActive( (*it) ); | 270 | deviceActive( (*it) ); |
270 | 271 | ||
271 | // ggf auch hier? | 272 | // ggf auch hier? |
272 | addServicesToDevice( deviceItem ); | 273 | addServicesToDevice( deviceItem ); |
273 | } | 274 | } |
274 | } | 275 | } |
275 | 276 | ||
276 | 277 | ||
277 | /** | 278 | /** |
278 | * Action that is toggled on entrys on click | 279 | * Action that is toggled on entrys on click |
279 | */ | 280 | */ |
280 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { | 281 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { |
281 | } | 282 | } |
282 | 283 | ||
283 | 284 | ||
284 | /** | 285 | /** |
285 | * Action that are toggled on hold (mostly QPopups i guess) | 286 | * Action that are toggled on hold (mostly QPopups i guess) |
286 | */ | 287 | */ |
287 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { | 288 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { |
288 | if (!item ) | 289 | if (!item ) |
289 | return; | 290 | return; |
290 | 291 | ||
291 | QPopupMenu *menu = new QPopupMenu(); | 292 | QPopupMenu *menu = new QPopupMenu(); |
292 | int ret=0; | 293 | int ret=0; |
293 | 294 | ||
294 | if ( ((BTListItem*)item)->type() == "device") { | 295 | if ( ((BTListItem*)item)->type() == "device") { |
295 | 296 | ||
296 | QPopupMenu *groups = new QPopupMenu(); | 297 | QPopupMenu *groups = new QPopupMenu(); |
297 | 298 | ||
298 | menu->insertItem( tr("rescan sevices:"), 0); | 299 | menu->insertItem( tr("rescan sevices:"), 0); |
299 | menu->insertItem( tr("to group"), groups , 1); | 300 | menu->insertItem( tr("to group"), groups , 1); |
300 | // menu->insertItem( tr("bound device"), 2); | 301 | // menu->insertItem( tr("bound device"), 2); |
301 | menu->insertItem( tr("delete"), 3); | 302 | menu->insertItem( tr("delete"), 3); |
302 | 303 | ||
303 | ret = menu->exec( point , 0); | 304 | ret = menu->exec( point , 0); |
304 | 305 | ||
305 | switch(ret) { | 306 | switch(ret) { |
306 | case -1: | 307 | case -1: |
307 | break; | 308 | break; |
308 | case 0: | 309 | case 0: |
309 | addServicesToDevice( (BTDeviceItem*)item ); | 310 | addServicesToDevice( (BTDeviceItem*)item ); |
310 | break; | 311 | break; |
311 | case 1: | 312 | case 1: |
312 | 313 | ||
313 | break; | 314 | break; |
314 | 315 | ||
315 | // NO need to, since hcid does that on the fly | 316 | // NO need to, since hcid does that on the fly |
316 | // case 2: | 317 | // case 2: |
317 | // make connection | 318 | // make connection |
318 | //m_localDevice->connectTo( ((BTDeviceItem*)item)->mac() ); | 319 | //m_localDevice->connectTo( ((BTDeviceItem*)item)->mac() ); |
319 | //break; | 320 | //break; |
320 | case 3: | 321 | case 3: |
321 | // deletes childs too | 322 | // deletes childs too |
322 | delete item; | 323 | delete item; |
323 | break; | 324 | break; |
324 | } | 325 | } |
325 | delete groups; | 326 | delete groups; |
326 | 327 | ||
327 | } | 328 | } |
328 | 329 | ||
329 | /* | 330 | /* |
330 | * We got service sensitive PopupMenus in our factory | 331 | * We got service sensitive PopupMenus in our factory |
331 | * We will create one through the factory and will insert | 332 | * We will create one through the factory and will insert |
332 | * our Separator + ShowInfo into the menu or create a new | 333 | * our Separator + ShowInfo into the menu or create a new |
333 | * one if the factory returns 0 | 334 | * one if the factory returns 0 |
334 | * PopupMenu deletion is kind of weird. | 335 | * PopupMenu deletion is kind of weird. |
335 | * If escaped( -1 ) or any of our items were chosen we'll | 336 | * If escaped( -1 ) or any of our items were chosen we'll |
336 | * delete the PopupMenu otherwise it's the responsibility of | 337 | * delete the PopupMenu otherwise it's the responsibility of |
337 | * the PopupMenu to delete itself | 338 | * the PopupMenu to delete itself |
338 | * | 339 | * |
339 | */ | 340 | */ |
340 | else if ( ((BTListItem*)item)->type() == "service") { | 341 | else if ( ((BTListItem*)item)->type() == "service") { |
341 | BTServiceItem* service = (BTServiceItem*)item; | 342 | BTServiceItem* service = (BTServiceItem*)item; |
342 | QMap<int, QString> list = service->services().classIdList(); | 343 | QMap<int, QString> list = service->services().classIdList(); |
343 | QMap<int, QString>::Iterator it = list.begin(); | 344 | QMap<int, QString>::Iterator it = list.begin(); |
344 | QPopupMenu *popup =0l; | 345 | QPopupMenu *popup =0l; |
345 | if ( it != list.end() ) { | 346 | if ( it != list.end() ) { |
346 | qWarning("Searching id %d %s", it.key(), it.data().latin1() ); | 347 | qWarning("Searching id %d %s", it.key(), it.data().latin1() ); |
347 | popup = m_popHelper.find( it.key() /*1*/, | 348 | popup = m_popHelper.find( it.key() /*1*/, |
348 | service->services(), | 349 | service->services(), |
349 | (BTDeviceItem*)service->parent() ); | 350 | (BTDeviceItem*)service->parent() ); |
350 | }else { | 351 | }else { |
351 | qWarning("Empty"); | 352 | qWarning("Empty"); |
352 | } | 353 | } |
353 | 354 | ||
354 | if ( popup == 0l ) { | 355 | if ( popup == 0l ) { |
355 | qWarning("factory returned 0l"); | 356 | qWarning("factory returned 0l"); |
356 | popup = new QPopupMenu(); | 357 | popup = new QPopupMenu(); |
357 | } | 358 | } |
358 | 359 | ||
359 | int test1 = popup->insertItem( tr("Test1:"), 0); | 360 | int test1 = popup->insertItem( tr("Test1:"), 0); |
360 | int con = popup->insertItem( tr("connect"), 1); | ||
361 | int del = popup->insertItem( tr("delete"), 2); | ||
362 | 361 | ||
363 | ret = popup->exec( point ); | 362 | ret = popup->exec( point ); |
364 | qWarning("returned from exec() "); | 363 | qWarning("returned from exec() "); |
365 | if ( ret == -1 ) | 364 | if ( ret == -1 ) { |
366 | ; | 365 | ; |
367 | else if ( ret == test1 ) | 366 | } else if ( ret == test1 ) { |
368 | ; | 367 | ; |
369 | else if ( ret == con ) | ||
370 | ; | ||
371 | else if ( ret == del ) { | ||
372 | // take item first? -zecke | ||
373 | delete item; | ||
374 | } | 368 | } |
375 | delete popup; | 369 | delete popup; |
376 | } | 370 | } |
377 | delete menu; | 371 | delete menu; |
378 | } | 372 | } |
379 | 373 | ||
380 | 374 | ||
381 | /** | 375 | /** |
382 | * Search and display avail. services for a device (on expand from device listing) | 376 | * Search and display avail. services for a device (on expand from device listing) |
383 | * @param item the service item returned | 377 | * @param item the service item returned |
384 | */ | 378 | */ |
385 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { | 379 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { |
386 | qDebug("addServicesToDevice"); | 380 | qDebug("addServicesToDevice"); |
387 | // row of mac adress text(3) | 381 | // row of mac adress text(3) |
388 | RemoteDevice device = item->remoteDevice(); | 382 | RemoteDevice device = item->remoteDevice(); |
389 | m_deviceList.insert( item->mac() , item ); | 383 | m_deviceList.insert( item->mac() , item ); |
390 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 384 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
391 | m_localDevice->searchServices( device ); | 385 | m_localDevice->searchServices( device ); |
392 | } | 386 | } |
393 | 387 | ||
394 | 388 | ||
395 | /** | 389 | /** |
396 | * Overloaded. This one it the one that is connected to the foundServices signal | 390 | * Overloaded. This one it the one that is connected to the foundServices signal |
397 | * @param device the mac address of the remote device | 391 | * @param device the mac address of the remote device |
398 | * @param servicesList the list with the service the device has. | 392 | * @param servicesList the list with the service the device has. |
399 | */ | 393 | */ |
400 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 394 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { |
401 | qDebug("fill services list"); | 395 | qDebug("fill services list"); |
402 | 396 | ||
403 | QMap<QString,BTDeviceItem*>::Iterator it; | 397 | QMap<QString,BTDeviceItem*>::Iterator it; |
404 | BTDeviceItem* deviceItem = 0; | 398 | BTDeviceItem* deviceItem = 0; |
405 | 399 | ||
406 | // get the right devices which requested the search | 400 | // get the right devices which requested the search |
407 | it = m_deviceList.find( device ); | 401 | it = m_deviceList.find( device ); |
408 | if( it == m_deviceList.end() ) | 402 | if( it == m_deviceList.end() ) |
409 | return; | 403 | return; |
410 | deviceItem = it.data(); | 404 | deviceItem = it.data(); |
411 | 405 | ||
412 | QValueList<OpieTooth::Services>::Iterator it2; | 406 | QValueList<OpieTooth::Services>::Iterator it2; |
413 | BTServiceItem * serviceItem; | 407 | BTServiceItem * serviceItem; |
414 | 408 | ||
415 | if (!servicesList.isEmpty() ) { | 409 | if (!servicesList.isEmpty() ) { |
416 | // add services | 410 | // add services |
417 | QMap<int, QString> list; | 411 | QMap<int, QString> list; |
418 | QMap<int, QString>::Iterator classIt; | 412 | QMap<int, QString>::Iterator classIt; |
419 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { | 413 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { |
420 | serviceItem = new BTServiceItem( deviceItem , (*it2) ); | 414 | serviceItem = new BTServiceItem( deviceItem , (*it2) ); |
421 | list = (*it2).classIdList(); | 415 | list = (*it2).classIdList(); |
422 | classIt = list.begin(); | 416 | classIt = list.begin(); |
423 | int classId=0; | 417 | int classId=0; |
424 | if ( classIt != list.end() ) { | 418 | if ( classIt != list.end() ) { |
425 | classId = classIt.key(); | 419 | classId = classIt.key(); |
426 | } | 420 | } |
427 | 421 | ||
428 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); | 422 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); |
429 | } | 423 | } |
430 | } else { | 424 | } else { |
431 | Services s1; | 425 | Services s1; |
432 | s1.setServiceName( tr("no serives found") ); | 426 | s1.setServiceName( tr("no serives found") ); |
433 | serviceItem = new BTServiceItem( deviceItem, s1 ); | 427 | serviceItem = new BTServiceItem( deviceItem, s1 ); |
434 | } | 428 | } |
435 | // now remove them from the list | 429 | // now remove them from the list |
436 | m_deviceList.remove( it ); | 430 | m_deviceList.remove( it ); |
437 | } | 431 | } |
438 | 432 | ||
439 | 433 | ||
440 | /** | 434 | /** |
441 | * Add the existing connections (pairs) to the connections tab. | 435 | * Add the existing connections (pairs) to the connections tab. |
442 | * This one triggers the search | 436 | * This one triggers the search |
443 | */ | 437 | */ |
444 | void BlueBase::addConnectedDevices() { | 438 | void BlueBase::addConnectedDevices() { |
445 | m_localDevice->searchConnections(); | 439 | m_localDevice->searchConnections(); |
446 | } | 440 | } |
447 | 441 | ||
448 | 442 | ||
449 | /** | 443 | /** |
450 | * This adds the found connections to the connection tab. | 444 | * This adds the found connections to the connection tab. |
451 | * @param connectionList the ValueList with all current connections | 445 | * @param connectionList the ValueList with all current connections |
452 | */ | 446 | */ |
453 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { | 447 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { |
454 | 448 | ||
455 | // clear the ListView first | 449 | // clear the ListView first |
456 | ListView4->clear(); | 450 | ListView4->clear(); |
457 | 451 | ||
458 | QValueList<OpieTooth::ConnectionState>::Iterator it; | 452 | QValueList<OpieTooth::ConnectionState>::Iterator it; |
459 | BTConnectionItem * connectionItem; | 453 | BTConnectionItem * connectionItem; |
460 | 454 | ||
461 | if ( !connectionList.isEmpty() ) { | 455 | if ( !connectionList.isEmpty() ) { |
462 | 456 | ||
463 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | 457 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { |
464 | connectionItem = new BTConnectionItem( ListView4 , (*it) ); | 458 | connectionItem = new BTConnectionItem( ListView4 , (*it) ); |
465 | } | 459 | } |
466 | } else { | 460 | } else { |
467 | ConnectionState con; | 461 | ConnectionState con; |
468 | con.setMac( tr("No connections found") ); | 462 | con.setMac( tr("No connections found") ); |
469 | connectionItem = new BTConnectionItem( ListView4 , con ); | 463 | connectionItem = new BTConnectionItem( ListView4 , con ); |
470 | } | 464 | } |
471 | 465 | ||
472 | // recall connection search after some time | 466 | // recall connection search after some time |
473 | QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); | 467 | QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); |
474 | } | 468 | } |
475 | 469 | ||
476 | 470 | ||
477 | /** | 471 | /** |
478 | * Find out if a device can currently be reached | 472 | * Find out if a device can currently be reached |
479 | * @param device | 473 | * @param device |
480 | */ | 474 | */ |
481 | void BlueBase::deviceActive( const RemoteDevice &device ) { | 475 | void BlueBase::deviceActive( const RemoteDevice &device ) { |
482 | // search by mac, async, gets a signal back | 476 | // search by mac, async, gets a signal back |
483 | // We should have a BTDeviceItem there or where does it get added to the map -zecke | 477 | // We should have a BTDeviceItem there or where does it get added to the map -zecke |
484 | m_localDevice->isAvailable( device.mac() ); | 478 | m_localDevice->isAvailable( device.mac() ); |
485 | } | 479 | } |
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index a68a04b..0326daf 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h | |||
@@ -1,91 +1,92 @@ | |||
1 | 1 | ||
2 | #ifndef BLUEBASE_H | 2 | #ifndef BLUEBASE_H |
3 | #define BLUEBASE_H | 3 | #define BLUEBASE_H |
4 | 4 | ||
5 | #include <qvariant.h> | 5 | #include <qvariant.h> |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #include <qscrollview.h> | 7 | #include <qscrollview.h> |
8 | #include <qsplitter.h> | 8 | #include <qsplitter.h> |
9 | #include <qlist.h> | 9 | #include <qlist.h> |
10 | #include <qpixmap.h> | 10 | #include <qpixmap.h> |
11 | 11 | ||
12 | #include "bluetoothbase.h" | 12 | #include "bluetoothbase.h" |
13 | 13 | ||
14 | #include "btserviceitem.h" | 14 | #include "btserviceitem.h" |
15 | #include "btdeviceitem.h" | 15 | #include "btdeviceitem.h" |
16 | #include "popuphelper.h" | 16 | #include "popuphelper.h" |
17 | 17 | ||
18 | #include "bticonloader.h" | 18 | #include "bticonloader.h" |
19 | 19 | ||
20 | #include <remotedevice.h> | 20 | #include <remotedevice.h> |
21 | #include <manager.h> | 21 | #include <manager.h> |
22 | 22 | ||
23 | class QVBox; | 23 | class QVBox; |
24 | class QHBoxLayout; | 24 | class QHBoxLayout; |
25 | class QGridLayout; | 25 | class QGridLayout; |
26 | class QFrame; | 26 | class QFrame; |
27 | class QLabel; | 27 | class QLabel; |
28 | class QPushButton; | 28 | class QPushButton; |
29 | class QTabWidget; | 29 | class QTabWidget; |
30 | class QCheckBox; | 30 | class QCheckBox; |
31 | 31 | ||
32 | 32 | ||
33 | namespace OpieTooth { | 33 | namespace OpieTooth { |
34 | 34 | ||
35 | class BlueBase : public BluetoothBase { | 35 | class BlueBase : public BluetoothBase { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | 37 | ||
38 | public: | 38 | public: |
39 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 39 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
40 | ~BlueBase(); | 40 | ~BlueBase(); |
41 | 41 | ||
42 | protected: | 42 | protected: |
43 | 43 | ||
44 | 44 | ||
45 | private slots: | 45 | private slots: |
46 | void startScan(); | 46 | void startScan(); |
47 | 47 | ||
48 | private: | 48 | private: |
49 | bool find( const RemoteDevice& device ); | 49 | bool find( const RemoteDevice& device ); |
50 | void readConfig(); | 50 | void readConfig(); |
51 | void writeConfig(); | 51 | void writeConfig(); |
52 | void readSavedDevices(); | 52 | void readSavedDevices(); |
53 | void writeSavedDevices(); | 53 | void writeSavedDevices(); |
54 | void writeToHciConfig(); | 54 | void writeToHciConfig(); |
55 | QString status()const; | 55 | QString status()const; |
56 | void initGui(); | 56 | void initGui(); |
57 | void setInfo(); | 57 | void setInfo(); |
58 | PopupHelper m_popHelper; | 58 | PopupHelper m_popHelper; |
59 | Manager *m_localDevice; | 59 | Manager *m_localDevice; |
60 | QMap<QString,BTDeviceItem*> m_deviceList; | 60 | QMap<QString,BTDeviceItem*> m_deviceList; |
61 | 61 | ||
62 | void deviceActive( const RemoteDevice &device ); | 62 | void deviceActive( const RemoteDevice &device ); |
63 | 63 | ||
64 | QString m_deviceName; | 64 | QString m_deviceName; |
65 | QString m_defaultPasskey; | 65 | QString m_defaultPasskey; |
66 | bool m_useEncryption; | 66 | bool m_useEncryption; |
67 | bool m_enableAuthentification; | 67 | bool m_enableAuthentification; |
68 | bool m_enablePagescan; | 68 | bool m_enablePagescan; |
69 | bool m_enableInquiryscan; | 69 | bool m_enableInquiryscan; |
70 | 70 | ||
71 | QPixmap m_offPix; | 71 | QPixmap m_offPix; |
72 | QPixmap m_onPix; | 72 | QPixmap m_onPix; |
73 | QPixmap m_findPix; | ||
73 | 74 | ||
74 | BTIconLoader *m_iconLoader; | 75 | BTIconLoader *m_iconLoader; |
75 | 76 | ||
76 | private slots: | 77 | private slots: |
77 | void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); | 78 | void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); |
78 | void addServicesToDevice( BTDeviceItem *item ); | 79 | void addServicesToDevice( BTDeviceItem *item ); |
79 | void addServicesToDevice( const QString& device, Services::ValueList ); | 80 | void addServicesToDevice( const QString& device, Services::ValueList ); |
80 | void addConnectedDevices(); | 81 | void addConnectedDevices(); |
81 | void addConnectedDevices( ConnectionState::ValueList ); | 82 | void addConnectedDevices( ConnectionState::ValueList ); |
82 | void startServiceActionClicked( QListViewItem *item ); | 83 | void startServiceActionClicked( QListViewItem *item ); |
83 | void startServiceActionHold( QListViewItem *, const QPoint &, int ); | 84 | void startServiceActionHold( QListViewItem *, const QPoint &, int ); |
84 | void deviceActive( const QString& mac, bool connected ); | 85 | void deviceActive( const QString& mac, bool connected ); |
85 | void applyConfigChanges(); | 86 | void applyConfigChanges(); |
86 | 87 | ||
87 | }; | 88 | }; |
88 | 89 | ||
89 | } | 90 | } |
90 | 91 | ||
91 | #endif | 92 | #endif |
diff --git a/noncore/net/opietooth/manager/pppdialog.h b/noncore/net/opietooth/manager/pppdialog.h index 6fdc90a..bb8b734 100644 --- a/noncore/net/opietooth/manager/pppdialog.h +++ b/noncore/net/opietooth/manager/pppdialog.h | |||
@@ -1,37 +1,37 @@ | |||
1 | #ifndef PPPDIALOG_H | 1 | #ifndef PPPDIALOG_H |
2 | #define PPPDIALOG_H | 2 | #define PPPDIALOG_H |
3 | 3 | ||
4 | 4 | ||
5 | #include <qdialog.h> | 5 | #include <qdialog.h> |
6 | #include <opie/oprocess.h> | 6 | #include <opie/oprocess.h> |
7 | 7 | ||
8 | class QVBoxLayout; | 8 | class QVBoxLayout; |
9 | class QPushButton; | 9 | class QPushButton; |
10 | class QMultiLineEdit; | 10 | class QMultiLineEdit; |
11 | class QLineEdit; | 11 | class QLineEdit; |
12 | 12 | ||
13 | 13 | ||
14 | namespace OpieTooth { | 14 | namespace OpieTooth { |
15 | 15 | ||
16 | class PPPDialog : public QDialog { | 16 | class PPPDialog : public QDialog { |
17 | 17 | ||
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | 19 | ||
20 | public: | 20 | public: |
21 | PPPDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0, const QString& device = 0); | 21 | PPPDialog( QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0, const QString& device = 0); |
22 | ~PPPDialog(); | 22 | ~PPPDialog(); |
23 | 23 | ||
24 | private slots: | 24 | private slots: |
25 | void connectToDevice(); | 25 | void connectToDevice(); |
26 | void fillOutPut( OProcess* pppDial, char* cha, int len ); | 26 | void fillOutPut( OProcess* pppDial, char* cha, int len ); |
27 | protected: | 27 | protected: |
28 | QVBoxLayout* layout; | 28 | QVBoxLayout* layout; |
29 | QLineEdit* cmdLine; | 29 | QLineEdit* cmdLine; |
30 | QPushButton* connectButton; | 30 | QPushButton* connectButton; |
31 | QMultiLineEdit* outPut; | 31 | QMultiLineEdit* outPut; |
32 | 32 | ||
33 | private: | 33 | private: |
34 | QString m_device; | 34 | QString m_device; |
35 | }; | 35 | }; |
36 | } | 36 | } |
37 | #endif | 37 | #endif |
diff --git a/noncore/net/opietooth/manager/rfcpopup.cpp b/noncore/net/opietooth/manager/rfcpopup.cpp index 1b53f4b..cc87b6c 100644 --- a/noncore/net/opietooth/manager/rfcpopup.cpp +++ b/noncore/net/opietooth/manager/rfcpopup.cpp | |||
@@ -1,81 +1,85 @@ | |||
1 | 1 | ||
2 | #include <qtimer.h> | 2 | #include <qtimer.h> |
3 | 3 | ||
4 | #include "pppdialog.h" | 4 | #include "pppdialog.h" |
5 | #include "rfcpopup.h" | 5 | #include "rfcpopup.h" |
6 | 6 | ||
7 | using namespace OpieTooth; | 7 | using namespace OpieTooth; |
8 | 8 | ||
9 | /* | 9 | /* |
10 | * c'tor init the QAction | 10 | * c'tor init the QAction |
11 | */ | 11 | */ |
12 | RfcCommPopup::RfcCommPopup() | 12 | RfcCommPopup::RfcCommPopup() |
13 | : QPopupMenu() { | 13 | : QPopupMenu() { |
14 | qWarning("RfcCommPopup c'tor"); | 14 | qWarning("RfcCommPopup c'tor"); |
15 | 15 | ||
16 | QAction* a; | 16 | QAction* a; |
17 | 17 | ||
18 | /* connect action */ | 18 | /* connect action */ |
19 | a = new QAction( ); // so it's get deleted | 19 | a = new QAction( ); // so it's get deleted |
20 | a->setText("Connect"); | 20 | a->setText("Connect"); |
21 | a->addTo( this ); | 21 | a->addTo( this ); |
22 | connect( a, SIGNAL( activated() ), | 22 | connect( a, SIGNAL( activated() ), |
23 | this, SLOT( slotConnect() ) ); | 23 | this, SLOT( slotConnect() ) ); |
24 | 24 | ||
25 | 25 | ||
26 | /* disconnect action */ | 26 | /* disconnect action */ |
27 | a = new QAction( ); | 27 | a = new QAction( ); |
28 | a->setText("Disconnect"); | 28 | a->setText("Disconnect"); |
29 | a->addTo( this ); | 29 | a->addTo( this ); |
30 | connect( a, SIGNAL( activated() ) , | 30 | connect( a, SIGNAL( activated() ) , |
31 | this, SLOT( slotDisconnect() ) ); | 31 | this, SLOT( slotDisconnect() ) ); |
32 | 32 | ||
33 | 33 | ||
34 | /* foo action */ | 34 | /* foo action */ |
35 | a = new QAction( ); | 35 | a = new QAction( ); |
36 | a->setText("Foo"); | 36 | a->setText("Foo"); |
37 | a->addTo( this ); | 37 | a->addTo( this ); |
38 | connect( a, SIGNAL( activated() ), | 38 | connect( a, SIGNAL( activated() ), |
39 | this, SLOT( slotFoo() ) ); | 39 | this, SLOT( slotFoo() ) ); |
40 | 40 | ||
41 | 41 | ||
42 | /* bar action */ | 42 | /* bar action */ |
43 | a = new QAction( ); | 43 | a = new QAction( ); |
44 | a->setText( "Bar" ); | 44 | a->setText( "Bar" ); |
45 | a->addTo( this ); | 45 | a->addTo( this ); |
46 | connect( a, SIGNAL( activated() ), | 46 | connect( a, SIGNAL( activated() ), |
47 | this, SLOT( slotBar() ) ); | 47 | this, SLOT( slotBar() ) ); |
48 | 48 | ||
49 | }; | 49 | }; |
50 | 50 | ||
51 | 51 | ||
52 | RfcCommPopup::~RfcCommPopup() { | 52 | RfcCommPopup::~RfcCommPopup() { |
53 | /* delete m_con; | 53 | /* delete m_con; |
54 | delete m_dis; | 54 | delete m_dis; |
55 | delete m_foo; | 55 | delete m_foo; |
56 | delete m_bar; */ | 56 | delete m_bar; */ |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | ||
60 | void RfcCommPopup::slotConnect() { | 60 | void RfcCommPopup::slotConnect() { |
61 | |||
61 | qWarning("connect"); | 62 | qWarning("connect"); |
63 | |||
64 | |||
65 | |||
62 | PPPDialog pppDialog; | 66 | PPPDialog pppDialog; |
63 | pppDialog.showMaximized(); | 67 | pppDialog.showMaximized(); |
64 | pppDialog.exec(); | 68 | pppDialog.exec(); |
65 | } | 69 | } |
66 | 70 | ||
67 | 71 | ||
68 | void RfcCommPopup::slotDisconnect() { | 72 | void RfcCommPopup::slotDisconnect() { |
69 | qWarning("slot disconnected"); | 73 | qWarning("slot disconnected"); |
70 | } | 74 | } |
71 | 75 | ||
72 | 76 | ||
73 | void RfcCommPopup::slotFoo() { | 77 | void RfcCommPopup::slotFoo() { |
74 | qWarning("slotFoo"); | 78 | qWarning("slotFoo"); |
75 | } | 79 | } |
76 | 80 | ||
77 | 81 | ||
78 | void RfcCommPopup::slotBar() { | 82 | void RfcCommPopup::slotBar() { |
79 | qWarning("slotBar"); | 83 | qWarning("slotBar"); |
80 | }; | 84 | }; |
81 | 85 | ||