summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.cpp51
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.h5
2 files changed, 56 insertions, 0 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp
index 8925803..48698b6 100644
--- a/noncore/net/opietooth/applet/bluezapplet.cpp
+++ b/noncore/net/opietooth/applet/bluezapplet.cpp
@@ -65,2 +65,3 @@ namespace OpieTooth {
btDevice = 0;
+ btManager = 0;
bluezactive = false;
@@ -68,2 +69,6 @@ namespace OpieTooth {
+ // 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&) ) );
}
@@ -74,2 +79,5 @@ namespace OpieTooth {
}
+ if ( btManager ) {
+ delete btManager;
+ }
}
@@ -120,2 +128,3 @@ int BluezApplet::position()
int BluezApplet::checkBluezDiscoveryStatus() {
+ return bluezDiscoveryActive;
}
@@ -123,2 +132,44 @@ int BluezApplet::position()
int BluezApplet::setBluezDiscoveryStatus(int d) {
+ return bluezDiscoveryActive=d;
+ }
+
+ // FIXME mbhaynie
+ // receiver for QCopChannel("QPE/Bluetooth") messages.
+ void BluezApplet::slotMessage( const QCString& str, const QByteArray& )
+ {
+ if ( str == "enableBluetooth()") {
+ if (!checkBluezStatus()) {
+ setBluezStatus(1);
+ }
+ } else if ( str == "disableBluetooth()") {
+ if (checkBluezStatus()) {
+ // setBluezStatus(0);
+ }
+ } else if ( str == "listDevices()") {
+ if (!btManager)
+ {
+ btManager = new Manager("hci0");
+ connect( btManager, SIGNAL( foundDevices(const QString&,RemoteDevice::ValueList) ),
+ this, SLOT( fillList(const QString&,RemoteDevice::ValueList) ) ) ;
+ }
+
+ btManager->searchDevices();
+ }
+ }
+
+ // Once the hcitool scan is complete, report back.
+ void BluezApplet::fillList(const QString&, RemoteDevice::ValueList deviceList)
+ {
+ QCopEnvelope e("QPE/BluetoothBack", "devices(QStringMap)");
+
+ QStringList list;
+ QMap<QString, QString> btmap;
+
+ RemoteDevice::ValueList::Iterator it;
+ for( it = deviceList.begin(); it != deviceList.end(); ++it )
+ {
+ btmap[(*it).name()] = (*it).mac();
+ }
+
+ e << btmap;
}
diff --git a/noncore/net/opietooth/applet/bluezapplet.h b/noncore/net/opietooth/applet/bluezapplet.h
index a394e38..3b99c0f 100644
--- a/noncore/net/opietooth/applet/bluezapplet.h
+++ b/noncore/net/opietooth/applet/bluezapplet.h
@@ -34,2 +34,3 @@
#include <qtimer.h>
+#include <manager.h>
@@ -48,2 +49,4 @@ namespace OpieTooth {
public slots:
+ void fillList( const QString& device, RemoteDevice::ValueList list );
+
private:
@@ -59,2 +62,3 @@ public slots:
Device* btDevice;
+ Manager *btManager;
QPixmap bluezOnPixmap;
@@ -66,2 +70,3 @@ public slots:
private slots:
+ void slotMessage( const QCString& , const QByteArray& );