Verified Commit 0487c8eb authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

wallpapers/potd: update wallpapers after network is connected

Usually after waking up from sleep and when the engine receives
`PrepareForSleep` from org.freedesktop.login1.Manager, the network
is still disconnected, so the engine needs to update wallpapers after
the network is connected.

In case the network is connected before `PrepareForSleep`, the loading
condition will block duplicate update requests.

BUG: 457361
FIXED-IN: 5.26
parent 6192b04e
Pipeline #220821 passed with stage
in 1 minute and 43 seconds
......@@ -11,9 +11,6 @@
#include <QDBusConnection>
#include <QThreadPool>
#if HAVE_NetworkManagerQt
#include <NetworkManagerQt/Manager>
#endif
#include <KPluginFactory>
#include "cachedprovider.h"
......@@ -231,6 +228,10 @@ PotdEngine::PotdEngine(QObject *parent)
QStringLiteral("PrepareForSleep"),
this,
SLOT(slotPrepareForSleep(bool)));
#if HAVE_NetworkManagerQt
connect(NetworkManager::notifier(), &NetworkManager::Notifier::connectivityChanged, this, &PotdEngine::slotConnectivityChanged);
#endif
}
PotdClient *PotdEngine::registerClient(const QString &identifier, const QVariantList &args)
......@@ -337,11 +338,28 @@ void PotdEngine::slotPrepareForSleep(bool sleep)
return;
}
#if HAVE_NetworkManagerQt
if (NetworkManager::connectivity() != NetworkManager::Connectivity::Full) {
qCDebug(WALLPAPERPOTD) << "Waking up from sleep but the network is not connected yet.";
return;
}
#endif
// Resume from sleep
// Always force update to work around the current date not being updated
forceUpdateSource();
}
#if HAVE_NetworkManagerQt
void PotdEngine::slotConnectivityChanged(NetworkManager::Connectivity connectivity)
{
if (connectivity == NetworkManager::Connectivity::Full) {
qCDebug(WALLPAPERPOTD) << "Network is connected.";
updateSource(false);
}
}
#endif
void PotdEngine::loadPluginMetaData()
{
const auto plugins = KPluginMetaData::findPlugins(QStringLiteral("potd"));
......
......@@ -6,15 +6,19 @@
#pragma once
#include "config-NetworkManagerQt.h"
#include <unordered_map>
#include <QDate>
#include <QObject>
#include <QTimer>
#if HAVE_NetworkManagerQt
#include <NetworkManagerQt/Manager>
#endif
#include <KPluginMetaData>
#include "config-NetworkManagerQt.h"
#include "potdprovider.h"
/**
......@@ -96,6 +100,9 @@ private Q_SLOTS:
void forceUpdateSource();
void slotDone(PotdClient *client, bool success);
void slotPrepareForSleep(bool sleep);
#if HAVE_NetworkManagerQt
void slotConnectivityChanged(NetworkManager::Connectivity connectivity);
#endif
private:
void loadPluginMetaData();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment