Diffstat (limited to 'noncore/net/opietooth/applet/bluezapplet.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 31 |
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 @@ -78,4 +78,5 @@ namespace OpieTooth { isScanning = false; m_wasOn = false; + m_sync = false; // TODO: determine whether this channel has to be closed at destruction time. @@ -88,4 +89,5 @@ namespace OpieTooth { BluezApplet::~BluezApplet() { if ( btDevice ) { + ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); delete btDevice; } @@ -128,5 +130,5 @@ namespace OpieTooth { break; -#ifndef OPIE120 +#if OPIE_VERSION >= 102010 case Model_MyPal_716: btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); @@ -138,10 +140,8 @@ namespace OpieTooth { 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"); @@ -337,4 +337,21 @@ namespace OpieTooth { } } + /** + * 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"); + } + } }; |