| 1 | /* |
| 2 | This file is part of the KDE libraries |
| 3 | SPDX-FileCopyrightText: 2009 Shaun Reich <shaun.reich@kdemail.net> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #include "joburlcache_p.h" |
| 9 | |
| 10 | #ifdef WITH_QTDBUS |
| 11 | #include "kuiserver_interface.h" |
| 12 | #endif |
| 13 | |
| 14 | class JobUrlCacheSingleton |
| 15 | { |
| 16 | public: |
| 17 | JobUrlCache instance; |
| 18 | }; |
| 19 | |
| 20 | Q_GLOBAL_STATIC(JobUrlCacheSingleton, s_jobUrlCache) |
| 21 | |
| 22 | JobUrlCache &JobUrlCache::instance() |
| 23 | { |
| 24 | return s_jobUrlCache()->instance; |
| 25 | } |
| 26 | |
| 27 | JobUrlCache::JobUrlCache() |
| 28 | : QObject(nullptr) |
| 29 | { |
| 30 | #ifdef WITH_QTDBUS |
| 31 | org::kde::kuiserver *interface = |
| 32 | new org::kde::kuiserver(QStringLiteral("org.kde.kuiserver" ), QStringLiteral("/JobViewServer" ), QDBusConnection::sessionBus(), this); |
| 33 | |
| 34 | // connect to receive updates about the job urls |
| 35 | connect(sender: interface, signal: &OrgKdeKuiserverInterface::jobUrlsChanged, context: this, slot: &JobUrlCache::slotJobUrlsChanged); |
| 36 | |
| 37 | // force signal emission |
| 38 | interface->emitJobUrlsChanged(); |
| 39 | #endif |
| 40 | } |
| 41 | |
| 42 | JobUrlCache::~JobUrlCache() |
| 43 | { |
| 44 | } |
| 45 | |
| 46 | void JobUrlCache::slotJobUrlsChanged(const QStringList &urlList) |
| 47 | { |
| 48 | m_destUrls = urlList; |
| 49 | Q_EMIT jobUrlsChanged(urlList); |
| 50 | } |
| 51 | |
| 52 | void JobUrlCache::requestJobUrlsChanged() |
| 53 | { |
| 54 | Q_EMIT jobUrlsChanged(m_destUrls); |
| 55 | } |
| 56 | |
| 57 | #include "moc_joburlcache_p.cpp" |
| 58 | |