gk_system.hpp 4.11 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 **     __                 _ _   __    __           _     _ 
 **    / _\_ __ ___   __ _| | | / / /\ \ \___  _ __| | __| |
 **    \ \| '_ ` _ \ / _` | | | \ \/  \/ / _ \| '__| |/ _` |
 **    _\ \ | | | | | (_| | | |  \  /\  / (_) | |  | | (_| |
 **    \__/_| |_| |_|\__,_|_|_|   \/  \/ \___/|_|  |_|\__,_|
 **                                                         
 **                  ___     _                              
 **                 /   \___| |_   ___  _____               
 **                / /\ / _ \ | | | \ \/ / _ \              
 **               / /_//  __/ | |_| |>  <  __/              
 **              /___,' \___|_|\__,_/_/\_\___|              
 **
 **
 **   If you have downloaded the source code for "Small World Deluxe" and are reading this,
 **   then thank you from the bottom of our hearts for making use of our hard work, sweat
 **   and tears in whatever you are implementing this into!
 **
Phobos D'thorga's avatar
Phobos D'thorga committed
19
 **   Copyright (C) 2020 - 2021. GekkoFyre.
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 **
 **   Small World Deluxe is free software: you can redistribute it and/or modify
 **   it under the terms of the GNU General Public License as published by
 **   the Free Software Foundation, either version 3 of the License, or
 **   (at your option) any later version.
 **
 **   Small World is distributed in the hope that it will be useful,
 **   but WITHOUT ANY WARRANTY; without even the implied warranty of
 **   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 **   GNU General Public License for more details.
 **
 **   You should have received a copy of the GNU General Public License
 **   along with Small World Deluxe.  If not, see <http://www.gnu.org/licenses/>.
 **
 **
 **   The latest source code updates can be obtained from [ 1 ] below at your
 **   discretion. A web-browser or the 'git' application may be required.
 **
38
 **   [ 1 ] - https://code.gekkofyre.io/amateur-radio/small-world-deluxe
39
40
41
42
43
44
 **
 ****************************************************************************************************/

#pragma once

#include "src/defines.hpp"
45
46
#include "src/gk_string_funcs.hpp"
#include "src/gk_logger.hpp"
47
#include <string>
48
#include <cstdio>
49
50
#include <QObject>
#include <QString>
51
#include <QPointer>
52

53
#if defined(_WIN32) || defined(__MINGW64__) || defined(__CYGWIN__)
54
55
56
57
58
59
60
#include <windows.h>
#include <crtdbg.h>
#include <netfw.h>
#include <objbase.h>
#include <oleauto.h>
#endif

61
62
63
64
65
66
namespace GekkoFyre {

class GkSystem : public QObject {
    Q_OBJECT

public:
67
    explicit GkSystem(QPointer<GekkoFyre::StringFuncs> stringFuncs, QObject *parent = nullptr);
68
69
    ~GkSystem() override;

Phobos D'thorga's avatar
   
Phobos D'thorga committed
70
    bool isInternetAvailable();
71
    qint32 getNumCpuCores();
72
    QString renameCommsDevice(const qint32 &port, const GekkoFyre::AmateurRadio::GkConnType &conn_type);
73

74
75
76
77
78
79
80
81
82
    #if defined(_WIN32) || defined(__MINGW64__) || defined(__CYGWIN__)
    HRESULT WindowsFirewallInitialize(OUT INetFwProfile **fwProfile);
    HRESULT WindowsFirewallIsOn(IN INetFwProfile *fwProfile, OUT BOOL *fwOn);
    HRESULT WindowsFirewallAppIsEnabled(IN INetFwProfile *fwProfile, IN const wchar_t *fwProcessImageFileName, OUT BOOL *fwAppEnabled);
    HRESULT WindowsFirewallTurnOn(IN INetFwProfile *fwProfile);
    HRESULT WindowsFirewallTurnOff(IN INetFwProfile *fwProfile);
    HRESULT WindowsFirewallAddApp(IN INetFwProfile *fwProfile, IN const wchar_t *fwProcessImageFileName, IN const wchar_t *fwName);
    HRESULT WindowsFirewallPortIsEnabled(IN INetFwProfile *fwProfile, IN LONG portNumber, IN NET_FW_IP_PROTOCOL ipProtocol, OUT BOOL *fwPortEnabled);
    HRESULT WindowsFirewallPortAdd(IN INetFwProfile *fwProfile, IN LONG portNumber, IN NET_FW_IP_PROTOCOL ipProtocol, IN const wchar_t *name);
83
84

    static QString processHResult(const HRESULT &hr);
85
86
87
88
89
90
91
92
93
94
    #endif

signals:
    void publishEventMsg(const QString &event, const GekkoFyre::System::Events::Logging::GkSeverity &severity = GekkoFyre::System::Events::Logging::GkSeverity::Warning,
                         const QVariant &arguments = "", const bool &sys_notification = false, const bool &publishToConsole = true, const bool &publishToStatusBar = false,
                         const bool &displayMsgBox = false);

private:
    QPointer<GekkoFyre::StringFuncs> gkStringFuncs;

95
};
96
};