Tone Kastlunger wrote:

> I have always been suspecting Jolla using the missing BT export as
> a lock-in technique; but even switching between sfos phones (jolla 1 ->
> jolla c -> xperia x for me,
> probably a xa2 coming up soon) is impossible as it is now, so that
> (luckily) kills the theory.
> 
> I'd be glad to be able to help, a (somewhat) working sync mechanism for
> contacts & notes would
> be extremely helpful already!

I do not know about the background. I heard syncml is dead as no one of the
companies involved in establishing the protocol are interested in this
anymore. This, however, leaves us with one option less to express our
freedom of choice and even worse there is no possible way to synchronize
locally. I heard somehow that Windows/Android supposed to offer something
for local synchronization, but I have no way to test this.
My drama is that I was using N9 for 7y and it worked perfectly well ... now
I am constantly out of sync :|

>From what I see is that a lot of stuff is missing in Sailfish X that was
present in N9. From the services this is PC Suite, Obex File Transfer,
SyncML Server/Client etc.
I do not know if this is limitation by the kernel. I do not recall what was
the status of bluez5 and obex in 3.9. I do not know how obexd was compiled.

I see in the syncevolution logs following and I think something in the
background is missing - perhaps outside of buteo

>>> N9 <<<

[2019-07-10 21:41:17.880] ready to sync
[2019-07-10 21:41:17.880] starting SAN 12 auth 1B2M2Y8AsgTpgAmY7PhCfg==
nonce SyncEvolution session 1 server PC Suite
[2019-07-10 21:41:17.881] SAN datastore addressbook uri Contacts type 7 mode
206
[2019-07-10 21:41:17.881] ObexTransportAgent::wait(no reply)
[2019-07-10 21:41:17.881] ObexTransportAgent::wait(): iteration
[2019-07-10 21:41:17.881] ObexTransportAgent::wait(): iteration
...
[2019-07-10 21:41:20.777] ObexTransportAgent::wait(): iteration
[2019-07-10 21:41:20.777] Connecting Bluetooth device with address
40:98:4E:90:56:E3 and channel 25
[2019-07-10 21:41:20.936] OBEX_EV_PROGRESS
[2019-07-10 21:41:20.936] ObexTransportAgent::wait(): iteration
[2019-07-10 21:41:21.432] OBEX_EV_REQDONE
[2019-07-10 21:41:21.432] OBEX Transport: get header who from connect
response with value SYNCML-SYNC
[2019-07-10 21:41:21.432] ObexTransportAgent::wait(): is ready
[2019-07-10 21:41:21.432] Server sending SAN
...
[2019-07-10 21:41:20.777] ObexTransportAgent::wait(): iteration
[2019-07-10 21:41:20.777] Connecting Bluetooth device with address
66:55:44:33:22:11 and channel 25
[2019-07-10 21:41:20.936] OBEX_EV_PROGRESS
[2019-07-10 21:41:20.936] ObexTransportAgent::wait(): iteration
[2019-07-10 21:41:21.432] OBEX_EV_REQDONE
[2019-07-10 21:41:21.432] OBEX Transport: get header who from connect
response with value SYNCML-SYNC
[2019-07-10 21:41:21.432] ObexTransportAgent::wait(): is ready
[2019-07-10 21:41:21.432] Server sending SAN

>>> Xperia X <<<

[2019-07-09 23:25:31.041] ready to sync
[2019-07-09 23:25:31.041] starting SAN 12 auth 1B2M2Y8AsgTpgAmY7PhCfg==
nonce SyncEvolution session 1 server PC Suite
[2019-07-09 23:25:31.041] SAN datastore addressbook uri Contacts type 7 mode
206
[2019-07-09 23:25:31.041] ObexTransportAgent::wait(no reply)
[2019-07-09 23:25:31.041] ObexTransportAgent::wait(): iteration
...
[2019-07-09 23:25:35.497] ObexTransportAgent::wait(): iteration
[2019-07-09 23:25:35.497] Connecting Bluetooth device with address
11:22:33:44:55:66 and channel 25
[2019-07-09 23:25:35.655] OBEX_EV_PROGRESS
[2019-07-09 23:25:35.655] ObexTransportAgent::wait(): iteration
[2019-07-09 23:25:35.660] OBEX_EV_LINKERR
[2019-07-09 23:25:35.660] ObexTransportAgent::shutdown()
[2019-07-09 23:25:35.660] ObexTransportAgent::wait(no reply)
[2019-07-09 23:25:35.660] ObexTransportAgent::wait(): iteration
[2019-07-09 23:25:53.765] ObexTransport: exception thrown in
obex_fd_source_cb_impl

You can try the attached patch against buteo-syncfw (master before commit
081a511) and tell me what you think.
I will look forward to clean up the buteo-sync-plugins changes and hopefully
source out the access to git soon. I am afraid I got the wrong access to
bugzilla instead of git :|

Also bear with me as I am not a pro-developer.

regards



diff --git a/libbuteosyncfw/common/TransportTracker.cpp b/libbuteosyncfw/common/TransportTracker.cpp
index 35097ec..566d5dd 100644
--- a/libbuteosyncfw/common/TransportTracker.cpp
+++ b/libbuteosyncfw/common/TransportTracker.cpp
@@ -32,6 +32,8 @@
 #include <QDBusMessage>
 #include <QDBusArgument>
 
+#include <adapter.h>
+
 using namespace Buteo;
 
 TransportTracker::TransportTracker(QObject *aParent) :
@@ -65,16 +67,19 @@ TransportTracker::TransportTracker(QObject *aParent) :
 #endif
 
     // BT
-    // Set the bluetooth state
-    iTransportStates[Sync::CONNECTIVITY_BT] = btConnectivityStatus();
-    if (!iSystemBus.connect("org.bluez",
-                    "",
-                    "org.bluez.Adapter",
-                    "PropertyChanged",
-                    this,
-                    SLOT(onBtStateChanged(QString, QDBusVariant))))
+    // Initialize BluezQt
+    btManager = new BluezQt::Manager(this);
+    if (btManager != 0) {
+        BluezQt::InitManagerJob *initJob = btManager->init();
+        initJob->start();
+        connect(initJob, &BluezQt::InitManagerJob::result,
+                this, &TransportTracker::initBluez5ManagerJobResult/*,
+                Qt::QueuedConnection*/);
+        LOG_DEBUG("BT manager init started");
+    }
+    else
     {
-        LOG_WARNING("Unable to connect to system bus for org.bluez.Adapter");
+        LOG_CRITICAL("BT manager init failed");
     }
 
     // Internet
@@ -86,7 +91,8 @@ TransportTracker::TransportTracker(QObject *aParent) :
             iInternet->isOnline();
         connect(iInternet,
                 SIGNAL(statusChanged(bool, Sync::InternetConnectionType)),
-                SLOT(onInternetStateChanged(bool, Sync::InternetConnectionType)) /*, Qt::QueuedConnection*/);
+                SLOT(onInternetStateChanged(bool, Sync::InternetConnectionType)) /*,
+                 Qt::QueuedConnection*/);
     }
     else
     {
@@ -97,6 +103,7 @@ TransportTracker::TransportTracker(QObject *aParent) :
 TransportTracker::~TransportTracker()
 {
     FUNCTION_CALL_TRACE;
+
 }
 
 bool TransportTracker::isConnectivityAvailable(Sync::ConnectivityType aType) const
@@ -116,16 +123,14 @@ void TransportTracker::onUsbStateChanged(bool aConnected)
     updateState(Sync::CONNECTIVITY_USB, aConnected);
 }
 
-void TransportTracker::onBtStateChanged(QString aKey, QDBusVariant aValue)
+void TransportTracker::onBtStateChanged(bool aValue)
 {
     FUNCTION_CALL_TRACE;
 
-    if (aKey == "Powered")
-    {
-        bool btPowered = aValue.variant().toBool();
-        LOG_DEBUG("BT power state " << btPowered);
-        updateState(Sync::CONNECTIVITY_BT, btPowered);
-    }
+    LOG_DEBUG("BT state changed (sent update in 5sec):" << aValue);
+//     If BT was enabled or disabled give the framework 5sec
+//     to complete before updating the BT state
+    QTimer::singleShot(5000, this, SLOT(onBtStateChangedUpdateState()));
 }
 
 void TransportTracker::onInternetStateChanged(bool aConnected, Sync::InternetConnectionType aType)
@@ -142,13 +147,14 @@ void TransportTracker::updateState(Sync::ConnectivityType aType,
 {
     FUNCTION_CALL_TRACE;
 
-
     bool oldState = false;
     {
         QMutexLocker locker(&iMutex);
         oldState = iTransportStates[aType];
         iTransportStates[aType] = aState;
     }
+    LOG_DEBUG("Connection state old:" << oldState);
+    LOG_DEBUG("Connection state new:" << aState);
     if(oldState != aState)
     {
         if (aType != Sync::CONNECTIVITY_INTERNET)
@@ -158,57 +164,64 @@ void TransportTracker::updateState(Sync::ConnectivityType aType,
     }
 }
 
-bool TransportTracker::btConnectivityStatus()
+void TransportTracker::onBtStateChangedUpdateState()
 {
     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)
+    bool state = false;
+    if (btManager && btManager->isOperational()) {
+        BluezQt::AdapterPtr defaultAdapter = btManager->usableAdapter();
+        if (defaultAdapter)
+        {
+            state = defaultAdapter->isPowered();
+            LOG_DEBUG("BT default adapter path: " << defaultAdapter->ubi());
+            LOG_DEBUG("BT default adapter name: " << defaultAdapter->name());
+        }
+    }
+    else
     {
-        LOG_WARNING("This device does not have a BT adapter");
-        return btOn;
+            LOG_CRITICAL("BT manager is not working");
     }
+    LOG_DEBUG("BT state:" << state);
+    updateState(Sync::CONNECTIVITY_BT, state);
+}
 
-    QList<QVariant> adapterList = reply.arguments();
-    // We will take the first adapter in the list
-    QString adapterPath = qdbus_cast<QDBusObjectPath>(adapterList.at(0)).path();
+void TransportTracker::initBluez5ManagerJobResult(BluezQt::InitManagerJob* job) {
 
-    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;
-        }
+    FUNCTION_CALL_TRACE;
 
-        QDBusArgument arg = reply.arguments().at(0).value<QDBusArgument>();
-        if (arg.currentType() == QDBusArgument::MapType)
-        {
-            // Scan through the dict returned and check for "Powered" entry
-            QMap<QString,QVariant> dict = qdbus_cast<QMap<QString,QVariant> >(arg);
-            QMap<QString,QVariant>::iterator iter;
-            for(iter = dict.begin(); iter != dict.end(); ++iter)
-            {
-                if (iter.key() == "Powered")
-                {
-                    btOn = iter.value().toBool();
-                    LOG_DEBUG ("Bluetooth powered on? " << btOn);
-                    break;
-                }
-            }
-        }
+    if (job->error()) {
+        LOG_CRITICAL("BT manager init error: " << job->errorText());
+        return;
+    }
+
+    // @todo do we need this
+    Q_ASSERT(job->manager() == btManager);
+
+    // Make sure to update msyncd when bluetoothd starts
+    connect(btManager, &BluezQt::Manager::operationalChanged,
+            this, &TransportTracker::onBtStateChanged);
+    connect(btManager, &BluezQt::Manager::bluetoothOperationalChanged,
+            this, &TransportTracker::onBtStateChanged);
+    connect(btManager, &BluezQt::Manager::bluetoothBlockedChanged,
+            this, &TransportTracker::onBtStateChanged);
+
+    bool isBlocked = btManager->isBluetoothBlocked();
+    if (!btManager->isOperational() || isBlocked) {
+        if (isBlocked)
+            LOG_WARNING("BT manager started (adapter is blocked)");
+        else
+            LOG_CRITICAL("BT manager started (not operational)");
+        return;
+    }
+
+    BluezQt::AdapterPtr defaultAdapter = btManager->usableAdapter();
+    if (!defaultAdapter)
+    {
+        LOG_WARNING("BT manager initialized but no usable adapter found");
+        return;
     }
-    return btOn;
+    // Update bluetooth state
+    updateState(Sync::CONNECTIVITY_BT, defaultAdapter->isPowered());
+    LOG_DEBUG ("BT manager init done");
 }
diff --git a/libbuteosyncfw/common/TransportTracker.h b/libbuteosyncfw/common/TransportTracker.h
index f43155d..d68300a 100644
--- a/libbuteosyncfw/common/TransportTracker.h
+++ b/libbuteosyncfw/common/TransportTracker.h
@@ -31,37 +31,40 @@
 #include <QDBusVariant>
 #include <QDBusConnection>
 
-namespace Buteo {
+#include <manager.h>
+#include <initmanagerjob.h>
+
+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.
  */
-class TransportTracker : public QObject
+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:
 
@@ -70,7 +73,7 @@ signals:
      * @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
      *
@@ -89,11 +92,27 @@ signals:
 
 private slots:
 
-        void onUsbStateChanged(bool aConnected);
+    void onUsbStateChanged(bool aConnected);
 
-    void onBtStateChanged(QString aKey, QDBusVariant aValue);
+    /*! \brief Slot onBtStateChanged to update BT state
+     * \param bool aValue
+     */
+    void onBtStateChanged(bool aValue);
 
-    void onInternetStateChanged(bool aConnected, Sync::InternetConnectionType aType);
+    /*! \brief Process the result of the onInternetStateChanged signal
+     * \param bool aConnected
+     * \param Sync::InternetConnectionType aType
+     */
+    void onInternetStateChanged(bool aConnected,
+            Sync::InternetConnectionType aType);
+
+    /*! \brief Slot onBtStateChangedUpdateState to update state after 5sec
+     */
+    void onBtStateChangedUpdateState();
+
+    /*! \brief Process the result of the initBluez5ManagerJob signal
+     */
+    void initBluez5ManagerJobResult(BluezQt::InitManagerJob*/*job*/);
 
 private:
 
@@ -104,22 +123,22 @@ private:
     NetworkManager *iInternet;
     QDBusConnection iSystemBus;
 
+    BluezQt::Manager *btManager;
+
     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;
     friend class SynchronizerTest;
 #endif
 
-    bool btConnectivityStatus();
-
 };
 
 }
diff --git a/libbuteosyncfw/libbuteosyncfw.pro b/libbuteosyncfw/libbuteosyncfw.pro
index ca1422b..1814ccd 100644
--- a/libbuteosyncfw/libbuteosyncfw.pro
+++ b/libbuteosyncfw/libbuteosyncfw.pro
@@ -10,11 +10,17 @@ VER_PAT = 0
 QT += sql xml dbus network
 QT -= gui
 
+unix {
+    QT_CONFIG -= no-pkg-config
+    CONFIG += link_pkgconfig
+    PKGCONFIG += KF5BluezQt
+}
+
 CONFIG += dll \
     create_pc \
     create_prl
 
-#DEFINES += BUTEO_ENABLE_DEBUG
+DEFINES += BUTEO_ENABLE_DEBUG
 
 # Input
 HEADERS += common/Logger.h \
diff --git a/libbuteosyncfw/profile/BtHelper.cpp b/libbuteosyncfw/profile/BtHelper.cpp
index 47269a4..cedb2a4 100644
--- a/libbuteosyncfw/profile/BtHelper.cpp
+++ b/libbuteosyncfw/profile/BtHelper.cpp
@@ -24,134 +24,164 @@
 #include <LogMacros.h>
 
 #include "BtHelper.h"
+#include <initmanagerjob.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::DBUS_PROPERTIES_INTERFACE = "org.freedesktop.DBus.Properties";
+const QString BT::GETPROPERTIES = "GetAll";
 
 
 BtHelper::BtHelper(const QString& deviceAddress,
                        QObject* parent) : QObject(parent)
 {
-    m_deviceAddress         = deviceAddress;
+    m_deviceAddress = deviceAddress;
+
+    btManager = new BluezQt::Manager(this);
+    if (btManager != 0) {
+        BluezQt::InitManagerJob *initJob = btManager->init();
+        initJob->start();
+        connect(initJob, &BluezQt::InitManagerJob::result,
+                this, &BtHelper::initBluez5ManagerJobResult/*,
+                    Qt::QueuedConnection*/);
+        LOG_DEBUG("BtHelper::BtHelper manager init started");
+    }
+    else
+    {
+        LOG_CRITICAL("BtHelper::BtHelper manager start failed");
+    }
 }
 
 BtHelper::~BtHelper()
 {
-  LOG_DEBUG ("");    
+    FUNCTION_CALL_TRACE;
+    LOG_DEBUG ("BtHelper::~BtHelper()");
 }
 
+void BtHelper::initBluez5ManagerJobResult(BluezQt::InitManagerJob* job) {
+    FUNCTION_CALL_TRACE;
 
+    if (job->error()) {
+        LOG_CRITICAL("BtHelper manager init error: " << job->errorText());
+        return;
+    }
+
+    // @todo do we need notifications on operational status?
+    // Make sure to update BtHelper when bluetoothd starts
+//    connect(btManager, &BluezQt::Manager::operationalChanged,
+//            this, &BtHelper::onBtStateChanged);
+//    connect(btManager, &BluezQt::Manager::bluetoothOperationalChanged,
+//            this, &BtHelper::onBtStateChanged);
+
+    if (!btManager->isOperational() || btManager->isBluetoothBlocked()) {
+        if (btManager->isBluetoothBlocked())
+            LOG_WARNING("BtHelper manager init failed (adapter is blocked)");
+        else
+            LOG_CRITICAL("BtHelper manager init failed (not operational)");
+        return;
+    }
+
+    BluezQt::DevicePtr dev = btManager->deviceForAddress(m_deviceAddress);
+    if (!dev)
+    {
+        LOG_WARNING("BtHelper manager device query failed for addr: " << m_deviceAddress);
+        return;
+    }
+    BluezQt::AdapterPtr adapter = dev->adapter();
+    if (!adapter)
+    {
+        LOG_WARNING("BtHelper manager init done but no usable adapter found");
+        return;
+    }
+    LOG_DEBUG("BtHelper adapter path: " << adapter->ubi());
+    LOG_DEBUG("BtHelper adapter name: " << adapter->name());
+}
 
 bool BtHelper::isServiceSupported (const QList<QString>& 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;
+
+    if (!btManager->isOperational())
+    {
+        LOG_WARNING("BtHelper::isServiceSupported: manager is not working properly");
+        return false;
+    }
+    foreach (QString service, servicesList) {
+        LOG_DEBUG ("Record : "  << service);
+        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() );
+    FUNCTION_CALL_TRACE;
 
-    if( !managerInterface.isValid() ) {
-        LOG_DEBUG ("Manager interface is invalid");
-        return QString();
+    if (!btManager->isOperational())
+    {
+        LOG_WARNING("BtHelper::getDefaultAdapterPath: manager is not working properly");
+        return false;
     }
 
-    QDBusReply<QDBusObjectPath> pathReply = managerInterface.call(BT::GET_DEFAULT_ADAPTER);
-
-    if( !pathReply.isValid() ) {
-        LOG_DEBUG ("Not able to get the adapter path");
+    BluezQt::DevicePtr dev = btManager->deviceForAddress(m_deviceAddress);
+    BluezQt::AdapterPtr defaultAdapter = dev->adapter();
+    if ( ! defaultAdapter )
         return QString();
-    }
-    return pathReply.value().path();
+    
+    return defaultAdapter->ubi();
 }
 
-QString BtHelper::getDevicePath(QString &defaultAdapterPath)
+QString BtHelper::getDevicePath()
 {
-    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;
+
+    if (!btManager->isOperational())
+    {
+        LOG_WARNING("BtHelper::getDevicePath: manager is not working properly");
+        return false;
     }
 
-    QDBusReply<QDBusObjectPath> pathReply = adapterInterface.call(BT::FIND_DEVICE, m_deviceAddress );
+    BluezQt::DevicePtr dev = btManager->deviceForAddress(m_deviceAddress);
 
-    if( !pathReply.isValid() ) {
-        LOG_DEBUG ( "Not able to find the BT device");
+    if (!dev)
         return QString();
-    }
-    return pathReply.value().path();
+    return dev->ubi();
 }
 
 bool BtHelper::getServiceRecords(QList<QString>& servicesList)
 {
-    LOG_DEBUG ( "getServiceRecords()");
+    FUNCTION_CALL_TRACE;
 
-    QString defaultAdapterPath = getDefaultAdapterPath();
-    LOG_DEBUG ( "Adapter path = " << defaultAdapterPath) ;
-
-    QString devicePath = getDevicePath(defaultAdapterPath);
-    if (devicePath.isEmpty())
-	    return false;
-    LOG_DEBUG ( "Device path =" << devicePath);
-
-    QDBusInterface deviceInterface(BT::BLUEZ_DEST, devicePath,
-                                   BT::BLUEZ_DEVICE_INTERFACE,
-                                   QDBusConnection::systemBus() );
-    if( deviceInterface.isValid() == false ) {
-        LOG_DEBUG ("Device interface is not valid");
+    if (!btManager->isOperational())
+    {
+        LOG_WARNING("BtHelper::getServiceRecords: manager is not working properly");
         return false;
     }
 
-   QDBusMessage message = deviceInterface.call(BT::DISCOVERSERVICES, QString());
-   QDBusArgument reply = QDBusReply<QDBusArgument>(message).value();
-   QMap<uint, QString> mapVal;
-   reply >> mapVal;  
-   servicesList = mapVal.values();
+    BluezQt::DevicePtr dev = btManager->deviceForAddress(m_deviceAddress);
+    servicesList = dev->uuids();
+
    if (servicesList.size() > 0)
 	   return true;
    return false;
 }
 
-QMap<QString, QVariant> BtHelper::getDeviceProperties()
+QVariantMap BtHelper::getDeviceProperties()
 {
-    LOG_DEBUG ( "getDeviceProperties");
+    FUNCTION_CALL_TRACE;
 
-    QMap<QString, QVariant> mapVal;
-    QString defaultAdapterPath = getDefaultAdapterPath();
-    LOG_DEBUG ( "Adapter path = " << defaultAdapterPath) ;
+    QVariantMap mapVal;
 
-    QString devicePath = getDevicePath(defaultAdapterPath);
+    QString devicePath = getDevicePath();
     if (devicePath.isEmpty())
 	    return mapVal;
     LOG_DEBUG ( "Device path =" << devicePath);
 
     QDBusInterface deviceInterface(BT::BLUEZ_DEST, devicePath,
-                                   BT::BLUEZ_DEVICE_INTERFACE,
+                                   BT::DBUS_PROPERTIES_INTERFACE,
                                    QDBusConnection::systemBus() );
     if( deviceInterface.isValid() == false ) {
         LOG_DEBUG ("Device interface is not valid");
@@ -160,6 +190,6 @@ QMap<QString, QVariant> BtHelper::getDeviceProperties()
 
    QDBusMessage message = deviceInterface.call(BT::GETPROPERTIES);
    QDBusArgument reply = QDBusReply<QDBusArgument>(message).value();
-   reply >> mapVal;  
+   reply >> mapVal;
    return mapVal;
 }
diff --git a/libbuteosyncfw/profile/BtHelper.h b/libbuteosyncfw/profile/BtHelper.h
index 819be11..e40e538 100644
--- a/libbuteosyncfw/profile/BtHelper.h
+++ b/libbuteosyncfw/profile/BtHelper.h
@@ -28,25 +28,17 @@
 #include <QtDBus>
 #include <QMap>
 
+#include <manager.h>
+#include <adapter.h>
+#include <device.h>
+
 /*! \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
-    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;
-    /// Method name for discovering services
+    static const QString DBUS_PROPERTIES_INTERFACE;
     static const QString GETPROPERTIES;
 };
 
@@ -58,6 +50,7 @@ class BtHelper : public QObject
 
 private:
 	QString m_deviceAddress;
+    BluezQt::Manager *btManager;
 
 // Private methods
 
@@ -66,12 +59,14 @@ private:
      QString getDefaultAdapterPath();
     
      /*! \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
-       */
+     QString getDevicePath();
+
+private slots:
+     /*! \brief Process the result of the initManagerJob
+      */
+     void initBluez5ManagerJobResult(BluezQt::InitManagerJob*/*job*/);
+
 public:
     /*! \brief Constructor.
       * \param deviceAddess Bluetooth address of remote device
@@ -95,7 +90,7 @@ public:
 
     /*! \brief To find remote device BT properties.
       */
-     QMap<QString, QVariant> getDeviceProperties();
+     QVariantMap getDeviceProperties();
 };
 
 #endif // BTHELPER_H
diff --git a/msyncd/msyncd-app.pro b/msyncd/msyncd-app.pro
index a8e08ec..50d1914 100644
--- a/msyncd/msyncd-app.pro
+++ b/msyncd/msyncd-app.pro
@@ -18,7 +18,7 @@ INCLUDEPATH += . \
     ../libbuteosyncfw/profile
 
 
-PKGCONFIG += dbus-1 libsignon-qt5 accounts-qt5 Qt5SystemInfo
+PKGCONFIG += dbus-1 libsignon-qt5 accounts-qt5 Qt5SystemInfo KF5BluezQt
 LIBS += -lbuteosyncfw5
 packagesExist(qt5-boostable) {
     DEFINES += HAS_BOOSTER
diff --git a/msyncd/msyncd-lib.pro b/msyncd/msyncd-lib.pro
index 7cf681d..633e575 100644
--- a/msyncd/msyncd-lib.pro
+++ b/msyncd/msyncd-lib.pro
@@ -18,9 +18,10 @@ INCLUDEPATH += . \
     ../libbuteosyncfw/common \
     ../libbuteosyncfw/profile
 
+DEFINES += BUTEO_ENABLE_DEBUG
 
 PKGCONFIG += dbus-1 gio-2.0 libsignon-qt5 accounts-qt5 Qt5SystemInfo
-PKGCONFIG += mce-qt5
+PKGCONFIG += mce-qt5 KF5BluezQt
 LIBS += -lbuteosyncfw5
 packagesExist(qt5-boostable) {
     DEFINES += HAS_BOOSTER
diff --git a/rpm/buteo-syncfw-qt5.spec b/rpm/buteo-syncfw-qt5.spec
index 83b4f9d..1dbdf64 100644
--- a/rpm/buteo-syncfw-qt5.spec
+++ b/rpm/buteo-syncfw-qt5.spec
@@ -20,12 +20,14 @@ BuildRequires: pkgconfig(libiphb)
 BuildRequires: pkgconfig(qt5-boostable)
 BuildRequires: pkgconfig(keepalive)
 BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(KF5BluezQt)
 BuildRequires: pkgconfig(mce-qt5) >= 1.1.0
 BuildRequires: oneshot
 BuildRequires: doxygen
 Requires: mapplauncherd-qt5
 Requires: oneshot
 Requires: glib2
+Requires: kf5bluezqt-bluez5 >= 5.24
 Requires: libmce-qt5 >= 1.1.0
 %{_oneshot_requires_post}
 
diff --git a/unittests/tests/msyncdtests/TransportTrackerTest/TransportTrackerTest.cpp b/unittests/tests/msyncdtests/TransportTrackerTest/TransportTrackerTest.cpp
index 0c37b4c..7fcb221 100644
--- a/unittests/tests/msyncdtests/TransportTrackerTest/TransportTrackerTest.cpp
+++ b/unittests/tests/msyncdtests/TransportTrackerTest/TransportTrackerTest.cpp
@@ -102,7 +102,7 @@ void TransportTrackerTest :: testStateChanged()
 
     // change BT state and verify
     bool btCurrentState = iTransportTracker->isConnectivityAvailable(Sync::CONNECTIVITY_BT);
-    iTransportTracker->onBtStateChanged("Powered", QDBusVariant(QVariant(!btCurrentState)));
+    iTransportTracker->onBtStateChanged(!btCurrentState);
 
     QCOMPARE(iTransportTracker->isConnectivityAvailable(Sync::CONNECTIVITY_BT), !btCurrentState);
     QCOMPARE(connectivityStateSpy.count(), 1);
diff --git a/unittests/tests/tests_common.pri b/unittests/tests/tests_common.pri
index 35f4d11..127cd81 100644
--- a/unittests/tests/tests_common.pri
+++ b/unittests/tests/tests_common.pri
@@ -16,7 +16,7 @@ QT -= gui
 
 CONFIG += link_pkgconfig link_prl
 
-PKGCONFIG += dbus-1 Qt5SystemInfo
+PKGCONFIG += dbus-1 Qt5SystemInfo KF5BluezQt
 
 LIBS += -lgcov
 

_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org

Reply via email to