Deskflow
1.26.0.418
Keyboard and mouse sharing utility
Toggle main menu visibility
Loading...
Searching...
No Matches
App.h
Go to the documentation of this file.
1
/*
2
* Deskflow -- mouse and keyboard sharing utility
3
* SPDX-FileCopyrightText: (C) 2026 Deskflow Developers
4
* SPDX-FileCopyrightText: (C) 2012 - 2026 Synergy App Ltd
5
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
6
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
7
*/
8
9
#pragma once
10
11
#include "
base/EventQueue.h
"
12
#include "
base/Log.h
"
13
#include "
common/ExitCodes.h
"
14
#include "
deskflow/IApp.h
"
15
#include "
net/SocketMultiplexer.h
"
16
17
#if defined(Q_OS_WIN)
18
#include "
deskflow/win32/AppUtilWindows.h
"
19
#else
20
#include "
deskflow/unix/AppUtilUnix.h
"
21
#endif
22
23
#include <QObject>
24
#include <QThread>
25
26
#include <memory>
27
#include <stdexcept>
28
29
namespace
deskflow
{
30
class
Screen
;
31
}
32
33
class
FileLogOutputter
;
34
class
IEventQueue
;
35
class
SocketMultiplexer
;
36
37
class
App
:
public
QObject,
private
IApp
38
{
39
public
:
40
class
XNoEiSupport
:
public
std::runtime_error
41
{
42
public
:
43
XNoEiSupport
() :
std
::runtime_error(
"libei is not supported"
)
44
{
45
// do nothing
46
}
47
};
48
49
explicit
App
(
IEventQueue
*events,
const
QString &
processName
);
50
App
(
App
const
&) =
delete
;
51
App
(
App
&&) =
delete
;
52
~App
()
override
;
53
54
App
&
operator=
(
App
const
&) =
delete
;
55
App
&
operator=
(
App
&&) =
delete
;
56
57
virtual
void
parseArgs
() = 0;
58
virtual
void
loadConfig
() = 0;
59
virtual
bool
loadConfig
(
const
QString &filename) = 0;
60
61
void
setByeFunc
(
void
(*
bye
)(
int
))
override
62
{
63
m_bye =
bye
;
64
}
65
void
bye
(
int
error)
override
66
{
67
m_bye(error);
68
}
69
IEventQueue
*
getEvents
()
const override
70
{
71
return
m_events;
72
}
73
74
ARCH_APP_UTIL
&
appUtil
()
75
{
76
return
m_appUtil;
77
}
78
79
void
run
(QThread &coreThread);
80
void
quit
()
const
;
81
void
setupFileLogging
();
82
void
loggingFilterWarning
()
const
;
83
void
initApp
()
override
;
84
85
void
setEvents
(
EventQueue
&events)
86
{
87
m_events = &events;
88
}
89
void
setSocketMultiplexer
(std::unique_ptr<SocketMultiplexer> &&sm)
90
{
91
m_socketMultiplexer = std::move(sm);
92
}
93
94
SocketMultiplexer
*
getSocketMultiplexer
()
const
95
{
96
return
m_socketMultiplexer.get();
97
}
98
99
static
App
&
instance
()
100
{
101
assert(s_instance !=
nullptr
);
102
return
*s_instance;
103
}
104
105
QString
processName
()
const
106
{
107
return
m_pname;
108
}
109
110
void
handleScreenError
()
const
;
111
112
void
updateExitCode
(
int
errorCode)
113
{
114
m_exitCode = errorCode;
115
}
116
117
int
getExitCode
()
const
118
{
119
return
m_exitCode;
120
}
121
122
protected
:
123
void
runEventsLoop
(
const
void
*);
124
125
struct
LoopErrorCode
126
{
127
int
m_errorCode
;
128
explicit
LoopErrorCode
(
int
errorCode) :
m_errorCode
(errorCode)
129
{
130
}
131
};
132
133
private
:
134
void (*m_bye)(int);
135
IEventQueue
*m_events =
nullptr
;
136
static
App
*s_instance;
137
FileLogOutputter
*m_fileLog =
nullptr
;
138
ARCH_APP_UTIL
m_appUtil;
139
std::unique_ptr<SocketMultiplexer> m_socketMultiplexer;
140
QString m_pname;
141
int
m_exitCode = s_exitSuccess;
142
};
143
144
#if !defined(WINAPI_LIBEI) && WINAPI_XWINDOWS
145
constexpr
static
auto
s_helpNoWayland
=
//
146
"\nYour Linux distribution does not support Wayland EI (emulated input)\n"
147
"which is required for Wayland support. Please use a Linux distribution\n"
148
"that supports Wayland EI.\n"
;
149
150
#else
151
constexpr
static
auto
s_helpNoWayland
=
""
;
152
#endif
AppUtilUnix.h
ARCH_APP_UTIL
#define ARCH_APP_UTIL
Definition
AppUtilUnix.h:12
AppUtilWindows.h
s_helpNoWayland
static constexpr auto s_helpNoWayland
Definition
App.h:151
EventQueue.h
ExitCodes.h
IApp.h
Log.h
SocketMultiplexer.h
App::XNoEiSupport::XNoEiSupport
XNoEiSupport()
Definition
App.h:43
App
Definition
App.h:38
App::updateExitCode
void updateExitCode(int errorCode)
Definition
App.h:112
App::getEvents
IEventQueue * getEvents() const override
Definition
App.h:69
App::loadConfig
virtual void loadConfig()=0
App::instance
static App & instance()
Definition
App.h:99
App::loadConfig
virtual bool loadConfig(const QString &filename)=0
App::App
App(App const &)=delete
App::getSocketMultiplexer
SocketMultiplexer * getSocketMultiplexer() const
Definition
App.h:94
App::operator=
App & operator=(App &&)=delete
App::loggingFilterWarning
void loggingFilterWarning() const
Definition
App.cpp:134
App::App
App(IEventQueue *events, const QString &processName)
Definition
App.cpp:41
App::setupFileLogging
void setupFileLogging()
Definition
App.cpp:124
App::setByeFunc
void setByeFunc(void(*bye)(int)) override
Definition
App.h:61
App::initApp
void initApp() override
Definition
App.cpp:144
App::getExitCode
int getExitCode() const
Definition
App.h:117
App::quit
void quit() const
Definition
App.cpp:171
App::run
void run(QThread &coreThread)
Definition
App.cpp:59
App::processName
QString processName() const
Definition
App.h:105
App::App
App(App &&)=delete
App::appUtil
ARCH_APP_UTIL & appUtil()
Definition
App.h:74
App::runEventsLoop
void runEventsLoop(const void *)
Definition
App.cpp:177
App::parseArgs
virtual void parseArgs()=0
App::bye
void bye(int error) override
Definition
App.h:65
App::operator=
App & operator=(App const &)=delete
App::setEvents
void setEvents(EventQueue &events)
Definition
App.h:85
App::setSocketMultiplexer
void setSocketMultiplexer(std::unique_ptr< SocketMultiplexer > &&sm)
Definition
App.h:89
App::handleScreenError
void handleScreenError() const
Definition
App.cpp:165
EventQueue
Event queue.
Definition
EventQueue.h:29
FileLogOutputter
Write log to file.
Definition
LogOutputters.h:57
IApp
Definition
IApp.h:20
IEventQueue
Event queue interface.
Definition
IEventQueue.h:29
SocketMultiplexer
Socket multiplexer.
Definition
SocketMultiplexer.h:24
deskflow::Screen
Platform independent screen.
Definition
Screen.h:30
deskflow
Definition
DaemonApp.h:18
std
Definition
Config.h:29
App::LoopErrorCode::m_errorCode
int m_errorCode
Definition
App.h:127
App::LoopErrorCode::LoopErrorCode
LoopErrorCode(int errorCode)
Definition
App.h:128
src
lib
deskflow
App.h
Generated by
1.18.0