author | mickeyl <mickeyl> | 2005-08-23 20:37:03 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-08-23 20:37:03 (UTC) |
commit | 68c01ad5f6e7dc12192c9ce77f0a2ee48b813831 (patch) (unidiff) | |
tree | 054dd974156c8e49400979eb9b226bb7bd32fd31 /core | |
parent | 95210ac41729a4c264e830963cdae3a4cdd218fb (diff) | |
download | opie-68c01ad5f6e7dc12192c9ce77f0a2ee48b813831.zip opie-68c01ad5f6e7dc12192c9ce77f0a2ee48b813831.tar.gz opie-68c01ad5f6e7dc12192c9ce77f0a2ee48b813831.tar.bz2 |
- fix SIGSEGV when trying to send but IrDA is not enabled
- rename 'scan' button to 'rescan'
- disable 'send' button if IrDA and BT is both disabled
-rw-r--r-- | core/obex/obexsend.cpp | 51 | ||||
-rw-r--r-- | core/obex/obexsendbase.ui | 8 |
2 files changed, 32 insertions, 27 deletions
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp index a80a48b..9cd9972 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp | |||
@@ -8,24 +8,25 @@ | |||
8 | #include "obexsend.h" | 8 | #include "obexsend.h" |
9 | using namespace OpieObex; | 9 | using namespace OpieObex; |
10 | 10 | ||
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | #include <opie2/odebug.h> | 12 | #include <opie2/odebug.h> |
13 | #include <qpe/qcopenvelope_qws.h> | 13 | #include <qpe/qcopenvelope_qws.h> |
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | 15 | ||
16 | using namespace Opie::Core; | 16 | using namespace Opie::Core; |
17 | 17 | ||
18 | /* QT */ | 18 | /* QT */ |
19 | #include <qlabel.h> | 19 | #include <qlabel.h> |
20 | #include <qpushbutton.h> | ||
20 | #include <qpixmap.h> | 21 | #include <qpixmap.h> |
21 | #include <qlistview.h> | 22 | #include <qlistview.h> |
22 | #include <qtimer.h> | 23 | #include <qtimer.h> |
23 | 24 | ||
24 | /* TRANSLATOR OpieObex::SendWidget */ | 25 | /* TRANSLATOR OpieObex::SendWidget */ |
25 | 26 | ||
26 | SendWidget::SendWidget( QWidget* parent, const char* name ) | 27 | SendWidget::SendWidget( QWidget* parent, const char* name ) |
27 | : obexSendBase( parent, name ) { | 28 | : obexSendBase( parent, name ) { |
28 | initUI(); | 29 | initUI(); |
29 | } | 30 | } |
30 | SendWidget::~SendWidget() { | 31 | SendWidget::~SendWidget() { |
31 | } | 32 | } |
@@ -129,25 +130,26 @@ void SendWidget::slotIrError( int ) { | |||
129 | irdaStatus->setText(tr("error :(")); | 130 | irdaStatus->setText(tr("error :(")); |
130 | } | 131 | } |
131 | void SendWidget::slotIrSent( bool b) { | 132 | void SendWidget::slotIrSent( bool b) { |
132 | QString text = b ? tr("Sent") : tr("Failure"); | 133 | QString text = b ? tr("Sent") : tr("Failure"); |
133 | setReceiverStatus( m_irDaIt.key(), text ); | 134 | setReceiverStatus( m_irDaIt.key(), text ); |
134 | ++m_irDaIt; | 135 | ++m_irDaIt; |
135 | slotStartIrda(); | 136 | slotStartIrda(); |
136 | } | 137 | } |
137 | void SendWidget::slotIrTry(unsigned int trI) { | 138 | void SendWidget::slotIrTry(unsigned int trI) { |
138 | setReceiverStatus(m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) )); | 139 | setReceiverStatus(m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) )); |
139 | } | 140 | } |
140 | void SendWidget::slotStartIrda() { | 141 | void SendWidget::slotStartIrda() { |
141 | if (m_irDaIt == m_irDa.end() ) { | 142 | if ( !m_irDa.count() ) return; |
143 | if ( m_irDaIt == m_irDa.end() ) { | ||
142 | irdaStatus->setText(tr("complete.")); | 144 | irdaStatus->setText(tr("complete.")); |
143 | return; | 145 | return; |
144 | } | 146 | } |
145 | setReceiverStatus( m_irDaIt.key(), tr("Start sending") ); | 147 | setReceiverStatus( m_irDaIt.key(), tr("Start sending") ); |
146 | m_obex->send( m_file ); | 148 | m_obex->send( m_file ); |
147 | } | 149 | } |
148 | 150 | ||
149 | void SendWidget::dispatchBt( const QCString& str, const QByteArray& ar ) { | 151 | void SendWidget::dispatchBt( const QCString& str, const QByteArray& ar ) { |
150 | if ( str == "devices(QStringMap)" ) { | 152 | if ( str == "devices(QStringMap)" ) { |
151 | QDataStream stream( ar, IO_ReadOnly ); | 153 | QDataStream stream( ar, IO_ReadOnly ); |
152 | QMap<QString, QString> btmap; | 154 | QMap<QString, QString> btmap; |
153 | stream >> btmap; | 155 | stream >> btmap; |
@@ -174,49 +176,52 @@ void SendWidget::slotStartBt() { | |||
174 | btStatus->setText(tr("complete.")); | 176 | btStatus->setText(tr("complete.")); |
175 | return; | 177 | return; |
176 | } | 178 | } |
177 | setReceiverStatus( m_btIt.key(), tr("Start sending") ); | 179 | setReceiverStatus( m_btIt.key(), tr("Start sending") ); |
178 | m_btobex->send( m_file, m_btIt.data().second() ); | 180 | m_btobex->send( m_file, m_btIt.data().second() ); |
179 | } | 181 | } |
180 | 182 | ||
181 | void SendWidget::send_to_receivers() { | 183 | void SendWidget::send_to_receivers() { |
182 | slotStartIrda(); | 184 | slotStartIrda(); |
183 | slotStartBt(); | 185 | slotStartBt(); |
184 | } | 186 | } |
185 | 187 | ||
186 | void SendWidget::scan_for_receivers() { | 188 | void SendWidget::scan_for_receivers() |
187 | 189 | { | |
188 | bool enable_irda=false; | 190 | //FIXME: Clean ListBox prior to (re)scan |
189 | bool enable_bt=false; | 191 | sendButton->setDisabled( true ); |
190 | |||
191 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) { | ||
192 | irdaStatus->setText(tr("not enabled.")); | ||
193 | enable_irda=true; | ||
194 | } else | ||
195 | irdaStatus->setText(tr("searching...")); | ||
196 | 192 | ||
197 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) { | 193 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) |
198 | btStatus->setText(tr("not enabled.")); | 194 | { |
199 | enable_bt=true; | 195 | irdaStatus->setText(tr("not enabled.")); |
200 | } else | 196 | } |
201 | btStatus->setText(tr("searching...")); | 197 | else |
198 | { | ||
199 | QCopEnvelope e1("QPE/IrDaApplet", "enableIrda()"); | ||
200 | irdaStatus->setText(tr("searching...")); | ||
201 | sendButton->setEnabled( true ); | ||
202 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | ||
203 | } | ||
202 | 204 | ||
203 | if (enable_irda) | 205 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) |
204 | QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); | 206 | { |
205 | if (enable_bt) | 207 | btStatus->setText(tr("not enabled.")); |
208 | } | ||
209 | else | ||
210 | { | ||
206 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); | 211 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); |
207 | 212 | btStatus->setText(tr("searching...")); | |
208 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 213 | sendButton->setEnabled( true ); |
209 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); | 214 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); |
210 | 215 | } | |
211 | } | 216 | } |
212 | 217 | ||
213 | void SendWidget::toggle_receiver(QListViewItem* item) | 218 | void SendWidget::toggle_receiver(QListViewItem* item) |
214 | { | 219 | { |
215 | // toggle the state of an individual receiver. | 220 | // toggle the state of an individual receiver. |
216 | if(item->pixmap(2)) | 221 | if(item->pixmap(2)) |
217 | item->setPixmap(2,QPixmap()); | 222 | item->setPixmap(2,QPixmap()); |
218 | else | 223 | else |
219 | item->setPixmap(2,Resource::loadPixmap("backup/check.png")); | 224 | item->setPixmap(2,Resource::loadPixmap("backup/check.png")); |
220 | } | 225 | } |
221 | 226 | ||
222 | 227 | ||
diff --git a/core/obex/obexsendbase.ui b/core/obex/obexsendbase.ui index a192dd3..4619842 100644 --- a/core/obex/obexsendbase.ui +++ b/core/obex/obexsendbase.ui | |||
@@ -7,25 +7,25 @@ for selecting destination hosts.</comment> | |||
7 | <include location="global">qlistview.h</include> | 7 | <include location="global">qlistview.h</include> |
8 | <widget> | 8 | <widget> |
9 | <class>QWidget</class> | 9 | <class>QWidget</class> |
10 | <property stdset="1"> | 10 | <property stdset="1"> |
11 | <name>name</name> | 11 | <name>name</name> |
12 | <cstring>obexSendBase</cstring> | 12 | <cstring>obexSendBase</cstring> |
13 | </property> | 13 | </property> |
14 | <property stdset="1"> | 14 | <property stdset="1"> |
15 | <name>geometry</name> | 15 | <name>geometry</name> |
16 | <rect> | 16 | <rect> |
17 | <x>0</x> | 17 | <x>0</x> |
18 | <y>0</y> | 18 | <y>0</y> |
19 | <width>363</width> | 19 | <width>359</width> |
20 | <height>221</height> | 20 | <height>221</height> |
21 | </rect> | 21 | </rect> |
22 | </property> | 22 | </property> |
23 | <property stdset="1"> | 23 | <property stdset="1"> |
24 | <name>caption</name> | 24 | <name>caption</name> |
25 | <string>Send via OBEX</string> | 25 | <string>Send via OBEX</string> |
26 | </property> | 26 | </property> |
27 | <vbox> | 27 | <vbox> |
28 | <property stdset="1"> | 28 | <property stdset="1"> |
29 | <name>margin</name> | 29 | <name>margin</name> |
30 | <number>11</number> | 30 | <number>11</number> |
31 | </property> | 31 | </property> |
@@ -288,47 +288,47 @@ for selecting destination hosts.</comment> | |||
288 | <height>20</height> | 288 | <height>20</height> |
289 | </size> | 289 | </size> |
290 | </property> | 290 | </property> |
291 | </spacer> | 291 | </spacer> |
292 | <widget> | 292 | <widget> |
293 | <class>QPushButton</class> | 293 | <class>QPushButton</class> |
294 | <property stdset="1"> | 294 | <property stdset="1"> |
295 | <name>name</name> | 295 | <name>name</name> |
296 | <cstring>scanButton</cstring> | 296 | <cstring>scanButton</cstring> |
297 | </property> | 297 | </property> |
298 | <property stdset="1"> | 298 | <property stdset="1"> |
299 | <name>text</name> | 299 | <name>text</name> |
300 | <string>Scan</string> | 300 | <string>&Rescan</string> |
301 | </property> | 301 | </property> |
302 | </widget> | 302 | </widget> |
303 | <widget> | 303 | <widget> |
304 | <class>QPushButton</class> | 304 | <class>QPushButton</class> |
305 | <property stdset="1"> | 305 | <property stdset="1"> |
306 | <name>name</name> | 306 | <name>name</name> |
307 | <cstring>sendButton</cstring> | 307 | <cstring>sendButton</cstring> |
308 | </property> | 308 | </property> |
309 | <property stdset="1"> | 309 | <property stdset="1"> |
310 | <name>text</name> | 310 | <name>text</name> |
311 | <string>Send</string> | 311 | <string>&Send</string> |
312 | </property> | 312 | </property> |
313 | </widget> | 313 | </widget> |
314 | <widget> | 314 | <widget> |
315 | <class>QPushButton</class> | 315 | <class>QPushButton</class> |
316 | <property stdset="1"> | 316 | <property stdset="1"> |
317 | <name>name</name> | 317 | <name>name</name> |
318 | <cstring>doneButton</cstring> | 318 | <cstring>doneButton</cstring> |
319 | </property> | 319 | </property> |
320 | <property stdset="1"> | 320 | <property stdset="1"> |
321 | <name>text</name> | 321 | <name>text</name> |
322 | <string>Done</string> | 322 | <string>&Close</string> |
323 | </property> | 323 | </property> |
324 | </widget> | 324 | </widget> |
325 | </hbox> | 325 | </hbox> |
326 | </widget> | 326 | </widget> |
327 | </vbox> | 327 | </vbox> |
328 | </widget> | 328 | </widget> |
329 | <images> | 329 | <images> |
330 | <image> | 330 | <image> |
331 | <name>image0</name> | 331 | <name>image0</name> |
332 | <data format="XPM.GZ" length="356">789c5d8f410a02310c45f73d456876453a0aeec423282e05719156075d8c82332e44bcbb4d52eb4c435bf25ffe6f69e360bfdb806b4c3fd0708d102ff400777a76ddeb705cbf8d5d2c21ad74d899b11e226cefb733f721f5389762492c6391c8b26d7fd24f2a13a49a7844ac88f79499120d118eef1126a8a4248393141b789794e23f91a952212148afa64c823acaeb42ea5f8cc86765bebe81454c</data> | 332 | <data format="XPM.GZ" length="356">789c5d8f410a02310c45f73d456876453a0aeec423282e05719156075d8c82332e44bcbb4d52eb4c435bf25ffe6f69e360bfdb806b4c3fd0708d102ff400777a76ddeb705cbf8d5d2c21ad74d899b11e226cefb733f721f5389762492c6391c8b26d7fd24f2a13a49a7844ac88f79499120d118eef1126a8a4248393141b789794e23f91a952212148afa64c823acaeb42ea5f8cc86765bebe81454c</data> |
333 | </image> | 333 | </image> |
334 | <image> | 334 | <image> |