-rw-r--r-- | core/obex/obexsend.cpp | 10 | ||||
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp index 9a30a0a..2512de3 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp | |||
@@ -1,252 +1,252 @@ | |||
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 | 10 | ||
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | #include <opie2/odebug.h> | 12 | #include <opie2/odebug.h> |
13 | #include <qpe/qcopenvelope_qws.h> | 13 | #include <qpe/qcopenvelope_qws.h> |
14 | #include <qpe/resource.h> | 14 | #include <opie2/oresource.h> |
15 | 15 | ||
16 | using namespace Opie::Core; | 16 | using namespace Opie::Core; |
17 | 17 | ||
18 | /* QT */ | 18 | /* QT */ |
19 | #include <qlabel.h> | 19 | #include <qlabel.h> |
20 | #include <qpushbutton.h> | 20 | #include <qpushbutton.h> |
21 | #include <qpixmap.h> | 21 | #include <qpixmap.h> |
22 | #include <qlistview.h> | 22 | #include <qlistview.h> |
23 | 23 | ||
24 | #include <unistd.h> | 24 | #include <unistd.h> |
25 | /* TRANSLATOR OpieObex::SendWidget */ | 25 | /* TRANSLATOR OpieObex::SendWidget */ |
26 | 26 | ||
27 | SendWidget::SendWidget( QWidget* parent, const char* name ) | 27 | SendWidget::SendWidget( QWidget* parent, const char* name ) |
28 | : obexSendBase( parent, name ) { | 28 | : obexSendBase( parent, name ) { |
29 | initUI(); | 29 | initUI(); |
30 | } | 30 | } |
31 | SendWidget::~SendWidget() { | 31 | SendWidget::~SendWidget() { |
32 | } | 32 | } |
33 | void SendWidget::initUI() { | 33 | void SendWidget::initUI() { |
34 | m_obex = new Obex(this, "obex"); | 34 | m_obex = new Obex(this, "obex"); |
35 | connect(m_obex, SIGNAL(error(int) ), | 35 | connect(m_obex, SIGNAL(error(int) ), |
36 | this, SLOT(slotIrError(int) ) ); | 36 | this, SLOT(slotIrError(int) ) ); |
37 | connect(m_obex, SIGNAL(sent(bool) ), | 37 | connect(m_obex, SIGNAL(sent(bool) ), |
38 | this, SLOT(slotIrSent(bool) ) ); | 38 | this, SLOT(slotIrSent(bool) ) ); |
39 | connect(m_obex, SIGNAL(currentTry(unsigned int) ), | 39 | connect(m_obex, SIGNAL(currentTry(unsigned int) ), |
40 | this, SLOT(slotIrTry(unsigned int) ) ); | 40 | this, SLOT(slotIrTry(unsigned int) ) ); |
41 | 41 | ||
42 | QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); | 42 | QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); |
43 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 43 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
44 | this, SLOT(dispatchIrda(const QCString&,const QByteArray&) ) ); | 44 | this, SLOT(dispatchIrda(const QCString&,const QByteArray&) ) ); |
45 | 45 | ||
46 | m_btobex = new BtObex(this, "btobex"); | 46 | m_btobex = new BtObex(this, "btobex"); |
47 | connect(m_btobex, SIGNAL(error(int) ), | 47 | connect(m_btobex, SIGNAL(error(int) ), |
48 | this, SLOT(slotBtError(int) ) ); | 48 | this, SLOT(slotBtError(int) ) ); |
49 | connect(m_btobex, SIGNAL(sent(bool) ), | 49 | connect(m_btobex, SIGNAL(sent(bool) ), |
50 | this, SLOT(slotBtSent(bool) ) ); | 50 | this, SLOT(slotBtSent(bool) ) ); |
51 | connect(m_btobex, SIGNAL(currentTry(unsigned int) ), | 51 | connect(m_btobex, SIGNAL(currentTry(unsigned int) ), |
52 | this, SLOT(slotBtTry(unsigned int) ) ); | 52 | this, SLOT(slotBtTry(unsigned int) ) ); |
53 | 53 | ||
54 | chan = new QCopChannel("QPE/BluetoothBack", this ); | 54 | chan = new QCopChannel("QPE/BluetoothBack", this ); |
55 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 55 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
56 | this, SLOT(dispatchBt(const QCString&,const QByteArray&) ) ); | 56 | this, SLOT(dispatchBt(const QCString&,const QByteArray&) ) ); |
57 | 57 | ||
58 | } | 58 | } |
59 | 59 | ||
60 | /* | 60 | /* |
61 | * in send we'll first set everything up | 61 | * in send we'll first set everything up |
62 | * and then wait for a list of devices. | 62 | * and then wait for a list of devices. |
63 | */ | 63 | */ |
64 | void SendWidget::send( const QString& file, const QString& desc ) { | 64 | void SendWidget::send( const QString& file, const QString& desc ) { |
65 | m_file = file; | 65 | m_file = file; |
66 | m_irDa.clear(); | 66 | m_irDa.clear(); |
67 | m_start = 0; | 67 | m_start = 0; |
68 | 68 | ||
69 | fileToSend->setText(desc.isEmpty() ? file : desc ); | 69 | fileToSend->setText(desc.isEmpty() ? file : desc ); |
70 | scan_for_receivers(); | 70 | scan_for_receivers(); |
71 | } | 71 | } |
72 | 72 | ||
73 | int SendWidget::addReceiver(const char *r, const char *icon) | 73 | int SendWidget::addReceiver(const char *r, const char *icon) |
74 | { | 74 | { |
75 | QListViewItem * item = new QListViewItem( receiverList, 0 ); | 75 | QListViewItem * item = new QListViewItem( receiverList, 0 ); |
76 | item->setText( 0, r); | 76 | item->setText( 0, r); |
77 | item->setPixmap( 1, Resource::loadPixmap( icon ) ); | 77 | item->setPixmap( 1, OResource::loadPixmap( icon ) ); |
78 | 78 | ||
79 | int id=receivers.count(); | 79 | int id=receivers.count(); |
80 | receivers[id]=item; | 80 | receivers[id]=item; |
81 | return id; | 81 | return id; |
82 | } | 82 | } |
83 | 83 | ||
84 | bool SendWidget::receiverSelected(int id) | 84 | bool SendWidget::receiverSelected(int id) |
85 | { | 85 | { |
86 | return (bool)(receivers[id]->pixmap(2) != NULL); | 86 | return (bool)(receivers[id]->pixmap(2) != NULL); |
87 | } | 87 | } |
88 | 88 | ||
89 | void SendWidget::setReceiverStatus( int id, const QString& status ) { | 89 | void SendWidget::setReceiverStatus( int id, const QString& status ) { |
90 | if ( !receivers.contains(id) ) return; | 90 | if ( !receivers.contains(id) ) return; |
91 | receivers[id]->setText(3, status ); | 91 | receivers[id]->setText(3, status ); |
92 | } | 92 | } |
93 | 93 | ||
94 | void SendWidget::slotIrDaDevices( const QStringList& list) { | 94 | void SendWidget::slotIrDaDevices( const QStringList& list) { |
95 | for (QStringList::ConstIterator it = list.begin(); | 95 | for (QStringList::ConstIterator it = list.begin(); |
96 | it != list.end(); ++it ) { | 96 | it != list.end(); ++it ) { |
97 | int id = addReceiver(*it, "obex/irda.png"); | 97 | int id = addReceiver(*it, "obex/irda.png"); |
98 | m_irDa.insert( id, (*it) ); | 98 | m_irDa.insert( id, (*it) ); |
99 | } | 99 | } |
100 | irdaStatus->setText( tr("ready.")); | 100 | irdaStatus->setText( tr("ready.")); |
101 | m_irDaIt = m_irDa.begin(); | 101 | m_irDaIt = m_irDa.begin(); |
102 | 102 | ||
103 | } | 103 | } |
104 | 104 | ||
105 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { | 105 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { |
106 | for(QMap<QString, QString>::ConstIterator it = str.begin(); | 106 | for(QMap<QString, QString>::ConstIterator it = str.begin(); |
107 | it != str.end(); ++it ) { | 107 | it != str.end(); ++it ) { |
108 | int id = addReceiver(it.key(), "obex/bt.png"); | 108 | int id = addReceiver(it.key(), "obex/bt.png"); |
109 | m_bt.insert( id, Pair( it.key(), it.data() ) ); | 109 | m_bt.insert( id, Pair( it.key(), it.data() ) ); |
110 | } | 110 | } |
111 | btStatus->setText(tr("ready.")); | 111 | btStatus->setText(tr("ready.")); |
112 | m_btIt = m_bt.begin(); | 112 | m_btIt = m_bt.begin(); |
113 | 113 | ||
114 | } | 114 | } |
115 | void SendWidget::slotSelectedDevice( int, int ) { | 115 | void SendWidget::slotSelectedDevice( int, int ) { |
116 | /* if ( name == m_irDeSearch ) { | 116 | /* if ( name == m_irDeSearch ) { |
117 | for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) | 117 | for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) |
118 | m_devBox->removeDevice( it.key() ); | 118 | m_devBox->removeDevice( it.key() ); |
119 | 119 | ||
120 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 120 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
121 | }*/ | 121 | }*/ |
122 | } | 122 | } |
123 | void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { | 123 | void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { |
124 | if ( str == "devices(QStringList)" ) { | 124 | if ( str == "devices(QStringList)" ) { |
125 | QDataStream stream( ar, IO_ReadOnly ); | 125 | QDataStream stream( ar, IO_ReadOnly ); |
126 | QStringList list; | 126 | QStringList list; |
127 | stream >> list; | 127 | stream >> list; |
128 | slotIrDaDevices( list ); | 128 | slotIrDaDevices( list ); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | void SendWidget::slotIrError( int ) { | 131 | void SendWidget::slotIrError( int ) { |
132 | irdaStatus->setText(tr("error :(")); | 132 | irdaStatus->setText(tr("error :(")); |
133 | } | 133 | } |
134 | void SendWidget::slotIrSent( bool b) { | 134 | void SendWidget::slotIrSent( bool b) { |
135 | QString text = b ? tr("Sent") : tr("Failure"); | 135 | QString text = b ? tr("Sent") : tr("Failure"); |
136 | setReceiverStatus( m_irDaIt.key(), text ); | 136 | setReceiverStatus( m_irDaIt.key(), text ); |
137 | ++m_irDaIt; | 137 | ++m_irDaIt; |
138 | slotStartIrda(); | 138 | slotStartIrda(); |
139 | } | 139 | } |
140 | void SendWidget::slotIrTry(unsigned int trI) { | 140 | void SendWidget::slotIrTry(unsigned int trI) { |
141 | setReceiverStatus(m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) )); | 141 | setReceiverStatus(m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) )); |
142 | } | 142 | } |
143 | void SendWidget::slotStartIrda() { | 143 | void SendWidget::slotStartIrda() { |
144 | if ( !m_irDa.count() ) | 144 | if ( !m_irDa.count() ) |
145 | return; | 145 | return; |
146 | if ( m_irDaIt == m_irDa.end() || !receiverSelected(m_irDaIt.key())) { | 146 | if ( m_irDaIt == m_irDa.end() || !receiverSelected(m_irDaIt.key())) { |
147 | irdaStatus->setText(tr("complete.")); | 147 | irdaStatus->setText(tr("complete.")); |
148 | return; | 148 | return; |
149 | } | 149 | } |
150 | setReceiverStatus( m_irDaIt.key(), tr("Start sending") ); | 150 | setReceiverStatus( m_irDaIt.key(), tr("Start sending") ); |
151 | m_obex->send( m_file, tr("noaddress") ); | 151 | m_obex->send( m_file, tr("noaddress") ); |
152 | } | 152 | } |
153 | 153 | ||
154 | void SendWidget::dispatchBt( const QCString& str, const QByteArray& ar ) { | 154 | void SendWidget::dispatchBt( const QCString& str, const QByteArray& ar ) { |
155 | if ( str == "devices(QStringMap)" ) { | 155 | if ( str == "devices(QStringMap)" ) { |
156 | QDataStream stream( ar, IO_ReadOnly ); | 156 | QDataStream stream( ar, IO_ReadOnly ); |
157 | QMap<QString, QString> btmap; | 157 | QMap<QString, QString> btmap; |
158 | stream >> btmap; | 158 | stream >> btmap; |
159 | slotBTDevices( btmap ); | 159 | slotBTDevices( btmap ); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | void SendWidget::slotBtError( int ) { | 162 | void SendWidget::slotBtError( int ) { |
163 | btStatus->setText(tr("error :(")); | 163 | btStatus->setText(tr("error :(")); |
164 | } | 164 | } |
165 | void SendWidget::slotBtSent( bool b) { | 165 | void SendWidget::slotBtSent( bool b) { |
166 | QString text = b ? tr("Sent") : tr("Failure"); | 166 | QString text = b ? tr("Sent") : tr("Failure"); |
167 | setReceiverStatus( m_btIt.key(), text ); | 167 | setReceiverStatus( m_btIt.key(), text ); |
168 | ++m_btIt; | 168 | ++m_btIt; |
169 | slotStartBt(); | 169 | slotStartBt(); |
170 | } | 170 | } |
171 | void SendWidget::slotBtTry(unsigned int trI) { | 171 | void SendWidget::slotBtTry(unsigned int trI) { |
172 | setReceiverStatus( m_btIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); | 172 | setReceiverStatus( m_btIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); |
173 | } | 173 | } |
174 | void SendWidget::slotStartBt() { | 174 | void SendWidget::slotStartBt() { |
175 | // skip past unselected receivers | 175 | // skip past unselected receivers |
176 | while((m_btIt != m_bt.end()) && !receiverSelected(m_btIt.key())) | 176 | while((m_btIt != m_bt.end()) && !receiverSelected(m_btIt.key())) |
177 | ++m_btIt; | 177 | ++m_btIt; |
178 | if (m_btIt == m_bt.end() ) { | 178 | if (m_btIt == m_bt.end() ) { |
179 | btStatus->setText(tr("complete.")); | 179 | btStatus->setText(tr("complete.")); |
180 | return; | 180 | return; |
181 | } | 181 | } |
182 | setReceiverStatus( m_btIt.key(), tr("Start sending") ); | 182 | setReceiverStatus( m_btIt.key(), tr("Start sending") ); |
183 | m_btobex->send( m_file, m_btIt.data().second() ); | 183 | m_btobex->send( m_file, m_btIt.data().second() ); |
184 | } | 184 | } |
185 | 185 | ||
186 | void SendWidget::send_to_receivers() { | 186 | void SendWidget::send_to_receivers() { |
187 | slotStartIrda(); | 187 | slotStartIrda(); |
188 | slotStartBt(); | 188 | slotStartBt(); |
189 | } | 189 | } |
190 | 190 | ||
191 | void SendWidget::scan_for_receivers() | 191 | void SendWidget::scan_for_receivers() |
192 | { | 192 | { |
193 | receiverList->clear(); | 193 | receiverList->clear(); |
194 | receivers.clear(); | 194 | receivers.clear(); |
195 | sendButton->setDisabled( true ); | 195 | sendButton->setDisabled( true ); |
196 | 196 | ||
197 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) | 197 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) |
198 | { | 198 | { |
199 | irdaStatus->setText(tr("not enabled.")); | 199 | irdaStatus->setText(tr("not enabled.")); |
200 | } | 200 | } |
201 | else | 201 | else |
202 | { | 202 | { |
203 | QCopEnvelope e1("QPE/IrDaApplet", "enableIrda()"); | 203 | QCopEnvelope e1("QPE/IrDaApplet", "enableIrda()"); |
204 | irdaStatus->setText(tr("searching...")); | 204 | irdaStatus->setText(tr("searching...")); |
205 | sendButton->setEnabled( true ); | 205 | sendButton->setEnabled( true ); |
206 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 206 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
207 | } | 207 | } |
208 | 208 | ||
209 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) | 209 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) |
210 | { | 210 | { |
211 | btStatus->setText(tr("not enabled.")); | 211 | btStatus->setText(tr("not enabled.")); |
212 | } | 212 | } |
213 | else | 213 | else |
214 | { | 214 | { |
215 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); | 215 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); |
216 | btStatus->setText(tr("searching...")); | 216 | btStatus->setText(tr("searching...")); |
217 | sendButton->setEnabled( true ); | 217 | sendButton->setEnabled( true ); |
218 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); | 218 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 | ||
222 | void SendWidget::toggle_receiver(QListViewItem* item) | 222 | void SendWidget::toggle_receiver(QListViewItem* item) |
223 | { | 223 | { |
224 | // toggle the state of an individual receiver. | 224 | // toggle the state of an individual receiver. |
225 | if(item->pixmap(2)) | 225 | if (item->pixmap(2)) |
226 | item->setPixmap(2,QPixmap()); | 226 | item->setPixmap(2, QPixmap()); |
227 | else | 227 | else |
228 | item->setPixmap(2,Resource::loadPixmap("obex/check.png")); | 228 | item->setPixmap(2, OResource::loadPixmap("obex/check.png")); |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | void SendWidget::closeEvent( QCloseEvent* evt) { | 232 | void SendWidget::closeEvent( QCloseEvent* evt) { |
233 | delete m_obex; | 233 | delete m_obex; |
234 | m_obex = NULL; | 234 | m_obex = NULL; |
235 | delete m_btobex; | 235 | delete m_btobex; |
236 | m_btobex = NULL; | 236 | m_btobex = NULL; |
237 | obexSendBase::closeEvent(evt); | 237 | obexSendBase::closeEvent(evt); |
238 | { | 238 | { |
239 | QCopEnvelope e("QPE/IrDaApplet", "disableIrda()"); | 239 | QCopEnvelope e("QPE/IrDaApplet", "disableIrda()"); |
240 | } | 240 | } |
241 | { | 241 | { |
242 | QCopEnvelope e("QPE/Bluetooth", "disableBluetooth()"); | 242 | QCopEnvelope e("QPE/Bluetooth", "disableBluetooth()"); |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | void SendWidget::userDone() { | 246 | void SendWidget::userDone() { |
247 | close(); | 247 | close(); |
248 | } | 248 | } |
249 | 249 | ||
250 | QString SendWidget::file()const { | 250 | QString SendWidget::file()const { |
251 | return m_file; | 251 | return m_file; |
252 | } | 252 | } |
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp index 91ab2e1..8498afc 100644 --- a/noncore/net/opietooth/applet/bluezapplet.cpp +++ b/noncore/net/opietooth/applet/bluezapplet.cpp | |||
@@ -1,168 +1,168 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> | 3 | .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <, > . <= redistribute it and/or modify it under | 6 | .> <, > . <= redistribute it and/or modify it under |
7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; version 2 of the License. | 9 | - . .-<_> .<> Foundation; version 2 of the License. |
10 | ._= =} : | 10 | ._= =} : |
11 | .%+i> _;_. | 11 | .%+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. . .: details. | 18 | ++= -. . .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-= this library; see the file COPYING.LIB. | 22 | -- :-= this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | 29 | ||
30 | #include "bluezapplet.h" | 30 | #include "bluezapplet.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/otaskbarapplet.h> | 33 | #include <opie2/otaskbarapplet.h> |
34 | #include <opie2/odevice.h> | 34 | #include <opie2/odevice.h> |
35 | #include <opie2/odebug.h> | 35 | #include <opie2/odebug.h> |
36 | #include <opie2/oresource.h> | 36 | #include <opie2/oresource.h> |
37 | #include <opie2/oprocess.h> | 37 | #include <opie2/oprocess.h> |
38 | #include <qpe/version.h> | 38 | #include <qpe/version.h> |
39 | #include <qpe/applnk.h> | 39 | #include <qpe/applnk.h> |
40 | #include <qpe/qcopenvelope_qws.h> | 40 | #include <qpe/qcopenvelope_qws.h> |
41 | #include <qpe/config.h> | 41 | #include <qpe/config.h> |
42 | using namespace Opie::Core; | 42 | using namespace Opie::Core; |
43 | 43 | ||
44 | /* QT */ | 44 | /* QT */ |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qpoint.h> | 46 | #include <qpoint.h> |
47 | #include <qpainter.h> | 47 | #include <qpainter.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qframe.h> | 49 | #include <qframe.h> |
50 | #include <qpixmap.h> | 50 | #include <qpixmap.h> |
51 | #include <qstring.h> | 51 | #include <qstring.h> |
52 | #include <qtimer.h> | 52 | #include <qtimer.h> |
53 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
54 | #include <qmessagebox.h> | 54 | #include <qmessagebox.h> |
55 | 55 | ||
56 | /* STD */ | 56 | /* STD */ |
57 | #include <device.h> | 57 | #include <device.h> |
58 | 58 | ||
59 | namespace OpieTooth { | 59 | namespace OpieTooth { |
60 | BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { | 60 | BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { |
61 | setFixedHeight( AppLnk::smallIconSize() ); | 61 | setFixedHeight( AppLnk::smallIconSize() ); |
62 | setFixedWidth( AppLnk::smallIconSize() ); | 62 | setFixedWidth( AppLnk::smallIconSize() ); |
63 | #if OPIE_VERSION < 102010 | 63 | #if OPIE_VERSION < 102010 |
64 | bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); | 64 | bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); |
65 | bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); | 65 | bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); |
66 | bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass.png" ); | 66 | bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass.png" ); |
67 | bluezReceiveOnPixmap = Resource::loadPixmap( "bluetoothapplet/receive.png" ); | 67 | bluezReceiveOnPixmap = Resource::loadPixmap( "bluetoothapplet/receive.png" ); |
68 | #else | 68 | #else |
69 | bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon ); | 69 | bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon ); |
70 | bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon ); | 70 | bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon ); |
71 | bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon ); | 71 | bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon ); |
72 | bluezReceiveOnPixmap = Resource::loadImage( "bluetoothapplet/bluezonreceive", Opie::Core::OResource::SmallIcon ); | 72 | bluezReceiveOnPixmap = OResource::loadImage( "bluetoothapplet/bluezonreceive", Opie::Core::OResource::SmallIcon ); |
73 | #endif | 73 | #endif |
74 | startTimer(2000); | 74 | startTimer(2000); |
75 | btDevice = 0; | 75 | btDevice = 0; |
76 | btManager = 0; | 76 | btManager = 0; |
77 | bluezactive = false; | 77 | bluezactive = false; |
78 | bluezDiscoveryActive = false; | 78 | bluezDiscoveryActive = false; |
79 | bluezReceiveActive = false; | 79 | bluezReceiveActive = false; |
80 | bluezReceiveChanged = false; | 80 | bluezReceiveChanged = false; |
81 | doListDevice = false; | 81 | doListDevice = false; |
82 | isScanning = false; | 82 | isScanning = false; |
83 | m_wasOn = false; | 83 | m_wasOn = false; |
84 | m_sync = false; | 84 | m_sync = false; |
85 | 85 | ||
86 | // TODO: determine whether this channel has to be closed at destruction time. | 86 | // TODO: determine whether this channel has to be closed at destruction time. |
87 | QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this ); | 87 | QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this ); |
88 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 88 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
89 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); | 89 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); |
90 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 90 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
91 | } | 91 | } |
92 | 92 | ||
93 | BluezApplet::~BluezApplet() { | 93 | BluezApplet::~BluezApplet() { |
94 | if ( btDevice ) { | 94 | if ( btDevice ) { |
95 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 95 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
96 | delete btDevice; | 96 | delete btDevice; |
97 | } | 97 | } |
98 | if ( btManager ) { | 98 | if ( btManager ) { |
99 | delete btManager; | 99 | delete btManager; |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | int BluezApplet::position() | 103 | int BluezApplet::position() |
104 | { | 104 | { |
105 | return 6; | 105 | return 6; |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | bool BluezApplet::checkBluezStatus() { | 109 | bool BluezApplet::checkBluezStatus() { |
110 | if (btDevice) { | 110 | if (btDevice) { |
111 | if (btDevice->isLoaded() ) { | 111 | if (btDevice->isLoaded() ) { |
112 | odebug << "btDevice isLoaded" << oendl; | 112 | odebug << "btDevice isLoaded" << oendl; |
113 | return true; | 113 | return true; |
114 | } else { | 114 | } else { |
115 | odebug << "btDevice is NOT loaded" << oendl; | 115 | odebug << "btDevice is NOT loaded" << oendl; |
116 | return false; | 116 | return false; |
117 | } | 117 | } |
118 | } else { | 118 | } else { |
119 | odebug << "btDevice is ZERO" << oendl; | 119 | odebug << "btDevice is ZERO" << oendl; |
120 | return false; | 120 | return false; |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | int BluezApplet::setBluezStatus(int c, bool sync) { | 124 | int BluezApplet::setBluezStatus(int c, bool sync) { |
125 | 125 | ||
126 | if ( c == 1 ) { | 126 | if ( c == 1 ) { |
127 | switch ( ODevice::inst()->model() ) { | 127 | switch ( ODevice::inst()->model() ) { |
128 | case Model_iPAQ_H39xx: | 128 | case Model_iPAQ_H39xx: |
129 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); | 129 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); |
130 | break; | 130 | break; |
131 | 131 | ||
132 | case Model_iPAQ_H5xxx: | 132 | case Model_iPAQ_H5xxx: |
133 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); | 133 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); |
134 | break; | 134 | break; |
135 | 135 | ||
136 | #if OPIE_VERSION >= 102010 | 136 | #if OPIE_VERSION >= 102010 |
137 | case Model_MyPal_716: | 137 | case Model_MyPal_716: |
138 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); | 138 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); |
139 | break; | 139 | break; |
140 | #endif | 140 | #endif |
141 | case Model_iPAQ_H22xx: | 141 | case Model_iPAQ_H22xx: |
142 | btDevice = new Device( "/dev/tts/3", "any", "921600" ); | 142 | btDevice = new Device( "/dev/tts/3", "any", "921600" ); |
143 | break; | 143 | break; |
144 | 144 | ||
145 | default: | 145 | default: |
146 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); | 146 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); |
147 | break; | 147 | break; |
148 | } | 148 | } |
149 | m_sync = sync; | 149 | m_sync = sync; |
150 | connect(btDevice, SIGNAL(device(const QString&, bool)), | 150 | connect(btDevice, SIGNAL(device(const QString&, bool)), |
151 | this, SLOT(slotDevice(const QString&, bool))); | 151 | this, SLOT(slotDevice(const QString&, bool))); |
152 | 152 | ||
153 | } else { | 153 | } else { |
154 | setObexRecieveStatus(0); | 154 | setObexRecieveStatus(0); |
155 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 155 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
156 | if ( btManager ) { | 156 | if ( btManager ) { |
157 | delete btManager; | 157 | delete btManager; |
158 | btManager = 0; | 158 | btManager = 0; |
159 | } | 159 | } |
160 | if ( btDevice ) { | 160 | if ( btDevice ) { |
161 | delete btDevice; | 161 | delete btDevice; |
162 | btDevice = 0; | 162 | btDevice = 0; |
163 | } | 163 | } |
164 | } | 164 | } |
165 | return 0; | 165 | return 0; |
166 | } | 166 | } |
167 | 167 | ||
168 | int BluezApplet::checkBluezDiscoveryStatus() { | 168 | int BluezApplet::checkBluezDiscoveryStatus() { |