From kde-commits Tue May 22 13:32:19 2018 From: Aleix Pol Date: Tue, 22 May 2018 13:32:19 +0000 To: kde-commits Subject: [discover/Plasma/5.13] /: Merge branch 'Plasma/5.12' into Plasma/5.13 Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=152699595023861 Git commit 342db07b0a0f12039e317566a52a1d3fb2722f2d by Aleix Pol. Committed on 22/05/2018 at 13:31. Pushed by apol into branch 'Plasma/5.13'. Merge branch 'Plasma/5.12' into Plasma/5.13 M +6 -1 discover/DiscoverObject.cpp M +37 -10 libdiscover/backends/PackageKitBackend/AppPackageKitResource= .cpp M +6 -4 libdiscover/backends/PackageKitBackend/PKTransaction.cpp M +5 -0 libdiscover/backends/PackageKitBackend/PackageKitBackend.cpp M +2 -2 libdiscover/backends/SnapBackend/SnapResource.cpp https://commits.kde.org/discover/342db07b0a0f12039e317566a52a1d3fb2722f2d diff --cc libdiscover/backends/PackageKitBackend/AppPackageKitResource.cpp index 82bfd3bf,bee92691..16db9429 --- a/libdiscover/backends/PackageKitBackend/AppPackageKitResource.cpp +++ b/libdiscover/backends/PackageKitBackend/AppPackageKitResource.cpp @@@ -24,6 -24,6 +24,7 @@@ #include #include #include ++#include #include #include #include @@@ -31,6 -31,8 +32,7 @@@ #include #include #include "config-paths.h" -#include -#include ++#include "utils.h" = AppPackageKitResource::AppPackageKitResource(const AppStream::Component& = data, const QString &packageName, PackageKitBackend* parent) : PackageKitResource(packageName, QString(), parent) @@@ -199,21 -191,32 +206,41 @@@ void AppPackageKitResource::fetchChange = void AppPackageKitResource::invokeApplication() const { - const QStringList exes =3D m_appdata.provided(AppStream::Provided::Ki= ndBinary).items(); - if (exes.isEmpty()) { - const auto servicePath =3D QStandardPaths::locate(QStandardPaths:= :ApplicationsLocation, m_appdata.id()); - QProcess::startDetached(QStringLiteral(CMAKE_INSTALL_FULL_LIBEXEC= DIR_KF5 "/discover/runservice"), {servicePath}); - } else { - QProcess::startDetached(exes.constFirst()); - } + auto trans =3D PackageKit::Daemon::getFiles({installedPackageId()}); + connect(trans, &PackageKit::Transaction::files, this, [this](const QS= tring &/*packageID*/, const QStringList &filenames) { + const auto allServices =3D QStandardPaths::locateAll(QStandardPat= hs::ApplicationsLocation, m_appdata.id()); + if (!allServices.isEmpty()) { + const auto packageServices =3D kFilter(allServic= es, [filenames](const QString &file) { return filenames.contains(file); }); + QProcess::startDetached(QStringLiteral(CMAKE_INSTALL_FULL_LIB= EXECDIR_KF5 "/discover/runservice"), {packageServices}); + } else { + const QStringList exes =3D m_appdata.provided(AppStream::Prov= ided::KindBinary).items(); + const auto packageExecutables =3D kFilter(allSer= vices, [filenames](const QString &exe) { return filenames.contains(QLatin1C= har('/') + exe); }); + if (!packageExecutables.isEmpty()) { + QProcess::startDetached(exes.constFirst()); + } else { + const auto locations =3D QStandardPaths::standardLocation= s(QStandardPaths::ApplicationsLocation); + const auto desktopFiles =3D kFilter(filename= s, [locations](const QString &exe) { + for (const auto &location: locations) { + if (exe.startsWith(location)) + return exe.contains(QLatin1String(".desktop")= ); + } + return false; + }); + if (!desktopFiles.isEmpty()) { + QProcess::startDetached(QStringLiteral(CMAKE_INSTALL_= FULL_LIBEXECDIR_KF5 "/discover/runservice"), { desktopFiles }); + } + } + qWarning() << "Could not find any executables" << exes << fil= enames; + } + }); } = +QDate AppPackageKitResource::releaseDate() const +{ + if (!m_appdata.releases().isEmpty()) { + auto release =3D m_appdata.releases().constFirst(); + return release.timestamp().date(); + } + + return {}; +} diff --cc libdiscover/backends/SnapBackend/SnapResource.cpp index df0fbe94,74bdc2f3..6272c734 --- a/libdiscover/backends/SnapBackend/SnapResource.cpp +++ b/libdiscover/backends/SnapBackend/SnapResource.cpp @@@ -24,56 -24,12 +24,56 @@@ #include #include #include - #include +#include +#include +#include + #include = -SnapResource::SnapResource(QSharedPointer snap, AbstractResou= rce::State state, SnapBackend* parent) - : AbstractResource(parent) +QDebug operator<<(QDebug debug, const QSnapdPlug& plug) +{ + QDebugStateSaver saver(debug); + debug.nospace() << "QSnapdPlug("; + debug.nospace() << "name:" << plug.name() << ','; + debug.nospace() << "snap:" << plug.snap() << ','; + debug.nospace() << "label:" << plug.label() << ','; + debug.nospace() << "interface:" << plug.interface() << ','; + debug.nospace() << "connectionCount:" << plug.connectionCount(); + debug.nospace() << ')'; + return debug; +} + +QDebug operator<<(QDebug debug, const QSnapdSlot& slot) +{ + QDebugStateSaver saver(debug); + debug.nospace() << "QSnapdSlot("; + debug.nospace() << "name:" << slot.name() << ','; + debug.nospace() << "label:" << slot.label() << ','; + debug.nospace() << "snap:" << slot.snap() << ','; + debug.nospace() << "interface:" << slot.interface() << ','; + debug.nospace() << "connectionCount:" << slot.connectionCount(); + debug.nospace() << ')'; + return debug; +} + +QDebug operator<<(QDebug debug, const QSnapdPlug* plug) +{ + QDebugStateSaver saver(debug); + debug.nospace() << "*" << *plug; + return debug; +} + +QDebug operator<<(QDebug debug, const QSnapdSlot* slot) +{ + QDebugStateSaver saver(debug); + debug.nospace() << "*" << *slot; + return debug; +} + +SnapResource::SnapResource(QSharedPointer snap, AbstractResou= rce::State state, SnapBackend* backend) + : AbstractResource(backend) , m_state(state) , m_snap(snap) + , m_objects({ QStringLiteral("qrc:/snapui/PermissionsButton.qml") }) { setObjectName(snap->name()); }