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