Diffstat (limited to 'noncore/net/opietooth/applet/bluezapplet.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp index a1d64a4..32560a1 100644 --- a/noncore/net/opietooth/applet/bluezapplet.cpp +++ b/noncore/net/opietooth/applet/bluezapplet.cpp | |||
@@ -61,22 +61,26 @@ namespace OpieTooth { | |||
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 | bluezReceiveOnPixmap = Resource::loadPixmap( "bluetoothapplet/receive.png" ); | ||
67 | #else | 68 | #else |
68 | bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon ); | 69 | bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon ); |
69 | bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon ); | 70 | bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon ); |
70 | bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon ); | 71 | bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon ); |
72 | bluezReceiveOnPixmap = )Resource::loadImage( "bluetoothapplet/bluezonreceive", Opie::Core::OResource::SmallIcon ); | ||
71 | #endif | 73 | #endif |
72 | startTimer(2000); | 74 | startTimer(2000); |
73 | btDevice = 0; | 75 | btDevice = 0; |
74 | btManager = 0; | 76 | btManager = 0; |
75 | bluezactive = false; | 77 | bluezactive = false; |
76 | bluezDiscoveryActive = false; | 78 | bluezDiscoveryActive = false; |
79 | bluezReceiveActive = false; | ||
80 | bluezReceiveChanged = false; | ||
77 | doListDevice = false; | 81 | doListDevice = false; |
78 | isScanning = false; | 82 | isScanning = false; |
79 | m_wasOn = false; | 83 | m_wasOn = false; |
80 | m_sync = false; | 84 | m_sync = false; |
81 | 85 | ||
82 | // TODO: determine whether this channel has to be closed at destruction time. | 86 | // TODO: determine whether this channel has to be closed at destruction time. |
@@ -131,13 +135,12 @@ namespace OpieTooth { | |||
131 | 135 | ||
132 | #if OPIE_VERSION >= 102010 | 136 | #if OPIE_VERSION >= 102010 |
133 | case Model_MyPal_716: | 137 | case Model_MyPal_716: |
134 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); | 138 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); |
135 | break; | 139 | break; |
136 | #endif | 140 | #endif |
137 | |||
138 | case Model_iPAQ_H22xx: | 141 | case Model_iPAQ_H22xx: |
139 | btDevice = new Device( "/dev/tts/3", "any", "921600" ); | 142 | btDevice = new Device( "/dev/tts/3", "any", "921600" ); |
140 | break; | 143 | break; |
141 | 144 | ||
142 | default: | 145 | default: |
143 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); | 146 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); |
@@ -145,12 +148,13 @@ namespace OpieTooth { | |||
145 | } | 148 | } |
146 | m_sync = sync; | 149 | m_sync = sync; |
147 | connect(btDevice, SIGNAL(device(const QString&, bool)), | 150 | connect(btDevice, SIGNAL(device(const QString&, bool)), |
148 | this, SLOT(slotDevice(const QString&, bool))); | 151 | this, SLOT(slotDevice(const QString&, bool))); |
149 | 152 | ||
150 | } else { | 153 | } else { |
154 | setObexRecieveStatus(0); | ||
151 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 155 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
152 | if ( btManager ) { | 156 | if ( btManager ) { |
153 | delete btManager; | 157 | delete btManager; |
154 | btManager = 0; | 158 | btManager = 0; |
155 | } | 159 | } |
156 | if ( btDevice ) { | 160 | if ( btDevice ) { |
@@ -166,12 +170,22 @@ namespace OpieTooth { | |||
166 | } | 170 | } |
167 | 171 | ||
168 | int BluezApplet::setBluezDiscoveryStatus(int d) { | 172 | int BluezApplet::setBluezDiscoveryStatus(int d) { |
169 | return bluezDiscoveryActive = d; | 173 | return bluezDiscoveryActive = d; |
170 | } | 174 | } |
171 | 175 | ||
176 | int BluezApplet::setObexRecieveStatus(int d) { | ||
177 | { | ||
178 | QCopEnvelope e ( "QPE/Obex", "btreceive(int)" ); | ||
179 | e << ( d ? 1 : 0 ); | ||
180 | } | ||
181 | bluezReceiveActive = (bool)(d != 0); | ||
182 | bluezReceiveChanged = true; | ||
183 | return d; | ||
184 | } | ||
185 | |||
172 | // FIXME mbhaynie | 186 | // FIXME mbhaynie |
173 | // receiver for QCopChannel("QPE/Bluetooth") messages. | 187 | // receiver for QCopChannel("QPE/Bluetooth") messages. |
174 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) | 188 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) |
175 | { | 189 | { |
176 | if ( str == "enableBluetooth()") { | 190 | if ( str == "enableBluetooth()") { |
177 | m_wasOn = checkBluezStatus(); | 191 | m_wasOn = checkBluezStatus(); |
@@ -241,18 +255,19 @@ namespace OpieTooth { | |||
241 | menu->insertItem( tr("Launch manager"), 2 ); | 255 | menu->insertItem( tr("Launch manager"), 2 ); |
242 | 256 | ||
243 | menu->insertSeparator(6); | 257 | menu->insertSeparator(6); |
244 | //menu->insertItem( tr("Signal strength"), signal, 5); | 258 | //menu->insertItem( tr("Signal strength"), signal, 5); |
245 | //menu->insertSeparator(8); | 259 | //menu->insertSeparator(8); |
246 | 260 | ||
247 | if (bluezDiscoveryActive) { | 261 | if (bluezactive) { |
248 | menu->insertItem( tr("Disable discovery"), 3 ); | 262 | if (bluezReceiveActive) { |
263 | menu->insertItem( tr("Disable receive"), 3 ); | ||
249 | } else { | 264 | } else { |
250 | menu->insertItem( tr("Enable discovery"), 4 ); | 265 | menu->insertItem( tr("Enable receive"), 4 ); |
266 | } | ||
251 | } | 267 | } |
252 | |||
253 | 268 | ||
254 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); | 269 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); |
255 | ret = menu->exec(p, 0); | 270 | ret = menu->exec(p, 0); |
256 | menu->hide(); | 271 | menu->hide(); |
257 | 272 | ||
258 | switch(ret) { | 273 | switch(ret) { |
@@ -267,17 +282,17 @@ namespace OpieTooth { | |||
267 | case 2: | 282 | case 2: |
268 | // start bluetoothmanager | 283 | // start bluetoothmanager |
269 | launchManager(); | 284 | launchManager(); |
270 | timerEvent( 0 ); | 285 | timerEvent( 0 ); |
271 | break; | 286 | break; |
272 | case 3: | 287 | case 3: |
273 | setBluezDiscoveryStatus(0); | 288 | setObexRecieveStatus(0); |
274 | timerEvent( 0 ); | 289 | timerEvent( 0 ); |
275 | break; | 290 | break; |
276 | case 4: | 291 | case 4: |
277 | setBluezDiscoveryStatus(1); | 292 | setObexRecieveStatus(1); |
278 | timerEvent(0 ); | 293 | timerEvent(0 ); |
279 | break; | 294 | break; |
280 | //case 7: | 295 | //case 7: |
281 | // With table of currently-detected devices. | 296 | // With table of currently-detected devices. |
282 | } | 297 | } |
283 | 298 | ||
@@ -303,18 +318,21 @@ namespace OpieTooth { | |||
303 | int olddiscovery = bluezDiscoveryActive; | 318 | int olddiscovery = bluezDiscoveryActive; |
304 | 319 | ||
305 | bluezactive = checkBluezStatus(); | 320 | bluezactive = checkBluezStatus(); |
306 | bluezDiscoveryActive = checkBluezDiscoveryStatus(); | 321 | bluezDiscoveryActive = checkBluezDiscoveryStatus(); |
307 | 322 | ||
308 | if ((bluezactive != oldactive) || | 323 | if ((bluezactive != oldactive) || |
309 | (bluezDiscoveryActive != olddiscovery)) | 324 | (bluezDiscoveryActive != olddiscovery) || |
325 | bluezReceiveChanged) | ||
310 | update(); | 326 | update(); |
311 | if (bluezactive && doListDevice) { | 327 | if (bluezactive && doListDevice) { |
312 | const QByteArray arr; | 328 | const QByteArray arr; |
313 | slotMessage("listDevices()", arr); | 329 | slotMessage("listDevices()", arr); |
314 | } | 330 | } |
331 | if (bluezReceiveChanged) | ||
332 | bluezReceiveChanged = false; | ||
315 | } | 333 | } |
316 | 334 | ||
317 | /** | 335 | /** |
318 | * Implementation of the paint event | 336 | * Implementation of the paint event |
319 | * @param the QPaintEvent | 337 | * @param the QPaintEvent |
320 | */ | 338 | */ |
@@ -336,13 +354,17 @@ namespace OpieTooth { | |||
336 | #endif | 354 | #endif |
337 | } | 355 | } |
338 | 356 | ||
339 | if (bluezDiscoveryActive) { | 357 | if (bluezDiscoveryActive) { |
340 | p.drawPixmap( 0, 0, bluezDiscoveryOnPixmap ); | 358 | p.drawPixmap( 0, 0, bluezDiscoveryOnPixmap ); |
341 | } | 359 | } |
360 | if (bluezReceiveActive) { | ||
361 | p.drawPixmap( 0, 0, bluezReceiveOnPixmap ); | ||
342 | } | 362 | } |
363 | } | ||
364 | |||
343 | /** | 365 | /** |
344 | * Reacts on device up | 366 | * Reacts on device up |
345 | * @param name device name | 367 | * @param name device name |
346 | * @param up if device was brought up | 368 | * @param up if device was brought up |
347 | */ | 369 | */ |
348 | void BluezApplet::slotDevice(const QString& name, bool up) | 370 | void BluezApplet::slotDevice(const QString& name, bool up) |