File indexing completed on 2024-02-25 17:31:05

0001 /*
0002  * SPDX-FileCopyrightText: 2016 Red Hat Inc
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  *
0006  * SPDX-FileCopyrightText: 2016 Jan Grulich <jgrulich@redhat.com>
0007  */
0008 
0009 #include <QApplication>
0010 #include <QDBusConnection>
0011 
0012 #include <KAboutData>
0013 #include <KLocalizedString>
0014 
0015 #include "../version.h"
0016 #include "debug.h"
0017 #include "desktopportal.h"
0018 
0019 int main(int argc, char *argv[])
0020 {
0021     QCoreApplication::setAttribute(Qt::AA_DisableSessionManager);
0022 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0023     QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
0024 #endif
0025     QApplication a(argc, argv);
0026     a.setQuitOnLastWindowClosed(false);
0027 
0028     KAboutData about(QStringLiteral("xdg-desktop-portal-kde"), i18n("Portal"), QStringLiteral(XDPK_VERSION_STRING));
0029     about.setDesktopFileName(QStringLiteral("org.freedesktop.impl.portal.desktop.kde"));
0030     KAboutData::setApplicationData(about);
0031 
0032     QDBusConnection sessionBus = QDBusConnection::sessionBus();
0033 
0034     if (sessionBus.registerService(QStringLiteral("org.freedesktop.impl.portal.desktop.kde"))) {
0035         DesktopPortal *desktopPortal = new DesktopPortal(&a);
0036         if (sessionBus.registerObject(QStringLiteral("/org/freedesktop/portal/desktop"), desktopPortal, QDBusConnection::ExportAdaptors)) {
0037             qCDebug(XdgDesktopPortalKde) << "Desktop portal registered successfully";
0038         } else {
0039             qCDebug(XdgDesktopPortalKde) << "Failed to register desktop portal";
0040         }
0041     } else {
0042         qCDebug(XdgDesktopPortalKde) << "Failed to register org.freedesktop.impl.portal.desktop.kde service";
0043         return 1;
0044     }
0045 
0046     return a.exec();
0047 }