2012-06-10 16:50:54 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2025-01-24 00:11:17 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2012 Symless Ltd.
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
2012-06-10 16:50:54 +00:00
|
|
|
*/
|
2024-07-02 19:07:06 +00:00
|
|
|
|
2012-06-10 16:50:54 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
2014-02-28 12:36:45 +00:00
|
|
|
#include "ipc/IpcServer.h"
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2024-07-18 07:04:39 +00:00
|
|
|
#include <memory>
|
2012-06-10 16:50:54 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
2025-02-06 11:22:47 +00:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
|
2014-11-11 13:51:47 +00:00
|
|
|
class Event;
|
|
|
|
|
class IpcLogOutputter;
|
|
|
|
|
class FileLogOutputter;
|
2025-02-06 11:22:47 +00:00
|
|
|
class QLocalServer;
|
|
|
|
|
|
|
|
|
|
namespace deskflow::ipc {
|
|
|
|
|
class IpcServer2;
|
|
|
|
|
}
|
2012-07-03 14:15:05 +00:00
|
|
|
|
2013-10-15 10:04:27 +00:00
|
|
|
#if SYSAPI_WIN32
|
2014-11-11 14:50:09 +00:00
|
|
|
class MSWindowsWatchdog;
|
2013-10-15 10:04:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
2024-07-18 07:04:39 +00:00
|
|
|
extern const char *const kLogFilename;
|
|
|
|
|
|
2025-02-06 11:22:47 +00:00
|
|
|
class DaemonApp : public QCoreApplication
|
2024-10-17 18:04:35 +00:00
|
|
|
{
|
2012-06-10 16:50:54 +00:00
|
|
|
public:
|
2025-02-06 11:22:47 +00:00
|
|
|
DaemonApp(IEventQueue *events, int argc, char **argv);
|
2024-07-18 07:04:39 +00:00
|
|
|
~DaemonApp();
|
2025-02-06 11:22:47 +00:00
|
|
|
void startAsync();
|
2024-07-02 19:07:06 +00:00
|
|
|
void mainLoop(bool logToFile, bool foreground = false);
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
private:
|
2025-02-06 11:22:47 +00:00
|
|
|
int init(int argc, char **argv);
|
2024-07-02 19:07:06 +00:00
|
|
|
void daemonize();
|
|
|
|
|
void foregroundError(const char *message);
|
|
|
|
|
std::string logFilename();
|
|
|
|
|
void handleIpcMessage(const Event &, void *);
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
public:
|
2024-07-02 19:07:06 +00:00
|
|
|
static DaemonApp *s_instance;
|
2012-07-03 14:15:05 +00:00
|
|
|
|
2012-06-10 16:50:54 +00:00
|
|
|
#if SYSAPI_WIN32
|
2024-07-18 07:04:39 +00:00
|
|
|
std::unique_ptr<MSWindowsWatchdog> m_watchdog;
|
2012-06-10 16:50:54 +00:00
|
|
|
#endif
|
2012-07-03 14:15:05 +00:00
|
|
|
|
|
|
|
|
private:
|
2024-07-18 07:04:39 +00:00
|
|
|
std::unique_ptr<IpcServer> m_ipcServer;
|
|
|
|
|
std::unique_ptr<IpcLogOutputter> m_ipcLogOutputter;
|
2025-02-28 12:46:12 +00:00
|
|
|
IEventQueue *m_events = nullptr;
|
2025-02-28 12:19:39 +00:00
|
|
|
FileLogOutputter *m_fileLogOutputter = nullptr;
|
2025-02-06 11:22:47 +00:00
|
|
|
std::unique_ptr<deskflow::ipc::IpcServer2> m_ipcServer2;
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|