author | korovkin <korovkin> | 2006-11-10 20:49:54 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-11-10 20:49:54 (UTC) |
commit | 961e5561b24452d9cfc2bf7400f6f5952b31431c (patch) (unidiff) | |
tree | 44439765333edad675966ce33f88427240cdbb0e /core/obex/obexsend.cpp | |
parent | b742daec72bbef07039b785dcadca9dca9a0dc1c (diff) | |
download | opie-961e5561b24452d9cfc2bf7400f6f5952b31431c.zip opie-961e5561b24452d9cfc2bf7400f6f5952b31431c.tar.gz opie-961e5561b24452d9cfc2bf7400f6f5952b31431c.tar.bz2 |
Made list of receivers loaded form files saved by bt-manager.
-rw-r--r-- | core/obex/obexsend.cpp | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp index 5c177e3..bca6784 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp | |||
@@ -1,27 +1,30 @@ | |||
1 | // 7-Jul-2005 mbh@sdgsystems.com: replace hand coded form with one | 1 | // 7-Jul-2005 mbh@sdgsystems.com: replace hand coded form with one |
2 | // generated via QT2 Designer. The new form supports | 2 | // generated via QT2 Designer. The new form supports |
3 | // selection of target devices, as opposed to sending to | 3 | // selection of target devices, as opposed to sending to |
4 | // all. | 4 | // all. |
5 | 5 | ||
6 | #include "obex.h" | 6 | #include "obex.h" |
7 | #include "btobex.h" | 7 | #include "btobex.h" |
8 | #include "obexsend.h" | 8 | #include "obexsend.h" |
9 | using namespace OpieObex; | 9 | using namespace OpieObex; |
10 | using namespace OpieTooth; | ||
10 | 11 | ||
11 | /* OPIE */ | 12 | /* OPIE */ |
12 | #include <opie2/odebug.h> | 13 | #include <opie2/odebug.h> |
13 | #include <qpe/qcopenvelope_qws.h> | 14 | #include <qpe/qcopenvelope_qws.h> |
14 | #include <opie2/oresource.h> | 15 | #include <opie2/oresource.h> |
15 | #include <qpe/version.h> | 16 | #include <qpe/version.h> |
17 | #include <devicehandler.h> | ||
18 | #include "remotedevice.h" | ||
16 | 19 | ||
17 | using namespace Opie::Core; | 20 | using namespace Opie::Core; |
18 | 21 | ||
19 | /* QT */ | 22 | /* QT */ |
20 | #include <qlabel.h> | 23 | #include <qlabel.h> |
21 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
22 | #include <qpixmap.h> | 25 | #include <qpixmap.h> |
23 | #include <qlistview.h> | 26 | #include <qlistview.h> |
24 | 27 | ||
25 | #include <unistd.h> | 28 | #include <unistd.h> |
26 | /* TRANSLATOR OpieObex::SendWidget */ | 29 | /* TRANSLATOR OpieObex::SendWidget */ |
27 | 30 | ||
@@ -64,31 +67,31 @@ void SendWidget::initUI() { | |||
64 | } | 67 | } |
65 | 68 | ||
66 | /* | 69 | /* |
67 | * in send we'll first set everything up | 70 | * in send we'll first set everything up |
68 | * and then wait for a list of devices. | 71 | * and then wait for a list of devices. |
69 | */ | 72 | */ |
70 | void SendWidget::send( const QString& file, const QString& desc ) { | 73 | void SendWidget::send( const QString& file, const QString& desc ) { |
71 | m_file = file; | 74 | m_file = file; |
72 | m_irDa.clear(); | 75 | m_irDa.clear(); |
73 | m_start = 0; | 76 | m_start = 0; |
74 | 77 | ||
75 | fileToSend->setText(desc.isEmpty() ? file : desc ); | 78 | fileToSend->setText(desc.isEmpty() ? file : desc ); |
76 | scan_for_receivers(); | 79 | read_receivers(); |
77 | } | 80 | } |
78 | 81 | ||
79 | int SendWidget::addReceiver(const char *r, const char *icon) | 82 | int SendWidget::addReceiver(const QString& str, const char *icon) |
80 | { | 83 | { |
81 | QListViewItem * item = new QListViewItem( receiverList, 0 ); | 84 | QListViewItem * item = new QListViewItem( receiverList, 0 ); |
82 | item->setText( 0, r); | 85 | item->setText( 0, str ); |
83 | item->setPixmap( 1, OResource::loadPixmap( icon ) ); | 86 | item->setPixmap( 1, OResource::loadPixmap( icon ) ); |
84 | 87 | ||
85 | int id=receivers.count(); | 88 | int id=receivers.count(); |
86 | receivers[id]=item; | 89 | receivers[id]=item; |
87 | return id; | 90 | return id; |
88 | } | 91 | } |
89 | 92 | ||
90 | bool SendWidget::receiverSelected(int id) | 93 | bool SendWidget::receiverSelected(int id) |
91 | { | 94 | { |
92 | return (bool)(receivers[id]->pixmap(2) != NULL); | 95 | return (bool)(receivers[id]->pixmap(2) != NULL); |
93 | } | 96 | } |
94 | 97 | ||
@@ -185,24 +188,68 @@ void SendWidget::slotStartBt() { | |||
185 | btStatus->setText(tr("complete.")); | 188 | btStatus->setText(tr("complete.")); |
186 | return; | 189 | return; |
187 | } | 190 | } |
188 | setReceiverStatus( m_btIt.key(), tr("Start sending") ); | 191 | setReceiverStatus( m_btIt.key(), tr("Start sending") ); |
189 | m_btobex->send( m_file, m_btIt.data().second() ); | 192 | m_btobex->send( m_file, m_btIt.data().second() ); |
190 | } | 193 | } |
191 | 194 | ||
192 | void SendWidget::send_to_receivers() { | 195 | void SendWidget::send_to_receivers() { |
193 | slotStartIrda(); | 196 | slotStartIrda(); |
194 | slotStartBt(); | 197 | slotStartBt(); |
195 | } | 198 | } |
196 | 199 | ||
200 | /** | ||
201 | * Read receivers saved by bluetooth manager | ||
202 | */ | ||
203 | void SendWidget::read_receivers() | ||
204 | { | ||
205 | QValueList<RemoteDevice> devices; | ||
206 | DeviceHandler handler; | ||
207 | QValueList<RemoteDevice>::ConstIterator it; | ||
208 | |||
209 | receiverList->clear(); | ||
210 | receivers.clear(); | ||
211 | sendButton->setDisabled( true ); | ||
212 | |||
213 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) | ||
214 | { | ||
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(); | ||
232 | for( it = devices.begin(); it != devices.end() ; ++it ) | ||
233 | { | ||
234 | int id = addReceiver((*it).name(), "obex/bt.png"); | ||
235 | m_bt.insert(id, Pair((*it).name(), (*it).mac())); | ||
236 | } | ||
237 | btStatus->setText(tr("ready.")); | ||
238 | m_btIt = m_bt.begin(); | ||
239 | sendButton->setEnabled( true ); | ||
240 | } | ||
241 | } | ||
242 | |||
243 | |||
197 | void SendWidget::scan_for_receivers() | 244 | void SendWidget::scan_for_receivers() |
198 | { | 245 | { |
199 | receiverList->clear(); | 246 | receiverList->clear(); |
200 | receivers.clear(); | 247 | receivers.clear(); |
201 | sendButton->setDisabled( true ); | 248 | sendButton->setDisabled( true ); |
202 | 249 | ||
203 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) | 250 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) |
204 | { | 251 | { |
205 | irdaStatus->setText(tr("not enabled.")); | 252 | irdaStatus->setText(tr("not enabled.")); |
206 | } | 253 | } |
207 | else | 254 | else |
208 | { | 255 | { |