author | mickeyl <mickeyl> | 2006-05-13 11:47:05 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2006-05-13 11:47:05 (UTC) |
commit | 89efebff8f5a00089f02397aa0778dd0dbbacdbb (patch) (unidiff) | |
tree | 6562aa181606465f3776e552974961465a0c5943 | |
parent | e847e13515267ae9dc32648c3a427794a9449dfd (diff) | |
download | opie-89efebff8f5a00089f02397aa0778dd0dbbacdbb.zip opie-89efebff8f5a00089f02397aa0778dd0dbbacdbb.tar.gz opie-89efebff8f5a00089f02397aa0778dd0dbbacdbb.tar.bz2 |
don't use hand cooked #ifdef versions for conditional compiling, this breaks OE
I added a numerical version code in OPIE_VERSION which you can use. fixed all tests in bluezapplet.cpp
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp index 6351d4e..f7774f0 100644 --- a/noncore/net/opietooth/applet/bluezapplet.cpp +++ b/noncore/net/opietooth/applet/bluezapplet.cpp | |||
@@ -1,344 +1,343 @@ | |||
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/applnk.h> | 39 | #include <qpe/applnk.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 40 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/config.h> | 41 | #include <qpe/config.h> |
41 | using namespace Opie::Core; | 42 | using namespace Opie::Core; |
42 | 43 | ||
43 | /* QT */ | 44 | /* QT */ |
44 | #include <qapplication.h> | 45 | #include <qapplication.h> |
45 | #include <qpoint.h> | 46 | #include <qpoint.h> |
46 | #include <qpainter.h> | 47 | #include <qpainter.h> |
47 | #include <qlayout.h> | 48 | #include <qlayout.h> |
48 | #include <qframe.h> | 49 | #include <qframe.h> |
49 | #include <qpixmap.h> | 50 | #include <qpixmap.h> |
50 | #include <qstring.h> | 51 | #include <qstring.h> |
51 | #include <qtimer.h> | 52 | #include <qtimer.h> |
52 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
53 | #include <qmessagebox.h> | 54 | #include <qmessagebox.h> |
54 | 55 | ||
55 | /* STD */ | 56 | /* STD */ |
56 | #include <device.h> | 57 | #include <device.h> |
57 | 58 | ||
58 | #define OPIE120 // undefine it fo the latest OPIE | ||
59 | |||
60 | namespace OpieTooth { | 59 | namespace OpieTooth { |
61 | BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { | 60 | BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { |
62 | setFixedHeight( AppLnk::smallIconSize() ); | 61 | setFixedHeight( AppLnk::smallIconSize() ); |
63 | setFixedWidth( AppLnk::smallIconSize() ); | 62 | setFixedWidth( AppLnk::smallIconSize() ); |
64 | #ifdef OPIE120 | 63 | #if OPIE_VERSION < 102010 |
65 | bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); | 64 | bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); |
66 | bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); | 65 | bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); |
67 | bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass.png" ); | 66 | bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass.png" ); |
68 | #else | 67 | #else |
69 | bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon ); | 68 | bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon ); |
70 | bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon ); | 69 | bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon ); |
71 | bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon ); | 70 | bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon ); |
72 | #endif | 71 | #endif |
73 | startTimer(2000); | 72 | startTimer(2000); |
74 | btDevice = 0; | 73 | btDevice = 0; |
75 | btManager = 0; | 74 | btManager = 0; |
76 | bluezactive = false; | 75 | bluezactive = false; |
77 | bluezDiscoveryActive = false; | 76 | bluezDiscoveryActive = false; |
78 | doListDevice = false; | 77 | doListDevice = false; |
79 | isScanning = false; | 78 | isScanning = false; |
80 | m_wasOn = false; | 79 | m_wasOn = false; |
81 | 80 | ||
82 | // TODO: determine whether this channel has to be closed at destruction time. | 81 | // TODO: determine whether this channel has to be closed at destruction time. |
83 | QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this ); | 82 | QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this ); |
84 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 83 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
85 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); | 84 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); |
86 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 85 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
87 | } | 86 | } |
88 | 87 | ||
89 | BluezApplet::~BluezApplet() { | 88 | BluezApplet::~BluezApplet() { |
90 | if ( btDevice ) { | 89 | if ( btDevice ) { |
91 | delete btDevice; | 90 | delete btDevice; |
92 | } | 91 | } |
93 | if ( btManager ) { | 92 | if ( btManager ) { |
94 | delete btManager; | 93 | delete btManager; |
95 | } | 94 | } |
96 | } | 95 | } |
97 | 96 | ||
98 | int BluezApplet::position() | 97 | int BluezApplet::position() |
99 | { | 98 | { |
100 | return 6; | 99 | return 6; |
101 | } | 100 | } |
102 | 101 | ||
103 | 102 | ||
104 | bool BluezApplet::checkBluezStatus() { | 103 | bool BluezApplet::checkBluezStatus() { |
105 | if (btDevice) { | 104 | if (btDevice) { |
106 | if (btDevice->isLoaded() ) { | 105 | if (btDevice->isLoaded() ) { |
107 | odebug << "btDevice isLoaded" << oendl; | 106 | odebug << "btDevice isLoaded" << oendl; |
108 | return true; | 107 | return true; |
109 | } else { | 108 | } else { |
110 | odebug << "btDevice is NOT loaded" << oendl; | 109 | odebug << "btDevice is NOT loaded" << oendl; |
111 | return false; | 110 | return false; |
112 | } | 111 | } |
113 | } else { | 112 | } else { |
114 | odebug << "btDevice is ZERO" << oendl; | 113 | odebug << "btDevice is ZERO" << oendl; |
115 | return false; | 114 | return false; |
116 | } | 115 | } |
117 | } | 116 | } |
118 | 117 | ||
119 | int BluezApplet::setBluezStatus(int c, bool sync) { | 118 | int BluezApplet::setBluezStatus(int c, bool sync) { |
120 | 119 | ||
121 | if ( c == 1 ) { | 120 | if ( c == 1 ) { |
122 | switch ( ODevice::inst()->model() ) { | 121 | switch ( ODevice::inst()->model() ) { |
123 | case Model_iPAQ_H39xx: | 122 | case Model_iPAQ_H39xx: |
124 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); | 123 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); |
125 | break; | 124 | break; |
126 | 125 | ||
127 | case Model_iPAQ_H5xxx: | 126 | case Model_iPAQ_H5xxx: |
128 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); | 127 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); |
129 | break; | 128 | break; |
130 | 129 | ||
131 | #ifndef OPIE120 | 130 | #ifndef OPIE120 |
132 | case Model_MyPal_716: | 131 | case Model_MyPal_716: |
133 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); | 132 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); |
134 | break; | 133 | break; |
135 | #endif | 134 | #endif |
136 | 135 | ||
137 | default: | 136 | default: |
138 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); | 137 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); |
139 | break; | 138 | break; |
140 | } | 139 | } |
141 | if (sync) { | 140 | if (sync) { |
142 | ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null"); | 141 | ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null"); |
143 | } else { | 142 | } else { |
144 | QCopEnvelope e("QPE/System", "execute(QString)"); | 143 | QCopEnvelope e("QPE/System", "execute(QString)"); |
145 | e << QString("/etc/init.d/bluetooth start"); | 144 | e << QString("/etc/init.d/bluetooth start"); |
146 | } | 145 | } |
147 | } else { | 146 | } else { |
148 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 147 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
149 | if ( btManager ) { | 148 | if ( btManager ) { |
150 | delete btManager; | 149 | delete btManager; |
151 | btManager = 0; | 150 | btManager = 0; |
152 | } | 151 | } |
153 | if ( btDevice ) { | 152 | if ( btDevice ) { |
154 | delete btDevice; | 153 | delete btDevice; |
155 | btDevice = 0; | 154 | btDevice = 0; |
156 | } | 155 | } |
157 | } | 156 | } |
158 | return 0; | 157 | return 0; |
159 | } | 158 | } |
160 | 159 | ||
161 | int BluezApplet::checkBluezDiscoveryStatus() { | 160 | int BluezApplet::checkBluezDiscoveryStatus() { |
162 | return isScanning; | 161 | return isScanning; |
163 | } | 162 | } |
164 | 163 | ||
165 | int BluezApplet::setBluezDiscoveryStatus(int d) { | 164 | int BluezApplet::setBluezDiscoveryStatus(int d) { |
166 | return bluezDiscoveryActive = d; | 165 | return bluezDiscoveryActive = d; |
167 | } | 166 | } |
168 | 167 | ||
169 | // FIXME mbhaynie | 168 | // FIXME mbhaynie |
170 | // receiver for QCopChannel("QPE/Bluetooth") messages. | 169 | // receiver for QCopChannel("QPE/Bluetooth") messages. |
171 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) | 170 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) |
172 | { | 171 | { |
173 | if ( str == "enableBluetooth()") { | 172 | if ( str == "enableBluetooth()") { |
174 | m_wasOn = checkBluezStatus(); | 173 | m_wasOn = checkBluezStatus(); |
175 | if (!m_wasOn) { | 174 | if (!m_wasOn) { |
176 | setBluezStatus(1, true); | 175 | setBluezStatus(1, true); |
177 | sleep(2); | 176 | sleep(2); |
178 | } | 177 | } |
179 | } | 178 | } |
180 | else if ( str == "disableBluetooth()") { | 179 | else if ( str == "disableBluetooth()") { |
181 | /* | 180 | /* |
182 | * We can down BT only if it was started by qcop. We don't want | 181 | * We can down BT only if it was started by qcop. We don't want |
183 | * to down BT started from menu an break our networking connection | 182 | * to down BT started from menu an break our networking connection |
184 | */ | 183 | */ |
185 | if (checkBluezStatus() && !m_wasOn) | 184 | if (checkBluezStatus() && !m_wasOn) |
186 | setBluezStatus(0); | 185 | setBluezStatus(0); |
187 | doListDevice = false; | 186 | doListDevice = false; |
188 | } | 187 | } |
189 | else if ( str == "listDevices()") { | 188 | else if ( str == "listDevices()") { |
190 | if (checkBluezStatus()) { | 189 | if (checkBluezStatus()) { |
191 | doListDevice = false; | 190 | doListDevice = false; |
192 | timerEvent(0); | 191 | timerEvent(0); |
193 | if (!btManager) { | 192 | if (!btManager) { |
194 | btManager = new Manager("hci0"); | 193 | btManager = new Manager("hci0"); |
195 | connect( btManager, | 194 | connect( btManager, |
196 | SIGNAL( foundDevices(const QString&, RemoteDevice::ValueList) ), | 195 | SIGNAL( foundDevices(const QString&, RemoteDevice::ValueList) ), |
197 | this, SLOT( fillList(const QString&, RemoteDevice::ValueList) ) ) ; | 196 | this, SLOT( fillList(const QString&, RemoteDevice::ValueList) ) ) ; |
198 | } | 197 | } |
199 | btManager->searchDevices(); | 198 | btManager->searchDevices(); |
200 | isScanning = true; | 199 | isScanning = true; |
201 | } else | 200 | } else |
202 | doListDevice = true; | 201 | doListDevice = true; |
203 | } | 202 | } |
204 | } | 203 | } |
205 | 204 | ||
206 | // Once the hcitool scan is complete, report back. | 205 | // Once the hcitool scan is complete, report back. |
207 | void BluezApplet::fillList(const QString&, RemoteDevice::ValueList deviceList) | 206 | void BluezApplet::fillList(const QString&, RemoteDevice::ValueList deviceList) |
208 | { | 207 | { |
209 | QCopEnvelope e("QPE/BluetoothBack", "devices(QStringMap)"); | 208 | QCopEnvelope e("QPE/BluetoothBack", "devices(QStringMap)"); |
210 | 209 | ||
211 | QMap<QString, QString> btmap; | 210 | QMap<QString, QString> btmap; |
212 | 211 | ||
213 | RemoteDevice::ValueList::Iterator it; | 212 | RemoteDevice::ValueList::Iterator it; |
214 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) | 213 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) |
215 | btmap[(*it).name()] = (*it).mac(); | 214 | btmap[(*it).name()] = (*it).mac(); |
216 | 215 | ||
217 | e << btmap; | 216 | e << btmap; |
218 | isScanning = false; | 217 | isScanning = false; |
219 | timerEvent( 0 ); | 218 | timerEvent( 0 ); |
220 | } | 219 | } |
221 | 220 | ||
222 | void BluezApplet::mousePressEvent( QMouseEvent *) { | 221 | void BluezApplet::mousePressEvent( QMouseEvent *) { |
223 | 222 | ||
224 | QPopupMenu *menu = new QPopupMenu(); | 223 | QPopupMenu *menu = new QPopupMenu(); |
225 | QPopupMenu *signal = new QPopupMenu(); | 224 | QPopupMenu *signal = new QPopupMenu(); |
226 | int ret=0; | 225 | int ret=0; |
227 | 226 | ||
228 | /* Refresh active state */ | 227 | /* Refresh active state */ |
229 | timerEvent( 0 ); | 228 | timerEvent( 0 ); |
230 | 229 | ||
231 | 230 | ||
232 | if (bluezactive) { | 231 | if (bluezactive) { |
233 | menu->insertItem( tr("Disable Bluetooth"), 0 ); | 232 | menu->insertItem( tr("Disable Bluetooth"), 0 ); |
234 | } else { | 233 | } else { |
235 | menu->insertItem( tr("Enable Bluetooth"), 1 ); | 234 | menu->insertItem( tr("Enable Bluetooth"), 1 ); |
236 | } | 235 | } |
237 | 236 | ||
238 | menu->insertItem( tr("Launch manager"), 2 ); | 237 | menu->insertItem( tr("Launch manager"), 2 ); |
239 | 238 | ||
240 | menu->insertSeparator(6); | 239 | menu->insertSeparator(6); |
241 | //menu->insertItem( tr("Signal strength"), signal, 5); | 240 | //menu->insertItem( tr("Signal strength"), signal, 5); |
242 | //menu->insertSeparator(8); | 241 | //menu->insertSeparator(8); |
243 | 242 | ||
244 | if (bluezDiscoveryActive) { | 243 | if (bluezDiscoveryActive) { |
245 | menu->insertItem( tr("Disable discovery"), 3 ); | 244 | menu->insertItem( tr("Disable discovery"), 3 ); |
246 | } else { | 245 | } else { |
247 | menu->insertItem( tr("Enable discovery"), 4 ); | 246 | menu->insertItem( tr("Enable discovery"), 4 ); |
248 | } | 247 | } |
249 | 248 | ||
250 | 249 | ||
251 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); | 250 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); |
252 | ret = menu->exec(p, 0); | 251 | ret = menu->exec(p, 0); |
253 | menu->hide(); | 252 | menu->hide(); |
254 | 253 | ||
255 | switch(ret) { | 254 | switch(ret) { |
256 | case 0: | 255 | case 0: |
257 | setBluezStatus(0); | 256 | setBluezStatus(0); |
258 | timerEvent( 0 ); | 257 | timerEvent( 0 ); |
259 | break; | 258 | break; |
260 | case 1: | 259 | case 1: |
261 | setBluezStatus(1); | 260 | setBluezStatus(1); |
262 | timerEvent( 0 ); | 261 | timerEvent( 0 ); |
263 | break; | 262 | break; |
264 | case 2: | 263 | case 2: |
265 | // start bluetoothmanager | 264 | // start bluetoothmanager |
266 | launchManager(); | 265 | launchManager(); |
267 | timerEvent( 0 ); | 266 | timerEvent( 0 ); |
268 | break; | 267 | break; |
269 | case 3: | 268 | case 3: |
270 | setBluezDiscoveryStatus(0); | 269 | setBluezDiscoveryStatus(0); |
271 | timerEvent( 0 ); | 270 | timerEvent( 0 ); |
272 | break; | 271 | break; |
273 | case 4: | 272 | case 4: |
274 | setBluezDiscoveryStatus(1); | 273 | setBluezDiscoveryStatus(1); |
275 | timerEvent(0 ); | 274 | timerEvent(0 ); |
276 | break; | 275 | break; |
277 | //case 7: | 276 | //case 7: |
278 | // With table of currently-detected devices. | 277 | // With table of currently-detected devices. |
279 | } | 278 | } |
280 | 279 | ||
281 | delete signal; | 280 | delete signal; |
282 | delete menu; | 281 | delete menu; |
283 | } | 282 | } |
284 | 283 | ||
285 | 284 | ||
286 | /** | 285 | /** |
287 | * Launches the bluetooth manager | 286 | * Launches the bluetooth manager |
288 | */ | 287 | */ |
289 | void BluezApplet::launchManager() { | 288 | void BluezApplet::launchManager() { |
290 | QCopEnvelope e("QPE/System", "execute(QString)"); | 289 | QCopEnvelope e("QPE/System", "execute(QString)"); |
291 | e << QString("bluetooth-manager"); | 290 | e << QString("bluetooth-manager"); |
292 | } | 291 | } |
293 | 292 | ||
294 | /** | 293 | /** |
295 | * Refresh timer | 294 | * Refresh timer |
296 | * @param the timer event | 295 | * @param the timer event |
297 | */ | 296 | */ |
298 | void BluezApplet::timerEvent( QTimerEvent * ) { | 297 | void BluezApplet::timerEvent( QTimerEvent * ) { |
299 | bool oldactive = bluezactive; | 298 | bool oldactive = bluezactive; |
300 | int olddiscovery = bluezDiscoveryActive; | 299 | int olddiscovery = bluezDiscoveryActive; |
301 | 300 | ||
302 | bluezactive = checkBluezStatus(); | 301 | bluezactive = checkBluezStatus(); |
303 | bluezDiscoveryActive = checkBluezDiscoveryStatus(); | 302 | bluezDiscoveryActive = checkBluezDiscoveryStatus(); |
304 | 303 | ||
305 | if ((bluezactive != oldactive) || | 304 | if ((bluezactive != oldactive) || |
306 | (bluezDiscoveryActive != olddiscovery)) | 305 | (bluezDiscoveryActive != olddiscovery)) |
307 | update(); | 306 | update(); |
308 | if (bluezactive && doListDevice) { | 307 | if (bluezactive && doListDevice) { |
309 | const QByteArray arr; | 308 | const QByteArray arr; |
310 | slotMessage("listDevices()", arr); | 309 | slotMessage("listDevices()", arr); |
311 | } | 310 | } |
312 | } | 311 | } |
313 | 312 | ||
314 | /** | 313 | /** |
315 | * Implementation of the paint event | 314 | * Implementation of the paint event |
316 | * @param the QPaintEvent | 315 | * @param the QPaintEvent |
317 | */ | 316 | */ |
318 | void BluezApplet::paintEvent( QPaintEvent* ) { | 317 | void BluezApplet::paintEvent( QPaintEvent* ) { |
319 | QPainter p(this); | 318 | QPainter p(this); |
320 | odebug << "paint bluetooth pixmap" << oendl; | 319 | odebug << "paint bluetooth pixmap" << oendl; |
321 | 320 | ||
322 | if (bluezactive) { | 321 | if (bluezactive) { |
323 | #ifdef OPIE120 | 322 | #if OPIE_VERSION < 102010 |
324 | p.drawPixmap( 0, -1, bluezOnPixmap ); | 323 | p.drawPixmap( 0, -1, bluezOnPixmap ); |
325 | #else | 324 | #else |
326 | p.drawPixmap( 0, 0, bluezOnPixmap ); | 325 | p.drawPixmap( 0, 0, bluezOnPixmap ); |
327 | #endif | 326 | #endif |
328 | } else { | 327 | } else { |
329 | #ifdef OPIE120 | 328 | #if OPIE_VERSION < 102010 |
330 | p.drawPixmap( 0, -1, bluezOffPixmap ); | 329 | p.drawPixmap( 0, -1, bluezOffPixmap ); |
331 | #else | 330 | #else |
332 | p.drawPixmap( 0, 0, bluezOffPixmap ); | 331 | p.drawPixmap( 0, 0, bluezOffPixmap ); |
333 | #endif | 332 | #endif |
334 | } | 333 | } |
335 | 334 | ||
336 | if (bluezDiscoveryActive) { | 335 | if (bluezDiscoveryActive) { |
337 | p.drawPixmap( 0, 0, bluezDiscoveryOnPixmap ); | 336 | p.drawPixmap( 0, 0, bluezDiscoveryOnPixmap ); |
338 | } | 337 | } |
339 | } | 338 | } |
340 | }; | 339 | }; |
341 | 340 | ||
342 | 341 | ||
343 | EXPORT_OPIE_APPLET_v1( OpieTooth::BluezApplet ) | 342 | EXPORT_OPIE_APPLET_v1( OpieTooth::BluezApplet ) |
344 | 343 | ||