Changeset View
Changeset View
Standalone View
Standalone View
notifier/DiscoverNotifier.cpp
Show All 18 Lines | |||||
19 | ***************************************************************************/ | 19 | ***************************************************************************/ | ||
20 | 20 | | |||
21 | #include "DiscoverNotifier.h" | 21 | #include "DiscoverNotifier.h" | ||
22 | #include "BackendNotifierFactory.h" | 22 | #include "BackendNotifierFactory.h" | ||
23 | #include <QDebug> | 23 | #include <QDebug> | ||
24 | #include <QDBusInterface> | 24 | #include <QDBusInterface> | ||
25 | #include <QDBusPendingReply> | 25 | #include <QDBusPendingReply> | ||
26 | #include <QNetworkConfigurationManager> | 26 | #include <QNetworkConfigurationManager> | ||
27 | #include <KRun> | | |||
28 | #include <KLocalizedString> | 27 | #include <KLocalizedString> | ||
29 | #include <KNotification> | 28 | #include <KNotification> | ||
29 | #include <KNotificationJobUiDelegate> | ||||
30 | #include <KPluginFactory> | 30 | #include <KPluginFactory> | ||
31 | 31 | | |||
32 | #include <KIO/ApplicationLauncherJob> | ||||
33 | #include <KIO/CommandLauncherJob> | ||||
34 | | ||||
32 | #include "../libdiscover/utils.h" | 35 | #include "../libdiscover/utils.h" | ||
33 | 36 | | |||
34 | DiscoverNotifier::DiscoverNotifier(QObject * parent) | 37 | DiscoverNotifier::DiscoverNotifier(QObject * parent) | ||
35 | : QObject(parent) | 38 | : QObject(parent) | ||
36 | { | 39 | { | ||
37 | m_backends = BackendNotifierFactory().allBackends(); | 40 | m_backends = BackendNotifierFactory().allBackends(); | ||
38 | foreach(BackendNotifierModule* module, m_backends) { | 41 | foreach(BackendNotifierModule* module, m_backends) { | ||
39 | connect(module, &BackendNotifierModule::foundUpdates, this, &DiscoverNotifier::updateStatusNotifier); | 42 | connect(module, &BackendNotifierModule::foundUpdates, this, &DiscoverNotifier::updateStatusNotifier); | ||
Show All 16 Lines | |||||
56 | //Only fetch updates after the system is comfortably booted | 59 | //Only fetch updates after the system is comfortably booted | ||
57 | QTimer::singleShot(20000, this, &DiscoverNotifier::recheckSystemUpdateNeeded); | 60 | QTimer::singleShot(20000, this, &DiscoverNotifier::recheckSystemUpdateNeeded); | ||
58 | } | 61 | } | ||
59 | 62 | | |||
60 | DiscoverNotifier::~DiscoverNotifier() = default; | 63 | DiscoverNotifier::~DiscoverNotifier() = default; | ||
61 | 64 | | |||
62 | void DiscoverNotifier::showDiscover() | 65 | void DiscoverNotifier::showDiscover() | ||
63 | { | 66 | { | ||
64 | KRun::runCommand(QStringLiteral("plasma-discover"), nullptr); | 67 | auto *job = new KIO::ApplicationLauncherJob(KService::serviceByDesktopName(QStringLiteral("org.kde.discover"))); | ||
65 | if (m_updatesAvailableNotification) { m_updatesAvailableNotification->close(); } | 68 | job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled)); | ||
69 | job->start(); | ||||
70 | | ||||
71 | if (m_updatesAvailableNotification) { | ||||
72 | m_updatesAvailableNotification->close(); | ||||
73 | } | ||||
66 | } | 74 | } | ||
67 | 75 | | |||
68 | void DiscoverNotifier::showDiscoverUpdates() | 76 | void DiscoverNotifier::showDiscoverUpdates() | ||
69 | { | 77 | { | ||
70 | KRun::runCommand(QStringLiteral("plasma-discover --mode update"), nullptr); | 78 | auto *job = new KIO::CommandLauncherJob(QStringLiteral("plasma-discover"), { | ||
71 | if (m_updatesAvailableNotification) { m_updatesAvailableNotification->close(); } | 79 | QStringLiteral("--mode"), | ||
80 | QStringLiteral("update") | ||||
81 | }); | ||||
82 | job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled)); | ||||
83 | job->setDesktopName(QStringLiteral("org.kde.discover")); | ||||
84 | job->start(); | ||||
85 | | ||||
86 | if (m_updatesAvailableNotification) { | ||||
87 | m_updatesAvailableNotification->close(); | ||||
88 | } | ||||
72 | } | 89 | } | ||
73 | 90 | | |||
74 | void DiscoverNotifier::showUpdatesNotification() | 91 | void DiscoverNotifier::showUpdatesNotification() | ||
75 | { | 92 | { | ||
76 | if (m_updatesAvailableNotification) { m_updatesAvailableNotification->close(); } | 93 | if (m_updatesAvailableNotification) { m_updatesAvailableNotification->close(); } | ||
77 | if (state() != NormalUpdates && state() != SecurityUpdates) { | 94 | if (state() != NormalUpdates && state() != SecurityUpdates) { | ||
78 | //it's not very helpful to notify that everything is in order | 95 | //it's not very helpful to notify that everything is in order | ||
79 | return; | 96 | return; | ||
▲ Show 20 Lines • Show All 130 Lines • Show Last 20 Lines |