diff --git a/libbuteosyncfw/common/TransportTracker.cpp b/libbuteosyncfw/common/TransportTracker.cpp index 35097ec..800ae18 100644 --- a/libbuteosyncfw/common/TransportTracker.cpp +++ b/libbuteosyncfw/common/TransportTracker.cpp @@ -2,6 +2,7 @@ * This file is part of buteo-syncfw package * * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * 2018 Upgraded to use bluez5 by deloptes@gmail.com * * Contact: Sateesh Kavuri * @@ -38,7 +39,8 @@ TransportTracker::TransportTracker(QObject *aParent) : QObject(aParent), iUSBProxy(0), iInternet(0), - iSystemBus(QDBusConnection::systemBus()) + iSystemBus(QDBusConnection::systemBus()), + iDefaultBtAdapter(QString()) { FUNCTION_CALL_TRACE; @@ -65,18 +67,51 @@ TransportTracker::TransportTracker(QObject *aParent) : #endif // BT - // Set the bluetooth state - iTransportStates[Sync::CONNECTIVITY_BT] = btConnectivityStatus(); + // big help was found here + // https://github.com/zeenix/bluetooth-demo/blob/master/blueconnect.cpp + qDBusRegisterMetaType (); + qDBusRegisterMetaType (); + qDBusRegisterMetaType (); + + // listen for added interfaces if (!iSystemBus.connect("org.bluez", - "", - "org.bluez.Adapter", - "PropertyChanged", - this, - SLOT(onBtStateChanged(QString, QDBusVariant)))) + "/", + "org.freedesktop.DBus.ObjectManager", + "InterfacesAdded", + this, + SLOT(onInterfacesAdded(const QDBusObjectPath &, const InterfacesMap)))) { + LOG_WARNING("Failed to connect InterfacesAdded signal"); + } + + if (!iSystemBus.connect("org.bluez", + "/", + "org.freedesktop.DBus.ObjectManager", + "InterfacesRemoved", + this, + SLOT(onInterfacesRemoved(const QDBusObjectPath &, const QStringList)))) { + LOG_WARNING("Failed to connect InterfacesRemoved signal"); + } + + // get the initial state + bool btOn = btConnectivityStatus(); + if (btOn) { + if (!iSystemBus.connect("org.bluez", + iDefaultBtAdapter, + QString("org.freedesktop.DBus.Properties"), + QString("PropertiesChanged"), + this, + SLOT(onBtStateChanged(QString, QVariantMap, QStringList)))) { + LOG_WARNING("Failed to connect PropertiesChanged signal"); + } + } + else { - LOG_WARNING("Unable to connect to system bus for org.bluez.Adapter"); + LOG_WARNING("The BT adapter is powered off or missing"); } + // Set the bluetooth state + iTransportStates[Sync::CONNECTIVITY_BT] = btOn; + // Internet // @todo: enable when internet state is reported correctly. iInternet = new NetworkManager(this); @@ -116,15 +151,21 @@ void TransportTracker::onUsbStateChanged(bool aConnected) updateState(Sync::CONNECTIVITY_USB, aConnected); } -void TransportTracker::onBtStateChanged(QString aKey, QDBusVariant aValue) +void TransportTracker::onBtStateChanged(QString interface, QVariantMap changed, QStringList invalidated) { FUNCTION_CALL_TRACE; - if (aKey == "Powered") + Q_UNUSED(invalidated); + + if (interface == "org.bluez.Adapter1") { - bool btPowered = aValue.variant().toBool(); - LOG_DEBUG("BT power state " << btPowered); - updateState(Sync::CONNECTIVITY_BT, btPowered); + for (auto i = changed.begin(); i != changed.end(); ++i) { + if ( i.key() == "Powered") { + bool btOn = i.value().toBool(); + LOG_INFO("BT power state " << btOn); + updateState(Sync::CONNECTIVITY_BT, btOn); + } + } } } @@ -137,6 +178,83 @@ void TransportTracker::onInternetStateChanged(bool aConnected, Sync::InternetCon emit networkStateChanged(aConnected, aType); } +void TransportTracker::onInterfacesAdded(const QDBusObjectPath &path, + const InterfacesMap interfaces) +{ + FUNCTION_CALL_TRACE; + + for (auto i = interfaces.begin(); i != interfaces.end(); ++i) { + if (i.key() == "org.bluez.Adapter1") { + + if (!iDefaultBtAdapter.isEmpty() && path.path() != iDefaultBtAdapter) + continue; + + // If BT was enabled or dsiabled, give the framework 2sec to complete + LOG_INFO("BT state changed (sending update in 2sec)"); + QTime dieTime= QTime::currentTime().addSecs(2); + while (QTime::currentTime() < dieTime) + QCoreApplication::processEvents(QEventLoop::AllEvents, 100); + + if (iDefaultBtAdapter.isEmpty() || iDefaultBtAdapter != path.path()) { + iDefaultBtAdapter = path.path(); + LOG_DEBUG ("Using adapter path: " << iDefaultBtAdapter); + } + + QDBusInterface adapter("org.bluez", + iDefaultBtAdapter, + QString("org.bluez.Adapter1"), + iSystemBus); + + updateState(Sync::CONNECTIVITY_BT, adapter.property("Powered").toBool()); + + if (!iSystemBus.connect("org.bluez", + iDefaultBtAdapter, + QString("org.freedesktop.DBus.Properties"), + QString("PropertiesChanged"), + this, + SLOT(onBtStateChanged(QString, QVariantMap, QStringList)))) { + LOG_WARNING("Failed to connect PropertiesChanged signal"); + + } + else + LOG_DEBUG("'org.bluez.Adapter1' interface at " << iDefaultBtAdapter); + + + break; + } + } +} + +void TransportTracker::onInterfacesRemoved(const QDBusObjectPath &path, + const QStringList interfaces) +{ + FUNCTION_CALL_TRACE; + + for (auto i = interfaces.begin(); i != interfaces.end(); ++i) { + if (*i == "org.bluez.Adapter1") { + + if (path.path() != iDefaultBtAdapter) + continue; + + LOG_DEBUG("DBus adapter path: " << path.path() ); + if (!iSystemBus.disconnect("org.bluez", + path.path(), + QString("org.freedesktop.DBus.Properties"), + QString("PropertiesChanged"), + this, + SLOT(onBtStateChanged(QString, QVariantMap, QStringList)))) { + LOG_WARNING("Failed to disconnect PropertiesChanged signal"); + } + else + LOG_DEBUG("'org.bluez.Adapter1' interface removed from " << path.path()); + + iDefaultBtAdapter = QString(); + + break; + } + } +} + void TransportTracker::updateState(Sync::ConnectivityType aType, bool aState) { @@ -163,50 +281,38 @@ bool TransportTracker::btConnectivityStatus() FUNCTION_CALL_TRACE; bool btOn = false; - QDBusMessage methodCallMsg = QDBusMessage::createMethodCall("org.bluez", - "/", - "org.bluez.Manager", - "DefaultAdapter"); - QDBusMessage reply = iSystemBus.call(methodCallMsg); - if (reply.type() == QDBusMessage::ErrorMessage) - { - LOG_WARNING("This device does not have a BT adapter"); + QDBusInterface manager("org.bluez", + "/", + "org.freedesktop.DBus.ObjectManager", + iSystemBus); + + QDBusReply reply = manager.call("GetManagedObjects"); + if (!reply.isValid()) { + LOG_WARNING( "Failed to connect BT ObjectManager: " << reply.error().message() ); return btOn; } - QList adapterList = reply.arguments(); - // We will take the first adapter in the list - QString adapterPath = qdbus_cast(adapterList.at(0)).path(); + auto objects = reply.value(); + for (auto i = objects.begin(); i != objects.end(); ++i) { - if (!adapterPath.isEmpty() || !adapterPath.isNull()) - { - // Retrive the properties of the adapter and check for "Powered" key - methodCallMsg = QDBusMessage::createMethodCall("org.bluez", - adapterPath, - "org.bluez.Adapter", - "GetProperties"); - reply = iSystemBus.call(methodCallMsg); - if (reply.type() == QDBusMessage::ErrorMessage) - { - LOG_WARNING("Error in retrieving bluetooth properties"); - return btOn; - } + auto ifaces = i.value(); + for (auto j = ifaces.begin(); j != ifaces.end(); ++j) { - QDBusArgument arg = reply.arguments().at(0).value(); - if (arg.currentType() == QDBusArgument::MapType) - { - // Scan through the dict returned and check for "Powered" entry - QMap dict = qdbus_cast >(arg); - QMap::iterator iter; - for(iter = dict.begin(); iter != dict.end(); ++iter) + if (j.key() == "org.bluez.Adapter1") { - if (iter.key() == "Powered") - { - btOn = iter.value().toBool(); - LOG_DEBUG ("Bluetooth powered on? " << btOn); - break; + if (iDefaultBtAdapter.isEmpty() || iDefaultBtAdapter != i.key().path()) { + iDefaultBtAdapter = i.key().path(); + LOG_DEBUG ("Using adapter path: " << iDefaultBtAdapter); } + QDBusInterface adapter("org.bluez", + iDefaultBtAdapter, + QString("org.bluez.Adapter1"), + iSystemBus); + + btOn = adapter.property("Powered").toBool(); + + break; // use first adapter } } } diff --git a/libbuteosyncfw/common/TransportTracker.h b/libbuteosyncfw/common/TransportTracker.h index f43155d..065cbe3 100644 --- a/libbuteosyncfw/common/TransportTracker.h +++ b/libbuteosyncfw/common/TransportTracker.h @@ -31,70 +31,82 @@ #include #include +typedef QMap InterfacesMap; +typedef QList InterfacesList; +typedef QMap ObjectsMap; + +Q_DECLARE_METATYPE(InterfacesMap) +Q_DECLARE_METATYPE(InterfacesList) +Q_DECLARE_METATYPE(ObjectsMap) + namespace Buteo { class USBModedProxy; class NetworkManager; - /*! \brief Class for tracking transport states - * - * USB state is tracked with HAL, BT with Context Framework and Internet states with Buteo::NetworkManager. - */ + * + * USB state is tracked with HAL, BT with Context Framework and + * Internet states with Buteo::NetworkManager. + */ class TransportTracker : public QObject { - Q_OBJECT + Q_OBJECT public: - /*! \brief Constructor - * - * @param aParent Parent object - */ - TransportTracker(QObject *aParent = 0); + /*! \brief Constructor + * + * @param aParent Parent object + */ + TransportTracker(QObject *aParent = 0); - //! \brief Destructor - virtual ~TransportTracker(); + //! \brief Destructor + virtual ~TransportTracker(); - /*! \brief Checks the state of the given connectivity type - * - * @param aType Connectivity type - * @return True if available, false if not - */ - bool isConnectivityAvailable(Sync::ConnectivityType aType) const; + /*! \brief Checks the state of the given connectivity type + * + * @param aType Connectivity type + * @return True if available, false if not + */ + bool isConnectivityAvailable(Sync::ConnectivityType aType) const; signals: - /*! \brief Signal emitted when a connectivity state changes + /*! \brief Signal emitted when a connectivity state changes * * @param aType Connectivity type whose state has changed * @param aState New state. True if available, false if not. */ - void connectivityStateChanged(Sync::ConnectivityType aType, bool aState); + void connectivityStateChanged(Sync::ConnectivityType aType, bool aState); - /*! \brief Signal emitted when a n/w state changes + /*! \brief Signal emitted when a n/w state changes * * @param aState New state. True if available, false if not. * @param aType Connection type. The type of connetcion with the Internet. */ void networkStateChanged(bool aState, Sync::InternetConnectionType aType); - /*! \brief Signal emitted when a network session is successfully opened + /*! \brief Signal emitted when a network session is successfully opened */ void sessionConnected(); - /*! \brief Signal emitted when opening a network session fails + /*! \brief Signal emitted when opening a network session fails */ void sessionError(); private slots: - void onUsbStateChanged(bool aConnected); + void onUsbStateChanged(bool aConnected); - void onBtStateChanged(QString aKey, QDBusVariant aValue); + void onBtStateChanged(QString interface, QVariantMap changed, QStringList invalidated); void onInternetStateChanged(bool aConnected, Sync::InternetConnectionType aType); + void onInterfacesAdded(const QDBusObjectPath &path, const InterfacesMap interfaces); + + void onInterfacesRemoved(const QDBusObjectPath &path, const QStringList interfaces); + private: QMap iTransportStates; @@ -103,15 +115,16 @@ private: NetworkManager *iInternet; QDBusConnection iSystemBus; + QString iDefaultBtAdapter; mutable QMutex iMutex; - /*! \brief updates the state of the given connectivity type to input value - * - * @param aType Connectivity type - * @param aState Connectivity State - */ - void updateState(Sync::ConnectivityType aType, bool aState); + /*! \brief updates the state of the given connectivity type to input value + * + * @param aType Connectivity type + * @param aState Connectivity State + */ + void updateState(Sync::ConnectivityType aType, bool aState); #ifdef SYNCFW_UNIT_TESTS friend class TransportTrackerTest; @@ -122,6 +135,6 @@ private: }; -} +} // namespace Buteo #endif /* TRANSPORTTRACKER_H_ */ diff --git a/libbuteosyncfw/profile/BtHelper.cpp b/libbuteosyncfw/profile/BtHelper.cpp index 47269a4..ea5d987 100644 --- a/libbuteosyncfw/profile/BtHelper.cpp +++ b/libbuteosyncfw/profile/BtHelper.cpp @@ -25,141 +25,188 @@ #include "BtHelper.h" - const QString BT::BLUEZ_DEST = "org.bluez"; -const QString BT::BLUEZ_MANAGER_INTERFACE = "org.bluez.Manager"; -const QString BT::BLUEZ_ADAPTER_INTERFACE = "org.bluez.Adapter"; -const QString BT::BLUEZ_DEVICE_INTERFACE = "org.bluez.Device"; -const QString BT::GET_DEFAULT_ADAPTER = "DefaultAdapter"; -const QString BT::FIND_DEVICE = "FindDevice"; -const QString BT::DISCOVERSERVICES = "DiscoverServices"; -const QString BT::GETPROPERTIES = "GetProperties"; +const QString BT::BLUEZ_MANAGER_INTERFACE = "org.freedesktop.DBus.ObjectManager"; +const QString BT::BLUEZ_ADAPTER_INTERFACE = "org.bluez.Adapter1"; +const QString BT::BLUEZ_DEVICE_INTERFACE = "org.bluez.Device1"; +const QString BT::BLUEZ_PROPERTIES_INTERFACE = "org.freedesktop.DBus.Properties"; +const QString BT::GETMANAGEDOBJECTS = "GetManagedObjects"; +const QString BT::GETPROPERTIES = "GetAll"; + +// big help was found here +// https://github.com/zeenix/bluetooth-demo/blob/master/blueconnect.cpp + +typedef QMap InterfacesMap; +typedef QMap ObjectsMap; +Q_DECLARE_METATYPE(InterfacesMap) +Q_DECLARE_METATYPE(ObjectsMap) BtHelper::BtHelper(const QString& deviceAddress, - QObject* parent) : QObject(parent) + QObject* parent) : QObject(parent), + m_SystemBus(QDBusConnection::systemBus()), + m_AdapterPath(QString()) { + FUNCTION_CALL_TRACE; + m_deviceAddress = deviceAddress; + + qDBusRegisterMetaType (); + qDBusRegisterMetaType (); + + QDBusInterface managerInterface( BT::BLUEZ_DEST, "/", + BT::BLUEZ_MANAGER_INTERFACE, + m_SystemBus ); + + QDBusReply reply = managerInterface.call("GetManagedObjects"); + if (!reply.isValid()) { + LOG_WARNING( "Failed to connect to ObjectManager: " << reply.error().message() ); + } + else + { + auto objects = reply.value(); + for (auto i = objects.begin(); i != objects.end(); ++i) { + + auto ifaces = i.value(); + for (auto j = ifaces.begin(); j != ifaces.end(); ++j) { + + if (j.key() == BT::BLUEZ_ADAPTER_INTERFACE) + { + m_AdapterPath = i.key().path(); + LOG_DEBUG ("[BtHelper] Using adapter path:" << m_AdapterPath); + break; // use first adapter + } + } + } + } } BtHelper::~BtHelper() { - LOG_DEBUG (""); + FUNCTION_CALL_TRACE; } - - bool BtHelper::isServiceSupported (const QList& servicesList, const QString& serviceUUID) { - LOG_DEBUG ("isServiceSupported"); - foreach (QString service, servicesList) { - //LOG_DEBUG ("Record : " << service); - if (service.contains(serviceUUID)){ - LOG_DEBUG ("Service found " << serviceUUID); - return true; - } - } - return false; + FUNCTION_CALL_TRACE; + + foreach (QString service, servicesList) { + if (service.contains(serviceUUID)){ + LOG_DEBUG ("Service found " << serviceUUID); + return true; + } + } + return false; } QString BtHelper::getDefaultAdapterPath() { - LOG_DEBUG ("getDefaultAdapterPath"); - - QDBusInterface managerInterface( BT::BLUEZ_DEST, "/", - BT::BLUEZ_MANAGER_INTERFACE, - QDBusConnection::systemBus() ); - - if( !managerInterface.isValid() ) { - LOG_DEBUG ("Manager interface is invalid"); - return QString(); - } - - QDBusReply pathReply = managerInterface.call(BT::GET_DEFAULT_ADAPTER); + FUNCTION_CALL_TRACE; - if( !pathReply.isValid() ) { - LOG_DEBUG ("Not able to get the adapter path"); - return QString(); - } - return pathReply.value().path(); + return m_AdapterPath; } QString BtHelper::getDevicePath(QString &defaultAdapterPath) { - if (defaultAdapterPath.isEmpty()) { - LOG_DEBUG ( "Adapter path is empty"); - return QString(); - } - - QDBusInterface adapterInterface(BT::BLUEZ_DEST, defaultAdapterPath, - BT::BLUEZ_ADAPTER_INTERFACE, QDBusConnection::systemBus() ); - if( !adapterInterface.isValid() ) { - LOG_DEBUG ( "Adapter interface is invalid"); - return QString(); - } + FUNCTION_CALL_TRACE; + //In bluez5 ObjectManager is used to get the device + Q_UNUSED(defaultAdapterPath); - QDBusReply pathReply = adapterInterface.call(BT::FIND_DEVICE, m_deviceAddress ); + QDBusInterface managerInterface( BT::BLUEZ_DEST, "/", + BT::BLUEZ_MANAGER_INTERFACE, + m_SystemBus ); - if( !pathReply.isValid() ) { - LOG_DEBUG ( "Not able to find the BT device"); + QDBusReply reply = managerInterface.call("GetManagedObjects"); + if (!reply.isValid()) { + LOG_WARNING( "Failed to connect to ObjectManager: " << reply.error().message() ); return QString(); } - return pathReply.value().path(); + + auto objects = reply.value(); + for (auto i = objects.begin(); i != objects.end(); ++i) { + + auto ifaces = i.value(); + for (auto j = ifaces.begin(); j != ifaces.end(); ++j) { + if (j.key() == BT::BLUEZ_DEVICE_INTERFACE) + { + QString path = i.key().path(); + LOG_DEBUG ( "Object path:" << path ); + QDBusInterface dev(BT::BLUEZ_DEST, + path, + BT::BLUEZ_DEVICE_INTERFACE, + m_SystemBus); + bool connected = dev.property("Connected").toBool(); + if(connected) + { + LOG_DEBUG ( "[BtHelper]Device connected" << dev.property("Address")); + return path; + } + } + } + } + + LOG_DEBUG ( "[BtHelper]Not able to find the BT device"); + return QString(); } bool BtHelper::getServiceRecords(QList& servicesList) { - LOG_DEBUG ( "getServiceRecords()"); - - QString defaultAdapterPath = getDefaultAdapterPath(); - LOG_DEBUG ( "Adapter path = " << defaultAdapterPath) ; + FUNCTION_CALL_TRACE; - QString devicePath = getDevicePath(defaultAdapterPath); + QString adapterPath = getDefaultAdapterPath(); + if (adapterPath.isEmpty()) + return false; + QString devicePath = getDevicePath(adapterPath); if (devicePath.isEmpty()) - return false; + return false; LOG_DEBUG ( "Device path =" << devicePath); - QDBusInterface deviceInterface(BT::BLUEZ_DEST, devicePath, - BT::BLUEZ_DEVICE_INTERFACE, - QDBusConnection::systemBus() ); - if( deviceInterface.isValid() == false ) { + QDBusInterface deviceInterface(BT::BLUEZ_DEST, + devicePath, + BT::BLUEZ_DEVICE_INTERFACE, + m_SystemBus); + if(!deviceInterface.isValid()) { LOG_DEBUG ("Device interface is not valid"); return false; } + servicesList = deviceInterface.property("UUIDs").toStringList(); - QDBusMessage message = deviceInterface.call(BT::DISCOVERSERVICES, QString()); - QDBusArgument reply = QDBusReply(message).value(); - QMap mapVal; - reply >> mapVal; - servicesList = mapVal.values(); - if (servicesList.size() > 0) - return true; - return false; + if (servicesList.size() > 0) + return true; + return false; } QMap BtHelper::getDeviceProperties() { - LOG_DEBUG ( "getDeviceProperties"); + FUNCTION_CALL_TRACE; QMap mapVal; - QString defaultAdapterPath = getDefaultAdapterPath(); - LOG_DEBUG ( "Adapter path = " << defaultAdapterPath) ; - QString devicePath = getDevicePath(defaultAdapterPath); + QString adapterPath = getDefaultAdapterPath(); + if (adapterPath.isEmpty()) + return mapVal; + + QString devicePath = getDevicePath(adapterPath); if (devicePath.isEmpty()) - return mapVal; - LOG_DEBUG ( "Device path =" << devicePath); + return mapVal; - QDBusInterface deviceInterface(BT::BLUEZ_DEST, devicePath, - BT::BLUEZ_DEVICE_INTERFACE, - QDBusConnection::systemBus() ); - if( deviceInterface.isValid() == false ) { + QDBusInterface deviceInterface(BT::BLUEZ_DEST, + devicePath, + BT::BLUEZ_PROPERTIES_INTERFACE, + m_SystemBus ); + if(!deviceInterface.isValid()) { LOG_DEBUG ("Device interface is not valid"); return mapVal; } - QDBusMessage message = deviceInterface.call(BT::GETPROPERTIES); - QDBusArgument reply = QDBusReply(message).value(); - reply >> mapVal; - return mapVal; + QDBusReply > reply = + deviceInterface.call(BT::GETPROPERTIES, BT::BLUEZ_DEVICE_INTERFACE); + if (!reply.isValid()) { + LOG_WARNING( "Failed to get device properties: " << reply.error().message() ); + return mapVal; + } + + mapVal = reply.value(); + + return mapVal; } diff --git a/libbuteosyncfw/profile/BtHelper.h b/libbuteosyncfw/profile/BtHelper.h index 819be11..68c7aab 100644 --- a/libbuteosyncfw/profile/BtHelper.h +++ b/libbuteosyncfw/profile/BtHelper.h @@ -28,24 +28,23 @@ #include #include -/*! \brief Strings used for DBus communication with bluetooth daemon are grouped using this structure. +/*! \brief Strings used for DBus communication with bluetooth + * daemon are grouped using this structure. */ struct BT { /// Destination for Dbus command to bluez static const QString BLUEZ_DEST; - /// Bluez manager interface name + /// DBus object manager interface name static const QString BLUEZ_MANAGER_INTERFACE; /// Bluez adapter interface name static const QString BLUEZ_ADAPTER_INTERFACE; /// Bluez Device interface name static const QString BLUEZ_DEVICE_INTERFACE; - /// Method name for retrieving default adapter - static const QString GET_DEFAULT_ADAPTER; - /// Method name for finding the device - static const QString FIND_DEVICE; - /// Method name for discovering services - static const QString DISCOVERSERVICES; + /// DBus properties interface name + static const QString BLUEZ_PROPERTIES_INTERFACE; + /// Method name for discovering the managed object + static const QString GETMANAGEDOBJECTS; /// Method name for discovering services static const QString GETPROPERTIES; }; @@ -58,6 +57,8 @@ class BtHelper : public QObject private: QString m_deviceAddress; + QDBusConnection m_SystemBus; + QString m_AdapterPath; // Private methods @@ -65,23 +66,21 @@ private: */ QString getDefaultAdapterPath(); - /*! \brief Fetches the device path + /*! \brief Fetches the device path * \param defaultAdapterPath Default adapter path */ QString getDevicePath(QString& defaultAdapterPath); - /* \brief Open the serial port and get file descriptor for the port. - * \return File descriptor if opening port was success, otherwise -1 - */ + public: /*! \brief Constructor. * \param deviceAddess Bluetooth address of remote device * \param parent Parent object */ - BtHelper(const QString& deviceAddess, QObject* parent = 0); + BtHelper(const QString& deviceAddess, QObject* parent = 0); /*! \brief Destructor */ - ~BtHelper(); + ~BtHelper(); /*! \brief Fetch the bluetooth services supported by remote device. * \param servicesList outparam which will be populated with the services. diff --git a/unittests/tests/msyncdtests/TransportTrackerTest/TransportTrackerTest.cpp b/unittests/tests/msyncdtests/TransportTrackerTest/TransportTrackerTest.cpp index 0c37b4c..a671c4f 100644 --- a/unittests/tests/msyncdtests/TransportTrackerTest/TransportTrackerTest.cpp +++ b/unittests/tests/msyncdtests/TransportTrackerTest/TransportTrackerTest.cpp @@ -102,7 +102,12 @@ void TransportTrackerTest :: testStateChanged() // change BT state and verify bool btCurrentState = iTransportTracker->isConnectivityAvailable(Sync::CONNECTIVITY_BT); - iTransportTracker->onBtStateChanged("Powered", QDBusVariant(QVariant(!btCurrentState))); + + QVariantMap map; + QStringList list; + map["Powered"] = QVariant(!btCurrentState); + list << "Powered"; + iTransportTracker->onBtStateChanged("org.bluez.Adapter1", map, list); QCOMPARE(iTransportTracker->isConnectivityAvailable(Sync::CONNECTIVITY_BT), !btCurrentState); QCOMPARE(connectivityStateSpy.count(), 1);