-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 127b0af..a1d64a4 100644 --- a/noncore/net/opietooth/applet/bluezapplet.cpp +++ b/noncore/net/opietooth/applet/bluezapplet.cpp | |||
@@ -1,360 +1,364 @@ | |||
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 | #else | 67 | #else |
68 | bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon ); | 68 | bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon ); |
69 | bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon ); | 69 | bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon ); |
70 | bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon ); | 70 | bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon ); |
71 | #endif | 71 | #endif |
72 | startTimer(2000); | 72 | startTimer(2000); |
73 | btDevice = 0; | 73 | btDevice = 0; |
74 | btManager = 0; | 74 | btManager = 0; |
75 | bluezactive = false; | 75 | bluezactive = false; |
76 | bluezDiscoveryActive = false; | 76 | bluezDiscoveryActive = false; |
77 | doListDevice = false; | 77 | doListDevice = false; |
78 | isScanning = false; | 78 | isScanning = false; |
79 | m_wasOn = false; | 79 | m_wasOn = false; |
80 | m_sync = false; | 80 | m_sync = false; |
81 | 81 | ||
82 | // TODO: determine whether this channel has to be closed at destruction time. | 82 | // TODO: determine whether this channel has to be closed at destruction time. |
83 | QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this ); | 83 | QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this ); |
84 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 84 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
85 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); | 85 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); |
86 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 86 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
87 | } | 87 | } |
88 | 88 | ||
89 | BluezApplet::~BluezApplet() { | 89 | BluezApplet::~BluezApplet() { |
90 | if ( btDevice ) { | 90 | if ( btDevice ) { |
91 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 91 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
92 | delete btDevice; | 92 | delete btDevice; |
93 | } | 93 | } |
94 | if ( btManager ) { | 94 | if ( btManager ) { |
95 | delete btManager; | 95 | delete btManager; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | int BluezApplet::position() | 99 | int BluezApplet::position() |
100 | { | 100 | { |
101 | return 6; | 101 | return 6; |
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | bool BluezApplet::checkBluezStatus() { | 105 | bool BluezApplet::checkBluezStatus() { |
106 | if (btDevice) { | 106 | if (btDevice) { |
107 | if (btDevice->isLoaded() ) { | 107 | if (btDevice->isLoaded() ) { |
108 | odebug << "btDevice isLoaded" << oendl; | 108 | odebug << "btDevice isLoaded" << oendl; |
109 | return true; | 109 | return true; |
110 | } else { | 110 | } else { |
111 | odebug << "btDevice is NOT loaded" << oendl; | 111 | odebug << "btDevice is NOT loaded" << oendl; |
112 | return false; | 112 | return false; |
113 | } | 113 | } |
114 | } else { | 114 | } else { |
115 | odebug << "btDevice is ZERO" << oendl; | 115 | odebug << "btDevice is ZERO" << oendl; |
116 | return false; | 116 | return false; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | int BluezApplet::setBluezStatus(int c, bool sync) { | 120 | int BluezApplet::setBluezStatus(int c, bool sync) { |
121 | 121 | ||
122 | if ( c == 1 ) { | 122 | if ( c == 1 ) { |
123 | switch ( ODevice::inst()->model() ) { | 123 | switch ( ODevice::inst()->model() ) { |
124 | case Model_iPAQ_H39xx: | 124 | case Model_iPAQ_H39xx: |
125 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); | 125 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); |
126 | break; | 126 | break; |
127 | 127 | ||
128 | case Model_iPAQ_H5xxx: | 128 | case Model_iPAQ_H5xxx: |
129 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); | 129 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); |
130 | break; | 130 | break; |
131 | 131 | ||
132 | #if OPIE_VERSION >= 102010 | 132 | #if OPIE_VERSION >= 102010 |
133 | case Model_MyPal_716: | 133 | case Model_MyPal_716: |
134 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); | 134 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); |
135 | break; | 135 | break; |
136 | #endif | 136 | #endif |
137 | 137 | ||
138 | case Model_iPAQ_H22xx: | ||
139 | btDevice = new Device( "/dev/tts/3", "any", "921600" ); | ||
140 | break; | ||
141 | |||
138 | default: | 142 | default: |
139 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); | 143 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); |
140 | break; | 144 | break; |
141 | } | 145 | } |
142 | m_sync = sync; | 146 | m_sync = sync; |
143 | connect(btDevice, SIGNAL(device(const QString&, bool)), | 147 | connect(btDevice, SIGNAL(device(const QString&, bool)), |
144 | this, SLOT(slotDevice(const QString&, bool))); | 148 | this, SLOT(slotDevice(const QString&, bool))); |
145 | 149 | ||
146 | } else { | 150 | } else { |
147 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 151 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
148 | if ( btManager ) { | 152 | if ( btManager ) { |
149 | delete btManager; | 153 | delete btManager; |
150 | btManager = 0; | 154 | btManager = 0; |
151 | } | 155 | } |
152 | if ( btDevice ) { | 156 | if ( btDevice ) { |
153 | delete btDevice; | 157 | delete btDevice; |
154 | btDevice = 0; | 158 | btDevice = 0; |
155 | } | 159 | } |
156 | } | 160 | } |
157 | return 0; | 161 | return 0; |
158 | } | 162 | } |
159 | 163 | ||
160 | int BluezApplet::checkBluezDiscoveryStatus() { | 164 | int BluezApplet::checkBluezDiscoveryStatus() { |
161 | return isScanning; | 165 | return isScanning; |
162 | } | 166 | } |
163 | 167 | ||
164 | int BluezApplet::setBluezDiscoveryStatus(int d) { | 168 | int BluezApplet::setBluezDiscoveryStatus(int d) { |
165 | return bluezDiscoveryActive = d; | 169 | return bluezDiscoveryActive = d; |
166 | } | 170 | } |
167 | 171 | ||
168 | // FIXME mbhaynie | 172 | // FIXME mbhaynie |
169 | // receiver for QCopChannel("QPE/Bluetooth") messages. | 173 | // receiver for QCopChannel("QPE/Bluetooth") messages. |
170 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) | 174 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) |
171 | { | 175 | { |
172 | if ( str == "enableBluetooth()") { | 176 | if ( str == "enableBluetooth()") { |
173 | m_wasOn = checkBluezStatus(); | 177 | m_wasOn = checkBluezStatus(); |
174 | if (!m_wasOn) { | 178 | if (!m_wasOn) { |
175 | setBluezStatus(1, true); | 179 | setBluezStatus(1, true); |
176 | sleep(2); | 180 | sleep(2); |
177 | } | 181 | } |
178 | } | 182 | } |
179 | else if ( str == "disableBluetooth()") { | 183 | else if ( str == "disableBluetooth()") { |
180 | /* | 184 | /* |
181 | * We can down BT only if it was started by qcop. We don't want | 185 | * We can down BT only if it was started by qcop. We don't want |
182 | * to down BT started from menu an break our networking connection | 186 | * to down BT started from menu an break our networking connection |
183 | */ | 187 | */ |
184 | if (checkBluezStatus() && !m_wasOn) | 188 | if (checkBluezStatus() && !m_wasOn) |
185 | setBluezStatus(0); | 189 | setBluezStatus(0); |
186 | doListDevice = false; | 190 | doListDevice = false; |
187 | } | 191 | } |
188 | else if ( str == "listDevices()") { | 192 | else if ( str == "listDevices()") { |
189 | if (checkBluezStatus()) { | 193 | if (checkBluezStatus()) { |
190 | doListDevice = false; | 194 | doListDevice = false; |
191 | timerEvent(0); | 195 | timerEvent(0); |
192 | if (!btManager) { | 196 | if (!btManager) { |
193 | btManager = new Manager("hci0"); | 197 | btManager = new Manager("hci0"); |
194 | connect( btManager, | 198 | connect( btManager, |
195 | SIGNAL( foundDevices(const QString&, RemoteDevice::ValueList) ), | 199 | SIGNAL( foundDevices(const QString&, RemoteDevice::ValueList) ), |
196 | this, SLOT( fillList(const QString&, RemoteDevice::ValueList) ) ) ; | 200 | this, SLOT( fillList(const QString&, RemoteDevice::ValueList) ) ) ; |
197 | } | 201 | } |
198 | btManager->searchDevices(); | 202 | btManager->searchDevices(); |
199 | isScanning = true; | 203 | isScanning = true; |
200 | } else | 204 | } else |
201 | doListDevice = true; | 205 | doListDevice = true; |
202 | } | 206 | } |
203 | } | 207 | } |
204 | 208 | ||
205 | // Once the hcitool scan is complete, report back. | 209 | // Once the hcitool scan is complete, report back. |
206 | void BluezApplet::fillList(const QString&, RemoteDevice::ValueList deviceList) | 210 | void BluezApplet::fillList(const QString&, RemoteDevice::ValueList deviceList) |
207 | { | 211 | { |
208 | QCopEnvelope e("QPE/BluetoothBack", "devices(QStringMap)"); | 212 | QCopEnvelope e("QPE/BluetoothBack", "devices(QStringMap)"); |
209 | 213 | ||
210 | QMap<QString, QString> btmap; | 214 | QMap<QString, QString> btmap; |
211 | 215 | ||
212 | RemoteDevice::ValueList::Iterator it; | 216 | RemoteDevice::ValueList::Iterator it; |
213 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) | 217 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) |
214 | btmap[(*it).name()] = (*it).mac(); | 218 | btmap[(*it).name()] = (*it).mac(); |
215 | 219 | ||
216 | e << btmap; | 220 | e << btmap; |
217 | isScanning = false; | 221 | isScanning = false; |
218 | timerEvent( 0 ); | 222 | timerEvent( 0 ); |
219 | } | 223 | } |
220 | 224 | ||
221 | void BluezApplet::mousePressEvent( QMouseEvent *) { | 225 | void BluezApplet::mousePressEvent( QMouseEvent *) { |
222 | 226 | ||
223 | QPopupMenu *menu = new QPopupMenu(); | 227 | QPopupMenu *menu = new QPopupMenu(); |
224 | QPopupMenu *signal = new QPopupMenu(); | 228 | QPopupMenu *signal = new QPopupMenu(); |
225 | int ret=0; | 229 | int ret=0; |
226 | 230 | ||
227 | /* Refresh active state */ | 231 | /* Refresh active state */ |
228 | timerEvent( 0 ); | 232 | timerEvent( 0 ); |
229 | 233 | ||
230 | 234 | ||
231 | if (bluezactive) { | 235 | if (bluezactive) { |
232 | menu->insertItem( tr("Disable Bluetooth"), 0 ); | 236 | menu->insertItem( tr("Disable Bluetooth"), 0 ); |
233 | } else { | 237 | } else { |
234 | menu->insertItem( tr("Enable Bluetooth"), 1 ); | 238 | menu->insertItem( tr("Enable Bluetooth"), 1 ); |
235 | } | 239 | } |
236 | 240 | ||
237 | menu->insertItem( tr("Launch manager"), 2 ); | 241 | menu->insertItem( tr("Launch manager"), 2 ); |
238 | 242 | ||
239 | menu->insertSeparator(6); | 243 | menu->insertSeparator(6); |
240 | //menu->insertItem( tr("Signal strength"), signal, 5); | 244 | //menu->insertItem( tr("Signal strength"), signal, 5); |
241 | //menu->insertSeparator(8); | 245 | //menu->insertSeparator(8); |
242 | 246 | ||
243 | if (bluezDiscoveryActive) { | 247 | if (bluezDiscoveryActive) { |
244 | menu->insertItem( tr("Disable discovery"), 3 ); | 248 | menu->insertItem( tr("Disable discovery"), 3 ); |
245 | } else { | 249 | } else { |
246 | menu->insertItem( tr("Enable discovery"), 4 ); | 250 | menu->insertItem( tr("Enable discovery"), 4 ); |
247 | } | 251 | } |
248 | 252 | ||
249 | 253 | ||
250 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); | 254 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); |
251 | ret = menu->exec(p, 0); | 255 | ret = menu->exec(p, 0); |
252 | menu->hide(); | 256 | menu->hide(); |
253 | 257 | ||
254 | switch(ret) { | 258 | switch(ret) { |
255 | case 0: | 259 | case 0: |
256 | setBluezStatus(0); | 260 | setBluezStatus(0); |
257 | timerEvent( 0 ); | 261 | timerEvent( 0 ); |
258 | break; | 262 | break; |
259 | case 1: | 263 | case 1: |
260 | setBluezStatus(1); | 264 | setBluezStatus(1); |
261 | timerEvent( 0 ); | 265 | timerEvent( 0 ); |
262 | break; | 266 | break; |
263 | case 2: | 267 | case 2: |
264 | // start bluetoothmanager | 268 | // start bluetoothmanager |
265 | launchManager(); | 269 | launchManager(); |
266 | timerEvent( 0 ); | 270 | timerEvent( 0 ); |
267 | break; | 271 | break; |
268 | case 3: | 272 | case 3: |
269 | setBluezDiscoveryStatus(0); | 273 | setBluezDiscoveryStatus(0); |
270 | timerEvent( 0 ); | 274 | timerEvent( 0 ); |
271 | break; | 275 | break; |
272 | case 4: | 276 | case 4: |
273 | setBluezDiscoveryStatus(1); | 277 | setBluezDiscoveryStatus(1); |
274 | timerEvent(0 ); | 278 | timerEvent(0 ); |
275 | break; | 279 | break; |
276 | //case 7: | 280 | //case 7: |
277 | // With table of currently-detected devices. | 281 | // With table of currently-detected devices. |
278 | } | 282 | } |
279 | 283 | ||
280 | delete signal; | 284 | delete signal; |
281 | delete menu; | 285 | delete menu; |
282 | } | 286 | } |
283 | 287 | ||
284 | 288 | ||
285 | /** | 289 | /** |
286 | * Launches the bluetooth manager | 290 | * Launches the bluetooth manager |
287 | */ | 291 | */ |
288 | void BluezApplet::launchManager() { | 292 | void BluezApplet::launchManager() { |
289 | QCopEnvelope e("QPE/System", "execute(QString)"); | 293 | QCopEnvelope e("QPE/System", "execute(QString)"); |
290 | e << QString("bluetooth-manager"); | 294 | e << QString("bluetooth-manager"); |
291 | } | 295 | } |
292 | 296 | ||
293 | /** | 297 | /** |
294 | * Refresh timer | 298 | * Refresh timer |
295 | * @param the timer event | 299 | * @param the timer event |
296 | */ | 300 | */ |
297 | void BluezApplet::timerEvent( QTimerEvent * ) { | 301 | void BluezApplet::timerEvent( QTimerEvent * ) { |
298 | bool oldactive = bluezactive; | 302 | bool oldactive = bluezactive; |
299 | int olddiscovery = bluezDiscoveryActive; | 303 | int olddiscovery = bluezDiscoveryActive; |
300 | 304 | ||
301 | bluezactive = checkBluezStatus(); | 305 | bluezactive = checkBluezStatus(); |
302 | bluezDiscoveryActive = checkBluezDiscoveryStatus(); | 306 | bluezDiscoveryActive = checkBluezDiscoveryStatus(); |
303 | 307 | ||
304 | if ((bluezactive != oldactive) || | 308 | if ((bluezactive != oldactive) || |
305 | (bluezDiscoveryActive != olddiscovery)) | 309 | (bluezDiscoveryActive != olddiscovery)) |
306 | update(); | 310 | update(); |
307 | if (bluezactive && doListDevice) { | 311 | if (bluezactive && doListDevice) { |
308 | const QByteArray arr; | 312 | const QByteArray arr; |
309 | slotMessage("listDevices()", arr); | 313 | slotMessage("listDevices()", arr); |
310 | } | 314 | } |
311 | } | 315 | } |
312 | 316 | ||
313 | /** | 317 | /** |
314 | * Implementation of the paint event | 318 | * Implementation of the paint event |
315 | * @param the QPaintEvent | 319 | * @param the QPaintEvent |
316 | */ | 320 | */ |
317 | void BluezApplet::paintEvent( QPaintEvent* ) { | 321 | void BluezApplet::paintEvent( QPaintEvent* ) { |
318 | QPainter p(this); | 322 | QPainter p(this); |
319 | odebug << "paint bluetooth pixmap" << oendl; | 323 | odebug << "paint bluetooth pixmap" << oendl; |
320 | 324 | ||
321 | if (bluezactive) { | 325 | if (bluezactive) { |
322 | #if OPIE_VERSION < 102010 | 326 | #if OPIE_VERSION < 102010 |
323 | p.drawPixmap( 0, -1, bluezOnPixmap ); | 327 | p.drawPixmap( 0, -1, bluezOnPixmap ); |
324 | #else | 328 | #else |
325 | p.drawPixmap( 0, 0, bluezOnPixmap ); | 329 | p.drawPixmap( 0, 0, bluezOnPixmap ); |
326 | #endif | 330 | #endif |
327 | } else { | 331 | } else { |
328 | #if OPIE_VERSION < 102010 | 332 | #if OPIE_VERSION < 102010 |
329 | p.drawPixmap( 0, -1, bluezOffPixmap ); | 333 | p.drawPixmap( 0, -1, bluezOffPixmap ); |
330 | #else | 334 | #else |
331 | p.drawPixmap( 0, 0, bluezOffPixmap ); | 335 | p.drawPixmap( 0, 0, bluezOffPixmap ); |
332 | #endif | 336 | #endif |
333 | } | 337 | } |
334 | 338 | ||
335 | if (bluezDiscoveryActive) { | 339 | if (bluezDiscoveryActive) { |
336 | p.drawPixmap( 0, 0, bluezDiscoveryOnPixmap ); | 340 | p.drawPixmap( 0, 0, bluezDiscoveryOnPixmap ); |
337 | } | 341 | } |
338 | } | 342 | } |
339 | /** | 343 | /** |
340 | * Reacts on device up | 344 | * Reacts on device up |
341 | * @param name device name | 345 | * @param name device name |
342 | * @param up if device was brought up | 346 | * @param up if device was brought up |
343 | */ | 347 | */ |
344 | void BluezApplet::slotDevice(const QString& name, bool up) | 348 | void BluezApplet::slotDevice(const QString& name, bool up) |
345 | { | 349 | { |
346 | if (!up) | 350 | if (!up) |
347 | return; | 351 | return; |
348 | odebug << name << " is up" << oendl; | 352 | odebug << name << " is up" << oendl; |
349 | if (m_sync) { | 353 | if (m_sync) { |
350 | ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null"); | 354 | ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null"); |
351 | } else { | 355 | } else { |
352 | QCopEnvelope e("QPE/System", "execute(QString)"); | 356 | QCopEnvelope e("QPE/System", "execute(QString)"); |
353 | e << QString("/etc/init.d/bluetooth start"); | 357 | e << QString("/etc/init.d/bluetooth start"); |
354 | } | 358 | } |
355 | } | 359 | } |
356 | }; | 360 | }; |
357 | 361 | ||
358 | 362 | ||
359 | EXPORT_OPIE_APPLET_v1( OpieTooth::BluezApplet ) | 363 | EXPORT_OPIE_APPLET_v1( OpieTooth::BluezApplet ) |
360 | 364 | ||