Debian Codegraph @

src/helper/sysctl/msgreceiver.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/helper/sysctl/msgreceiver.cpp`/
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include "msgreceiver.h"cxx . . $ `<file>/src/helper/sysctl/msgreceiver.h`/
5
6 #include "common/icryptolayer.h"cxx . . $ `<file>/src/common/icryptolayer.h`/
7 #include "isysfswriter.h"cxx . . $ `<file>/src/helper/sysctl/isysfswriter.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 MsgReceivercxx . . $ MsgReceiver#::MsgReceivercxx . . $ MsgReceiver#MsgReceiver(f09e84cac6d7c2ff).(stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<ICryptoLayercxx . . $ ICryptoLayer#> cryptoLayer,
18 stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ISysfsWritercxx . . $ ISysfsWriter#> &&sysfsWriter,
19 QObjectcxx . . $ QObject# *parent)
20 : QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent)
21 , cryptoLayer_cxx . . $ MsgReceiver#cryptoLayer_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(cryptoLayer))
22 , sysfsWriter_cxx . . $ MsgReceiver#sysfsWriter_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(sysfsWriter))
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).(
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`!), this,
31 QDBusConnectioncxx . . $ QFlags#QFlags(93d577a3e9528307).::ExportScriptableSlotscxx . . $ QDBusConnection#ExportScriptableSlots.))
32 throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#(
33 stdcxx . . $ std/::formatcxx . . $ std/format(7a9e6f4918cdc192).("Could not register D-Bus object on path {} "cxx . . $ std/basic_format_string#basic_format_string(edcd8b2679e9bd1a).
34 "using the interface {}\n.Last D-Bus error: {}",
35 DBUS_HELPER_SYSCTL_PATHcxx . . $ `src/helper/helperids.h:19:9`!, DBUS_HELPER_SYSCTL_INTERFACEcxx . . $ `src/helper/helperids.h:18:9`!,
36 dbusConnection.lastErrorcxx . . $ QDBusConnection#lastError(1d9100e4f448fa26).().messagecxx . . $ QDBusError#message(6ef7b6c27b00b43d).().toStdStringcxx . . $ QString#toStdString(219584694fe2b248).()));
37 }
38
39 MsgReceivercxx . . $ MsgReceiver#::~cxx . . $ MsgReceiver#`~MsgReceiver`(ced63f7c635d850d).MsgReceivercxx . . $ MsgReceiver#()
40 {
41 QDBusConnectioncxx . . $ QDBusConnection# dbusConnection = QDBusConnectioncxx . . $ QDBusConnection#::systemBuscxx . . $ QDBusConnection#systemBus(45d475f1888103b2).();
42 dbusConnection.unregisterObjectcxx . . $ QDBusConnection#unregisterObject(1667c585e463f5a5).(QStringLiteralcxx . . $ `<external>/13954984326995544643/qstring.h:1789:9`!(DBUS_HELPER_SYSCTL_INTERFACEcxx . . $ `src/helper/helperids.h:18:9`!));
43 }
44
45 void MsgReceivercxx . . $ MsgReceiver#::applycxx . . $ MsgReceiver#apply(a34492a60dbd2bdc).(QByteArraycxx . . $ QByteArray# const &data, QByteArraycxx . . $ QByteArray# const &signature)
46 {
47 if (cryptoLayer_cxx . . $ MsgReceiver#cryptoLayer_.->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).verifycxx . . $ ICryptoLayer#verify(5ad6b2491b335728).(data, signature)) {
48 auto cmdList = data.splitcxx . . $ QByteArray#split(7e7c4c9f9d7ac60e).('\0');
49 for (int i = 0; i + 1 < cmdList.sizecxx . . $ QList#size(6b0412d51016192f).(); i += 2)
50 sysfsWriter_cxx . . $ MsgReceiver#sysfsWriter_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).writecxx . . $ ISysfsWriter#write(b03b73af961d2abd).(cmdListcxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).[cxx . . $ QList#`operator[]`(f5945173c490e616).i].datacxx . . $ QByteArray#data(41208ce6ca65dd58).(), cmdListcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).[cxx . . $ QList#`operator[]`(f5945173c490e616).i + 1].datacxx . . $ QByteArray#data(41208ce6ca65dd58).());
51 }
52 else
53 SPDLOG_DEBUGcxx . . $ `<external>/13613935168682455490/spdlog.h:311:13`!("Failed to verify received data from D-Bus");
54 }