summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp
index c0ad246..3fdbde0 100644
--- a/noncore/net/opietooth/applet/bluezapplet.cpp
+++ b/noncore/net/opietooth/applet/bluezapplet.cpp
@@ -1,203 +1,203 @@
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; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
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#include <qapplication.h> 31#include <qapplication.h>
32 32
33#include <qpe/resource.h> 33#include <qpe/resource.h>
34#include <qpe/qcopenvelope_qws.h> 34#include <qpe/qcopenvelope_qws.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38#include <qpoint.h> 38#include <qpoint.h>
39#include <qpainter.h> 39#include <qpainter.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qframe.h> 41#include <qframe.h>
42#include <qpixmap.h> 42#include <qpixmap.h>
43#include <qstring.h> 43#include <qstring.h>
44#include <qtimer.h> 44#include <qtimer.h>
45#include <qpopupmenu.h> 45#include <qpopupmenu.h>
46 46
47#include <device.h> 47#include <device.h>
48 48
49namespace OpieTooth { 49namespace OpieTooth {
50 50
51 BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { 51 BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) {
52 setFixedHeight( 18 ); 52 setFixedHeight( 18 );
53 setFixedWidth( 14 ); 53 setFixedWidth( 14 );
54 bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); 54 bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" );
55 bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); 55 bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" );
56 // bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass" ); 56 // bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass" );
57 startTimer(5000); 57 startTimer(4000);
58 btDevice = 0; 58 btDevice = 0;
59 bluezactive = false; 59 bluezactive = false;
60 bluezDiscoveryActive = false; 60 bluezDiscoveryActive = false;
61 61
62 } 62 }
63 63
64 BluezApplet::~BluezApplet() { 64 BluezApplet::~BluezApplet() {
65 } 65 }
66 66
67 bool BluezApplet::checkBluezStatus() { 67 bool BluezApplet::checkBluezStatus() {
68 if (btDevice) { 68 if (btDevice) {
69 if (btDevice->isLoaded() ) { 69 if (btDevice->isLoaded() ) {
70 return true; 70 return true;
71 } else { 71 } else {
72 return false; 72 return false;
73 } 73 }
74 } else { 74 } else {
75 return false; 75 return false;
76 } 76 }
77 } 77 }
78 78
79 int BluezApplet::setBluezStatus(int c) { 79 int BluezApplet::setBluezStatus(int c) {
80 80
81 if (c == 1) { 81 if (c == 1) {
82 btDevice = new Device("/dev/ttySB0", "csr" ); 82 btDevice = new Device("/dev/ttySB0", "bcsp", "230400" );
83 } else { 83 } else {
84 if (btDevice) { 84 if (btDevice) {
85 delete btDevice; 85 delete btDevice;
86 btDevice = 0; 86 btDevice = 0;
87 } 87 }
88 } 88 }
89 return 0; 89 return 0;
90 } 90 }
91 91
92 int BluezApplet::checkBluezDiscoveryStatus() { 92 int BluezApplet::checkBluezDiscoveryStatus() {
93 } 93 }
94 94
95 int BluezApplet::setBluezDiscoveryStatus(int d) { 95 int BluezApplet::setBluezDiscoveryStatus(int d) {
96 } 96 }
97 97
98 void BluezApplet::mousePressEvent( QMouseEvent *) { 98 void BluezApplet::mousePressEvent( QMouseEvent *) {
99 99
100 QPopupMenu *menu = new QPopupMenu(); 100 QPopupMenu *menu = new QPopupMenu();
101 QPopupMenu *signal = new QPopupMenu(); 101 QPopupMenu *signal = new QPopupMenu();
102 int ret=0; 102 int ret=0;
103 103
104 /* Refresh active state */ 104 /* Refresh active state */
105 timerEvent( 0 ); 105 timerEvent( 0 );
106 106
107 107
108 if (bluezactive) { 108 if (bluezactive) {
109 menu->insertItem( tr("Disable Bluetooth"), 0 ); 109 menu->insertItem( tr("Disable Bluetooth"), 0 );
110 } else { 110 } else {
111 menu->insertItem( tr("Enable Bluetooth"), 1 ); 111 menu->insertItem( tr("Enable Bluetooth"), 1 );
112 } 112 }
113 113
114 menu->insertItem( tr("Launch manager"), 2 ); 114 menu->insertItem( tr("Launch manager"), 2 );
115 115
116 menu->insertSeparator(6); 116 menu->insertSeparator(6);
117 menu->insertItem( tr("Signal strength"), signal, 5); 117 menu->insertItem( tr("Signal strength"), signal, 5);
118 menu->insertSeparator(8); 118 menu->insertSeparator(8);
119 119
120 if (bluezDiscoveryActive) { 120 if (bluezDiscoveryActive) {
121 menu->insertItem( tr("Disable discovery"), 3 ); 121 menu->insertItem( tr("Disable discovery"), 3 );
122 } else { 122 } else {
123 menu->insertItem( tr("Enable discovery"), 4 ); 123 menu->insertItem( tr("Enable discovery"), 4 );
124 } 124 }
125 125
126 126
127 QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); 127 QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) );
128 ret = menu->exec(p, 0); 128 ret = menu->exec(p, 0);
129 129
130 switch(ret) { 130 switch(ret) {
131 case 0: 131 case 0:
132 setBluezStatus(0); 132 setBluezStatus(0);
133 timerEvent( 0 ); 133 timerEvent( 0 );
134 break; 134 break;
135 case 1: 135 case 1:
136 setBluezStatus(1); 136 setBluezStatus(1);
137 timerEvent( 0 ); 137 timerEvent( 0 );
138 break; 138 break;
139 case 2: 139 case 2:
140 // start bluetoothmanager 140 // start bluetoothmanager
141 launchManager(); 141 launchManager();
142 timerEvent( 0 ); 142 timerEvent( 0 );
143 break; 143 break;
144 case 3: 144 case 3:
145 setBluezDiscoveryStatus(0); 145 setBluezDiscoveryStatus(0);
146 timerEvent( 0 ); 146 timerEvent( 0 );
147 break; 147 break;
148 case 4: 148 case 4:
149 setBluezDiscoveryStatus(1); 149 setBluezDiscoveryStatus(1);
150 timerEvent(0 ); 150 timerEvent(0 );
151 break; 151 break;
152 //case 7: 152 //case 7:
153 // With table of currently-detected devices. 153 // With table of currently-detected devices.
154 } 154 }
155 155
156 delete signal; 156 delete signal;
157 delete menu; 157 delete menu;
158 } 158 }
159 159
160 160
161/** 161/**
162 * Launches the bluetooth manager 162 * Launches the bluetooth manager
163 */ 163 */
164 void BluezApplet::launchManager() { 164 void BluezApplet::launchManager() {
165 QCopEnvelope e("QPE/System", "execute(QString)"); 165 QCopEnvelope e("QPE/System", "execute(QString)");
166 e << QString("bluetooth-manager"); 166 e << QString("bluetooth-manager");
167 } 167 }
168 168
169/** 169/**
170 * Refresh timer 170 * Refresh timer
171 * @param the timer event 171 * @param the timer event
172 */ 172 */
173 void BluezApplet::timerEvent( QTimerEvent * ) { 173 void BluezApplet::timerEvent( QTimerEvent * ) {
174 bool oldactive = bluezactive; 174 bool oldactive = bluezactive;
175 int olddiscovery = bluezDiscoveryActive; 175 int olddiscovery = bluezDiscoveryActive;
176 176
177 bluezactive = checkBluezStatus(); 177 bluezactive = checkBluezStatus();
178 bluezDiscoveryActive = checkBluezDiscoveryStatus(); 178 bluezDiscoveryActive = checkBluezDiscoveryStatus();
179 179
180 if ((bluezactive != oldactive) || (bluezDiscoveryActive != olddiscovery)) { 180 if ((bluezactive != oldactive) || (bluezDiscoveryActive != olddiscovery)) {
181 update(); 181 update();
182 } 182 }
183 } 183 }
184 184
185/** 185/**
186 * Implementation of the paint event 186 * Implementation of the paint event
187 * @param the QPaintEvent 187 * @param the QPaintEvent
188 */ 188 */
189 void BluezApplet::paintEvent( QPaintEvent* ) { 189 void BluezApplet::paintEvent( QPaintEvent* ) {
190 QPainter p(this); 190 QPainter p(this);
191 qDebug("paint bluetooth pixmap"); 191 qDebug("paint bluetooth pixmap");
192 192
193 if (bluezactive > 0) { 193 if (bluezactive > 0) {
194 p.drawPixmap( 0, 1, bluezOnPixmap ); 194 p.drawPixmap( 0, 1, bluezOnPixmap );
195 } else { 195 } else {
196 p.drawPixmap( 0, 1, bluezOffPixmap ); 196 p.drawPixmap( 0, 1, bluezOffPixmap );
197 } 197 }
198 198
199 if (bluezDiscoveryActive > 0) { 199 if (bluezDiscoveryActive > 0) {
200 p.drawPixmap( 0, 1, bluezDiscoveryOnPixmap ); 200 p.drawPixmap( 0, 1, bluezDiscoveryOnPixmap );
201 } 201 }
202 } 202 }
203}; 203};