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