aboutsummaryrefslogtreecommitdiff
path: root/libcontextsubscriber
diff options
context:
space:
mode:
authorGergely Risko <gergely+context@risko.hu>2009-09-11 15:11:32 +0300
committerGergely Risko <gergely+context@risko.hu>2009-09-11 15:11:32 +0300
commit2a3d7a72ccad23c15856fbd0292e0014cc59602b (patch)
tree5f7c81b31c1d490411618c3651d66bdbd3664e9f /libcontextsubscriber
parent3b21c398c63c93cccf4c7ed20637f8f52a04e327 (diff)
Ooops, accidentally merged bluezinterface.{cpp,h}, which shouldn't be in the core contextkit repository.
Diffstat (limited to 'libcontextsubscriber')
-rw-r--r--libcontextsubscriber/src/Makefile.am4
-rw-r--r--libcontextsubscriber/src/bluezinterface.cpp110
-rw-r--r--libcontextsubscriber/src/bluezinterface.h63
3 files changed, 2 insertions, 175 deletions
diff --git a/libcontextsubscriber/src/Makefile.am b/libcontextsubscriber/src/Makefile.am
index 9cc161a3..051c7b92 100644
--- a/libcontextsubscriber/src/Makefile.am
+++ b/libcontextsubscriber/src/Makefile.am
@@ -11,8 +11,8 @@ libcontextsubscriber_la_SOURCES = contextproperty.cpp \
infocdbbackend.cpp infocdbbackend.h dbusnamelistener.h \
dbusnamelistener.cpp handlesignalrouter.cpp \
handlesignalrouter.h queuedinvoker.cpp queuedinvoker.h \
- loggingfeatures.h bluezinterface.h bluezinterface.cpp \
- contextkitplugin.h contextkitplugin.cpp iproviderplugin.h
+ loggingfeatures.h contextkitplugin.h contextkitplugin.cpp \
+ iproviderplugin.h
includecontextsubscriberdir=$(includedir)/contextsubscriber
includecontextsubscriber_HEADERS = contextproperty.h \
diff --git a/libcontextsubscriber/src/bluezinterface.cpp b/libcontextsubscriber/src/bluezinterface.cpp
deleted file mode 100644
index a114c844..00000000
--- a/libcontextsubscriber/src/bluezinterface.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2008 Nokia Corporation.
- *
- * Contact: Marius Vollmer <marius.vollmer@nokia.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-#include "bluezinterface.h"
-#include <QDBusObjectPath>
-#include <QDBusInterface>
-#include <QDBusError>
-#include <QDBusVariant>
-#include "logging.h"
-
-const QString BluezInterface::serviceName = "org.bluez";
-const QString BluezInterface::managerPath = "/";
-const QString BluezInterface::managerInterface = "org.bluez.Manager";
-const QString BluezInterface::adapterInterface = "org.bluez.Adapter";
-QDBusConnection BluezInterface::busConnection = QDBusConnection::systemBus();
-
-BluezInterface::BluezInterface() : manager(0), adapter(0)
-{
- busConnection.connect("org.freedesktop.DBus", "/org/freedesktop/DBus",
- "org.freedesktop.DBus", "NameOwnerChanged",
- this, SLOT(onNameOwnerChanged(QString, QString, QString)));
- properties["Powered"] = "Bluetooth.Enabled";
- properties["Discoverable"] = "Bluetooth.Visible";
- connectToBluez();
-}
-
-void BluezInterface::onNameOwnerChanged(QString name, QString /*oldOwner*/, QString newOwner)
-{
- if (name == serviceName && newOwner != "") {
- connectToBluez();
- }
-}
-
-void BluezInterface::connectToBluez()
-{
- if (adapter) {
- busConnection.disconnect(serviceName,
- adapterPath,
- adapterInterface,
- "PropertyChanged",
- this, SLOT(onPropertyChanged(QString, QDBusVariant)));
- delete adapter;
- adapter = 0;
- }
- if (manager) {
- delete manager;
- manager = 0;
- }
-
- manager = new QDBusInterface(serviceName, managerPath, managerInterface, busConnection, this);
- manager->callWithCallback("DefaultAdapter", QList<QVariant>(), this,
- SLOT(replyDefaultAdapter(QDBusObjectPath)),
- SLOT(replyDBusError(QDBusError)));
-}
-
-void BluezInterface::replyDBusError(QDBusError err)
-{
- contextWarning() << "DBus error occured:" << err.message();
-}
-
-void BluezInterface::replyDefaultAdapter(QDBusObjectPath path)
-{
- adapterPath = path.path();
- adapter = new QDBusInterface(serviceName, adapterPath, adapterInterface, busConnection, this);
- busConnection.connect(serviceName,
- path.path(),
- adapterInterface,
- "PropertyChanged",
- this, SLOT(onPropertyChanged(QString, QDBusVariant)));
- adapter->callWithCallback("GetProperties", QList<QVariant>(), this,
- SLOT(replyGetProperties(QMap<QString, QVariant>)),
- SLOT(replyDBusError(QDBusError)));
-}
-
-void BluezInterface::onPropertyChanged(QString key, QDBusVariant value)
-{
- onPropertyChanged(key, value.variant());
-}
-
-void BluezInterface::onPropertyChanged(QString key, QVariant value)
-{
- if (properties.contains(key) && values[key] != value) {
- values[key] = value;
- // TODO: emit here
- }
-}
-
-void BluezInterface::replyGetProperties(QMap<QString, QVariant> map)
-{
- foreach(QString key, map.keys())
- onPropertyChanged(key, map[key]);
-}
diff --git a/libcontextsubscriber/src/bluezinterface.h b/libcontextsubscriber/src/bluezinterface.h
deleted file mode 100644
index cbe21a91..00000000
--- a/libcontextsubscriber/src/bluezinterface.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2008 Nokia Corporation.
- *
- * Contact: Marius Vollmer <marius.vollmer@nokia.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-#ifndef BLUEZINTERFACE_H
-#define BLUEZINTERFACE_H
-
-#include <QObject>
-#include <QString>
-#include <QMap>
-#include <QDBusConnection>
-#include <QVariant>
-
-class QDBusError;
-class QDBusInterface;
-class QDBusObjectPath;
-class QDBusVariant;
-
-class BluezInterface : public QObject
-{
- Q_OBJECT
-public:
- BluezInterface();
-private slots:
- void replyDBusError(QDBusError err);
- void replyDefaultAdapter(QDBusObjectPath path);
- void replyGetProperties(QMap<QString, QVariant> map);
- void onPropertyChanged(QString key, QDBusVariant value);
- void onNameOwnerChanged(QString name, QString oldOwner, QString newOwner);
-private:
- void onPropertyChanged(QString key, QVariant value);
- void connectToBluez();
-
- QDBusInterface* manager;
- QDBusInterface* adapter;
- QString adapterPath;
- QMap<QString, QVariant> values;
- QMap<QString, QVariant> properties;
- static const QString serviceName;
- static const QString managerPath;
- static const QString managerInterface;
- static const QString adapterInterface;
- static QDBusConnection busConnection;
-};
-
-#endif