File indexing completed on 2024-12-08 04:20:25
0001 /* 0002 * SPDX-License-Identifier: LGPL-2.0-or-later 0003 * SPDX-FileCopyrightText: 2016-2022 Red Hat Inc 0004 * SPDX-FileContributor: Jan Grulich <jgrulich@redhat.com> 0005 * SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org> 0006 */ 0007 0008 #pragma once 0009 0010 #include <memory> 0011 0012 #include <QDBusObjectPath> 0013 #include <QFlags> 0014 #include <QPointer> 0015 #include <QLoggingCategory> 0016 #include <QMainWindow> 0017 0018 #include "ui_xdgportaltest.h" 0019 0020 class QDBusMessage; 0021 class OrgFreedesktopPortalGlobalShortcutsInterface; 0022 0023 namespace Ui 0024 { 0025 class XdgPortalTest; 0026 } // namespace Ui 0027 0028 Q_DECLARE_LOGGING_CATEGORY(XdgPortalTestKde) 0029 0030 class XdgExporterV2; 0031 class XdgExportedV2; 0032 0033 class XdgPortalTest : public QMainWindow 0034 { 0035 Q_OBJECT 0036 public: 0037 struct Stream { 0038 uint node_id; 0039 QVariantMap map; 0040 } ; 0041 using Streams = QList<Stream>; 0042 0043 explicit XdgPortalTest(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()); 0044 ~XdgPortalTest(); 0045 0046 public Q_SLOTS: 0047 void gotCreateSessionResponse(uint response, const QVariantMap &results); 0048 void gotSelectSourcesResponse(uint response, const QVariantMap &results); 0049 void gotStartResponse(uint response, const QVariantMap &results); 0050 void gotPrintResponse(uint response, const QVariantMap &results); 0051 void gotPreparePrintResponse(uint response, const QVariantMap &results); 0052 void gotScreenshotResponse(uint response, const QVariantMap &results); 0053 void gotAccountResponse(uint response, const QVariantMap &results); 0054 void gotGlobalShortcutsCreateSessionResponse(uint, const QVariantMap &results); 0055 void gotListShortcutsResponse(uint, const QVariantMap &results); 0056 void inhibitRequested(); 0057 void uninhibitRequested(); 0058 void notificationActivated(const QString &label); 0059 void openFileRequested(); 0060 void openFileModalRequested(); 0061 void openDirRequested(); 0062 void openDirModalRequested(); 0063 void printDocument(); 0064 void requestDeviceAccess(); 0065 void saveFileRequested(); 0066 void sendNotification(); 0067 void sendNotificationPixmap(); 0068 void sendNotificationDefault(); 0069 void requestScreenSharing(); 0070 void requestScreenshot(); 0071 void requestAccount(); 0072 void chooseApplication(); 0073 void gotApplicationChoice(uint response, const QVariantMap &results); 0074 void addLauncher(); 0075 void gotLauncher(uint response, const QVariantMap &results); 0076 void removeLauncher(); 0077 void configureShortcuts(); 0078 0079 private: 0080 bool isRunningSandbox(); 0081 QString getSessionToken(); 0082 QString getRequestToken(); 0083 QString parentWindowId() const; 0084 0085 QDBusObjectPath m_inhibitionRequest; 0086 QString m_session; 0087 std::unique_ptr<Ui::XdgPortalTest> m_mainWindow; 0088 uint m_sessionTokenCounter; 0089 uint m_requestTokenCounter; 0090 0091 QScopedPointer<XdgExporterV2> m_xdgExporter; 0092 QPointer<XdgExportedV2> m_xdgExported; 0093 QString m_globalShortcutsSessionToken; 0094 QDBusObjectPath m_globalShortcutsSession; 0095 OrgFreedesktopPortalGlobalShortcutsInterface *m_shortcuts; 0096 };