summaryrefslogtreecommitdiff
Unidiff
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 {
65 btDevice = 0; 65 btDevice = 0;
66 btManager = 0;
66 bluezactive = false; 67 bluezactive = false;
@@ -68,2 +69,6 @@ namespace OpieTooth {
68 69
70 // TODO: determine whether this channel has to be closed at destruction time.
71 QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this );
72 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
73 this, SLOT(slotMessage(const QCString&,const QByteArray&) ) );
69 } 74 }
@@ -74,2 +79,5 @@ namespace OpieTooth {
74 } 79 }
80 if ( btManager ) {
81 delete btManager;
82 }
75 } 83 }
@@ -120,2 +128,3 @@ int BluezApplet::position()
120 int BluezApplet::checkBluezDiscoveryStatus() { 128 int BluezApplet::checkBluezDiscoveryStatus() {
129 return bluezDiscoveryActive;
121 } 130 }
@@ -123,2 +132,44 @@ int BluezApplet::position()
123 int BluezApplet::setBluezDiscoveryStatus(int d) { 132 int BluezApplet::setBluezDiscoveryStatus(int d) {
133 return bluezDiscoveryActive=d;
134 }
135
136 // FIXME mbhaynie
137 // receiver for QCopChannel("QPE/Bluetooth") messages.
138 void BluezApplet::slotMessage( const QCString& str, const QByteArray& )
139 {
140 if ( str == "enableBluetooth()") {
141 if (!checkBluezStatus()) {
142 setBluezStatus(1);
143 }
144 } else if ( str == "disableBluetooth()") {
145 if (checkBluezStatus()) {
146 // setBluezStatus(0);
147 }
148 } else if ( str == "listDevices()") {
149 if (!btManager)
150 {
151 btManager = new Manager("hci0");
152 connect( btManager, SIGNAL( foundDevices(const QString&,RemoteDevice::ValueList) ),
153 this, SLOT( fillList(const QString&,RemoteDevice::ValueList) ) ) ;
154 }
155
156 btManager->searchDevices();
157 }
158 }
159
160 // Once the hcitool scan is complete, report back.
161 void BluezApplet::fillList(const QString&, RemoteDevice::ValueList deviceList)
162 {
163 QCopEnvelope e("QPE/BluetoothBack", "devices(QStringMap)");
164
165 QStringList list;
166 QMap<QString, QString> btmap;
167
168 RemoteDevice::ValueList::Iterator it;
169 for( it = deviceList.begin(); it != deviceList.end(); ++it )
170 {
171 btmap[(*it).name()] = (*it).mac();
172 }
173
174 e << btmap;
124 } 175 }
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 @@
34#include <qtimer.h> 34#include <qtimer.h>
35#include <manager.h>
35 36
@@ -48,2 +49,4 @@ namespace OpieTooth {
48public slots: 49public slots:
50 void fillList( const QString& device, RemoteDevice::ValueList list );
51
49 private: 52 private:
@@ -59,2 +62,3 @@ public slots:
59 Device* btDevice; 62 Device* btDevice;
63 Manager *btManager;
60 QPixmap bluezOnPixmap; 64 QPixmap bluezOnPixmap;
@@ -66,2 +70,3 @@ public slots:
66private slots: 70private slots:
71 void slotMessage( const QCString& , const QByteArray& );
67 72