From 014483b5467069447e078092f5d38cb586cf8b57 Mon Sep 17 00:00:00 2001 From: Alberto Sottile Date: Tue, 5 Feb 2019 16:48:23 +0100 Subject: [PATCH] startTLS: handle ui messages --- syncplay/messages_de.py | 7 +++++++ syncplay/messages_en.py | 7 ++++++- syncplay/messages_it.py | 6 ++++++ syncplay/messages_ru.py | 7 +++++++ syncplay/protocols.py | 8 ++++---- syncplay/server.py | 2 +- 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/syncplay/messages_de.py b/syncplay/messages_de.py index fc09489..e67cbf8 100755 --- a/syncplay/messages_de.py +++ b/syncplay/messages_de.py @@ -310,6 +310,12 @@ de = { "userguide-menu-label": "&Benutzerhandbuch öffnen", "update-menu-label": "auf &Aktualisierung prüfen", + # startTLS messages - TODO: Translate + "startTLS-initiated": "Attempting secure connection", + "startTLS-secure-connection-ok": "Secure connection established", + "startTLS-not-supported-client": "TLS is not supported", + "startTLS-not-supported-server": "This server does not support TLS", + # About dialog - TODO: Translate "about-menu-label": "&About Syncplay", "about-dialog-title": "About Syncplay", @@ -438,6 +444,7 @@ de = { "server-chat-maxchars-argument": "Maximum number of characters in a chat message (default is {})", # TODO: Translate "server-maxusernamelength-argument": "Maximum number of characters in a username (default is {})", # TODO: Translate "server-stats-db-file-argument": "Enable server stats using the SQLite db file provided", # TODO: Translate + "server-startTLS-argument": "Enable TLS connections using the certificate files in the path provided", # TODO: Translate "server-messed-up-motd-unescaped-placeholders": "Die Nachricht des Tages hat unmaskierte Platzhalter. Alle $-Zeichen sollten verdoppelt werden ($$).", "server-messed-up-motd-too-long": "Die Nachricht des Tages ist zu lang - Maximal {} Zeichen, aktuell {}.", diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index 82c55e7..f5971cd 100755 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -312,6 +312,11 @@ en = { "userguide-menu-label": "Open user &guide", "update-menu-label": "Check for &update", + "startTLS-initiated": "Attempting secure connection", + "startTLS-secure-connection-ok": "Secure connection established", + "startTLS-not-supported-client": "TLS is not supported", + "startTLS-not-supported-server": "This server does not support TLS", + # About dialog "about-menu-label": "&About Syncplay", "about-dialog-title": "About Syncplay", @@ -439,7 +444,7 @@ en = { "server-chat-maxchars-argument": "Maximum number of characters in a chat message (default is {})", # Default number of characters "server-maxusernamelength-argument": "Maximum number of characters in a username (default is {})", "server-stats-db-file-argument": "Enable server stats using the SQLite db file provided", - "server-tls-argument": "Enable TLS connections using the certificate file provided", + "server-startTLS-argument": "Enable TLS connections using the certificate files in the path provided", "server-messed-up-motd-unescaped-placeholders": "Message of the Day has unescaped placeholders. All $ signs should be doubled ($$).", "server-messed-up-motd-too-long": "Message of the Day is too long - maximum of {} chars, {} given.", diff --git a/syncplay/messages_it.py b/syncplay/messages_it.py index a3d4c8c..33fcab9 100755 --- a/syncplay/messages_it.py +++ b/syncplay/messages_it.py @@ -312,6 +312,11 @@ it = { "userguide-menu-label": "Apri guida &utente", "update-menu-label": "Controlla la presenza di &aggiornamenti", + "startTLS-initiated": "Tentativo di connessione sicura in corso", + "startTLS-secure-connection-ok": "Connessione sicura stabilita", + "startTLS-not-supported-client": "TLS non è supportato", + "startTLS-not-supported-server": "Questo server non supporta TLS", + # About dialog "about-menu-label": "&Informazioni su Syncplay", "about-dialog-title": "Informazioni su Syncplay", @@ -439,6 +444,7 @@ it = { "server-chat-maxchars-argument": "Numero massimo di caratteri in un messaggio di chat (default è {})", # Default number of characters "server-maxusernamelength-argument": "Numero massimo di caratteri in un nome utente (default è {})", "server-stats-db-file-argument": "Abilita la raccolta dei dati statistici nel file SQLite indicato", + "server-startTLS-argument": "Abilita il protocollo TLS usando i certificati contenuti nel percorso indicato", "server-messed-up-motd-unescaped-placeholders": "Il messaggio del giorno ha dei caratteri non 'escaped'. Tutti i simboli $ devono essere doppi ($$).", "server-messed-up-motd-too-long": "Il messaggio del giorno è troppo lungo - numero massimo di caratteri è {}, {} trovati.", diff --git a/syncplay/messages_ru.py b/syncplay/messages_ru.py index f9156d2..7d258a2 100755 --- a/syncplay/messages_ru.py +++ b/syncplay/messages_ru.py @@ -313,6 +313,12 @@ ru = { "userguide-menu-label": "&Руководство пользователя", "update-menu-label": "Проверить &обновления", + # startTLS messages - TODO: Translate + "startTLS-initiated": "Attempting secure connection", + "startTLS-secure-connection-ok": "Secure connection established", + "startTLS-not-supported-client": "TLS is not supported", + "startTLS-not-supported-server": "This server does not support TLS", + # About dialog - TODO: Translate "about-menu-label": "&About Syncplay", "about-dialog-title": "About Syncplay", @@ -439,6 +445,7 @@ ru = { "server-chat-maxchars-argument": "Maximum number of characters in a chat message (default is {})", # TODO: Translate "server-maxusernamelength-argument": "Maximum number of characters in a username (default is {})", # TODO: Translate "server-stats-db-file-argument": "Enable server stats using the SQLite db file provided", # TODO: Translate + "server-startTLS-argument": "Enable TLS connections using the certificate files in the path provided", # TODO: Translate "server-messed-up-motd-unescaped-placeholders" : "MOTD-сообщение содержит неэкранированные спец.символы. Все знаки $ должны быть продублированы ($$).", "server-messed-up-motd-too-long" : "MOTD-сообщение слишком длинное: максимальная длина - {} символ(ов), текущая длина - {} символ(ов).", diff --git a/syncplay/protocols.py b/syncplay/protocols.py index 340bb92..cc7ad9d 100755 --- a/syncplay/protocols.py +++ b/syncplay/protocols.py @@ -76,9 +76,9 @@ class SyncClientProtocol(JSONCommandProtocol): self._client.initProtocol(self) if self._client._serverSupportsTLS: self.sendTLS({"startTLS": "send"}) - self._client.ui.showMessage("Attempting secure connection") + self._client.ui.showMessage(getMessage("startTLS-initiated")) else: - self._client.ui.showErrorMessage("TLS is not supported") + self._client.ui.showErrorMessage(getMessage("startTLS-not-supported-client")) self.sendHello() def connectionLost(self, reason): @@ -325,9 +325,9 @@ class SyncClientProtocol(JSONCommandProtocol): answer = message["startTLS"] if "startTLS" in message else None if "true" in answer and not self.logged and self._client.protocolFactory.options is not None: self.transport.startTLS(self._client.protocolFactory.options) - self._client.ui.showMessage("Secure connection established") + self._client.ui.showMessage(getMessage("startTLS-secure-connection-ok")) elif "false" in answer: - self._client.ui.showErrorMessage("This server does not support TLS") + self._client.ui.showErrorMessage(getMessage("startTLS-not-supported-server")) self.sendHello() class SyncServerProtocol(JSONCommandProtocol): diff --git a/syncplay/server.py b/syncplay/server.py index a76c0a5..4a0c142 100755 --- a/syncplay/server.py +++ b/syncplay/server.py @@ -649,4 +649,4 @@ class ConfigurationGetter(object): self._argparser.add_argument('--max-chat-message-length', metavar='maxChatMessageLength', type=int, nargs='?', help=getMessage("server-chat-maxchars-argument").format(constants.MAX_CHAT_MESSAGE_LENGTH)) self._argparser.add_argument('--max-username-length', metavar='maxUsernameLength', type=int, nargs='?', help=getMessage("server-maxusernamelength-argument").format(constants.MAX_USERNAME_LENGTH)) self._argparser.add_argument('--stats-db-file', metavar='file', type=str, nargs='?', help=getMessage("server-stats-db-file-argument")) - self._argparser.add_argument('--tls', metavar='path', type=str, nargs='?', help=getMessage("server-tls-argument")) + self._argparser.add_argument('--tls', metavar='path', type=str, nargs='?', help=getMessage("server-startTLS-argument"))