| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/helper/pmon/msgdispatcher.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "msgdispatcher.h"cxx . . $ `<file>/src/helper/pmon/msgdispatcher.h`/ |
| 5 | |
| 6 | #include "common/icryptolayer.h"cxx . . $ `<file>/src/common/icryptolayer.h`/ |
| 7 | #include "iappregistry.h"cxx . . $ `<file>/src/helper/pmon/iappregistry.h`/ |
| 8 | #include <QByteArray> |
| 9 | #include <QDBusConnection> |
| 10 | #include <QDBusError> |
| 11 | #include <QString> |
| 12 | #include <format> |
| 13 | #include <spdlog/spdlog.h> |
| 14 | #include <stdexcept> |
| 15 | #include <utility> |
| 16 | |
| 17 | DBusSignalDispatchercxx . . $ DBusSignalDispatcher#::DBusSignalDispatchercxx . . $ DBusSignalDispatcher#DBusSignalDispatcher(52eb8ef2a4488c3d).( |
| 18 | stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<ICryptoLayercxx . . $ ICryptoLayer#> cryptoLayer, |
| 19 | stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<IAppRegistrycxx . . $ IAppRegistry#> appRegistry, QObjectcxx . . $ QObject# *parent) |
| 20 | : QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent) |
| 21 | , cryptoLayer_cxx . . $ DBusSignalDispatcher#cryptoLayer_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(cryptoLayer)) |
| 22 | , appRegistry_cxx . . $ DBusSignalDispatcher#appRegistry_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(appRegistry)) |
| 23 | { |
| 24 | QDBusConnectioncxx . . $ QDBusConnection# dbusConnection = QDBusConnectioncxx . . $ QDBusConnection#::systemBuscxx . . $ QDBusConnection#systemBus(45d475f1888103b2).(); |
| 25 | if (!dbusConnection.isConnectedcxx . . $ QDBusConnection#isConnected(50ce9a9e25b4a850).()) |
| 26 | throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#("Could not connect to D-Bus system bus"); |
| 27 | |
| 28 | if (!dbusConnection.registerObjectcxx . . $ QDBusConnection#registerObject(a928bb5ef280441a).(QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!(DBUS_HELPER_PMON_PATHcxx . . $ `src/helper/helperids.h:17:9`!), |
| 29 | QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!(DBUS_HELPER_PMON_INTERFACEcxx . . $ `src/helper/helperids.h:16:9`!), |
| 30 | this, |
| 31 | QDBusConnectioncxx . . $ QDBusConnection#::ExportScriptableSignalscxx . . $ QDBusConnection#ExportScriptableSignals. |cxx . . $ `operator|`(38ea3bc15fa63abf). |
| 32 | QDBusConnectioncxx . . $ QDBusConnection#::ExportScriptableSlotscxx . . $ QDBusConnection#ExportScriptableSlots.)) |
| 33 | throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#( |
| 34 | stdcxx . . $ std/::formatcxx . . $ std/format(7a9e6f4918cdc192).("Could not register D-Bus object on path {} "cxx . . $ std/basic_format_string#basic_format_string(edcd8b2679e9bd1a). |
| 35 | "using the interface {}\n.Last D-Bus error: {}", |
| 36 | DBUS_HELPER_PMON_PATHcxx . . $ `src/helper/helperids.h:17:9`!, DBUS_HELPER_PMON_INTERFACEcxx . . $ `src/helper/helperids.h:16:9`!, |
| 37 | dbusConnection.lastErrorcxx . . $ QDBusConnection#lastError(1d9100e4f448fa26).().messagecxx . . $ QDBusError#message(6ef7b6c27b00b43d).().toStdStringcxx . . $ QString#toStdString(219584694fe2b248).())); |
| 38 | } |
| 39 | |
| 40 | DBusSignalDispatchercxx . . $ DBusSignalDispatcher#::~cxx . . $ DBusSignalDispatcher#`~DBusSignalDispatcher`(ced63f7c635d850d).DBusSignalDispatchercxx . . $ DBusSignalDispatcher#() |
| 41 | { |
| 42 | QDBusConnectioncxx . . $ QDBusConnection# dbusConnection = QDBusConnectioncxx . . $ QDBusConnection#::systemBuscxx . . $ QDBusConnection#systemBus(45d475f1888103b2).(); |
| 43 | dbusConnection.unregisterObjectcxx . . $ QDBusConnection#unregisterObject(1667c585e463f5a5).(QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!(DBUS_HELPER_PMON_INTERFACEcxx . . $ `src/helper/helperids.h:16:9`!)); |
| 44 | } |
| 45 | |
| 46 | void DBusSignalDispatchercxx . . $ DBusSignalDispatcher#::sendExeccxx . . $ DBusSignalDispatcher#sendExec(45672f3c6961a244).(QByteArraycxx . . $ QByteArray# const &data) |
| 47 | { |
| 48 | auto signature = cryptoLayer_cxx . . $ DBusSignalDispatcher#cryptoLayer_.->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).signaturecxx . . $ ICryptoLayer#signature(ba1ae99d10185369).(data); |
| 49 | emitcxx . . $ `<external>/4830994369567095248/qtmetamacros.h:51:10`! appExeccxx . . $ DBusSignalDispatcher#appExec(a34492a60dbd2bdc).(data, signature); |
| 50 | } |
| 51 | |
| 52 | void DBusSignalDispatchercxx . . $ DBusSignalDispatcher#::sendExitcxx . . $ DBusSignalDispatcher#sendExit(45672f3c6961a244).(QByteArraycxx . . $ QByteArray# const &data) |
| 53 | { |
| 54 | auto signature = cryptoLayer_cxx . . $ DBusSignalDispatcher#cryptoLayer_.->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).signaturecxx . . $ ICryptoLayer#signature(ba1ae99d10185369).(data); |
| 55 | emitcxx . . $ `<external>/4830994369567095248/qtmetamacros.h:51:10`! appExitcxx . . $ DBusSignalDispatcher#appExit(a34492a60dbd2bdc).(data, signature); |
| 56 | } |
| 57 | |
| 58 | void DBusSignalDispatchercxx . . $ DBusSignalDispatcher#::watchAppcxx . . $ DBusSignalDispatcher#watchApp(a34492a60dbd2bdc).(QByteArraycxx . . $ QByteArray# const &data, |
| 59 | QByteArraycxx . . $ QByteArray# const &signature) |
| 60 | { |
| 61 | if (cryptoLayer_cxx . . $ DBusSignalDispatcher#cryptoLayer_.->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).verifycxx . . $ ICryptoLayer#verify(5ad6b2491b335728).(data, signature)) |
| 62 | appRegistry_cxx . . $ DBusSignalDispatcher#appRegistry_.->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).addcxx . . $ IAppRegistry#add(9c546c94e5fcce4e).(data.toStdStringcxx . . $ QByteArray#toStdString(219584694fe2b248).()); |
| 63 | else |
| 64 | SPDLOG_DEBUGcxx . . $ `<external>/13613935168682455490/spdlog.h:311:13`!("Failed to verify received data from D-Bus"); |
| 65 | } |
| 66 | |
| 67 | void DBusSignalDispatchercxx . . $ DBusSignalDispatcher#::forgetAppcxx . . $ DBusSignalDispatcher#forgetApp(a34492a60dbd2bdc).(QByteArraycxx . . $ QByteArray# const &data, |
| 68 | QByteArraycxx . . $ QByteArray# const &signature) |
| 69 | { |
| 70 | if (cryptoLayer_cxx . . $ DBusSignalDispatcher#cryptoLayer_.->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).verifycxx . . $ ICryptoLayer#verify(5ad6b2491b335728).(data, signature)) |
| 71 | appRegistry_cxx . . $ DBusSignalDispatcher#appRegistry_.->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).removecxx . . $ IAppRegistry#remove(9c546c94e5fcce4e).(data.toStdStringcxx . . $ QByteArray#toStdString(219584694fe2b248).()); |
| 72 | else |
| 73 | SPDLOG_DEBUGcxx . . $ `<external>/13613935168682455490/spdlog.h:311:13`!("Failed to verify received data from D-Bus"); |
| 74 | } |
| 75 | |
| 76 | MsgDispatchercxx . . $ MsgDispatcher#::MsgDispatchercxx . . $ MsgDispatcher#MsgDispatcher(52eb8ef2a4488c3d).(stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<ICryptoLayercxx . . $ ICryptoLayer#> cryptoLayer, |
| 77 | stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<IAppRegistrycxx . . $ IAppRegistry#> appRegistry, |
| 78 | QObjectcxx . . $ QObject# *parent) |
| 79 | : QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent) |
| 80 | , dbusSignalDispatcher_cxx . . $ MsgDispatcher#dbusSignalDispatcher_.(stdcxx . . $ std/shared_ptr#shared_ptr(e98954a1f10335bf).::movecxx . . $ std/move(e35c19a1ba7baa26).(cryptoLayer), stdcxx . . $ std/shared_ptr#shared_ptr(e98954a1f10335bf).::movecxx . . $ std/move(e35c19a1ba7baa26).(appRegistry), this) |
| 81 | { |
| 82 | connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(this, &MsgDispatchercxx . . $ MsgDispatcher#::appExeccxx . . $ MsgDispatcher#appExec(45672f3c6961a244)., &dbusSignalDispatcher_cxx . . $ MsgDispatcher#dbusSignalDispatcher_., |
| 83 | &DBusSignalDispatchercxx . . $ DBusSignalDispatcher#::sendExeccxx . . $ DBusSignalDispatcher#sendExec(45672f3c6961a244).); |
| 84 | connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(this, &MsgDispatchercxx . . $ MsgDispatcher#::appExitcxx . . $ MsgDispatcher#appExit(45672f3c6961a244)., &dbusSignalDispatcher_cxx . . $ MsgDispatcher#dbusSignalDispatcher_., |
| 85 | &DBusSignalDispatchercxx . . $ DBusSignalDispatcher#::sendExitcxx . . $ DBusSignalDispatcher#sendExit(45672f3c6961a244).); |
| 86 | } |
| 87 | |
| 88 | void MsgDispatchercxx . . $ MsgDispatcher#::sendExeccxx . . $ MsgDispatcher#sendExec(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app) |
| 89 | { |
| 90 | emitcxx . . $ `<external>/4830994369567095248/qtmetamacros.h:51:10`! appExeccxx . . $ MsgDispatcher#appExec(45672f3c6961a244).({cxx . . $ QByteArray#QByteArray(de40a1f2d6082f12).app.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()}); |
| 91 | } |
| 92 | |
| 93 | void MsgDispatchercxx . . $ MsgDispatcher#::sendExitcxx . . $ MsgDispatcher#sendExit(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app) |
| 94 | { |
| 95 | emitcxx . . $ `<external>/4830994369567095248/qtmetamacros.h:51:10`! appExitcxx . . $ MsgDispatcher#appExit(45672f3c6961a244).({cxx . . $ QByteArray#QByteArray(de40a1f2d6082f12).app.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()}); |
| 96 | } |