| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/helper/helpersysctl.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "helpersysctl.h"cxx . . $ `<file>/src/helper/helpersysctl.h`/ |
| 5 | |
| 6 | #include "common/icryptolayer.h"cxx . . $ `<file>/src/common/icryptolayer.h`/ |
| 7 | #include "core/icommandqueue.h"cxx . . $ `<file>/src/core/icommandqueue.h`/ |
| 8 | #include "helperids.h"cxx . . $ `<file>/src/helper/helperids.h`/ |
| 9 | #include <QByteArray> |
| 10 | #include <QDBusConnection> |
| 11 | #include <QDBusInterface> |
| 12 | #include <QDBusPendingCall> |
| 13 | #include <QString> |
| 14 | #include <format> |
| 15 | #include <stdexcept> |
| 16 | #include <utility> |
| 17 | |
| 18 | HelperSysCtlcxx . . $ HelperSysCtl#::HelperSysCtlcxx . . $ HelperSysCtl#HelperSysCtl(4464ea89c5a0e04a).(stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<ICryptoLayercxx . . $ ICryptoLayer#> cryptoLayer, |
| 19 | bool logCommands) noexcept |
| 20 | : cryptoLayer_cxx . . $ HelperSysCtl#cryptoLayer_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(cryptoLayer)) |
| 21 | , logCommands_cxx . . $ HelperSysCtl#logCommands_.(logCommands) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | void HelperSysCtlcxx . . $ HelperSysCtl#::initcxx . . $ HelperSysCtl#init(49f6e7a06ebc5aa8).() |
| 26 | { |
| 27 | sysCtlInterface_cxx . . $ HelperSysCtl#sysCtlInterface_. =cxx . . $ std/unique_ptr#`operator=`(1b63e42eaa758a73). stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<QDBusInterfacecxx . . $ QDBusInterface#>( |
| 28 | QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!(DBUS_HELPER_SERVICEcxx . . $ `src/helper/helperids.h:13:9`!), |
| 29 | QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!(DBUS_HELPER_SYSCTL_PATHcxx . . $ `src/helper/helperids.h:19:9`!), |
| 30 | QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!(DBUS_HELPER_SYSCTL_INTERFACEcxx . . $ `src/helper/helperids.h:18:9`!), |
| 31 | QDBusConnectioncxx . . $ QDBusConnection#::systemBuscxx . . $ QDBusConnection#systemBus(45d475f1888103b2).()); |
| 32 | |
| 33 | if (!sysCtlInterface_cxx . . $ HelperSysCtl#sysCtlInterface_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).isValidcxx . . $ QDBusAbstractInterface#isValid(50ce9a9e25b4a850).()) { |
| 34 | throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#( |
| 35 | stdcxx . . $ std/::formatcxx . . $ std/format(7a9e6f4918cdc192).("Cannot connect to D-Bus interface {} (path: {})"cxx . . $ std/basic_format_string#basic_format_string(edcd8b2679e9bd1a)., |
| 36 | DBUS_HELPER_SYSCTL_INTERFACEcxx . . $ `src/helper/helperids.h:18:9`!, DBUS_HELPER_SYSCTL_PATHcxx . . $ `src/helper/helperids.h:19:9`!)); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | void HelperSysCtlcxx . . $ HelperSysCtl#::applycxx . . $ HelperSysCtl#apply(151e9138769f295e).(ICommandQueuecxx . . $ ICommandQueue# &ctlCmds) |
| 41 | { |
| 42 | if (logCommands_cxx . . $ HelperSysCtl#logCommands_.) |
| 43 | ctlCmds.logCommandscxx . . $ ICommandQueue#logCommands(83f5f38750778ac8).(); |
| 44 | |
| 45 | auto data = ctlCmds.toRawDatacxx . . $ ICommandQueue#toRawData(b3c286cec66e09f4).(); |
| 46 | if (!data.isEmptycxx . . $ QByteArray#isEmpty(3482b152b9333168).()) { |
| 47 | auto signature = cryptoLayer_cxx . . $ HelperSysCtl#cryptoLayer_.->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).signaturecxx . . $ ICryptoLayer#signature(ba1ae99d10185369).(data); |
| 48 | sysCtlInterface_cxx . . $ HelperSysCtl#sysCtlInterface_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).asyncCallcxx . . $ QDBusAbstractInterface#asyncCall(1ecb6b7bdc99c898).(QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!("apply"), data, signature); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | void HelperSysCtlcxx . . $ HelperSysCtl#::logCommandscxx . . $ HelperSysCtl#logCommands(b45ddcbc8423892c).(bool enable) |
| 53 | { |
| 54 | logCommands_cxx . . $ HelperSysCtl#logCommands_. = enable; |
| 55 | } |