-rw-r--r-- | core/obex/obexsend.cpp | 74 |
1 files changed, 41 insertions, 33 deletions
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp index bca6784..45754e3 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp | |||
@@ -72,11 +72,33 @@ void SendWidget::initUI() { | |||
72 | */ | 72 | */ |
73 | void SendWidget::send( const QString& file, const QString& desc ) { | 73 | void SendWidget::send( const QString& file, const QString& desc ) { |
74 | m_file = file; | 74 | m_file = file; |
75 | m_irDa.clear(); | 75 | m_irDa.clear(); |
76 | m_bt.clear(); | ||
76 | m_start = 0; | 77 | m_start = 0; |
77 | 78 | ||
78 | fileToSend->setText(desc.isEmpty() ? file : desc ); | 79 | fileToSend->setText(desc.isEmpty() ? file : desc ); |
80 | |||
81 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) | ||
82 | { | ||
83 | irdaStatus->setText(tr("not enabled.")); | ||
84 | } | ||
85 | else | ||
86 | { | ||
87 | QCopEnvelope e1("QPE/IrDaApplet", "enableIrda()"); | ||
88 | irdaStatus->setText(tr("ready")); | ||
89 | sendButton->setEnabled( true ); | ||
90 | } | ||
91 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) | ||
92 | { | ||
93 | btStatus->setText(tr("not enabled.")); | ||
94 | } | ||
95 | else | ||
96 | { | ||
97 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); | ||
98 | btStatus->setText(tr("ready.")); | ||
99 | sendButton->setEnabled( true ); | ||
100 | } | ||
79 | read_receivers(); | 101 | read_receivers(); |
80 | } | 102 | } |
81 | 103 | ||
82 | int SendWidget::addReceiver(const QString& str, const char *icon) | 104 | int SendWidget::addReceiver(const QString& str, const char *icon) |
@@ -84,10 +106,10 @@ int SendWidget::addReceiver(const QString& str, const char *icon) | |||
84 | QListViewItem * item = new QListViewItem( receiverList, 0 ); | 106 | QListViewItem * item = new QListViewItem( receiverList, 0 ); |
85 | item->setText( 0, str ); | 107 | item->setText( 0, str ); |
86 | item->setPixmap( 1, OResource::loadPixmap( icon ) ); | 108 | item->setPixmap( 1, OResource::loadPixmap( icon ) ); |
87 | 109 | ||
88 | int id=receivers.count(); | 110 | int id = receivers.count(); |
89 | receivers[id]=item; | 111 | receivers[id] = item; |
90 | return id; | 112 | return id; |
91 | } | 113 | } |
92 | 114 | ||
93 | bool SendWidget::receiverSelected(int id) | 115 | bool SendWidget::receiverSelected(int id) |
@@ -153,11 +175,13 @@ void SendWidget::slotStartIrda() { | |||
153 | if ( !m_irDa.count() ) | 175 | if ( !m_irDa.count() ) |
154 | return; | 176 | return; |
155 | if ( m_irDaIt == m_irDa.end() || !receiverSelected(m_irDaIt.key())) { | 177 | if ( m_irDaIt == m_irDa.end() || !receiverSelected(m_irDaIt.key())) { |
156 | irdaStatus->setText(tr("complete.")); | 178 | irdaStatus->setText(tr("complete.")); |
179 | m_irDaIt = m_irDa.begin(); | ||
157 | return; | 180 | return; |
158 | } | 181 | } |
159 | setReceiverStatus( m_irDaIt.key(), tr("Start sending") ); | 182 | setReceiverStatus( m_irDaIt.key(), tr("Start sending") ); |
183 | irdaStatus->setText(tr("sending.")); | ||
160 | m_obex->send( m_file, tr("noaddress") ); | 184 | m_obex->send( m_file, tr("noaddress") ); |
161 | } | 185 | } |
162 | 186 | ||
163 | void SendWidget::dispatchBt( const QCString& str, const QByteArray& ar ) { | 187 | void SendWidget::dispatchBt( const QCString& str, const QByteArray& ar ) { |
@@ -181,21 +205,25 @@ void SendWidget::slotBtTry(unsigned int trI) { | |||
181 | setReceiverStatus( m_btIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); | 205 | setReceiverStatus( m_btIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); |
182 | } | 206 | } |
183 | void SendWidget::slotStartBt() { | 207 | void SendWidget::slotStartBt() { |
184 | // skip past unselected receivers | 208 | // skip past unselected receivers |
209 | if ( !m_bt.count() ) | ||
210 | return; | ||
185 | while((m_btIt != m_bt.end()) && !receiverSelected(m_btIt.key())) | 211 | while((m_btIt != m_bt.end()) && !receiverSelected(m_btIt.key())) |
186 | ++m_btIt; | 212 | ++m_btIt; |
187 | if (m_btIt == m_bt.end() ) { | 213 | if (m_btIt == m_bt.end() ) { |
188 | btStatus->setText(tr("complete.")); | 214 | btStatus->setText(tr("complete.")); |
215 | m_btIt = m_bt.begin(); | ||
189 | return; | 216 | return; |
190 | } | 217 | } |
191 | setReceiverStatus( m_btIt.key(), tr("Start sending") ); | 218 | setReceiverStatus( m_btIt.key(), tr("Start sending") ); |
219 | btStatus->setText(tr("sending.")); | ||
192 | m_btobex->send( m_file, m_btIt.data().second() ); | 220 | m_btobex->send( m_file, m_btIt.data().second() ); |
193 | } | 221 | } |
194 | 222 | ||
195 | void SendWidget::send_to_receivers() { | 223 | void SendWidget::send_to_receivers() { |
196 | slotStartIrda(); | ||
197 | slotStartBt(); | 224 | slotStartBt(); |
225 | slotStartIrda(); | ||
198 | } | 226 | } |
199 | 227 | ||
200 | /** | 228 | /** |
201 | * Read receivers saved by bluetooth manager | 229 | * Read receivers saved by bluetooth manager |
@@ -208,27 +236,13 @@ void SendWidget::read_receivers() | |||
208 | 236 | ||
209 | receiverList->clear(); | 237 | receiverList->clear(); |
210 | receivers.clear(); | 238 | receivers.clear(); |
211 | sendButton->setDisabled( true ); | 239 | sendButton->setDisabled( true ); |
240 | btStatus->setText(tr("load.")); | ||
241 | m_bt.clear(); | ||
212 | 242 | ||
213 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) | 243 | if ( QCopChannel::isRegistered("QPE/Bluetooth") ) |
214 | { | 244 | { |
215 | irdaStatus->setText(tr("not enabled.")); | ||
216 | } | ||
217 | else | ||
218 | { | ||
219 | QCopEnvelope e1("QPE/IrDaApplet", "enableIrda()"); | ||
220 | irdaStatus->setText(tr("ready")); | ||
221 | sendButton->setEnabled( true ); | ||
222 | } | ||
223 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) | ||
224 | { | ||
225 | btStatus->setText(tr("not enabled.")); | ||
226 | } | ||
227 | else | ||
228 | { | ||
229 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); | ||
230 | |||
231 | devices = handler.load(); | 245 | devices = handler.load(); |
232 | for( it = devices.begin(); it != devices.end() ; ++it ) | 246 | for( it = devices.begin(); it != devices.end() ; ++it ) |
233 | { | 247 | { |
234 | int id = addReceiver((*it).name(), "obex/bt.png"); | 248 | int id = addReceiver((*it).name(), "obex/bt.png"); |
@@ -242,39 +256,33 @@ void SendWidget::read_receivers() | |||
242 | 256 | ||
243 | 257 | ||
244 | void SendWidget::scan_for_receivers() | 258 | void SendWidget::scan_for_receivers() |
245 | { | 259 | { |
260 | sendButton->setDisabled( true ); | ||
246 | receiverList->clear(); | 261 | receiverList->clear(); |
247 | receivers.clear(); | 262 | receivers.clear(); |
248 | sendButton->setDisabled( true ); | 263 | m_irDa.clear(); |
264 | m_bt.clear(); | ||
249 | 265 | ||
250 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) | 266 | if ( QCopChannel::isRegistered("QPE/IrDaApplet") ) |
251 | { | ||
252 | irdaStatus->setText(tr("not enabled.")); | ||
253 | } | ||
254 | else | ||
255 | { | 267 | { |
256 | QCopEnvelope e1("QPE/IrDaApplet", "enableIrda()"); | ||
257 | irdaStatus->setText(tr("searching...")); | 268 | irdaStatus->setText(tr("searching...")); |
258 | sendButton->setEnabled( true ); | 269 | sendButton->setEnabled( true ); |
259 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 270 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
260 | } | 271 | } |
261 | 272 | ||
262 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) | 273 | if ( QCopChannel::isRegistered("QPE/Bluetooth") ) |
263 | { | 274 | { |
264 | btStatus->setText(tr("not enabled.")); | ||
265 | } | ||
266 | else | ||
267 | { | ||
268 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); | ||
269 | btStatus->setText(tr("searching...")); | 275 | btStatus->setText(tr("searching...")); |
270 | sendButton->setEnabled( true ); | 276 | sendButton->setEnabled( true ); |
271 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); | 277 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); |
272 | } | 278 | } |
273 | } | 279 | } |
274 | 280 | ||
275 | void SendWidget::toggle_receiver(QListViewItem* item) | 281 | void SendWidget::toggle_receiver(QListViewItem* item) |
276 | { | 282 | { |
283 | if (!item) | ||
284 | return; | ||
277 | // toggle the state of an individual receiver. | 285 | // toggle the state of an individual receiver. |
278 | if (item->pixmap(2)) | 286 | if (item->pixmap(2)) |
279 | item->setPixmap(2, QPixmap()); | 287 | item->setPixmap(2, QPixmap()); |
280 | else | 288 | else |