id
int64
0
755k
file_name
stringlengths
3
109
file_path
stringlengths
13
185
content
stringlengths
31
9.38M
size
int64
31
9.38M
language
stringclasses
1 value
extension
stringclasses
11 values
total_lines
int64
1
340k
avg_line_length
float64
2.18
149k
max_line_length
int64
7
2.22M
alphanum_fraction
float64
0
1
repo_name
stringlengths
6
65
repo_stars
int64
100
47.3k
repo_forks
int64
0
12k
repo_open_issues
int64
0
3.4k
repo_license
stringclasses
9 values
repo_extraction_date
stringclasses
92 values
exact_duplicates_redpajama
bool
2 classes
near_duplicates_redpajama
bool
2 classes
exact_duplicates_githubcode
bool
2 classes
exact_duplicates_stackv2
bool
1 class
exact_duplicates_stackv1
bool
2 classes
near_duplicates_githubcode
bool
2 classes
near_duplicates_stackv1
bool
2 classes
near_duplicates_stackv2
bool
1 class
13,990
dotenv.h
deskflow_deskflow/src/lib/gui/dotenv.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2024 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QString> namespace deskflow::gui { const QString kDefaultEnvFilename = ".env"; /** * @brief Loads environment variables from a .env file. * * First checks current dir for .env, then looks in the app dir. */ void dotenv(const QString &filename = kDefaultEnvFilename); } // namespace deskflow::gui
1,015
C++
.h
27
35.666667
72
0.758656
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,991
styles.h
deskflow_deskflow/src/lib/gui/styles.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2014 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QString> namespace deskflow::gui { const auto kColorWhite = "#ffffff"; const auto kColorPrimary = "#ff7c00"; const auto kColorSecondary = "#4285f4"; const auto kColorTertiary = "#33b2cc"; const auto kColorError = "#ec4c47"; const auto kColorNotice = "#3b67d3"; const auto kColorLightGrey = "#666666"; const auto kStyleLink = // QString("color: %1").arg(kColorSecondary); const auto kStyleLineEditErrorBorder = QString("border: 1px solid %1; border-radius: 2px; padding: 2px;").arg(kColorError); const auto kStyleErrorActiveLabel = // QString("padding: 3px 5px; border-radius: 3px; " "background-color: %1; color: %2") .arg(kColorError, kColorWhite); const auto kStyleErrorInactiveLabel = // QString("padding: 3px 5px; border-radius: 3px;" "background-color: none"); const auto kStyleNoticeLabel = // QString("padding: 3px 5px; border-radius: 3px;" "background-color: %1; color: %2") .arg(kColorNotice, kColorWhite); } // namespace deskflow::gui
1,736
C++
.h
42
38.02381
88
0.726247
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,992
QNetworkAccessManagerProxy.h
deskflow_deskflow/src/lib/gui/proxy/QNetworkAccessManagerProxy.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2024 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QNetworkAccessManager> #include <QObject> namespace deskflow::gui::proxy { class QNetworkAccessManagerProxy : public QObject { Q_OBJECT public: virtual void init(); virtual void get(const QNetworkRequest &request) const; signals: void finished(QNetworkReply *reply); private: std::shared_ptr<QNetworkAccessManager> m_network; }; } // namespace deskflow::gui::proxy
1,092
C++
.h
32
32.09375
72
0.773764
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,993
QSettingsProxy.h
deskflow_deskflow/src/lib/gui/proxy/QSettingsProxy.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2024 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QSettings> namespace deskflow::gui::proxy { QString getSystemSettingBaseDir(); class QSettingsProxy { public: virtual ~QSettingsProxy() = default; virtual void loadUser(); virtual void loadSystem(); virtual void clear() { m_pSettings->clear(); } virtual void sync() { m_pSettings->sync(); } virtual int beginReadArray(const QString &prefix); virtual void beginWriteArray(const QString &prefix); virtual void setArrayIndex(int i); virtual QVariant value(const QString &key) const; virtual QVariant value(const QString &key, const QVariant &defaultValue) const; virtual void endArray(); virtual void setValue(const QString &key, const QVariant &value); virtual void beginGroup(const QString &prefix); virtual void endGroup(); virtual void remove(const QString &key); virtual bool isWritable() const; virtual bool contains(const QString &key) const; virtual QString fileName() const { return m_pSettings->fileName(); } QSettings &get() const { return *m_pSettings; } private: std::unique_ptr<QSettings> m_pSettings; }; } // namespace deskflow::gui::proxy
1,842
C++
.h
58
29.103448
81
0.752113
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,994
QProcessProxy.h
deskflow_deskflow/src/lib/gui/proxy/QProcessProxy.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2024 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QObject> #include <QProcess> namespace deskflow::gui::proxy { class QProcessProxy : public QObject { Q_OBJECT public: ~QProcessProxy() override = default; explicit virtual operator bool() const; virtual void create(); virtual void start(const QString &program, const QStringList &arguments = {}); virtual bool waitForStarted(); virtual QProcess::ProcessState state() const; virtual void close(); virtual QString readAllStandardOutput(); virtual QString readAllStandardError(); signals: void finished(int exitCode, QProcess::ExitStatus exitStatus); void readyReadStandardOutput(); void readyReadStandardError(); private: std::unique_ptr<QProcess> m_pProcess; }; } // namespace deskflow::gui::proxy
1,442
C++
.h
41
32.926829
80
0.77028
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,995
TlsUtility.h
deskflow_deskflow/src/lib/gui/tls/TlsUtility.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2024 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "gui/config/IAppConfig.h" #include "TlsCertificate.h" #include <QObject> namespace deskflow::gui { class TlsUtility : public QObject { Q_OBJECT public: explicit TlsUtility(const IAppConfig &appConfig); bool generateCertificate(); bool persistCertificate(); /** * @brief Combines the availability and the enabled status of TLS. * * @return Given that the app setting for TLS is enabled: * If licensing is enabled, it checks whether the product has TLS * available, and if licensing is not enabled, true is returned. */ bool isEnabled() const; private: const IAppConfig &m_appConfig; TlsCertificate m_certificate; }; } // namespace deskflow::gui
1,397
C++
.h
41
31.609756
72
0.759108
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,996
TlsFingerprint.h
deskflow_deskflow/src/lib/gui/tls/TlsFingerprint.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2015 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QString> class TlsFingerprint { private: explicit TlsFingerprint(const QString &filename); public: static TlsFingerprint local(); static TlsFingerprint trustedServers(); static TlsFingerprint trustedClients(); static QString directoryPath(); static QString localFingerprint(); static bool localFingerprintExists(); static void persistDirectory(); void trust(const QString &fingerprintText, bool append = true) const; bool isTrusted(const QString &fingerprintText) const; QStringList readList(const int readTo = -1) const; QString readFirst() const; QString filePath() const; bool fileExists() const; private: QString m_Filename; };
1,377
C++
.h
39
33
72
0.777027
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,997
TlsCertificate.h
deskflow_deskflow/src/lib/gui/tls/TlsCertificate.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2015 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QObject> class TlsCertificate : public QObject { Q_OBJECT public: explicit TlsCertificate(QObject *parent = nullptr); bool generateCertificate(const QString &path, int keyLength); int getCertKeyLength(const QString &path); private: bool runTool(const QStringList &args); bool generateFingerprint(const QString &certificateFilename); private: QString m_toolStdout; };
1,097
C++
.h
31
33.225806
72
0.777148
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,998
ServerConnection.h
deskflow_deskflow/src/lib/gui/core/ServerConnection.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QString> #include <QStringList> #include "gui/config/IAppConfig.h" #include "gui/config/IServerConfig.h" #include "gui/config/ServerConfigDialogState.h" #include "gui/messages.h" namespace deskflow::gui { class ServerConnection : public QObject { Q_OBJECT using IServerConfig = deskflow::gui::IServerConfig; public: struct Deps { virtual ~Deps() = default; virtual messages::NewClientPromptResult showNewClientPrompt(QWidget *parent, const QString &clientName) const; }; explicit ServerConnection( QWidget *parent, IAppConfig &appConfig, IServerConfig &serverConfig, const config::ServerConfigDialogState &serverConfigDialogState, std::shared_ptr<Deps> deps = std::make_shared<Deps>() ); void handleLogLine(const QString &logLine); signals: void messageShowing(); void configureClient(const QString &clientName); private: void handleNewClient(const QString &clientName); QWidget *m_pParent; IAppConfig &m_appConfig; IServerConfig &m_serverConfig; const config::ServerConfigDialogState &m_serverConfigDialogState; std::shared_ptr<Deps> m_pDeps; QStringList m_receivedClients; bool m_messageShowing = false; }; } // namespace deskflow::gui
1,920
C++
.h
54
32.925926
114
0.774124
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,999
ServerMessage.h
deskflow_deskflow/src/lib/gui/core/ServerMessage.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QString> namespace deskflow::gui { class ServerMessage { QString m_message; QString m_clientName; public: explicit ServerMessage(const QString &message); bool isNewClientMessage() const; bool isExitMessage() const; bool isConnectedMessage() const; bool isDisconnectedMessage() const; const QString &getClientName() const; private: QString parseClientName(const QString &line) const; }; } // namespace deskflow::gui
1,151
C++
.h
34
31.617647
72
0.772563
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,000
CommandProcess.h
deskflow_deskflow/src/lib/gui/core/CommandProcess.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2014 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QObject> #include <QStringList> class CommandProcess : public QObject { Q_OBJECT public: CommandProcess(QString cmd, QStringList arguments, QString input = ""); signals: void finished(); public slots: QString run(); private: QString m_Command; QStringList m_Arguments; QString m_Input; };
1,019
C++
.h
33
28.787879
73
0.764045
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,001
ClientConnection.h
deskflow_deskflow/src/lib/gui/core/ClientConnection.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "gui/config/IAppConfig.h" #include "gui/messages.h" #include <QObject> #include <QString> #include <QWidget> #include <memory> class QWidget; namespace deskflow::gui { class ClientConnection : public QObject { Q_OBJECT public: struct Deps { virtual ~Deps() = default; virtual void showError(QWidget *parent, messages::ClientError error, const QString &address) const; }; explicit ClientConnection( QWidget *parent, IAppConfig &appConfig, std::shared_ptr<Deps> deps = std::make_shared<Deps>() ) : m_pParent(parent), m_appConfig(appConfig), m_deps(deps) { } void handleLogLine(const QString &line); void setShowMessage() { m_showMessage = true; } signals: void messageShowing(); private: void showMessage(const QString &logLine); QWidget *m_pParent; IAppConfig &m_appConfig; std::shared_ptr<Deps> m_deps; bool m_showMessage = true; }; } // namespace deskflow::gui
1,660
C++
.h
57
26.280702
103
0.737571
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,002
CoreProcess.h
deskflow_deskflow/src/lib/gui/core/CoreProcess.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2024 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "gui/config/IAppConfig.h" #include "gui/config/IServerConfig.h" #include "gui/ipc/QIpcClient.h" #include "gui/proxy/QProcessProxy.h" #include <QMutex> #include <QObject> #include <QString> #include <QStringList> #include <QTimer> #include <memory> namespace deskflow::gui { class CoreProcess : public QObject { using IServerConfig = deskflow::gui::IServerConfig; using QProcessProxy = deskflow::gui::proxy::QProcessProxy; using IQIpcClient = deskflow::gui::ipc::IQIpcClient; Q_OBJECT public: struct Deps { virtual ~Deps() = default; virtual QProcessProxy &process() { return m_process; } virtual IQIpcClient &ipcClient() { return m_ipcClient; } virtual QString appPath(const QString &name) const; virtual bool fileExists(const QString &path) const; virtual QString getProfileRoot() const; private: QProcessProxy m_process; QIpcClient m_ipcClient; }; enum class Mode { None, Client, Server }; enum class Error { AddressMissing, StartFailed }; enum class ProcessState { Starting, Started, Stopping, Stopped, RetryPending }; enum class ConnectionState { Disconnected, Connecting, Connected, Listening }; explicit CoreProcess( const IAppConfig &appConfig, const IServerConfig &serverConfig, std::shared_ptr<Deps> deps = std::make_shared<Deps>() ); void extracted(QString &app, QStringList &args); void start(std::optional<ProcessMode> processMode = std::nullopt); void stop(std::optional<ProcessMode> processMode = std::nullopt); void restart(); void cleanup(); // getters Mode mode() const { return m_mode; } QString secureSocketVersion() const { return m_secureSocketVersion; } bool isStarted() const { return m_processState == ProcessState::Started; } ProcessState processState() const { return m_processState; } ConnectionState connectionState() const { return m_connectionState; } // setters void setAddress(const QString &address) { m_address = address.trimmed(); } void setMode(Mode mode) { m_mode = mode; } signals: void starting(); void error(Error error); void logLine(const QString &line); void connectionStateChanged(ConnectionState state); void processStateChanged(ProcessState state); void secureSocket(bool enabled); private slots: void onIpcClientServiceReady(); void onIpcClientRead(const QString &text); void onIpcClientError(const QString &text) const; void onProcessFinished(int exitCode, QProcess::ExitStatus); void onProcessReadyReadStandardOutput(); void onProcessReadyReadStandardError(); private: void startDesktop(const QString &app, const QStringList &args); void startService(const QString &app, const QStringList &args); void stopDesktop() const; void stopService(); bool addGenericArgs(QStringList &args, const ProcessMode processMode) const; bool addServerArgs(QStringList &args, QString &app); bool addClientArgs(QStringList &args, QString &app); QString persistServerConfig() const; QString modeString() const; QString processModeString() const; void setConnectionState(ConnectionState state); void setProcessState(ProcessState state); void checkLogLine(const QString &line); bool checkSecureSocket(const QString &line); void handleLogLines(const QString &text); QString correctedInterface() const; QString correctedAddress() const; #ifdef Q_OS_MAC void checkOSXNotification(const QString &line); #endif const IAppConfig &m_appConfig; const IServerConfig &m_serverConfig; std::shared_ptr<Deps> m_pDeps; QString m_address; ProcessState m_processState = ProcessState::Stopped; ConnectionState m_connectionState = ConnectionState::Disconnected; Mode m_mode = Mode::None; QMutex m_processMutex; QString m_secureSocketVersion = ""; std::optional<ProcessMode> m_lastProcessMode = std::nullopt; QTimer m_retryTimer; }; } // namespace deskflow::gui
4,735
C++
.h
166
25.283133
78
0.750989
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,003
CoreTool.h
deskflow_deskflow/src/lib/gui/core/CoreTool.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2015 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QString> class CoreTool { public: QString getProfileDir() const; QString getInstalledDir() const; QString getArch() const; };
844
C++
.h
25
31.8
72
0.76348
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,004
WaylandWarnings.h
deskflow_deskflow/src/lib/gui/core/WaylandWarnings.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2024 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QWidget> #include <memory> #include "CoreProcess.h" #include "platform/wayland.h" namespace deskflow::gui::core { class WaylandWarnings { public: struct Deps { virtual ~Deps() = default; virtual void showWaylandLibraryError(QWidget *parent); }; explicit WaylandWarnings(std::shared_ptr<Deps> deps = std::make_shared<Deps>()) : m_pDeps(deps) { } void showOnce( QWidget *parent, CoreProcess::Mode mode, bool hasEi = platform::kHasEi, bool hasPortal = platform::kHasPortal, bool hasPortalInputCapture = platform::kHasPortalInputCapture ); private: bool m_errorShown{false}; std::shared_ptr<Deps> m_pDeps; }; } // namespace deskflow::gui::core
1,398
C++
.h
42
30.761905
116
0.749072
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,005
SpacesValidator.h
deskflow_deskflow/src/lib/gui/validators/SpacesValidator.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "IStringValidator.h" namespace validators { class SpacesValidator : public IStringValidator { public: explicit SpacesValidator(const QString &message); bool validate(const QString &input) const override; }; } // namespace validators
950
C++
.h
26
34.615385
72
0.775843
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,006
EmptyStringValidator.h
deskflow_deskflow/src/lib/gui/validators/EmptyStringValidator.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "IStringValidator.h" namespace validators { class EmptyStringValidator : public IStringValidator { public: explicit EmptyStringValidator(const QString &message); bool validate(const QString &input) const override; }; } // namespace validators
960
C++
.h
26
35
72
0.778256
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,007
LineEditValidator.h
deskflow_deskflow/src/lib/gui/validators/LineEditValidator.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "IStringValidator.h" #include <QLabel> #include <QLineEdit> #include <QValidator> #include <memory> #include <vector> #include "ValidationError.h" namespace validators { class LineEditValidator : public QValidator { public: explicit LineEditValidator(QLineEdit *lineEdit = nullptr, ValidationError *error = nullptr); QValidator::State validate(QString &input, int &pos) const override; void addValidator(std::unique_ptr<IStringValidator> validator); private: ValidationError *m_pError = nullptr; QLineEdit *m_pLineEdit = nullptr; std::vector<std::unique_ptr<IStringValidator>> m_Validators; void setError(const QString &message) const; }; } // namespace validators
1,396
C++
.h
38
34.736842
94
0.777613
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,008
IStringValidator.h
deskflow_deskflow/src/lib/gui/validators/IStringValidator.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QString> namespace validators { class IStringValidator { QString m_Message; public: IStringValidator() = default; explicit IStringValidator(const QString &message); const QString &getMessage() const; virtual bool validate(const QString &input) const = 0; virtual ~IStringValidator() = default; }; } // namespace validators
1,051
C++
.h
30
32.9
72
0.767258
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,009
ScreenDuplicationsValidator.h
deskflow_deskflow/src/lib/gui/validators/ScreenDuplicationsValidator.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "IStringValidator.h" #include "gui/config/ScreenList.h" namespace validators { class ScreenDuplicationsValidator : public IStringValidator { const QString m_defaultName; const ScreenList *m_pScreenList = nullptr; public: ScreenDuplicationsValidator(const QString &message, const QString &defaultName, const ScreenList *pScreens); bool validate(const QString &input) const override; }; } // namespace validators
1,134
C++
.h
29
37.068966
110
0.783242
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,010
ValidationError.h
deskflow_deskflow/src/lib/gui/validators/ValidationError.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2024 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QLabel> #include <QObject> #include <QString> namespace validators { class ValidationError : public QObject { QString m_message; QLabel *m_pLabel = nullptr; public: explicit ValidationError(QObject *parent, QLabel *label = nullptr); const QString &message() const; void setMessage(const QString &message); }; } // namespace validators
1,059
C++
.h
31
32.193548
72
0.765396
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,011
ScreenNameValidator.h
deskflow_deskflow/src/lib/gui/validators/ScreenNameValidator.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "LineEditValidator.h" #include "gui/config/ScreenList.h" #include "gui/validators/ValidationError.h" namespace validators { class ScreenNameValidator : public LineEditValidator { public: explicit ScreenNameValidator( QLineEdit *lineEdit = nullptr, ValidationError *error = nullptr, const ScreenList *pScreens = nullptr ); }; } // namespace validators
1,074
C++
.h
29
35
107
0.775
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,012
AliasValidator.h
deskflow_deskflow/src/lib/gui/validators/AliasValidator.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "LineEditValidator.h" #include "gui/validators/ValidationError.h" namespace validators { class AliasValidator : public LineEditValidator { public: explicit AliasValidator(QLineEdit *parent = nullptr, ValidationError *error = nullptr); }; } // namespace validators
979
C++
.h
26
35.807692
89
0.777426
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,013
ComputerNameValidator.h
deskflow_deskflow/src/lib/gui/validators/ComputerNameValidator.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "IStringValidator.h" #include <QRegularExpression> namespace validators { class ComputerNameValidator : public IStringValidator { public: explicit ComputerNameValidator(const QString &message); bool validate(const QString &input) const override; private: inline static const QRegularExpression m_nameValidator = QRegularExpression(QStringLiteral("^[\\w\\._-]{0,255}$"), QRegularExpression::CaseInsensitiveOption); }; } // namespace validators
1,170
C++
.h
30
36.866667
107
0.778464
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,014
QIpcClient.h
deskflow_deskflow/src/lib/gui/ipc/QIpcClient.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QAbstractSocket> #include <QDataStream> #include <QObject> #include <QTcpSocket> #include <memory> #include "IpcReader.h" #include "QDataStreamProxy.h" #include "gui/config/ElevateMode.h" #include "gui/ipc/IQIpcClient.h" class IpcReader; class QIpcClient : public deskflow::gui::ipc::IQIpcClient { Q_OBJECT public: using StreamProvider = std::function<std::shared_ptr<QDataStreamProxy>()>; explicit QIpcClient(const StreamProvider &streamProvider = nullptr); void sendHello() const override; void sendCommand(const QString &command, ElevateMode elevate) const override; void connectToHost() override; void disconnectFromHost() override; bool isConnected() const override { return m_isConnected; } private slots: void onRetryConnect(); void onSocketConnected() const; void onIpcReaderHelloBack(); void onSocketError(QAbstractSocket::SocketError error); void onIpcReaderRead(const QString &text); private: std::unique_ptr<QTcpSocket> m_pSocket; std::unique_ptr<IpcReader> m_pReader; bool m_readerStarted = false; StreamProvider m_streamProvider; bool m_isConnected = false; bool m_isConnecting = false; };
1,869
C++
.h
55
31.690909
79
0.777162
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,015
IpcReader.h
deskflow_deskflow/src/lib/gui/ipc/IpcReader.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QMutex> #include <QObject> class QTcpSocket; class IpcReader : public QObject { Q_OBJECT; public: explicit IpcReader(QTcpSocket *socket); ~IpcReader() override = default; void start() const; void stop() const; signals: void read(const QString &text); void helloBack(); private: bool readStream(char *buffer, int length); private slots: void onSocketReadyRead(); private: QTcpSocket *m_Socket; QMutex m_Mutex; };
1,152
C++
.h
39
27.358974
72
0.759058
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,016
QDataStreamProxy.h
deskflow_deskflow/src/lib/gui/ipc/QDataStreamProxy.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2024 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QTcpSocket> /** * @brief Useful for overriding QDataStream. */ class QDataStreamProxy { public: explicit QDataStreamProxy() = default; explicit QDataStreamProxy(QTcpSocket *socket) : m_Stream(std::make_unique<QDataStream>(socket)) { } virtual ~QDataStreamProxy() = default; virtual qint64 writeRawData(const char *data, int len) { assert(m_Stream); return m_Stream->writeRawData(data, len); } private: std::unique_ptr<QDataStream> m_Stream; };
1,185
C++
.h
37
29.756757
97
0.753497
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,017
IQIpcClient.h
deskflow_deskflow/src/lib/gui/ipc/IQIpcClient.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2024 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QObject> #include <QString> #include "gui/config/ElevateMode.h" namespace deskflow::gui::ipc { class IQIpcClient : public QObject { Q_OBJECT public: ~IQIpcClient() override = default; virtual void sendHello() const = 0; virtual void sendCommand(const QString &command, ElevateMode elevate) const = 0; virtual void connectToHost() = 0; virtual void disconnectFromHost() = 0; virtual bool isConnected() const = 0; signals: void read(const QString &text); void serviceReady(); }; } // namespace deskflow::gui::ipc
1,245
C++
.h
36
32.472222
82
0.757072
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,018
IServerConfig.h
deskflow_deskflow/src/lib/gui/config/IServerConfig.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2024 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QFile> #include <QString> #include "ScreenList.h" namespace deskflow::gui { class IServerConfig { public: virtual ~IServerConfig() = default; virtual bool isFull() const = 0; virtual bool screenExists(const QString &screenName) const = 0; virtual bool save(const QString &fileName) const = 0; virtual void save(QFile &file) const = 0; virtual bool enableDragAndDrop() const = 0; virtual const ScreenList &screens() const = 0; }; } // namespace deskflow::gui
1,187
C++
.h
33
33.909091
72
0.756098
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,019
AppConfig.h
deskflow_deskflow/src/lib/gui/config/AppConfig.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "ElevateMode.h" #include "IAppConfig.h" #include "IConfigScopes.h" #include "common/constants.h" #include "gui/paths.h" #include <QDir> #include <QHostInfo> #include <QObject> #include <QPoint> #include <QSize> #include <QString> #include <QVariant> #include <optional> namespace deskflow::gui { const ElevateMode kDefaultElevateMode = ElevateMode::kAutomatic; const QString kDefaultLogFile = QStringLiteral("%1.log").arg(kAppId); const int kDefaultTlsKeyLength = 2048; #if defined(Q_OS_WIN) const ProcessMode kDefaultProcessMode = ProcessMode::kService; #else const ProcessMode kDefaultProcessMode = ProcessMode::kDesktop; #endif // Q_OS_WIN } // namespace deskflow::gui /** * @brief Simply reads and writes app settings. * * Important: Maintain a clear separation of concerns and keep it simple. * It is tempting to add logic (e.g. license checks) to this class since it * instance is widely accessible, but that has previously led to this class * becoming a god object. */ class AppConfig : public QObject, public deskflow::gui::IAppConfig { using ProcessMode = deskflow::gui::ProcessMode; using IConfigScopes = deskflow::gui::IConfigScopes; Q_OBJECT private: enum class Setting { kScreenName = 0, kPort = 1, kInterface = 2, kLogLevel = 3, kLogToFile = 4, kLogFilename = 5, kWizardLastRun = 6, kStartedBefore = 7, kElevateModeLegacy = 8, kElevateMode = 9, // 10 = edition, obsolete (related to obsolete licensing) kTlsEnabled = 11, kAutoHide = 12, // 13 = serial key, obsolete kLastVersion = 14, // 15 = last expire time, obsolete // 16 = activation has run, obsolete // 17 = minimize to tray, obsolete // 18 = activate email, obsolete kLoadSystemSettings = 19, kServerGroupChecked = 20, kUseExternalConfig = 21, kConfigFile = 22, kUseInternalConfig = 23, kClientGroupChecked = 24, kServerHostname = 25, kTlsCertPath = 26, kTlsKeyLength = 27, kPreventSleep = 28, kLanguageSync = 29, kInvertScrollDirection = 30, // 31 = guid, obsolete // 32 = license registry url, obsolete // 33 = license next check, obsolete kInvertConnection = 34, // 35 = client-host-mode, obsolete // 36 = server-client-mode, obsolete kEnableService = 37, kCloseToTray = 38, kMainWindowSize = 39, kMainWindowPosition = 40, // 41 = show dev thanks, obsolete kShowCloseReminder = 42, kEnableUpdateCheck = 43, }; public: struct Deps { virtual ~Deps() = default; virtual QString defaultTlsCertPath() const { return deskflow::gui::paths::defaultTlsCertPath(); } virtual QString hostname() const { return QHostInfo::localHostName(); } }; explicit AppConfig(IConfigScopes &scopes, std::shared_ptr<Deps> deps = std::make_shared<Deps>()); void determineScope(); /** * @brief Commits the current settings to the active scope. * This should only be called when the settings are about to be saved. */ void commit(); // // Getters (overrides) // IConfigScopes &scopes() const override; ProcessMode processMode() const override; ElevateMode elevateMode() const override; bool tlsEnabled() const override; QString tlsCertPath() const override; int tlsKeyLength() const override; QString logLevelText() const override; const QString &screenName() const override; bool logToFile() const override; bool preventSleep() const override; const QString &logFilename() const override; QString coreServerName() const override; QString coreClientName() const override; bool invertConnection() const override; void persistLogDir() const override; bool languageSync() const override; bool invertScrollDirection() const override; int port() const override; bool useExternalConfig() const override; const QString &configFile() const override; const QString &networkInterface() const override; const QString &serverHostname() const override; bool isActiveScopeWritable() const override; bool isActiveScopeSystem() const override; int logLevel() const override; bool autoHide() const override; bool enableService() const override; bool closeToTray() const override; bool clientGroupChecked() const override; // // Getters (new methods) // bool wizardShouldRun() const; bool startedBefore() const; QString logDir() const; bool serverGroupChecked() const; bool useInternalConfig() const; QString lastVersion() const; std::optional<QSize> mainWindowSize() const; std::optional<QPoint> mainWindowPosition() const; bool showCloseReminder() const; std::optional<bool> enableUpdateCheck() const; // // Setters (overrides) // void setScreenName(const QString &s) override; void setPort(int i) override; void setNetworkInterface(const QString &s) override; void setLogLevel(int i) override; void setLogToFile(bool b) override; void setLogFilename(const QString &s) override; void setElevateMode(ElevateMode em) override; void setTlsEnabled(bool e) override; void setAutoHide(bool b) override; void setInvertScrollDirection(bool b) override; void setLanguageSync(bool b) override; void setPreventSleep(bool b) override; void setEnableService(bool enabled) override; void setCloseToTray(bool minimize) override; void setTlsCertPath(const QString &path) override; void setTlsKeyLength(int length) override; void setInvertConnection(bool value) override; // // Setters (new methods) // void setStartedBefore(bool b); void setWizardHasRun(); void setServerGroupChecked(bool); void setUseExternalConfig(bool); void setConfigFile(const QString &); void setUseInternalConfig(bool); void setClientGroupChecked(bool); void setServerHostname(const QString &); void setLastVersion(const QString &version); void setMainWindowSize(const QSize &size); void setMainWindowPosition(const QPoint &position); void setShowCloseReminder(bool show); void setEnableUpdateCheck(bool value); /// @brief Sets the user preference to load from SystemScope. /// @param [in] value /// True - This will set the variable and load the global scope /// settings. False - This will set the variable and load the user /// scope settings. void setLoadFromSystemScope(bool value) override; private: static QString settingName(AppConfig::Setting name); void recall(); void recallScreenName(); void recallElevateMode(); void recallFromAllScopes(); void recallFromCurrentScope(); /** * @brief Loads a setting if it exists, otherwise returns `std::nullopt` * * @param toType A function to convert the QVariant to the desired type. */ template <typename T> std::optional<T> getFromCurrentScope(Setting name, std::function<T(const QVariant &)> toType) const; /** * @brief Sets a setting if the value is not `std::nullopt`. */ template <typename T> void setInCurrentScope(Setting name, const std::optional<T> &value); /// @brief Sets the value of a setting /// @param [in] name The Setting to be saved /// @param [in] value The Value to be saved template <typename T> void setInCurrentScope(AppConfig::Setting name, T value); /// @brief Sets the value of a common setting /// which should have the same value for all scopes /// @param [in] name The Setting to be saved /// @param [in] value The Value to be saved template <typename T> void saveToAllScopes(AppConfig::Setting name, T value); QVariant getFromCurrentScope(AppConfig::Setting name, const QVariant &defaultValue = QVariant()) const; /** * @brief Finds a value by searching each scope starting with the current * scope. */ QVariant findInAllScopes(AppConfig::Setting name, const QVariant &defaultValue = QVariant()) const; /// @brief This method loads config from specified scope /// @param [in] scope which should be loaded. void loadScope(IConfigScopes::Scope scope); /** * @brief Gets a TLS certificate path based on the user's profile dir. */ QString defaultTlsCertPath() const; // Used to make the server and client names on windows. #ifdef Q_OS_WIN inline static const auto s_winExeTemplate = QStringLiteral("%1.exe"); #endif inline static const auto s_CoreServerName = QStringLiteral("deskflow-server"); inline static const auto s_CoreClientName = QStringLiteral("deskflow-client"); static const char m_LogDir[]; /// @brief Contains the string values of the settings names that will be saved static const char *const m_SettingsName[]; /// @brief Core config file extention (not the Qt settings filename) #ifdef Q_OS_WIN inline static const auto s_ConfigFileExt = QStringLiteral("sgc"); #else inline static const auto s_ConfigFileExt = QStringLiteral("conf"); #endif int m_Port = 24800; QString m_Interface = ""; int m_LogLevel = 0; bool m_LogToFile = false; QString m_LogFilename = logDir() + deskflow::gui::kDefaultLogFile; int m_WizardLastRun = 0; bool m_StartedBefore = false; ElevateMode m_ElevateMode = deskflow::gui::kDefaultElevateMode; bool m_TlsEnabled = true; bool m_AutoHide = false; QString m_LastVersion = ""; bool m_InvertScrollDirection = false; bool m_LanguageSync = true; bool m_PreventSleep = false; bool m_InvertConnection = false; bool m_ServerGroupChecked = false; bool m_UseExternalConfig = false; QString m_ConfigFile = QStringLiteral("%1/%2.%3").arg(QDir::homePath(), kAppId, s_ConfigFileExt); bool m_UseInternalConfig = false; bool m_ClientGroupChecked = false; QString m_ServerHostname = ""; bool m_EnableService = deskflow::gui::kDefaultProcessMode == ProcessMode::kService; bool m_CloseToTray = true; int m_TlsKeyLength = deskflow::gui::kDefaultTlsKeyLength; std::optional<QSize> m_MainWindowSize; std::optional<QPoint> m_MainWindowPosition; bool m_LoadFromSystemScope = false; bool m_ShowCloseReminder = true; std::optional<bool> m_EnableUpdateCheck; /** * @brief Flag is set when any TLS is setting is changed, and is reset * when the TLS changed event is emitted. */ bool m_TlsChanged = false; deskflow::gui::IConfigScopes &m_Scopes; std::shared_ptr<Deps> m_pDeps; QString m_ScreenName; QString m_TlsCertPath; signals: void tlsChanged(); void screenNameChanged(); void invertConnectionChanged(); };
11,144
C++
.h
307
33.078176
105
0.74178
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,020
ConfigScopes.h
deskflow_deskflow/src/lib/gui/config/ConfigScopes.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2020 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "IConfigScopes.h" #include <QObject> #include <QSettings> #include <QVariant> #include <memory> namespace deskflow::gui { /// @brief Encapsulates Qt config for both user and global scopes. class ConfigScopes : public QObject, public IConfigScopes { using QSettingsProxy = deskflow::gui::proxy::QSettingsProxy; Q_OBJECT public: struct Deps { virtual ~Deps() = default; virtual std::shared_ptr<QSettingsProxy> makeUserSettings(); virtual std::shared_ptr<QSettingsProxy> makeSystemSettings(); }; explicit ConfigScopes(std::shared_ptr<Deps> deps = std::make_shared<Deps>()); ~ConfigScopes() override = default; void clear() const; void signalReady() override; void save(bool emitSaving = true) override; bool scopeContains(const QString &name, Scope scope = Scope::Current) const override; bool isActiveScopeWritable() const override; void setInScope(const QString &name, const QVariant &value, Scope scope = Scope::Current) override; QVariant getFromScope(const QString &name, const QVariant &defaultValue = QVariant(), Scope scope = Scope::Current) const override; void setActiveScope(Scope scope = Scope::User) override; Scope activeScope() const override; QSettingsProxy &activeSettings() override; const QSettingsProxy &activeSettings() const override; QString activeFilePath() const override; signals: void ready(); void saving(); private: Scope m_currentScope = Scope::User; std::shared_ptr<QSettingsProxy> m_pUserSettingsProxy; std::shared_ptr<QSettingsProxy> m_pSystemSettingsProxy; }; } // namespace deskflow::gui
2,307
C++
.h
59
36.508475
117
0.766443
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,021
IAppConfig.h
deskflow_deskflow/src/lib/gui/config/IAppConfig.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2024 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "ElevateMode.h" #include "gui/config/IConfigScopes.h" #include <QString> namespace deskflow::gui { enum class ProcessMode { kService, kDesktop }; class IAppConfig { using IConfigScopes = deskflow::gui::IConfigScopes; public: virtual ~IAppConfig() = default; // // Getters // virtual IConfigScopes &scopes() const = 0; virtual QString tlsCertPath() const = 0; virtual int tlsKeyLength() const = 0; virtual bool tlsEnabled() const = 0; virtual ProcessMode processMode() const = 0; virtual ElevateMode elevateMode() const = 0; virtual QString logLevelText() const = 0; virtual const QString &screenName() const = 0; virtual bool preventSleep() const = 0; virtual bool logToFile() const = 0; virtual const QString &logFilename() const = 0; virtual QString coreServerName() const = 0; virtual QString coreClientName() const = 0; virtual bool invertConnection() const = 0; virtual void persistLogDir() const = 0; virtual bool languageSync() const = 0; virtual bool invertScrollDirection() const = 0; virtual int port() const = 0; virtual bool useExternalConfig() const = 0; virtual const QString &configFile() const = 0; virtual const QString &networkInterface() const = 0; virtual const QString &serverHostname() const = 0; virtual int logLevel() const = 0; virtual bool autoHide() const = 0; virtual bool enableService() const = 0; virtual bool closeToTray() const = 0; virtual bool isActiveScopeSystem() const = 0; virtual bool isActiveScopeWritable() const = 0; virtual bool clientGroupChecked() const = 0; // // Setters // virtual void setLoadFromSystemScope(bool loadFromSystemScope) = 0; virtual void setScreenName(const QString &screenName) = 0; virtual void setPort(int port) = 0; virtual void setNetworkInterface(const QString &networkInterface) = 0; virtual void setLogLevel(int logLevel) = 0; virtual void setLogToFile(bool logToFile) = 0; virtual void setLogFilename(const QString &logFilename) = 0; virtual void setElevateMode(ElevateMode elevateMode) = 0; virtual void setAutoHide(bool autoHide) = 0; virtual void setPreventSleep(bool preventSleep) = 0; virtual void setTlsCertPath(const QString &tlsCertPath) = 0; virtual void setTlsKeyLength(int tlsKeyLength) = 0; virtual void setTlsEnabled(bool tlsEnabled) = 0; virtual void setLanguageSync(bool languageSync) = 0; virtual void setInvertScrollDirection(bool invertScrollDirection) = 0; virtual void setEnableService(bool enableService) = 0; virtual void setCloseToTray(bool closeToTray) = 0; virtual void setInvertConnection(bool invertConnection) = 0; }; } // namespace deskflow::gui
3,383
C++
.h
86
36.686047
72
0.75944
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,022
Screen.h
deskflow_deskflow/src/lib/gui/config/Screen.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "ScreenConfig.h" #include "gui/proxy/QSettingsProxy.h" #include <QList> #include <QPixmap> #include <QString> #include <QStringList> class QSettings; class QTextStream; class ScreenSettingsDialog; class Screen : public ScreenConfig { using QSettingsProxy = deskflow::gui::proxy::QSettingsProxy; friend class ScreenSettingsDialog; friend class ScreenSetupModel; friend class ScreenSetupView; friend QDataStream &operator<<(QDataStream &outStream, const Screen &screen) { return outStream << screen.name() << screen.switchCornerSize() << screen.aliases() << screen.modifiers() << screen.switchCorners() << screen.fixes() << screen.isServer(); } friend QDataStream &operator>>(QDataStream &inStream, Screen &screen) { return inStream >> screen.m_Name >> screen.m_SwitchCornerSize >> screen.m_Aliases >> screen.m_Modifiers >> screen.m_SwitchCorners >> screen.m_Fixes >> screen.m_isServer; } public: explicit Screen(); explicit Screen(const QString &name); const QPixmap &pixmap() const { return m_Pixmap; } const QString &name() const { return m_Name; } const QStringList &aliases() const { return m_Aliases; } bool isNull() const { return m_Name.isEmpty(); } int modifier(int m) const { return m_Modifiers[m] == static_cast<int>(ScreenConfig::Modifier::DefaultMod) ? m : m_Modifiers[m]; } const QList<int> &modifiers() const { return m_Modifiers; } bool switchCorner(int c) const { return m_SwitchCorners[c]; } const QList<bool> &switchCorners() const { return m_SwitchCorners; } int switchCornerSize() const { return m_SwitchCornerSize; } bool fix(Fix f) const { return m_Fixes[static_cast<int>(f)]; } const QList<bool> &fixes() const { return m_Fixes; } void loadSettings(QSettingsProxy &settings); void saveSettings(QSettingsProxy &settings) const; QTextStream &writeScreensSection(QTextStream &outStream) const; QTextStream &writeAliasesSection(QTextStream &outStream) const; bool swapped() const { return m_Swapped; } QString &name() { return m_Name; } void setName(const QString &name) { m_Name = name; } bool isServer() const { return m_isServer; } void markAsServer() { m_isServer = true; } bool operator==(const Screen &screen) const; protected: void init(); QStringList &aliases() { return m_Aliases; } void setModifier(int m, int n) { m_Modifiers[m] = n; } QList<int> &modifiers() { return m_Modifiers; } void addAlias(const QString &alias) { m_Aliases.append(alias); } void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; } QList<bool> &switchCorners() { return m_SwitchCorners; } void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; } void setFix(int f, bool on) { m_Fixes[f] = on; } QList<bool> &fixes() { return m_Fixes; } void setSwapped(bool on) { m_Swapped = on; } private: QPixmap m_Pixmap = QPixmap(":res/icons/64x64/video-display.png"); QString m_Name; QStringList m_Aliases; QList<int> m_Modifiers; QList<bool> m_SwitchCorners; int m_SwitchCornerSize; QList<bool> m_Fixes; bool m_Swapped = false; bool m_isServer = false; };
4,092
C++
.h
168
21.047619
110
0.703789
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,023
ServerConfigDialogState.h
deskflow_deskflow/src/lib/gui/config/ServerConfigDialogState.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once namespace deskflow::gui::config { /** * @brief Represents the state of the server config dialog. * * Future design consideration: Once moving the server config dialog to the GUI * lib, we can probably just pass a reference to that rather than needing an * object to track it's state. */ class ServerConfigDialogState { public: bool isVisible() const { return m_isVisible; } void setVisible(bool isVisible) { m_isVisible = isVisible; } private: bool m_isVisible = false; }; } // namespace deskflow::gui::config
1,242
C++
.h
40
28.85
79
0.752715
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,024
ScreenConfig.h
deskflow_deskflow/src/lib/gui/config/ScreenConfig.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <QString> #include <QVariant> #include "gui/proxy/QSettingsProxy.h" /// @brief Screen configuration base class class ScreenConfig { using QSettingsProxy = deskflow::gui::proxy::QSettingsProxy; public: enum class Modifier { DefaultMod = -1, Shift, Ctrl, Alt, Meta, Super, None, NumModifiers }; enum class SwitchCorner { TopLeft, TopRight, BottomLeft, BottomRight, NumSwitchCorners }; enum class Fix { CapsLock, NumLock, ScrollLock, XTest, NumFixes }; protected: explicit ScreenConfig() = default; ~ScreenConfig() = default; template <typename T1, typename T2> void readSettings(QSettingsProxy &settings, T1 &array, const QString &arrayName, const T2 &defaultValue) { int entries = settings.beginReadArray(arrayName + "Array"); array.clear(); for (int i = 0; i < entries; i++) { settings.setArrayIndex(i); QVariant v = settings.value(arrayName, defaultValue); array.append(v.value<T2>()); } settings.endArray(); } template <typename T1, typename T2> void readSettings(QSettingsProxy &settings, T1 &array, const QString &arrayName, const T2 &defaultValue, int entries) { Q_ASSERT(array.size() >= entries); settings.beginReadArray(arrayName + "Array"); for (int i = 0; i < entries; i++) { settings.setArrayIndex(i); QVariant v = settings.value(arrayName, defaultValue); array[i] = v.value<T2>(); } settings.endArray(); } template <typename T> void writeSettings(QSettingsProxy &settings, const T &array, const QString &arrayName) const { settings.beginWriteArray(arrayName + "Array"); for (int i = 0; i < array.size(); i++) { settings.setArrayIndex(i); settings.setValue(arrayName, array[i]); } settings.endArray(); } public: static const char *modifierName(int idx) { return m_ModifierNames[idx]; } static const char *fixName(int idx) { return m_FixNames[idx]; } static const char *switchCornerName(int idx) { return m_SwitchCornerNames[idx]; } private: static const char *m_ModifierNames[]; static const char *m_FixNames[]; static const char *m_SwitchCornerNames[]; };
2,992
C++
.h
107
24.299065
119
0.703549
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,025
ScreenList.h
deskflow_deskflow/src/lib/gui/config/ScreenList.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "Screen.h" class ScreenList : public QList<Screen> { int m_width = 5; public: explicit ScreenList(int width = 5); /** * @brief addScreenByPriority adds a new screen according to the following * priority: 1.left side of the server 2.right side of the server 3.top 4.down * 5.top left-hand diagonally * 6.top right-hand diagonally * 7.bottom right-hand diagonally * 8.bottom left-hand diagonally * 9.In case all places from the list have already booked, place in any spare * place * @param newScreen */ void addScreenByPriority(const Screen &newScreen); /** * @brief addScreenToFirstEmpty adds screen into the first empty place * @param newScreen */ void addScreenToFirstEmpty(const Screen &newScreen); /** * @brief Returns true if screens are equal * @param sc */ bool operator==(const ScreenList &sc) const; };
1,590
C++
.h
46
31.695652
80
0.738452
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,026
IConfigScopes.h
deskflow_deskflow/src/lib/gui/config/IConfigScopes.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2024 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "gui/proxy/QSettingsProxy.h" #include <QSettings> #include <QString> #include <QVariant> namespace deskflow::gui { class IConfigScopes { using QSettingsProxy = deskflow::gui::proxy::QSettingsProxy; public: enum class Scope { Current, System, User }; virtual ~IConfigScopes() = default; virtual Scope activeScope() const = 0; virtual void setActiveScope(Scope scope = Scope::User) = 0; virtual bool isActiveScopeWritable() const = 0; virtual QSettingsProxy &activeSettings() = 0; virtual const QSettingsProxy &activeSettings() const = 0; virtual QString activeFilePath() const = 0; /** * @brief Signals to listeners that the settings that they should read. */ virtual void signalReady() = 0; /** * @brief Signals to listeners to save and calls `sync` on underlying Qt * config. * * @param emitSaving Whether to emit the saving signal which typically * triggers listeners to write their current state to the config. */ virtual void save(bool emitSaving = true) = 0; /** * @brief Check a scope for a config value (default is current scope). */ virtual bool scopeContains(const QString &name, Scope scope = Scope::Current) const = 0; /** * @brief Load a config value from a scope (default is current scope). */ virtual QVariant getFromScope(const QString &name, const QVariant &defaultValue = QVariant(), Scope scope = Scope::Current) const = 0; /** * @brief Set a config value in a scope (default is current scope). */ virtual void setInScope(const QString &name, const QVariant &value, Scope scope = Scope::Current) = 0; }; } // namespace deskflow::gui
2,371
C++
.h
66
33
119
0.732868
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,027
ElevateMode.h
deskflow_deskflow/src/lib/gui/config/ElevateMode.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2016 Symless * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once /** * @brief The elevate mode tristate determines two behaviors on Windows. * * The first, switch-on-desk-switch (SodS), passed through deskflowd as a * command line argument to deskflow core, determines if the server restarts * when switching Windows desktops (e.g. when Windows UAC dialog pops up). * The second, passed as a boolean flag to Deskflowd over the IPC inside * IpcMessageType::CommandMessage, determines whether Deskflow should be started * with elevated privileges. * * The matrix for these two behaviors is as follows: * * | SodS | Elevate | * |-----------|------------| * kAutomatic | true | false | * kAlways | false | true | * kNever | false | false | */ enum class ElevateMode { kAutomatic = 0, kAlways = 1, kNever = 2 };
1,542
C++
.h
41
35.634146
80
0.694463
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,028
PriorityQueue.h
deskflow_deskflow/src/lib/base/PriorityQueue.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "common/stdvector.h" #include <algorithm> #include <functional> //! A priority queue with an iterator /*! This priority queue is the same as a standard priority queue except: it sorts by std::greater, it has a forward iterator through the elements (which can appear in any order), and its contents can be swapped. */ template < class T, class Container = std::vector<T>, #if defined(_MSC_VER) class Compare = std::greater<Container::value_type>> #else class Compare = std::greater<typename Container::value_type>> #endif class PriorityQueue { public: typedef typename Container::value_type value_type; typedef typename Container::size_type size_type; typedef typename Container::iterator iterator; typedef typename Container::const_iterator const_iterator; typedef Container container_type; PriorityQueue() { } PriorityQueue(Container &swappedIn) { swap(swappedIn); } ~PriorityQueue() { } //! @name manipulators //@{ //! Add element void push(const value_type &v) { c.push_back(v); std::push_heap(c.begin(), c.end(), comp); } //! Remove head element void pop() { std::pop_heap(c.begin(), c.end(), comp); c.pop_back(); } //! Erase element void erase(iterator i) { c.erase(i); std::make_heap(c.begin(), c.end(), comp); } //! Get start iterator iterator begin() { return c.begin(); } //! Get end iterator iterator end() { return c.end(); } //! Swap contents with another priority queue void swap(PriorityQueue<T, Container, Compare> &q) { c.swap(q.c); } //! Swap contents with another container void swap(Container &c2) { c.swap(c2); std::make_heap(c.begin(), c.end(), comp); } //@} //! @name accessors //@{ //! Returns true if there are no elements bool empty() const { return c.empty(); } //! Returns the number of elements size_type size() const { return c.size(); } //! Returns the head element const value_type &top() const { return c.front(); } //! Get start iterator const_iterator begin() const { return c.begin(); } //! Get end iterator const_iterator end() const { return c.end(); } //@} private: Container c; Compare comp; };
3,027
C++
.h
126
20.984127
72
0.691319
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
14,029
log_outputters.h
deskflow_deskflow/src/lib/base/log_outputters.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/ILogOutputter.h" #include "base/String.h" #include "common/basic_types.h" #include "common/stddeque.h" #include "mt/Thread.h" #include <fstream> #include <list> //! Stop traversing log chain outputter /*! This outputter performs no output and returns false from \c write(), causing the logger to stop traversing the outputter chain. Insert this to prevent already inserted outputters from writing. */ class StopLogOutputter : public ILogOutputter { public: StopLogOutputter(); virtual ~StopLogOutputter(); // ILogOutputter overrides virtual void open(const char *title); virtual void close(); virtual void show(bool showIfEmpty); virtual bool write(ELevel level, const char *message); }; //! Write log to console /*! This outputter writes output to the console. The level for each message is ignored. */ class ConsoleLogOutputter : public ILogOutputter { public: ConsoleLogOutputter(); virtual ~ConsoleLogOutputter(); // ILogOutputter overrides virtual void open(const char *title); virtual void close(); virtual void show(bool showIfEmpty); virtual bool write(ELevel level, const char *message); virtual void flush(); }; //! Write log to file /*! This outputter writes output to the file. The level for each message is ignored. */ class FileLogOutputter : public ILogOutputter { public: FileLogOutputter(const char *logFile); virtual ~FileLogOutputter(); // ILogOutputter overrides virtual void open(const char *title); virtual void close(); virtual void show(bool showIfEmpty); virtual bool write(ELevel level, const char *message); void setLogFilename(const char *title); private: std::string m_fileName; }; //! Write log to system log /*! This outputter writes output to the system log. */ class SystemLogOutputter : public ILogOutputter { public: SystemLogOutputter(); virtual ~SystemLogOutputter(); // ILogOutputter overrides virtual void open(const char *title); virtual void close(); virtual void show(bool showIfEmpty); virtual bool write(ELevel level, const char *message); }; //! Write log to system log only /*! Creating an object of this type inserts a StopLogOutputter followed by a SystemLogOutputter into Log. The destructor removes those outputters. Add one of these to any scope that needs to write to the system log (only) and restore the old outputters when exiting the scope. */ class SystemLogger { public: SystemLogger(const char *title, bool blockConsole); SystemLogger(SystemLogger const &) = delete; SystemLogger(SystemLogger &&) = delete; ~SystemLogger(); SystemLogger &operator=(SystemLogger const &) = delete; SystemLogger &operator=(SystemLogger &&) = delete; private: ILogOutputter *m_syslog; ILogOutputter *m_stop; }; //! Save log history /*! This outputter records the last N log messages. */ class BufferedLogOutputter : public ILogOutputter { private: typedef std::deque<String> Buffer; public: typedef Buffer::const_iterator const_iterator; BufferedLogOutputter(UInt32 maxBufferSize); virtual ~BufferedLogOutputter(); //! @name accessors //@{ //! Get start of buffer const_iterator begin() const; //! Get end of buffer const_iterator end() const; //@} // ILogOutputter overrides virtual void open(const char *title); virtual void close(); virtual void show(bool showIfEmpty); virtual bool write(ELevel level, const char *message); private: UInt32 m_maxBufferSize; Buffer m_buffer; };
4,223
C++
.h
142
27.640845
72
0.76942
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,030
IEventQueue.h
deskflow_deskflow/src/lib/base/IEventQueue.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/Event.h" #include "base/String.h" #include "common/IInterface.h" class IEventJob; class IEventQueueBuffer; // Opaque type for timer info. This is defined by subclasses of // IEventQueueBuffer. class EventQueueTimer; // Event type registration classes. class ClientEvents; class IStreamEvents; class IpcClientEvents; class IpcClientProxyEvents; class IpcServerEvents; class IpcServerProxyEvents; class IDataSocketEvents; class IListenSocketEvents; class ISocketEvents; class OSXScreenEvents; class ClientListenerEvents; class ClientProxyEvents; class ClientProxyUnknownEvents; class ServerEvents; class ServerAppEvents; class IKeyStateEvents; class IPrimaryScreenEvents; class IScreenEvents; class ClipboardEvents; class FileEvents; class EiEvents; //! Event queue interface /*! An event queue provides a queue of Events. Clients can block waiting on any event becoming available at the head of the queue and can place new events at the end of the queue. Clients can also add and remove timers which generate events periodically. */ class IEventQueue : public IInterface { public: class TimerEvent { public: EventQueueTimer *m_timer; //!< The timer UInt32 m_count; //!< Number of repeats }; //! @name manipulators //@{ //! Loop the event queue until quit /*! Dequeues and dispatches events until the kQuit event is found. */ virtual void loop() = 0; //! Set the buffer /*! Replace the current event queue buffer. Any queued events are discarded. The queue takes ownership of the buffer. */ virtual void adoptBuffer(IEventQueueBuffer *) = 0; //! Remove event from queue /*! Returns the next event on the queue into \p event. If no event is available then blocks for up to \p timeout seconds, or forever if \p timeout is negative. Returns true iff an event was available. */ virtual bool getEvent(Event &event, double timeout = -1.0) = 0; //! Dispatch an event /*! Looks up the dispatcher for the event's target and invokes it. Returns true iff a dispatcher exists for the target. */ virtual bool dispatchEvent(const Event &event) = 0; //! Add event to queue /*! Adds \p event to the end of the queue. */ virtual void addEvent(const Event &event) = 0; //! Create a recurring timer /*! Creates and returns a timer. An event is returned after \p duration seconds and the timer is reset to countdown again. When a timer event is returned the data points to a \c TimerEvent. The client must pass the returned timer to \c deleteTimer() (whether or not the timer has expired) to release the timer. The returned timer event uses the given \p target. If \p target is NULL it uses the returned timer as the target. Events for a single timer don't accumulate in the queue, even if the client reading events can't keep up. Instead, the \c m_count member of the \c TimerEvent indicates how many events for the timer would have been put on the queue since the last event for the timer was removed (or since the timer was added). */ virtual EventQueueTimer *newTimer(double duration, void *target) = 0; //! Create a one-shot timer /*! Creates and returns a one-shot timer. An event is returned when the timer expires and the timer is removed from further handling. When a timer event is returned the data points to a \c TimerEvent. The c_count member of the \c TimerEvent is always 1. The client must pass the returned timer to \c deleteTimer() (whether or not the timer has expired) to release the timer. The returned timer event uses the given \p target. If \p target is NULL it uses the returned timer as the target. */ virtual EventQueueTimer *newOneShotTimer(double duration, void *target) = 0; //! Destroy a timer /*! Destroys a previously created timer. The timer is removed from the queue and will not generate event, even if the timer has expired. */ virtual void deleteTimer(EventQueueTimer *) = 0; //! Register an event handler for an event type /*! Registers an event handler for \p type and \p target. The \p handler is adopted. Any existing handler for the type,target pair is deleted. \c dispatchEvent() will invoke \p handler for any event for \p target of type \p type. If no such handler exists it will use the handler for \p target and type \p kUnknown if it exists. */ virtual void adoptHandler(Event::Type type, void *target, IEventJob *handler) = 0; //! Unregister an event handler for an event type /*! Unregisters an event handler for the \p type, \p target pair and deletes it. */ virtual void removeHandler(Event::Type type, void *target) = 0; //! Unregister all event handlers for an event target /*! Unregisters all event handlers for the \p target and deletes them. */ virtual void removeHandlers(void *target) = 0; //! Creates a new event type /*! If \p type contains \c kUnknown then it is set to a unique event type id otherwise it is left alone. The final value of \p type is returned. */ virtual Event::Type registerTypeOnce(Event::Type &type, const char *name) = 0; //! Wait for event queue to become ready /*! Blocks on the current thread until the event queue is ready for events to be added. */ virtual void waitForReady() const = 0; //@} //! @name accessors //@{ //! Test if queue is empty /*! Returns true iff the queue has no events in it, including timer events. */ virtual bool isEmpty() const = 0; //! Get an event handler /*! Finds and returns the event handler for the \p type, \p target pair if it exists, otherwise it returns NULL. */ virtual IEventJob *getHandler(Event::Type type, void *target) const = 0; //! Get name for event /*! Returns the name for the event \p type. This is primarily for debugging. */ virtual const char *getTypeName(Event::Type type) = 0; //! Get an event type by name /*! Returns the registered type for an event for a given name. */ virtual Event::Type getRegisteredType(const String &name) const = 0; //! Get the system event type target /*! Returns the target to use for dispatching \c Event::kSystem events. */ virtual void *getSystemTarget() = 0; //@} // // Event type providers. // virtual ClientEvents &forClient() = 0; virtual IStreamEvents &forIStream() = 0; virtual IpcClientEvents &forIpcClient() = 0; virtual IpcClientProxyEvents &forIpcClientProxy() = 0; virtual IpcServerEvents &forIpcServer() = 0; virtual IpcServerProxyEvents &forIpcServerProxy() = 0; virtual IDataSocketEvents &forIDataSocket() = 0; virtual IListenSocketEvents &forIListenSocket() = 0; virtual ISocketEvents &forISocket() = 0; virtual OSXScreenEvents &forOSXScreen() = 0; virtual ClientListenerEvents &forClientListener() = 0; virtual ClientProxyEvents &forClientProxy() = 0; virtual ClientProxyUnknownEvents &forClientProxyUnknown() = 0; virtual ServerEvents &forServer() = 0; virtual ServerAppEvents &forServerApp() = 0; virtual IKeyStateEvents &forIKeyState() = 0; virtual IPrimaryScreenEvents &forIPrimaryScreen() = 0; virtual IScreenEvents &forIScreen() = 0; virtual ClipboardEvents &forClipboard() = 0; virtual FileEvents &forFile() = 0; virtual EiEvents &forEi() = 0; };
8,066
C++
.h
219
34.141553
84
0.744531
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,031
IJob.h
deskflow_deskflow/src/lib/base/IJob.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "common/IInterface.h" //! Job interface /*! A job is an interface for executing some function. */ class IJob : public IInterface { public: //! Run the job virtual void run() = 0; };
941
C++
.h
29
30.655172
72
0.752475
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,033
TMethodEventJob.h
deskflow_deskflow/src/lib/base/TMethodEventJob.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "IEventJob.h" //! Use a member function as an event job /*! An event job class that invokes a member function. */ template <class T> class TMethodEventJob : public IEventJob { public: //! run(event) invokes \c object->method(event, arg) TMethodEventJob(T *object, void (T::*method)(const Event &, void *), void *arg = NULL); virtual ~TMethodEventJob(); // IJob overrides virtual void run(const Event &); private: T *m_object; void (T::*m_method)(const Event &, void *); void *m_arg; }; template <class T> inline TMethodEventJob<T>::TMethodEventJob(T *object, void (T::*method)(const Event &, void *), void *arg) : m_object(object), m_method(method), m_arg(arg) { // do nothing } template <class T> inline TMethodEventJob<T>::~TMethodEventJob() { // do nothing } template <class T> inline void TMethodEventJob<T>::run(const Event &event) { if (m_object != NULL) { (m_object->*m_method)(event, m_arg); } }
1,708
C++
.h
54
29.37037
106
0.718712
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,034
Stopwatch.h
deskflow_deskflow/src/lib/base/Stopwatch.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "common/common.h" //! A timer class /*! This class measures time intervals. All time interval measurement should use this class. */ class Stopwatch { public: /*! The default constructor does an implicit reset() or setTrigger(). If triggered == false then the clock starts ticking. */ Stopwatch(bool triggered = false); ~Stopwatch(); //! @name manipulators //@{ //! Reset the timer to zero /*! Set the start time to the current time, returning the time since the last reset. This does not remove the trigger if it's set nor does it start a stopped clock. If the clock is stopped then subsequent reset()'s will return 0. */ double reset(); //! Stop the timer /*! Stop the stopwatch. The time interval while stopped is not counted by the stopwatch. stop() does not remove the trigger. Has no effect if already stopped. */ void stop(); //! Start the timer /*! Start the stopwatch. start() removes the trigger, even if the stopwatch was already started. */ void start(); //! Stop the timer and set the trigger /*! setTrigger() stops the clock like stop() except there's an implicit start() the next time (non-const) getTime() is called. This is useful when you want the clock to start the first time you check it. */ void setTrigger(); //! Get elapsed time /*! Returns the time since the last reset() (or calls reset() and returns zero if the trigger is set). */ double getTime(); //! Same as getTime() operator double(); //@} //! @name accessors //@{ //! Check if timer is stopped /*! Returns true if the stopwatch is stopped. */ bool isStopped() const; // return the time since the last reset(). //! Get elapsed time /*! Returns the time since the last reset(). This cannot trigger the stopwatch to start and will not clear the trigger. */ double getTime() const; //! Same as getTime() const operator double() const; //@} private: double getClock() const; private: double m_mark; bool m_triggered; bool m_stopped; };
2,820
C++
.h
97
26.391753
72
0.714391
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
14,035
IEventJob.h
deskflow_deskflow/src/lib/base/IEventJob.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "common/IInterface.h" class Event; //! Event handler interface /*! An event job is an interface for executing a event handler. */ class IEventJob : public IInterface { public: //! Run the job virtual void run(const Event &) = 0; };
992
C++
.h
30
31.266667
72
0.756785
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,036
ELevel.h
deskflow_deskflow/src/lib/base/ELevel.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once //! Log levels /*! The logging priority levels in order of highest to lowest priority. */ enum ELevel { kPRINT = -1, //!< For print only (no file or time) kFATAL, //!< For fatal errors kERROR, //!< For serious errors kWARNING, //!< For minor errors and warnings kNOTE, //!< For messages about notable events kINFO, //!< For informational messages kDEBUG, //!< For important debugging messages kDEBUG1, //!< For verbosity +1 debugging messages kDEBUG2, //!< For verbosity +2 debugging messages kDEBUG3, //!< For verbosity +3 debugging messages kDEBUG4, //!< For verbosity +4 debugging messages kDEBUG5 //!< For verbosity +5 debugging messages };
1,465
C++
.h
37
37.459459
72
0.712482
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
14,037
String.h
deskflow_deskflow/src/lib/base/String.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "common/common.h" #include "common/stdstring.h" #include <stdarg.h> #include <vector> // use standard C++ string class for our string class using String = std::string; namespace deskflow { //! String utilities /*! Provides functions for string manipulation. */ namespace string { //! Format positional arguments /*! Format a string using positional arguments. fmt has literal characters and conversion specifications introduced by `\%': - \%\% -- literal `\%' - \%{n} -- positional element n, n a positive integer, {} are literal All arguments in the variable list are const char*. Positional elements are indexed from 1. */ String format(const char *fmt, ...); //! Format positional arguments /*! Same as format() except takes va_list. */ String vformat(const char *fmt, va_list); //! Print a string using sprintf-style formatting /*! Equivalent to sprintf() except the result is returned as a String. */ String sprintf(const char *fmt, ...); //! Find and replace all /*! Finds \c find inside \c subject and replaces it with \c replace */ void findReplaceAll(String &subject, const String &find, const String &replace); //! Remove file extension /*! Finds the last dot and remove all characters from the dot to the end */ String removeFileExt(String filename); //! Convert into hexdecimal /*! Convert each character in \c subject into hexdecimal form with \c width */ void toHex(String &subject, int width, const char fill = '0'); //! Convert to all uppercase /*! Convert each character in \c subject to uppercase */ void uppercase(String &subject); //! Remove all specific char in suject /*! Remove all specific \c c in \c suject */ void removeChar(String &subject, const char c); //! Convert a size type to a string /*! Convert an size type to a string */ String sizeTypeToString(size_t n); //! Convert a string to a size type /*! Convert an a \c string to an size type */ size_t stringToSizeType(String string); //! Split a string into substrings /*! Split a \c string that separated by a \c c into substrings */ std::vector<String> splitString(String string, const char c); //! Case-insensitive comparisons /*! This class provides case-insensitve comparison functions. */ class CaselessCmp { public: //! Same as less() bool operator()(const String &a, const String &b) const; //! Returns true iff \c a is lexicographically less than \c b static bool less(const String &a, const String &b); //! Returns true iff \c a is lexicographically equal to \c b static bool equal(const String &a, const String &b); //! Returns true iff \c a is lexicographically less than \c b static bool cmpLess(const String::value_type &a, const String::value_type &b); //! Returns true iff \c a is lexicographically equal to \c b static bool cmpEqual(const String::value_type &a, const String::value_type &b); }; } // namespace string } // namespace deskflow
3,639
C++
.h
110
31.536364
81
0.749215
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,038
IEventQueueBuffer.h
deskflow_deskflow/src/lib/base/IEventQueueBuffer.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "common/IInterface.h" #include "common/basic_types.h" class Event; class EventQueueTimer; //! Event queue buffer interface /*! An event queue buffer provides a queue of events for an IEventQueue. */ class IEventQueueBuffer : public IInterface { public: enum Type { kNone, //!< No event is available kSystem, //!< Event is a system event kUser //!< Event is a user event }; //! @name manipulators //@{ //! Initialize /*! Useful for platform-specific initialisation from a specific thread. */ virtual void init() = 0; //! Block waiting for an event /*! Wait for an event in the event queue buffer for up to \p timeout seconds. */ virtual void waitForEvent(double timeout) = 0; //! Get the next event /*! Get the next event from the buffer. Return kNone if no event is available. If a system event is next, return kSystem and fill in event. The event data in a system event can point to a static buffer (because Event::deleteData() will not attempt to delete data in a kSystem event). Otherwise, return kUser and fill in \p dataID with the value passed to \c addEvent(). */ virtual Type getEvent(Event &event, UInt32 &dataID) = 0; //! Post an event /*! Add the given event to the end of the queue buffer. This is a user event and \c getEvent() must be able to identify it as such and return \p dataID. This method must cause \c waitForEvent() to return at some future time if it's blocked waiting on an event. */ virtual bool addEvent(UInt32 dataID) = 0; //@} //! @name accessors //@{ //! Check if event queue buffer is empty /*! Return true iff the event queue buffer is empty. */ virtual bool isEmpty() const = 0; //! Create a timer object /*! Create and return a timer object. The object is opaque and is used only by the buffer but it must be a valid object (i.e. not NULL). */ virtual EventQueueTimer *newTimer(double duration, bool oneShot) const = 0; //! Destroy a timer object /*! Destroy a timer object previously returned by \c newTimer(). */ virtual void deleteTimer(EventQueueTimer *) const = 0; //@} };
2,914
C++
.h
88
30.386364
77
0.719772
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
14,039
EventQueue.h
deskflow_deskflow/src/lib/base/EventQueue.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/IArchMultithread.h" #include "base/Event.h" #include "base/EventTypes.h" #include "base/IEventQueue.h" #include "base/PriorityQueue.h" #include "base/Stopwatch.h" #include "common/stdmap.h" #include "common/stdset.h" #include "mt/CondVar.h" #include <queue> class Mutex; //! Event queue /*! An event queue that implements the platform independent parts and delegates the platform dependent parts to a subclass. */ class EventQueue : public IEventQueue { public: EventQueue(); EventQueue(EventQueue const &) = delete; EventQueue(EventQueue &&) = delete; virtual ~EventQueue(); EventQueue &operator=(EventQueue const &) = delete; EventQueue &operator=(EventQueue &&) = delete; // IEventQueue overrides virtual void loop(); virtual void adoptBuffer(IEventQueueBuffer *); virtual bool getEvent(Event &event, double timeout = -1.0); virtual bool dispatchEvent(const Event &event); virtual void addEvent(const Event &event); virtual EventQueueTimer *newTimer(double duration, void *target); virtual EventQueueTimer *newOneShotTimer(double duration, void *target); virtual void deleteTimer(EventQueueTimer *); virtual void adoptHandler(Event::Type type, void *target, IEventJob *handler); virtual void removeHandler(Event::Type type, void *target); virtual void removeHandlers(void *target); virtual Event::Type registerTypeOnce(Event::Type &type, const char *name); virtual bool isEmpty() const; virtual IEventJob *getHandler(Event::Type type, void *target) const; virtual const char *getTypeName(Event::Type type); virtual Event::Type getRegisteredType(const String &name) const; void *getSystemTarget(); virtual void waitForReady() const; private: UInt32 saveEvent(const Event &event); Event removeEvent(UInt32 eventID); bool hasTimerExpired(Event &event); double getNextTimerTimeout() const; void addEventToBuffer(const Event &event); private: class Timer { public: Timer(EventQueueTimer *, double timeout, double initialTime, void *target, bool oneShot); ~Timer(); void reset(); Timer &operator-=(double); operator double() const; bool isOneShot() const; EventQueueTimer *getTimer() const; void *getTarget() const; void fillEvent(TimerEvent &) const; bool operator<(const Timer &) const; private: EventQueueTimer *m_timer; double m_timeout; void *m_target; bool m_oneShot; double m_time; }; typedef std::set<EventQueueTimer *> Timers; typedef PriorityQueue<Timer> TimerQueue; typedef std::map<UInt32, Event> EventTable; typedef std::vector<UInt32> EventIDList; typedef std::map<Event::Type, const char *> TypeMap; typedef std::map<String, Event::Type> NameMap; typedef std::map<Event::Type, IEventJob *> TypeHandlerTable; typedef std::map<void *, TypeHandlerTable> HandlerTable; int m_systemTarget; ArchMutex m_mutex; // registered events Event::Type m_nextType; TypeMap m_typeMap; NameMap m_nameMap; // buffer of events IEventQueueBuffer *m_buffer; // saved events EventTable m_events; EventIDList m_oldEventIDs; // timers Stopwatch m_time; Timers m_timers; TimerQueue m_timerQueue; TimerEvent m_timerEvent; // event handlers HandlerTable m_handlers; public: // // Event type providers. // ClientEvents &forClient(); IStreamEvents &forIStream(); IpcClientEvents &forIpcClient(); IpcClientProxyEvents &forIpcClientProxy(); IpcServerEvents &forIpcServer(); IpcServerProxyEvents &forIpcServerProxy(); IDataSocketEvents &forIDataSocket(); IListenSocketEvents &forIListenSocket(); ISocketEvents &forISocket(); OSXScreenEvents &forOSXScreen(); ClientListenerEvents &forClientListener(); ClientProxyEvents &forClientProxy(); ClientProxyUnknownEvents &forClientProxyUnknown(); ServerEvents &forServer(); ServerAppEvents &forServerApp(); IKeyStateEvents &forIKeyState(); IPrimaryScreenEvents &forIPrimaryScreen(); IScreenEvents &forIScreen(); ClipboardEvents &forClipboard(); FileEvents &forFile(); EiEvents &forEi(); private: ClientEvents *m_typesForClient; IStreamEvents *m_typesForIStream; IpcClientEvents *m_typesForIpcClient; IpcClientProxyEvents *m_typesForIpcClientProxy; IpcServerEvents *m_typesForIpcServer; IpcServerProxyEvents *m_typesForIpcServerProxy; IDataSocketEvents *m_typesForIDataSocket; IListenSocketEvents *m_typesForIListenSocket; ISocketEvents *m_typesForISocket; OSXScreenEvents *m_typesForOSXScreen; ClientListenerEvents *m_typesForClientListener; ClientProxyEvents *m_typesForClientProxy; ClientProxyUnknownEvents *m_typesForClientProxyUnknown; ServerEvents *m_typesForServer; ServerAppEvents *m_typesForServerApp; IKeyStateEvents *m_typesForIKeyState; IPrimaryScreenEvents *m_typesForIPrimaryScreen; IScreenEvents *m_typesForIScreen; ClipboardEvents *m_typesForClipboard; FileEvents *m_typesForFile; EiEvents *m_typesForEi; Mutex *m_readyMutex; CondVar<bool> *m_readyCondVar; std::queue<Event> m_pending; }; #define EVENT_TYPE_ACCESSOR(type_) \ type_##Events& \ EventQueue::for##type_() \ { \ if (m_typesFor##type_ == NULL) { \ m_typesFor##type_ = new type_##Events(); \ m_typesFor##type_->setEvents(dynamic_cast<IEventQueue *>(this)); \ } \ return *m_typesFor##type_; \ }
6,837
C++
.h
176
35.880682
120
0.678017
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,040
XBase.h
deskflow_deskflow/src/lib/base/XBase.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/String.h" #include "common/stdexcept.h" //! Exception base class /*! This is the base class of most exception types. */ class XBase : public std::runtime_error { public: //! Use getWhat() as the result of what() XBase(); //! Use \c msg as the result of what() XBase(const String &msg); virtual ~XBase() _NOEXCEPT; //! Reason for exception virtual const char *what() const _NOEXCEPT; protected: //! Get a human readable string describing the exception virtual String getWhat() const throw() { return ""; } //! Format a string /*! Looks up a message format using \c id, using \c defaultFormat if no format can be found, then replaces positional parameters in the format string and returns the result. */ virtual String format(const char *id, const char *defaultFormat, ...) const throw(); private: mutable String m_what; }; /*! \def XBASE_SUBCLASS Convenience macro to subclass from XBase (or a subclass of it), providing the c'tor taking a const String&. getWhat() is not declared. */ #define XBASE_SUBCLASS(name_, super_) \ class name_ : public super_ \ { \ public: \ name_() : super_() \ { \ } \ name_(const String &msg) : super_(msg) \ { \ } \ virtual ~name_() _NOEXCEPT \ { \ } \ } /*! \def XBASE_SUBCLASS Convenience macro to subclass from XBase (or a subclass of it), providing the c'tor taking a const String&. getWhat() must be implemented. */ #define XBASE_SUBCLASS_WHAT(name_, super_) \ class name_ : public super_ \ { \ public: \ name_() : super_() \ { \ } \ name_(const String &msg) : super_(msg) \ { \ } \ virtual ~name_() _NOEXCEPT \ { \ } \ \ protected: \ virtual String getWhat() const throw(); \ } /*! \def XBASE_SUBCLASS_FORMAT Convenience macro to subclass from XBase (or a subclass of it), providing the c'tor taking a const String&. what() is overridden to call getWhat() when first called; getWhat() can format the error message and can call what() to get the message passed to the c'tor. */ #define XBASE_SUBCLASS_FORMAT(name_, super_) \ class name_ : public super_ \ { \ private: \ enum EState \ { \ kFirst, \ kFormat, \ kDone \ }; \ \ public: \ name_() : super_(), m_state(kDone) \ { \ } \ name_(const String &msg) : super_(msg), m_state(kFirst) \ { \ } \ virtual ~name_() _NOEXCEPT \ { \ } \ \ virtual const char *what() const _NOEXCEPT \ { \ if (m_state == kFirst) { \ m_state = kFormat; \ m_formatted = getWhat(); \ m_state = kDone; \ } \ if (m_state == kDone) { \ return m_formatted.c_str(); \ } else { \ return super_::what(); \ } \ } \ \ protected: \ virtual String getWhat() const throw(); \ \ private: \ mutable EState m_state; \ mutable std::string m_formatted; \ }
10,866
C++
.h
144
67.993056
120
0.213686
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
14,041
TMethodJob.h
deskflow_deskflow/src/lib/base/TMethodJob.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "IJob.h" //! Use a function as a job /*! A job class that invokes a member function. */ template <class T> class TMethodJob : public IJob { public: //! run() invokes \c object->method(arg) TMethodJob(T *object, void (T::*method)(void *), void *arg = NULL); virtual ~TMethodJob(); // IJob overrides virtual void run(); private: T *m_object; void (T::*m_method)(void *); void *m_arg; }; template <class T> inline TMethodJob<T>::TMethodJob(T *object, void (T::*method)(void *), void *arg) : m_object(object), m_method(method), m_arg(arg) { // do nothing } template <class T> inline TMethodJob<T>::~TMethodJob() { // do nothing } template <class T> inline void TMethodJob<T>::run() { if (m_object != NULL) { (m_object->*m_method)(m_arg); } }
1,542
C++
.h
54
26.296296
81
0.706081
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,042
ILogOutputter.h
deskflow_deskflow/src/lib/base/ILogOutputter.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/ELevel.h" #include "base/Log.h" #include "common/IInterface.h" //! Outputter interface /*! Type of outputter interface. The logger performs all output through outputters. ILogOutputter overrides must not call any log functions directly or indirectly. */ class ILogOutputter : public IInterface { public: //! @name manipulators //@{ //! Open the outputter /*! Opens the outputter for writing. Calling this method on an already open outputter must have no effect. */ virtual void open(const char *title) = 0; //! Close the outputter /*! Close the outputter. Calling this method on an already closed outputter must have no effect. */ virtual void close() = 0; //! Show the outputter /*! Causes the output to become visible. This generally only makes sense for a logger in a graphical user interface. Other implementations will do nothing. Iff \p showIfEmpty is \c false then the implementation may optionally only show the log if it's not empty. */ virtual void show(bool showIfEmpty) = 0; //! Write a message with level /*! Writes \c message, which has the given \c level, to a log. If this method returns true then Log will stop passing the message to all outputters in the outputter chain, otherwise it continues. Most implementations should return true. */ virtual bool write(ELevel level, const char *message) = 0; //@} };
2,161
C++
.h
62
32.467742
74
0.748924
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,043
FunctionJob.h
deskflow_deskflow/src/lib/base/FunctionJob.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/IJob.h" //! Use a function as a job /*! A job class that invokes a function. */ class FunctionJob : public IJob { public: //! run() invokes \c func(arg) FunctionJob(void (*func)(void *), void *arg = NULL); virtual ~FunctionJob(); // IJob overrides virtual void run(); private: void (*m_func)(void *); void *m_arg; };
1,094
C++
.h
35
29.257143
72
0.732448
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
14,044
Log.h
deskflow_deskflow/src/lib/base/Log.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/Arch.h" #include "arch/IArchMultithread.h" #include "common/common.h" #include "common/stdlist.h" #include <stdarg.h> #define CLOG (Log::getInstance()) #define BYE "\nTry `%s --help' for more information." class ILogOutputter; class Thread; //! Logging facility /*! The logging class; all console output should go through this class. It supports multithread safe operation, several message priority levels, filtering by priority, and output redirection. The macros LOG() and LOGC() provide convenient access. */ class Log { public: Log(bool singleton = true); Log(Log *src); Log(Log const &) = delete; Log(Log &&) = delete; ~Log(); Log &operator=(Log const &) = delete; Log &operator=(Log &&) = delete; //! @name manipulators //@{ //! Add an outputter to the head of the list /*! Inserts an outputter to the head of the outputter list. When the logger writes a message, it goes to the outputter at the head of the outputter list. If that outputter's \c write() method returns true then it also goes to the next outputter, as so on until an outputter returns false or there are no more outputters. Outputters still in the outputter list when the log is destroyed will be deleted. If \c alwaysAtHead is true then the outputter is always called before all outputters with \c alwaysAtHead false and the return value of the outputter is ignored. By default, the logger has one outputter installed which writes to the console. */ void insert(ILogOutputter *adopted, bool alwaysAtHead = false); //! Remove an outputter from the list /*! Removes the first occurrence of the given outputter from the outputter list. It does nothing if the outputter is not in the list. The outputter is not deleted. */ void remove(ILogOutputter *orphaned); //! Remove the outputter from the head of the list /*! Removes and deletes the outputter at the head of the outputter list. This does nothing if the outputter list is empty. Only removes outputters that were inserted with the matching \c alwaysAtHead. */ void pop_front(bool alwaysAtHead = false); //! Set the minimum priority filter. /*! Set the filter. Messages below this priority are discarded. The default priority is 4 (INFO) (unless built without NDEBUG in which case it's 5 (DEBUG)). setFilter(const char*) returns true if the priority \c name was recognized; if \c name is NULL then it simply returns true. */ bool setFilter(const char *name); //! Set the minimum priority filter (by ordinal). void setFilter(int); //@} //! @name accessors //@{ //! Print a log message /*! Print a log message using the printf-like \c format and arguments preceded by the filename and line number. If \c file is NULL then neither the file nor the line are printed. */ void print(const char *file, int line, const char *format, ...); //! Get the minimum priority level. int getFilter() const; //! Get the filter name of the current filter level. const char *getFilterName() const; //! Get the filter name of a specified filter level. const char *getFilterName(int level) const; //! Get the singleton instance of the log static Log *getInstance(); //! Get the console filter level (messages above this are not sent to //! console). int getConsoleMaxLevel() const { return kDEBUG2; } //@} private: void output(ELevel priority, char *msg); private: typedef std::list<ILogOutputter *> OutputterList; static Log *s_log; ArchMutex m_mutex; OutputterList m_outputters; OutputterList m_alwaysOutputters; int m_maxPriority; }; /*! \def LOG(arg) Write to the log. Because macros cannot accept variable arguments, this should be invoked like so: \code LOG((CLOG_XXX "%d and %d are %s", x, y, x == y ? "equal" : "not equal")); \endcode In particular, notice the double open and close parentheses. Also note that there is no comma after the \c CLOG_XXX. The \c XXX should be replaced by one of enumerants in \c Log::ELevel without the leading \c k. For example, \c CLOG_INFO. The special \c CLOG_PRINT level will not be filtered and is never prefixed by the filename and line number. If \c NOLOGGING is defined during the build then this macro expands to nothing. If \c NDEBUG is defined during the build then it expands to a call to Log::print. Otherwise it expands to a call to Log::print, which includes the filename and line number. */ /*! \def LOGC(expr, arg) Write to the log if and only if expr is true. Because macros cannot accept variable arguments, this should be invoked like so: \code LOGC(x == y, (CLOG_XXX "%d and %d are equal", x, y)); \endcode In particular, notice the parentheses around everything after the boolean expression. Also note that there is no comma after the \c CLOG_XXX. The \c XXX should be replaced by one of enumerants in \c Log::ELevel without the leading \c k. For example, \c CLOG_INFO. The special \c CLOG_PRINT level will not be filtered and is never prefixed by the filename and line number. If \c NOLOGGING is defined during the build then this macro expands to nothing. If \c NDEBUG is not defined during the build then it expands to a call to Log::print that prints the filename and line number, otherwise it expands to a call that doesn't. */ #if defined(NOLOGGING) #define LOG(_a1) #define LOGC(_a1, _a2) #define CLOG_TRACE #elif defined(NDEBUG) #define LOG(_a1) CLOG->print _a1 #define LOGC(_a1, _a2) \ if (_a1) \ CLOG->print _a2 #define CLOG_TRACE NULL, 0, #else #define LOG(_a1) CLOG->print _a1 #define LOGC(_a1, _a2) \ if (_a1) \ CLOG->print _a2 #define CLOG_TRACE __FILE__, __LINE__, #endif // the CLOG_* defines are line and file plus %z and an octal number (060=0, // 071=9), but the limitation is that once we run out of numbers at either // end, then we resort to using non-numerical chars. this still works (since // to deduce the number we subtract octal \060, so '/' is -1, and ':' is 10 #define CLOG_PRINT CLOG_TRACE "%z\057" // char is '/' #define CLOG_CRIT CLOG_TRACE "%z\060" // char is '0' #define CLOG_ERR CLOG_TRACE "%z\061" #define CLOG_WARN CLOG_TRACE "%z\062" #define CLOG_NOTE CLOG_TRACE "%z\063" #define CLOG_INFO CLOG_TRACE "%z\064" #define CLOG_DEBUG CLOG_TRACE "%z\065" #define CLOG_DEBUG1 CLOG_TRACE "%z\066" #define CLOG_DEBUG2 CLOG_TRACE "%z\067" #define CLOG_DEBUG3 CLOG_TRACE "%z\070" #define CLOG_DEBUG4 CLOG_TRACE "%z\071" // char is '9' #define CLOG_DEBUG5 CLOG_TRACE "%z\072" // char is ':' #define LOG_PRINT(...) LOG((CLOG_PRINT __VA_ARGS__)) #define LOG_CRIT(...) LOG((CLOG_CRIT __VA_ARGS__)) #define LOG_ERR(...) LOG((CLOG_ERR __VA_ARGS__)) #define LOG_WARN(...) LOG((CLOG_WARN __VA_ARGS__)) #define LOG_NOTE(...) LOG((CLOG_NOTE __VA_ARGS__)) #define LOG_INFO(...) LOG((CLOG_INFO __VA_ARGS__)) #define LOG_DEBUG(...) LOG((CLOG_DEBUG __VA_ARGS__)) #define LOG_DEBUG1(...) LOG((CLOG_DEBUG1 __VA_ARGS__)) #define LOG_DEBUG2(...) LOG((CLOG_DEBUG2 __VA_ARGS__)) #define LOG_DEBUG3(...) LOG((CLOG_DEBUG3 __VA_ARGS__)) #define LOG_DEBUG4(...) LOG((CLOG_DEBUG4 __VA_ARGS__)) #define LOG_DEBUG5(...) LOG((CLOG_DEBUG5 __VA_ARGS__))
8,317
C++
.h
201
39.273632
120
0.690547
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,045
FunctionEventJob.h
deskflow_deskflow/src/lib/base/FunctionEventJob.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/IEventJob.h" //! Use a function as an event job /*! An event job class that invokes a function. */ class FunctionEventJob : public IEventJob { public: //! run() invokes \c func(arg) FunctionEventJob(void (*func)(const Event &, void *), void *arg = NULL); virtual ~FunctionEventJob(); // IEventJob overrides virtual void run(const Event &); private: void (*m_func)(const Event &, void *); void *m_arg; };
1,181
C++
.h
35
31.742857
74
0.739702
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,046
Path.h
deskflow_deskflow/src/lib/base/Path.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2014-2021 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "String.h" namespace deskflow { namespace filesystem { #ifdef SYSAPI_WIN32 std::wstring path(const String &filePath); #else std::string path(const String &filePath); #endif } // namespace filesystem } // namespace deskflow
942
C++
.h
27
33.111111
72
0.768977
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,047
Unicode.h
deskflow_deskflow/src/lib/base/Unicode.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/IArchString.h" #include "base/String.h" #include "common/basic_types.h" //! Unicode utility functions /*! This class provides functions for converting between various Unicode encodings and the current locale encoding. */ class Unicode { public: //! @name accessors //@{ //! Test UTF-8 string for validity /*! Returns true iff the string contains a valid sequence of UTF-8 encoded characters. */ static bool isUTF8(const String &); //! Convert from UTF-8 to UCS-2 encoding /*! Convert from UTF-8 to UCS-2. If errors is not NULL then *errors is set to true iff any character could not be encoded in UCS-2. Decoding errors do not set *errors. */ static String UTF8ToUCS2(const String &, bool *errors = NULL); //! Convert from UTF-8 to UCS-4 encoding /*! Convert from UTF-8 to UCS-4. If errors is not NULL then *errors is set to true iff any character could not be encoded in UCS-4. Decoding errors do not set *errors. */ static String UTF8ToUCS4(const String &, bool *errors = NULL); //! Convert from UTF-8 to UTF-16 encoding /*! Convert from UTF-8 to UTF-16. If errors is not NULL then *errors is set to true iff any character could not be encoded in UTF-16. Decoding errors do not set *errors. */ static String UTF8ToUTF16(const String &, bool *errors = NULL); //! Convert from UTF-8 to UTF-32 encoding /*! Convert from UTF-8 to UTF-32. If errors is not NULL then *errors is set to true iff any character could not be encoded in UTF-32. Decoding errors do not set *errors. */ static String UTF8ToUTF32(const String &, bool *errors = NULL); //! Convert from UTF-8 to the current locale encoding /*! Convert from UTF-8 to the current locale encoding. If errors is not NULL then *errors is set to true iff any character could not be encoded. Decoding errors do not set *errors. */ static String UTF8ToText(const String &, bool *errors = NULL); //! Convert from UCS-2 to UTF-8 /*! Convert from UCS-2 to UTF-8. If errors is not NULL then *errors is set to true iff any character could not be decoded. */ static String UCS2ToUTF8(const String &, bool *errors = NULL); //! Convert from UCS-4 to UTF-8 /*! Convert from UCS-4 to UTF-8. If errors is not NULL then *errors is set to true iff any character could not be decoded. */ static String UCS4ToUTF8(const String &, bool *errors = NULL); //! Convert from UTF-16 to UTF-8 /*! Convert from UTF-16 to UTF-8. If errors is not NULL then *errors is set to true iff any character could not be decoded. */ static String UTF16ToUTF8(const String &, bool *errors = NULL); //! Convert from UTF-32 to UTF-8 /*! Convert from UTF-32 to UTF-8. If errors is not NULL then *errors is set to true iff any character could not be decoded. */ static String UTF32ToUTF8(const String &, bool *errors = NULL); //! Convert from the current locale encoding to UTF-8 /*! Convert from the current locale encoding to UTF-8. If errors is not NULL then *errors is set to true iff any character could not be decoded. */ static String textToUTF8( const String &, bool *errors = nullptr, IArchString::EWideCharEncoding encoding = IArchString::kPlatformDetermined ); //@} private: // convert UTF8 to wchar_t string (using whatever encoding is native // to the platform). caller must delete[] the returned string. the // string is *not* nul terminated; the length (in characters) is // returned in size. static wchar_t *UTF8ToWideChar(const String &, UInt32 &size, bool *errors); // convert nul terminated wchar_t string (in platform's native // encoding) to UTF8. static String wideCharToUTF8( const wchar_t *, UInt32 size, bool *errors, IArchString::EWideCharEncoding encoding = IArchString::kPlatformDetermined ); // internal conversion to UTF8 static String doUCS2ToUTF8(const UInt8 *src, UInt32 n, bool *errors); static String doUCS4ToUTF8(const UInt8 *src, UInt32 n, bool *errors); static String doUTF16ToUTF8(const UInt8 *src, UInt32 n, bool *errors); static String doUTF32ToUTF8(const UInt8 *src, UInt32 n, bool *errors); // convert characters to/from UTF8 static UInt32 fromUTF8(const UInt8 *&src, UInt32 &size); static void toUTF8(String &dst, UInt32 c, bool *errors); private: static UInt32 s_invalid; static UInt32 s_replacement; };
5,150
C++
.h
129
37.046512
120
0.730854
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,048
SimpleEventQueueBuffer.h
deskflow_deskflow/src/lib/base/SimpleEventQueueBuffer.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/IArchMultithread.h" #include "base/IEventQueueBuffer.h" #include "common/stddeque.h" //! In-memory event queue buffer /*! An event queue buffer provides a queue of events for an IEventQueue. */ class SimpleEventQueueBuffer : public IEventQueueBuffer { public: SimpleEventQueueBuffer(); SimpleEventQueueBuffer(SimpleEventQueueBuffer const &) = delete; SimpleEventQueueBuffer(SimpleEventQueueBuffer &&) = delete; ~SimpleEventQueueBuffer(); SimpleEventQueueBuffer &operator=(SimpleEventQueueBuffer const &) = delete; SimpleEventQueueBuffer &operator=(SimpleEventQueueBuffer &&) = delete; // IEventQueueBuffer overrides void init() { } virtual void waitForEvent(double timeout); virtual Type getEvent(Event &event, UInt32 &dataID); virtual bool addEvent(UInt32 dataID); virtual bool isEmpty() const; virtual EventQueueTimer *newTimer(double duration, bool oneShot) const; virtual void deleteTimer(EventQueueTimer *) const; private: typedef std::deque<UInt32> EventDeque; ArchMutex m_queueMutex; ArchCond m_queueReadyCond; bool m_queueReady; EventDeque m_queue; };
1,867
C++
.h
51
34.333333
77
0.782753
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,049
EventTypes.h
deskflow_deskflow/src/lib/base/EventTypes.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2013-2016 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/Event.h" class IEventQueue; class EventTypes { public: EventTypes(); void setEvents(IEventQueue *events); protected: IEventQueue *getEvents() const; private: IEventQueue *m_events; }; #define REGISTER_EVENT(type_, name_) \ Event::Type type_##Events::name_() \ { \ return getEvents()->registerTypeOnce(m_##name_, __FUNCTION__); \ } class ClientEvents : public EventTypes { public: //! @name accessors //@{ //! Get connected event type /*! Returns the connected event type. This is sent when the client has successfully connected to the server. */ Event::Type connected(); //! Get connection failed event type /*! Returns the connection failed event type. This is sent when the server fails for some reason. The event data is a FailInfo*. */ Event::Type connectionFailed(); //! Get connection refused event type /*! Returns the connection refused event type. This is sent when the server refuses for some reason. The event data is a FailInfo*. */ Event::Type connectionRefused(); //! Get disconnected event type /*! Returns the disconnected event type. This is sent when the client has disconnected from the server (and only after having successfully connected). */ Event::Type disconnected(); //@} private: Event::Type m_connected = Event::kUnknown; Event::Type m_connectionFailed = Event::kUnknown; Event::Type m_connectionRefused = Event::kUnknown; Event::Type m_disconnected = Event::kUnknown; }; class IStreamEvents : public EventTypes { public: IStreamEvents() : m_inputReady(Event::kUnknown), m_outputFlushed(Event::kUnknown), m_outputError(Event::kUnknown), m_inputShutdown(Event::kUnknown), m_outputShutdown(Event::kUnknown) { } //! @name accessors //@{ //! Get input ready event type /*! Returns the input ready event type. A stream sends this event when \c read() will return with data. */ Event::Type inputReady(); //! Get output flushed event type /*! Returns the output flushed event type. A stream sends this event when the output buffer has been flushed. If there have been no writes since the event was posted, calling \c shutdownOutput() or \c close() will not discard any data and \c flush() will return immediately. */ Event::Type outputFlushed(); //! Get output error event type /*! Returns the output error event type. A stream sends this event when a write has failed. */ Event::Type outputError(); //! Get input shutdown event type /*! Returns the input shutdown event type. This is sent when the input side of the stream has shutdown. When the input has shutdown, no more data will ever be available to read. */ Event::Type inputShutdown(); //! Get output shutdown event type /*! Returns the output shutdown event type. This is sent when the output side of the stream has shutdown. When the output has shutdown, no more data can ever be written to the stream. Any attempt to do so will generate a output error event. */ Event::Type outputShutdown(); //@} private: Event::Type m_inputReady; Event::Type m_outputFlushed; Event::Type m_outputError; Event::Type m_inputShutdown; Event::Type m_outputShutdown; }; class IpcClientEvents : public EventTypes { public: IpcClientEvents() : m_connected(Event::kUnknown), m_messageReceived(Event::kUnknown) { } //! @name accessors //@{ //! Raised when the socket is connected. Event::Type connected(); //! Raised when a message is received. Event::Type messageReceived(); //@} private: Event::Type m_connected; Event::Type m_messageReceived; }; class IpcClientProxyEvents : public EventTypes { public: IpcClientProxyEvents() : m_messageReceived(Event::kUnknown), m_disconnected(Event::kUnknown) { } //! @name accessors //@{ //! Raised when the server receives a message from a client. Event::Type messageReceived(); //! Raised when the client disconnects from the server. Event::Type disconnected(); //@} private: Event::Type m_messageReceived; Event::Type m_disconnected; }; class IpcServerEvents : public EventTypes { public: IpcServerEvents() : m_clientConnected(Event::kUnknown), m_messageReceived(Event::kUnknown) { } //! @name accessors //@{ //! Raised when we have created the client proxy. Event::Type clientConnected(); //! Raised when a message is received through a client proxy. Event::Type messageReceived(); //@} private: Event::Type m_clientConnected; Event::Type m_messageReceived; }; class IpcServerProxyEvents : public EventTypes { public: IpcServerProxyEvents() : m_messageReceived(Event::kUnknown) { } //! @name accessors //@{ //! Raised when the client receives a message from the server. Event::Type messageReceived(); //@} private: Event::Type m_messageReceived; }; class IDataSocketEvents : public EventTypes { public: IDataSocketEvents() : m_connected(Event::kUnknown), m_secureConnected(Event::kUnknown), m_connectionFailed(Event::kUnknown) { } //! @name accessors //@{ //! Get connected event type /*! Returns the socket connected event type. A socket sends this event when a remote connection has been established. */ Event::Type connected(); //! Get secure connected event type /*! Returns the secure socket connected event type. A secure socket sends this event when a remote connection has been established. */ Event::Type secureConnected(); //! Get connection failed event type /*! Returns the socket connection failed event type. A socket sends this event when an attempt to connect to a remote port has failed. The data is a pointer to a ConnectionFailedInfo. */ Event::Type connectionFailed(); //@} private: Event::Type m_connected; Event::Type m_secureConnected; Event::Type m_connectionFailed; }; class IListenSocketEvents : public EventTypes { public: IListenSocketEvents() : m_connecting(Event::kUnknown) { } //! @name accessors //@{ //! Get connecting event type /*! Returns the socket connecting event type. A socket sends this event when a remote connection is waiting to be accepted. */ Event::Type connecting(); //@} private: Event::Type m_connecting; }; class ISocketEvents : public EventTypes { public: ISocketEvents() : m_disconnected(Event::kUnknown), m_stopRetry(Event::kUnknown) { } //! @name accessors //@{ //! Get disconnected event type /*! Returns the socket disconnected event type. A socket sends this event when the remote side of the socket has disconnected or shutdown both input and output. */ Event::Type disconnected(); //! Get stop retry event type /*! Returns the stop retry event type. This is sent when the client doesn't want to reconnect after it disconnects from the server. */ Event::Type stopRetry(); //@} private: Event::Type m_disconnected; Event::Type m_stopRetry; }; class OSXScreenEvents : public EventTypes { public: OSXScreenEvents() : m_confirmSleep(Event::kUnknown) { } //! @name accessors //@{ Event::Type confirmSleep(); //@} private: Event::Type m_confirmSleep; }; class ClientListenerEvents : public EventTypes { public: ClientListenerEvents() : m_accepted(Event::kUnknown), m_connected(Event::kUnknown) { } //! @name accessors //@{ //! Get accepted event type /*! Returns the accepted event type. This is sent whenever a server accepts a client. */ Event::Type accepted(); //! Get connected event type /*! Returns the connected event type. This is sent whenever a a client connects. */ Event::Type connected(); //@} private: Event::Type m_accepted; Event::Type m_connected; }; class ClientProxyEvents : public EventTypes { public: ClientProxyEvents() : m_ready(Event::kUnknown), m_disconnected(Event::kUnknown) { } //! @name accessors //@{ //! Get ready event type /*! Returns the ready event type. This is sent when the client has completed the initial handshake. Until it is sent, the client is not fully connected. */ Event::Type ready(); //! Get disconnect event type /*! Returns the disconnect event type. This is sent when the client disconnects or is disconnected. The target is getEventTarget(). */ Event::Type disconnected(); //@} private: Event::Type m_ready; Event::Type m_disconnected; }; class ClientProxyUnknownEvents : public EventTypes { public: ClientProxyUnknownEvents() : m_success(Event::kUnknown), m_failure(Event::kUnknown) { } //! @name accessors //@{ //! Get success event type /*! Returns the success event type. This is sent when the client has correctly responded to the hello message. The target is this. */ Event::Type success(); //! Get failure event type /*! Returns the failure event type. This is sent when a client fails to correctly respond to the hello message. The target is this. */ Event::Type failure(); //@} private: Event::Type m_success; Event::Type m_failure; }; class ServerEvents : public EventTypes { public: ServerEvents() : m_error(Event::kUnknown), m_connected(Event::kUnknown), m_disconnected(Event::kUnknown), m_switchToScreen(Event::kUnknown), m_switchInDirection(Event::kUnknown), m_keyboardBroadcast(Event::kUnknown), m_lockCursorToScreen(Event::kUnknown), m_screenSwitched(Event::kUnknown) { } //! @name accessors //@{ //! Get error event type /*! Returns the error event type. This is sent when the server fails for some reason. */ Event::Type error(); //! Get connected event type /*! Returns the connected event type. This is sent when a client screen has connected. The event data is a \c ScreenConnectedInfo* that indicates the connected screen. */ Event::Type connected(); //! Get disconnected event type /*! Returns the disconnected event type. This is sent when all the clients have disconnected. */ Event::Type disconnected(); //! Get switch to screen event type /*! Returns the switch to screen event type. The server responds to this by switching screens. The event data is a \c SwitchToScreenInfo* that indicates the target screen. */ Event::Type switchToScreen(); //! Get switch in direction event type /*! Returns the switch in direction event type. The server responds to this by switching screens. The event data is a \c SwitchInDirectionInfo* that indicates the target direction. */ Event::Type switchInDirection(); //! Get keyboard broadcast event type /*! Returns the keyboard broadcast event type. The server responds to this by turning on keyboard broadcasting or turning it off. The event data is a \c KeyboardBroadcastInfo*. */ Event::Type keyboardBroadcast(); //! Get lock cursor event type /*! Returns the lock cursor event type. The server responds to this by locking the cursor to the active screen or unlocking it. The event data is a \c LockCursorToScreenInfo*. */ Event::Type lockCursorToScreen(); //! Get screen switched event type /*! Returns the screen switched event type. This is raised when the screen has been switched to a client. */ Event::Type screenSwitched(); //@} private: Event::Type m_error; Event::Type m_connected; Event::Type m_disconnected; Event::Type m_switchToScreen; Event::Type m_switchInDirection; Event::Type m_keyboardBroadcast; Event::Type m_lockCursorToScreen; Event::Type m_screenSwitched; }; class ServerAppEvents : public EventTypes { public: ServerAppEvents() : m_reloadConfig(Event::kUnknown), m_forceReconnect(Event::kUnknown), m_resetServer(Event::kUnknown) { } //! @name accessors //@{ Event::Type reloadConfig(); Event::Type forceReconnect(); Event::Type resetServer(); //@} private: Event::Type m_reloadConfig; Event::Type m_forceReconnect; Event::Type m_resetServer; }; class IKeyStateEvents : public EventTypes { public: IKeyStateEvents() : m_keyDown(Event::kUnknown), m_keyUp(Event::kUnknown), m_keyRepeat(Event::kUnknown) { } //! @name accessors //@{ //! Get key down event type. Event data is KeyInfo*, count == 1. Event::Type keyDown(); //! Get key up event type. Event data is KeyInfo*, count == 1. Event::Type keyUp(); //! Get key repeat event type. Event data is KeyInfo*. Event::Type keyRepeat(); //@} private: Event::Type m_keyDown; Event::Type m_keyUp; Event::Type m_keyRepeat; }; class IPrimaryScreenEvents : public EventTypes { public: IPrimaryScreenEvents() : m_buttonDown(Event::kUnknown), m_buttonUp(Event::kUnknown), m_motionOnPrimary(Event::kUnknown), m_motionOnSecondary(Event::kUnknown), m_wheel(Event::kUnknown), m_screensaverActivated(Event::kUnknown), m_screensaverDeactivated(Event::kUnknown), m_hotKeyDown(Event::kUnknown), m_hotKeyUp(Event::kUnknown), m_fakeInputBegin(Event::kUnknown), m_fakeInputEnd(Event::kUnknown) { } //! @name accessors //@{ //! button down event type. Event data is ButtonInfo*. Event::Type buttonDown(); //! button up event type. Event data is ButtonInfo*. Event::Type buttonUp(); //! mouse motion on the primary screen event type /*! Event data is MotionInfo* and the values are an absolute position. */ Event::Type motionOnPrimary(); //! mouse motion on a secondary screen event type /*! Event data is MotionInfo* and the values are motion deltas not absolute coordinates. */ Event::Type motionOnSecondary(); //! mouse wheel event type. Event data is WheelInfo*. Event::Type wheel(); //! screensaver activated event type Event::Type screensaverActivated(); //! screensaver deactivated event type Event::Type screensaverDeactivated(); //! hot key down event type. Event data is HotKeyInfo*. Event::Type hotKeyDown(); //! hot key up event type. Event data is HotKeyInfo*. Event::Type hotKeyUp(); //! start of fake input event type Event::Type fakeInputBegin(); //! end of fake input event type Event::Type fakeInputEnd(); //@} private: Event::Type m_buttonDown; Event::Type m_buttonUp; Event::Type m_motionOnPrimary; Event::Type m_motionOnSecondary; Event::Type m_wheel; Event::Type m_screensaverActivated; Event::Type m_screensaverDeactivated; Event::Type m_hotKeyDown; Event::Type m_hotKeyUp; Event::Type m_fakeInputBegin; Event::Type m_fakeInputEnd; }; class IScreenEvents : public EventTypes { public: IScreenEvents() : m_error(Event::kUnknown), m_shapeChanged(Event::kUnknown), m_suspend(Event::kUnknown), m_resume(Event::kUnknown) { } //! @name accessors //@{ //! Get error event type /*! Returns the error event type. This is sent whenever the screen has failed for some reason (e.g. the X Windows server died). */ Event::Type error(); //! Get shape changed event type /*! Returns the shape changed event type. This is sent whenever the screen's shape changes. */ Event::Type shapeChanged(); //! Get suspend event type /*! Returns the suspend event type. This is sent whenever the system goes to sleep or a user session is deactivated (fast user switching). */ Event::Type suspend(); //! Get resume event type /*! Returns the resume event type. This is sent whenever the system wakes up or a user session is activated (fast user switching). */ Event::Type resume(); //@} private: Event::Type m_error; Event::Type m_shapeChanged; Event::Type m_suspend; Event::Type m_resume; }; class ClipboardEvents : public EventTypes { public: ClipboardEvents() : m_clipboardGrabbed(Event::kUnknown), m_clipboardChanged(Event::kUnknown), m_clipboardSending(Event::kUnknown) { } //! @name accessors //@{ //! Get clipboard grabbed event type /*! Returns the clipboard grabbed event type. This is sent whenever the clipboard is grabbed by some other application so we don't own it anymore. The data is a pointer to a ClipboardInfo. */ Event::Type clipboardGrabbed(); //! Get clipboard changed event type /*! Returns the clipboard changed event type. This is sent whenever the contents of the clipboard has changed. The data is a pointer to a IScreen::ClipboardInfo. */ Event::Type clipboardChanged(); //! Clipboard sending event type /*! Returns the clipboard sending event type. This is used to send clipboard chunks. */ Event::Type clipboardSending(); //@} private: Event::Type m_clipboardGrabbed; Event::Type m_clipboardChanged; Event::Type m_clipboardSending; }; class FileEvents : public EventTypes { public: FileEvents() : m_fileChunkSending(Event::kUnknown), m_fileRecieveCompleted(Event::kUnknown), m_keepAlive(Event::kUnknown) { } //! @name accessors //@{ //! Sending a file chunk Event::Type fileChunkSending(); //! Completed receiving a file Event::Type fileRecieveCompleted(); //! Send a keep alive Event::Type keepAlive(); //@} private: Event::Type m_fileChunkSending; Event::Type m_fileRecieveCompleted; Event::Type m_keepAlive; }; class EiEvents : public EventTypes { public: EiEvents() : m_connected(Event::kUnknown), m_sessionClosed(Event::kUnknown) { } //! @name accessors //@{ //! Get connected event type /*! This event is sent whenever connection to EIS is established and a file descriptor for reading events is available. */ Event::Type connected(); //! Get session closed event type /*! This event is sent whenever the portal session managing our EIS connection is closed. */ Event::Type sessionClosed(); //@} private: Event::Type m_connected; Event::Type m_sessionClosed; };
19,080
C++
.h
669
25.331839
120
0.704552
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,050
ServerProxy.h
deskflow_deskflow/src/lib/client/ServerProxy.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/Event.h" #include "base/Stopwatch.h" #include "base/String.h" #include "deskflow/clipboard_types.h" #include "deskflow/key_types.h" #include "deskflow/languages/LanguageManager.h" class Client; class ClientInfo; class EventQueueTimer; class IClipboard; namespace deskflow { class IStream; } class IEventQueue; //! Proxy for server /*! This class acts a proxy for the server, converting calls into messages to the server and messages from the server to calls on the client. */ class ServerProxy { public: /*! Process messages from the server on \p stream and forward to \p client. */ ServerProxy(Client *client, deskflow::IStream *stream, IEventQueue *events); ServerProxy(ServerProxy const &) = delete; ServerProxy(ServerProxy &&) = delete; ~ServerProxy(); ServerProxy &operator=(ServerProxy const &) = delete; ServerProxy &operator=(ServerProxy &&) = delete; //! @name manipulators //@{ void onInfoChanged(); bool onGrabClipboard(ClipboardID); void onClipboardChanged(ClipboardID, const IClipboard *); //@} // sending file chunk to server void fileChunkSending(UInt8 mark, char *data, size_t dataSize); // sending dragging information to server void sendDragInfo(UInt32 fileCount, const char *info, size_t size); #ifdef TEST_ENV void handleDataForTest() { handleData(Event(), NULL); } #endif protected: enum EResult { kOkay, kUnknown, kDisconnect }; EResult parseHandshakeMessage(const UInt8 *code); EResult parseMessage(const UInt8 *code); private: // if compressing mouse motion then send the last motion now void flushCompressedMouse(); void sendInfo(const ClientInfo &); void resetKeepAliveAlarm(); void setKeepAliveRate(double); // modifier key translation KeyID translateKey(KeyID) const; KeyModifierMask translateModifierMask(KeyModifierMask) const; // event handlers void handleData(const Event &, void *); void handleKeepAliveAlarm(const Event &, void *); // message handlers void enter(); void leave(); void setClipboard(); void grabClipboard(); void keyDown(UInt16 id, UInt16 mask, UInt16 button, const String &lang); void keyRepeat(); void keyUp(); void mouseDown(); void mouseUp(); void mouseMove(); void mouseRelativeMove(); void mouseWheel(); void screensaver(); void resetOptions(); void setOptions(); void queryInfo(); void infoAcknowledgment(); void fileChunkReceived(); void dragInfoReceived(); void handleClipboardSendingEvent(const Event &, void *); void secureInputNotification(); void setServerLanguages(); void setActiveServerLanguage(const String &language); void checkMissedLanguages() const; private: typedef EResult (ServerProxy::*MessageParser)(const UInt8 *); Client *m_client; deskflow::IStream *m_stream; UInt32 m_seqNum; bool m_compressMouse; bool m_compressMouseRelative; SInt32 m_xMouse, m_yMouse; SInt32 m_dxMouse, m_dyMouse; bool m_ignoreMouse; KeyModifierID m_modifierTranslationTable[kKeyModifierIDLast]; double m_keepAliveAlarm; EventQueueTimer *m_keepAliveAlarmTimer; MessageParser m_parser; IEventQueue *m_events; String m_serverLanguage = ""; bool m_isUserNotifiedAboutLanguageSyncError = false; deskflow::languages::LanguageManager m_languageManager; };
4,061
C++
.h
131
28.320611
78
0.764344
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
14,051
Client.h
deskflow_deskflow/src/lib/client/Client.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "deskflow/IClient.h" #include "HelloBack.h" #include "base/EventTypes.h" #include "deskflow/ClientArgs.h" #include "deskflow/Clipboard.h" #include "deskflow/DragInformation.h" #include "deskflow/INode.h" #include "mt/CondVar.h" #include "net/NetworkAddress.h" #include <memory> class EventQueueTimer; namespace deskflow { class Screen; } class ServerProxy; class IDataSocket; class ISocketFactory; namespace deskflow { class IStream; } class IEventQueue; class Thread; class TCPSocket; //! Deskflow client /*! This class implements the top-level client algorithms for deskflow. */ class Client : public IClient, public INode { public: class FailInfo { public: FailInfo(const char *what) : m_retry(false), m_what(what) { } bool m_retry; String m_what; }; public: /*! This client will attempt to connect to the server using \p name as its name and \p address as the server's address and \p factory to create the socket. \p screen is the local screen. */ Client( IEventQueue *events, const String &name, const NetworkAddress &address, ISocketFactory *socketFactory, deskflow::Screen *screen, deskflow::ClientArgs const &args ); Client(Client const &) = delete; Client(Client &&) = delete; ~Client(); Client &operator=(Client const &) = delete; Client &operator=(Client &&) = delete; //! @name manipulators //@{ //! Connect to server /*! Starts an attempt to connect to the server. This is ignored if the client is trying to connect or is already connected. */ void connect(size_t addressIndex = 0); //! Disconnect /*! Disconnects from the server with an optional error message. */ void disconnect(const char *msg); //! Refuse connection /*! Disconnects from the server with an optional error message. Unlike disconnect this function doesn't try to use other ip addresses */ void refuseConnection(const char *msg); //! Notify of handshake complete /*! Notifies the client that the connection handshake has completed. */ virtual void handshakeComplete(); //! Received drag information void dragInfoReceived(UInt32 fileNum, String data); //! Create a new thread and use it to send file to Server void sendFileToServer(const char *filename); //! Send dragging file information back to server void sendDragInfo(UInt32 fileCount, String &info, size_t size); //@} //! @name accessors //@{ //! Test if connected /*! Returns true iff the client is successfully connected to the server. */ bool isConnected() const; //! Test if connecting /*! Returns true iff the client is currently attempting to connect to the server. */ bool isConnecting() const; //! Get address of server /*! Returns the address of the server the client is connected (or wants to connect) to. */ NetworkAddress getServerAddress() const; //! Return true if received file size is valid bool isReceivedFileSizeValid(); //! Return expected file size size_t &getExpectedFileSize() { return m_expectedFileSize; } //! Return received file data String &getReceivedFileData() { return m_receivedFileData; } //! Return drag file list DragFileList getDragFileList() { return m_dragFileList; } //! Return last resolved adresses count size_t getLastResolvedAddressesCount() const { return m_resolvedAddressesCount; } //@} // IScreen overrides virtual void *getEventTarget() const; virtual bool getClipboard(ClipboardID id, IClipboard *) const; virtual void getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const; virtual void getCursorPos(SInt32 &x, SInt32 &y) const; // IClient overrides virtual void enter(SInt32 xAbs, SInt32 yAbs, UInt32 seqNum, KeyModifierMask mask, bool forScreensaver); virtual bool leave(); virtual void setClipboard(ClipboardID, const IClipboard *); virtual void grabClipboard(ClipboardID); virtual void setClipboardDirty(ClipboardID, bool); virtual void keyDown(KeyID, KeyModifierMask, KeyButton, const String &); virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count, KeyButton, const String &lang); virtual void keyUp(KeyID, KeyModifierMask, KeyButton); virtual void mouseDown(ButtonID); virtual void mouseUp(ButtonID); virtual void mouseMove(SInt32 xAbs, SInt32 yAbs); virtual void mouseRelativeMove(SInt32 xRel, SInt32 yRel); virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta); virtual void screensaver(bool activate); virtual void resetOptions(); virtual void setOptions(const OptionsList &options); virtual String getName() const; private: void sendClipboard(ClipboardID); void sendEvent(Event::Type, void *); void sendConnectionFailedEvent(const char *msg); void sendFileChunk(const void *data); void sendFileThread(void *); void writeToDropDirThread(void *); void setupConnecting(); void setupConnection(); void setupScreen(); void setupTimer(); void cleanup(); void cleanupConnecting(); void cleanupConnection(); void cleanupScreen(); void cleanupTimer(); void cleanupStream(); void handleConnected(const Event &, void *); void handleConnectionFailed(const Event &, void *); void handleConnectTimeout(const Event &, void *); void handleOutputError(const Event &, void *); void handleDisconnected(const Event &, void *); void handleShapeChanged(const Event &, void *); void handleClipboardGrabbed(const Event &, void *); void handleHello(const Event &, void *); void handleSuspend(const Event &event, void *); void handleResume(const Event &event, void *); void handleFileChunkSending(const Event &, void *); void handleFileRecieveCompleted(const Event &, void *); void handleStopRetry(const Event &, void *); void onFileRecieveCompleted(); void sendClipboardThread(void *); void bindNetworkInterface(IDataSocket *socket) const; public: bool m_mock; private: String m_name; NetworkAddress m_serverAddress; ISocketFactory *m_socketFactory; deskflow::Screen *m_screen; deskflow::IStream *m_stream; EventQueueTimer *m_timer; ServerProxy *m_server; bool m_ready; bool m_active; bool m_suspended; bool m_connectOnResume; bool m_ownClipboard[kClipboardEnd]; bool m_sentClipboard[kClipboardEnd]; IClipboard::Time m_timeClipboard[kClipboardEnd]; String m_dataClipboard[kClipboardEnd]; IEventQueue *m_events; std::size_t m_expectedFileSize; String m_receivedFileData; DragFileList m_dragFileList; String m_dragFileExt; using AutoThread = std::unique_ptr<Thread>; AutoThread m_sendFileThread; AutoThread m_writeToDropDirThread; bool m_useSecureNetwork; bool m_enableClipboard; size_t m_maximumClipboardSize; deskflow::ClientArgs m_args; size_t m_resolvedAddressesCount = 0; std::unique_ptr<deskflow::client::HelloBack> m_pHelloBack; };
7,604
C++
.h
234
29.636752
108
0.754462
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,052
HelloBack.h
deskflow_deskflow/src/lib/client/HelloBack.h
/* * Deskflow -- mouse and keyboard sharing utility * * SPDX-FileCopyrightText: Copyright (C) 2024 Symless Ltd. * SPDX-License-Identifier: GPL-2.0 */ #pragma once #include "common/basic_types.h" #include "deskflow/protocol_types.h" #include "io/IStream.h" #include <functional> #include <memory> namespace deskflow::client { class HelloBack { public: struct Deps { Deps() = default; explicit Deps(std::function<void()> invalidHello, std::function<void(int, int)> incompatible) : m_invalidHello(std::move(invalidHello)), m_incompatible(std::move(incompatible)) { } virtual ~Deps() = default; /** * @brief Call when invalid hello message received from server. */ virtual void invalidHello(); /** * @brief Call when the client is incompatible with the server. */ virtual void incompatible(int major, int minor); private: std::function<void()> m_invalidHello; std::function<void(int, int)> m_incompatible; }; explicit HelloBack( std::shared_ptr<Deps> deps, const SInt16 majorVersion = kProtocolMajorVersion, const SInt16 minorVersion = kProtocolMinorVersion ) : m_deps(deps), m_majorVersion(majorVersion), m_minorVersion(minorVersion) { } /** * @brief Handle hello message from server and reply with hello back. */ void handleHello(deskflow::IStream *stream, const std::string &clientName) const; private: bool shouldDowngrade(int major, int minor) const; std::shared_ptr<Deps> m_deps; SInt16 m_majorVersion; SInt16 m_minorVersion; }; } // namespace deskflow::client
1,631
C++
.h
57
24.666667
97
0.704036
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,053
XMT.h
deskflow_deskflow/src/lib/mt/XMT.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/XBase.h" //! Generic multithreading exception XBASE_SUBCLASS(XMT, XBase); //! Thread creation exception /*! Thrown when a thread cannot be created. */ XBASE_SUBCLASS_WHAT(XMTThreadUnavailable, XMT);
961
C++
.h
26
35.192308
72
0.767991
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
14,054
XThread.h
deskflow_deskflow/src/lib/mt/XThread.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/XArch.h" //! Thread exception to exit /*! Thrown by Thread::exit() to exit a thread. Clients of Thread must not throw this type but must rethrow it if caught (by XThreadExit, XThread, or ...). */ class XThreadExit : public XThread { public: //! \c result is the result of the thread XThreadExit(void *result) : m_result(result) { } ~XThreadExit() { } public: void *m_result; };
1,157
C++
.h
38
28.5
72
0.742601
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,055
Mutex.h
deskflow_deskflow/src/lib/mt/Mutex.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/IArchMultithread.h" //! Mutual exclusion /*! A non-recursive mutual exclusion object. Only one thread at a time can hold a lock on a mutex. Any thread that attempts to lock a locked mutex will block until the mutex is unlocked. At that time, if any threads are blocked, exactly one waiting thread will acquire the lock and continue running. A thread may not lock a mutex it already owns the lock on; if it tries it will deadlock itself. */ class Mutex { public: Mutex(); //! Equivalent to default c'tor /*! Copy c'tor doesn't copy anything. It just makes it possible to copy objects that contain a mutex. */ Mutex(const Mutex &); ~Mutex(); //! @name manipulators //@{ //! Does nothing /*! This does nothing. It just makes it possible to assign objects that contain a mutex. */ Mutex &operator=(const Mutex &); //@} //! @name accessors //@{ //! Lock the mutex /*! Locks the mutex, which must not have been previously locked by the calling thread. This blocks if the mutex is already locked by another thread. (cancellation point) */ void lock() const; //! Unlock the mutex /*! Unlocks the mutex, which must have been previously locked by the calling thread. */ void unlock() const; //@} private: friend class CondVarBase; ArchMutex m_mutex; };
2,092
C++
.h
69
27.884058
73
0.733101
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,056
Thread.h
deskflow_deskflow/src/lib/mt/Thread.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/IArchMultithread.h" class IJob; //! Thread handle /*! Creating a Thread creates a new context of execution (i.e. thread) that runs simulatenously with the calling thread. A Thread is only a handle to a thread; deleting a Thread does not cancel or destroy the thread it refers to and multiple Thread objects can refer to the same thread. Threads can terminate themselves but cannot be forced to terminate by other threads. However, other threads can signal a thread to terminate itself by cancelling it. And a thread can wait (block) on another thread to terminate. Most functions that can block for an arbitrary time are cancellation points. A cancellation point is a function that can be interrupted by a request to cancel the thread. Cancellation points are noted in the documentation. */ // note -- do not derive from this class class Thread { public: //! Run \c adoptedJob in a new thread /*! Create and start a new thread executing the \c adoptedJob. The new thread takes ownership of \c adoptedJob and will delete it. */ Thread(IJob *adoptedJob); //! Duplicate a thread handle /*! Make a new thread object that refers to an existing thread. This does \b not start a new thread. */ Thread(const Thread &); //! Release a thread handle /*! Release a thread handle. This does not terminate the thread. A thread will keep running until the job completes or calls exit() or allows itself to be cancelled. */ ~Thread(); //! @name manipulators //@{ //! Assign thread handle /*! Assign a thread handle. This has no effect on the threads, it simply makes this thread object refer to another thread. It does \b not start a new thread. */ Thread &operator=(const Thread &); //! Terminate the calling thread /*! Terminate the calling thread. This function does not return but the stack is unwound and automatic objects are destroyed, as if exit() threw an exception (which is, in fact, what it does). The argument is saved as the result returned by getResult(). If you have \c catch(...) blocks then you should add the following before each to avoid catching the exit: \code catch(ThreadExit&) { throw; } \endcode or add the \c RETHROW_XTHREAD macro to the \c catch(...) block. */ static void exit(void *); //! Cancel thread /*! Cancel the thread. cancel() never waits for the thread to terminate; it just posts the cancel and returns. A thread will terminate when it enters a cancellation point with cancellation enabled. If cancellation is disabled then the cancel is remembered but not acted on until the first call to a cancellation point after cancellation is enabled. A cancellation point is a function that can act on cancellation. A cancellation point does not return if there's a cancel pending. Instead, it unwinds the stack and destroys automatic objects, as if cancel() threw an exception (which is, in fact, what it does). Threads must take care to unlock and clean up any resources they may have, especially mutexes. They can \c catch(XThreadCancel) to do that then rethrow the exception or they can let it happen automatically by doing clean up in the d'tors of automatic objects (like Lock). Clients are strongly encouraged to do the latter. During cancellation, further cancel() calls are ignored (i.e. a thread cannot be interrupted by a cancel during cancellation). Clients that \c catch(XThreadCancel) must always rethrow the exception. Clients that \c catch(...) must either rethrow the exception or include a \c catch(XThreadCancel) handler that rethrows. The \c RETHROW_XTHREAD macro may be useful for that. */ void cancel(); //! Change thread priority /*! Change the priority of the thread. Normal priority is 0, 1 is the next lower, etc. -1 is the next higher, etc. but boosting the priority may not be permitted and will be silenty ignored. */ void setPriority(int n); //! Force pollSocket() to return /*! Forces a currently blocked pollSocket() in the thread to return immediately. */ void unblockPollSocket(); //@} //! @name accessors //@{ //! Get current thread's handle /*! Return a Thread object representing the calling thread. */ static Thread getCurrentThread(); //! Test for cancellation /*! testCancel() does nothing but is a cancellation point. Call this to make a function itself a cancellation point. If the thread was cancelled and cancellation is enabled this will cause the thread to unwind the stack and terminate. (cancellation point) */ static void testCancel(); //! Wait for thread to terminate /*! Waits for the thread to terminate (by exit() or cancel() or by returning from the thread job) for up to \c timeout seconds, returning true if the thread terminated and false otherwise. This returns immediately with false if called by a thread on itself and immediately with true if the thread has already terminated. This will wait forever if \c timeout < 0.0. (cancellation point) */ bool wait(double timeout = -1.0) const; //! Get the exit result /*! Returns the exit result. This does an implicit wait(). It returns NULL immediately if called by a thread on itself or on a thread that was cancelled. (cancellation point) */ void *getResult() const; //! Get the thread id /*! Returns an integer id for this thread. This id must not be used to check if two Thread objects refer to the same thread. Use operator==() for that. */ IArchMultithread::ThreadID getID() const; //! Compare thread handles /*! Returns true if two Thread objects refer to the same thread. */ bool operator==(const Thread &) const; //! Compare thread handles /*! Returns true if two Thread objects do not refer to the same thread. */ bool operator!=(const Thread &) const; //@} private: Thread(ArchThread); static void *threadFunc(void *); private: ArchThread m_thread; };
6,778
C++
.h
179
35.072626
73
0.744823
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,057
Lock.h
deskflow_deskflow/src/lib/mt/Lock.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "common/common.h" class Mutex; class CondVarBase; //! Mutual exclusion lock utility /*! This class locks a mutex or condition variable in the c'tor and unlocks it in the d'tor. It's easier and safer than manually locking and unlocking since unlocking must usually be done no matter how a function exits (including by unwinding due to an exception). */ class Lock { public: //! Lock the mutex \c mutex Lock(const Mutex *mutex); //! Lock the condition variable \c cv Lock(const CondVarBase *cv); //! Unlock the mutex or condition variable ~Lock(); private: // not implemented Lock(const Lock &); Lock &operator=(const Lock &); private: const Mutex *m_mutex; };
1,438
C++
.h
44
30.727273
72
0.755764
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
14,058
CondVar.h
deskflow_deskflow/src/lib/mt/CondVar.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "common/basic_types.h" #include "mt/Mutex.h" class Stopwatch; //! Generic condition variable /*! This class provides functionality common to all condition variables but doesn't provide the actual variable storage. A condition variable is a multiprocessing primitive that can be waited on. Every condition variable has an associated mutex. */ class CondVarBase { public: /*! \c mutex must not be NULL. All condition variables have an associated mutex. The mutex needn't be unique to one condition variable. */ CondVarBase(Mutex *mutex); ~CondVarBase(); //! @name manipulators //@{ //! Lock the condition variable's mutex /*! Lock the condition variable's mutex. The condition variable should be locked before reading or writing it. It must be locked for a call to wait(). Locks are not recursive; locking a locked mutex will deadlock the thread. */ void lock() const; //! Unlock the condition variable's mutex void unlock() const; //! Signal the condition variable /*! Wake up one waiting thread, if there are any. Which thread gets woken is undefined. */ void signal(); //! Signal the condition variable /*! Wake up all waiting threads, if any. */ void broadcast(); //@} //! @name accessors //@{ //! Wait on the condition variable /*! Wait on the condition variable. If \c timeout < 0 then wait until signalled, otherwise up to \c timeout seconds or until signalled, whichever comes first. Returns true if the object was signalled during the wait, false otherwise. The proper way to wait for a condition is: \code cv.lock(); while (cv-expr) { cv.wait(); } cv.unlock(); \endcode where \c cv-expr involves the value of \c cv and is false when the condition is satisfied. (cancellation point) */ bool wait(double timeout = -1.0) const; //! Wait on the condition variable /*! Same as \c wait(double) but use \c timer to compare against \c timeout. Since clients normally wait on condition variables in a loop, clients can use this to avoid recalculating \c timeout on each iteration. Passing a stopwatch with a negative \c timeout is pointless (it will never time out) but permitted. (cancellation point) */ bool wait(Stopwatch &timer, double timeout) const; //! Get the mutex /*! Get the mutex passed to the c'tor. */ Mutex *getMutex() const; //@} private: // not implemented CondVarBase(const CondVarBase &); CondVarBase &operator=(const CondVarBase &); private: Mutex *m_mutex; ArchCond m_cond; }; //! Condition variable /*! A condition variable with storage for type \c T. */ template <class T> class CondVar : public CondVarBase { public: //! Initialize using \c value CondVar(Mutex *mutex, const T &value); //! Initialize using another condition variable's value CondVar(const CondVar &); ~CondVar(); //! @name manipulators //@{ //! Assigns the value of \c cv to this /*! Set the variable's value. The condition variable should be locked before calling this method. */ CondVar &operator=(const CondVar &cv); //! Assigns \c value to this /*! Set the variable's value. The condition variable should be locked before calling this method. */ CondVar &operator=(const T &v); //@} //! @name accessors //@{ //! Get the variable's value /*! Get the variable's value. The condition variable should be locked before calling this method. */ operator const volatile T &() const; //@} private: volatile T m_data; }; template <class T> inline CondVar<T>::CondVar(Mutex *mutex, const T &data) : CondVarBase(mutex), m_data(data) { // do nothing } template <class T> inline CondVar<T>::CondVar(const CondVar &cv) : CondVarBase(cv.getMutex()), m_data(cv.m_data) { // do nothing } template <class T> inline CondVar<T>::~CondVar() { // do nothing } template <class T> inline CondVar<T> &CondVar<T>::operator=(const CondVar<T> &cv) { m_data = cv.m_data; return *this; } template <class T> inline CondVar<T> &CondVar<T>::operator=(const T &data) { m_data = data; return *this; } template <class T> inline CondVar<T>::operator const volatile T &() const { return m_data; }
4,979
C++
.h
172
26.348837
112
0.720779
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
14,059
TCPSocket.h
deskflow_deskflow/src/lib/net/TCPSocket.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/IArchNetwork.h" #include "io/StreamBuffer.h" #include "mt/CondVar.h" #include "mt/Mutex.h" #include "net/IDataSocket.h" class Mutex; class Thread; class ISocketMultiplexerJob; class IEventQueue; class SocketMultiplexer; //! TCP data socket /*! A data socket using TCP. */ class TCPSocket : public IDataSocket { public: TCPSocket( IEventQueue *events, SocketMultiplexer *socketMultiplexer, IArchNetwork::EAddressFamily family = IArchNetwork::kINET ); TCPSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, ArchSocket socket); TCPSocket(TCPSocket const &) = delete; TCPSocket(TCPSocket &&) = delete; virtual ~TCPSocket(); TCPSocket &operator=(TCPSocket const &) = delete; TCPSocket &operator=(TCPSocket &&) = delete; // ISocket overrides virtual void bind(const NetworkAddress &); virtual void close(); virtual void *getEventTarget() const; // IStream overrides virtual UInt32 read(void *buffer, UInt32 n); virtual void write(const void *buffer, UInt32 n); virtual void flush(); virtual void shutdownInput(); virtual void shutdownOutput(); virtual bool isReady() const; virtual bool isFatal() const; virtual UInt32 getSize() const; // IDataSocket overrides virtual void connect(const NetworkAddress &); virtual ISocketMultiplexerJob *newJob(); protected: enum EJobResult { kBreak = -1, //!< Break the Job chain kRetry, //!< Retry the same job kNew //!< Require a new job }; ArchSocket getSocket() { return m_socket; } IEventQueue *getEvents() { return m_events; } virtual EJobResult doRead(); virtual EJobResult doWrite(); void setJob(ISocketMultiplexerJob *); bool isReadable() { return m_readable; } bool isWritable() { return m_writable; } Mutex &getMutex() { return m_mutex; } void sendEvent(Event::Type); void discardWrittenData(int bytesWrote); private: void init(); void sendConnectionFailedEvent(const char *); void onConnected(); void onInputShutdown(); void onOutputShutdown(); void onDisconnected(); ISocketMultiplexerJob *serviceConnecting(ISocketMultiplexerJob *, bool, bool, bool); ISocketMultiplexerJob *serviceConnected(ISocketMultiplexerJob *, bool, bool, bool); protected: bool m_readable; bool m_writable; bool m_connected; IEventQueue *m_events; StreamBuffer m_inputBuffer; StreamBuffer m_outputBuffer; private: Mutex m_mutex; ArchSocket m_socket; CondVar<bool> m_flushed; SocketMultiplexer *m_socketMultiplexer; };
3,313
C++
.h
115
25.982609
90
0.748584
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
14,060
SocketMultiplexer.h
deskflow_deskflow/src/lib/net/SocketMultiplexer.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/IArchNetwork.h" #include "common/stdlist.h" #include "common/stdmap.h" template <class T> class CondVar; class Mutex; class Thread; class ISocket; class ISocketMultiplexerJob; //! Socket multiplexer /*! A socket multiplexer services multiple sockets simultaneously. */ class SocketMultiplexer { public: SocketMultiplexer(); SocketMultiplexer(SocketMultiplexer const &) = delete; SocketMultiplexer(SocketMultiplexer &&) = delete; ~SocketMultiplexer(); SocketMultiplexer &operator=(SocketMultiplexer const &) = delete; SocketMultiplexer &operator=(SocketMultiplexer &&) = delete; //! @name manipulators //@{ void addSocket(ISocket *, ISocketMultiplexerJob *); void removeSocket(ISocket *); //@} //! @name accessors //@{ // maybe belongs on ISocketMultiplexer static SocketMultiplexer *getInstance(); //@} private: // list of jobs. we use a list so we can safely iterate over it // while other threads modify it. typedef std::list<ISocketMultiplexerJob *> SocketJobs; typedef SocketJobs::iterator JobCursor; typedef std::map<ISocket *, JobCursor> SocketJobMap; // service sockets. the service thread will only access m_sockets // and m_update while m_pollable and m_polling are true. all other // threads must only modify these when m_pollable and m_polling are // false. only the service thread sets m_polling. void serviceThread(void *); // create, iterate, and destroy a cursor. a cursor is used to // safely iterate through the job list while other threads modify // the list. it works by inserting a dummy item in the list and // moving that item through the list. the dummy item will never // be removed by other edits so an iterator pointing at the item // remains valid until we remove the dummy item in deleteCursor(). // nextCursor() finds the next non-dummy item, moves our dummy // item just past it, and returns an iterator for the non-dummy // item. all cursor calls lock the mutex for their duration. JobCursor newCursor(); JobCursor nextCursor(JobCursor); void deleteCursor(JobCursor); // lock out locking the job list. this blocks if another thread // has already locked out locking. once it returns, only the // calling thread will be able to lock the job list after any // current lock is released. void lockJobListLock(); // lock the job list. this blocks if the job list is already // locked. the calling thread must have called requestJobLock. void lockJobList(); // unlock the job list and the lock out on locking. void unlockJobList(); private: Mutex *m_mutex; Thread *m_thread; bool m_update; CondVar<bool> *m_jobsReady; CondVar<bool> *m_jobListLock; CondVar<bool> *m_jobListLockLocked; Thread *m_jobListLocker; Thread *m_jobListLockLocker; SocketJobs m_socketJobs; SocketJobMap m_socketJobMap; ISocketMultiplexerJob *m_cursorMark; };
3,664
C++
.h
95
35.957895
72
0.755775
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,061
SecureListenSocket.h
deskflow_deskflow/src/lib/net/SecureListenSocket.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2015-2016 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "common/stdset.h" #include "net/TCPListenSocket.h" class IEventQueue; class SocketMultiplexer; class IDataSocket; class SecureListenSocket : public TCPListenSocket { public: SecureListenSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, IArchNetwork::EAddressFamily family); // IListenSocket overrides virtual IDataSocket *accept(); };
1,075
C++
.h
29
35.172414
117
0.787704
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,062
XSocket.h
deskflow_deskflow/src/lib/net/XSocket.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/String.h" #include "base/XBase.h" #include "common/basic_types.h" #include "io/XIO.h" //! Generic socket exception XBASE_SUBCLASS(XSocket, XBase); //! Socket bad address exception /*! Thrown when attempting to create an invalid network address. */ class XSocketAddress : public XSocket { public: //! Failure codes enum EError { kUnknown, //!< Unknown error kNotFound, //!< The hostname is unknown kNoAddress, //!< The hostname is valid but has no IP address kUnsupported, //!< The hostname is valid but has no supported address kBadPort //!< The port is invalid }; XSocketAddress(EError, const String &hostname, int port) _NOEXCEPT; virtual ~XSocketAddress() _NOEXCEPT { } //! @name accessors //@{ //! Get the error code EError getError() const throw(); //! Get the hostname String getHostname() const throw(); //! Get the port int getPort() const throw(); //@} protected: // XBase overrides virtual String getWhat() const throw(); private: EError m_error; String m_hostname; int m_port; }; //! I/O closing exception /*! Thrown if a stream cannot be closed. */ XBASE_SUBCLASS_FORMAT(XSocketIOClose, XIOClose); //! Socket cannot bind address exception /*! Thrown when a socket cannot be bound to an address. */ XBASE_SUBCLASS_FORMAT(XSocketBind, XSocket); //! Socket address in use exception /*! Thrown when a socket cannot be bound to an address because the address is already in use. */ XBASE_SUBCLASS(XSocketAddressInUse, XSocketBind); //! Cannot connect socket exception /*! Thrown when a socket cannot connect to a remote endpoint. */ XBASE_SUBCLASS_FORMAT(XSocketConnect, XSocket); //! Cannot create socket exception /*! Thrown when a socket cannot be created (by the operating system). */ XBASE_SUBCLASS_FORMAT(XSocketCreate, XSocket);
2,593
C++
.h
87
27.712644
73
0.743878
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,063
SecureSocket.h
deskflow_deskflow/src/lib/net/SecureSocket.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2015-2016 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "net/TCPSocket.h" #include "net/XSocket.h" class IEventQueue; class SocketMultiplexer; class ISocketMultiplexerJob; struct Ssl; //! Secure socket /*! A secure socket using SSL. */ class SecureSocket : public TCPSocket { public: SecureSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, IArchNetwork::EAddressFamily family); SecureSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, ArchSocket socket); SecureSocket(SecureSocket const &) = delete; SecureSocket(SecureSocket &&) = delete; ~SecureSocket(); SecureSocket &operator=(SecureSocket const &) = delete; SecureSocket &operator=(SecureSocket &&) = delete; // ISocket overrides void close() override; // IDataSocket overrides virtual void connect(const NetworkAddress &) override; ISocketMultiplexerJob *newJob() override; bool isFatal() const override { return m_fatal; } void isFatal(bool b) { m_fatal = b; } bool isSecureReady(); void secureConnect(); void secureAccept(); int secureRead(void *buffer, int size, int &read); int secureWrite(const void *buffer, int size, int &wrote); EJobResult doRead() override; EJobResult doWrite() override; void initSsl(bool server); bool loadCertificates(String &CertFile); private: // SSL void initContext(bool server); void createSSL(); void freeSSL(); int secureAccept(int s); int secureConnect(int s); bool showCertificate() const; void checkResult(int n, int &retry); void disconnect(); void formatFingerprint(String &fingerprint, bool hex = true, bool separator = true); bool verifyCertFingerprint(); ISocketMultiplexerJob *serviceConnect(ISocketMultiplexerJob *, bool, bool, bool); ISocketMultiplexerJob *serviceAccept(ISocketMultiplexerJob *, bool, bool, bool); void handleTCPConnected(const Event &event, void *); private: Ssl *m_ssl; bool m_secureReady; bool m_fatal; };
2,627
C++
.h
79
30.670886
111
0.76322
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,064
NetworkAddress.h
deskflow_deskflow/src/lib/net/NetworkAddress.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/IArchNetwork.h" #include "base/EventTypes.h" #include "base/String.h" //! Network address type /*! This class represents a network address. */ class NetworkAddress { public: /*! Constructs the invalid address */ NetworkAddress() = default; /*! Construct the wildcard address with the given port. \c port must not be zero. */ NetworkAddress(int port); /*! Construct the network address for the given \c hostname and \c port. If \c hostname can be parsed as a numerical address then that's how it's used, otherwise it's used as a host name. If \c hostname ends in ":[0-9]+" then that suffix is extracted and used as the port, overridding the port parameter. The resulting port must be a valid port number (zero is not a valid port number) otherwise \c XSocketAddress is thrown with an error of \c XSocketAddress::kBadPort. The hostname is not resolved by the c'tor; use \c resolve to do that. */ NetworkAddress(const String &hostname, int port = 0); NetworkAddress(const NetworkAddress &); ~NetworkAddress(); NetworkAddress &operator=(const NetworkAddress &); //! @name manipulators //@{ //! Resolve address /*! Resolves the hostname to an address. This can be done any number of times and is done automatically by the c'tor taking a hostname. Throws XSocketAddress if resolution is unsuccessful, after which \c isValid returns false until the next call to this method. index - determine index of IP we would like to use from resolved addresses Returns count of successfully resolved addressed. */ size_t resolve(size_t index = 0); //@} //! @name accessors //@{ //! Check address equality /*! Returns true if this address is equal to \p address. */ bool operator==(const NetworkAddress &address) const; //! Check address inequality /*! Returns true if this address is not equal to \p address. */ bool operator!=(const NetworkAddress &address) const; //! Check address validity /*! Returns true if this is not the invalid address. */ bool isValid() const; //! Get address /*! Returns the address in the platform's native network address structure. */ const ArchNetAddress &getAddress() const; //! Get port /*! Returns the port passed to the c'tor as a suffix to the hostname, if that existed, otherwise as passed directly to the c'tor. */ int getPort() const; //! Get hostname /*! Returns the hostname passed to the c'tor sans any port suffix. */ String getHostname() const; //@} private: void checkPort(); private: ArchNetAddress m_address = nullptr; String m_hostname; int m_port = 0; };
3,421
C++
.h
106
29.518868
76
0.733232
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,065
ISocketFactory.h
deskflow_deskflow/src/lib/net/ISocketFactory.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/IArchNetwork.h" #include "common/IInterface.h" class IDataSocket; class IListenSocket; //! Socket factory /*! This interface defines the methods common to all factories used to create sockets. */ class ISocketFactory : public IInterface { public: //! @name accessors //@{ //! Create data socket virtual IDataSocket *create(bool secure, IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const = 0; //! Create listen socket virtual IListenSocket *createListen(bool secure, IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const = 0; //@} };
1,337
C++
.h
38
33.210526
120
0.766254
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
14,066
IDataSocket.h
deskflow_deskflow/src/lib/net/IDataSocket.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/EventTypes.h" #include "base/String.h" #include "io/IStream.h" #include "net/ISocket.h" //! Data stream socket interface /*! This interface defines the methods common to all network sockets that represent a full-duplex data stream. */ class IDataSocket : public ISocket, public deskflow::IStream { public: class ConnectionFailedInfo { public: ConnectionFailedInfo(const char *what) : m_what(what) { } String m_what; }; IDataSocket(IEventQueue *events) { } //! @name manipulators //@{ //! Connect socket /*! Attempt to connect to a remote endpoint. This returns immediately and sends a connected event when successful or a connection failed event when it fails. The stream acts as if shutdown for input and output until the stream connects. */ virtual void connect(const NetworkAddress &) = 0; //@} // ISocket overrides // close() and getEventTarget() aren't pure to work around a bug // in VC++6. it claims the methods are unused locals and warns // that it's removing them. it's presumably tickled by inheriting // methods with identical signatures from both superclasses. virtual void bind(const NetworkAddress &) = 0; virtual void close(); virtual void *getEventTarget() const; // IStream overrides virtual UInt32 read(void *buffer, UInt32 n) = 0; virtual void write(const void *buffer, UInt32 n) = 0; virtual void flush() = 0; virtual void shutdownInput() = 0; virtual void shutdownOutput() = 0; virtual bool isReady() const = 0; virtual bool isFatal() const = 0; virtual UInt32 getSize() const = 0; };
2,364
C++
.h
70
31.185714
72
0.739606
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
14,067
TSocketMultiplexerMethodJob.h
deskflow_deskflow/src/lib/net/TSocketMultiplexerMethodJob.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/Arch.h" #include "net/ISocketMultiplexerJob.h" //! Use a method as a socket multiplexer job /*! A socket multiplexer job class that invokes a member function. */ template <class T> class TSocketMultiplexerMethodJob : public ISocketMultiplexerJob { public: typedef ISocketMultiplexerJob *(T::*Method)(ISocketMultiplexerJob *, bool, bool, bool); //! run() invokes \c object->method(arg) TSocketMultiplexerMethodJob(T *object, Method method, ArchSocket socket, bool readable, bool writeable); TSocketMultiplexerMethodJob(TSocketMultiplexerMethodJob const &) = delete; TSocketMultiplexerMethodJob(TSocketMultiplexerMethodJob &&) = delete; virtual ~TSocketMultiplexerMethodJob(); TSocketMultiplexerMethodJob &operator=(TSocketMultiplexerMethodJob const &) = delete; TSocketMultiplexerMethodJob &operator=(TSocketMultiplexerMethodJob &&) = delete; // IJob overrides virtual ISocketMultiplexerJob *run(bool readable, bool writable, bool error); virtual ArchSocket getSocket() const; virtual bool isReadable() const; virtual bool isWritable() const; private: T *m_object; Method m_method; ArchSocket m_socket; bool m_readable; bool m_writable; void *m_arg; }; template <class T> inline TSocketMultiplexerMethodJob<T>::TSocketMultiplexerMethodJob( T *object, Method method, ArchSocket socket, bool readable, bool writable ) : m_object(object), m_method(method), m_socket(ARCH->copySocket(socket)), m_readable(readable), m_writable(writable) { // do nothing } template <class T> inline TSocketMultiplexerMethodJob<T>::~TSocketMultiplexerMethodJob() { ARCH->closeSocket(m_socket); } template <class T> inline ISocketMultiplexerJob *TSocketMultiplexerMethodJob<T>::run(bool read, bool write, bool error) { if (m_object != NULL) { return (m_object->*m_method)(this, read, write, error); } return NULL; } template <class T> inline ArchSocket TSocketMultiplexerMethodJob<T>::getSocket() const { return m_socket; } template <class T> inline bool TSocketMultiplexerMethodJob<T>::isReadable() const { return m_readable; } template <class T> inline bool TSocketMultiplexerMethodJob<T>::isWritable() const { return m_writable; }
2,970
C++
.h
83
33.349398
119
0.772095
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
14,068
ISocketMultiplexerJob.h
deskflow_deskflow/src/lib/net/ISocketMultiplexerJob.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/IArchNetwork.h" #include "common/IInterface.h" //! Socket multiplexer job /*! A socket multiplexer job handles events on a socket. */ class ISocketMultiplexerJob : public IInterface { public: //! @name manipulators //@{ //! Handle socket event /*! Called by a socket multiplexer when the socket becomes readable, writable, or has an error. It should return itself if the same job can continue to service events, a new job if the socket must be serviced differently, or NULL if the socket should no longer be serviced. The socket is readable if \p readable is true, writable if \p writable is true, and in error if \p error is true. This call must not attempt to directly change the job for this socket by calling \c addSocket() or \c removeSocket() on the multiplexer. It must instead return the new job. It can, however, add or remove jobs for other sockets. */ virtual ISocketMultiplexerJob *run(bool readable, bool writable, bool error) = 0; //@} //! @name accessors //@{ //! Get the socket /*! Return the socket to multiplex */ virtual ArchSocket getSocket() const = 0; //! Check for interest in readability /*! Return true if the job is interested in being run if the socket becomes readable. */ virtual bool isReadable() const = 0; //! Check for interest in writability /*! Return true if the job is interested in being run if the socket becomes writable. */ virtual bool isWritable() const = 0; //@} };
2,258
C++
.h
66
31.666667
83
0.739688
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
14,069
ISocket.h
deskflow_deskflow/src/lib/net/ISocket.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/Event.h" #include "base/EventTypes.h" #include "common/IInterface.h" class NetworkAddress; //! Generic socket interface /*! This interface defines the methods common to all network sockets. Generated events use \c this as the target. */ class ISocket : public IInterface { public: //! @name manipulators //@{ //! Bind socket to address /*! Binds the socket to a particular address. */ virtual void bind(const NetworkAddress &) = 0; //! Close socket /*! Closes the socket. This should flush the output stream. */ virtual void close() = 0; //@} //! @name accessors //@{ //! Get event target /*! Returns the event target for events generated by this socket. */ virtual void *getEventTarget() const = 0; //@} };
1,518
C++
.h
52
26.903846
72
0.730954
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,070
TCPSocketFactory.h
deskflow_deskflow/src/lib/net/TCPSocketFactory.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/IArchNetwork.h" #include "net/ISocketFactory.h" class IEventQueue; class SocketMultiplexer; //! Socket factory for TCP sockets class TCPSocketFactory : public ISocketFactory { public: TCPSocketFactory(IEventQueue *events, SocketMultiplexer *socketMultiplexer); virtual ~TCPSocketFactory(); // ISocketFactory overrides virtual IDataSocket *create(bool secure, IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const; virtual IListenSocket *createListen(bool secure, IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const; private: IEventQueue *m_events; SocketMultiplexer *m_socketMultiplexer; };
1,393
C++
.h
35
37.771429
116
0.79068
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,071
IListenSocket.h
deskflow_deskflow/src/lib/net/IListenSocket.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/EventTypes.h" #include "net/ISocket.h" class IDataSocket; //! Listen socket interface /*! This interface defines the methods common to all network sockets that listen for incoming connections. */ class IListenSocket : public ISocket { public: //! @name manipulators //@{ //! Accept connection /*! Accept a connection, returning a socket representing the full-duplex data stream. Returns NULL if no socket is waiting to be accepted. This is only valid after a call to \c bind(). */ virtual IDataSocket *accept() = 0; //@} // ISocket overrides virtual void bind(const NetworkAddress &) = 0; virtual void close() = 0; virtual void *getEventTarget() const = 0; };
1,454
C++
.h
44
30.886364
72
0.749109
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
14,072
TCPListenSocket.h
deskflow_deskflow/src/lib/net/TCPListenSocket.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "arch/IArchNetwork.h" #include "net/IListenSocket.h" class Mutex; class ISocketMultiplexerJob; class IEventQueue; class SocketMultiplexer; //! TCP listen socket /*! A listen socket using TCP. */ class TCPListenSocket : public IListenSocket { public: TCPListenSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, IArchNetwork::EAddressFamily family); TCPListenSocket(TCPListenSocket const &) = delete; TCPListenSocket(TCPListenSocket &&) = delete; virtual ~TCPListenSocket(); TCPListenSocket &operator=(TCPListenSocket const &) = delete; TCPListenSocket &operator=(TCPListenSocket &&) = delete; // ISocket overrides virtual void bind(const NetworkAddress &); virtual void close(); virtual void *getEventTarget() const; // IListenSocket overrides virtual IDataSocket *accept(); protected: void setListeningJob(); public: ISocketMultiplexerJob *serviceListening(ISocketMultiplexerJob *, bool, bool, bool); protected: ArchSocket m_socket; Mutex *m_mutex; IEventQueue *m_events; SocketMultiplexer *m_socketMultiplexer; };
1,828
C++
.h
53
32.320755
114
0.782436
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,073
InverseSocketFactory.h
deskflow_deskflow/src/lib/net/InverseSockets/InverseSocketFactory.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2022 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "net/ISocketFactory.h" class IEventQueue; class SocketMultiplexer; class InverseSocketFactory : public ISocketFactory { public: InverseSocketFactory(IEventQueue *events, SocketMultiplexer *socketMultiplexer); // ISocketFactory overrides IDataSocket *create(bool secure, IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const override; IListenSocket *createListen(bool secure, IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const override; private: IEventQueue *m_events = nullptr; SocketMultiplexer *m_socketMultiplexer = nullptr; };
1,285
C++
.h
31
39.451613
117
0.7928
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,074
SecureClientSocket.h
deskflow_deskflow/src/lib/net/InverseSockets/SecureClientSocket.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2015-2022 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "InverseClientSocket.h" #include "SslApi.h" //! Secure socket /*! A secure socket using SSL. */ class SecureClientSocket : public InverseClientSocket { public: SecureClientSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, IArchNetwork::EAddressFamily family); SecureClientSocket(SecureClientSocket const &) = delete; SecureClientSocket(SecureClientSocket &&) = delete; SecureClientSocket &operator=(SecureClientSocket const &) = delete; SecureClientSocket &operator=(SecureClientSocket &&) = delete; // IDataSocket overrides void connect(const NetworkAddress &) override; ISocketMultiplexerJob *newJob(); bool isFatal() const override { return m_fatal; } void setFatal(int code); int getRetry(int errorCode, int retry) const; bool isSecureReady() const; void secureConnect(); void secureAccept(); int secureRead(void *buffer, int size, int &read); int secureWrite(const void *buffer, int size, int &wrote); EJobResult doRead() override; EJobResult doWrite() override; bool loadCertificates(const std::string &CertFile); private: // SSL void initContext(bool server); int secureAccept(int s); int secureConnect(int s); void checkResult(int n, int &retry); void disconnect(); ISocketMultiplexerJob *serviceConnect(ISocketMultiplexerJob *, bool, bool, bool); ISocketMultiplexerJob *serviceAccept(ISocketMultiplexerJob *, bool, bool, bool); void handleTCPConnected(const Event &, void *); deskflow::ssl::SslApi m_ssl{false}; bool m_secureReady = false; bool m_fatal = false; };
2,282
C++
.h
62
34.290323
117
0.767526
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,075
InverseServerSocket.h
deskflow_deskflow/src/lib/net/InverseSockets/InverseServerSocket.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2022 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "AutoArchSocket.h" #include "arch/IArchNetwork.h" #include "mt/Mutex.h" #include "net/IListenSocket.h" class ISocketMultiplexerJob; class IEventQueue; class SocketMultiplexer; class InverseServerSocket : public IListenSocket { public: InverseServerSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, IArchNetwork::EAddressFamily family); InverseServerSocket(InverseServerSocket const &) = delete; InverseServerSocket(InverseServerSocket &&) = delete; ~InverseServerSocket() override; InverseServerSocket &operator=(InverseServerSocket const &) = delete; InverseServerSocket &operator=(InverseServerSocket &&) = delete; // ISocket overrides void bind(const NetworkAddress &) override; void close() override; void *getEventTarget() const override; // IListenSocket overrides IDataSocket *accept() override; protected: void setListeningJob(bool read = false); public: ISocketMultiplexerJob *serviceListening(ISocketMultiplexerJob *, bool, bool, bool); protected: AutoArchSocket m_socket; Mutex m_mutex; IEventQueue *m_events; SocketMultiplexer *m_socketMultiplexer; private: NetworkAddress m_address; };
1,916
C++
.h
52
34.596154
118
0.791689
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,076
SslApi.h
deskflow_deskflow/src/lib/net/InverseSockets/SslApi.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2015-2022 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <openssl/ssl.h> #include <string> namespace deskflow { namespace ssl { class SslApi { public: explicit SslApi(bool isServer = false); SslApi(SslApi const &) = delete; SslApi &operator=(SslApi const &) = delete; ~SslApi(); int read(char *buffer, int size); int write(const char *buffer, int size); int accept(int socket); int connect(int socket); bool loadCertificate(const std::string &filename); bool showCertificate() const; std::string getFingerprint() const; bool isTrustedFingerprint(const std::string &fingerprint) const; void logSecureInfo() const; int getErrorCode(int status) const; private: void createSSL(); void formatFingerprint(std::string &fingerprint) const; bool isCertificateExists(const std::string &filename) const; void createContext(bool isServer = false); SSL *m_ssl = nullptr; SSL_CTX *m_context = nullptr; }; } // namespace ssl } // namespace deskflow
1,638
C++
.h
48
31.8125
72
0.754741
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,077
InverseClientSocket.h
deskflow_deskflow/src/lib/net/InverseSockets/InverseClientSocket.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2022 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "AutoArchSocket.h" #include "arch/IArchNetwork.h" #include "io/StreamBuffer.h" #include "mt/CondVar.h" #include "mt/Mutex.h" #include "net/IDataSocket.h" class ISocketMultiplexerJob; class IEventQueue; class SocketMultiplexer; class InverseClientSocket : public IDataSocket { public: InverseClientSocket( IEventQueue *events, SocketMultiplexer *socketMultiplexer, IArchNetwork::EAddressFamily family = IArchNetwork::kINET ); InverseClientSocket(InverseClientSocket const &) = delete; InverseClientSocket(InverseClientSocket &&) = delete; ~InverseClientSocket() override; InverseClientSocket &operator=(InverseClientSocket const &) = delete; InverseClientSocket &operator=(InverseClientSocket &&) = delete; // ISocket overrides void bind(const NetworkAddress &) override; void close() override; void *getEventTarget() const override; // IStream overrides UInt32 read(void *buffer, UInt32 n) override; void write(const void *buffer, UInt32 n) override; void flush() override; void shutdownInput() override; void shutdownOutput() override; bool isReady() const override; bool isFatal() const override; UInt32 getSize() const override; // IDataSocket overrides void connect(const NetworkAddress &) override; virtual ISocketMultiplexerJob *newJob(ArchSocket socket); protected: enum class EJobResult { kBreak = -1, //!< Break the Job chain kRetry, //!< Retry the same job kNew //!< Require a new job }; ArchSocket getSocket() { return m_socket.getRawSocket(); } IEventQueue *getEvents() { return m_events; } virtual EJobResult doRead(); virtual EJobResult doWrite(); void setJob(ISocketMultiplexerJob *); bool isReadable() const { return m_readable; } bool isWritable() const { return m_writable; } Mutex &getMutex() { return m_mutex; } void sendEvent(Event::Type); void discardWrittenData(int bytesWrote); private: void sendConnectionFailedEvent(const char *); void onConnected(); void onInputShutdown(); void onOutputShutdown(); void onDisconnected(); ISocketMultiplexerJob *serviceConnecting(ISocketMultiplexerJob *, bool, bool, bool); ISocketMultiplexerJob *serviceConnected(ISocketMultiplexerJob *, bool, bool, bool); protected: bool m_readable = false; bool m_writable = false; bool m_connected = false; IEventQueue *m_events; StreamBuffer m_inputBuffer; StreamBuffer m_outputBuffer; Mutex m_mutex; AutoArchSocket m_socket; AutoArchSocket m_listener; CondVar<bool> m_flushed; SocketMultiplexer *m_socketMultiplexer; };
3,375
C++
.h
108
28.342593
86
0.758695
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,078
AutoArchSocket.h
deskflow_deskflow/src/lib/net/InverseSockets/AutoArchSocket.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2022 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "net/NetworkAddress.h" class AutoArchSocket { public: explicit AutoArchSocket(IArchNetwork::EAddressFamily family); ~AutoArchSocket(); AutoArchSocket(const AutoArchSocket &) = delete; AutoArchSocket &operator=(const AutoArchSocket &) = delete; void setNoDelayOnSocket(bool value = true); void setReuseAddrOnSocket(bool value = true); void listenOnSocket(); ArchSocket acceptSocket(); void bindSocket(const NetworkAddress &addr); bool connectSocket(const NetworkAddress &addr); void bindAndListen(const NetworkAddress &addr); void closeSocket(); void closeSocketForRead(); void closeSocketForWrite(); size_t readSocket(UInt8 *buffer, size_t size); size_t writeSocket(const UInt8 *buffer, size_t size); void throwErrorOnSocket(); bool isValid() const; ArchSocket getRawSocket() const; void operator=(ArchSocket socket); private: ArchSocket m_socket = nullptr; };
1,663
C++
.h
45
34.488889
72
0.773292
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,079
SecureServerSocket.h
deskflow_deskflow/src/lib/net/InverseSockets/SecureServerSocket.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2015-2022 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "InverseServerSocket.h" class SecureServerSocket : public InverseServerSocket { public: SecureServerSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, IArchNetwork::EAddressFamily family); // IListenSocket overrides IDataSocket *accept() override; private: std::string getCertificateFileName() const; };
1,043
C++
.h
27
36.666667
117
0.784798
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,080
SslLogger.h
deskflow_deskflow/src/lib/net/InverseSockets/SslLogger.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2015-2022 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <openssl/ssl.h> #include <string> class SslLogger { public: static void logSecureLibInfo(); static void logSecureCipherInfo(const SSL *ssl); static void logSecureConnectInfo(const SSL *ssl); static void logError(const std::string &reason = ""); static void logErrorByCode(int code, int retry); };
1,021
C++
.h
28
34.535714
72
0.764113
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,081
MockArgParser.h
deskflow_deskflow/src/test/mock/deskflow/MockArgParser.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2014-2016 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #define TEST_ENV #include "deskflow/ArgParser.h" #include <gmock/gmock.h> class MockArgParser : public ArgParser { public: MockArgParser() : ArgParser(NULL) { } MOCK_METHOD(bool, parseGenericArgs, (int, const char *const *, int &)); MOCK_METHOD(bool, checkUnexpectedArgs, ()); };
1,000
C++
.h
29
32.413793
73
0.753368
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,082
MockEventQueue.h
deskflow_deskflow/src/test/mock/deskflow/MockEventQueue.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 Nick Bolton * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/IEventQueue.h" #include <gmock/gmock.h> class MockEventQueue : public IEventQueue { public: MOCK_METHOD(void, loop, (), (override)); MOCK_METHOD(EventQueueTimer *, newOneShotTimer, (double, void *), (override)); MOCK_METHOD(EventQueueTimer *, newTimer, (double, void *), (override)); MOCK_METHOD(bool, getEvent, (Event &, double), (override)); MOCK_METHOD(void, adoptBuffer, (IEventQueueBuffer *), (override)); MOCK_METHOD(Event::Type, registerTypeOnce, (Event::Type &, const char *), (override)); MOCK_METHOD(void, removeHandlers, (void *), (override)); MOCK_METHOD(Event::Type, registerType, (const char *)); MOCK_METHOD(bool, isEmpty, (), (const, override)); MOCK_METHOD(void, adoptHandler, (Event::Type, void *, IEventJob *), (override)); MOCK_METHOD(const char *, getTypeName, (Event::Type), (override)); MOCK_METHOD(void, addEvent, (const Event &), (override)); MOCK_METHOD(void, removeHandler, (Event::Type, void *), (override)); MOCK_METHOD(bool, dispatchEvent, (const Event &), (override)); MOCK_METHOD(IEventJob *, getHandler, (Event::Type, void *), (const, override)); MOCK_METHOD(void, deleteTimer, (EventQueueTimer *), (override)); MOCK_METHOD(Event::Type, getRegisteredType, (const String &), (const, override)); MOCK_METHOD(void *, getSystemTarget, (), (override)); MOCK_METHOD(ClientEvents &, forClient, (), (override)); MOCK_METHOD(IStreamEvents &, forIStream, (), (override)); MOCK_METHOD(IpcClientEvents &, forIpcClient, (), (override)); MOCK_METHOD(IpcClientProxyEvents &, forIpcClientProxy, (), (override)); MOCK_METHOD(IpcServerEvents &, forIpcServer, (), (override)); MOCK_METHOD(IpcServerProxyEvents &, forIpcServerProxy, (), (override)); MOCK_METHOD(IDataSocketEvents &, forIDataSocket, (), (override)); MOCK_METHOD(IListenSocketEvents &, forIListenSocket, (), (override)); MOCK_METHOD(ISocketEvents &, forISocket, (), (override)); MOCK_METHOD(OSXScreenEvents &, forOSXScreen, (), (override)); MOCK_METHOD(ClientListenerEvents &, forClientListener, (), (override)); MOCK_METHOD(ClientProxyEvents &, forClientProxy, (), (override)); MOCK_METHOD(ClientProxyUnknownEvents &, forClientProxyUnknown, (), (override)); MOCK_METHOD(ServerEvents &, forServer, (), (override)); MOCK_METHOD(ServerAppEvents &, forServerApp, (), (override)); MOCK_METHOD(IKeyStateEvents &, forIKeyState, (), (override)); MOCK_METHOD(IPrimaryScreenEvents &, forIPrimaryScreen, (), (override)); MOCK_METHOD(IScreenEvents &, forIScreen, (), (override)); MOCK_METHOD(ClipboardEvents &, forClipboard, (), (override)); MOCK_METHOD(FileEvents &, forFile, (), (override)); MOCK_METHOD(EiEvents &, forEi, (), (override)); MOCK_METHOD(void, waitForReady, (), (const, override)); };
3,505
C++
.h
64
52.203125
88
0.720687
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,083
MockKeyMap.h
deskflow_deskflow/src/test/mock/deskflow/MockKeyMap.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 Nick Bolton * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/String.h" #include "deskflow/KeyMap.h" #include <gmock/gmock.h> class MockKeyMap : public deskflow::KeyMap { public: MOCK_METHOD(void, swap, (KeyMap &), (override)); MOCK_METHOD(void, finish, (), (override)); MOCK_METHOD(void, foreachKey, (ForeachKeyCallback, void *), (override)); MOCK_METHOD(void, addHalfDuplexModifier, (KeyID), (override)); MOCK_METHOD(bool, isHalfDuplex, (KeyID, KeyButton), (const, override)); MOCK_METHOD( const KeyMap::KeyItem *, mapKey, (Keystrokes &, KeyID, SInt32, ModifierToKeys &, KeyModifierMask &, KeyModifierMask, bool, const String &), (const, override) ); };
1,382
C++
.h
35
37.028571
112
0.735119
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,084
MockApp.h
deskflow_deskflow/src/test/mock/deskflow/MockApp.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2014-2016 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #define TEST_ENV #include "deskflow/App.h" #include <gmock/gmock.h> class MockApp : public App { public: MockApp() : App(NULL, NULL, NULL) { } MOCK_METHOD(void, help, (), (override)); MOCK_METHOD(void, loadConfig, (), (override)); MOCK_METHOD(bool, loadConfig, (const String &), (override)); MOCK_METHOD(const char *, daemonInfo, (), (const, override)); MOCK_METHOD(const char *, daemonName, (), (const, override)); MOCK_METHOD(void, parseArgs, (int, const char *const *), (override)); MOCK_METHOD(void, version, (), (override)); MOCK_METHOD(int, standardStartup, (int, char **), (override)); MOCK_METHOD(int, runInner, (int, char **, ILogOutputter *, StartupFunc), (override)); MOCK_METHOD(void, startNode, (), (override)); MOCK_METHOD(int, mainLoop, (), (override)); MOCK_METHOD(int, foregroundStartup, (int, char **), (override)); MOCK_METHOD(deskflow::Screen *, createScreen, (), (override)); MOCK_METHOD(std::string, configSection, (), (const, override)); };
1,708
C++
.h
41
39.317073
87
0.711017
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,085
MockKeyState.h
deskflow_deskflow/src/test/mock/deskflow/MockKeyState.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 Nick Bolton * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "deskflow/KeyState.h" #include <gmock/gmock.h> class MockKeyMap; class MockEventQueue; // NOTE: do not mock methods that are not pure virtual. this mock exists only // to provide an implementation of the KeyState abstract class. class MockKeyState : public KeyState { public: MockKeyState(const MockEventQueue &eventQueue) : KeyState((IEventQueue *)&eventQueue, {"en"}, true) { } MockKeyState(const MockEventQueue &eventQueue, const deskflow::KeyMap &keyMap) : KeyState((IEventQueue *)&eventQueue, (deskflow::KeyMap &)keyMap, {"en"}, true) { } MOCK_METHOD(SInt32, pollActiveGroup, (), (const, override)); MOCK_METHOD(KeyModifierMask, pollActiveModifiers, (), (const, override)); MOCK_METHOD(bool, fakeCtrlAltDel, (), (override)); MOCK_METHOD(void, getKeyMap, (deskflow::KeyMap &), (override)); MOCK_METHOD(void, fakeKey, (const Keystroke &), (override)); MOCK_METHOD(bool, fakeMediaKey, (KeyID), (override)); MOCK_METHOD(void, pollPressedKeys, (KeyButtonSet &), (const, override)); }; typedef ::testing::NiceMock<MockKeyState> KeyStateImpl; typedef UInt32 KeyID; typedef void (*ForeachKeyCallback)(KeyID, SInt32 group, deskflow::KeyMap::KeyItem &, void *userData);
1,954
C++
.h
45
41.133333
101
0.751448
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,086
MockScreen.h
deskflow_deskflow/src/test/mock/deskflow/MockScreen.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2013-2016 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #define TEST_ENV #include "deskflow/Screen.h" #include <gmock/gmock.h> class MockScreen : public deskflow::Screen { public: MockScreen() : deskflow::Screen() { } MOCK_METHOD(void, disable, (), (override)); MOCK_METHOD(void, getShape, (SInt32 &, SInt32 &, SInt32 &, SInt32 &), (const, override)); MOCK_METHOD(void, getCursorPos, (SInt32 &, SInt32 &), (const, override)); MOCK_METHOD(void, resetOptions, (), (override)); MOCK_METHOD(void, setOptions, (const OptionsList &), (override)); MOCK_METHOD(void, enable, (), (override)); };
1,258
C++
.h
33
35.969697
91
0.729508
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,087
MockInputFilter.h
deskflow_deskflow/src/test/mock/server/MockInputFilter.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2013-2016 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #define TEST_ENV #include "server/InputFilter.h" #include <gmock/gmock.h> class MockInputFilter : public InputFilter { public: MOCK_METHOD(void, setPrimaryClient, (PrimaryClient *), (override)); };
909
C++
.h
25
34.48
72
0.765643
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,088
MockConfig.h
deskflow_deskflow/src/test/mock/server/MockConfig.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2013-2016 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #define TEST_ENV #include "server/Config.h" #include <gmock/gmock.h> class MockConfig : public Config { public: MockConfig() : Config() { } MOCK_METHOD(InputFilter *, getInputFilter, (), (override)); MOCK_METHOD(bool, isScreen, (const String &), (const, override)); };
988
C++
.h
29
32.034483
72
0.746331
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,089
MockServer.h
deskflow_deskflow/src/test/mock/server/MockServer.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2013-2016 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #define TEST_ENV #include "server/Server.h" #include <gmock/gmock.h> class IEventQueue; class MockServer : public Server { public: MockServer() : Server() { } };
878
C++
.h
28
29.392857
72
0.757109
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
14,090
MockPrimaryClient.h
deskflow_deskflow/src/test/mock/server/MockPrimaryClient.h
/* * Deskflow -- mouse and keyboard sharing utility * Copyright (C) 2013-2016 Symless Ltd. * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package 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 this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #define TEST_ENV #include "base/String.h" #include "server/PrimaryClient.h" #include <gmock/gmock.h> class MockPrimaryClient : public PrimaryClient { public: MOCK_METHOD(void *, getEventTarget, (), (const, override)); MOCK_METHOD(void, getCursorPos, (SInt32 &, SInt32 &), (const, override)); MOCK_METHOD(void, setJumpCursorPos, (SInt32, SInt32), (const)); MOCK_METHOD(void, reconfigure, (UInt32), (override)); MOCK_METHOD(void, resetOptions, (), (override)); MOCK_METHOD(void, setOptions, (const OptionsList &), (override)); MOCK_METHOD(void, enable, (), (override)); MOCK_METHOD(void, disable, (), (override)); MOCK_METHOD(UInt32, registerHotKey, (KeyID, KeyModifierMask), (override)); MOCK_METHOD(KeyModifierMask, getToggleMask, (), (const, override)); MOCK_METHOD(void, unregisterHotKey, (UInt32), (override)); };
1,548
C++
.h
36
40.833333
76
0.740544
deskflow/deskflow
10,364
3,653
93
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false