author | ar <ar> | 2004-02-21 15:27:41 (UTC) |
---|---|---|
committer | ar <ar> | 2004-02-21 15:27:41 (UTC) |
commit | 460258f203be746ff79e14f32a823f381b8ea513 (patch) (unidiff) | |
tree | 87dddbacda3050027d343730cf021b53045e80cb /noncore/net/opietooth | |
parent | 76b70b355d2c1c32c0f74e844e0654e39db2a175 (diff) | |
download | opie-460258f203be746ff79e14f32a823f381b8ea513.zip opie-460258f203be746ff79e14f32a823f381b8ea513.tar.gz opie-460258f203be746ff79e14f32a823f381b8ea513.tar.bz2 |
improve support for BigScreen
-rw-r--r-- | noncore/net/opietooth/blue-pin/pindlg.cc | 41 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 261 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/obexpopup.cpp | 22 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp | 51 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/rfcpopup.cpp | 49 |
5 files changed, 261 insertions, 163 deletions
diff --git a/noncore/net/opietooth/blue-pin/pindlg.cc b/noncore/net/opietooth/blue-pin/pindlg.cc index 7d60d6c..9418a20 100644 --- a/noncore/net/opietooth/blue-pin/pindlg.cc +++ b/noncore/net/opietooth/blue-pin/pindlg.cc | |||
@@ -1,54 +1,65 @@ | |||
1 | 1 | ||
2 | #include <stdio.h> | 2 | #include "pindlg.h" |
3 | |||
4 | /* OPIE */ | ||
5 | #include <qpe/config.h> | ||
6 | #include <qpe/qpeapplication.h> | ||
3 | 7 | ||
8 | /* QT */ | ||
4 | #include <qcheckbox.h> | 9 | #include <qcheckbox.h> |
5 | #include <qlabel.h> | 10 | #include <qlabel.h> |
6 | #include <qlineedit.h> | 11 | #include <qlineedit.h> |
7 | #include <qtimer.h> | 12 | #include <qtimer.h> |
8 | 13 | ||
9 | #include <qpe/config.h> | 14 | /* STD */ |
10 | 15 | #include <stdio.h> | |
11 | #include "pindlg.h" | ||
12 | 16 | ||
13 | using namespace OpieTooth; | 17 | using namespace OpieTooth; |
14 | 18 | ||
15 | PinDlg::PinDlg( const QString& status, | 19 | PinDlg::PinDlg( const QString& status, |
16 | const QString& mac, QWidget* parent, | 20 | const QString& mac, QWidget* parent, |
17 | const char* name ) | 21 | const char* name ) |
18 | : PinDlgBase( parent, name, WType_Modal ) | 22 | : PinDlgBase( parent, name, WType_Modal ) |
19 | { | 23 | { |
20 | m_mac = mac; | 24 | m_mac = mac; |
21 | test( mac ); | 25 | test( mac ); |
22 | txtStatus->setText(status); | 26 | txtStatus->setText(status); |
23 | showMaximized(); | 27 | QPEApplication::showDialog( this ); |
24 | } | 28 | } |
25 | PinDlg::~PinDlg() { | ||
26 | 29 | ||
27 | } | 30 | PinDlg::~PinDlg() |
28 | void PinDlg::setMac( const QString& mac ) { | 31 | {} |
32 | void PinDlg::setMac( const QString& mac ) | ||
33 | { | ||
29 | txtStatus->setText( mac ); | 34 | txtStatus->setText( mac ); |
30 | } | 35 | } |
31 | QString PinDlg::pin() const{ | 36 | QString PinDlg::pin() const |
37 | { | ||
32 | return lnePin->text(); | 38 | return lnePin->text(); |
33 | } | 39 | } |
34 | 40 | ||
35 | void PinDlg::test( const QString& mac ) { | 41 | void PinDlg::test( const QString& mac ) |
36 | if (!mac.isEmpty() ) { | 42 | { |
43 | if (!mac.isEmpty() ) | ||
44 | { | ||
37 | Config cfg("bluepin"); | 45 | Config cfg("bluepin"); |
38 | cfg.setGroup(mac); | 46 | cfg.setGroup(mac); |
39 | lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) ); | 47 | lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) ); |
40 | if ( !lnePin->text().isEmpty() ) { | 48 | if ( !lnePin->text().isEmpty() ) |
49 | { | ||
41 | //QTimer::singleShot(100, this, SLOT(accept() ) ); | 50 | //QTimer::singleShot(100, this, SLOT(accept() ) ); |
42 | } | 51 | } |
43 | 52 | ||
44 | } | 53 | } |
45 | 54 | ||
46 | } | 55 | } |
47 | void PinDlg::accept() { | 56 | void PinDlg::accept() |
48 | if ( ckbPin->isChecked() ) { | 57 | { |
58 | if ( ckbPin->isChecked() ) | ||
59 | { | ||
49 | Config cfg("bluepin"); | 60 | Config cfg("bluepin"); |
50 | cfg.setGroup(m_mac ); | 61 | cfg.setGroup(m_mac ); |
51 | cfg.writeEntryCrypt("pin", lnePin->text() ); | 62 | cfg.writeEntryCrypt("pin", lnePin->text() ); |
52 | } | 63 | } |
53 | QDialog::accept(); | 64 | QDialog::accept(); |
54 | } | 65 | } |
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 2e68984..0ea45d2 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -19,17 +19,18 @@ | |||
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 | #include "rfcommassigndialogimpl.h" | 23 | #include "rfcommassigndialogimpl.h" |
24 | 24 | ||
25 | #include <remotedevice.h> | 25 | /* OPIE */ |
26 | #include <services.h> | 26 | #include <qpe/qpeapplication.h> |
27 | 27 | #include <qpe/resource.h> | |
28 | #include <stdlib.h> | 28 | #include <qpe/config.h> |
29 | 29 | ||
30 | /* QT */ | ||
30 | #include <qframe.h> | 31 | #include <qframe.h> |
31 | #include <qlabel.h> | 32 | #include <qlabel.h> |
32 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
33 | #include <qlayout.h> | 34 | #include <qlayout.h> |
34 | #include <qvariant.h> | 35 | #include <qvariant.h> |
35 | #include <qimage.h> | 36 | #include <qimage.h> |
@@ -43,29 +44,30 @@ | |||
43 | #include <qlistview.h> | 44 | #include <qlistview.h> |
44 | #include <qdir.h> | 45 | #include <qdir.h> |
45 | #include <qpopupmenu.h> | 46 | #include <qpopupmenu.h> |
46 | #include <qtimer.h> | 47 | #include <qtimer.h> |
47 | #include <qlist.h> | 48 | #include <qlist.h> |
48 | 49 | ||
49 | #include <qpe/qpeapplication.h> | 50 | /* STD */ |
50 | #include <qpe/resource.h> | 51 | #include <remotedevice.h> |
51 | #include <qpe/config.h> | 52 | #include <services.h> |
52 | 53 | #include <stdlib.h> | |
53 | 54 | ||
54 | using namespace OpieTooth; | 55 | using namespace OpieTooth; |
55 | 56 | ||
56 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 57 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
57 | : BluetoothBase( parent, name, fl ) { | 58 | : BluetoothBase( parent, name, fl ) |
59 | { | ||
58 | 60 | ||
59 | m_localDevice = new Manager( "hci0" ); | 61 | m_localDevice = new Manager( "hci0" ); |
60 | 62 | ||
61 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 63 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
62 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 64 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
63 | 65 | ||
64 | connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) ); | 66 | connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) ); |
65 | // not good since lib is async | 67 | // not good since lib is async |
66 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), | 68 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), |
67 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); | 69 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); |
68 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), | 70 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), |
69 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); | 71 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); |
70 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), | 72 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), |
71 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); | 73 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); |
@@ -73,13 +75,13 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | |||
73 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); | 75 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); |
74 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), | 76 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), |
75 | this, SLOT( deviceActive( const QString& , bool ) ) ); | 77 | this, SLOT( deviceActive( const QString& , bool ) ) ); |
76 | connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), | 78 | connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), |
77 | this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); | 79 | this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); |
78 | connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ), | 80 | connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ), |
79 | this, SLOT( addSignalStrength( const QString&, const QString& ) ) ); | 81 | this, SLOT( addSignalStrength( const QString&, const QString& ) ) ); |
80 | 82 | ||
81 | 83 | ||
82 | // let hold be rightButtonClicked() | 84 | // let hold be rightButtonClicked() |
83 | QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); | 85 | QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); |
84 | QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); | 86 | QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); |
85 | 87 | ||
@@ -112,13 +114,14 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | |||
112 | readSavedDevices(); | 114 | readSavedDevices(); |
113 | } | 115 | } |
114 | 116 | ||
115 | /** | 117 | /** |
116 | * Reads all options from the config file | 118 | * Reads all options from the config file |
117 | */ | 119 | */ |
118 | void BlueBase::readConfig() { | 120 | void BlueBase::readConfig() |
121 | { | ||
119 | 122 | ||
120 | Config cfg( "bluetoothmanager" ); | 123 | Config cfg( "bluetoothmanager" ); |
121 | cfg.setGroup( "bluezsettings" ); | 124 | cfg.setGroup( "bluezsettings" ); |
122 | 125 | ||
123 | 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 |
124 | 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 |
@@ -128,13 +131,14 @@ void BlueBase::readConfig() { | |||
128 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); | 131 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); |
129 | } | 132 | } |
130 | 133 | ||
131 | /** | 134 | /** |
132 | * Writes all options to the config file | 135 | * Writes all options to the config file |
133 | */ | 136 | */ |
134 | void BlueBase::writeConfig() { | 137 | void BlueBase::writeConfig() |
138 | { | ||
135 | 139 | ||
136 | Config cfg( "bluetoothmanager" ); | 140 | Config cfg( "bluetoothmanager" ); |
137 | cfg.setGroup( "bluezsettings" ); | 141 | cfg.setGroup( "bluezsettings" ); |
138 | 142 | ||
139 | cfg.writeEntry( "name" , m_deviceName ); | 143 | cfg.writeEntry( "name" , m_deviceName ); |
140 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); | 144 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); |
@@ -146,13 +150,14 @@ void BlueBase::writeConfig() { | |||
146 | writeToHciConfig(); | 150 | writeToHciConfig(); |
147 | } | 151 | } |
148 | 152 | ||
149 | /** | 153 | /** |
150 | * Modify the hcid.conf file to our needs | 154 | * Modify the hcid.conf file to our needs |
151 | */ | 155 | */ |
152 | void BlueBase::writeToHciConfig() { | 156 | void BlueBase::writeToHciConfig() |
157 | { | ||
153 | qWarning("writeToHciConfig"); | 158 | qWarning("writeToHciConfig"); |
154 | HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); | 159 | HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); |
155 | hciconf.load(); | 160 | hciconf.load(); |
156 | hciconf.setPinHelper( "/opt/QtPalmtop/bin/bluepin" ); | 161 | hciconf.setPinHelper( "/opt/QtPalmtop/bin/bluepin" ); |
157 | hciconf.setName( m_deviceName ); | 162 | hciconf.setName( m_deviceName ); |
158 | hciconf.setEncrypt( m_useEncryption ); | 163 | hciconf.setEncrypt( m_useEncryption ); |
@@ -163,31 +168,34 @@ void BlueBase::writeToHciConfig() { | |||
163 | } | 168 | } |
164 | 169 | ||
165 | 170 | ||
166 | /** | 171 | /** |
167 | * Read the list of allready known devices | 172 | * Read the list of allready known devices |
168 | */ | 173 | */ |
169 | void BlueBase::readSavedDevices() { | 174 | void BlueBase::readSavedDevices() |
175 | { | ||
170 | 176 | ||
171 | QValueList<RemoteDevice> loadedDevices; | 177 | QValueList<RemoteDevice> loadedDevices; |
172 | DeviceHandler handler; | 178 | DeviceHandler handler; |
173 | loadedDevices = handler.load(); | 179 | loadedDevices = handler.load(); |
174 | 180 | ||
175 | addSearchedDevices( loadedDevices ); | 181 | addSearchedDevices( loadedDevices ); |
176 | } | 182 | } |
177 | 183 | ||
178 | 184 | ||
179 | /** | 185 | /** |
180 | * Write the list of allready known devices | 186 | * Write the list of allready known devices |
181 | */ | 187 | */ |
182 | void BlueBase::writeSavedDevices() { | 188 | void BlueBase::writeSavedDevices() |
189 | { | ||
183 | QListViewItemIterator it( ListView2 ); | 190 | QListViewItemIterator it( ListView2 ); |
184 | BTListItem* item; | 191 | BTListItem* item; |
185 | BTDeviceItem* device; | 192 | BTDeviceItem* device; |
186 | RemoteDevice::ValueList list; | 193 | RemoteDevice::ValueList list; |
187 | for ( ; it.current(); ++it ) { | 194 | for ( ; it.current(); ++it ) |
195 | { | ||
188 | item = (BTListItem*)it.current(); | 196 | item = (BTListItem*)it.current(); |
189 | if(item->typeId() != BTListItem::Device ) | 197 | if(item->typeId() != BTListItem::Device ) |
190 | continue; | 198 | continue; |
191 | device = (BTDeviceItem*)item; | 199 | device = (BTDeviceItem*)item; |
192 | 200 | ||
193 | list.append( device->remoteDevice() ); | 201 | list.append( device->remoteDevice() ); |
@@ -202,13 +210,14 @@ void BlueBase::writeSavedDevices() { | |||
202 | } | 210 | } |
203 | 211 | ||
204 | 212 | ||
205 | /** | 213 | /** |
206 | * Set up the gui | 214 | * Set up the gui |
207 | */ | 215 | */ |
208 | void BlueBase::initGui() { | 216 | void BlueBase::initGui() |
217 | { | ||
209 | StatusLabel->setText( status() ); // maybe move it to getStatus() | 218 | StatusLabel->setText( status() ); // maybe move it to getStatus() |
210 | cryptCheckBox->setChecked( m_useEncryption ); | 219 | cryptCheckBox->setChecked( m_useEncryption ); |
211 | authCheckBox->setChecked( m_enableAuthentification ); | 220 | authCheckBox->setChecked( m_enableAuthentification ); |
212 | pagescanCheckBox->setChecked( m_enablePagescan ); | 221 | pagescanCheckBox->setChecked( m_enablePagescan ); |
213 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); | 222 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); |
214 | deviceNameLine->setText( m_deviceName ); | 223 | deviceNameLine->setText( m_deviceName ); |
@@ -219,25 +228,27 @@ void BlueBase::initGui() { | |||
219 | 228 | ||
220 | 229 | ||
221 | /** | 230 | /** |
222 | * Get the status informations and returns it | 231 | * Get the status informations and returns it |
223 | * @return QString the status informations gathered | 232 | * @return QString the status informations gathered |
224 | */ | 233 | */ |
225 | QString BlueBase::status()const{ | 234 | QString BlueBase::status()const |
235 | { | ||
226 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); | 236 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); |
227 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); | 237 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); |
228 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); | 238 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); |
229 | 239 | ||
230 | return (infoString); | 240 | return (infoString); |
231 | } | 241 | } |
232 | 242 | ||
233 | 243 | ||
234 | /** | 244 | /** |
235 | * Read the current values from the gui and invoke writeConfig() | 245 | * Read the current values from the gui and invoke writeConfig() |
236 | */ | 246 | */ |
237 | void BlueBase::applyConfigChanges() { | 247 | void BlueBase::applyConfigChanges() |
248 | { | ||
238 | m_deviceName = deviceNameLine->text(); | 249 | m_deviceName = deviceNameLine->text(); |
239 | m_defaultPasskey = passkeyLine->text(); | 250 | m_defaultPasskey = passkeyLine->text(); |
240 | m_useEncryption = cryptCheckBox->isChecked(); | 251 | m_useEncryption = cryptCheckBox->isChecked(); |
241 | m_enableAuthentification = authCheckBox->isChecked(); | 252 | m_enableAuthentification = authCheckBox->isChecked(); |
242 | m_enablePagescan = pagescanCheckBox->isChecked(); | 253 | m_enablePagescan = pagescanCheckBox->isChecked(); |
243 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); | 254 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); |
@@ -248,31 +259,33 @@ void BlueBase::applyConfigChanges() { | |||
248 | } | 259 | } |
249 | 260 | ||
250 | /** | 261 | /** |
251 | * Launch Rfcomm Bind dialog | 262 | * Launch Rfcomm Bind dialog |
252 | * | 263 | * |
253 | */ | 264 | */ |
254 | void BlueBase::rfcommDialog() { | 265 | void BlueBase::rfcommDialog() |
266 | { | ||
255 | RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); | 267 | RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); |
256 | 268 | ||
257 | rfcommAssign.showMaximized(); | 269 | if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted ) |
258 | 270 | { | |
259 | if ( rfcommAssign.exec() == QDialog::Accepted ) { | ||
260 | rfcommAssign.saveConfig(); | 271 | rfcommAssign.saveConfig(); |
261 | } | 272 | } |
262 | } | 273 | } |
263 | 274 | ||
264 | /** | 275 | /** |
265 | * Add fresh found devices from scan dialog to the listing | 276 | * Add fresh found devices from scan dialog to the listing |
266 | * | 277 | * |
267 | */ | 278 | */ |
268 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { | 279 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) |
280 | { | ||
269 | BTDeviceItem * deviceItem; | 281 | BTDeviceItem * deviceItem; |
270 | QValueList<RemoteDevice>::ConstIterator it; | 282 | QValueList<RemoteDevice>::ConstIterator it; |
271 | 283 | ||
272 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { | 284 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) |
285 | { | ||
273 | 286 | ||
274 | if (find( (*it) )) // is already inserted | 287 | if (find( (*it) )) // is already inserted |
275 | continue; | 288 | continue; |
276 | 289 | ||
277 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); | 290 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); |
278 | deviceItem->setPixmap( 1, m_findPix ); | 291 | deviceItem->setPixmap( 1, m_findPix ); |
@@ -287,39 +300,42 @@ void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) | |||
287 | } | 300 | } |
288 | 301 | ||
289 | 302 | ||
290 | /** | 303 | /** |
291 | * Action that is toggled on entrys on click | 304 | * Action that is toggled on entrys on click |
292 | */ | 305 | */ |
293 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { | 306 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) |
294 | } | 307 | {} |
295 | 308 | ||
296 | 309 | ||
297 | /** | 310 | /** |
298 | * Action that are toggled on hold (mostly QPopups i guess) | 311 | * Action that are toggled on hold (mostly QPopups i guess) |
299 | */ | 312 | */ |
300 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { | 313 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) |
314 | { | ||
301 | if (!item ) | 315 | if (!item ) |
302 | return; | 316 | return; |
303 | 317 | ||
304 | QPopupMenu *menu = new QPopupMenu(); | 318 | QPopupMenu *menu = new QPopupMenu(); |
305 | int ret=0; | 319 | int ret=0; |
306 | 320 | ||
307 | if ( ((BTListItem*)item)->type() == "device") { | 321 | if ( ((BTListItem*)item)->type() == "device") |
322 | { | ||
308 | 323 | ||
309 | QPopupMenu *groups = new QPopupMenu(); | 324 | QPopupMenu *groups = new QPopupMenu(); |
310 | 325 | ||
311 | menu->insertItem( ((BTDeviceItem*)item)->name(),0 ); | 326 | menu->insertItem( ((BTDeviceItem*)item)->name(),0 ); |
312 | menu->insertSeparator(1); | 327 | menu->insertSeparator(1); |
313 | menu->insertItem( tr("rescan sevices"), 2); | 328 | menu->insertItem( tr("rescan sevices"), 2); |
314 | menu->insertItem( tr("to group"), groups , 3); | 329 | menu->insertItem( tr("to group"), groups , 3); |
315 | menu->insertItem( tr("delete"), 4); | 330 | menu->insertItem( tr("delete"), 4); |
316 | 331 | ||
317 | ret = menu->exec( point , 0); | 332 | ret = menu->exec( point , 0); |
318 | 333 | ||
319 | switch(ret) { | 334 | switch(ret) |
335 | { | ||
320 | case -1: | 336 | case -1: |
321 | break; | 337 | break; |
322 | case 2: | 338 | case 2: |
323 | addServicesToDevice( (BTDeviceItem*)item ); | 339 | addServicesToDevice( (BTDeviceItem*)item ); |
324 | break; | 340 | break; |
325 | 341 | ||
@@ -340,50 +356,59 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin | |||
340 | * PopupMenu deletion is kind of weird. | 356 | * PopupMenu deletion is kind of weird. |
341 | * If escaped( -1 ) or any of our items were chosen we'll | 357 | * If escaped( -1 ) or any of our items were chosen we'll |
342 | * delete the PopupMenu otherwise it's the responsibility of | 358 | * delete the PopupMenu otherwise it's the responsibility of |
343 | * the PopupMenu to delete itself | 359 | * the PopupMenu to delete itself |
344 | * | 360 | * |
345 | */ | 361 | */ |
346 | else if ( ((BTListItem*)item)->type() == "service") { | 362 | else if ( ((BTListItem*)item)->type() == "service") |
363 | { | ||
347 | BTServiceItem* service = (BTServiceItem*)item; | 364 | BTServiceItem* service = (BTServiceItem*)item; |
348 | QMap<int, QString> list = service->services().classIdList(); | 365 | QMap<int, QString> list = service->services().classIdList(); |
349 | QMap<int, QString>::Iterator it = list.begin(); | 366 | QMap<int, QString>::Iterator it = list.begin(); |
350 | QPopupMenu *popup =0l; | 367 | QPopupMenu *popup =0l; |
351 | if ( it != list.end() ) { | 368 | if ( it != list.end() ) |
352 | qWarning("Searching id %d %s", it.key(), it.data().latin1() ); | 369 | { |
370 | qWarning("Searching id %d %s", it.key(), it.data().latin1() ); | ||
353 | popup = m_popHelper.find( it.key(), | 371 | popup = m_popHelper.find( it.key(), |
354 | service->services(), | 372 | service->services(), |
355 | (BTDeviceItem*)service->parent() ); | 373 | (BTDeviceItem*)service->parent() ); |
356 | }else { | 374 | } |
357 | qWarning("Empty"); | 375 | else |
358 | } | 376 | { |
377 | qWarning("Empty"); | ||
378 | } | ||
359 | 379 | ||
360 | if ( popup == 0l ) { | 380 | if ( popup == 0l ) |
381 | { | ||
361 | qWarning("factory returned 0l"); | 382 | qWarning("factory returned 0l"); |
362 | popup = new QPopupMenu(); | 383 | popup = new QPopupMenu(); |
363 | } | 384 | } |
364 | int test1 = popup->insertItem( tr("Test1:"), 2); | 385 | int test1 = popup->insertItem( tr("Test1:"), 2); |
365 | 386 | ||
366 | ret = popup->exec( point ); | 387 | ret = popup->exec( point ); |
367 | qWarning("returned from exec() "); | 388 | qWarning("returned from exec() "); |
368 | if ( ret == -1 ) { | 389 | if ( ret == -1 ) |
390 | { | ||
369 | ; | 391 | ; |
370 | } else if ( ret == test1 ) { | 392 | } |
393 | else if ( ret == test1 ) | ||
394 | { | ||
371 | ; | 395 | ; |
372 | } | 396 | } |
373 | delete popup; | 397 | delete popup; |
374 | } | 398 | } |
375 | delete menu; | 399 | delete menu; |
376 | } | 400 | } |
377 | 401 | ||
378 | 402 | ||
379 | /** | 403 | /** |
380 | * Search and display avail. services for a device (on expand from device listing) | 404 | * Search and display avail. services for a device (on expand from device listing) |
381 | * @param item the service item returned | 405 | * @param item the service item returned |
382 | */ | 406 | */ |
383 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { | 407 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) |
408 | { | ||
384 | qDebug("addServicesToDevice"); | 409 | qDebug("addServicesToDevice"); |
385 | // row of mac adress text(3) | 410 | // row of mac adress text(3) |
386 | RemoteDevice device = item->remoteDevice(); | 411 | RemoteDevice device = item->remoteDevice(); |
387 | m_deviceList.insert( item->mac() , item ); | 412 | m_deviceList.insert( item->mac() , item ); |
388 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 413 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
389 | m_localDevice->searchServices( device ); | 414 | m_localDevice->searchServices( device ); |
@@ -393,13 +418,14 @@ void BlueBase::addServicesToDevice( BTDeviceItem * item ) { | |||
393 | /** | 418 | /** |
394 | * Overloaded. This one it the one that is | 419 | * Overloaded. This one it the one that is |
395 | ted to the foundServices signal | 420 | ted to the foundServices signal |
396 | * @param device the mac address of the remote device | 421 | * @param device the mac address of the remote device |
397 | * @param servicesList the list with the service the device has. | 422 | * @param servicesList the list with the service the device has. |
398 | */ | 423 | */ |
399 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 424 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) |
425 | { | ||
400 | qDebug("fill services list"); | 426 | qDebug("fill services list"); |
401 | 427 | ||
402 | QMap<QString,BTDeviceItem*>::Iterator it; | 428 | QMap<QString,BTDeviceItem*>::Iterator it; |
403 | BTDeviceItem* deviceItem = 0; | 429 | BTDeviceItem* deviceItem = 0; |
404 | 430 | ||
405 | // get the right devices which requested the search | 431 | // get the right devices which requested the search |
@@ -409,126 +435,151 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s | |||
409 | deviceItem = it.data(); | 435 | deviceItem = it.data(); |
410 | 436 | ||
411 | // remove previous entries | 437 | // remove previous entries |
412 | QList<QListViewItem> tempList; | 438 | QList<QListViewItem> tempList; |
413 | tempList.setAutoDelete( true ); | 439 | tempList.setAutoDelete( true ); |
414 | QListViewItem * child = deviceItem->firstChild(); | 440 | QListViewItem * child = deviceItem->firstChild(); |
415 | while( child ) { | 441 | while( child ) |
416 | tempList.append( child ); | 442 | { |
417 | child = child->nextSibling(); | 443 | tempList.append( child ); |
444 | child = child->nextSibling(); | ||
418 | } | 445 | } |
419 | tempList.clear(); | 446 | tempList.clear(); |
420 | 447 | ||
421 | QValueList<OpieTooth::Services>::Iterator it2; | 448 | QValueList<OpieTooth::Services>::Iterator it2; |
422 | BTServiceItem* serviceItem; | 449 | BTServiceItem* serviceItem; |
423 | 450 | ||
424 | 451 | ||
425 | if (!servicesList.isEmpty() ) { | 452 | if (!servicesList.isEmpty() ) |
453 | { | ||
426 | // add services | 454 | // add services |
427 | QMap<int, QString> list; | 455 | QMap<int, QString> list; |
428 | QMap<int, QString>::Iterator classIt; | 456 | QMap<int, QString>::Iterator classIt; |
429 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { | 457 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) |
458 | { | ||
430 | serviceItem = new BTServiceItem( deviceItem, (*it2) ); | 459 | serviceItem = new BTServiceItem( deviceItem, (*it2) ); |
431 | list = (*it2).classIdList(); | 460 | list = (*it2).classIdList(); |
432 | classIt = list.begin(); | 461 | classIt = list.begin(); |
433 | int classId=0; | 462 | int classId=0; |
434 | if ( classIt != list.end() ) { | 463 | if ( classIt != list.end() ) |
464 | { | ||
435 | classId = classIt.key(); | 465 | classId = classIt.key(); |
436 | } | 466 | } |
437 | 467 | ||
438 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); | 468 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); |
439 | } | 469 | } |
440 | } else { | 470 | } |
471 | else | ||
472 | { | ||
441 | Services s1; | 473 | Services s1; |
442 | s1.setServiceName( tr("no services found") ); | 474 | s1.setServiceName( tr("no services found") ); |
443 | serviceItem = new BTServiceItem( deviceItem, s1 ); | 475 | serviceItem = new BTServiceItem( deviceItem, s1 ); |
444 | } | 476 | } |
445 | // now remove them from the list | 477 | // now remove them from the list |
446 | m_deviceList.remove( it ); | 478 | m_deviceList.remove( it ); |
447 | } | 479 | } |
448 | 480 | ||
449 | 481 | ||
450 | 482 | ||
451 | 483 | ||
452 | 484 | ||
453 | void BlueBase::addSignalStrength() { | 485 | void BlueBase::addSignalStrength() |
486 | { | ||
454 | 487 | ||
455 | QListViewItemIterator it( ListView4 ); | 488 | QListViewItemIterator it( ListView4 ); |
456 | for ( ; it.current(); ++it ) { | 489 | for ( ; it.current(); ++it ) |
457 | m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() ); | 490 | { |
458 | } | 491 | m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() ); |
492 | } | ||
459 | 493 | ||
460 | QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); | 494 | QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); |
461 | } | 495 | } |
462 | 496 | ||
463 | void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) { | 497 | void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) |
498 | { | ||
464 | 499 | ||
465 | QListViewItemIterator it( ListView4 ); | 500 | QListViewItemIterator it( ListView4 ); |
466 | for ( ; it.current(); ++it ) { | 501 | for ( ; it.current(); ++it ) |
467 | if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) { | 502 | { |
468 | ((BTConnectionItem*)it.current() )->setSignalStrength( strength ); | 503 | if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) |
469 | } | 504 | { |
470 | } | 505 | ((BTConnectionItem*)it.current() )->setSignalStrength( strength ); |
506 | } | ||
507 | } | ||
471 | } | 508 | } |
472 | 509 | ||
473 | /** | 510 | /** |
474 | * Add the existing connections (pairs) to the connections tab. | 511 | * Add the existing connections (pairs) to the connections tab. |
475 | * This one triggers the search | 512 | * This one triggers the search |
476 | */ | 513 | */ |
477 | void BlueBase::addConnectedDevices() { | 514 | void BlueBase::addConnectedDevices() |
478 | m_localDevice->searchConnections(); | 515 | { |
516 | m_localDevice->searchConnections(); | ||
479 | } | 517 | } |
480 | 518 | ||
481 | /** | 519 | /** |
482 | * This adds the found connections to the connection tab. | 520 | * This adds the found connections to the connection tab. |
483 | * @param connectionList the ValueList with all current connections | 521 | * @param connectionList the ValueList with all current connections |
484 | */ | 522 | */ |
485 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { | 523 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) |
524 | { | ||
486 | 525 | ||
487 | QValueList<OpieTooth::ConnectionState>::Iterator it; | 526 | QValueList<OpieTooth::ConnectionState>::Iterator it; |
488 | BTConnectionItem * connectionItem; | 527 | BTConnectionItem * connectionItem; |
489 | 528 | ||
490 | if ( !connectionList.isEmpty() ) { | 529 | if ( !connectionList.isEmpty() ) |
530 | { | ||
491 | 531 | ||
492 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | 532 | for (it = connectionList.begin(); it != connectionList.end(); ++it) |
533 | { | ||
493 | 534 | ||
494 | QListViewItemIterator it2( ListView4 ); | 535 | QListViewItemIterator it2( ListView4 ); |
495 | bool found = false; | 536 | bool found = false; |
496 | for ( ; it2.current(); ++it2 ) { | 537 | for ( ; it2.current(); ++it2 ) |
497 | if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() ) { | 538 | { |
498 | found = true; | 539 | if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() ) |
499 | } | 540 | { |
500 | } | 541 | found = true; |
542 | } | ||
543 | } | ||
501 | 544 | ||
502 | if ( found == false ) { | 545 | if ( found == false ) |
503 | connectionItem = new BTConnectionItem( ListView4, (*it) ); | 546 | { |
547 | connectionItem = new BTConnectionItem( ListView4, (*it) ); | ||
504 | 548 | ||
505 | if( m_deviceList.find((*it).mac()).data() ) { | 549 | if( m_deviceList.find((*it).mac()).data() ) |
506 | connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); | 550 | { |
507 | } | 551 | connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); |
508 | } | 552 | } |
553 | } | ||
509 | 554 | ||
510 | } | 555 | } |
511 | 556 | ||
512 | QListViewItemIterator it2( ListView4 ); | 557 | QListViewItemIterator it2( ListView4 ); |
513 | for ( ; it2.current(); ++it2 ) { | 558 | for ( ; it2.current(); ++it2 ) |
514 | bool found = false; | 559 | { |
515 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | 560 | bool found = false; |
516 | if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() ) { | 561 | for (it = connectionList.begin(); it != connectionList.end(); ++it) |
517 | found = true; | 562 | { |
518 | } | 563 | if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() ) |
564 | { | ||
565 | found = true; | ||
566 | } | ||
519 | } | 567 | } |
520 | 568 | ||
521 | if ( !found ) { | 569 | if ( !found ) |
522 | delete it2.current(); | 570 | { |
523 | } | 571 | delete it2.current(); |
572 | } | ||
524 | 573 | ||
525 | } | 574 | } |
526 | 575 | ||
527 | 576 | ||
528 | } else { | 577 | } |
578 | else | ||
579 | { | ||
529 | ListView4->clear(); | 580 | ListView4->clear(); |
530 | ConnectionState con; | 581 | ConnectionState con; |
531 | con.setMac( tr("No connections found") ); | 582 | con.setMac( tr("No connections found") ); |
532 | connectionItem = new BTConnectionItem( ListView4 , con ); | 583 | connectionItem = new BTConnectionItem( ListView4 , con ); |
533 | } | 584 | } |
534 | 585 | ||
@@ -538,86 +589,96 @@ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) | |||
538 | 589 | ||
539 | 590 | ||
540 | /** | 591 | /** |
541 | * Find out if a device can currently be reached | 592 | * Find out if a device can currently be reached |
542 | * @param device | 593 | * @param device |
543 | */ | 594 | */ |
544 | void BlueBase::deviceActive( const RemoteDevice &device ) { | 595 | void BlueBase::deviceActive( const RemoteDevice &device ) |
596 | { | ||
545 | // search by mac, async, gets a signal back | 597 | // search by mac, async, gets a signal back |
546 | // We should have a BTDeviceItem there or where does it get added to the map -zecke | 598 | // We should have a BTDeviceItem there or where does it get added to the map -zecke |
547 | m_localDevice->isAvailable( device.mac() ); | 599 | m_localDevice->isAvailable( device.mac() ); |
548 | } | 600 | } |
549 | 601 | ||
550 | 602 | ||
551 | /** | 603 | /** |
552 | * The signal catcher. Set the avail. status on device. | 604 | * The signal catcher. Set the avail. status on device. |
553 | * @param device - the mac address | 605 | * @param device - the mac address |
554 | * @param connected - if it is avail. or not | 606 | * @param connected - if it is avail. or not |
555 | */ | 607 | */ |
556 | void BlueBase::deviceActive( const QString& device, bool connected ) { | 608 | void BlueBase::deviceActive( const QString& device, bool connected ) |
609 | { | ||
557 | qDebug("deviceActive slot"); | 610 | qDebug("deviceActive slot"); |
558 | 611 | ||
559 | QMap<QString,BTDeviceItem*>::Iterator it; | 612 | QMap<QString,BTDeviceItem*>::Iterator it; |
560 | 613 | ||
561 | it = m_deviceList.find( device ); | 614 | it = m_deviceList.find( device ); |
562 | if( it == m_deviceList.end() ) | 615 | if( it == m_deviceList.end() ) |
563 | return; | 616 | return; |
564 | 617 | ||
565 | BTDeviceItem* deviceItem = it.data(); | 618 | BTDeviceItem* deviceItem = it.data(); |
566 | 619 | ||
567 | 620 | ||
568 | if ( connected ) { | 621 | if ( connected ) |
622 | { | ||
569 | deviceItem->setPixmap( 1, m_onPix ); | 623 | deviceItem->setPixmap( 1, m_onPix ); |
570 | } else { | 624 | } |
625 | else | ||
626 | { | ||
571 | deviceItem->setPixmap( 1, m_offPix ); | 627 | deviceItem->setPixmap( 1, m_offPix ); |
572 | } | 628 | } |
573 | m_deviceList.remove( it ); | 629 | m_deviceList.remove( it ); |
574 | } | 630 | } |
575 | 631 | ||
576 | 632 | ||
577 | /** | 633 | /** |
578 | * Open the "scan for devices" dialog | 634 | * Open the "scan for devices" dialog |
579 | */ | 635 | */ |
580 | void BlueBase::startScan() { | 636 | void BlueBase::startScan() |
637 | { | ||
581 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", | 638 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", |
582 | true, WDestructiveClose ); | 639 | true, WDestructiveClose ); |
583 | QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), | 640 | QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), |
584 | this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); | 641 | this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); |
585 | 642 | ||
586 | scan->showMaximized(); | 643 | QPEApplication::showDialog( scan ); |
587 | } | 644 | } |
588 | 645 | ||
589 | 646 | ||
590 | /** | 647 | /** |
591 | * Set the informations about the local device in information Tab | 648 | * Set the informations about the local device in information Tab |
592 | */ | 649 | */ |
593 | void BlueBase::setInfo() { | 650 | void BlueBase::setInfo() |
651 | { | ||
594 | StatusLabel->setText( status() ); | 652 | StatusLabel->setText( status() ); |
595 | } | 653 | } |
596 | 654 | ||
597 | 655 | ||
598 | /** | 656 | /** |
599 | * Decontructor | 657 | * Decontructor |
600 | */ | 658 | */ |
601 | BlueBase::~BlueBase() { | 659 | BlueBase::~BlueBase() |
660 | { | ||
602 | writeSavedDevices(); | 661 | writeSavedDevices(); |
603 | delete m_iconLoader; | 662 | delete m_iconLoader; |
604 | } | 663 | } |
605 | 664 | ||
606 | 665 | ||
607 | /** | 666 | /** |
608 | * find searches the ListView for a BTDeviceItem containig | 667 | * find searches the ListView for a BTDeviceItem containig |
609 | * the same Device if found return true else false | 668 | * the same Device if found return true else false |
610 | * @param dev RemoteDevice to find | 669 | * @param dev RemoteDevice to find |
611 | * @return returns true if found | 670 | * @return returns true if found |
612 | */ | 671 | */ |
613 | bool BlueBase::find( const RemoteDevice& rem ) { | 672 | bool BlueBase::find( const RemoteDevice& rem ) |
673 | { | ||
614 | QListViewItemIterator it( ListView2 ); | 674 | QListViewItemIterator it( ListView2 ); |
615 | BTListItem* item; | 675 | BTListItem* item; |
616 | BTDeviceItem* device; | 676 | BTDeviceItem* device; |
617 | for (; it.current(); ++it ) { | 677 | for (; it.current(); ++it ) |
678 | { | ||
618 | item = (BTListItem*) it.current(); | 679 | item = (BTListItem*) it.current(); |
619 | if ( item->typeId() != BTListItem::Device ) | 680 | if ( item->typeId() != BTListItem::Device ) |
620 | continue; | 681 | continue; |
621 | 682 | ||
622 | device = (BTDeviceItem*)item; | 683 | device = (BTDeviceItem*)item; |
623 | if ( rem.equals( device->remoteDevice() ) ) | 684 | if ( rem.equals( device->remoteDevice() ) ) |
diff --git a/noncore/net/opietooth/manager/obexpopup.cpp b/noncore/net/opietooth/manager/obexpopup.cpp index a550648..d147d52 100644 --- a/noncore/net/opietooth/manager/obexpopup.cpp +++ b/noncore/net/opietooth/manager/obexpopup.cpp | |||
@@ -1,19 +1,24 @@ | |||
1 | 1 | ||
2 | #include <qtimer.h> | ||
3 | |||
4 | #include "obexdialog.h" | 2 | #include "obexdialog.h" |
5 | #include "obexpopup.h" | 3 | #include "obexpopup.h" |
6 | 4 | ||
5 | /* OPIE */ | ||
6 | #include <qpe/qpeapplication.h> | ||
7 | |||
8 | /* QT */ | ||
9 | #include <qtimer.h> | ||
10 | |||
7 | using namespace OpieTooth; | 11 | using namespace OpieTooth; |
8 | 12 | ||
9 | /* | 13 | /* |
10 | * c'tor init the QAction | 14 | * c'tor init the QAction |
11 | */ | 15 | */ |
12 | ObexPopup::ObexPopup() | 16 | ObexPopup::ObexPopup() |
13 | : QPopupMenu() { | 17 | : QPopupMenu() |
18 | { | ||
14 | qWarning("RfcCommPopup c'tor"); | 19 | qWarning("RfcCommPopup c'tor"); |
15 | 20 | ||
16 | QAction* a; | 21 | QAction* a; |
17 | 22 | ||
18 | /* connect action */ | 23 | /* connect action */ |
19 | a = new QAction( ); // so it's get deleted | 24 | a = new QAction( ); // so it's get deleted |
@@ -21,21 +26,20 @@ ObexPopup::ObexPopup() | |||
21 | a->addTo( this ); | 26 | a->addTo( this ); |
22 | connect( a, SIGNAL( activated() ), | 27 | connect( a, SIGNAL( activated() ), |
23 | this, SLOT( slotPush() ) ); | 28 | this, SLOT( slotPush() ) ); |
24 | }; | 29 | }; |
25 | 30 | ||
26 | 31 | ||
27 | ObexPopup::~ObexPopup() { | 32 | ObexPopup::~ObexPopup() |
28 | } | 33 | {} |
29 | 34 | ||
30 | 35 | ||
31 | void ObexPopup::slotPush() { | 36 | void ObexPopup::slotPush() |
37 | { | ||
32 | 38 | ||
33 | qWarning("push something"); | 39 | qWarning("push something"); |
34 | 40 | ||
35 | |||
36 | ObexDialog obexDialog; | 41 | ObexDialog obexDialog; |
37 | obexDialog.showMaximized(); | 42 | QPEApplication::execDialog( &obexDialog ); |
38 | obexDialog.exec(); | ||
39 | } | 43 | } |
40 | 44 | ||
41 | 45 | ||
diff --git a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp index b5cc074..fc76301 100644 --- a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp +++ b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp | |||
@@ -1,24 +1,28 @@ | |||
1 | 1 | ||
2 | #include "rfcommassigndialogimpl.h" | 2 | #include "rfcommassigndialogimpl.h" |
3 | #include "rfcommassigndialogitem.h" | 3 | #include "rfcommassigndialogitem.h" |
4 | #include "rfcommconfhandler.h" | 4 | #include "rfcommconfhandler.h" |
5 | 5 | ||
6 | /* OPIE */ | ||
6 | #include <qpe/config.h> | 7 | #include <qpe/config.h> |
8 | #include <qpe/qpeapplication.h> | ||
7 | 9 | ||
10 | /* QT */ | ||
8 | #include <qlayout.h> | 11 | #include <qlayout.h> |
9 | 12 | ||
10 | using namespace OpieTooth; | 13 | using namespace OpieTooth; |
11 | 14 | ||
12 | // TODO: write only the file in bluebase? | 15 | // TODO: write only the file in bluebase? |
13 | // muss rfcommd dann neu gestartet werden | 16 | // muss rfcommd dann neu gestartet werden |
14 | // sollte rfcomm bind all nicht eh default config sein ( polled das? - d.h. sobald nen gerät in der nähe ist bindet es? | 17 | // sollte rfcomm bind all nicht eh default config sein ( polled das? - d.h. sobald nen gerät in der nähe ist bindet es? |
15 | 18 | ||
16 | 19 | ||
17 | RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 20 | RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
18 | : RfcommAssignDialogBase( parent, name, modal, fl ) { | 21 | : RfcommAssignDialogBase( parent, name, modal, fl ) |
22 | { | ||
19 | 23 | ||
20 | m_range = 5; | 24 | m_range = 5; |
21 | 25 | ||
22 | m_scrollView = new QScrollView( this ); | 26 | m_scrollView = new QScrollView( this ); |
23 | m_scrollView->setResizePolicy( QScrollView::AutoOneFit ); | 27 | m_scrollView->setResizePolicy( QScrollView::AutoOneFit ); |
24 | m_scrollView->setHScrollBarMode( QScrollView::AlwaysOff ); | 28 | m_scrollView->setHScrollBarMode( QScrollView::AlwaysOff ); |
@@ -30,81 +34,92 @@ RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool | |||
30 | 34 | ||
31 | confHandler = new RfCommConfHandler( "/etc/bluetooth/rfcomm.conf" ); | 35 | confHandler = new RfCommConfHandler( "/etc/bluetooth/rfcomm.conf" ); |
32 | 36 | ||
33 | loadConfig(); | 37 | loadConfig(); |
34 | } | 38 | } |
35 | 39 | ||
36 | RfcommAssignDialog::~RfcommAssignDialog() { | 40 | RfcommAssignDialog::~RfcommAssignDialog() |
37 | if ( confHandler ) { | 41 | { |
42 | if ( confHandler ) | ||
43 | { | ||
38 | delete confHandler; | 44 | delete confHandler; |
39 | } | 45 | } |
40 | } | 46 | } |
41 | 47 | ||
42 | 48 | ||
43 | void RfcommAssignDialog::newDevice( const QString & mac ) { | 49 | void RfcommAssignDialog::newDevice( const QString & mac ) |
50 | { | ||
44 | 51 | ||
45 | for ( int i = 0 ; i < m_range; i++ ) { | 52 | for ( int i = 0 ; i < m_range; i++ ) |
53 | { | ||
46 | 54 | ||
47 | QMap<QString, RfCommConfObject*>::Iterator it; | 55 | QMap<QString, RfCommConfObject*>::Iterator it; |
48 | it = confHandler->foundEntries().find( QString("%1").arg( i ) ); | 56 | it = confHandler->foundEntries().find( QString("%1").arg( i ) ); |
49 | // make sure that rfcommX is not assigned yet | 57 | // make sure that rfcommX is not assigned yet |
50 | if ( it == confHandler->foundEntries().end() ) { | 58 | if ( it == confHandler->foundEntries().end() ) |
59 | { | ||
51 | QDialog dialog( this, "newdevice", true, WStyle_ContextHelp ); | 60 | QDialog dialog( this, "newdevice", true, WStyle_ContextHelp ); |
52 | dialog.showMaximized(); | 61 | |
53 | RfcommDialogItem *newDev = new RfcommDialogItem( &dialog ); | 62 | RfcommDialogItem *newDev = new RfcommDialogItem( &dialog ); |
54 | newDev->setIdent( i ); | 63 | newDev->setIdent( i ); |
55 | newDev->setMac( mac ); | 64 | newDev->setMac( mac ); |
56 | 65 | ||
57 | if ( dialog.exec() == QDialog::Accepted ) { | 66 | if ( QPEApplication::execDialog( &dialog ) == QDialog::Accepted ) |
67 | { | ||
58 | RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); | 68 | RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); |
59 | m_itemList.insert( i , rfcomm ); | 69 | m_itemList.insert( i , rfcomm ); |
60 | rfcomm->setIdent( i ); | 70 | rfcomm->setIdent( i ); |
61 | rfcomm->setMac( mac ); | 71 | rfcomm->setMac( mac ); |
62 | rfcomm->setChannel( newDev->channel() ); | 72 | rfcomm->setChannel( newDev->channel() ); |
63 | rfcomm->setComment( newDev->comment() ); | 73 | rfcomm->setComment( newDev->comment() ); |
64 | qDebug( "New device set up" ); | 74 | qDebug( "New device set up" ); |
65 | } | 75 | } |
66 | } | 76 | } |
67 | } | 77 | } |
68 | } | 78 | } |
69 | 79 | ||
70 | void RfcommAssignDialog::loadConfig() { | 80 | void RfcommAssignDialog::loadConfig() |
81 | { | ||
71 | 82 | ||
72 | //Config cfg( "bluetoothmanager-rfcommbind" ); | 83 | //Config cfg( "bluetoothmanager-rfcommbind" ); |
73 | 84 | ||
74 | for ( int i = 0 ; i < m_range; i++ ) { | 85 | for ( int i = 0 ; i < m_range; i++ ) |
86 | { | ||
75 | // cfg.setGroup( QString("%1").arg( i ) ); | 87 | // cfg.setGroup( QString("%1").arg( i ) ); |
76 | RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); | 88 | RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); |
77 | m_itemList.insert( i , rfcomm ); | 89 | m_itemList.insert( i , rfcomm ); |
78 | rfcomm->setIdent( i ); | 90 | rfcomm->setIdent( i ); |
79 | QMap<QString, RfCommConfObject*>::Iterator it; | 91 | QMap<QString, RfCommConfObject*>::Iterator it; |
80 | it = confHandler->foundEntries().find( QString("%1").arg( i ) ); | 92 | it = confHandler->foundEntries().find( QString("%1").arg( i ) ); |
81 | if ( it != confHandler->foundEntries().end() ) { | 93 | if ( it != confHandler->foundEntries().end() ) |
94 | { | ||
82 | qDebug( "Found key in foundEntries() " ); | 95 | qDebug( "Found key in foundEntries() " ); |
83 | rfcomm->setMac( it.data()->mac() ); | 96 | rfcomm->setMac( it.data()->mac() ); |
84 | rfcomm->setChannel( it.data()->channel() ); | 97 | rfcomm->setChannel( it.data()->channel() ); |
85 | rfcomm->setComment( it.data()->comment() ); | 98 | rfcomm->setComment( it.data()->comment() ); |
86 | } | 99 | } |
87 | /* Use rfcomm.conf directly for now | 100 | /* Use rfcomm.conf directly for now |
88 | * rfcomm->setMac( cfg.readEntry( "mac", "" ) ); | 101 | * rfcomm->setMac( cfg.readEntry( "mac", "" ) ); |
89 | * rfcomm->setChannel( cfg.readNumEntry( "channel", 1 ) ); | 102 | * rfcomm->setChannel( cfg.readNumEntry( "channel", 1 ) ); |
90 | * rfcomm->setComment( cfg.readEntry( "comment", "" ) ); | 103 | * rfcomm->setComment( cfg.readEntry( "comment", "" ) ); |
91 | */ | 104 | */ |
92 | } | 105 | } |
93 | } | 106 | } |
94 | 107 | ||
95 | 108 | ||
96 | void RfcommAssignDialog::saveConfig() { | 109 | void RfcommAssignDialog::saveConfig() |
110 | { | ||
97 | 111 | ||
98 | //Config cfg( "bluetoothmanager-rfcommbind" ); | 112 | //Config cfg( "bluetoothmanager-rfcommbind" ); |
99 | 113 | ||
100 | QMap< int, RfcommDialogItem*>::Iterator it; | 114 | QMap< int, RfcommDialogItem*>::Iterator it; |
101 | 115 | ||
102 | QMap< QString, RfCommConfObject*> outMap; | 116 | QMap< QString, RfCommConfObject*> outMap; |
103 | 117 | ||
104 | for( it = m_itemList.begin(); it != m_itemList.end(); ++it ) { | 118 | for( it = m_itemList.begin(); it != m_itemList.end(); ++it ) |
119 | { | ||
105 | 120 | ||
106 | //cfg.setGroup( QString("%1").arg( it.key() ) ); | 121 | //cfg.setGroup( QString("%1").arg( it.key() ) ); |
107 | RfcommDialogItem *rfcomm = it.data(); | 122 | RfcommDialogItem *rfcomm = it.data(); |
108 | 123 | ||
109 | 124 | ||
110 | outMap.insert( QString( "%1").arg( it.key() ), new RfCommConfObject( it.key(), rfcomm->mac(), rfcomm->channel(), rfcomm->comment() ) ); | 125 | outMap.insert( QString( "%1").arg( it.key() ), new RfCommConfObject( it.key(), rfcomm->mac(), rfcomm->channel(), rfcomm->comment() ) ); |
diff --git a/noncore/net/opietooth/manager/rfcpopup.cpp b/noncore/net/opietooth/manager/rfcpopup.cpp index d95f14b..04bfe48 100644 --- a/noncore/net/opietooth/manager/rfcpopup.cpp +++ b/noncore/net/opietooth/manager/rfcpopup.cpp | |||
@@ -1,20 +1,25 @@ | |||
1 | 1 | ||
2 | #include <qtimer.h> | ||
3 | |||
4 | #include "pppdialog.h" | 2 | #include "pppdialog.h" |
5 | #include "rfcpopup.h" | 3 | #include "rfcpopup.h" |
6 | #include "rfcommassigndialogimpl.h" | 4 | #include "rfcommassigndialogimpl.h" |
7 | 5 | ||
6 | /* OPIE */ | ||
7 | #include <qpe/qpeapplication.h> | ||
8 | |||
9 | /* QT */ | ||
10 | #include <qtimer.h> | ||
11 | |||
8 | using namespace OpieTooth; | 12 | using namespace OpieTooth; |
9 | 13 | ||
10 | /* | 14 | /* |
11 | * c'tor init the QAction | 15 | * c'tor init the QAction |
12 | */ | 16 | */ |
13 | RfcCommPopup::RfcCommPopup( OpieTooth::BTDeviceItem* item ) | 17 | RfcCommPopup::RfcCommPopup( OpieTooth::BTDeviceItem* item ) |
14 | : QPopupMenu() { | 18 | : QPopupMenu() |
19 | { | ||
15 | qWarning("RfcCommPopup c'tor"); | 20 | qWarning("RfcCommPopup c'tor"); |
16 | 21 | ||
17 | QAction* a; | 22 | QAction* a; |
18 | 23 | ||
19 | 24 | ||
20 | m_item = item; | 25 | m_item = item; |
@@ -29,68 +34,70 @@ RfcCommPopup::RfcCommPopup( OpieTooth::BTDeviceItem* item ) | |||
29 | 34 | ||
30 | /* disconnect action */ | 35 | /* disconnect action */ |
31 | a = new QAction( ); | 36 | a = new QAction( ); |
32 | a->setText("Disconnect"); | 37 | a->setText("Disconnect"); |
33 | a->addTo( this ); | 38 | a->addTo( this ); |
34 | connect( a, SIGNAL( activated() ) , | 39 | connect( a, SIGNAL( activated() ) , |
35 | this, SLOT( slotDisconnect() ) ); | 40 | this, SLOT( slotDisconnect() ) ); |
36 | 41 | ||
37 | 42 | ||
38 | /* foo action */ | 43 | /* foo action */ |
39 | a = new QAction( ); | 44 | a = new QAction( ); |
40 | a->setText("Bind table"); | 45 | a->setText("Bind table"); |
41 | a->addTo( this ); | 46 | a->addTo( this ); |
42 | connect( a, SIGNAL( activated() ), | 47 | connect( a, SIGNAL( activated() ), |
43 | this, SLOT( slotBind() ) ); | 48 | this, SLOT( slotBind() ) ); |
44 | 49 | ||
45 | 50 | ||
46 | /* bar action */ | 51 | /* bar action */ |
47 | a = new QAction( ); | 52 | a = new QAction( ); |
48 | a->setText( "Bar" ); | 53 | a->setText( "Bar" ); |
49 | a->addTo( this ); | 54 | a->addTo( this ); |
50 | connect( a, SIGNAL( activated() ), | 55 | connect( a, SIGNAL( activated() ), |
51 | this, SLOT( slotBar() ) ); | 56 | this, SLOT( slotBar() ) ); |
52 | 57 | ||
53 | }; | 58 | }; |
54 | 59 | ||
55 | 60 | ||
56 | RfcCommPopup::~RfcCommPopup() { | 61 | RfcCommPopup::~RfcCommPopup() |
57 | /* delete m_con; | 62 | { |
58 | delete m_dis; | 63 | /* delete m_con; |
59 | delete m_foo; | 64 | delete m_dis; |
60 | delete m_bar; */ | 65 | delete m_foo; |
66 | delete m_bar; */ | ||
61 | } | 67 | } |
62 | 68 | ||
63 | 69 | ||
64 | void RfcCommPopup::slotConnect() { | 70 | void RfcCommPopup::slotConnect() |
71 | { | ||
65 | 72 | ||
66 | qWarning("connect"); | 73 | qWarning("connect"); |
67 | 74 | ||
68 | |||
69 | |||
70 | PPPDialog pppDialog; | 75 | PPPDialog pppDialog; |
71 | pppDialog.showMaximized(); | 76 | QPEApplication::execDialog( &pppDialog ); |
72 | pppDialog.exec(); | ||
73 | } | 77 | } |
74 | 78 | ||
75 | 79 | ||
76 | void RfcCommPopup::slotDisconnect() { | 80 | void RfcCommPopup::slotDisconnect() |
81 | { | ||
77 | qWarning("slot disconnected"); | 82 | qWarning("slot disconnected"); |
78 | } | 83 | } |
79 | 84 | ||
80 | 85 | ||
81 | void RfcCommPopup::slotBind() { | 86 | void RfcCommPopup::slotBind() |
87 | { | ||
82 | RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); | 88 | RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); |
83 | 89 | ||
84 | rfcommAssign.showMaximized(); | ||
85 | rfcommAssign.newDevice( m_item->mac() ); | 90 | rfcommAssign.newDevice( m_item->mac() ); |
86 | 91 | ||
87 | if ( rfcommAssign.exec() == QDialog::Accepted ) { | 92 | if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted ) |
93 | { | ||
88 | rfcommAssign.saveConfig(); | 94 | rfcommAssign.saveConfig(); |
89 | } | 95 | } |
90 | } | 96 | } |
91 | 97 | ||
92 | 98 | ||
93 | void RfcCommPopup::slotBar() { | 99 | void RfcCommPopup::slotBar() |
100 | { | ||
94 | qWarning("slotBar"); | 101 | qWarning("slotBar"); |
95 | }; | 102 | }; |
96 | 103 | ||