File indexing completed on 2024-04-14 05:38:14

0001 /*
0002     SPDX-FileCopyrightText: 2018-2020 Harald Sitter <sitter@kde.org>
0003     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 */
0005 
0006 #include "dbusinterface.h"
0007 
0008 #include <QCoreApplication>
0009 
0010 #include "debug.h"
0011 #include "distroreleasenotifieradaptor.h"
0012 
0013 DBusInterface::DBusInterface(QObject *parent)
0014     : QObject(parent)
0015     , m_useDevel(qEnvironmentVariableIsSet("DEVEL_RELEASE"))
0016 {
0017     new DistroReleaseNotifierAdaptor(this);
0018     QDBusConnection dbus = QDBusConnection::sessionBus();
0019     const bool objectRet = dbus.registerObject(QStringLiteral("/org/kde/DistroReleaseNotifier"), this);
0020     const bool serviceRet = dbus.registerService(QStringLiteral("org.kde.DistroReleaseNotifier"));
0021     if (!objectRet || !serviceRet) {
0022         // If this build isn't qFatal, manually exit on errors.
0023         // We'd not get here if it was fatal!
0024         qCritical() << "Failed to register org.kde.DistroReleaseNotifier" << objectRet << serviceRet;
0025     }
0026 }
0027 
0028 bool DBusInterface::useDevel() const
0029 {
0030     return m_useDevel;
0031 }
0032 
0033 void DBusInterface::setUseDevel(bool use)
0034 {
0035     if (m_useDevel == use) {
0036         return;
0037     }
0038     m_useDevel = use;
0039     emit useDevelChanged();
0040 }
0041 
0042 void DBusInterface::Poll()
0043 {
0044     emit pollingRequested();
0045 }