feat(ipc): Handle missing keyboard layouts with IPC
This commit is contained in:
parent
59a4747113
commit
682966fec0
14 changed files with 113 additions and 14 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
#include "deskflow/ProtocolTypes.h"
|
#include "deskflow/ProtocolTypes.h"
|
||||||
#include "deskflow/ProtocolUtil.h"
|
#include "deskflow/ProtocolUtil.h"
|
||||||
#include "deskflow/StreamChunker.h"
|
#include "deskflow/StreamChunker.h"
|
||||||
|
#include "deskflow/ipc/CoreIpc.h"
|
||||||
#include "io/IStream.h"
|
#include "io/IStream.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
@ -139,7 +140,12 @@ ServerProxy::ConnectionResult ServerProxy::parseHandshakeMessage(const uint8_t *
|
||||||
|
|
||||||
// handshake is complete
|
// handshake is complete
|
||||||
m_parser = &ServerProxy::parseMessage;
|
m_parser = &ServerProxy::parseMessage;
|
||||||
checkMissedLanguages();
|
|
||||||
|
if (const auto missedKeyboardLayouts = m_languageManager.getMissedLanguages(); !missedKeyboardLayouts.empty()) {
|
||||||
|
LOG_WARN("server layouts missing on this computer: %s", missedKeyboardLayouts.c_str());
|
||||||
|
ipcSendToClient("missingKeyboardLayouts", QString::fromStdString(missedKeyboardLayouts));
|
||||||
|
}
|
||||||
|
|
||||||
m_client->handshakeComplete();
|
m_client->handshakeComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -844,15 +850,3 @@ void ServerProxy::setActiveServerLanguage(const std::string_view &language)
|
||||||
LOG_DEBUG1("active server language is empty");
|
LOG_DEBUG1("active server language is empty");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerProxy::checkMissedLanguages() const
|
|
||||||
{
|
|
||||||
auto missedLanguages = m_languageManager.getMissedLanguages();
|
|
||||||
if (!missedLanguages.empty()) {
|
|
||||||
LOG(
|
|
||||||
(CLOG_WARN "You need to install these languages on this computer and restart "
|
|
||||||
"Deskflow to enable support for multiple languages: %s",
|
|
||||||
missedLanguages.c_str())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,6 @@ private:
|
||||||
void secureInputNotification();
|
void secureInputNotification();
|
||||||
void setServerLanguages();
|
void setServerLanguages();
|
||||||
void setActiveServerLanguage(const std::string_view &language);
|
void setActiveServerLanguage(const std::string_view &language);
|
||||||
void checkMissedLanguages() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using MessageParser = ConnectionResult (ServerProxy::*)(const uint8_t *);
|
using MessageParser = ConnectionResult (ServerProxy::*)(const uint8_t *);
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ public:
|
||||||
inline static const auto ShownFirstConnectedMessage = QStringLiteral("gui/shownFirstConnectedMessage");
|
inline static const auto ShownFirstConnectedMessage = QStringLiteral("gui/shownFirstConnectedMessage");
|
||||||
inline static const auto ShownServerFirstStartMessage = QStringLiteral("gui/shownServerFirstStartMessage");
|
inline static const auto ShownServerFirstStartMessage = QStringLiteral("gui/shownServerFirstStartMessage");
|
||||||
inline static const auto ShowVersionInTitle = QStringLiteral("gui/showVersionInTitle");
|
inline static const auto ShowVersionInTitle = QStringLiteral("gui/showVersionInTitle");
|
||||||
|
inline static const auto IgnoreMissingKeyboardLayouts = QStringLiteral("gui/ignoreMissingKeyboardLayouts");
|
||||||
};
|
};
|
||||||
struct Log
|
struct Log
|
||||||
{
|
{
|
||||||
|
|
@ -243,6 +244,7 @@ private:
|
||||||
, Settings::Gui::ShownFirstConnectedMessage
|
, Settings::Gui::ShownFirstConnectedMessage
|
||||||
, Settings::Gui::ShownServerFirstStartMessage
|
, Settings::Gui::ShownServerFirstStartMessage
|
||||||
, Settings::Gui::ShowVersionInTitle
|
, Settings::Gui::ShowVersionInTitle
|
||||||
|
, Settings::Gui::IgnoreMissingKeyboardLayouts
|
||||||
, Settings::Security::Certificate
|
, Settings::Security::Certificate
|
||||||
, Settings::Security::CheckPeers
|
, Settings::Security::CheckPeers
|
||||||
, Settings::Security::KeySize
|
, Settings::Security::KeySize
|
||||||
|
|
@ -258,6 +260,7 @@ private:
|
||||||
, Settings::Gui::ShownFirstConnectedMessage
|
, Settings::Gui::ShownFirstConnectedMessage
|
||||||
, Settings::Gui::ShownServerFirstStartMessage
|
, Settings::Gui::ShownServerFirstStartMessage
|
||||||
, Settings::Gui::ShowVersionInTitle
|
, Settings::Gui::ShowVersionInTitle
|
||||||
|
, Settings::Gui::IgnoreMissingKeyboardLayouts
|
||||||
, Settings::Core::PreventSleep
|
, Settings::Core::PreventSleep
|
||||||
, Settings::Core::UseWlClipboard
|
, Settings::Core::UseWlClipboard
|
||||||
, Settings::Core::EnableEnterCommand
|
, Settings::Core::EnableEnterCommand
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
namespace deskflow::languages {
|
namespace deskflow::languages {
|
||||||
|
|
||||||
|
// TODO: rename class and namespace; "languages" is a misnomer. These are keyboard
|
||||||
|
// _layouts_ (Windows/X11) or input sources (macOS), not spoken "languages".
|
||||||
class LanguageManager
|
class LanguageManager
|
||||||
{
|
{
|
||||||
std::vector<std::string> m_remoteLanguages;
|
std::vector<std::string> m_remoteLanguages;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#include "net/FingerprintDatabase.h"
|
#include "net/FingerprintDatabase.h"
|
||||||
#include "widgets/StatusBar.h"
|
#include "widgets/StatusBar.h"
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
@ -272,6 +273,7 @@ void MainWindow::connectSlots()
|
||||||
connect(&m_coreProcess, &CoreProcess::connectionRefused, this, &MainWindow::handleConnectionRefused);
|
connect(&m_coreProcess, &CoreProcess::connectionRefused, this, &MainWindow::handleConnectionRefused);
|
||||||
connect(&m_coreProcess, &CoreProcess::retryIn, this, &MainWindow::updateTimeoutDelay);
|
connect(&m_coreProcess, &CoreProcess::retryIn, this, &MainWindow::updateTimeoutDelay);
|
||||||
connect(&m_coreProcess, &CoreProcess::peerFingerprint, this, &MainWindow::handlePeerFingerprint);
|
connect(&m_coreProcess, &CoreProcess::peerFingerprint, this, &MainWindow::handlePeerFingerprint);
|
||||||
|
connect(&m_coreProcess, &CoreProcess::missingKeyboardLayouts, this, &MainWindow::handleMissingKeyboardLayouts);
|
||||||
|
|
||||||
if (Settings::value(Settings::Gui::AutoStartCore).toBool()) {
|
if (Settings::value(Settings::Gui::AutoStartCore).toBool()) {
|
||||||
connect(ui->btnToggleCore, &QPushButton::clicked, m_actionStopCore, &QAction::trigger, Qt::UniqueConnection);
|
connect(ui->btnToggleCore, &QPushButton::clicked, m_actionStopCore, &QAction::trigger, Qt::UniqueConnection);
|
||||||
|
|
@ -802,6 +804,29 @@ void MainWindow::handleConnectionRefused(deskflow::core::ConnectionRefusal reaso
|
||||||
m_clientErrorVisible = false;
|
m_clientErrorVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::handleMissingKeyboardLayouts(const QString &layouts)
|
||||||
|
{
|
||||||
|
if (Settings::value(Settings::Gui::IgnoreMissingKeyboardLayouts).toBool())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QMessageBox msgBox(this);
|
||||||
|
msgBox.setIcon(QMessageBox::Warning);
|
||||||
|
msgBox.setWindowTitle(tr("Missing Keyboard Layouts"));
|
||||||
|
msgBox.setText(tr("<p>Keyboard layout support requires matching layouts on all computers. "
|
||||||
|
"The following layouts from the other computer are not installed on this computer:</p>"
|
||||||
|
"<p><b>%1</b></p>"
|
||||||
|
"<p>Please install them to enable support for these layouts.</p>")
|
||||||
|
.arg(layouts));
|
||||||
|
|
||||||
|
auto *checkBox = new QCheckBox(tr("Don't show this again"), &msgBox);
|
||||||
|
msgBox.setCheckBox(checkBox);
|
||||||
|
msgBox.exec();
|
||||||
|
|
||||||
|
if (checkBox->isChecked()) {
|
||||||
|
Settings::setValue(Settings::Gui::IgnoreMissingKeyboardLayouts, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::handlePeerFingerprint(const QString &fingerprint)
|
void MainWindow::handlePeerFingerprint(const QString &fingerprint)
|
||||||
{
|
{
|
||||||
const auto sha256Text = QString(fingerprint).remove(':');
|
const auto sha256Text = QString(fingerprint).remove(':');
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,7 @@ private:
|
||||||
void handleUnrecognisedClient(const QString &clientName);
|
void handleUnrecognisedClient(const QString &clientName);
|
||||||
void handleConnectionRefused(deskflow::core::ConnectionRefusal reason);
|
void handleConnectionRefused(deskflow::core::ConnectionRefusal reason);
|
||||||
void handlePeerFingerprint(const QString &fingerprint);
|
void handlePeerFingerprint(const QString &fingerprint);
|
||||||
|
void handleMissingKeyboardLayouts(const QString &layouts);
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
void secureSocket(bool secureSocket);
|
void secureSocket(bool secureSocket);
|
||||||
void connectSlots();
|
void connectSlots();
|
||||||
|
|
|
||||||
|
|
@ -564,6 +564,8 @@ void CoreProcess::onCoreIpcMessageReceived(const QString &command, const QString
|
||||||
Q_EMIT retryIn(args.toInt());
|
Q_EMIT retryIn(args.toInt());
|
||||||
} else if (command == "peerFingerprint") {
|
} else if (command == "peerFingerprint") {
|
||||||
Q_EMIT peerFingerprint(args);
|
Q_EMIT peerFingerprint(args);
|
||||||
|
} else if (command == "missingKeyboardLayouts") {
|
||||||
|
Q_EMIT missingKeyboardLayouts(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ Q_SIGNALS:
|
||||||
void connectionRefused(deskflow::core::ConnectionRefusal reason);
|
void connectionRefused(deskflow::core::ConnectionRefusal reason);
|
||||||
void retryIn(int seconds);
|
void retryIn(int seconds);
|
||||||
void peerFingerprint(const QString &fingerprint);
|
void peerFingerprint(const QString &fingerprint);
|
||||||
|
void missingKeyboardLayouts(const QString &layouts);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onProcessFinished(int exitCode, QProcess::ExitStatus);
|
void onProcessFinished(int exitCode, QProcess::ExitStatus);
|
||||||
|
|
|
||||||
|
|
@ -559,6 +559,18 @@ Additionally, check you are able to %1 the server config file: %2</source>
|
||||||
<translation type="unfinished">
|
<translation type="unfinished">
|
||||||
Además, verifique que puede %1 el archivo de configuración del servidor: %2</translation>
|
Además, verifique que puede %1 el archivo de configuración del servidor: %2</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Don't show this again</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Missing Keyboard Layouts</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source><p>Keyboard layout support requires matching layouts on all computers. The following layouts from the other computer are not installed on this computer:</p><p><b>%1</b></p><p>Please install them to enable support for these layouts.</p></source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>NewScreenWidget</name>
|
<name>NewScreenWidget</name>
|
||||||
|
|
|
||||||
|
|
@ -559,6 +559,18 @@ Additionally, check you are able to %1 the server config file: %2</source>
|
||||||
<translation type="unfinished">
|
<translation type="unfinished">
|
||||||
Inoltre, verifica di poter %1 il file di configurazione del server: %2</translation>
|
Inoltre, verifica di poter %1 il file di configurazione del server: %2</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Don't show this again</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Missing Keyboard Layouts</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source><p>Keyboard layout support requires matching layouts on all computers. The following layouts from the other computer are not installed on this computer:</p><p><b>%1</b></p><p>Please install them to enable support for these layouts.</p></source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>NewScreenWidget</name>
|
<name>NewScreenWidget</name>
|
||||||
|
|
|
||||||
|
|
@ -559,6 +559,18 @@ Additionally, check you are able to %1 the server config file: %2</source>
|
||||||
<translation type="unfinished">
|
<translation type="unfinished">
|
||||||
また、サーバー設定ファイルを%1できることを確認してください: %2</translation>
|
また、サーバー設定ファイルを%1できることを確認してください: %2</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Don't show this again</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Missing Keyboard Layouts</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source><p>Keyboard layout support requires matching layouts on all computers. The following layouts from the other computer are not installed on this computer:</p><p><b>%1</b></p><p>Please install them to enable support for these layouts.</p></source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>NewScreenWidget</name>
|
<name>NewScreenWidget</name>
|
||||||
|
|
|
||||||
|
|
@ -559,6 +559,18 @@ Additionally, check you are able to %1 the server config file: %2</source>
|
||||||
<translation type="unfinished">
|
<translation type="unfinished">
|
||||||
또한 서버 구성 파일을 %1할 수 있는지 확인하세요: %2</translation>
|
또한 서버 구성 파일을 %1할 수 있는지 확인하세요: %2</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Don't show this again</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Missing Keyboard Layouts</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source><p>Keyboard layout support requires matching layouts on all computers. The following layouts from the other computer are not installed on this computer:</p><p><b>%1</b></p><p>Please install them to enable support for these layouts.</p></source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>NewScreenWidget</name>
|
<name>NewScreenWidget</name>
|
||||||
|
|
|
||||||
|
|
@ -559,6 +559,18 @@ Additionally, check you are able to %1 the server config file: %2</source>
|
||||||
<translation type="unfinished">
|
<translation type="unfinished">
|
||||||
Также убедитесь, что вы можете %1 файл конфигурации сервера: %2</translation>
|
Также убедитесь, что вы можете %1 файл конфигурации сервера: %2</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Don't show this again</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Missing Keyboard Layouts</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source><p>Keyboard layout support requires matching layouts on all computers. The following layouts from the other computer are not installed on this computer:</p><p><b>%1</b></p><p>Please install them to enable support for these layouts.</p></source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>NewScreenWidget</name>
|
<name>NewScreenWidget</name>
|
||||||
|
|
|
||||||
|
|
@ -559,6 +559,18 @@ Additionally, check you are able to %1 the server config file: %2</source>
|
||||||
<translation type="unfinished">
|
<translation type="unfinished">
|
||||||
另外,请检查您是否能够%1服务器配置文件:%2</translation>
|
另外,请检查您是否能够%1服务器配置文件:%2</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Don't show this again</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Missing Keyboard Layouts</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source><p>Keyboard layout support requires matching layouts on all computers. The following layouts from the other computer are not installed on this computer:</p><p><b>%1</b></p><p>Please install them to enable support for these layouts.</p></source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>NewScreenWidget</name>
|
<name>NewScreenWidget</name>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue