-rw-r--r-- | core/obex/obexsend.cpp | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp index d58b4e9..a401a40 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp | |||
@@ -53,264 +53,260 @@ void SendWidget::initUI() { | |||
53 | this, SLOT(slotIrSent(bool) ) ); | 53 | this, SLOT(slotIrSent(bool) ) ); |
54 | connect(m_obex, SIGNAL(currentTry(unsigned int) ), | 54 | connect(m_obex, SIGNAL(currentTry(unsigned int) ), |
55 | this, SLOT(slotIrTry(unsigned int) ) ); | 55 | this, SLOT(slotIrTry(unsigned int) ) ); |
56 | 56 | ||
57 | QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); | 57 | QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); |
58 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 58 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
59 | this, SLOT(dispatchIrda(const QCString&,const QByteArray&) ) ); | 59 | this, SLOT(dispatchIrda(const QCString&,const QByteArray&) ) ); |
60 | 60 | ||
61 | #ifdef BLUETOOTH | 61 | #ifdef BLUETOOTH |
62 | m_btobex = new BtObex(this, "btobex"); | 62 | m_btobex = new BtObex(this, "btobex"); |
63 | connect(m_btobex, SIGNAL(error(int) ), | 63 | connect(m_btobex, SIGNAL(error(int) ), |
64 | this, SLOT(slotBtError(int) ) ); | 64 | this, SLOT(slotBtError(int) ) ); |
65 | connect(m_btobex, SIGNAL(sent(bool) ), | 65 | connect(m_btobex, SIGNAL(sent(bool) ), |
66 | this, SLOT(slotBtSent(bool) ) ); | 66 | this, SLOT(slotBtSent(bool) ) ); |
67 | connect(m_btobex, SIGNAL(currentTry(unsigned int) ), | 67 | connect(m_btobex, SIGNAL(currentTry(unsigned int) ), |
68 | this, SLOT(slotBtTry(unsigned int) ) ); | 68 | this, SLOT(slotBtTry(unsigned int) ) ); |
69 | 69 | ||
70 | chan = new QCopChannel("QPE/BluetoothBack", this ); | 70 | chan = new QCopChannel("QPE/BluetoothBack", this ); |
71 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 71 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
72 | this, SLOT(dispatchBt(const QCString&,const QByteArray&) ) ); | 72 | this, SLOT(dispatchBt(const QCString&,const QByteArray&) ) ); |
73 | #endif | 73 | #endif |
74 | } | 74 | } |
75 | 75 | ||
76 | /* | 76 | /* |
77 | * in send we'll first set everything up | 77 | * in send we'll first set everything up |
78 | * and then wait for a list of devices. | 78 | * and then wait for a list of devices. |
79 | */ | 79 | */ |
80 | void SendWidget::send( const QString& file, const QString& desc ) { | 80 | void SendWidget::send( const QString& file, const QString& desc ) { |
81 | m_file = file; | 81 | m_file = file; |
82 | m_irDa.clear(); | 82 | m_irDa.clear(); |
83 | #ifdef BLUETOOTH | 83 | #ifdef BLUETOOTH |
84 | m_bt.clear(); | 84 | m_bt.clear(); |
85 | #endif | 85 | #endif |
86 | m_start = 0; | 86 | m_start = 0; |
87 | 87 | ||
88 | fileToSend->setText(desc.isEmpty() ? file : desc ); | 88 | fileToSend->setText(desc.isEmpty() ? file : desc ); |
89 | 89 | ||
90 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) | 90 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) |
91 | { | 91 | { |
92 | irdaStatus->setText(tr("not enabled.")); | 92 | irdaStatus->setText(tr("not enabled.")); |
93 | } | 93 | } |
94 | else | 94 | else |
95 | { | 95 | { |
96 | QCopEnvelope e1("QPE/IrDaApplet", "enableIrda()"); | 96 | QCopEnvelope e1("QPE/IrDaApplet", "enableIrda()"); |
97 | irdaStatus->setText(tr("ready")); | 97 | irdaStatus->setText(tr("ready")); |
98 | sendButton->setEnabled( true ); | 98 | sendButton->setEnabled( true ); |
99 | } | 99 | } |
100 | #ifdef BLUETOOTH | 100 | #ifdef BLUETOOTH |
101 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) | 101 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) |
102 | { | 102 | { |
103 | btStatus->setText(tr("not enabled.")); | 103 | btStatus->setText(tr("not enabled.")); |
104 | } | 104 | } |
105 | else | 105 | else |
106 | { | 106 | { |
107 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); | 107 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); |
108 | btStatus->setText(tr("ready.")); | 108 | btStatus->setText(tr("ready.")); |
109 | sendButton->setEnabled( true ); | 109 | sendButton->setEnabled( true ); |
110 | } | 110 | } |
111 | read_receivers(); | 111 | read_receivers(); |
112 | #endif | 112 | #endif |
113 | } | 113 | } |
114 | 114 | ||
115 | int SendWidget::addReceiver(const QString& str, const char *icon) | 115 | int SendWidget::addReceiver(const QString& str, const char *icon) |
116 | { | 116 | { |
117 | QListViewItem * item = new QListViewItem( receiverList, 0 ); | 117 | QListViewItem * item = new QListViewItem( receiverList, 0 ); |
118 | item->setText( 0, str ); | 118 | item->setText( 0, str ); |
119 | item->setPixmap( 1, OResource::loadPixmap( icon ) ); | 119 | item->setPixmap( 1, OResource::loadPixmap( icon ) ); |
120 | 120 | ||
121 | int id = receivers.count(); | 121 | int id = receivers.count(); |
122 | receivers[id] = item; | 122 | receivers[id] = item; |
123 | return id; | 123 | return id; |
124 | } | 124 | } |
125 | 125 | ||
126 | bool SendWidget::receiverSelected(int id) | 126 | bool SendWidget::receiverSelected(int id) |
127 | { | 127 | { |
128 | return (bool)(receivers[id]->pixmap(2) != NULL); | 128 | return (bool)(receivers[id]->pixmap(2) != NULL); |
129 | } | 129 | } |
130 | 130 | ||
131 | void SendWidget::setReceiverStatus( int id, const QString& status ) { | 131 | void SendWidget::setReceiverStatus( int id, const QString& status ) { |
132 | if ( !receivers.contains(id) ) return; | 132 | if ( !receivers.contains(id) ) return; |
133 | receivers[id]->setText(3, status ); | 133 | receivers[id]->setText(3, status ); |
134 | } | 134 | } |
135 | 135 | ||
136 | void SendWidget::slotIrDaDevices( const QStringList& list) { | 136 | void SendWidget::slotIrDaDevices( const QStringList& list) { |
137 | for (QStringList::ConstIterator it = list.begin(); | 137 | for (QStringList::ConstIterator it = list.begin(); |
138 | it != list.end(); ++it ) { | 138 | it != list.end(); ++it ) { |
139 | int id = addReceiver(*it, "obex/irda.png"); | 139 | int id = addReceiver(*it, "obex/irda.png"); |
140 | m_irDa.insert( id, (*it) ); | 140 | m_irDa.insert( id, (*it) ); |
141 | } | 141 | } |
142 | irdaStatus->setText( tr("ready.")); | 142 | irdaStatus->setText( tr("ready.")); |
143 | m_irDaIt = m_irDa.begin(); | 143 | m_irDaIt = m_irDa.begin(); |
144 | 144 | ||
145 | } | 145 | } |
146 | 146 | ||
147 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { | 147 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { |
148 | #ifdef BLUETOOTH | 148 | #ifdef BLUETOOTH |
149 | for(QMap<QString, QString>::ConstIterator it = str.begin(); | 149 | for(QMap<QString, QString>::ConstIterator it = str.begin(); |
150 | it != str.end(); ++it ) { | 150 | it != str.end(); ++it ) { |
151 | int id = addReceiver(it.key(), "obex/bt.png"); | 151 | int id = addReceiver(it.key(), "obex/bt.png"); |
152 | m_bt.insert( id, Pair( it.key(), it.data() ) ); | 152 | m_bt.insert( id, Pair( it.key(), it.data() ) ); |
153 | } | 153 | } |
154 | btStatus->setText(tr("ready.")); | 154 | btStatus->setText(tr("ready.")); |
155 | m_btIt = m_bt.begin(); | 155 | m_btIt = m_bt.begin(); |
156 | 156 | ||
157 | #else | 157 | #else |
158 | (void)str; | 158 | (void)str; |
159 | #endif | 159 | #endif |
160 | } | 160 | } |
161 | void SendWidget::slotSelectedDevice( int, int ) { | 161 | void SendWidget::slotSelectedDevice( int, int ) { |
162 | /* if ( name == m_irDeSearch ) { | 162 | /* if ( name == m_irDeSearch ) { |
163 | for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) | 163 | for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) |
164 | m_devBox->removeDevice( it.key() ); | 164 | m_devBox->removeDevice( it.key() ); |
165 | 165 | ||
166 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 166 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
167 | }*/ | 167 | }*/ |
168 | } | 168 | } |
169 | void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { | 169 | void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { |
170 | if ( str == "devices(QStringList)" ) { | 170 | if ( str == "devices(QStringList)" ) { |
171 | QDataStream stream( ar, IO_ReadOnly ); | 171 | QDataStream stream( ar, IO_ReadOnly ); |
172 | QStringList list; | 172 | QStringList list; |
173 | stream >> list; | 173 | stream >> list; |
174 | slotIrDaDevices( list ); | 174 | slotIrDaDevices( list ); |
175 | } | 175 | } |
176 | } | 176 | } |
177 | void SendWidget::slotIrError( int ) { | 177 | void SendWidget::slotIrError( int ) { |
178 | irdaStatus->setText(tr("error :(")); | 178 | irdaStatus->setText(tr("error :(")); |
179 | } | 179 | } |
180 | void SendWidget::slotIrSent( bool b) { | 180 | void SendWidget::slotIrSent( bool b) { |
181 | #ifdef BLUETOOTH | ||
182 | QString text = b ? tr("Sent") : tr("Failure"); | 181 | QString text = b ? tr("Sent") : tr("Failure"); |
183 | setReceiverStatus( m_irDaIt.key(), text ); | 182 | setReceiverStatus( m_irDaIt.key(), text ); |
184 | ++m_irDaIt; | 183 | ++m_irDaIt; |
185 | slotStartIrda(); | 184 | slotStartIrda(); |
186 | #else | ||
187 | (void)b; | ||
188 | #endif | ||
189 | } | 185 | } |
190 | void SendWidget::slotIrTry(unsigned int trI) { | 186 | void SendWidget::slotIrTry(unsigned int trI) { |
191 | setReceiverStatus(m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) )); | 187 | setReceiverStatus(m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) )); |
192 | } | 188 | } |
193 | void SendWidget::slotStartIrda() { | 189 | void SendWidget::slotStartIrda() { |
194 | if ( !m_irDa.count() ) | 190 | if ( !m_irDa.count() ) |
195 | return; | 191 | return; |
196 | if ( m_irDaIt == m_irDa.end() || !receiverSelected(m_irDaIt.key())) { | 192 | if ( m_irDaIt == m_irDa.end() || !receiverSelected(m_irDaIt.key())) { |
197 | irdaStatus->setText(tr("complete.")); | 193 | irdaStatus->setText(tr("complete.")); |
198 | m_irDaIt = m_irDa.begin(); | 194 | m_irDaIt = m_irDa.begin(); |
199 | return; | 195 | return; |
200 | } | 196 | } |
201 | setReceiverStatus( m_irDaIt.key(), tr("Start sending") ); | 197 | setReceiverStatus( m_irDaIt.key(), tr("Start sending") ); |
202 | irdaStatus->setText(tr("sending.")); | 198 | irdaStatus->setText(tr("sending.")); |
203 | m_obex->send( m_file, tr("noaddress") ); | 199 | m_obex->send( m_file, tr("noaddress") ); |
204 | } | 200 | } |
205 | 201 | ||
206 | void SendWidget::dispatchBt( const QCString& str, const QByteArray& ar ) { | 202 | void SendWidget::dispatchBt( const QCString& str, const QByteArray& ar ) { |
207 | if ( str == "devices(QStringMap)" ) { | 203 | if ( str == "devices(QStringMap)" ) { |
208 | QDataStream stream( ar, IO_ReadOnly ); | 204 | QDataStream stream( ar, IO_ReadOnly ); |
209 | QMap<QString, QString> btmap; | 205 | QMap<QString, QString> btmap; |
210 | stream >> btmap; | 206 | stream >> btmap; |
211 | slotBTDevices( btmap ); | 207 | slotBTDevices( btmap ); |
212 | } | 208 | } |
213 | } | 209 | } |
214 | void SendWidget::slotBtError( int ) { | 210 | void SendWidget::slotBtError( int ) { |
215 | btStatus->setText(tr("error :(")); | 211 | btStatus->setText(tr("error :(")); |
216 | } | 212 | } |
217 | void SendWidget::slotBtSent( bool b) { | 213 | void SendWidget::slotBtSent( bool b) { |
218 | #ifdef BLUETOOTH | 214 | #ifdef BLUETOOTH |
219 | QString text = b ? tr("Sent") : tr("Failure"); | 215 | QString text = b ? tr("Sent") : tr("Failure"); |
220 | setReceiverStatus( m_btIt.key(), text ); | 216 | setReceiverStatus( m_btIt.key(), text ); |
221 | ++m_btIt; | 217 | ++m_btIt; |
222 | slotStartBt(); | 218 | slotStartBt(); |
223 | #else | 219 | #else |
224 | (void)b; | 220 | (void)b; |
225 | #endif | 221 | #endif |
226 | } | 222 | } |
227 | void SendWidget::slotBtTry(unsigned int trI) { | 223 | void SendWidget::slotBtTry(unsigned int trI) { |
228 | #ifdef BLUETOOTH | 224 | #ifdef BLUETOOTH |
229 | setReceiverStatus( m_btIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); | 225 | setReceiverStatus( m_btIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); |
230 | #else | 226 | #else |
231 | (void)trI; | 227 | (void)trI; |
232 | #endif | 228 | #endif |
233 | } | 229 | } |
234 | void SendWidget::slotStartBt() { | 230 | void SendWidget::slotStartBt() { |
235 | #ifdef BLUETOOTH | 231 | #ifdef BLUETOOTH |
236 | // skip past unselected receivers | 232 | // skip past unselected receivers |
237 | if ( !m_bt.count() ) | 233 | if ( !m_bt.count() ) |
238 | return; | 234 | return; |
239 | while((m_btIt != m_bt.end()) && !receiverSelected(m_btIt.key())) | 235 | while((m_btIt != m_bt.end()) && !receiverSelected(m_btIt.key())) |
240 | ++m_btIt; | 236 | ++m_btIt; |
241 | if (m_btIt == m_bt.end() ) { | 237 | if (m_btIt == m_bt.end() ) { |
242 | btStatus->setText(tr("complete.")); | 238 | btStatus->setText(tr("complete.")); |
243 | m_btIt = m_bt.begin(); | 239 | m_btIt = m_bt.begin(); |
244 | return; | 240 | return; |
245 | } | 241 | } |
246 | setReceiverStatus( m_btIt.key(), tr("Start sending") ); | 242 | setReceiverStatus( m_btIt.key(), tr("Start sending") ); |
247 | btStatus->setText(tr("sending.")); | 243 | btStatus->setText(tr("sending.")); |
248 | m_btobex->send( m_file, m_btIt.data().second() ); | 244 | m_btobex->send( m_file, m_btIt.data().second() ); |
249 | #endif | 245 | #endif |
250 | } | 246 | } |
251 | 247 | ||
252 | void SendWidget::send_to_receivers() { | 248 | void SendWidget::send_to_receivers() { |
253 | #ifdef BLUETOOTH | 249 | #ifdef BLUETOOTH |
254 | slotStartBt(); | 250 | slotStartBt(); |
255 | #endif | 251 | #endif |
256 | slotStartIrda(); | 252 | slotStartIrda(); |
257 | } | 253 | } |
258 | 254 | ||
259 | #ifdef BLUETOOTH | 255 | #ifdef BLUETOOTH |
260 | /** | 256 | /** |
261 | * Read receivers saved by bluetooth manager | 257 | * Read receivers saved by bluetooth manager |
262 | */ | 258 | */ |
263 | void SendWidget::read_receivers() | 259 | void SendWidget::read_receivers() |
264 | { | 260 | { |
265 | QValueList<RemoteDevice> devices; | 261 | QValueList<RemoteDevice> devices; |
266 | DeviceHandler handler; | 262 | DeviceHandler handler; |
267 | QValueList<RemoteDevice>::ConstIterator it; | 263 | QValueList<RemoteDevice>::ConstIterator it; |
268 | 264 | ||
269 | receiverList->clear(); | 265 | receiverList->clear(); |
270 | receivers.clear(); | 266 | receivers.clear(); |
271 | sendButton->setDisabled( true ); | 267 | sendButton->setDisabled( true ); |
272 | btStatus->setText(tr("load.")); | 268 | btStatus->setText(tr("load.")); |
273 | m_bt.clear(); | 269 | m_bt.clear(); |
274 | 270 | ||
275 | if ( QCopChannel::isRegistered("QPE/Bluetooth") ) | 271 | if ( QCopChannel::isRegistered("QPE/Bluetooth") ) |
276 | { | 272 | { |
277 | devices = handler.load(); | 273 | devices = handler.load(); |
278 | for( it = devices.begin(); it != devices.end() ; ++it ) | 274 | for( it = devices.begin(); it != devices.end() ; ++it ) |
279 | { | 275 | { |
280 | int id = addReceiver((*it).name(), "obex/bt.png"); | 276 | int id = addReceiver((*it).name(), "obex/bt.png"); |
281 | m_bt.insert(id, Pair((*it).name(), (*it).mac())); | 277 | m_bt.insert(id, Pair((*it).name(), (*it).mac())); |
282 | } | 278 | } |
283 | btStatus->setText(tr("ready.")); | 279 | btStatus->setText(tr("ready.")); |
284 | m_btIt = m_bt.begin(); | 280 | m_btIt = m_bt.begin(); |
285 | sendButton->setEnabled( true ); | 281 | sendButton->setEnabled( true ); |
286 | } | 282 | } |
287 | } | 283 | } |
288 | #endif | 284 | #endif |
289 | 285 | ||
290 | void SendWidget::scan_for_receivers() | 286 | void SendWidget::scan_for_receivers() |
291 | { | 287 | { |
292 | sendButton->setDisabled( true ); | 288 | sendButton->setDisabled( true ); |
293 | receiverList->clear(); | 289 | receiverList->clear(); |
294 | receivers.clear(); | 290 | receivers.clear(); |
295 | m_irDa.clear(); | 291 | m_irDa.clear(); |
296 | #ifdef BLUETOOTH | 292 | #ifdef BLUETOOTH |
297 | m_bt.clear(); | 293 | m_bt.clear(); |
298 | #endif | 294 | #endif |
299 | if ( QCopChannel::isRegistered("QPE/IrDaApplet") ) | 295 | if ( QCopChannel::isRegistered("QPE/IrDaApplet") ) |
300 | { | 296 | { |
301 | irdaStatus->setText(tr("searching...")); | 297 | irdaStatus->setText(tr("searching...")); |
302 | sendButton->setEnabled( true ); | 298 | sendButton->setEnabled( true ); |
303 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 299 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
304 | } | 300 | } |
305 | 301 | ||
306 | #ifdef BLUETOOTH | 302 | #ifdef BLUETOOTH |
307 | if ( QCopChannel::isRegistered("QPE/Bluetooth") ) | 303 | if ( QCopChannel::isRegistered("QPE/Bluetooth") ) |
308 | { | 304 | { |
309 | btStatus->setText(tr("searching...")); | 305 | btStatus->setText(tr("searching...")); |
310 | sendButton->setEnabled( true ); | 306 | sendButton->setEnabled( true ); |
311 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); | 307 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); |
312 | } | 308 | } |
313 | #endif | 309 | #endif |
314 | } | 310 | } |
315 | 311 | ||
316 | void SendWidget::toggle_receiver(QListViewItem* item) | 312 | void SendWidget::toggle_receiver(QListViewItem* item) |