-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 31 | ||||
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.h | 8 |
2 files changed, 32 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 @@ -79,2 +79,3 @@ namespace OpieTooth { m_wasOn = false; + m_sync = false; @@ -89,2 +90,3 @@ namespace OpieTooth { if ( btDevice ) { + ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); delete btDevice; @@ -129,3 +131,3 @@ namespace OpieTooth { -#ifndef OPIE120 +#if OPIE_VERSION >= 102010 case Model_MyPal_716: @@ -139,8 +141,6 @@ namespace OpieTooth { } - 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 { @@ -338,2 +338,19 @@ 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"); + } + } }; diff --git a/noncore/net/opietooth/applet/bluezapplet.h b/noncore/net/opietooth/applet/bluezapplet.h index 1937934..b79ed5b 100644 --- a/noncore/net/opietooth/applet/bluezapplet.h +++ b/noncore/net/opietooth/applet/bluezapplet.h @@ -72,2 +72,4 @@ public slots: bool m_wasOn; //If BT was started by menu? + protected: + bool m_sync; //If we have to bring BT synchronously @@ -75,2 +77,8 @@ private slots: void slotMessage( const QCString& , const QByteArray& ); + /** + * Reacts on device up + * @param name device name + * @param up if device was brought up + */ + void slotDevice(const QString&, bool); }; |