File indexing completed on 2024-05-12 05:46:44

0001 /*****************************************************************************
0002 *  This file is part of the KDE libraries                                    *
0003 *  Copyright (C) 2009 by Shaun Reich <shaun.reich@kdemail.net>               *
0004 *                                                                            *
0005 *  This library is free software; you can redistribute it and/or modify      *
0006 *  it under the terms of the GNU Lesser General Public License as published  *
0007 *  by the Free Software Foundation; either version 2 of the License or (at   *
0008 *  your option) any later version.                                           *
0009 *                                                                            *
0010 *  This library is distributed in the hope that it will be useful,           *
0011 *  but WITHOUT ANY WARRANTY; without even the implied warranty of            *
0012 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
0013 *  Library General Public License for more details.                          *
0014 *                                                                            *
0015 *  You should have received a copy of the GNU Lesser General Public License  *
0016 *  along with this library; see the file COPYING.LIB.                        *
0017 *  If not, see <http://www.gnu.org/licenses/>.                               *
0018 *****************************************************************************/
0019 
0020 #include "joburlcache_p.h"
0021 #include "kuiserver_interface.h"
0022 
0023 class JobUrlCacheSingleton
0024 {
0025 public:
0026     JobUrlCache instance;
0027 };
0028 
0029 Q_GLOBAL_STATIC(JobUrlCacheSingleton, s_jobUrlCache)
0030 
0031 JobUrlCache &JobUrlCache::instance()
0032 {
0033     return s_jobUrlCache()->instance;
0034 }
0035 
0036 JobUrlCache::JobUrlCache() : QObject(nullptr)
0037 {
0038     org::kde::kuiserver *interface = new
0039     org::kde::kuiserver(QStringLiteral("org.kde.kuiserver"), QStringLiteral("/JobViewServer"), QDBusConnection::sessionBus(), this);
0040 
0041     //connect to receive updates about the job urls
0042     connect(interface, &OrgKdeKuiserverInterface::jobUrlsChanged,
0043             this, &JobUrlCache::slotJobUrlsChanged);
0044 
0045     //force signal emission
0046     interface->emitJobUrlsChanged();
0047 }
0048 
0049 JobUrlCache::~JobUrlCache()
0050 {
0051 }
0052 
0053 void JobUrlCache::slotJobUrlsChanged(const QStringList &urlList)
0054 {
0055     m_destUrls = urlList;
0056     emit jobUrlsChanged(urlList);
0057 }
0058 
0059 void JobUrlCache::requestJobUrlsChanged()
0060 {
0061     emit jobUrlsChanged(m_destUrls);
0062 }
0063 
0064 #include "moc_joburlcache_p.cpp"