author | erik <erik> | 2007-02-08 01:43:09 (UTC) |
---|---|---|
committer | erik <erik> | 2007-02-08 01:43:09 (UTC) |
commit | 853b61f97e718359bef95147ab3c7beb0705acda (patch) (unidiff) | |
tree | 7b374511f636951a2ab9ff0f9fec7ec2d64abd2a | |
parent | c36a2e25a8875a31957968482ba8a0831a8b0aba (diff) | |
download | opie-853b61f97e718359bef95147ab3c7beb0705acda.zip opie-853b61f97e718359bef95147ab3c7beb0705acda.tar.gz opie-853b61f97e718359bef95147ab3c7beb0705acda.tar.bz2 |
This commit adds support for the HTC Universal bluetooth device to
bluezapplet. This commit is based on a patch submitted by GoXbox Live
<goxboxlive at gmail dot com> to the opie-devel mailing list.
Thanks GoXbox Live!
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp index 8498afc..787abc6 100644 --- a/noncore/net/opietooth/applet/bluezapplet.cpp +++ b/noncore/net/opietooth/applet/bluezapplet.cpp | |||
@@ -1,332 +1,336 @@ | |||
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 = OResource::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_HTC_Universal: | ||
142 | btDevice = new Device( "/dev/ttyS1", "texas", "115200" ); | ||
143 | break; | ||
144 | |||
141 | case Model_iPAQ_H22xx: | 145 | case Model_iPAQ_H22xx: |
142 | btDevice = new Device( "/dev/tts/3", "any", "921600" ); | 146 | btDevice = new Device( "/dev/tts/3", "any", "921600" ); |
143 | break; | 147 | break; |
144 | 148 | ||
145 | default: | 149 | default: |
146 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); | 150 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); |
147 | break; | 151 | break; |
148 | } | 152 | } |
149 | m_sync = sync; | 153 | m_sync = sync; |
150 | connect(btDevice, SIGNAL(device(const QString&, bool)), | 154 | connect(btDevice, SIGNAL(device(const QString&, bool)), |
151 | this, SLOT(slotDevice(const QString&, bool))); | 155 | this, SLOT(slotDevice(const QString&, bool))); |
152 | 156 | ||
153 | } else { | 157 | } else { |
154 | setObexRecieveStatus(0); | 158 | setObexRecieveStatus(0); |
155 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 159 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
156 | if ( btManager ) { | 160 | if ( btManager ) { |
157 | delete btManager; | 161 | delete btManager; |
158 | btManager = 0; | 162 | btManager = 0; |
159 | } | 163 | } |
160 | if ( btDevice ) { | 164 | if ( btDevice ) { |
161 | delete btDevice; | 165 | delete btDevice; |
162 | btDevice = 0; | 166 | btDevice = 0; |
163 | } | 167 | } |
164 | } | 168 | } |
165 | return 0; | 169 | return 0; |
166 | } | 170 | } |
167 | 171 | ||
168 | int BluezApplet::checkBluezDiscoveryStatus() { | 172 | int BluezApplet::checkBluezDiscoveryStatus() { |
169 | return isScanning; | 173 | return isScanning; |
170 | } | 174 | } |
171 | 175 | ||
172 | int BluezApplet::setBluezDiscoveryStatus(int d) { | 176 | int BluezApplet::setBluezDiscoveryStatus(int d) { |
173 | return bluezDiscoveryActive = d; | 177 | return bluezDiscoveryActive = d; |
174 | } | 178 | } |
175 | 179 | ||
176 | int BluezApplet::setObexRecieveStatus(int d) { | 180 | int BluezApplet::setObexRecieveStatus(int d) { |
177 | { | 181 | { |
178 | QCopEnvelope e ( "QPE/Obex", "btreceive(int)" ); | 182 | QCopEnvelope e ( "QPE/Obex", "btreceive(int)" ); |
179 | e << ( d ? 1 : 0 ); | 183 | e << ( d ? 1 : 0 ); |
180 | } | 184 | } |
181 | bluezReceiveActive = (bool)(d != 0); | 185 | bluezReceiveActive = (bool)(d != 0); |
182 | bluezReceiveChanged = true; | 186 | bluezReceiveChanged = true; |
183 | return d; | 187 | return d; |
184 | } | 188 | } |
185 | 189 | ||
186 | // FIXME mbhaynie | 190 | // FIXME mbhaynie |
187 | // receiver for QCopChannel("QPE/Bluetooth") messages. | 191 | // receiver for QCopChannel("QPE/Bluetooth") messages. |
188 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) | 192 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) |
189 | { | 193 | { |
190 | if ( str == "enableBluetooth()") { | 194 | if ( str == "enableBluetooth()") { |
191 | m_wasOn = checkBluezStatus(); | 195 | m_wasOn = checkBluezStatus(); |
192 | if (!m_wasOn) { | 196 | if (!m_wasOn) { |
193 | setBluezStatus(1, true); | 197 | setBluezStatus(1, true); |
194 | sleep(2); | 198 | sleep(2); |
195 | } | 199 | } |
196 | } | 200 | } |
197 | else if ( str == "disableBluetooth()") { | 201 | else if ( str == "disableBluetooth()") { |
198 | /* | 202 | /* |
199 | * We can down BT only if it was started by qcop. We don't want | 203 | * We can down BT only if it was started by qcop. We don't want |
200 | * to down BT started from menu an break our networking connection | 204 | * to down BT started from menu an break our networking connection |
201 | */ | 205 | */ |
202 | if (checkBluezStatus() && !m_wasOn) | 206 | if (checkBluezStatus() && !m_wasOn) |
203 | setBluezStatus(0); | 207 | setBluezStatus(0); |
204 | doListDevice = false; | 208 | doListDevice = false; |
205 | } | 209 | } |
206 | else if ( str == "listDevices()") { | 210 | else if ( str == "listDevices()") { |
207 | if (checkBluezStatus()) { | 211 | if (checkBluezStatus()) { |
208 | doListDevice = false; | 212 | doListDevice = false; |
209 | timerEvent(0); | 213 | timerEvent(0); |
210 | if (!btManager) { | 214 | if (!btManager) { |
211 | btManager = new Manager("hci0"); | 215 | btManager = new Manager("hci0"); |
212 | connect( btManager, | 216 | connect( btManager, |
213 | SIGNAL( foundDevices(const QString&, RemoteDevice::ValueList) ), | 217 | SIGNAL( foundDevices(const QString&, RemoteDevice::ValueList) ), |
214 | this, SLOT( fillList(const QString&, RemoteDevice::ValueList) ) ) ; | 218 | this, SLOT( fillList(const QString&, RemoteDevice::ValueList) ) ) ; |
215 | } | 219 | } |
216 | btManager->searchDevices(); | 220 | btManager->searchDevices(); |
217 | isScanning = true; | 221 | isScanning = true; |
218 | } else | 222 | } else |
219 | doListDevice = true; | 223 | doListDevice = true; |
220 | } | 224 | } |
221 | } | 225 | } |
222 | 226 | ||
223 | // Once the hcitool scan is complete, report back. | 227 | // Once the hcitool scan is complete, report back. |
224 | void BluezApplet::fillList(const QString&, RemoteDevice::ValueList deviceList) | 228 | void BluezApplet::fillList(const QString&, RemoteDevice::ValueList deviceList) |
225 | { | 229 | { |
226 | QCopEnvelope e("QPE/BluetoothBack", "devices(QStringMap)"); | 230 | QCopEnvelope e("QPE/BluetoothBack", "devices(QStringMap)"); |
227 | 231 | ||
228 | QMap<QString, QString> btmap; | 232 | QMap<QString, QString> btmap; |
229 | 233 | ||
230 | RemoteDevice::ValueList::Iterator it; | 234 | RemoteDevice::ValueList::Iterator it; |
231 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) | 235 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) |
232 | btmap[(*it).name()] = (*it).mac(); | 236 | btmap[(*it).name()] = (*it).mac(); |
233 | 237 | ||
234 | e << btmap; | 238 | e << btmap; |
235 | isScanning = false; | 239 | isScanning = false; |
236 | timerEvent( 0 ); | 240 | timerEvent( 0 ); |
237 | } | 241 | } |
238 | 242 | ||
239 | void BluezApplet::mousePressEvent( QMouseEvent *) { | 243 | void BluezApplet::mousePressEvent( QMouseEvent *) { |
240 | 244 | ||
241 | QPopupMenu *menu = new QPopupMenu(); | 245 | QPopupMenu *menu = new QPopupMenu(); |
242 | QPopupMenu *signal = new QPopupMenu(); | 246 | QPopupMenu *signal = new QPopupMenu(); |
243 | int ret=0; | 247 | int ret=0; |
244 | 248 | ||
245 | /* Refresh active state */ | 249 | /* Refresh active state */ |
246 | timerEvent( 0 ); | 250 | timerEvent( 0 ); |
247 | 251 | ||
248 | 252 | ||
249 | if (bluezactive) { | 253 | if (bluezactive) { |
250 | menu->insertItem( tr("Disable Bluetooth"), 0 ); | 254 | menu->insertItem( tr("Disable Bluetooth"), 0 ); |
251 | } else { | 255 | } else { |
252 | menu->insertItem( tr("Enable Bluetooth"), 1 ); | 256 | menu->insertItem( tr("Enable Bluetooth"), 1 ); |
253 | } | 257 | } |
254 | 258 | ||
255 | menu->insertItem( tr("Launch manager"), 2 ); | 259 | menu->insertItem( tr("Launch manager"), 2 ); |
256 | 260 | ||
257 | menu->insertSeparator(6); | 261 | menu->insertSeparator(6); |
258 | //menu->insertItem( tr("Signal strength"), signal, 5); | 262 | //menu->insertItem( tr("Signal strength"), signal, 5); |
259 | //menu->insertSeparator(8); | 263 | //menu->insertSeparator(8); |
260 | 264 | ||
261 | if (bluezactive) { | 265 | if (bluezactive) { |
262 | if (bluezReceiveActive) { | 266 | if (bluezReceiveActive) { |
263 | menu->insertItem( tr("Disable receive"), 3 ); | 267 | menu->insertItem( tr("Disable receive"), 3 ); |
264 | } else { | 268 | } else { |
265 | menu->insertItem( tr("Enable receive"), 4 ); | 269 | menu->insertItem( tr("Enable receive"), 4 ); |
266 | } | 270 | } |
267 | } | 271 | } |
268 | 272 | ||
269 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); | 273 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); |
270 | ret = menu->exec(p, 0); | 274 | ret = menu->exec(p, 0); |
271 | menu->hide(); | 275 | menu->hide(); |
272 | 276 | ||
273 | switch(ret) { | 277 | switch(ret) { |
274 | case 0: | 278 | case 0: |
275 | setBluezStatus(0); | 279 | setBluezStatus(0); |
276 | timerEvent( 0 ); | 280 | timerEvent( 0 ); |
277 | break; | 281 | break; |
278 | case 1: | 282 | case 1: |
279 | setBluezStatus(1); | 283 | setBluezStatus(1); |
280 | timerEvent( 0 ); | 284 | timerEvent( 0 ); |
281 | break; | 285 | break; |
282 | case 2: | 286 | case 2: |
283 | // start bluetoothmanager | 287 | // start bluetoothmanager |
284 | launchManager(); | 288 | launchManager(); |
285 | timerEvent( 0 ); | 289 | timerEvent( 0 ); |
286 | break; | 290 | break; |
287 | case 3: | 291 | case 3: |
288 | setObexRecieveStatus(0); | 292 | setObexRecieveStatus(0); |
289 | timerEvent( 0 ); | 293 | timerEvent( 0 ); |
290 | break; | 294 | break; |
291 | case 4: | 295 | case 4: |
292 | setObexRecieveStatus(1); | 296 | setObexRecieveStatus(1); |
293 | timerEvent( 0 ); | 297 | timerEvent( 0 ); |
294 | break; | 298 | break; |
295 | //case 7: | 299 | //case 7: |
296 | // With table of currently-detected devices. | 300 | // With table of currently-detected devices. |
297 | } | 301 | } |
298 | 302 | ||
299 | delete signal; | 303 | delete signal; |
300 | delete menu; | 304 | delete menu; |
301 | } | 305 | } |
302 | 306 | ||
303 | 307 | ||
304 | /** | 308 | /** |
305 | * Launches the bluetooth manager | 309 | * Launches the bluetooth manager |
306 | */ | 310 | */ |
307 | void BluezApplet::launchManager() { | 311 | void BluezApplet::launchManager() { |
308 | QCopEnvelope e("QPE/System", "execute(QString)"); | 312 | QCopEnvelope e("QPE/System", "execute(QString)"); |
309 | e << QString("bluetooth-manager"); | 313 | e << QString("bluetooth-manager"); |
310 | } | 314 | } |
311 | 315 | ||
312 | /** | 316 | /** |
313 | * Refresh timer | 317 | * Refresh timer |
314 | * @param the timer event | 318 | * @param the timer event |
315 | */ | 319 | */ |
316 | void BluezApplet::timerEvent( QTimerEvent * ) { | 320 | void BluezApplet::timerEvent( QTimerEvent * ) { |
317 | bool oldactive = bluezactive; | 321 | bool oldactive = bluezactive; |
318 | int olddiscovery = bluezDiscoveryActive; | 322 | int olddiscovery = bluezDiscoveryActive; |
319 | 323 | ||
320 | bluezactive = checkBluezStatus(); | 324 | bluezactive = checkBluezStatus(); |
321 | bluezDiscoveryActive = checkBluezDiscoveryStatus(); | 325 | bluezDiscoveryActive = checkBluezDiscoveryStatus(); |
322 | 326 | ||
323 | if ((bluezactive != oldactive) || | 327 | if ((bluezactive != oldactive) || |
324 | (bluezDiscoveryActive != olddiscovery) || | 328 | (bluezDiscoveryActive != olddiscovery) || |
325 | bluezReceiveChanged) | 329 | bluezReceiveChanged) |
326 | update(); | 330 | update(); |
327 | if (bluezactive && doListDevice) { | 331 | if (bluezactive && doListDevice) { |
328 | const QByteArray arr; | 332 | const QByteArray arr; |
329 | slotMessage("listDevices()", arr); | 333 | slotMessage("listDevices()", arr); |
330 | } | 334 | } |
331 | if (bluezReceiveChanged) | 335 | if (bluezReceiveChanged) |
332 | bluezReceiveChanged = false; | 336 | bluezReceiveChanged = false; |