Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
DaemonIpcClient.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2025 Symless Ltd.
4 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
5 */
6
7#pragma once
8
9#include <QObject>
10
11class QLocalSocket;
12
13namespace deskflow::gui::ipc {
14
15class DaemonIpcClient : public QObject
16{
17 Q_OBJECT
18
19 // Represents underlying socket state and whether the server responded to the hello message.
20 enum class State
21 {
22 Unconnected,
23 Connecting,
24 Connected,
25 Disconnecting,
26 };
27
28public:
29 explicit DaemonIpcClient(QObject *parent = nullptr);
30 bool connectToServer();
32 bool sendLogLevel(const QString &logLevel);
33 bool sendStartProcess(const QString &command, bool elevate);
34 bool sendStopProcess();
35 bool sendClearSettings();
36 QString requestLogPath();
37
38 bool isConnected() const
39 {
40 return m_state == State::Connected;
41 }
42
43Q_SIGNALS:
44 void connected();
46
47private Q_SLOTS:
48 void handleDisconnected();
49 void handleErrorOccurred();
50
51private:
52 bool keepAlive();
53 bool sendMessage(const QString &message, const QString &expectAck = "ok", const bool expectConnected = true);
54
55private:
56 QLocalSocket *m_socket;
57 State m_state{State::Unconnected};
58};
59
60} // namespace deskflow::gui::ipc
DaemonIpcClient(QObject *parent=nullptr)
Definition DaemonIpcClient.cpp:21
bool sendStartProcess(const QString &command, bool elevate)
Definition DaemonIpcClient.cpp:186
QString requestLogPath()
Definition DaemonIpcClient.cpp:207
bool sendLogLevel(const QString &logLevel)
Definition DaemonIpcClient.cpp:177
bool sendClearSettings()
Definition DaemonIpcClient.cpp:248
bool connectToServer()
Definition DaemonIpcClient.cpp:29
bool sendStopProcess()
Definition DaemonIpcClient.cpp:202
bool isConnected() const
Definition DaemonIpcClient.h:38
void disconnectFromServer()
Definition DaemonIpcClient.cpp:80
Definition CoreProcess.h:25