File: devposture-signals.hpp

package info (click to toggle)
openvpn3-client 25%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,276 kB
  • sloc: cpp: 190,085; python: 7,218; ansic: 1,866; sh: 1,361; java: 402; lisp: 81; makefile: 17
file content (68 lines) | stat: -rw-r--r-- 1,972 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//  OpenVPN 3 Linux client -- Next generation OpenVPN client
//
//  SPDX-License-Identifier: AGPL-3.0-only
//
//  Copyright (C) 2017-  OpenVPN Inc <sales@openvpn.net>
//  Copyright (C) 2017-  David Sommerseth <davids@openvpn.net>
//  Copyright (C) 2018-  Arne Schwabe <arne@openvpn.net>
//  Copyright (C) 2018-  Lev Stipakov <lev@openvpn.net>
//  Copyright (C) 2024-  Răzvan Cojocaru <razvan.cojocaru@openvpn.com>
//

/**
 * @file devposture-signals.hpp
 *
 * @brief Declaration helper classes handling D-Bus signals for
 *        net.openvpn.v3.devposture
 */

#pragma once

#include <memory>
#include <gdbuspp/connection.hpp>
#include <gdbuspp/signals/signal.hpp>
#include <gdbuspp/signals/subscriptionmgr.hpp>
#include <events/attention-req.hpp>
#include <events/status.hpp>
#include <log/dbus-log.hpp>

namespace DevPosture {

/**
 * Helper class to tackle signals sent by the session manager
 *
 * This mostly just wraps the LogSender class and predefines LogGroup to always
 * be EXTSERVICE.
 */
class Log : public LogSender
{
  public:
    using Ptr = std::shared_ptr<Log>;

    [[nodiscard]] static Log::Ptr Create(DBus::Connection::Ptr conn,
                                         LogGroup lgroup,
                                         const std::string &object_path,
                                         LogWriter::Ptr logwr);
    ~Log() = default;

    /**
     *  Whenever a FATAL error happens, the process is expected to stop.
     *  The abort() call gets caught by the main loop, which then starts the
     *  proper shutdown process.
     *
     * @param msg  Message to sent to the log subscribers
     */
    void LogFATAL(const std::string &msg) override;

  private:
    const std::string object_path;
    const std::string object_interface;
    uint8_t default_log_level = 6;

    Log(DBus::Connection::Ptr conn,
        LogGroup lgroup,
        const std::string &object_path_,
        LogWriter::Ptr logwr);
};

} // namespace DevPosture