diff --git a/kcms/activities/CMakeLists.txt b/kcms/activities/CMakeLists.txt --- a/kcms/activities/CMakeLists.txt +++ b/kcms/activities/CMakeLists.txt @@ -33,8 +33,6 @@ BlacklistedApplicationsModel.cpp ExtraActivitiesInterface.cpp - - utils/dbusfuture_p.cpp ) ki18n_wrap_ui ( diff --git a/kcms/activities/ExtraActivitiesInterface.cpp b/kcms/activities/ExtraActivitiesInterface.cpp --- a/kcms/activities/ExtraActivitiesInterface.cpp +++ b/kcms/activities/ExtraActivitiesInterface.cpp @@ -29,7 +29,6 @@ #include #include -#include "utils/dbusfuture_p.h" #include "features_interface.h" #include "common/dbus/common.h" diff --git a/kcms/activities/utils/dbusfuture_p.h b/kcms/activities/utils/dbusfuture_p.h deleted file mode 100644 --- a/kcms/activities/utils/dbusfuture_p.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2013 - 2016 by Ivan Cukic - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License or (at your option) version 3 or any later version - * accepted by the membership of KDE e.V. (or its successor approved - * by the membership of KDE e.V.), which shall act as a proxy - * defined in Section 14 of version 3 of the license. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef ACTIVITIES_DBUSFUTURE_P_H -#define ACTIVITIES_DBUSFUTURE_P_H - -#include -#include -#include -#include -#include -#include -#include - -namespace DBusFuture { - -namespace detail { //_ - -template -class DBusCallFutureInterface : public QObject, - public QFutureInterface<_Result> { -public: - DBusCallFutureInterface(QDBusPendingReply<_Result> reply) - : reply(reply), - replyWatcher(nullptr) - { - } - - ~DBusCallFutureInterface() override - { - delete replyWatcher; - } - - void callFinished(); - - QFuture<_Result> start() - { - replyWatcher = new QDBusPendingCallWatcher(reply); - - QObject::connect(replyWatcher, - &QDBusPendingCallWatcher::finished, - [this] () { callFinished(); }); - - this->reportStarted(); - - if (reply.isFinished()) { - this->callFinished(); - } - - return this->future(); - } - -private: - QDBusPendingReply<_Result> reply; - QDBusPendingCallWatcher * replyWatcher; -}; - -template -void DBusCallFutureInterface<_Result>::callFinished() -{ - deleteLater(); - - if (!reply.isError()) { - this->reportResult(reply.value()); - } - - this->reportFinished(); -} - -template <> -void DBusCallFutureInterface::callFinished(); - -template -class ValueFutureInterface : public QObject, QFutureInterface<_Result> { -public: - ValueFutureInterface(const _Result & value) - : value(value) - { - } - - QFuture<_Result> start() - { - auto future = this->future(); - - this->reportResult(value); - this->reportFinished(); - - deleteLater(); - - return future; - } - -private: - _Result value; - -}; - -template <> -class ValueFutureInterface : public QObject, QFutureInterface { -public: - ValueFutureInterface(); - - QFuture start(); - // { - // auto future = this->future(); - // this->reportFinished(); - // deleteLater(); - // return future; - // } -}; - -} //^ namespace detail - -template -QFuture<_Result> -asyncCall(QDBusAbstractInterface *interface, const QString &method, - const QVariant &arg1 = QVariant(), const QVariant &arg2 = QVariant(), - const QVariant &arg3 = QVariant(), const QVariant &arg4 = QVariant(), - const QVariant &arg5 = QVariant(), const QVariant &arg6 = QVariant(), - const QVariant &arg7 = QVariant(), const QVariant &arg8 = QVariant()) -{ - using namespace detail; - - auto callFutureInterface = new DBusCallFutureInterface - <_Result>(interface->asyncCall(method, arg1, arg2, arg3, arg4, arg5, - arg6, arg7, arg8)); - - return callFutureInterface->start(); -} - -template -QFuture<_Result> -fromValue(const _Result & value) -{ - using namespace detail; - - auto valueFutureInterface = new ValueFutureInterface<_Result>(value); - - return valueFutureInterface->start(); -} - -template -QFuture<_Result> -fromReply(const QDBusPendingReply<_Result> &reply) -{ - using namespace detail; - - auto callFutureInterface = new DBusCallFutureInterface<_Result>(reply); - - return callFutureInterface->start(); -} - -QFuture fromVoid(); - -} // namespace DBusFuture - -#endif /* DBUSFUTURE_P_H */ - diff --git a/kcms/activities/utils/dbusfuture_p.cpp b/kcms/activities/utils/dbusfuture_p.cpp deleted file mode 100644 --- a/kcms/activities/utils/dbusfuture_p.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2013 - 2016 by Ivan Cukic - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License or (at your option) version 3 or any later version - * accepted by the membership of KDE e.V. (or its successor approved - * by the membership of KDE e.V.), which shall act as a proxy - * defined in Section 14 of version 3 of the license. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "dbusfuture_p.h" - -namespace DBusFuture { - -namespace detail { //_ - -template <> -void DBusCallFutureInterface::callFinished() -{ - deleteLater(); - - // qDebug() << "This is call end"; - - this->reportFinished(); -} - -ValueFutureInterface::ValueFutureInterface() -{ -} - -QFuture ValueFutureInterface::start() -{ - auto future = this->future(); - - this->reportFinished(); - - deleteLater(); - - return future; -} - -} //^ namespace detail - -QFuture fromVoid() -{ - using namespace detail; - - auto valueFutureInterface = new ValueFutureInterface(); - - return valueFutureInterface->start(); -} - -} // namespace DBusFuture -