From 52f3e0de7e2dba9044742e97f52160dda1488337 Mon Sep 17 00:00:00 2001 From: retgal Date: Sun, 24 Apr 2022 22:35:20 +0200 Subject: [PATCH 01/14] Added parsing of yaml presets --- .../mpo/dayon/assisted/AssistedRunner.java | 42 +++++++++++++++++++ .../java/mpo/dayon/assisted/gui/Assisted.java | 2 +- .../dayon/common/utils/SystemUtilities.java | 13 +++++- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/main/java/mpo/dayon/assisted/AssistedRunner.java b/src/main/java/mpo/dayon/assisted/AssistedRunner.java index 2266a80d..982b0a3d 100644 --- a/src/main/java/mpo/dayon/assisted/AssistedRunner.java +++ b/src/main/java/mpo/dayon/assisted/AssistedRunner.java @@ -3,9 +3,22 @@ import mpo.dayon.assisted.gui.Assisted; import mpo.dayon.common.Runner; import mpo.dayon.common.error.FatalErrorHandler; +import mpo.dayon.common.log.Log; import javax.swing.SwingUtilities; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static java.lang.String.format; +import static mpo.dayon.common.utils.SystemUtilities.getJarDir; +import static mpo.dayon.common.utils.SystemUtilities.getOrCreateAppDir; class AssistedRunner implements Runner { public static void main(String[] args) { @@ -24,6 +37,35 @@ public static void main(String[] args) { private static void launchAssisted(String assistantHost, String assistantPort) { final Assisted assisted = new Assisted(); assisted.configure(); + // cli args have precedence + if (assistantHost == null || assistantPort == null) { + final Map config = readPresetFile(); + assistantHost = config.get("host"); + assistantPort = config.get("port"); + } assisted.start(assistantHost, assistantPort); } + + private static Map readPresetFile() { + List paths = Arrays.asList(getOrCreateAppDir().toString(), System.getProperty("user.home"), getJarDir()); + for (String path : paths) { + for (String fileExt : Arrays.asList("yaml", "yml")) { + File presetFile = new File(path, format("assisted.%s", fileExt)); + if (presetFile.exists() && presetFile.isFile() && presetFile.canRead()) { + try (Stream lines = Files.lines(presetFile.toPath())) { + final Map content = lines.map(line -> line.split(":")).filter(s -> s.length > 1).collect(Collectors.toMap(s -> s[0].trim(), s -> s[1].trim())); + if (content.size() > 1) { + Log.info(format("Using connection settings from %s", presetFile.getPath())); + return content; + } + } catch (IOException e) { + Log.warn(e.getMessage()); + } + } + } + } + return Collections.EMPTY_MAP; + } + + } diff --git a/src/main/java/mpo/dayon/assisted/gui/Assisted.java b/src/main/java/mpo/dayon/assisted/gui/Assisted.java index 5c331eb1..1055da22 100644 --- a/src/main/java/mpo/dayon/assisted/gui/Assisted.java +++ b/src/main/java/mpo/dayon/assisted/gui/Assisted.java @@ -96,7 +96,7 @@ private boolean configureConnection(String serverName, String portNumber) { if (SystemUtilities.isValidIpAddressOrHostName(serverName) && SystemUtilities.isValidPortNumber(portNumber)) { coldStart = false; configuration = new NetworkAssistedEngineConfiguration(serverName, Integer.parseInt(portNumber)); - Log.info("Configuration from cli params" + configuration); + Log.info("Configuration from params " + configuration); networkEngine.configure(configuration); networkEngine.connect(); return true; diff --git a/src/main/java/mpo/dayon/common/utils/SystemUtilities.java b/src/main/java/mpo/dayon/common/utils/SystemUtilities.java index 027e3dd2..70fdf2b1 100644 --- a/src/main/java/mpo/dayon/common/utils/SystemUtilities.java +++ b/src/main/java/mpo/dayon/common/utils/SystemUtilities.java @@ -12,6 +12,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.security.InvalidParameterException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -35,7 +36,7 @@ public static URI getQuickStartURI(FrameType frameType) throws URISyntaxExceptio return new URI(String.format("http://retgal.github.io/Dayon/%s#%s-setup", translate("quickstart.html"), frameType.getPrefix())); } - private static synchronized File getOrCreateAppDir() { + public static synchronized File getOrCreateAppDir() { final String homeDir = System.getProperty("user.home"); // *.log4j.xml are using that one (!) if (homeDir == null) { Log.warn("Home directory [user.home] is null!"); @@ -87,6 +88,16 @@ public static String getTempDir() { return isSnapped() ? getOrCreateTransferDir().getPath() : System.getProperty("java.io.tmpdir"); } + public static String getJarDir() { + String jarPath = ""; + try { + jarPath = Paths.get(SystemUtilities.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParent().toString(); + } catch (URISyntaxException e) { + Log.warn(e.getMessage()); + } + return jarPath; + } + private static void cleanDir(File folder) { try (Stream walk = Files.walk(folder.toPath())) { walk.sorted(Comparator.reverseOrder()) From 208109863b93cf2f7f10194f4fea27af2fc57142 Mon Sep 17 00:00:00 2001 From: retgal Date: Mon, 25 Apr 2022 23:27:52 +0200 Subject: [PATCH 02/14] Configurable auto connect --- .../mpo/dayon/assisted/AssistedRunner.java | 32 ++++++++++++------- .../java/mpo/dayon/assisted/gui/Assisted.java | 20 ++++-------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/main/java/mpo/dayon/assisted/AssistedRunner.java b/src/main/java/mpo/dayon/assisted/AssistedRunner.java index 982b0a3d..d7ea53a3 100644 --- a/src/main/java/mpo/dayon/assisted/AssistedRunner.java +++ b/src/main/java/mpo/dayon/assisted/AssistedRunner.java @@ -40,10 +40,10 @@ private static void launchAssisted(String assistantHost, String assistantPort) { // cli args have precedence if (assistantHost == null || assistantPort == null) { final Map config = readPresetFile(); - assistantHost = config.get("host"); - assistantPort = config.get("port"); + assisted.start(config.get("host"), config.get("port"), isAutoConnect(config)); + } else { + assisted.start(assistantHost, assistantPort, true); } - assisted.start(assistantHost, assistantPort); } private static Map readPresetFile() { @@ -52,14 +52,9 @@ private static Map readPresetFile() { for (String fileExt : Arrays.asList("yaml", "yml")) { File presetFile = new File(path, format("assisted.%s", fileExt)); if (presetFile.exists() && presetFile.isFile() && presetFile.canRead()) { - try (Stream lines = Files.lines(presetFile.toPath())) { - final Map content = lines.map(line -> line.split(":")).filter(s -> s.length > 1).collect(Collectors.toMap(s -> s[0].trim(), s -> s[1].trim())); - if (content.size() > 1) { - Log.info(format("Using connection settings from %s", presetFile.getPath())); - return content; - } - } catch (IOException e) { - Log.warn(e.getMessage()); + Map content = parseFileContent(presetFile); + if (content != null) { + return content; } } } @@ -67,5 +62,20 @@ private static Map readPresetFile() { return Collections.EMPTY_MAP; } + private static Map parseFileContent(File presetFile) { + try (Stream lines = Files.lines(presetFile.toPath())) { + final Map content = lines.map(line -> line.split(":")).filter(s -> s.length > 1).collect(Collectors.toMap(s -> s[0].trim(), s -> s[1].trim())); + if (content.containsKey("host") && content.containsKey("port")) { + Log.info(format("Using connection settings from %s", presetFile.getPath())); + return content; + } + } catch (IOException e) { + Log.warn(e.getMessage()); + } + return null; + } + private static boolean isAutoConnect(Map config) { + return !config.containsKey("autoConnect") || !config.get("autoConnect").equalsIgnoreCase("false"); + } } diff --git a/src/main/java/mpo/dayon/assisted/gui/Assisted.java b/src/main/java/mpo/dayon/assisted/gui/Assisted.java index 1055da22..c2ff5be0 100644 --- a/src/main/java/mpo/dayon/assisted/gui/Assisted.java +++ b/src/main/java/mpo/dayon/assisted/gui/Assisted.java @@ -64,7 +64,7 @@ public void configure() { /** * Returns true if we have a valid configuration */ - public boolean start(String serverName, String portNumber) { + public boolean start(String serverName, String portNumber, boolean autoConnect) { Log.info("Assisted start"); // these should not block as they are called from the network incoming message thread (!) @@ -85,15 +85,15 @@ public boolean start(String serverName, String portNumber) { KeyboardErrorHandler.attachFrame(frame); frame.setVisible(true); } - return configureConnection(serverName, portNumber); + return configureConnection(serverName, portNumber, autoConnect); } public NetworkAssistedEngineConfiguration getConfiguration() { return configuration; } - private boolean configureConnection(String serverName, String portNumber) { - if (SystemUtilities.isValidIpAddressOrHostName(serverName) && SystemUtilities.isValidPortNumber(portNumber)) { + private boolean configureConnection(String serverName, String portNumber, boolean autoConnect) { + if (SystemUtilities.isValidIpAddressOrHostName(serverName) && SystemUtilities.isValidPortNumber(portNumber) && autoConnect) { coldStart = false; configuration = new NetworkAssistedEngineConfiguration(serverName, Integer.parseInt(portNumber)); Log.info("Configuration from params " + configuration); @@ -102,24 +102,16 @@ private boolean configureConnection(String serverName, String portNumber) { return true; } - final String ip = SystemUtilities.getStringProperty(null, "dayon.assistant.ipAddress", null); - final int port = SystemUtilities.getIntProperty(null, "dayon.assistant.portNumber", -1); - if (ip != null && port > -1) { - configuration = new NetworkAssistedEngineConfiguration(ip, port); - } else { - configuration = new NetworkAssistedEngineConfiguration(); - } - // no network settings dialogue if (coldStart) { coldStart = false; return true; } - return requestConnectionSettings(); } private boolean requestConnectionSettings() { + configuration = new NetworkAssistedEngineConfiguration(); ConnectionSettingsDialog connectionSettingsDialog = new ConnectionSettingsDialog(configuration); final boolean ok = DialogFactory.showOkCancel(frame, translate("connection.settings"), connectionSettingsDialog.getTabbedPane(), false, () -> { @@ -190,7 +182,7 @@ public void actionPerformed(ActionEvent ev) { boolean start() { // triggers network settings dialogue - return start(null, null); + return start(null, null, false); } void connect() { From f906b557c471bee1e4a52738aaca9201c1702894 Mon Sep 17 00:00:00 2001 From: retgal Date: Mon, 25 Apr 2022 23:29:09 +0200 Subject: [PATCH 03/14] Removal of some legacy code --- .../NetworkAssistantConfiguration.java | 12 +---------- .../capture/CaptureEngineConfiguration.java | 17 ++------------- .../NetworkAssistedEngineConfiguration.java | 21 ++----------------- 3 files changed, 5 insertions(+), 45 deletions(-) diff --git a/src/main/java/mpo/dayon/assistant/network/NetworkAssistantConfiguration.java b/src/main/java/mpo/dayon/assistant/network/NetworkAssistantConfiguration.java index dc4335b6..7b8e5c6e 100644 --- a/src/main/java/mpo/dayon/assistant/network/NetworkAssistantConfiguration.java +++ b/src/main/java/mpo/dayon/assistant/network/NetworkAssistantConfiguration.java @@ -15,16 +15,7 @@ public class NetworkAssistantConfiguration extends Configuration { */ public NetworkAssistantConfiguration() { final Preferences prefs = Preferences.getPreferences(); - - final int version = prefs.getIntPreference(PREF_VERSION, 0); - - if (!prefs.isNull() && version == 0) { - port = prefs.getIntPreference("assistantPortNumber", 8080); - - persist(true); - } else { - port = prefs.getIntPreference(PREF_PORT_NUMBER, 8080); - } + port = prefs.getIntPreference(PREF_PORT_NUMBER, 8080); } public NetworkAssistantConfiguration(int port) { @@ -67,7 +58,6 @@ protected void persist(boolean clear) { if (clear) // migration support (!) { props.clear("assistantPortNumber"); - props.clear("assistantIpAddress"); } Preferences.getPreferences().update(props); // atomic (!) } diff --git a/src/main/java/mpo/dayon/assisted/capture/CaptureEngineConfiguration.java b/src/main/java/mpo/dayon/assisted/capture/CaptureEngineConfiguration.java index 94090272..984ccd00 100644 --- a/src/main/java/mpo/dayon/assisted/capture/CaptureEngineConfiguration.java +++ b/src/main/java/mpo/dayon/assisted/capture/CaptureEngineConfiguration.java @@ -28,18 +28,8 @@ public class CaptureEngineConfiguration extends Configuration { */ public CaptureEngineConfiguration() { final Preferences prefs = Preferences.getPreferences(); - - final int version = prefs.getIntPreference(PREF_VERSION, 0); - - if (!prefs.isNull() && version == 0) { - captureTick = (int) (1000.0 / prefs.getDoublePreference("generations", 2.0)); - captureQuantization = prefs.getEnumPreference("grayLevels", Gray8Bits.X_256, Gray8Bits.values()); - - persist(true); - } else { - captureTick = prefs.getIntPreference(PREF_CAPTURE_TICK, 200); - captureQuantization = prefs.getEnumPreference(PREF_CAPTURE_QUANTIZATION, Gray8Bits.X_256, Gray8Bits.values()); - } + captureTick = prefs.getIntPreference(PREF_CAPTURE_TICK, 200); + captureQuantization = prefs.getEnumPreference(PREF_CAPTURE_QUANTIZATION, Gray8Bits.X_256, Gray8Bits.values()); } public CaptureEngineConfiguration(int captureTick, Gray8Bits captureQuantization) { @@ -85,7 +75,6 @@ protected void persist(boolean clear) { private Preferences.Props getProps(boolean clear) { final Preferences.Props props = new Preferences.Props(); - props.set(PREF_VERSION, String.valueOf(1)); props.set(PREF_CAPTURE_TICK, String.valueOf(captureTick)); props.set(PREF_CAPTURE_QUANTIZATION, String.valueOf(captureQuantization.ordinal())); @@ -93,8 +82,6 @@ private Preferences.Props getProps(boolean clear) { // migration support (!) if (clear) { props.clear("generations"); - props.clear("grayLevels"); - props.clear("tiles"); } return props; } diff --git a/src/main/java/mpo/dayon/assisted/network/NetworkAssistedEngineConfiguration.java b/src/main/java/mpo/dayon/assisted/network/NetworkAssistedEngineConfiguration.java index 18bceb5a..04cba5dd 100644 --- a/src/main/java/mpo/dayon/assisted/network/NetworkAssistedEngineConfiguration.java +++ b/src/main/java/mpo/dayon/assisted/network/NetworkAssistedEngineConfiguration.java @@ -19,16 +19,8 @@ public class NetworkAssistedEngineConfiguration extends Configuration { */ public NetworkAssistedEngineConfiguration() { final Preferences prefs = Preferences.getPreferences(); - final int version = prefs.getIntPreference(PREF_VERSION, 0); - - if (!prefs.isNull() && version == 0) { - serverName = prefs.getStringPreference("assistantIpAddress", "localhost"); - serverPort = prefs.getIntPreference("assistantPortNumber", 8080); - persist(true); - } else { - serverName = prefs.getStringPreference(PREF_SERVER_NAME, "localhost"); - serverPort = prefs.getIntPreference(PREF_SERVER_PORT_NUMBER, 8080); - } + serverName = prefs.getStringPreference(PREF_SERVER_NAME, "localhost"); + serverPort = prefs.getIntPreference(PREF_SERVER_PORT_NUMBER, 8080); } public NetworkAssistedEngineConfiguration(String serverName, int serverPort) { @@ -75,15 +67,6 @@ protected void persist(boolean clear) { { props.clear("assistantIpAddress"); props.clear("assistantPortNumber"); - - props.clear("tiles"); - props.clear("grayLevels"); - props.clear("generations"); - - props.clear("assistedFrameX"); - props.clear("assistedFrameY"); - props.clear("assistedFrameWidth"); - props.clear("assistedFrameHeight"); } Preferences.getPreferences().update(props); // atomic (!) } From 2c952240adfb79f82c3f847c4997207c36edc129 Mon Sep 17 00:00:00 2001 From: retgal Date: Tue, 26 Apr 2022 20:14:17 +0200 Subject: [PATCH 04/14] Updated documentation --- docs/de_quickstart.html | 25 +++++++++++++++++++++++++ docs/de_support.html | 13 ++----------- docs/fr_quickstart.html | 25 +++++++++++++++++++++++++ docs/fr_support.html | 21 ++++++--------------- docs/quickstart.html | 25 +++++++++++++++++++++++++ docs/style.css | 1 + docs/support.html | 15 +++------------ docs/zh_quickstart.html | 25 +++++++++++++++++++++++++ docs/zh_support.html | 11 +---------- 9 files changed, 113 insertions(+), 48 deletions(-) diff --git a/docs/de_quickstart.html b/docs/de_quickstart.html index 636a07a8..9b353cdf 100644 --- a/docs/de_quickstart.html +++ b/docs/de_quickstart.html @@ -191,6 +191,31 @@

Windowstastendruck übertragen

Die Taste bleibt gedrückt, bis sie erneut auf das Symbol klicken. Auf diese Weise können sie auch Windows-Tastenkombinationen senden.
Wenn sie beispielsweise alle Fenster des Assistierten minimieren möchten, klicken sie auf das Windows-Symbol, danach drücken sie die M Taste und klicken schliesslich erneut auf das Windows-Symbol. +

+

Automatische Verbindung des Assistierten

+

Via Kommandozeilenparameter

+

+ Der Hostname oder IP-Adresse und der Port des Assistenten können via Kommandozeilenparameter übergeben werden:
+ dayon_assisted ah=example.com ap=4242 (Linux/Mac OS)
+ Als Snap installiert, lautet der Befehl dayon.assisted ah=example.com ap=4242, aus einem .tgz + Archiv installiert hingegen: ./dayon_assisted.sh ah=example.com ap=4242 (Linux)
+ java -jar dayon.jar ah=example.com ap=4567 (Windows)
+ oder bei der Quick Launch Version:
+ dayon_assisted.exe ah=example.org ap=80
+ Wird der Assisterte mit diesen Parametern gestartet, so verbindet er sich ohne Rückfrage direkt mit der übergebenen Host. +

Via Konfigurationsdatei

+

+ Ab Version v11.0.5, können die Verbindungsparameter in einer YAML-Datei hinterlegt werden. + Die Struktur ist äusserst simpel:

+host: an.example.com
+port: 8080
+ Diese Datei kann unter dem Namen assisted.yaml entweder im Dayon! Heimverzeichnis, im Benutzerverzeichnis, + oder im selben Verzeichnis wie die .jar, resp. .exe Datei abgelegt werden. + Diese Reihenfolge entspricht auch der Priorität, mit welcher sie berücksichtigt werden, falls mehrere Konfigurationen + existieren. (die erste gewinnt)
+ Um zu verhindern, dass sich der Assistierte direkt nach dem Start automatisch verbindet, kann assisted.yaml um die + folgende Zeile ergänzt werden:
+autoConnect: false

Das ist alles! Weitere Informationen finden sie auf der Support Seite. diff --git a/docs/de_support.html b/docs/de_support.html index 498f9162..f79f3f4b 100644 --- a/docs/de_support.html +++ b/docs/de_support.html @@ -28,18 +28,9 @@

Bekannte Einschränkungen

  • Es existiert keine Möglichkeit gewisse Tastenkombinationen wie etwa Ctrl-Alt-Del an den entfernten Computer zu senden.
  • Idealerweise verwenden die Computer des Assistenten und des Assistierten beide dieselbe Eingabesprache. - Die Verwendung unterschiedlicher Tastaturlayouts kann insbesondere bei der Eingabe von Sonderzeichen zu Problemen führen. + Die Verwendung unterschiedlicher Tastaturbelegung kann insbesondere bei der Eingabe von Sonderzeichen zu Problemen führen. + Die verwendete Tastaturbelegung ist in der Titelleiste der jeweiligen Applikation ersichtlich. -

    Automatische Verbindung des Assistierten

    -

    - Der Hostname oder IP-Adresse und der Port des Assistenten können via Kommandozeilenparameter übergeben werden:
    - dayon_assisted ah=example.com ap=4242 (Linux/Mac OS)
    - Als Snap installiert, lautet der Befehl dayon.assisted ah=example.com ap=4242, aus einem .tgz - Archiv installiert hingegen: ./dayon_assisted.sh ah=example.com ap=4242 (Linux)
    - java -jar dayon.jar ah=example.com ap=4567 (Windows)
    - oder bei der Quick Launch Version:
    - dayon_assisted.exe ah=example.org ap=80
    - Wird der Assisterte mit diesen Parametern gestartet, so verbindet er sich ohne Rückfrage direkt mit der übergebenen Host.

    Dayon! Heimverzeichnis

    Das Verzeichnis .dayon wird im Standardbenutzerverzeichnis des eingelogten Benutzers oder diff --git a/docs/fr_quickstart.html b/docs/fr_quickstart.html index aaf23f96..b69b60f9 100644 --- a/docs/fr_quickstart.html +++ b/docs/fr_quickstart.html @@ -190,6 +190,31 @@

    Transmettre la pression de la touche Windows

    Cela vous permet d'envoyer des raccourcis clavier Windows.
    Si vous avez besoin, par exemple, de réduire toutes les fenêtres sur l'assistée, vous cliquez sur le symbole Windows, appuyez sur la touche M, puis cliquez à nouveau sur le symbole Windows. +

    +

    Connexion automatique de l'assistée

    +

    Via les paramètres de la ligne de commande

    +

    + Le nom d'hôte ou l'adresse IP et le port de l'assistant peuvent être transmis via des paramètres de ligne de commande :
    + dayon_assisted ah=example.com ap=4242 (Linux/Mac OS)
    + Installé en Snap, la commande est dayon.assisted ah=example.com ap=4242, depuis un .tgz + Archive installée à la place : ./dayon_assisted.sh ah=example.com ap=4242 (Linux)
    + java -jar dayon.jar ah=exemple.com ap=4567 (Windows)
    + ou pour la version de lancement rapide :
    + dayon_assisted.exe ah=exemple.org ap=80
    + Si l'assistant est démarré avec ces paramètres, il se connecte directement à l'hôte transféré sans demander. +

    Via le fichier de configuration

    +

    + A partir de la version v11.0.5, les paramètres de connexion peuvent être stockés dans un fichier YAML. + La structure est extrêmement simple :

    +host: an.example.com
    +port: 8080
    + Ce fichier peut être enregistré sous le nom assisted.yaml soit dans le Dayon! répertoire personnel, dans le répertoire utilisateur, + ou dans le même répertoire que le .jar, resp. Fichier .exe. + Cet ordre correspond également à la priorité avec laquelle ils sont pris en compte dans le cas de configurations multiples + existent. (la première gagne)
    + Pour éviter que l'assisté ne se connecte automatiquement juste après le démarrage, assisted.yaml la + ligne suivante peut être ajoutée :
    +autoConnect: false

    C'est tout! Vous trouverez plus d'information sur la page support. diff --git a/docs/fr_support.html b/docs/fr_support.html index f4ea02aa..d9eed054 100644 --- a/docs/fr_support.html +++ b/docs/fr_support.html @@ -27,19 +27,10 @@

    Problèmes Connus

    • Il n'y a actuellement aucun moyen d'envoyer certaines combinaisons clés à l'ordinateur assisté. (par example Ctrl-Alt-Del).
    • Idéalement, les ordinateurs de l'assistant et de l'assisté utilisent tous les deux la même langue de saisie. - L'utilisation de différentes dispositions de clavier peut entraîner des problèmes, en particulier lors de la saisie de caractères spéciaux.
    -

    Connexion automatique de l’assistant

    -

    - Le nom d'hôte ou l'adresse IP et le port de l'assistant peuvent être transmis via les paramètres de ligne de - commande:
    - dayon_assisted ah=example.com ah=4242 (Linux/Mac OS)
    - Installée comme snap, la commande est dayon.assisted ah=example.com ap=4242, installée - à partir d'un .tgz: ./dayon_assisted.sh ah=example.com ap=4242 (Linux)
    - java -jar dayon.jar ah=example.com ap=4567 (Windows)
    - ou pour la version «lancement rapide»:
    - dayon_assisted.exe ah=example.org ap=80
    - Si l'assistant est démarré avec ces paramètres, il se connecte directement à l'hôte donné sans interrogation - supplémentaire. + L'utilisation de différentes dispositions de clavier peut entraîner des problèmes, en particulier lors de la saisie de caractères spéciaux. + La disposition du clavier utilisée est visible dans la barre de titre de l'application respective. + +

    Dayon! Répertoire de base

    Le répertoire .dayon est créé dans le répertoire de base par défaut de l'utilisateur connecté @@ -67,12 +58,12 @@

    Compteurs de statistiques

  • Compression Ratio: combien de fois la capture initiale (diff only) a été comprimé
  • Number of Tiles: le nombre de carreaux étant également transmis sur le réseau ou servis depuis le cache.
  • Number of Skipped Capture: le nombre de captures d'écran qui ont été ignorées En raison d'un taux trop - élevé (c'est-à-dire, une valeur de cotation faible) pour la CPU. Pour minimiser cette vous devez + élevé (c'est-à-dire, une valeur de cotation faible) pour la CPU. Pour minimiser cette, vous devez ralentir le taux de capture en utilisant une valeur plus grande.
  • Number of Merged Capture: le nombre de captures d'écran fusionnées avant d'être transmis. Ceci est dû à un taux de capture trop élevé pour le courant méthode de compression. Pour minimiser ce nombre, vous - devez ralentir la capture taux et / ou changer la méthode de compression en utilisant un plus rapide. + devez ralentir la capture taux et/ou changer la méthode de compression en utilisant un plus rapide.
  • Utilisation de la mémoire
  • Durée de la session d'assistance active ou de la dernière diff --git a/docs/quickstart.html b/docs/quickstart.html index 06c2d7e5..5f455699 100644 --- a/docs/quickstart.html +++ b/docs/quickstart.html @@ -183,6 +183,31 @@

    Transmit a Windows key press

    The key remains pressed until you click the symbol again. This allows you to send Windows key shortcuts.
    If you need for example to minimize all windows on the assisted side, you would click the Windows symbol, press the M key and then click the Windows symbol again. +

    +

    Automatic connection of the assisted

    +

    Via command line parameters

    +

    + The host name or IP address and port of the assistant can be passed via command line parameters:
    + dayon_assisted ah=example.com ap=4242 (Linux/Mac OS)
    + Installed as a snap, the command is dayon.assisted ah=example.com ap=4242, installed + from a .tgz archive: ./dayon_assisted.sh ah=example.com ap=4242 (Linux)
    + java -jar dayon.jar ah=example.com ap=4567 (Windows)
    + or for the Quick Launch version:
    + dayon_assisted.exe ah=example.org ap=80
    + If the assistant is started with these parameters, then he connects directly to the given host without further inquiry. +

    Via configuration file

    +

    + From version v11.0.5, the connection parameters can be stored in a YAML file. + The structure is extremely simple:

    +host: an.example.com
    +port: 8080
    + This file can be saved under the name assisted.yaml either in the Dayon! home directory, in the user directory, + or in the same directory as the .jar, resp. .exe file. + This order also corresponds to the priority with which they are taken into account in the case of multiple configurations + exist. (first wins)
    + To prevent the assisted from automatically connecting right after the start, assisted.yaml + the following line can be added:
    +autoConnect: false

    That's all folks! You can find more information on the support page. diff --git a/docs/style.css b/docs/style.css index 3358e107..d395e827 100644 --- a/docs/style.css +++ b/docs/style.css @@ -102,6 +102,7 @@ img { color:red; } +pre, code { font-weight:bolder; } diff --git a/docs/support.html b/docs/support.html index c3257413..c2fcd3d0 100644 --- a/docs/support.html +++ b/docs/support.html @@ -28,20 +28,11 @@

    Known Limitations

  • There's currently no way to send certain key combinations to the assisted computer (e.g., Ctrl-Alt-Del).
  • Ideally, the computers of the assistant and the assisted use both the same input language. Using different keyboard layouts can lead to problems, especially when entering special characters. + The keyboard layout in use can be seen in the title bar of the respective application. -

    Automatic connection of the assisted

    -

    - The host name or IP address and port of the assistant can be passed via command line parameters:
    - dayon_assisted ah=example.com ap=4242 (Linux/Mac OS)
    - Installed as a snap, the command is dayon.assisted ah=example.com ap=4242, installed - from a .tgz archive: ./dayon_assisted.sh ah=example.com ap=4242 (Linux)
    - java -jar dayon.jar ah=example.com ap=4567 (Windows)
    - or for the Quick Launch version:
    - dayon_assisted.exe ah=example.org ap=80
    - If the assistant is started with these parameters, then he connects directly to the given host without further inquiry.

    Dayon! Home Directory

    - The directory .dayon is created within the default home directory of the logged in user or within + The directory .dayon is created within the default home directory of the logged-in user or within the directory referenced by the JAVA property user.home and contains the saved user preferences and default log file(s).

    CRC Checksum

    @@ -50,7 +41,7 @@

    CRC Checksum

    changed from the previous capture are sent over the network to the assistant side. To determine if a tile is different I'm currently computing a CRC code (i.e., a unique integer value representing the pixels of the tile) that is not perfect for the sake - of speed. So it might happens that some changed tiles are not sent to the assistant. + of speed. So it might happen that some changed tiles are not sent to the assistant.

    Until now I've detected that issue during strong testing for very few pixels. Visually, I've not noticed anything serious. But in case things are going mad you can then restart the assisted or before try the diff --git a/docs/zh_quickstart.html b/docs/zh_quickstart.html index 48af98a7..4dd4a6af 100644 --- a/docs/zh_quickstart.html +++ b/docs/zh_quickstart.html @@ -178,6 +178,31 @@

    发送Windows徽标按键

    单击一次,Windows 键将保持按下状态,直到您再次单击该按钮。这么做是为了发送 Windows 快捷键。 例如,如果您需要最小化 所有窗口侧的 ,您可以单击 Windows 符号, 按下 M键,然后再次单击 Windows 符号。 +

    +

    用户端(Assisted)自动连接

    +

    通过命令行参数

    +

    + 可以通过命令行参数传递主控端(Assistant)的主机名或IP地址和端口:
    + dayon_assisted ah=example.com ap=4242 (Linux/Mac OS)
    + 如果是Snap版本,请使用:dayon.assisted ah=example.com ap=4242;如果您是从tge压缩包安装的 + 请使用:./dayon_assisted.sh ah=example.com ap=4242 (Linux)
    + java -jar dayon.jar ah=example.com ap=4567 (Windows)
    + 或者快速启动版本请使用:
    + dayon_assisted.exe ah=example.org ap=80
    + 如果使用这些参数启动,程序将直接连接到给定的远程主机。 +

    通过配置文件

    +

    + 从 v11.0.5 版本开始,连接参数可以存储在 YAML 文件中。 + 结构极其简单:

    +host: an.example.com
    +port: 8080
    + 该文件可以在 Dayon 中以 assisted.yaml 的名称保存! 主目录,在用户目录中, + 或在与 .jar 相同的目录中,分别。 .exe 文件。 + 此顺序还对应于在多个配置的情况下考虑它们的优先级 + 存在。 (第一次获胜)
    + 为防止辅助启动后立即自动连接,assisted.yaml + 可以添加以下行:
    +autoConnect: false

    That's all folks ! 更多信息请查看 支持 页面。 diff --git a/docs/zh_support.html b/docs/zh_support.html index 4573a02d..bc364683 100644 --- a/docs/zh_support.html +++ b/docs/zh_support.html @@ -27,17 +27,8 @@

    已知的不足

    • 目前无法将某些组合键发送到用户(Assisted)计算机(例如,Ctrl-Alt-Del)。
    • 理想情况下,助手和被协助者的计算机使用相同的输入语言。 使用不同的键盘布局可能会导致问题,尤其是在输入特殊字符时。 + 使用的键盘布局可以在相应应用程序的标题栏中看到。
    -

    用户端(Assisted)自动连接

    -

    - 可以通过命令行参数传递主控端(Assistant)的主机名或IP地址和端口:
    - dayon_assisted ah=example.com ap=4242 (Linux/Mac OS)
    - 如果是Snap版本,请使用:dayon.assisted ah=example.com ap=4242;如果您是从tge压缩包安装的 - 请使用:./dayon_assisted.sh ah=example.com ap=4242 (Linux)
    - java -jar dayon.jar ah=example.com ap=4567 (Windows)
    - 或者快速启动版本请使用:
    - dayon_assisted.exe ah=example.org ap=80
    - 如果使用这些参数启动,程序将直接连接到给定的远程主机。

    Dayon! 配置目录

    Dayon! 将会在所登录用户的用户文件夹下或者JAVA属性中的user.home创建一个.dayon文件夹,用于存放Dayon! 的用户配置和日志文件。 From f563ec311ade6a8b0f76bea589a38d3351f3907c Mon Sep 17 00:00:00 2001 From: retgal Date: Tue, 26 Apr 2022 20:15:32 +0200 Subject: [PATCH 05/14] Improved auto connect behaviour --- src/main/java/mpo/dayon/assisted/gui/Assisted.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/mpo/dayon/assisted/gui/Assisted.java b/src/main/java/mpo/dayon/assisted/gui/Assisted.java index c2ff5be0..bd9eabe2 100644 --- a/src/main/java/mpo/dayon/assisted/gui/Assisted.java +++ b/src/main/java/mpo/dayon/assisted/gui/Assisted.java @@ -93,16 +93,22 @@ public NetworkAssistedEngineConfiguration getConfiguration() { } private boolean configureConnection(String serverName, String portNumber, boolean autoConnect) { - if (SystemUtilities.isValidIpAddressOrHostName(serverName) && SystemUtilities.isValidPortNumber(portNumber) && autoConnect) { - coldStart = false; + if (SystemUtilities.isValidIpAddressOrHostName(serverName) && SystemUtilities.isValidPortNumber(portNumber)) { configuration = new NetworkAssistedEngineConfiguration(serverName, Integer.parseInt(portNumber)); Log.info("Configuration from params " + configuration); networkEngine.configure(configuration); + configuration.persist(); + } else { + autoConnect = false; + } + + if (autoConnect) { + coldStart = false; networkEngine.connect(); return true; } - // no network settings dialogue + // no network settings dialogue after startup if (coldStart) { coldStart = false; return true; From ff333c165ecf2e9a4e82e54795f310b4435dc0ac Mon Sep 17 00:00:00 2001 From: retgal Date: Wed, 27 Apr 2022 22:33:28 +0200 Subject: [PATCH 06/14] Improved logging, reformatting --- .../java/mpo/dayon/assisted/gui/Assisted.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/mpo/dayon/assisted/gui/Assisted.java b/src/main/java/mpo/dayon/assisted/gui/Assisted.java index bd9eabe2..0da66c2e 100644 --- a/src/main/java/mpo/dayon/assisted/gui/Assisted.java +++ b/src/main/java/mpo/dayon/assisted/gui/Assisted.java @@ -95,7 +95,7 @@ public NetworkAssistedEngineConfiguration getConfiguration() { private boolean configureConnection(String serverName, String portNumber, boolean autoConnect) { if (SystemUtilities.isValidIpAddressOrHostName(serverName) && SystemUtilities.isValidPortNumber(portNumber)) { configuration = new NetworkAssistedEngineConfiguration(serverName, Integer.parseInt(portNumber)); - Log.info("Configuration from params " + configuration); + Log.info("Autoconfigured " + configuration); networkEngine.configure(configuration); configuration.persist(); } else { @@ -171,13 +171,13 @@ private Action createToggleMultiScreenAction() { final Action multiScreen = new AbstractAction() { @Override public void actionPerformed(ActionEvent ev) { - initNewCaptureEngine(!shareAllScreens.get()); - shareAllScreens.set(!shareAllScreens.get()); - frame.repaint(); - if (networkEngine != null) { - final Dimension screenSize = ScreenUtilities.getSharedScreenSize().getSize(); - networkEngine.sendResizeScreen(screenSize.width, screenSize.height); - } + initNewCaptureEngine(!shareAllScreens.get()); + shareAllScreens.set(!shareAllScreens.get()); + frame.repaint(); + if (networkEngine != null) { + final Dimension screenSize = ScreenUtilities.getSharedScreenSize().getSize(); + networkEngine.sendResizeScreen(screenSize.width, screenSize.height); + } } }; multiScreen.putValue(Action.NAME, "shareAllScreens"); From 234c47f086221bcc49e7edac7cfea931b28431da Mon Sep 17 00:00:00 2001 From: retgal Date: Fri, 29 Apr 2022 13:49:39 +0200 Subject: [PATCH 07/14] Only accept .yaml extension --- .../java/mpo/dayon/assisted/AssistedRunner.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/mpo/dayon/assisted/AssistedRunner.java b/src/main/java/mpo/dayon/assisted/AssistedRunner.java index d7ea53a3..ff26a659 100644 --- a/src/main/java/mpo/dayon/assisted/AssistedRunner.java +++ b/src/main/java/mpo/dayon/assisted/AssistedRunner.java @@ -47,15 +47,14 @@ private static void launchAssisted(String assistantHost, String assistantPort) { } private static Map readPresetFile() { - List paths = Arrays.asList(getOrCreateAppDir().toString(), System.getProperty("user.home"), getJarDir()); + final List paths = Arrays.asList(getOrCreateAppDir().toString(), System.getProperty("user.home"), getJarDir()); + final String fileName = "assisted.yaml"; for (String path : paths) { - for (String fileExt : Arrays.asList("yaml", "yml")) { - File presetFile = new File(path, format("assisted.%s", fileExt)); - if (presetFile.exists() && presetFile.isFile() && presetFile.canRead()) { - Map content = parseFileContent(presetFile); - if (content != null) { - return content; - } + final File presetFile = new File(path, fileName); + if (presetFile.exists() && presetFile.isFile() && presetFile.canRead()) { + final Map content = parseFileContent(presetFile); + if (content != null) { + return content; } } } From 59d5dd1c876cdd4b8b4f58595504921e0f6dfa9a Mon Sep 17 00:00:00 2001 From: retgal Date: Fri, 29 Apr 2022 14:59:13 +0200 Subject: [PATCH 08/14] Fixed inverted uac settings condition --- src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java b/src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java index 46194881..6706af93 100644 --- a/src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java +++ b/src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java @@ -263,7 +263,7 @@ void onReady() { actions.getCaptureEngineConfigurationAction().setEnabled(true); actions.getResetAction().setEnabled(false); disableControls(); - statusBar.setMessage(translate("ready")); + getStatusBar().setMessage(translate("ready")); } void onHttpStarting(int port) { @@ -282,7 +282,7 @@ protected void paintComponent(Graphics g) { } }; add(center, BorderLayout.CENTER); - statusBar.setMessage(translate("listening", port)); + getStatusBar().setMessage(translate("listening", port)); } boolean onAccepted(Socket connection) { @@ -292,7 +292,7 @@ boolean onAccepted(Socket connection) { return false; } removeCenter(); - statusBar.setMessage(translate("connection.incoming.msg2", connection.getInetAddress().getHostAddress())); + getStatusBar().setMessage(translate("connection.incoming.msg2", connection.getInetAddress().getHostAddress())); center = assistantPanelWrapper; add(center, BorderLayout.CENTER); actions.getResetAction().setEnabled(true); @@ -322,7 +322,7 @@ void onSessionStarted() { long sessionStartTime = Instant.now().getEpochSecond(); sessionTimer = new Timer(1000, e -> { final long seconds = Instant.now().getEpochSecond() - sessionStartTime; - statusBar.setSessionDuration(format("%02d:%02d:%02d", seconds/3600, (seconds % 3600)/60, seconds % 60)); + getStatusBar().setSessionDuration(format("%02d:%02d:%02d", seconds/3600, (seconds % 3600)/60, seconds % 60)); }); sessionTimer.start(); } From b0484642d4d3ebb94285074242cc6f17b2976993 Mon Sep 17 00:00:00 2001 From: retgal Date: Fri, 29 Apr 2022 15:00:09 +0200 Subject: [PATCH 09/14] Fixed encapsulation issues --- .../assistant/gui/AssistantConfiguration.java | 2 +- .../NetworkAssistantConfiguration.java | 2 +- .../capture/CaptureEngineConfiguration.java | 2 +- .../assisted/compressor/CompressorEngine.java | 15 ++-- .../CompressorEngineConfiguration.java | 2 +- .../mpo/dayon/assisted/gui/AssistedFrame.java | 36 ++++---- .../NetworkAssistedEngineConfiguration.java | 2 +- .../mpo/dayon/common/capture/Capture.java | 12 ++- .../mpo/dayon/common/capture/CaptureTile.java | 2 +- .../dayon/common/gui/common/BaseFrame.java | 82 +++++++++++-------- .../common/network/message/FileMetaData.java | 10 +-- .../dayon/common/preference/Preferences.java | 68 ++++++++++----- .../mpo/dayon/common/utils/UnitUtilities.java | 30 +++++-- 13 files changed, 168 insertions(+), 97 deletions(-) diff --git a/src/main/java/mpo/dayon/assistant/gui/AssistantConfiguration.java b/src/main/java/mpo/dayon/assistant/gui/AssistantConfiguration.java index 62dbef73..e3e2f340 100644 --- a/src/main/java/mpo/dayon/assistant/gui/AssistantConfiguration.java +++ b/src/main/java/mpo/dayon/assistant/gui/AssistantConfiguration.java @@ -40,7 +40,7 @@ public boolean equals(Object o) { return false; } final AssistantConfiguration that = (AssistantConfiguration) o; - return lookAndFeelClassName.equals(that.lookAndFeelClassName); + return lookAndFeelClassName.equals(that.getLookAndFeelClassName()); } @Override diff --git a/src/main/java/mpo/dayon/assistant/network/NetworkAssistantConfiguration.java b/src/main/java/mpo/dayon/assistant/network/NetworkAssistantConfiguration.java index 7b8e5c6e..01ac1d82 100644 --- a/src/main/java/mpo/dayon/assistant/network/NetworkAssistantConfiguration.java +++ b/src/main/java/mpo/dayon/assistant/network/NetworkAssistantConfiguration.java @@ -37,7 +37,7 @@ public boolean equals(Object o) { final NetworkAssistantConfiguration that = (NetworkAssistantConfiguration) o; - return port == that.port; + return port == that.getPort(); } @Override diff --git a/src/main/java/mpo/dayon/assisted/capture/CaptureEngineConfiguration.java b/src/main/java/mpo/dayon/assisted/capture/CaptureEngineConfiguration.java index 984ccd00..6130aec9 100644 --- a/src/main/java/mpo/dayon/assisted/capture/CaptureEngineConfiguration.java +++ b/src/main/java/mpo/dayon/assisted/capture/CaptureEngineConfiguration.java @@ -56,7 +56,7 @@ public boolean equals(Object o) { final CaptureEngineConfiguration that = (CaptureEngineConfiguration) o; - return captureTick == that.captureTick && captureQuantization == that.captureQuantization; + return captureTick == that.getCaptureTick() && captureQuantization == that.getCaptureQuantization(); } @Override diff --git a/src/main/java/mpo/dayon/assisted/compressor/CompressorEngine.java b/src/main/java/mpo/dayon/assisted/compressor/CompressorEngine.java index 19c77f82..861ba6f1 100644 --- a/src/main/java/mpo/dayon/assisted/compressor/CompressorEngine.java +++ b/src/main/java/mpo/dayon/assisted/compressor/CompressorEngine.java @@ -93,10 +93,10 @@ public void start(int queueSize) { int pos = 0; for (int idx = pendings.size() - 1; idx > -1; idx--) { - cpendings[pos++] = ((MyExecutable) pendings.get(idx)).capture; + cpendings[pos++] = ((MyExecutable) pendings.get(idx)).getCapture(); } - newer.capture.mergeDirtyTiles(cpendings); + newer.getCapture().mergeDirtyTiles(cpendings); } poolExecutor.execute(newer); @@ -158,22 +158,22 @@ protected void execute() throws IOException { } if (xreconfigured) { - Log.info("Compressor engine has been reconfigured [tile:" + capture.getId() + "] " + xconfiguration); + Log.info("Compressor engine has been reconfigured [tile:" + getCapture().getId() + "] " + xconfiguration); } final Compressor compressor = Compressor.get(xconfiguration.getMethod()); - final MemByteBuffer compressed = compressor.compress(cache, capture); + final MemByteBuffer compressed = compressor.compress(cache, getCapture()); // Possibly blocking - no problem as we'll replace (and merge) in our queue // the oldest capture (if any) until we can compress it and send it to the next // stage of processing. if (!xreconfigured) { - fireOnCompressed(capture, compressor.getMethod(), null, compressed); + fireOnCompressed(getCapture(), compressor.getMethod(), null, compressed); } else { // we have to send the whole configuration => de-compressor synchronization (!) - fireOnCompressed(capture, compressor.getMethod(), xconfiguration, compressed); + fireOnCompressed(getCapture(), compressor.getMethod(), xconfiguration, compressed); } } finally { cache.onCaptureProcessed(); @@ -187,6 +187,9 @@ private void fireOnCompressed(Capture capture, CompressionMethod compressionMeth } } + public Capture getCapture() { + return capture; + } } } diff --git a/src/main/java/mpo/dayon/assisted/compressor/CompressorEngineConfiguration.java b/src/main/java/mpo/dayon/assisted/compressor/CompressorEngineConfiguration.java index 4f511904..551938ac 100644 --- a/src/main/java/mpo/dayon/assisted/compressor/CompressorEngineConfiguration.java +++ b/src/main/java/mpo/dayon/assisted/compressor/CompressorEngineConfiguration.java @@ -73,7 +73,7 @@ public boolean equals(Object o) { return false; } final CompressorEngineConfiguration that = (CompressorEngineConfiguration) o; - return maxSize == that.maxSize && purgeSize == that.purgeSize && useCache == that.useCache && method == that.method; + return maxSize == that.getCacheMaxSize() && purgeSize == that.getCachePurgeSize() && useCache == that.useCache() && method == that.getMethod(); } @Override diff --git a/src/main/java/mpo/dayon/assisted/gui/AssistedFrame.java b/src/main/java/mpo/dayon/assisted/gui/AssistedFrame.java index 85b844b0..535f4151 100755 --- a/src/main/java/mpo/dayon/assisted/gui/AssistedFrame.java +++ b/src/main/java/mpo/dayon/assisted/gui/AssistedFrame.java @@ -42,7 +42,7 @@ private ToolBar createToolBar() { if (ScreenUtilities.getNumberOfScreens() > 1) { toolbar.addToggleAction(toggleMultiScreenCaptureAction); } - if (File.separatorChar != '\\') { + if (File.separatorChar == '\\') { toolbar.addAction(createShowUacSettingsAction()); } toolbar.addSeparator(); @@ -54,16 +54,7 @@ private ToolBar createToolBar() { } private Action createShowUacSettingsAction() { - final Action showUacSettings = new AbstractAction() { - @Override - public void actionPerformed(ActionEvent ev) { - try { - Runtime.getRuntime().exec(System.getenv("WINDIR") + "\\system32\\useraccountcontrolsettings.exe"); - } catch (IOException e) { - Log.error(e.getMessage()); - } - } - }; + final Action showUacSettings = new AssistedAbstractAction(); showUacSettings.putValue(Action.NAME, "showUacSettings"); showUacSettings.putValue(Action.SHORT_DESCRIPTION, translate("uacSettings")); @@ -84,7 +75,7 @@ void onReady() { this.setCursor(cursor); startAction.setEnabled(true); stopAction.setEnabled(false); - statusBar.setMessage(translate("ready")); + getStatusBar().setMessage(translate("ready")); connected = false; } @@ -92,7 +83,7 @@ void onConnecting(String serverName, int serverPort) { this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); startAction.setEnabled(false); stopAction.setEnabled(true); - statusBar.setMessage(translate("connecting", serverName, serverPort)); + getStatusBar().setMessage(translate("connecting", serverName, serverPort)); connected = false; } @@ -100,7 +91,7 @@ void onConnected() { this.setCursor(cursor); startAction.setEnabled(false); stopAction.setEnabled(true); - statusBar.setMessage(translate("connected")); + getStatusBar().setMessage(translate("connected")); connected = true; } @@ -109,7 +100,7 @@ void onHostNotFound(String serverName) { if (!connected) { startAction.setEnabled(true); stopAction.setEnabled(false); - statusBar.setMessage(translate("serverNotFound", serverName)); + getStatusBar().setMessage(translate("serverNotFound", serverName)); } } @@ -118,7 +109,7 @@ void onConnectionTimeout(String serverName, int serverPort) { if (!connected) { stopAction.setEnabled(false); startAction.setEnabled(true); - statusBar.setMessage(translate("connectionTimeout", serverName, serverPort)); + getStatusBar().setMessage(translate("connectionTimeout", serverName, serverPort)); } } @@ -127,11 +118,22 @@ void onRefused(String serverName, int serverPort) { if (!connected) { startAction.setEnabled(true); stopAction.setEnabled(false); - statusBar.setMessage(translate("refused", serverName, serverPort)); + getStatusBar().setMessage(translate("refused", serverName, serverPort)); } } void onDisconnecting() { onReady(); } + + private static class AssistedAbstractAction extends AbstractAction { + @Override + public void actionPerformed(ActionEvent ev) { + try { + Runtime.getRuntime().exec(System.getenv("WINDIR") + "\\system32\\useraccountcontrolsettings.exe"); + } catch (IOException e) { + Log.error(e.getMessage()); + } + } + } } diff --git a/src/main/java/mpo/dayon/assisted/network/NetworkAssistedEngineConfiguration.java b/src/main/java/mpo/dayon/assisted/network/NetworkAssistedEngineConfiguration.java index 04cba5dd..7d3180c7 100644 --- a/src/main/java/mpo/dayon/assisted/network/NetworkAssistedEngineConfiguration.java +++ b/src/main/java/mpo/dayon/assisted/network/NetworkAssistedEngineConfiguration.java @@ -45,7 +45,7 @@ public boolean equals(Object o) { return false; } final NetworkAssistedEngineConfiguration that = (NetworkAssistedEngineConfiguration) o; - return serverPort == that.serverPort && serverName.equals(that.serverName); + return serverPort == that.getServerPort() && serverName.equals(that.getServerName()); } @Override diff --git a/src/main/java/mpo/dayon/common/capture/Capture.java b/src/main/java/mpo/dayon/common/capture/Capture.java index 1aa1e54a..cb1fb935 100644 --- a/src/main/java/mpo/dayon/common/capture/Capture.java +++ b/src/main/java/mpo/dayon/common/capture/Capture.java @@ -67,6 +67,10 @@ public int getMerged() { return merged.get(); } + private CaptureTile[] getDirty() { + return dirty; + } + /** * @see #computeInitialByteCount() */ @@ -126,8 +130,8 @@ public void mergeDirtyTiles(Capture[] olders) { for (final Capture older : olders) { doMergeDirtyTiles(older); - xskipped += older.skipped.get(); - xmerged += older.merged.get(); + xskipped += older.getSkipped(); + xmerged += older.getMerged(); } skipped.addAndGet(xskipped); @@ -150,13 +154,13 @@ private void doMergeDirtyTiles(Capture older) { // In that case (for the sake of simplicity) a FULL capture will be // sent. - if (dirty.length != older.dirty.length) { + if (dirty.length != older.getDirty().length) { return; // we're keeping the newest (FULL capture anyway) } for (int idx = 0; idx < dirty.length; idx++) { final CaptureTile thisTile = dirty[idx]; - final CaptureTile olderTile = older.dirty[idx]; + final CaptureTile olderTile = older.getDirty()[idx]; if (olderTile != null && thisTile == null) { dirty[idx] = olderTile; diff --git a/src/main/java/mpo/dayon/common/capture/CaptureTile.java b/src/main/java/mpo/dayon/common/capture/CaptureTile.java index 39ada9b2..2e29d7d0 100644 --- a/src/main/java/mpo/dayon/common/capture/CaptureTile.java +++ b/src/main/java/mpo/dayon/common/capture/CaptureTile.java @@ -119,7 +119,7 @@ public CaptureTile(int captureId, int id, XYWH xywh, CaptureTile cached) { this.singleLevel = -1; this.capture = (cached == MISSING) ? new MemByteBuffer(new byte[width * height]) // black image (!) - : cached.capture; // sharing it (!) + : cached.getCapture(); // sharing it (!) if (width * height != capture.size()) { throw new IllegalArgumentException("Ouch!"); diff --git a/src/main/java/mpo/dayon/common/gui/common/BaseFrame.java b/src/main/java/mpo/dayon/common/gui/common/BaseFrame.java index 1ff77861..dfc39790 100644 --- a/src/main/java/mpo/dayon/common/gui/common/BaseFrame.java +++ b/src/main/java/mpo/dayon/common/gui/common/BaseFrame.java @@ -41,7 +41,7 @@ public abstract class BaseFrame extends JFrame { protected static final Object[] OK_CANCEL_OPTIONS = {translate("cancel"), translate("ok")}; - protected StatusBar statusBar; + private StatusBar statusBar; protected BaseFrame() { setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); @@ -93,7 +93,7 @@ protected void setupToolBar(ToolBar toolBar) { } protected void setupStatusBar(StatusBar statusBar) { - this.statusBar = statusBar; + this.setStatusBar(statusBar); add(statusBar, BorderLayout.SOUTH); } @@ -135,48 +135,23 @@ public void actionPerformed(ActionEvent ev) { final JLabel info = new JLabel(composeLabelHtml("Dayon!", translate("synopsys"))); info.setAlignmentX(Component.LEFT_ALIGNMENT); - info.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - browse(HTTP_HOME); - } - }); + info.addMouseListener(new HomeMouseAdapter()); final JLabel version = new JLabel(composeLabelHtmlWithBuildNumber(translate("version.installed"), Version.get().toString(), getBuildNumber())); version.setAlignmentX(Component.LEFT_ALIGNMENT); - version.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - browse(Version.RELEASE_LOCATION + Version.get()); - } - }); + version.addMouseListener(new ReleaseMouseAdapter()); final JLabel latest = new JLabel(composeLabelHtml(translate("version.latest"), Version.get().getLatestRelease())); version.setAlignmentX(Component.LEFT_ALIGNMENT); - latest.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - browse(Version.RELEASE_LOCATION + Version.get().getLatestRelease()); - } - }); + latest.addMouseListener(new LatestReleaseMouseAdapter()); final JLabel support = new JLabel(composeLabelHtml(translate("support"), HTTP_SUPPORT)); support.setAlignmentX(Component.LEFT_ALIGNMENT); - support.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - browse(HTTP_SUPPORT); - } - }); + support.addMouseListener(new SupportMouseAdapter()); final JLabel feedback = new JLabel(composeLabelHtml(translate("feedback"), HTTP_FEEDBACK)); feedback.setAlignmentX(Component.LEFT_ALIGNMENT); - feedback.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - browse(HTTP_FEEDBACK); - } - }); + feedback.addMouseListener(new FeedbackMouseAdapter()); final JScrollPane spane = new JScrollPane(props); spane.setAlignmentX(Component.LEFT_ALIGNMENT); @@ -294,4 +269,47 @@ private static void browse(URI uri) { public ToolBar getToolBar() { return toolBar; } + + public StatusBar getStatusBar() { + return statusBar; + } + + public void setStatusBar(StatusBar statusBar) { + this.statusBar = statusBar; + } + + private static class FeedbackMouseAdapter extends MouseAdapter { + @Override + public void mouseClicked(MouseEvent e) { + browse(HTTP_FEEDBACK); + } + } + + private static class HomeMouseAdapter extends MouseAdapter { + @Override + public void mouseClicked(MouseEvent e) { + browse(HTTP_HOME); + } + } + + private static class ReleaseMouseAdapter extends MouseAdapter { + @Override + public void mouseClicked(MouseEvent e) { + browse(Version.RELEASE_LOCATION + Version.get()); + } + } + + private static class LatestReleaseMouseAdapter extends MouseAdapter { + @Override + public void mouseClicked(MouseEvent e) { + browse(Version.RELEASE_LOCATION + Version.get().getLatestRelease()); + } + } + + private static class SupportMouseAdapter extends MouseAdapter { + @Override + public void mouseClicked(MouseEvent e) { + browse(HTTP_SUPPORT); + } + } } diff --git a/src/main/java/mpo/dayon/common/network/message/FileMetaData.java b/src/main/java/mpo/dayon/common/network/message/FileMetaData.java index 7573c26f..fa9d4080 100644 --- a/src/main/java/mpo/dayon/common/network/message/FileMetaData.java +++ b/src/main/java/mpo/dayon/common/network/message/FileMetaData.java @@ -7,16 +7,16 @@ public class FileMetaData implements Serializable { private final String fileName; private final long fileSize; - public FileMetaData(String fileName, long fileSize, String basePath) { + FileMetaData(String fileName, long fileSize, String basePath) { this.fileName = fileName.replace(basePath, ""); this.fileSize = fileSize; } - public String getFileName() { + String getFileName() { return fileName; } - public long getFileSize() { + long getFileSize() { return fileSize; } @@ -27,8 +27,8 @@ public boolean equals(Object o) { FileMetaData that = (FileMetaData) o; - if (fileSize != that.fileSize) return false; - return Objects.equals(fileName, that.fileName); + if (fileSize != that.getFileSize()) return false; + return Objects.equals(fileName, that.getFileName()); } @Override diff --git a/src/main/java/mpo/dayon/common/preference/Preferences.java b/src/main/java/mpo/dayon/common/preference/Preferences.java index b70c4439..47be76ef 100644 --- a/src/main/java/mpo/dayon/common/preference/Preferences.java +++ b/src/main/java/mpo/dayon/common/preference/Preferences.java @@ -37,7 +37,7 @@ private Preferences(File file) throws IOException { if (file.exists()) { try (FileReader in = new FileReader(file)) { - props.load(in); + getProps().load(in); } catch (FileNotFoundException e) { Log.error("Preferences (read) permission denied"); } @@ -82,23 +82,43 @@ public static synchronized Preferences getPreferences() { } public String getStringPreference(String name, String defaultValue) { - return SystemUtilities.getStringProperty(props, name, defaultValue); + return SystemUtilities.getStringProperty(getProps(), name, defaultValue); } public int getIntPreference(String name, int defaultValue) { - return SystemUtilities.getIntProperty(props, name, defaultValue); + return SystemUtilities.getIntProperty(getProps(), name, defaultValue); } public > T getEnumPreference(String name, T defaultValue, T[] enums) { - return SystemUtilities.getEnumProperty(props, name, defaultValue, enums); + return SystemUtilities.getEnumProperty(getProps(), name, defaultValue, enums); } public double getDoublePreference(String name, double defaultValue) { - return SystemUtilities.getDoubleProperty(props, name, defaultValue); + return SystemUtilities.getDoubleProperty(getProps(), name, defaultValue); } public boolean getBooleanPreference(String name, boolean defaultValue) { - return SystemUtilities.getBooleanProperty(props, name, defaultValue); + return SystemUtilities.getBooleanProperty(getProps(), name, defaultValue); + } + + private AtomicBoolean getWriteError() { + return writeError; + } + + private Object getCloneLOCK() { + return cloneLOCK; + } + + private AtomicBoolean getDirty() { + return dirty; + } + + private Properties getProps() { + return props; + } + + private File getFile() { + return file; } public static class Props { @@ -107,11 +127,15 @@ public static class Props { private final Map entries = new HashMap<>(); public void set(String name, String value) { - entries.put(name, value); + getEntries().put(name, value); } public void clear(String name) { - entries.put(name, REMOVE); + getEntries().put(name, REMOVE); + } + + public Map getEntries() { + return entries; } } @@ -119,15 +143,15 @@ public void clear(String name) { * Called from multiple threads (!) */ public void update(Props props) { - synchronized (cloneLOCK) { - props.entries.forEach((pname, pvalue) -> { + synchronized (getCloneLOCK()) { + props.getEntries().forEach((pname, pvalue) -> { if (Props.REMOVE.equals(pvalue)) { - this.props.remove(pname); + this.getProps().remove(pname); } else { - this.props.setProperty(pname, pvalue); + this.getProps().setProperty(pname, pvalue); } }); - dirty.set(true); + getDirty().set(true); } } @@ -141,31 +165,31 @@ private static void setupPersister(final Preferences preferences) { new Timer("PreferencesWriter").schedule(new TimerTask() { @Override public void run() { - if (preferences.isNull() || preferences.writeError.get()) { + if (preferences.isNull() || preferences.getWriteError().get()) { return; } try { Properties cloned = null; - synchronized (preferences.cloneLOCK) { - if (preferences.dirty.get()) { - cloned = (Properties) preferences.props.clone(); - preferences.dirty.set(false); + synchronized (preferences.getCloneLOCK()) { + if (preferences.getDirty().get()) { + cloned = (Properties) preferences.getProps().clone(); + preferences.getDirty().set(false); } } if (cloned != null) { - Log.debug("Writing the preferences [" + preferences.file.getAbsolutePath() + "]"); - try (PrintWriter out = new PrintWriter(preferences.file)) { + Log.debug("Writing the preferences [" + preferences.getFile().getAbsolutePath() + "]"); + try (PrintWriter out = new PrintWriter(preferences.getFile())) { cloned.store(out, null); out.flush(); } } } catch (FileNotFoundException e) { Log.error("Preferences (write) permission denied"); - preferences.writeError.set(true); + preferences.getWriteError().set(true); } catch (IOException ex) { Log.error("Preferences write error!", ex); - preferences.writeError.set(true); + preferences.getWriteError().set(true); } } }, 0, 2000); diff --git a/src/main/java/mpo/dayon/common/utils/UnitUtilities.java b/src/main/java/mpo/dayon/common/utils/UnitUtilities.java index ed761b63..8cdf9963 100644 --- a/src/main/java/mpo/dayon/common/utils/UnitUtilities.java +++ b/src/main/java/mpo/dayon/common/utils/UnitUtilities.java @@ -22,6 +22,14 @@ public enum BitUnit { this.name = name; this.value = value; } + + public double getValue() { + return value; + } + + public String getSymbol() { + return symbol; + } } public static String toBitSize(double bits) { @@ -30,8 +38,8 @@ public static String toBitSize(double bits) { for (int idx = units.length - 1; idx >= 0; idx--) { final BitUnit unit = units[idx]; - if (bits >= unit.value) { - return String.format(DEC_UNIT, bits / unit.value, unit.symbol); + if (bits >= unit.getValue()) { + return String.format(DEC_UNIT, bits / unit.getValue(), unit.getSymbol()); } } return String.format(DEC_UNIT, bits, "bit"); @@ -58,6 +66,18 @@ public enum ByteUnit { this.value = value; this.formatter = formatter; } + + public double getValue() { + return value; + } + + public String getSymbol() { + return symbol; + } + + public String getFormatter() { + return formatter; + } } public static String toByteSize(double bytes) { @@ -70,11 +90,11 @@ static String toByteSize(double bytes, boolean withDecimal) { for (int idx = units.length - 1; idx >= 0; idx--) { final ByteUnit unit = units[idx]; - if (bytes >= unit.value) { + if (bytes >= unit.getValue()) { if (withDecimal) { - return String.format(DEC_UNIT, bytes / unit.value, unit.symbol); + return String.format(DEC_UNIT, bytes / unit.getValue(), unit.getSymbol()); } - return String.format(unit.formatter, bytes / unit.value); + return String.format(unit.getFormatter(), bytes / unit.getValue()); } } From 0215ba30306107c89ea891c5efc1d77c3516b0d8 Mon Sep 17 00:00:00 2001 From: retgal Date: Fri, 29 Apr 2022 15:03:56 +0200 Subject: [PATCH 10/14] Removed superfluous spacer --- src/main/java/mpo/dayon/assisted/gui/AssistedFrame.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/mpo/dayon/assisted/gui/AssistedFrame.java b/src/main/java/mpo/dayon/assisted/gui/AssistedFrame.java index 535f4151..9235a9e1 100755 --- a/src/main/java/mpo/dayon/assisted/gui/AssistedFrame.java +++ b/src/main/java/mpo/dayon/assisted/gui/AssistedFrame.java @@ -38,7 +38,9 @@ private ToolBar createToolBar() { final ToolBar toolbar = new ToolBar(); toolbar.addAction(startAction); toolbar.addAction(stopAction); - toolbar.addSeparator(); + if (ScreenUtilities.getNumberOfScreens() > 1 || File.separatorChar == '\\') { + toolbar.addSeparator(); + } if (ScreenUtilities.getNumberOfScreens() > 1) { toolbar.addToggleAction(toggleMultiScreenCaptureAction); } From 34ce62a2623f3b0bb0af9031213f831288536e63 Mon Sep 17 00:00:00 2001 From: retgal Date: Sat, 30 Apr 2022 15:58:26 +0200 Subject: [PATCH 11/14] Added sample yaml --- docs/assisted.yaml | 4 ++++ docs/de_quickstart.html | 4 ++-- docs/fr_quickstart.html | 4 ++-- docs/quickstart.html | 4 ++-- docs/zh_quickstart.html | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 docs/assisted.yaml diff --git a/docs/assisted.yaml b/docs/assisted.yaml new file mode 100644 index 00000000..91042390 --- /dev/null +++ b/docs/assisted.yaml @@ -0,0 +1,4 @@ +host: localhost +port: 8080 +# uncomment the next line to prevent auto connection at startup +# autoConnect: false \ No newline at end of file diff --git a/docs/de_quickstart.html b/docs/de_quickstart.html index 9b353cdf..fd2af0c6 100644 --- a/docs/de_quickstart.html +++ b/docs/de_quickstart.html @@ -209,11 +209,11 @@

    Via Konfigurationsdatei

    Die Struktur ist äusserst simpel:
     host: an.example.com
     port: 8080
    - Diese Datei kann unter dem Namen assisted.yaml entweder im Dayon! Heimverzeichnis, im Benutzerverzeichnis, + Diese Datei kann unter dem Namen assisted.yaml entweder im Dayon! Heimverzeichnis, im Benutzerverzeichnis, oder im selben Verzeichnis wie die .jar, resp. .exe Datei abgelegt werden. Diese Reihenfolge entspricht auch der Priorität, mit welcher sie berücksichtigt werden, falls mehrere Konfigurationen existieren. (die erste gewinnt)
    - Um zu verhindern, dass sich der Assistierte direkt nach dem Start automatisch verbindet, kann assisted.yaml um die + Um zu verhindern, dass sich der Assistierte direkt nach dem Start automatisch verbindet, kann assisted.yaml um die folgende Zeile ergänzt werden:
     autoConnect: false

    diff --git a/docs/fr_quickstart.html b/docs/fr_quickstart.html index b69b60f9..2b28c291 100644 --- a/docs/fr_quickstart.html +++ b/docs/fr_quickstart.html @@ -208,11 +208,11 @@

    Via le fichier de configuration

    La structure est extrêmement simple :
     host: an.example.com
     port: 8080
    - Ce fichier peut être enregistré sous le nom assisted.yaml soit dans le Dayon! répertoire personnel, dans le répertoire utilisateur, + Ce fichier peut être enregistré sous le nom assisted.yaml soit dans le Dayon! répertoire personnel, dans le répertoire utilisateur, ou dans le même répertoire que le .jar, resp. Fichier .exe. Cet ordre correspond également à la priorité avec laquelle ils sont pris en compte dans le cas de configurations multiples existent. (la première gagne)
    - Pour éviter que l'assisté ne se connecte automatiquement juste après le démarrage, assisted.yaml la + Pour éviter que l'assisté ne se connecte automatiquement juste après le démarrage, assisted.yaml la ligne suivante peut être ajoutée :
     autoConnect: false

    diff --git a/docs/quickstart.html b/docs/quickstart.html index 5f455699..6c652c95 100644 --- a/docs/quickstart.html +++ b/docs/quickstart.html @@ -201,11 +201,11 @@

    Via configuration file

    The structure is extremely simple:
     host: an.example.com
     port: 8080
    - This file can be saved under the name assisted.yaml either in the Dayon! home directory, in the user directory, + This file can be saved under the name assisted.yaml either in the Dayon! home directory, in the user directory, or in the same directory as the .jar, resp. .exe file. This order also corresponds to the priority with which they are taken into account in the case of multiple configurations exist. (first wins)
    - To prevent the assisted from automatically connecting right after the start, assisted.yaml + To prevent the assisted from automatically connecting right after the start, assisted.yaml the following line can be added:
     autoConnect: false

    diff --git a/docs/zh_quickstart.html b/docs/zh_quickstart.html index 4dd4a6af..8c6cfa0f 100644 --- a/docs/zh_quickstart.html +++ b/docs/zh_quickstart.html @@ -196,11 +196,11 @@

    通过配置文件

    结构极其简单:
     host: an.example.com
     port: 8080
    - 该文件可以在 Dayon 中以 assisted.yaml 的名称保存! 主目录,在用户目录中, + 该文件可以在 Dayon 中以 assisted.yaml 的名称保存! 主目录,在用户目录中, 或在与 .jar 相同的目录中,分别。 .exe 文件。 此顺序还对应于在多个配置的情况下考虑它们的优先级 存在。 (第一次获胜)
    - 为防止辅助启动后立即自动连接,assisted.yaml + 为防止辅助启动后立即自动连接,assisted.yaml 可以添加以下行:
     autoConnect: false

    From a26434529c3f69522b9450e1d38dbcd202d4ea38 Mon Sep 17 00:00:00 2001 From: retgal Date: Sat, 30 Apr 2022 16:09:07 +0200 Subject: [PATCH 12/14] Some file access optimizations --- .../network/message/NetworkClipboardFilesMessage.java | 3 ++- src/main/java/mpo/dayon/common/utils/FileUtilities.java | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/mpo/dayon/common/network/message/NetworkClipboardFilesMessage.java b/src/main/java/mpo/dayon/common/network/message/NetworkClipboardFilesMessage.java index 1ce270f9..76021061 100644 --- a/src/main/java/mpo/dayon/common/network/message/NetworkClipboardFilesMessage.java +++ b/src/main/java/mpo/dayon/common/network/message/NetworkClipboardFilesMessage.java @@ -4,6 +4,7 @@ import mpo.dayon.common.utils.FileUtilities; import java.io.*; +import java.nio.file.Files; import java.util.*; import static java.util.Arrays.copyOf; @@ -147,7 +148,7 @@ private void sendFile(File file, ObjectOutputStream out) throws IOException { long fileSize = file.length(); Log.debug("Total bytes to be sent: " + fileSize); byte[] buffer = fileSize < MAX_BUFFER_CAPACITY ? new byte[Math.toIntExact(fileSize)] : new byte[MAX_BUFFER_CAPACITY]; - try (InputStream input = new FileInputStream(file)) { + try (InputStream input = Files.newInputStream(file.toPath())) { int read; while (input.available() > 0) { read = readIntoBuffer(input, buffer); diff --git a/src/main/java/mpo/dayon/common/utils/FileUtilities.java b/src/main/java/mpo/dayon/common/utils/FileUtilities.java index 64967cdd..94ff489e 100644 --- a/src/main/java/mpo/dayon/common/utils/FileUtilities.java +++ b/src/main/java/mpo/dayon/common/utils/FileUtilities.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; import java.util.List; import java.util.stream.Stream; @@ -22,8 +23,9 @@ public static long calculateTotalFileSize(List files) throws IOException { } private static long calculateFileSize(File node) throws IOException { - if (node.isFile()) { - return node.length(); + BasicFileAttributes basicFileAttributes = Files.readAttributes(node.toPath(), BasicFileAttributes.class); + if (basicFileAttributes.isRegularFile()) { + return basicFileAttributes.size(); } try (Stream stream = Files.walk(node.toPath())) { return stream.filter(p -> p.toFile().isFile()) From f38052252bffaf122d5c96517801657bf0aed11a Mon Sep 17 00:00:00 2001 From: retgal Date: Sat, 30 Apr 2022 16:36:27 +0200 Subject: [PATCH 13/14] Converted anonymous to static private classes --- .../dayon/assistant/gui/AssistantFrame.java | 23 ++++--- .../gui/ConnectionSettingsDialog.java | 22 ++++--- .../dayon/common/gui/statusbar/StatusBar.java | 62 +++++++++---------- .../dayon/common/monitoring/BigBrother.java | 20 ++++-- 4 files changed, 70 insertions(+), 57 deletions(-) diff --git a/src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java b/src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java index 6706af93..63d601cc 100644 --- a/src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java +++ b/src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java @@ -271,16 +271,7 @@ void onHttpStarting(int port) { actions.getStopAction().setEnabled(true); actions.getNetworkConfigurationAction().setEnabled(false); actions.getIpAddressAction().setEnabled(false); - center = new JPanel() { - final ImageIcon waiting = getOrCreateIcon(ImageNames.WAITING); - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - final int x = (getWidth() - waiting.getIconWidth()) / 2; - final int y = (getHeight() - waiting.getIconHeight()) / 2; - g.drawImage(waiting.getImage(), x, y, this); - } - }; + center = new Spinner(); add(center, BorderLayout.CENTER); getStatusBar().setMessage(translate("listening", port)); } @@ -467,4 +458,16 @@ private void fireOnKeyReleased(int keyCode, char keyChar) { xListener.onKeyReleased(keyCode, keyChar); } } + + private static class Spinner extends JPanel { + final ImageIcon waiting = getOrCreateIcon(ImageNames.WAITING); + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + final int x = (getWidth() - waiting.getIconWidth()) / 2; + final int y = (getHeight() - waiting.getIconHeight()) / 2; + g.drawImage(waiting.getImage(), x, y, this); + } + } } diff --git a/src/main/java/mpo/dayon/assisted/gui/ConnectionSettingsDialog.java b/src/main/java/mpo/dayon/assisted/gui/ConnectionSettingsDialog.java index f4c628aa..03ca65fb 100644 --- a/src/main/java/mpo/dayon/assisted/gui/ConnectionSettingsDialog.java +++ b/src/main/java/mpo/dayon/assisted/gui/ConnectionSettingsDialog.java @@ -73,13 +73,21 @@ public JTabbedPane getTabbedPane() { } private MouseAdapter clearTextOnDoubleClick(JTextField textField) { - return new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { - textField.setText(null); - } + return new Cleanser(textField); + } + + private static class Cleanser extends MouseAdapter { + private final JTextField textField; + + public Cleanser(JTextField textField) { + this.textField = textField; + } + + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + textField.setText(null); } - }; + } } } diff --git a/src/main/java/mpo/dayon/common/gui/statusbar/StatusBar.java b/src/main/java/mpo/dayon/common/gui/statusbar/StatusBar.java index 3a4fefa4..906bd38f 100644 --- a/src/main/java/mpo/dayon/common/gui/statusbar/StatusBar.java +++ b/src/main/java/mpo/dayon/common/gui/statusbar/StatusBar.java @@ -21,22 +21,7 @@ public class StatusBar extends JPanel { public StatusBar() { setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); - setBorder(new EtchedBorder() { - - @Override - public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { - g.translate(x, y); - - g.setColor(etchType == LOWERED ? getShadowColor(c) : getHighlightColor(c)); - g.drawLine(0, 0, width, 0); - - g.setColor(etchType == LOWERED ? getHighlightColor(c) : getShadowColor(c)); - g.drawLine(1, 1, width, 1); - - g.translate(-x, -y); - } - }); - + setBorder(new EtchedBorderPainter()); add(Box.createHorizontalStrut(5)); add(message); add(Box.createHorizontalGlue()); @@ -56,52 +41,61 @@ public void setSessionDuration(String sessionDuration) { public void addCounter(Counter counter, int width) { final JLabel lbl = new JLabel(counter.getUid()); - lbl.setHorizontalAlignment(SwingConstants.CENTER); - lbl.setSize(new Dimension(width, 5)); lbl.setPreferredSize(new Dimension(width, 5)); - lbl.setToolTipText(counter.getShortDescription()); - counter.addListener((CounterListener) (counter1, value) -> lbl.setText(counter1.formatInstantValue(value))); - add(lbl); } public void addRamInfo() { final JLabel lbl = new JLabel(); - lbl.setHorizontalAlignment(SwingConstants.CENTER); - lbl.setSize(new Dimension(110, 5)); lbl.setPreferredSize(new Dimension(110, 5)); - - BigBrother.get().registerRamInfo(new TimerTask() { - @Override - public void run() { - lbl.setText(SystemUtilities.getRamInfo()); - } - }); + BigBrother.get().registerRamInfo(new MemoryCounter(lbl)); lbl.setToolTipText(translate("memory.info" )); - add(lbl); } public void addConnectionDuration() { sessionDuration.setHorizontalAlignment(SwingConstants.CENTER); - sessionDuration.setSize(new java.awt.Dimension(100, 5)); sessionDuration.setPreferredSize(new java.awt.Dimension(100, 5)); sessionDuration.setToolTipText(translate("session.duration" )); - add(sessionDuration); } public void addSeparator() { final JToolBar.Separator separator = new JToolBar.Separator(); separator.setOrientation(SwingConstants.VERTICAL); - add(separator); } + + private static class MemoryCounter extends TimerTask { + private final JLabel lbl; + + public MemoryCounter(JLabel lbl) { + this.lbl = lbl; + } + + @Override + public void run() { + lbl.setText(SystemUtilities.getRamInfo()); + } + } + + private static class EtchedBorderPainter extends EtchedBorder { + + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + g.translate(x, y); + g.setColor(etchType == LOWERED ? getShadowColor(c) : getHighlightColor(c)); + g.drawLine(0, 0, width, 0); + g.setColor(etchType == LOWERED ? getHighlightColor(c) : getShadowColor(c)); + g.drawLine(1, 1, width, 1); + g.translate(-x, -y); + } + } } \ No newline at end of file diff --git a/src/main/java/mpo/dayon/common/monitoring/BigBrother.java b/src/main/java/mpo/dayon/common/monitoring/BigBrother.java index 63aa389b..bb449f49 100644 --- a/src/main/java/mpo/dayon/common/monitoring/BigBrother.java +++ b/src/main/java/mpo/dayon/common/monitoring/BigBrother.java @@ -21,15 +21,23 @@ public static BigBrother get() { * @param instantRatePeriod millis */ public void registerCounter(final Counter counter, final long instantRatePeriod) { - timer.scheduleAtFixedRate(new TimerTask() { - @Override - public void run() { - counter.computeAndResetInstantValue(); - } - }, 0, instantRatePeriod); + timer.scheduleAtFixedRate(new SecondsCounter(counter), 0, instantRatePeriod); } public void registerRamInfo(TimerTask callback) { timer.scheduleAtFixedRate(callback, 0, 1000); } + + private static class SecondsCounter extends TimerTask { + private final Counter counter; + + public SecondsCounter(Counter counter) { + this.counter = counter; + } + + @Override + public void run() { + counter.computeAndResetInstantValue(); + } + } } From cc73437109a21d6e0168ec4b4319fc8127b400cc Mon Sep 17 00:00:00 2001 From: retgal Date: Sat, 30 Apr 2022 17:02:52 +0200 Subject: [PATCH 14/14] Version bump --- build.xml | 2 +- debian/changelog | 9 +++++++++ pom.xml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/build.xml b/build.xml index 6392d88d..72bb6313 100644 --- a/build.xml +++ b/build.xml @@ -13,7 +13,7 @@ - + diff --git a/debian/changelog b/debian/changelog index 8ccbd23d..c3592546 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +dayon (11.0.5) stable; urgency=medium + + * Let user decide if he/she/it wants to share just the primary or all screens (assisted) + * Added shortcut for showing the UAC settings dialogue (assisted) + * Connection pre configurable with a yaml file + * Fixed integer overflow exception when transferring very large files (>4GB) + + -- Reto Galante Sat, 30 Apr 2022 12:00:00 +0000 + dayon (11.0.4) stable; urgency=low * Fixed latent coordinate out of bounds exception diff --git a/pom.xml b/pom.xml index 5427772e..9172da68 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ https://github.com/retgal/dayon mpo.dayon dayon - 11.0.4 + 11.0.5 cross platform remote desktop solution