summaryrefslogtreecommitdiff
authorzecke <zecke>2005-11-02 20:11:29 (UTC)
committer zecke <zecke>2005-11-02 20:11:29 (UTC)
commit18d6f344e4656e7f77497d345f1480cecd4d2f31 (patch) (unidiff)
treebf9771459177e2835e1047a6178f11b420bed9e5
parent562ff5c89ae1da92172a086afc8c3ffb7eec23bd (diff)
downloadopie-18d6f344e4656e7f77497d345f1480cecd4d2f31.zip
opie-18d6f344e4656e7f77497d345f1480cecd4d2f31.tar.gz
opie-18d6f344e4656e7f77497d345f1480cecd4d2f31.tar.bz2
Opie Bluetooth Applet:
Start hciattach with the right commands for the Asus MyPal. Patch is courtsey Pawel Kolodziejski
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 e1c2341..5676e4f 100644
--- a/noncore/net/opietooth/applet/bluezapplet.cpp
+++ b/noncore/net/opietooth/applet/bluezapplet.cpp
@@ -19,192 +19,196 @@
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 <qpe/applnk.h> 37#include <qpe/applnk.h>
38#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
39#include <qpe/config.h> 39#include <qpe/config.h>
40using namespace Opie::Core; 40using namespace Opie::Core;
41 41
42/* QT */ 42/* QT */
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qpoint.h> 44#include <qpoint.h>
45#include <qpainter.h> 45#include <qpainter.h>
46#include <qlayout.h> 46#include <qlayout.h>
47#include <qframe.h> 47#include <qframe.h>
48#include <qpixmap.h> 48#include <qpixmap.h>
49#include <qstring.h> 49#include <qstring.h>
50#include <qtimer.h> 50#include <qtimer.h>
51#include <qpopupmenu.h> 51#include <qpopupmenu.h>
52 52
53/* STD */ 53/* STD */
54#include <device.h> 54#include <device.h>
55 55
56namespace OpieTooth { 56namespace OpieTooth {
57 57
58 BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { 58 BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) {
59 setFixedHeight( AppLnk::smallIconSize() ); 59 setFixedHeight( AppLnk::smallIconSize() );
60 setFixedWidth( AppLnk::smallIconSize() ); 60 setFixedWidth( AppLnk::smallIconSize() );
61 bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon ); 61 bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon );
62 bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon ); 62 bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon );
63 bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon ); 63 bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon );
64 startTimer(4000); 64 startTimer(4000);
65 btDevice = 0; 65 btDevice = 0;
66 btManager = 0; 66 btManager = 0;
67 bluezactive = false; 67 bluezactive = false;
68 bluezDiscoveryActive = false; 68 bluezDiscoveryActive = false;
69 69
70 // TODO: determine whether this channel has to be closed at destruction time. 70 // TODO: determine whether this channel has to be closed at destruction time.
71 QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this ); 71 QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this );
72 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), 72 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
73 this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); 73 this, SLOT(slotMessage(const QCString&,const QByteArray&) ) );
74 } 74 }
75 75
76 BluezApplet::~BluezApplet() { 76 BluezApplet::~BluezApplet() {
77 if ( btDevice ) { 77 if ( btDevice ) {
78 delete btDevice; 78 delete btDevice;
79 } 79 }
80 if ( btManager ) { 80 if ( btManager ) {
81 delete btManager; 81 delete btManager;
82 } 82 }
83 } 83 }
84 84
85int BluezApplet::position() 85int BluezApplet::position()
86{ 86{
87 return 6; 87 return 6;
88} 88}
89 89
90 90
91 bool BluezApplet::checkBluezStatus() { 91 bool BluezApplet::checkBluezStatus() {
92 if (btDevice) { 92 if (btDevice) {
93 if (btDevice->isLoaded() ) { 93 if (btDevice->isLoaded() ) {
94 return true; 94 return true;
95 } else { 95 } else {
96 return false; 96 return false;
97 } 97 }
98 } else { 98 } else {
99 return false; 99 return false;
100 } 100 }
101 } 101 }
102 102
103 int BluezApplet::setBluezStatus(int c) { 103 int BluezApplet::setBluezStatus(int c) {
104 104
105 if ( c == 1 ) { 105 if ( c == 1 ) {
106 switch ( ODevice::inst()->model() ) { 106 switch ( ODevice::inst()->model() ) {
107 case Model_iPAQ_H39xx: 107 case Model_iPAQ_H39xx:
108 btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); 108 btDevice = new Device( "/dev/tts/1", "bcsp", "921600" );
109 break; 109 break;
110 110
111 case Model_iPAQ_H5xxx: 111 case Model_iPAQ_H5xxx:
112 btDevice = new Device( "/dev/tts/1", "any", "921600" ); 112 btDevice = new Device( "/dev/tts/1", "any", "921600" );
113 break; 113 break;
114 114
115 case Model_MyPal_716:
116 btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" );
117 break;
118
115 default: 119 default:
116 btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); 120 btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" );
117 break; 121 break;
118 } 122 }
119 } else { 123 } else {
120 if ( btDevice ) { 124 if ( btDevice ) {
121 delete btDevice; 125 delete btDevice;
122 btDevice = 0; 126 btDevice = 0;
123 } 127 }
124 } 128 }
125 return 0; 129 return 0;
126 } 130 }
127 131
128 int BluezApplet::checkBluezDiscoveryStatus() { 132 int BluezApplet::checkBluezDiscoveryStatus() {
129 return bluezDiscoveryActive; 133 return bluezDiscoveryActive;
130 } 134 }
131 135
132 int BluezApplet::setBluezDiscoveryStatus(int d) { 136 int BluezApplet::setBluezDiscoveryStatus(int d) {
133 return bluezDiscoveryActive=d; 137 return bluezDiscoveryActive=d;
134 } 138 }
135 139
136 // FIXME mbhaynie 140 // FIXME mbhaynie
137 // receiver for QCopChannel("QPE/Bluetooth") messages. 141 // receiver for QCopChannel("QPE/Bluetooth") messages.
138 void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) 142 void BluezApplet::slotMessage( const QCString& str, const QByteArray& )
139 { 143 {
140 if ( str == "enableBluetooth()") { 144 if ( str == "enableBluetooth()") {
141 if (!checkBluezStatus()) { 145 if (!checkBluezStatus()) {
142 setBluezStatus(1); 146 setBluezStatus(1);
143 } 147 }
144 } else if ( str == "disableBluetooth()") { 148 } else if ( str == "disableBluetooth()") {
145 if (checkBluezStatus()) { 149 if (checkBluezStatus()) {
146 // setBluezStatus(0); 150 // setBluezStatus(0);
147 } 151 }
148 } else if ( str == "listDevices()") { 152 } else if ( str == "listDevices()") {
149 if (!btManager) 153 if (!btManager)
150 { 154 {
151 btManager = new Manager("hci0"); 155 btManager = new Manager("hci0");
152 connect( btManager, SIGNAL( foundDevices(const QString&,RemoteDevice::ValueList) ), 156 connect( btManager, SIGNAL( foundDevices(const QString&,RemoteDevice::ValueList) ),
153 this, SLOT( fillList(const QString&,RemoteDevice::ValueList) ) ) ; 157 this, SLOT( fillList(const QString&,RemoteDevice::ValueList) ) ) ;
154 } 158 }
155 159
156 btManager->searchDevices(); 160 btManager->searchDevices();
157 } 161 }
158 } 162 }
159 163
160 // Once the hcitool scan is complete, report back. 164 // Once the hcitool scan is complete, report back.
161 void BluezApplet::fillList(const QString&, RemoteDevice::ValueList deviceList) 165 void BluezApplet::fillList(const QString&, RemoteDevice::ValueList deviceList)
162 { 166 {
163 QCopEnvelope e("QPE/BluetoothBack", "devices(QStringMap)"); 167 QCopEnvelope e("QPE/BluetoothBack", "devices(QStringMap)");
164 168
165 QStringList list; 169 QStringList list;
166 QMap<QString, QString> btmap; 170 QMap<QString, QString> btmap;
167 171
168 RemoteDevice::ValueList::Iterator it; 172 RemoteDevice::ValueList::Iterator it;
169 for( it = deviceList.begin(); it != deviceList.end(); ++it ) 173 for( it = deviceList.begin(); it != deviceList.end(); ++it )
170 { 174 {
171 btmap[(*it).name()] = (*it).mac(); 175 btmap[(*it).name()] = (*it).mac();
172 } 176 }
173 177
174 e << btmap; 178 e << btmap;
175 } 179 }
176 180
177 void BluezApplet::mousePressEvent( QMouseEvent *) { 181 void BluezApplet::mousePressEvent( QMouseEvent *) {
178 182
179 QPopupMenu *menu = new QPopupMenu(); 183 QPopupMenu *menu = new QPopupMenu();
180 QPopupMenu *signal = new QPopupMenu(); 184 QPopupMenu *signal = new QPopupMenu();
181 int ret=0; 185 int ret=0;
182 186
183 /* Refresh active state */ 187 /* Refresh active state */
184 timerEvent( 0 ); 188 timerEvent( 0 );
185 189
186 190
187 if (bluezactive) { 191 if (bluezactive) {
188 menu->insertItem( tr("Disable Bluetooth"), 0 ); 192 menu->insertItem( tr("Disable Bluetooth"), 0 );
189 } else { 193 } else {
190 menu->insertItem( tr("Enable Bluetooth"), 1 ); 194 menu->insertItem( tr("Enable Bluetooth"), 1 );
191 } 195 }
192 196
193 menu->insertItem( tr("Launch manager"), 2 ); 197 menu->insertItem( tr("Launch manager"), 2 );
194 198
195 menu->insertSeparator(6); 199 menu->insertSeparator(6);
196 //menu->insertItem( tr("Signal strength"), signal, 5); 200 //menu->insertItem( tr("Signal strength"), signal, 5);
197 //menu->insertSeparator(8); 201 //menu->insertSeparator(8);
198 202
199 if (bluezDiscoveryActive) { 203 if (bluezDiscoveryActive) {
200 menu->insertItem( tr("Disable discovery"), 3 ); 204 menu->insertItem( tr("Disable discovery"), 3 );
201 } else { 205 } else {
202 menu->insertItem( tr("Enable discovery"), 4 ); 206 menu->insertItem( tr("Enable discovery"), 4 );
203 } 207 }
204 208
205 209
206 QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); 210 QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) );
207 ret = menu->exec(p, 0); 211 ret = menu->exec(p, 0);
208 212
209 switch(ret) { 213 switch(ret) {
210 case 0: 214 case 0: