summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2006-06-01 11:25:38 (UTC)
committer mickeyl <mickeyl>2006-06-01 11:25:38 (UTC)
commit4ec617a0fa1c44f5527ae7eff176cf8451d9973c (patch) (unidiff)
treecdb30283f8b09c2a8fa7448614ec4e3ae3e16529
parentb8da33d26189ae36814335e77bef05203df4e2b2 (diff)
downloadopie-4ec617a0fa1c44f5527ae7eff176cf8451d9973c.zip
opie-4ec617a0fa1c44f5527ae7eff176cf8451d9973c.tar.gz
opie-4ec617a0fa1c44f5527ae7eff176cf8451d9973c.tar.bz2
add support for ipaq 2200
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 127b0af..a1d64a4 100644
--- a/noncore/net/opietooth/applet/bluezapplet.cpp
+++ b/noncore/net/opietooth/applet/bluezapplet.cpp
@@ -42,192 +42,196 @@
42using namespace Opie::Core; 42using 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
59namespace OpieTooth { 59namespace 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 {