-rw-r--r-- | core/obex/obexsend.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp index a2e4c16..d5ebd81 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp | |||
@@ -11,53 +11,53 @@ | |||
11 | 11 | ||
12 | #include "obex.h" | 12 | #include "obex.h" |
13 | #include "obexsend.h" | 13 | #include "obexsend.h" |
14 | 14 | ||
15 | using namespace OpieObex; | 15 | using namespace OpieObex; |
16 | 16 | ||
17 | 17 | ||
18 | SendWidget::SendWidget( QWidget* parent, const char* name ) | 18 | SendWidget::SendWidget( QWidget* parent, const char* name ) |
19 | : QWidget( parent, name ) { | 19 | : QWidget( parent, name ) { |
20 | initUI(); | 20 | initUI(); |
21 | } | 21 | } |
22 | SendWidget::~SendWidget() { | 22 | SendWidget::~SendWidget() { |
23 | } | 23 | } |
24 | void SendWidget::initUI() { | 24 | void SendWidget::initUI() { |
25 | m_obex = new Obex(this, "obex"); | 25 | m_obex = new Obex(this, "obex"); |
26 | connect(m_obex, SIGNAL(error(int) ), | 26 | connect(m_obex, SIGNAL(error(int) ), |
27 | this, SLOT(slotIrError(int) ) ); | 27 | this, SLOT(slotIrError(int) ) ); |
28 | connect(m_obex, SIGNAL(sent(bool) ), | 28 | connect(m_obex, SIGNAL(sent(bool) ), |
29 | this, SLOT(slotIrSent(bool) ) ); | 29 | this, SLOT(slotIrSent(bool) ) ); |
30 | connect(m_obex, SIGNAL(currentTry(unsigned int ) ), | 30 | connect(m_obex, SIGNAL(currentTry(unsigned int ) ), |
31 | this, SLOT(slotIrTry(unsigned int ) ) ); | 31 | this, SLOT(slotIrTry(unsigned int ) ) ); |
32 | 32 | ||
33 | QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); | 33 | QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); |
34 | connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), | 34 | connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), |
35 | this, SLOT(dispatchBt(const QCString&, const QByteArray& ) ) ); | 35 | this, SLOT(dispatchIrda(const QCString&, const QByteArray& ) ) ); |
36 | 36 | ||
37 | chan = new QCopChannel("QPE/BluetoothBack", this ); | 37 | chan = new QCopChannel("QPE/BluetoothBack", this ); |
38 | connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), | 38 | connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), |
39 | this, SLOT(dispatchIrda(const QCString&, const QByteArray& ) ) ); | 39 | this, SLOT(dispatchBt(const QCString&, const QByteArray& ) ) ); |
40 | 40 | ||
41 | QVBoxLayout* lay = new QVBoxLayout(this); | 41 | QVBoxLayout* lay = new QVBoxLayout(this); |
42 | 42 | ||
43 | QHBox* nameBox = new QHBox(this); | 43 | QHBox* nameBox = new QHBox(this); |
44 | QLabel* name = new QLabel(nameBox); | 44 | QLabel* name = new QLabel(nameBox); |
45 | name->setText( tr("<qt><h1>Sending:</h1></qt>") ); | 45 | name->setText( tr("<qt><h1>Sending:</h1></qt>") ); |
46 | name->setAlignment( AlignLeft | AlignTop ); | 46 | name->setAlignment( AlignLeft | AlignTop ); |
47 | m_lblFile = new QLabel(nameBox); | 47 | m_lblFile = new QLabel(nameBox); |
48 | lay->addWidget(nameBox, 0); | 48 | lay->addWidget(nameBox, 0); |
49 | 49 | ||
50 | QFrame* frame = new QFrame(this); | 50 | QFrame* frame = new QFrame(this); |
51 | frame->setFrameShape( QFrame::HLine ); | 51 | frame->setFrameShape( QFrame::HLine ); |
52 | frame->setFrameShadow( QFrame::Sunken ); | 52 | frame->setFrameShadow( QFrame::Sunken ); |
53 | lay->addWidget(frame, 10); | 53 | lay->addWidget(frame, 10); |
54 | 54 | ||
55 | QLabel* devices = new QLabel(this); | 55 | QLabel* devices = new QLabel(this); |
56 | devices->setText("<qt><b>Devices:</b></qt>"); | 56 | devices->setText("<qt><b>Devices:</b></qt>"); |
57 | devices->setAlignment( AlignLeft | AlignTop ); | 57 | devices->setAlignment( AlignLeft | AlignTop ); |
58 | lay->addWidget( devices,10 ); | 58 | lay->addWidget( devices,10 ); |
59 | 59 | ||
60 | m_devBox = new DeviceBox(this); | 60 | m_devBox = new DeviceBox(this); |
61 | lay->addWidget( m_devBox, 50 ); | 61 | lay->addWidget( m_devBox, 50 ); |
62 | connect(m_devBox, SIGNAL(selectedDevice(const QString&, int ) ), | 62 | connect(m_devBox, SIGNAL(selectedDevice(const QString&, int ) ), |
63 | this, SLOT(slotSelectedDevice(const QString&, int) ) ); | 63 | this, SLOT(slotSelectedDevice(const QString&, int) ) ); |
@@ -82,104 +82,107 @@ void SendWidget::initUI() { | |||
82 | void SendWidget::send( const QString& file, const QString& desc ) { | 82 | void SendWidget::send( const QString& file, const QString& desc ) { |
83 | m_file = file; | 83 | m_file = file; |
84 | m_irDa.clear(); | 84 | m_irDa.clear(); |
85 | m_start = 0; | 85 | m_start = 0; |
86 | m_lblFile->setText(desc.isEmpty() ? file : desc ); | 86 | m_lblFile->setText(desc.isEmpty() ? file : desc ); |
87 | 87 | ||
88 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) { | 88 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) { |
89 | m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error ); | 89 | m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error ); |
90 | m_start++; | 90 | m_start++; |
91 | }else | 91 | }else |
92 | m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search ); | 92 | m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search ); |
93 | 93 | ||
94 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) { | 94 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) { |
95 | m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error ); | 95 | m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error ); |
96 | m_start++; | 96 | m_start++; |
97 | }else | 97 | }else |
98 | m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search ); | 98 | m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search ); |
99 | 99 | ||
100 | if (m_start != 2 ) { | 100 | if (m_start != 2 ) { |
101 | QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); | 101 | QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); |
102 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); | 102 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); |
103 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 103 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
104 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); | 104 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); |
105 | } | 105 | } |
106 | QTimer::singleShot(5000, this, SLOT(testIt() ) ); | ||
107 | } | 106 | } |
108 | void SendWidget::slotIrDaDevices( const QStringList& list) { | 107 | void SendWidget::slotIrDaDevices( const QStringList& list) { |
108 | qWarning("slot it irda devices "); | ||
109 | m_irDa = list; | 109 | m_irDa = list; |
110 | m_start = 0; | 110 | m_start = 0; |
111 | for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) | 111 | for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) |
112 | m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); | 112 | m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); |
113 | m_devBox->removeDevice( tr("Search for IrDa Devices.") ); | 113 | |
114 | m_devBox->removeDevice( tr("Searching for IrDa Devices.") ); | ||
114 | 115 | ||
115 | slotStartIrda(); | 116 | slotStartIrda(); |
116 | } | 117 | } |
117 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { | 118 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { |
118 | m_bt = str; | 119 | m_bt = str; |
119 | for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { | 120 | for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { |
120 | m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); | 121 | m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); |
121 | } | 122 | } |
122 | m_devBox->removeDevice( tr("Searching for bluetooth Devices.") ); | 123 | m_devBox->removeDevice( tr("Searching for bluetooth Devices.") ); |
123 | } | 124 | } |
124 | void SendWidget::slotSelectedDevice( const QString& name, int dev ) { | 125 | void SendWidget::slotSelectedDevice( const QString& name, int dev ) { |
125 | qWarning("Start beam? %s %d", name.latin1(), dev ); | 126 | qWarning("Start beam? %s %d", name.latin1(), dev ); |
126 | if ( name == tr("Search again for IrDa.") ) { | 127 | if ( name == tr("Search again for IrDa.") ) { |
127 | for (QStringList::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) | 128 | for (QStringList::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) |
128 | m_devBox->removeDevice( (*it) ); | 129 | m_devBox->removeDevice( (*it) ); |
130 | |||
129 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 131 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
130 | } | 132 | } |
131 | } | 133 | } |
132 | void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { | 134 | void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { |
133 | qWarning("dispatch irda %s", str.data() ); | 135 | qWarning("dispatch irda %s", str.data() ); |
134 | if ( str == "listDevices(QStringList)" ) { | 136 | if ( str == "devices(QStringList)" ) { |
135 | QDataStream stream( ar, IO_ReadOnly ); | 137 | QDataStream stream( ar, IO_ReadOnly ); |
136 | QStringList list; | 138 | QStringList list; |
137 | stream >> list; | 139 | stream >> list; |
138 | slotIrDaDevices( list ); | 140 | slotIrDaDevices( list ); |
139 | } | 141 | } |
140 | } | 142 | } |
141 | void SendWidget::dispatchBt( const QCString& str, const QByteArray& ar ) { | 143 | void SendWidget::dispatchBt( const QCString& str, const QByteArray& ar ) { |
142 | 144 | ||
143 | } | 145 | } |
144 | void SendWidget::slotIrError( int ) { | 146 | void SendWidget::slotIrError( int ) { |
145 | 147 | ||
146 | } | 148 | } |
147 | void SendWidget::slotIrSent( bool b) { | 149 | void SendWidget::slotIrSent( bool b) { |
150 | qWarning("irda sent!!"); | ||
148 | QString text = b ? tr("Sent") : tr("Failure"); | 151 | QString text = b ? tr("Sent") : tr("Failure"); |
149 | m_devBox->setStatus( m_irDa[m_start], text ); | 152 | // m_devBox->setStatus( m_irDa[m_start], text ); |
150 | m_start++; | 153 | m_start++; |
151 | slotStartIrda(); | 154 | slotStartIrda(); |
152 | } | 155 | } |
153 | void SendWidget::slotIrTry(unsigned int trI) { | 156 | void SendWidget::slotIrTry(unsigned int trI) { |
154 | m_devBox->setStatus( m_irDa[m_start], tr("Try %1").arg( QString::number( trI ) ) ); | 157 | // m_devBox->setStatus( m_irDa[m_start], tr("Try %1").arg( QString::number( trI ) ) ); |
155 | } | 158 | } |
156 | void SendWidget::slotStartIrda() { | 159 | void SendWidget::slotStartIrda() { |
157 | if (m_start >= m_irDa.count() ) { | 160 | if (m_start >= m_irDa.count() ) { |
158 | m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); | 161 | m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); |
159 | return; | 162 | return; |
160 | } | 163 | } |
161 | m_devBox->setStatus( m_irDa[m_start], tr("Start sending") ); | 164 | // m_devBox->setStatus( m_irDa[m_start], tr("Start sending") ); |
162 | m_obex->send( m_file ); | 165 | m_obex->send( m_file ); |
163 | } | 166 | } |
164 | void SendWidget::slotDone() { | 167 | void SendWidget::slotDone() { |
165 | QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); | 168 | QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); |
166 | QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); | 169 | QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); |
167 | emit done(); | 170 | emit done(); |
168 | } | 171 | } |
169 | QString SendWidget::file()const { | 172 | QString SendWidget::file()const { |
170 | return m_file; | 173 | return m_file; |
171 | } | 174 | } |
172 | DeviceBox::DeviceBox( QWidget* parent ) | 175 | DeviceBox::DeviceBox( QWidget* parent ) |
173 | : QTextBrowser( parent ) { | 176 | : QTextBrowser( parent ) { |
174 | 177 | ||
175 | } | 178 | } |
176 | DeviceBox::~DeviceBox() { | 179 | DeviceBox::~DeviceBox() { |
177 | 180 | ||
178 | } | 181 | } |
179 | void DeviceBox::addDevice( const QString& name, int dev, const QString& status ) { | 182 | void DeviceBox::addDevice( const QString& name, int dev, const QString& status ) { |
180 | QString tex; | 183 | QString tex; |
181 | DeviceItem item( name, status, dev ); | 184 | DeviceItem item( name, status, dev ); |
182 | m_dev.insert( name, item ); | 185 | m_dev.insert( name, item ); |
183 | tex = item.toString(); | 186 | tex = item.toString(); |
184 | m_devices.prepend(tex); | 187 | m_devices.prepend(tex); |
185 | setText( text()+ "<br>"+tex ); | 188 | setText( text()+ "<br>"+tex ); |