summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/applet/bluezapplet.cpp
authorkorovkin <korovkin>2006-05-14 15:38:20 (UTC)
committer korovkin <korovkin>2006-05-14 15:38:20 (UTC)
commit782a34192c2c879a80fd319153a2b2f48ded1c99 (patch) (side-by-side diff)
tree55f9d66e747876ffa2e87cf30eaafaf33864597a /noncore/net/opietooth/applet/bluezapplet.cpp
parent273ffc42b3f0ce593e0d20874a7f224328416445 (diff)
downloadopie-782a34192c2c879a80fd319153a2b2f48ded1c99.zip
opie-782a34192c2c879a80fd319153a2b2f48ded1c99.tar.gz
opie-782a34192c2c879a80fd319153a2b2f48ded1c99.tar.bz2
Script must be started after device is started up.
We should wait for 1 second after device is brought up. Fixed an error in hcicongig hci0 up.
Diffstat (limited to 'noncore/net/opietooth/applet/bluezapplet.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp
index f7774f0..127b0af 100644
--- a/noncore/net/opietooth/applet/bluezapplet.cpp
+++ b/noncore/net/opietooth/applet/bluezapplet.cpp
@@ -56,114 +56,114 @@ using namespace Opie::Core;
/* STD */
#include <device.h>
namespace OpieTooth {
BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) {
setFixedHeight( AppLnk::smallIconSize() );
setFixedWidth( AppLnk::smallIconSize() );
#if OPIE_VERSION < 102010
bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" );
bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" );
bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass.png" );
#else
bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon );
bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon );
bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon );
#endif
startTimer(2000);
btDevice = 0;
btManager = 0;
bluezactive = false;
bluezDiscoveryActive = false;
doListDevice = false;
isScanning = false;
m_wasOn = false;
+ m_sync = false;
// TODO: determine whether this channel has to be closed at destruction time.
QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this );
connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
this, SLOT(slotMessage(const QCString&,const QByteArray&) ) );
::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null");
}
BluezApplet::~BluezApplet() {
if ( btDevice ) {
+ ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null");
delete btDevice;
}
if ( btManager ) {
delete btManager;
}
}
int BluezApplet::position()
{
return 6;
}
bool BluezApplet::checkBluezStatus() {
if (btDevice) {
if (btDevice->isLoaded() ) {
odebug << "btDevice isLoaded" << oendl;
return true;
} else {
odebug << "btDevice is NOT loaded" << oendl;
return false;
}
} else {
odebug << "btDevice is ZERO" << oendl;
return false;
}
}
int BluezApplet::setBluezStatus(int c, bool sync) {
if ( c == 1 ) {
switch ( ODevice::inst()->model() ) {
case Model_iPAQ_H39xx:
btDevice = new Device( "/dev/tts/1", "bcsp", "921600" );
break;
case Model_iPAQ_H5xxx:
btDevice = new Device( "/dev/tts/1", "any", "921600" );
break;
-#ifndef OPIE120
+#if OPIE_VERSION >= 102010
case Model_MyPal_716:
btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" );
break;
#endif
default:
btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" );
break;
}
- if (sync) {
- ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null");
- } else {
- QCopEnvelope e("QPE/System", "execute(QString)");
- e << QString("/etc/init.d/bluetooth start");
- }
+ m_sync = sync;
+ connect(btDevice, SIGNAL(device(const QString&, bool)),
+ this, SLOT(slotDevice(const QString&, bool)));
+
} else {
::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null");
if ( btManager ) {
delete btManager;
btManager = 0;
}
if ( btDevice ) {
delete btDevice;
btDevice = 0;
}
}
return 0;
}
int BluezApplet::checkBluezDiscoveryStatus() {
return isScanning;
}
int BluezApplet::setBluezDiscoveryStatus(int d) {
return bluezDiscoveryActive = d;
}
// FIXME mbhaynie
// receiver for QCopChannel("QPE/Bluetooth") messages.
@@ -315,29 +315,46 @@ namespace OpieTooth {
* @param the QPaintEvent
*/
void BluezApplet::paintEvent( QPaintEvent* ) {
QPainter p(this);
odebug << "paint bluetooth pixmap" << oendl;
if (bluezactive) {
#if OPIE_VERSION < 102010
p.drawPixmap( 0, -1, bluezOnPixmap );
#else
p.drawPixmap( 0, 0, bluezOnPixmap );
#endif
} else {
#if OPIE_VERSION < 102010
p.drawPixmap( 0, -1, bluezOffPixmap );
#else
p.drawPixmap( 0, 0, bluezOffPixmap );
#endif
}
if (bluezDiscoveryActive) {
p.drawPixmap( 0, 0, bluezDiscoveryOnPixmap );
}
}
+ /**
+ * Reacts on device up
+ * @param name device name
+ * @param up if device was brought up
+ */
+ void BluezApplet::slotDevice(const QString& name, bool up)
+ {
+ if (!up)
+ return;
+ odebug << name << " is up" << oendl;
+ if (m_sync) {
+ ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null");
+ } else {
+ QCopEnvelope e("QPE/System", "execute(QString)");
+ e << QString("/etc/init.d/bluetooth start");
+ }
+ }
};
EXPORT_OPIE_APPLET_v1( OpieTooth::BluezApplet )