File indexing completed on 2024-04-14 03:53:30

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2009 Shaun Reich <shaun.reich@kdemail.net>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #include "joburlcache_p.h"
0009 #include "kuiserver_interface.h"
0010 
0011 class JobUrlCacheSingleton
0012 {
0013 public:
0014     JobUrlCache instance;
0015 };
0016 
0017 Q_GLOBAL_STATIC(JobUrlCacheSingleton, s_jobUrlCache)
0018 
0019 JobUrlCache &JobUrlCache::instance()
0020 {
0021     return s_jobUrlCache()->instance;
0022 }
0023 
0024 JobUrlCache::JobUrlCache()
0025     : QObject(nullptr)
0026 {
0027     org::kde::kuiserver *interface =
0028         new org::kde::kuiserver(QStringLiteral("org.kde.kuiserver"), QStringLiteral("/JobViewServer"), QDBusConnection::sessionBus(), this);
0029 
0030     // connect to receive updates about the job urls
0031     connect(interface, &OrgKdeKuiserverInterface::jobUrlsChanged, this, &JobUrlCache::slotJobUrlsChanged);
0032 
0033     // force signal emission
0034     interface->emitJobUrlsChanged();
0035 }
0036 
0037 JobUrlCache::~JobUrlCache()
0038 {
0039 }
0040 
0041 void JobUrlCache::slotJobUrlsChanged(const QStringList &urlList)
0042 {
0043     m_destUrls = urlList;
0044     Q_EMIT jobUrlsChanged(urlList);
0045 }
0046 
0047 void JobUrlCache::requestJobUrlsChanged()
0048 {
0049     Q_EMIT jobUrlsChanged(m_destUrls);
0050 }
0051 
0052 #include "moc_joburlcache_p.cpp"