/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
#include "Messages.h"
#include "Logger.h"
#include "Styles.h"
#include "VersionInfo.h"
#include "common/Settings.h"
#include "common/UrlConstants.h"
#include Please report a bug)"
" and copy/paste the following error: Sorry, a fatal error has occurred and the application must now exit. Sorry, a critical error has occurred. %1 will continue to run in the background and can be accessed via the %1 icon in your "
"system notifications area. This setting can be disabled. On Linux systems using GNOME 3, the notification area might be disabled. "
R"(You may need to enable an extension to see the %3 tray icon. Great, the %1 server is now running. Now you can connect your client computers to this server. "
"You should see a prompt here on the server when a new client tries to connect. %1 is now connected! Try moving your mouse to your other computer. Once there, go ahead "
"and type something. Don't forget, you can copy and paste between computers too. Try controlling this computer remotely. As you do not have the setting enabled to keep %1 running in "
"the background, you'll need to keep this window open or minimized "
"to keep %1 running. You can now close this window and %1 will continue to run in "
"the background. This setting can be disabled. Failed to connect to the server '%1'. A Client with your name is already connected to the server.v%3\n%4\n%5
"
)
.arg(kUrlHelp, kColorSecondary, kVersion, message, fileLine);
if (type == QtFatalMsg) {
text.prepend(QObject::tr("
Please try to connect to the server using the server IP address " "instead of the hostname.
" "If that doesn't work, please check your TLS and " "firewall settings.
" ) ); } else if (error == GenericError) { message.append(QObject::tr("Please check your TLS and firewall settings.
")); } else { qFatal("unknown client error"); } auto title = QObject::tr("%1 Connection Error").arg(kAppName); if (error != ClientError::HostnameError) { QMessageBox::warning(parent, title, message); return; } if (!Settings::value(Settings::Gui::ShowGenericClientFailureDialog).toBool()) return; auto dialog = QMessageBox(parent); dialog.setWindowTitle(title); dialog.setText(message); dialog.setWindowModality(Qt::ApplicationModal); dialog.setIcon(QMessageBox::Information); auto cbNoShowAgain = new QCheckBox(QObject::tr("Do not show this message again")); QObject::connect(cbNoShowAgain, &QCheckBox::toggled, [](bool enabled) { Settings::setValue(Settings::Gui::ShowGenericClientFailureDialog, !enabled); }); dialog.setCheckBox(cbNoShowAgain); dialog.setDefaultButton(QMessageBox::Ok); dialog.exec(); } NewClientPromptResult showNewClientPrompt(QWidget *parent, const QString &clientName, bool serverRequiresPeerAuth) { using enum NewClientPromptResult; if (serverRequiresPeerAuth) { // When peer auth is enabled you will be prompted to allow the connection before seeing this dialog. // This is why we do not show a dialog with an option to ignore the new client QMessageBox::information( parent, QObject::tr("%1 - New Client").arg(kAppName), QObject::tr("A new client called '%1' has been accepted. You'll need to add it to your server's screen layout.") .arg(clientName) ); return Add; } else { QMessageBox message(parent); const QPushButton *ignore = message.addButton(QObject::tr("Ignore"), QMessageBox::RejectRole); const QPushButton *add = message.addButton(QObject::tr("Add client"), QMessageBox::AcceptRole); message.setText(QObject::tr("A new client called '%1' wants to connect").arg(clientName)); message.exec(); if (message.clickedButton() == add) { return Add; } else if (message.clickedButton() == ignore) { return Ignore; } else { qFatal("no expected dialog button was clicked"); abort(); } } } bool showClearSettings(QWidget *parent) { const auto title = QObject::tr("%1 Clear Settings").arg(kAppName); const auto message = QObject::tr( "Are you sure you want to clear all settings and restart %1?
" "This action cannot be undone.
" ) .arg(kAppName); return QMessageBox::question(parent, title, message) == QMessageBox::Yes; } void showReadOnlySettings(QWidget *parent, const QString &systemSettingsPath) { const auto title = QObject::tr("%1 Read-only settings").arg(kAppName); const auto message = QObject::tr( "Settings are read-only because you only have read access " "to the file:
%1
" ) .arg(QDir::toNativeSeparators(systemSettingsPath)); QMessageBox::information(parent, title, message); } void showWaylandLibraryError(QWidget *parent) { QMessageBox::critical( parent, kAppName, QObject::tr( "Sorry, while this version of %1 does support Wayland, " "this build was not linked with one or more of the required " "libraries.
" "Please either switch to X from your login screen or use a build " "that uses the correct libraries.
" "If you think this is incorrect, please " R"(report a bug.
)" "Please check the logs for more information.
" ) .arg(kAppName, kUrlHelp, kColorSecondary) ); } bool showUpdateCheckOption(QWidget *parent) { QMessageBox message(parent); message.addButton(QObject::tr("No thanks"), QMessageBox::RejectRole); const auto checkButton = message.addButton(QObject::tr("Check for updates"), QMessageBox::AcceptRole); message.setText( QObject::tr( "Would you like to check for updates when %1 starts?
" "Checking for updates requires an Internet connection.
" "URL:
%2" ) .arg(kAppName, Settings::value(Settings::Core::UpdateUrl).toString()) ); message.exec(); return message.clickedButton() == checkButton; } bool showDaemonOffline(QWidget *parent) { QMessageBox message(parent); message.setIcon(QMessageBox::Warning); message.setWindowTitle(QObject::tr("Background service offline")); message.addButton(QObject::tr("Retry"), QMessageBox::AcceptRole); const auto ignore = message.addButton(QObject::tr("Ignore"), QMessageBox::RejectRole); const auto disable = message.addButton(QObject::tr("Disable"), QMessageBox::NoRole); message.setText( QObject::tr( "
There was a problem finding the %1 background service (daemon).
" "The background service makes %1 work with UAC prompts and the login screen.
" "If don't want to use the background service and intentionally stopped it, " "you can prevent it's use by disabling this feature.
" "If you did not stop the background service intentionally, there may be a problem with it. " "Please retry or try restarting the %1 service from the Windows services program.
" ) .arg(kAppName) ); message.exec(); if (message.clickedButton() == ignore) { return false; } else if (message.clickedButton() == disable) { Settings::setValue(Settings::Core::ProcessMode, Settings::ProcessMode::Desktop); return false; } return true; } } // namespace deskflow::gui::messages