summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/applet/bluezapplet.cpp
Unidiff
Diffstat (limited to 'noncore/net/opietooth/applet/bluezapplet.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.cpp9
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
@@ -14,75 +14,74 @@
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>
41using namespace Opie::Core; 42using 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
60namespace OpieTooth { 59namespace 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
@@ -299,46 +298,46 @@ namespace OpieTooth {
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
343EXPORT_OPIE_APPLET_v1( OpieTooth::BluezApplet ) 342EXPORT_OPIE_APPLET_v1( OpieTooth::BluezApplet )
344 343