-rw-r--r-- | core/obex/obexsend.cpp | 4 | ||||
-rw-r--r-- | core/obex/obexsend.h | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp index 0da57ca..1b19c6b 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp | |||
@@ -137,64 +137,68 @@ void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { | |||
137 | qWarning("dispatch irda %s", str.data() ); | 137 | qWarning("dispatch irda %s", str.data() ); |
138 | if ( str == "devices(QStringList)" ) { | 138 | if ( str == "devices(QStringList)" ) { |
139 | QDataStream stream( ar, IO_ReadOnly ); | 139 | QDataStream stream( ar, IO_ReadOnly ); |
140 | QStringList list; | 140 | QStringList list; |
141 | stream >> list; | 141 | stream >> list; |
142 | slotIrDaDevices( list ); | 142 | slotIrDaDevices( list ); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | void SendWidget::dispatchBt( const QCString&, const QByteArray& ) { | 145 | void SendWidget::dispatchBt( const QCString&, const QByteArray& ) { |
146 | 146 | ||
147 | } | 147 | } |
148 | void SendWidget::slotIrError( int ) { | 148 | void SendWidget::slotIrError( int ) { |
149 | 149 | ||
150 | } | 150 | } |
151 | void SendWidget::slotIrSent( bool b) { | 151 | void SendWidget::slotIrSent( bool b) { |
152 | qWarning("irda sent!!"); | 152 | qWarning("irda sent!!"); |
153 | QString text = b ? tr("Sent") : tr("Failure"); | 153 | QString text = b ? tr("Sent") : tr("Failure"); |
154 | m_devBox->setStatus( m_irDaIt.key(), text ); | 154 | m_devBox->setStatus( m_irDaIt.key(), text ); |
155 | ++m_irDaIt; | 155 | ++m_irDaIt; |
156 | slotStartIrda(); | 156 | slotStartIrda(); |
157 | } | 157 | } |
158 | void SendWidget::slotIrTry(unsigned int trI) { | 158 | void SendWidget::slotIrTry(unsigned int trI) { |
159 | m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); | 159 | m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); |
160 | } | 160 | } |
161 | void SendWidget::slotStartIrda() { | 161 | void SendWidget::slotStartIrda() { |
162 | if (m_irDaIt == m_irDa.end() ) { | 162 | if (m_irDaIt == m_irDa.end() ) { |
163 | m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); | 163 | m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | m_devBox->setStatus( m_irDaIt.key(), tr("Start sending") ); | 166 | m_devBox->setStatus( m_irDaIt.key(), tr("Start sending") ); |
167 | m_obex->send( m_file ); | 167 | m_obex->send( m_file ); |
168 | } | 168 | } |
169 | void SendWidget::closeEvent( QCloseEvent* e) { | ||
170 | e->accept(); // make sure | ||
171 | QTimer::singleShot(0, this, SLOT(slotDone() ) ); | ||
172 | } | ||
169 | void SendWidget::slotDone() { | 173 | void SendWidget::slotDone() { |
170 | QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); | 174 | QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); |
171 | QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); | 175 | QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); |
172 | emit done(); | 176 | emit done(); |
173 | } | 177 | } |
174 | QString SendWidget::file()const { | 178 | QString SendWidget::file()const { |
175 | return m_file; | 179 | return m_file; |
176 | } | 180 | } |
177 | DeviceBox::DeviceBox( QWidget* parent ) | 181 | DeviceBox::DeviceBox( QWidget* parent ) |
178 | : QTextBrowser( parent ) { | 182 | : QTextBrowser( parent ) { |
179 | 183 | ||
180 | } | 184 | } |
181 | DeviceBox::~DeviceBox() { | 185 | DeviceBox::~DeviceBox() { |
182 | 186 | ||
183 | } | 187 | } |
184 | int DeviceBox::addDevice( const QString& name, int dev, const QString& status ) { | 188 | int DeviceBox::addDevice( const QString& name, int dev, const QString& status ) { |
185 | /* return a id for a range of devices */ | 189 | /* return a id for a range of devices */ |
186 | int id = idFor ( dev ); | 190 | int id = idFor ( dev ); |
187 | DeviceItem item( name, status, dev,id ); | 191 | DeviceItem item( name, status, dev,id ); |
188 | m_dev.insert( id, item ); | 192 | m_dev.insert( id, item ); |
189 | setText( allText() ); | 193 | setText( allText() ); |
190 | 194 | ||
191 | return id; | 195 | return id; |
192 | } | 196 | } |
193 | void DeviceBox::removeDevice( int id ) { | 197 | void DeviceBox::removeDevice( int id ) { |
194 | if (!m_dev.contains(id) ) return; | 198 | if (!m_dev.contains(id) ) return; |
195 | 199 | ||
196 | m_dev.remove( id ); | 200 | m_dev.remove( id ); |
197 | setText( allText() ); | 201 | setText( allText() ); |
198 | } | 202 | } |
199 | void DeviceBox::setStatus( int id, const QString& status ) { | 203 | void DeviceBox::setStatus( int id, const QString& status ) { |
200 | if ( !m_dev.contains(id) ) return; | 204 | if ( !m_dev.contains(id) ) return; |
diff --git a/core/obex/obexsend.h b/core/obex/obexsend.h index 02100f7..bf901cb 100644 --- a/core/obex/obexsend.h +++ b/core/obex/obexsend.h | |||
@@ -10,64 +10,67 @@ | |||
10 | 10 | ||
11 | class QLabel; | 11 | class QLabel; |
12 | class QVBoxLayout; | 12 | class QVBoxLayout; |
13 | /** | 13 | /** |
14 | * This is the new sending widget for Obex | 14 | * This is the new sending widget for Obex |
15 | * It will attemp to smart and be able to send | 15 | * It will attemp to smart and be able to send |
16 | * it to multiple devices. | 16 | * it to multiple devices. |
17 | * It'll support BT + IrDa | 17 | * It'll support BT + IrDa |
18 | */ | 18 | */ |
19 | namespace OpieObex { | 19 | namespace OpieObex { |
20 | class DeviceBox; | 20 | class DeviceBox; |
21 | class Obex; | 21 | class Obex; |
22 | 22 | ||
23 | struct Pair { | 23 | struct Pair { |
24 | Pair(const QString& first = QString::null, | 24 | Pair(const QString& first = QString::null, |
25 | const QString& second = QString::null) | 25 | const QString& second = QString::null) |
26 | : m_first(first), m_second(second ) { | 26 | : m_first(first), m_second(second ) { |
27 | } | 27 | } |
28 | QString first()const{ return m_first; } | 28 | QString first()const{ return m_first; } |
29 | QString second()const { return m_second; } | 29 | QString second()const { return m_second; } |
30 | private: | 30 | private: |
31 | QString m_first; | 31 | QString m_first; |
32 | QString m_second; | 32 | QString m_second; |
33 | }; | 33 | }; |
34 | class SendWidget : public QWidget{ | 34 | class SendWidget : public QWidget{ |
35 | Q_OBJECT | 35 | Q_OBJECT |
36 | public: | 36 | public: |
37 | SendWidget( QWidget* parent = 0, const char* name = 0); | 37 | SendWidget( QWidget* parent = 0, const char* name = 0); |
38 | ~SendWidget(); | 38 | ~SendWidget(); |
39 | 39 | ||
40 | QString file()const; | 40 | QString file()const; |
41 | 41 | ||
42 | protected: | ||
43 | void closeEvent( QCloseEvent* ); | ||
44 | |||
42 | public slots: | 45 | public slots: |
43 | void send( const QString& file, const QString& desc ); | 46 | void send( const QString& file, const QString& desc ); |
44 | 47 | ||
45 | signals: | 48 | signals: |
46 | void done(); | 49 | void done(); |
47 | 50 | ||
48 | private slots: // QCOP slots | 51 | private slots: // QCOP slots |
49 | /* IrDa Names*/ | 52 | /* IrDa Names*/ |
50 | void slotIrDaDevices( const QStringList& ); | 53 | void slotIrDaDevices( const QStringList& ); |
51 | /* Bt Names + BD-Addr */ | 54 | /* Bt Names + BD-Addr */ |
52 | void slotBTDevices( const QMap<QString, QString>& ); | 55 | void slotBTDevices( const QMap<QString, QString>& ); |
53 | void slotSelectedDevice( int id, int dev ); | 56 | void slotSelectedDevice( int id, int dev ); |
54 | void dispatchIrda( const QCString& str, const QByteArray& ar ); | 57 | void dispatchIrda( const QCString& str, const QByteArray& ar ); |
55 | void dispatchBt( const QCString& str, const QByteArray& ar ); | 58 | void dispatchBt( const QCString& str, const QByteArray& ar ); |
56 | 59 | ||
57 | void slotIrError( int ); | 60 | void slotIrError( int ); |
58 | void slotIrSent(bool); | 61 | void slotIrSent(bool); |
59 | void slotIrTry(unsigned int ); | 62 | void slotIrTry(unsigned int ); |
60 | void slotStartIrda(); | 63 | void slotStartIrda(); |
61 | void slotDone(); | 64 | void slotDone(); |
62 | private: | 65 | private: |
63 | void initUI(); | 66 | void initUI(); |
64 | QLabel* m_lblFile; | 67 | QLabel* m_lblFile; |
65 | DeviceBox* m_devBox; | 68 | DeviceBox* m_devBox; |
66 | QVBoxLayout* m_lay; | 69 | QVBoxLayout* m_lay; |
67 | int m_start; | 70 | int m_start; |
68 | QMap<int, QString> m_irDa; | 71 | QMap<int, QString> m_irDa; |
69 | QMap<int, QString>::Iterator m_irDaIt; | 72 | QMap<int, QString>::Iterator m_irDaIt; |
70 | QMap<int, Pair > m_bt; | 73 | QMap<int, Pair > m_bt; |
71 | QString m_file; | 74 | QString m_file; |
72 | Obex* m_obex; | 75 | Obex* m_obex; |
73 | int m_irDeSearch; // search of irda and bt devices | 76 | int m_irDeSearch; // search of irda and bt devices |