-rw-r--r-- | core/obex/obexsend.cpp | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp index 45754e3..d58b4e9 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp | |||
@@ -4,18 +4,24 @@ | |||
4 | // all. | 4 | // all. |
5 | 5 | ||
6 | #include "obex.h" | 6 | #include "obex.h" |
7 | #ifdef BLUETOOTH | ||
7 | #include "btobex.h" | 8 | #include "btobex.h" |
9 | #endif | ||
8 | #include "obexsend.h" | 10 | #include "obexsend.h" |
9 | using namespace OpieObex; | 11 | using namespace OpieObex; |
12 | #ifdef BLUETOOTH | ||
10 | using namespace OpieTooth; | 13 | using namespace OpieTooth; |
14 | #endif | ||
11 | 15 | ||
12 | /* OPIE */ | 16 | /* OPIE */ |
13 | #include <opie2/odebug.h> | 17 | #include <opie2/odebug.h> |
14 | #include <qpe/qcopenvelope_qws.h> | 18 | #include <qpe/qcopenvelope_qws.h> |
15 | #include <opie2/oresource.h> | 19 | #include <opie2/oresource.h> |
16 | #include <qpe/version.h> | 20 | #include <qpe/version.h> |
21 | #ifdef BLUETOOTH | ||
17 | #include <devicehandler.h> | 22 | #include <devicehandler.h> |
18 | #include "remotedevice.h" | 23 | #include "remotedevice.h" |
24 | #endif | ||
19 | 25 | ||
20 | using namespace Opie::Core; | 26 | using namespace Opie::Core; |
21 | 27 | ||
@@ -52,6 +58,7 @@ void SendWidget::initUI() { | |||
52 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 58 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
53 | this, SLOT(dispatchIrda(const QCString&,const QByteArray&) ) ); | 59 | this, SLOT(dispatchIrda(const QCString&,const QByteArray&) ) ); |
54 | 60 | ||
61 | #ifdef BLUETOOTH | ||
55 | m_btobex = new BtObex(this, "btobex"); | 62 | m_btobex = new BtObex(this, "btobex"); |
56 | connect(m_btobex, SIGNAL(error(int) ), | 63 | connect(m_btobex, SIGNAL(error(int) ), |
57 | this, SLOT(slotBtError(int) ) ); | 64 | this, SLOT(slotBtError(int) ) ); |
@@ -63,7 +70,7 @@ void SendWidget::initUI() { | |||
63 | chan = new QCopChannel("QPE/BluetoothBack", this ); | 70 | chan = new QCopChannel("QPE/BluetoothBack", this ); |
64 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 71 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
65 | this, SLOT(dispatchBt(const QCString&,const QByteArray&) ) ); | 72 | this, SLOT(dispatchBt(const QCString&,const QByteArray&) ) ); |
66 | 73 | #endif | |
67 | } | 74 | } |
68 | 75 | ||
69 | /* | 76 | /* |
@@ -73,7 +80,9 @@ void SendWidget::initUI() { | |||
73 | void SendWidget::send( const QString& file, const QString& desc ) { | 80 | void SendWidget::send( const QString& file, const QString& desc ) { |
74 | m_file = file; | 81 | m_file = file; |
75 | m_irDa.clear(); | 82 | m_irDa.clear(); |
83 | #ifdef BLUETOOTH | ||
76 | m_bt.clear(); | 84 | m_bt.clear(); |
85 | #endif | ||
77 | m_start = 0; | 86 | m_start = 0; |
78 | 87 | ||
79 | fileToSend->setText(desc.isEmpty() ? file : desc ); | 88 | fileToSend->setText(desc.isEmpty() ? file : desc ); |
@@ -88,6 +97,7 @@ void SendWidget::send( const QString& file, const QString& desc ) { | |||
88 | irdaStatus->setText(tr("ready")); | 97 | irdaStatus->setText(tr("ready")); |
89 | sendButton->setEnabled( true ); | 98 | sendButton->setEnabled( true ); |
90 | } | 99 | } |
100 | #ifdef BLUETOOTH | ||
91 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) | 101 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) |
92 | { | 102 | { |
93 | btStatus->setText(tr("not enabled.")); | 103 | btStatus->setText(tr("not enabled.")); |
@@ -99,6 +109,7 @@ void SendWidget::send( const QString& file, const QString& desc ) { | |||
99 | sendButton->setEnabled( true ); | 109 | sendButton->setEnabled( true ); |
100 | } | 110 | } |
101 | read_receivers(); | 111 | read_receivers(); |
112 | #endif | ||
102 | } | 113 | } |
103 | 114 | ||
104 | int SendWidget::addReceiver(const QString& str, const char *icon) | 115 | int SendWidget::addReceiver(const QString& str, const char *icon) |
@@ -134,6 +145,7 @@ void SendWidget::slotIrDaDevices( const QStringList& list) { | |||
134 | } | 145 | } |
135 | 146 | ||
136 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { | 147 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { |
148 | #ifdef BLUETOOTH | ||
137 | for(QMap<QString, QString>::ConstIterator it = str.begin(); | 149 | for(QMap<QString, QString>::ConstIterator it = str.begin(); |
138 | it != str.end(); ++it ) { | 150 | it != str.end(); ++it ) { |
139 | int id = addReceiver(it.key(), "obex/bt.png"); | 151 | int id = addReceiver(it.key(), "obex/bt.png"); |
@@ -142,6 +154,9 @@ void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { | |||
142 | btStatus->setText(tr("ready.")); | 154 | btStatus->setText(tr("ready.")); |
143 | m_btIt = m_bt.begin(); | 155 | m_btIt = m_bt.begin(); |
144 | 156 | ||
157 | #else | ||
158 | (void)str; | ||
159 | #endif | ||
145 | } | 160 | } |
146 | void SendWidget::slotSelectedDevice( int, int ) { | 161 | void SendWidget::slotSelectedDevice( int, int ) { |
147 | /* if ( name == m_irDeSearch ) { | 162 | /* if ( name == m_irDeSearch ) { |
@@ -163,10 +178,14 @@ void SendWidget::slotIrError( int ) { | |||
163 | irdaStatus->setText(tr("error :(")); | 178 | irdaStatus->setText(tr("error :(")); |
164 | } | 179 | } |
165 | void SendWidget::slotIrSent( bool b) { | 180 | void SendWidget::slotIrSent( bool b) { |
181 | #ifdef BLUETOOTH | ||
166 | QString text = b ? tr("Sent") : tr("Failure"); | 182 | QString text = b ? tr("Sent") : tr("Failure"); |
167 | setReceiverStatus( m_irDaIt.key(), text ); | 183 | setReceiverStatus( m_irDaIt.key(), text ); |
168 | ++m_irDaIt; | 184 | ++m_irDaIt; |
169 | slotStartIrda(); | 185 | slotStartIrda(); |
186 | #else | ||
187 | (void)b; | ||
188 | #endif | ||
170 | } | 189 | } |
171 | void SendWidget::slotIrTry(unsigned int trI) { | 190 | void SendWidget::slotIrTry(unsigned int trI) { |
172 | setReceiverStatus(m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) )); | 191 | setReceiverStatus(m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) )); |
@@ -196,15 +215,24 @@ void SendWidget::slotBtError( int ) { | |||
196 | btStatus->setText(tr("error :(")); | 215 | btStatus->setText(tr("error :(")); |
197 | } | 216 | } |
198 | void SendWidget::slotBtSent( bool b) { | 217 | void SendWidget::slotBtSent( bool b) { |
218 | #ifdef BLUETOOTH | ||
199 | QString text = b ? tr("Sent") : tr("Failure"); | 219 | QString text = b ? tr("Sent") : tr("Failure"); |
200 | setReceiverStatus( m_btIt.key(), text ); | 220 | setReceiverStatus( m_btIt.key(), text ); |
201 | ++m_btIt; | 221 | ++m_btIt; |
202 | slotStartBt(); | 222 | slotStartBt(); |
223 | #else | ||
224 | (void)b; | ||
225 | #endif | ||
203 | } | 226 | } |
204 | void SendWidget::slotBtTry(unsigned int trI) { | 227 | void SendWidget::slotBtTry(unsigned int trI) { |
228 | #ifdef BLUETOOTH | ||
205 | setReceiverStatus( m_btIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); | 229 | setReceiverStatus( m_btIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); |
230 | #else | ||
231 | (void)trI; | ||
232 | #endif | ||
206 | } | 233 | } |
207 | void SendWidget::slotStartBt() { | 234 | void SendWidget::slotStartBt() { |
235 | #ifdef BLUETOOTH | ||
208 | // skip past unselected receivers | 236 | // skip past unselected receivers |
209 | if ( !m_bt.count() ) | 237 | if ( !m_bt.count() ) |
210 | return; | 238 | return; |
@@ -218,13 +246,17 @@ void SendWidget::slotStartBt() { | |||
218 | setReceiverStatus( m_btIt.key(), tr("Start sending") ); | 246 | setReceiverStatus( m_btIt.key(), tr("Start sending") ); |
219 | btStatus->setText(tr("sending.")); | 247 | btStatus->setText(tr("sending.")); |
220 | m_btobex->send( m_file, m_btIt.data().second() ); | 248 | m_btobex->send( m_file, m_btIt.data().second() ); |
249 | #endif | ||
221 | } | 250 | } |
222 | 251 | ||
223 | void SendWidget::send_to_receivers() { | 252 | void SendWidget::send_to_receivers() { |
253 | #ifdef BLUETOOTH | ||
224 | slotStartBt(); | 254 | slotStartBt(); |
255 | #endif | ||
225 | slotStartIrda(); | 256 | slotStartIrda(); |
226 | } | 257 | } |
227 | 258 | ||
259 | #ifdef BLUETOOTH | ||
228 | /** | 260 | /** |
229 | * Read receivers saved by bluetooth manager | 261 | * Read receivers saved by bluetooth manager |
230 | */ | 262 | */ |
@@ -253,7 +285,7 @@ void SendWidget::read_receivers() | |||
253 | sendButton->setEnabled( true ); | 285 | sendButton->setEnabled( true ); |
254 | } | 286 | } |
255 | } | 287 | } |
256 | 288 | #endif | |
257 | 289 | ||
258 | void SendWidget::scan_for_receivers() | 290 | void SendWidget::scan_for_receivers() |
259 | { | 291 | { |
@@ -261,8 +293,9 @@ void SendWidget::scan_for_receivers() | |||
261 | receiverList->clear(); | 293 | receiverList->clear(); |
262 | receivers.clear(); | 294 | receivers.clear(); |
263 | m_irDa.clear(); | 295 | m_irDa.clear(); |
296 | #ifdef BLUETOOTH | ||
264 | m_bt.clear(); | 297 | m_bt.clear(); |
265 | 298 | #endif | |
266 | if ( QCopChannel::isRegistered("QPE/IrDaApplet") ) | 299 | if ( QCopChannel::isRegistered("QPE/IrDaApplet") ) |
267 | { | 300 | { |
268 | irdaStatus->setText(tr("searching...")); | 301 | irdaStatus->setText(tr("searching...")); |
@@ -270,12 +303,14 @@ void SendWidget::scan_for_receivers() | |||
270 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 303 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
271 | } | 304 | } |
272 | 305 | ||
306 | #ifdef BLUETOOTH | ||
273 | if ( QCopChannel::isRegistered("QPE/Bluetooth") ) | 307 | if ( QCopChannel::isRegistered("QPE/Bluetooth") ) |
274 | { | 308 | { |
275 | btStatus->setText(tr("searching...")); | 309 | btStatus->setText(tr("searching...")); |
276 | sendButton->setEnabled( true ); | 310 | sendButton->setEnabled( true ); |
277 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); | 311 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); |
278 | } | 312 | } |
313 | #endif | ||
279 | } | 314 | } |
280 | 315 | ||
281 | void SendWidget::toggle_receiver(QListViewItem* item) | 316 | void SendWidget::toggle_receiver(QListViewItem* item) |
@@ -293,15 +328,19 @@ void SendWidget::toggle_receiver(QListViewItem* item) | |||
293 | void SendWidget::closeEvent( QCloseEvent* evt) { | 328 | void SendWidget::closeEvent( QCloseEvent* evt) { |
294 | delete m_obex; | 329 | delete m_obex; |
295 | m_obex = NULL; | 330 | m_obex = NULL; |
331 | #ifdef BLUETOOTH | ||
296 | delete m_btobex; | 332 | delete m_btobex; |
297 | m_btobex = NULL; | 333 | m_btobex = NULL; |
334 | #endif | ||
298 | obexSendBase::closeEvent(evt); | 335 | obexSendBase::closeEvent(evt); |
299 | { | 336 | { |
300 | QCopEnvelope e("QPE/IrDaApplet", "disableIrda()"); | 337 | QCopEnvelope e("QPE/IrDaApplet", "disableIrda()"); |
301 | } | 338 | } |
339 | #ifdef BLUETOOTH | ||
302 | { | 340 | { |
303 | QCopEnvelope e("QPE/Bluetooth", "disableBluetooth()"); | 341 | QCopEnvelope e("QPE/Bluetooth", "disableBluetooth()"); |
304 | } | 342 | } |
343 | #endif | ||
305 | } | 344 | } |
306 | 345 | ||
307 | void SendWidget::userDone() { | 346 | void SendWidget::userDone() { |