2019-12-22 07:49:55 +00:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
|
2019-12-22 07:49:55 +00:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2019-12-22 07:49:55 +00:00
|
|
|
*/
|
|
|
|
|
2015-08-21 17:38:54 +01:00
|
|
|
#include "responsewaiter.h"
|
2014-01-28 22:22:59 +00:00
|
|
|
|
|
|
|
#include <QDBusPendingCall>
|
|
|
|
#include <QDBusPendingReply>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
Build kdeconnect on sailfish and port some simple plugins
Summary:
Below is a lost of the commits, but, in summary
Port the build system for Sailfish, which means selectively building only the bits we need/can, and only against the KF5 libs that are available.
Allow to build on Qt 5.6
Switch from knotification to nemo notification (not complete!)
Add a very simple example sailfish app.
Note, there is still much missing functionality. Notifications dont work, pairing sort of works but not really, but when it is paired you can send a ping to the desktop client
Dont build kio for Sailfish
Port core build system
Port daemon buld system
Require CoreAddons on Sailfish
Port plugins build for sailfish and include the ping plugin for now
Final build changes for sailfish.
Disable tests and other not needed parts
Add includes for QCA
Fix build errors on sailfish
Get core/ to build on sailfish
Get interfaces/ to build on sailfish
Build daemon on sailfish
On sailfish, dont install the kcm file
Start port plugin to sailfish
Fixup installed files
Add sfos app
Hack declarative plugin to give a public interface
Build sfos app
Compile declarativeplugin into the sfos app for now
Redefine qAsConst for qt 5.6
Packaging fixes
Use official icon
Package .desktop
Reviewers: #kde_connect, apol, nicolasfella, albertvaka
Reviewed By: #kde_connect, apol, nicolasfella, albertvaka
Subscribers: kdeconnect, andyholmes, albertvaka, kossebau, mtijink, vonreth, apol, #kde_connect, nicolasfella
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D10703
2018-08-02 20:10:59 +01:00
|
|
|
//In older Qt released, qAsConst isnt available
|
|
|
|
#include "core/qtcompat_p.h"
|
|
|
|
|
2014-01-28 22:22:59 +00:00
|
|
|
Q_DECLARE_METATYPE(QDBusPendingReply<>)
|
|
|
|
Q_DECLARE_METATYPE(QDBusPendingReply<QVariant>)
|
|
|
|
Q_DECLARE_METATYPE(QDBusPendingReply<bool>)
|
|
|
|
Q_DECLARE_METATYPE(QDBusPendingReply<int>)
|
|
|
|
Q_DECLARE_METATYPE(QDBusPendingReply<QString>)
|
|
|
|
|
2015-09-08 09:46:59 +01:00
|
|
|
DBusResponseWaiter* DBusResponseWaiter::m_instance = nullptr;
|
2014-01-31 10:06:21 +00:00
|
|
|
|
|
|
|
DBusResponseWaiter* DBusResponseWaiter::instance()
|
|
|
|
{
|
|
|
|
if (!m_instance)
|
|
|
|
{
|
|
|
|
m_instance = new DBusResponseWaiter();
|
|
|
|
}
|
|
|
|
return m_instance;
|
|
|
|
}
|
|
|
|
|
2014-01-28 22:22:59 +00:00
|
|
|
DBusResponseWaiter::DBusResponseWaiter()
|
|
|
|
: QObject()
|
|
|
|
{
|
|
|
|
m_registered
|
|
|
|
<< qRegisterMetaType<QDBusPendingReply<> >("QDBusPendingReply<>")
|
|
|
|
<< qRegisterMetaType<QDBusPendingReply<QVariant> >("QDBusPendingReply<QVariant>")
|
|
|
|
<< qRegisterMetaType<QDBusPendingReply<bool> >("QDBusPendingReply<bool>")
|
Build kdeconnect on sailfish and port some simple plugins
Summary:
Below is a lost of the commits, but, in summary
Port the build system for Sailfish, which means selectively building only the bits we need/can, and only against the KF5 libs that are available.
Allow to build on Qt 5.6
Switch from knotification to nemo notification (not complete!)
Add a very simple example sailfish app.
Note, there is still much missing functionality. Notifications dont work, pairing sort of works but not really, but when it is paired you can send a ping to the desktop client
Dont build kio for Sailfish
Port core build system
Port daemon buld system
Require CoreAddons on Sailfish
Port plugins build for sailfish and include the ping plugin for now
Final build changes for sailfish.
Disable tests and other not needed parts
Add includes for QCA
Fix build errors on sailfish
Get core/ to build on sailfish
Get interfaces/ to build on sailfish
Build daemon on sailfish
On sailfish, dont install the kcm file
Start port plugin to sailfish
Fixup installed files
Add sfos app
Hack declarative plugin to give a public interface
Build sfos app
Compile declarativeplugin into the sfos app for now
Redefine qAsConst for qt 5.6
Packaging fixes
Use official icon
Package .desktop
Reviewers: #kde_connect, apol, nicolasfella, albertvaka
Reviewed By: #kde_connect, apol, nicolasfella, albertvaka
Subscribers: kdeconnect, andyholmes, albertvaka, kossebau, mtijink, vonreth, apol, #kde_connect, nicolasfella
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D10703
2018-08-02 20:10:59 +01:00
|
|
|
<< qRegisterMetaType<QDBusPendingReply<int> >("QDBusPendingReply<int>")
|
2014-01-28 22:22:59 +00:00
|
|
|
<< qRegisterMetaType<QDBusPendingReply<QString> >("QDBusPendingReply<QString>")
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2021-10-27 22:11:36 +01:00
|
|
|
QVariant DBusResponseWaiter::waitForReply(QVariant variant) const
|
2014-01-28 22:22:59 +00:00
|
|
|
{
|
2021-10-27 22:11:53 +01:00
|
|
|
if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(extractPendingCall(variant)))
|
2014-01-28 22:22:59 +00:00
|
|
|
{
|
|
|
|
call->waitForFinished();
|
Build kdeconnect on sailfish and port some simple plugins
Summary:
Below is a lost of the commits, but, in summary
Port the build system for Sailfish, which means selectively building only the bits we need/can, and only against the KF5 libs that are available.
Allow to build on Qt 5.6
Switch from knotification to nemo notification (not complete!)
Add a very simple example sailfish app.
Note, there is still much missing functionality. Notifications dont work, pairing sort of works but not really, but when it is paired you can send a ping to the desktop client
Dont build kio for Sailfish
Port core build system
Port daemon buld system
Require CoreAddons on Sailfish
Port plugins build for sailfish and include the ping plugin for now
Final build changes for sailfish.
Disable tests and other not needed parts
Add includes for QCA
Fix build errors on sailfish
Get core/ to build on sailfish
Get interfaces/ to build on sailfish
Build daemon on sailfish
On sailfish, dont install the kcm file
Start port plugin to sailfish
Fixup installed files
Add sfos app
Hack declarative plugin to give a public interface
Build sfos app
Compile declarativeplugin into the sfos app for now
Redefine qAsConst for qt 5.6
Packaging fixes
Use official icon
Package .desktop
Reviewers: #kde_connect, apol, nicolasfella, albertvaka
Reviewed By: #kde_connect, apol, nicolasfella, albertvaka
Subscribers: kdeconnect, andyholmes, albertvaka, kossebau, mtijink, vonreth, apol, #kde_connect, nicolasfella
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D10703
2018-08-02 20:10:59 +01:00
|
|
|
|
2014-02-05 20:36:51 +00:00
|
|
|
if (call->isError())
|
|
|
|
{
|
2016-06-12 21:26:32 +01:00
|
|
|
qWarning() << "error:" << call->error();
|
2019-06-10 15:40:28 +01:00
|
|
|
return QVariant(QStringLiteral("error"));
|
2014-02-05 20:36:51 +00:00
|
|
|
}
|
Build kdeconnect on sailfish and port some simple plugins
Summary:
Below is a lost of the commits, but, in summary
Port the build system for Sailfish, which means selectively building only the bits we need/can, and only against the KF5 libs that are available.
Allow to build on Qt 5.6
Switch from knotification to nemo notification (not complete!)
Add a very simple example sailfish app.
Note, there is still much missing functionality. Notifications dont work, pairing sort of works but not really, but when it is paired you can send a ping to the desktop client
Dont build kio for Sailfish
Port core build system
Port daemon buld system
Require CoreAddons on Sailfish
Port plugins build for sailfish and include the ping plugin for now
Final build changes for sailfish.
Disable tests and other not needed parts
Add includes for QCA
Fix build errors on sailfish
Get core/ to build on sailfish
Get interfaces/ to build on sailfish
Build daemon on sailfish
On sailfish, dont install the kcm file
Start port plugin to sailfish
Fixup installed files
Add sfos app
Hack declarative plugin to give a public interface
Build sfos app
Compile declarativeplugin into the sfos app for now
Redefine qAsConst for qt 5.6
Packaging fixes
Use official icon
Package .desktop
Reviewers: #kde_connect, apol, nicolasfella, albertvaka
Reviewed By: #kde_connect, apol, nicolasfella, albertvaka
Subscribers: kdeconnect, andyholmes, albertvaka, kossebau, mtijink, vonreth, apol, #kde_connect, nicolasfella
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D10703
2018-08-02 20:10:59 +01:00
|
|
|
|
2014-01-28 22:22:59 +00:00
|
|
|
QDBusMessage reply = call->reply();
|
|
|
|
|
|
|
|
if (reply.arguments().count() > 0)
|
|
|
|
{
|
2015-09-12 08:53:05 +01:00
|
|
|
return reply.arguments().at(0);
|
2014-01-28 22:22:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
2014-02-06 15:25:22 +00:00
|
|
|
DBusAsyncResponse::DBusAsyncResponse(QObject* parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, m_autodelete(false)
|
|
|
|
{
|
|
|
|
m_timeout.setSingleShot(true);
|
|
|
|
m_timeout.setInterval(15000);
|
2016-11-26 14:12:38 +00:00
|
|
|
connect(&m_timeout, &QTimer::timeout, this, &DBusAsyncResponse::onTimeout);
|
2014-02-06 15:25:22 +00:00
|
|
|
}
|
|
|
|
|
2021-10-27 22:11:36 +01:00
|
|
|
|
|
|
|
void DBusAsyncResponse::setPendingCall(QVariant variant)
|
2014-01-28 22:22:59 +00:00
|
|
|
{
|
2021-10-27 22:11:53 +01:00
|
|
|
if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(DBusResponseWaiter::instance()->extractPendingCall(variant)))
|
Build kdeconnect on sailfish and port some simple plugins
Summary:
Below is a lost of the commits, but, in summary
Port the build system for Sailfish, which means selectively building only the bits we need/can, and only against the KF5 libs that are available.
Allow to build on Qt 5.6
Switch from knotification to nemo notification (not complete!)
Add a very simple example sailfish app.
Note, there is still much missing functionality. Notifications dont work, pairing sort of works but not really, but when it is paired you can send a ping to the desktop client
Dont build kio for Sailfish
Port core build system
Port daemon buld system
Require CoreAddons on Sailfish
Port plugins build for sailfish and include the ping plugin for now
Final build changes for sailfish.
Disable tests and other not needed parts
Add includes for QCA
Fix build errors on sailfish
Get core/ to build on sailfish
Get interfaces/ to build on sailfish
Build daemon on sailfish
On sailfish, dont install the kcm file
Start port plugin to sailfish
Fixup installed files
Add sfos app
Hack declarative plugin to give a public interface
Build sfos app
Compile declarativeplugin into the sfos app for now
Redefine qAsConst for qt 5.6
Packaging fixes
Use official icon
Package .desktop
Reviewers: #kde_connect, apol, nicolasfella, albertvaka
Reviewed By: #kde_connect, apol, nicolasfella, albertvaka
Subscribers: kdeconnect, andyholmes, albertvaka, kossebau, mtijink, vonreth, apol, #kde_connect, nicolasfella
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D10703
2018-08-02 20:10:59 +01:00
|
|
|
{
|
2014-01-28 22:22:59 +00:00
|
|
|
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(*call);
|
2014-02-06 15:25:22 +00:00
|
|
|
watcher->setProperty("pengingCallVariant", variant);
|
2016-11-26 14:12:38 +00:00
|
|
|
connect(watcher, &QDBusPendingCallWatcher::finished, this, &DBusAsyncResponse::onCallFinished);
|
|
|
|
connect(watcher, &QDBusPendingCallWatcher::finished, watcher, &QObject::deleteLater);
|
|
|
|
connect(&m_timeout, &QTimer::timeout, watcher, &QObject::deleteLater);
|
2014-02-06 15:25:22 +00:00
|
|
|
m_timeout.start();
|
2016-06-15 22:49:37 +01:00
|
|
|
}
|
2014-01-28 22:22:59 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 10:06:21 +00:00
|
|
|
void DBusAsyncResponse::onCallFinished(QDBusPendingCallWatcher* watcher)
|
2014-01-28 22:22:59 +00:00
|
|
|
{
|
2014-02-06 15:25:22 +00:00
|
|
|
m_timeout.stop();
|
|
|
|
QVariant variant = watcher->property("pengingCallVariant");
|
Build kdeconnect on sailfish and port some simple plugins
Summary:
Below is a lost of the commits, but, in summary
Port the build system for Sailfish, which means selectively building only the bits we need/can, and only against the KF5 libs that are available.
Allow to build on Qt 5.6
Switch from knotification to nemo notification (not complete!)
Add a very simple example sailfish app.
Note, there is still much missing functionality. Notifications dont work, pairing sort of works but not really, but when it is paired you can send a ping to the desktop client
Dont build kio for Sailfish
Port core build system
Port daemon buld system
Require CoreAddons on Sailfish
Port plugins build for sailfish and include the ping plugin for now
Final build changes for sailfish.
Disable tests and other not needed parts
Add includes for QCA
Fix build errors on sailfish
Get core/ to build on sailfish
Get interfaces/ to build on sailfish
Build daemon on sailfish
On sailfish, dont install the kcm file
Start port plugin to sailfish
Fixup installed files
Add sfos app
Hack declarative plugin to give a public interface
Build sfos app
Compile declarativeplugin into the sfos app for now
Redefine qAsConst for qt 5.6
Packaging fixes
Use official icon
Package .desktop
Reviewers: #kde_connect, apol, nicolasfella, albertvaka
Reviewed By: #kde_connect, apol, nicolasfella, albertvaka
Subscribers: kdeconnect, andyholmes, albertvaka, kossebau, mtijink, vonreth, apol, #kde_connect, nicolasfella
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D10703
2018-08-02 20:10:59 +01:00
|
|
|
|
2014-01-31 10:06:21 +00:00
|
|
|
if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(DBusResponseWaiter::instance()->extractPendingCall(variant)))
|
2014-01-28 22:22:59 +00:00
|
|
|
{
|
|
|
|
if (call->isError())
|
|
|
|
{
|
2014-01-30 16:25:22 +00:00
|
|
|
Q_EMIT error(call->error().message());
|
2014-01-28 22:22:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QDBusMessage reply = call->reply();
|
|
|
|
|
|
|
|
if (reply.arguments().count() > 0)
|
|
|
|
{
|
2015-09-12 08:53:05 +01:00
|
|
|
Q_EMIT success(reply.arguments().at(0));
|
2014-01-28 22:22:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-30 16:25:22 +00:00
|
|
|
Q_EMIT success(QVariant());
|
2014-01-28 22:22:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-02-05 20:36:51 +00:00
|
|
|
if (m_autodelete)
|
|
|
|
{
|
|
|
|
deleteLater();
|
|
|
|
}
|
2014-01-28 22:22:59 +00:00
|
|
|
}
|
|
|
|
|
2014-02-06 15:25:22 +00:00
|
|
|
void DBusAsyncResponse::onTimeout()
|
|
|
|
{
|
2016-11-26 14:38:08 +00:00
|
|
|
Q_EMIT error(QStringLiteral("timeout when waiting dbus response!"));
|
2014-02-06 15:25:22 +00:00
|
|
|
}
|
|
|
|
|
2021-10-27 22:11:53 +01:00
|
|
|
const QDBusPendingCall* DBusResponseWaiter::extractPendingCall(QVariant& variant) const
|
2014-01-28 22:22:59 +00:00
|
|
|
{
|
2017-07-20 15:14:07 +01:00
|
|
|
for (int type : qAsConst(m_registered))
|
2014-01-28 22:22:59 +00:00
|
|
|
{
|
|
|
|
if (variant.canConvert(QVariant::Type(type)))
|
|
|
|
{
|
2021-10-27 22:11:53 +01:00
|
|
|
return reinterpret_cast<const QDBusPendingCall*>(variant.constData());
|
2014-01-28 22:22:59 +00:00
|
|
|
}
|
|
|
|
}
|
Build kdeconnect on sailfish and port some simple plugins
Summary:
Below is a lost of the commits, but, in summary
Port the build system for Sailfish, which means selectively building only the bits we need/can, and only against the KF5 libs that are available.
Allow to build on Qt 5.6
Switch from knotification to nemo notification (not complete!)
Add a very simple example sailfish app.
Note, there is still much missing functionality. Notifications dont work, pairing sort of works but not really, but when it is paired you can send a ping to the desktop client
Dont build kio for Sailfish
Port core build system
Port daemon buld system
Require CoreAddons on Sailfish
Port plugins build for sailfish and include the ping plugin for now
Final build changes for sailfish.
Disable tests and other not needed parts
Add includes for QCA
Fix build errors on sailfish
Get core/ to build on sailfish
Get interfaces/ to build on sailfish
Build daemon on sailfish
On sailfish, dont install the kcm file
Start port plugin to sailfish
Fixup installed files
Add sfos app
Hack declarative plugin to give a public interface
Build sfos app
Compile declarativeplugin into the sfos app for now
Redefine qAsConst for qt 5.6
Packaging fixes
Use official icon
Package .desktop
Reviewers: #kde_connect, apol, nicolasfella, albertvaka
Reviewed By: #kde_connect, apol, nicolasfella, albertvaka
Subscribers: kdeconnect, andyholmes, albertvaka, kossebau, mtijink, vonreth, apol, #kde_connect, nicolasfella
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D10703
2018-08-02 20:10:59 +01:00
|
|
|
|
2015-09-08 09:46:59 +01:00
|
|
|
return nullptr;
|
2014-01-28 22:22:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|