Commit e6472153 authored by Yunhe Guo's avatar Yunhe Guo
Browse files

Remove POTD KDED module

parent e7c51a04
......@@ -77,7 +77,6 @@ add_definitions(
################# list the subdirectories #################
add_subdirectory(applets)
add_subdirectory(dataengines)
add_subdirectory(kdeds)
add_subdirectory(runners)
add_subdirectory(wallpapers)
......
add_subdirectory(potd)
########### next target ###############
set(dbus_interface_name org.kde.potd.xml)
set(kded_potd_PART_SRCS kded_potd.cpp)
add_library(kded_potd MODULE ${kded_potd_PART_SRCS})
set_target_properties(kded_potd PROPERTIES OUTPUT_NAME potd)
target_link_libraries(kded_potd
KF5::DBusAddons
KF5::Plasma
)
########### install files ###############
kcoreaddons_desktop_to_json(kded_potd kded_potd.desktop)
install(TARGETS kded_potd DESTINATION ${PLUGIN_INSTALL_DIR}/kf5/kded)
# Picture Of The Day (POTD) Caching Daemon
The lock screen runs in a special mode where it cannot access the internet. So
when it trys to load a POTD wallpaper that isn't cached, it fails.
This daemon caches POTD before screen locking. The lock screen always loads POTD
from cache. Whenever the lock screen configuration changes, the daemon will read
the configuration and cache POTD if necessary.
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-FileCopyrightText: 2020 Guo Yunhe <i@guoyunhe.me>
// SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org>
#include "kded_potd.h"
#include <KPluginFactory>
K_PLUGIN_CLASS_WITH_JSON(PotdModule, "kded_potd.json")
PotdModule::PotdModule(QObject* parent, const QList<QVariant>&)
: KDEDModule(parent)
, config(KSharedConfig::openConfig(QStringLiteral("kscreenlockerrc"), KConfig::CascadeConfig))
, configWatcher(KConfigWatcher::create(config))
{
connect(configWatcher.data(), &KConfigWatcher::configChanged,
this, &PotdModule::configChanged);
configChanged();
}
PotdModule::~PotdModule()
{
delete consumer;
}
void PotdModule::configChanged()
{
if (engine) {
engine->disconnectSource(previousSource, this);
}
previousSource = getSource();
if (!previousSource.isEmpty()) {
if (!consumer) {
consumer = new Plasma::DataEngineConsumer;
engine = consumer->dataEngine(QStringLiteral("potd"));
engine->connectSource(previousSource, this); // trigger caching, no need to handle data
}
engine->connectSource(previousSource, this);
}
}
QString PotdModule::getSource()
{
KConfigGroup greeterGroup = config->group(QStringLiteral("Greeter"));
QString plugin = greeterGroup.readEntry(QStringLiteral("WallpaperPlugin"), QString());
if (plugin != QStringLiteral("org.kde.potd")) {
return QStringLiteral("");
}
KConfigGroup potdGroup = greeterGroup
.group(QStringLiteral("Wallpaper"))
.group(QStringLiteral("org.kde.potd"))
.group(QStringLiteral("General"));
QString provider = potdGroup.readEntry(QStringLiteral("Provider"), QString());
if (provider == QStringLiteral("unsplash")) {
QString category = potdGroup.readEntry(QStringLiteral("Category"), QString());
return provider + QStringLiteral(":") + category;
} else {
return provider;
}
}
#include "kded_potd.moc"
[Desktop Entry]
Name=Picture of The Day
Name[ca]=Imatge del dia
Name[cs]=Obrázek dne
Name[de]=Bild des Tages
Name[en_GB]=Picture of The Day
Name[es]=Imagen del día
Name[eu]=Eguneko irudia
Name[fi]=Päivän kuva
Name[fr]=Image du jour
Name[it]=Immagine del giorno
Name[ko]=오늘의 그림
Name[nl]=Afbeelding van de dag
Name[nn]=Dagens bilete
Name[pt]=Imagem do Dia
Name[pt_BR]=Imagem do dia
Name[sl]=Slika dneva
Name[sv]=Dagens bild
Name[tg]=Сурати рӯз
Name[uk]=Картинка дня
Name[x-test]=xxPicture of The Dayxx
Name[zh_CN]=每日一图
Comment=Cache picture of the day for lock screen and SDDM
Comment[ca]=Posa la imatge del dia a la memòria cau per a la pantalla de bloqueig i l'SDDM
Comment[en_GB]=Cache picture of the day for lock screen and SDDM
Comment[es]=Usar caché para la imagen del día de la pantalla de bloqueo y de SDDM
Comment[eu]=Cacheratu eguneko irudia giltzatze pantaila eta SDDMrako
Comment[fi]=Päivän välimuistikuva lukitus- ja kirjautumisnäytöille
Comment[fr]=Mettre en cache l'image du jour pour l'écran de verrouillage et de démarrage « SDDM »
Comment[it]=Salva in cache l'immagine del giorno per la schermata di blocco e SDDM
Comment[ko]=잠금 화면과 SDDM의 오늘의 그림 캐시
Comment[nl]=Afbeelding van de dag in cache zetten voor scherm vergrendelen en SDDM
Comment[nn]=Mellomlagra dagens bilete for låseskjerm og SDDM
Comment[pt]=Pôr em 'cache' a imagem do dia para o ecrã de bloqueio e o SDDM
Comment[pt_BR]=Cache da imagem do dia para o bloqueio de tela e SDDM
Comment[sl]=Slika dneva v predpomnilniku za zaklep zaslona in SDDM
Comment[sv]=Lagra dagens bild för skärmlåsning och SDDM
Comment[uk]=Кешувати картинку дня для екрана блокування та SDDM
Comment[x-test]=xxCache picture of the day for lock screen and SDDMxx
Comment[zh_CN]=为锁屏和 SDDM 缓存每日一图
Type=Service
X-KDE-ServiceTypes=KDEDModule
X-KDE-Library=potd
X-KDE-Kded-autoload=true
OnlyShowIn=KDE;
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-FileCopyrightText: 2020 Guo Yunhe <i@guoyunhe.me>
// SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org>
#ifndef KDED_POTD_H
#define KDED_POTD_H
#include <QObject>
#include <QString>
#include <KConfig>
#include <KConfigGroup>
#include <KDEDModule>
#include <Plasma/DataEngine>
#include <Plasma/DataEngineConsumer>
#include <KConfigWatcher>
class PotdModule: public KDEDModule
{
Q_OBJECT
public:
PotdModule(QObject* parent, const QList<QVariant>&);
virtual ~PotdModule();
private Q_SLOTS:
void configChanged();
private:
QString getSource();
Plasma::DataEngineConsumer *consumer = nullptr;
Plasma::DataEngine *engine = nullptr;
QString previousSource;
KSharedConfig::Ptr config;
KConfigWatcher::Ptr configWatcher;
};
#endif
Markdown is supported
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