deskflow/src/apps/deskflow-daemon/DaemonApp.h

70 lines
1.5 KiB
C
Raw Normal View History

2012-06-10 16:50:54 +00:00
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2012 - 2025 Symless Ltd.
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
2012-06-10 16:50:54 +00:00
*/
2012-06-10 16:50:54 +00:00
#pragma once
#include <string>
#include <QObject>
#include <QThread>
2014-11-11 13:51:47 +00:00
class Event;
class IEventQueue;
2014-11-11 13:51:47 +00:00
class FileLogOutputter;
class QLocalServer;
class QCoreApplication;
namespace deskflow::core::ipc {
class DaemonIpcServer;
}
2013-10-15 10:04:27 +00:00
#if SYSAPI_WIN32
class MSWindowsWatchdog;
2013-10-15 10:04:27 +00:00
#endif
Solve low hanging reliability and maintainability issues (#7403) * Add missing atom ctor init * Init members with `None` * Use in-class init and delcare getter inside if init * Temp revert of changes ahead of unit test repair * Move IPC header to shared, restore X clipboard test, simplify test cmake, new X clipboard unit test * Suppress sonar for undefs * Remove base dir include * Revert "Temp revert of changes ahead of unit test repair" This reverts commit 8f84b6ea5d5828f1be1362de3809279bcacb8cc8. * Use new accessor * Use default dtor * Beef up to 32 core * Use enum class * Make IPC protocol headers const at all levels * Use enum class and const char for better type safety * Use unique_ptr for m_clipboard * Use `-j` instead of `-j8` to utilize full parallelism * Increase thread count for sonar-scanner * Use 32 threads * Use in-class init for IpcClientProxy members * Use const instead of #define * Remove ctor member inits * Use unique_ptr on win * Implement temp bin dir for windows with more robust post-build copy * Fixed missing iostream * Add warning about copy errors * Only run clean-gcda on Linux * Use in-class init for IPC mutex * Do no-op on Windows * Hide clean-gcda task * Move flakey test to integtests * Delete dead code * Test * Temp disable post_config_all * Disable post config step * Revert "Disable post config step" This reverts commit 2f956a7714ba9bedacd4b39d4ae00940c3d565d6. * Revert "Temp disable post_config_all" This reverts commit b44ed72e44f838bfe1309f6e9672d2f1c6f21b75. * Restore -j8 * Simplify error handling * Use const for test port * Remove python check * Update changelog * Fixed order * Fixed bad issue number * Fixed bin copy source path * Remove redundant except
2024-07-18 07:04:39 +00:00
extern const char *const kLogFilename;
class DaemonApp : public QObject
{
Q_OBJECT
2012-06-10 16:50:54 +00:00
public:
explicit DaemonApp(IEventQueue &events);
~DaemonApp() override;
void run(QThread &daemonThread);
void setForeground();
void initLogging();
void connectIpcServer(const deskflow::core::ipc::DaemonIpcServer *ipcServer) const;
static QString logFilename();
private:
void daemonize();
void handleError(const char *message);
int mainLoop();
int daemonLoop();
void saveLogLevel(const QString &logLevel) const;
void setElevate(bool elevate);
void setCommand(const QString &command);
void applyWatchdogCommand() const;
void clearWatchdogCommand();
void clearSettings() const;
static void showConsole();
2012-06-10 16:50:54 +00:00
#if SYSAPI_WIN32
std::unique_ptr<MSWindowsWatchdog> m_pWatchdog;
2012-06-10 16:50:54 +00:00
#endif
IEventQueue &m_events;
FileLogOutputter *m_pFileLogOutputter = nullptr;
deskflow::core::ipc::DaemonIpcServer *m_ipcServer = nullptr;
std::string m_command = "";
bool m_elevate = false;
bool m_foreground = false;
2012-06-10 16:50:54 +00:00
};