From ae648fd7f6e16a0c591637c270ca6322f7117a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 14 Nov 2021 18:54:48 +0100 Subject: [PATCH] Rename option/field "server" to "hostname" --- README.md | 2 +- qweechat/connection.py | 10 +++++----- qweechat/network.py | 12 ++++++------ qweechat/qweechat.py | 16 ++++++++-------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 9942a91..5b11630 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ You have to add a relay port in WeeChat, for example on port 1234: In QWeeChat, click on connect and enter fields: -- `server`: the IP address or hostname of your machine with WeeChat running +- `hostname`: the IP address or hostname of your machine with WeeChat running - `port`: the relay port (defined in WeeChat) - `password`: the relay password (defined in WeeChat) - `totp`: the Time-Based One-Time Password (optional, to set if required by WeeChat) diff --git a/qweechat/connection.py b/qweechat/connection.py index aad350a..798e702 100644 --- a/qweechat/connection.py +++ b/qweechat/connection.py @@ -40,16 +40,16 @@ class ConnectionDialog(QtWidgets.QDialog): self.fields = {} focus = None - # server - grid.addWidget(QtWidgets.QLabel('Server'), 0, 0) + # hostname + grid.addWidget(QtWidgets.QLabel('Hostname'), 0, 0) line_edit = QtWidgets.QLineEdit() line_edit.setFixedWidth(200) - value = self.values.get('server', '') + value = self.values.get('hostname', '') line_edit.insert(value) grid.addWidget(line_edit, 0, 1) - self.fields['server'] = line_edit + self.fields['hostname'] = line_edit if not focus and not value: - focus = 'server' + focus = 'hostname' # port / SSL grid.addWidget(QtWidgets.QLabel('Port'), 1, 0) diff --git a/qweechat/network.py b/qweechat/network.py index d663dd8..e865702 100644 --- a/qweechat/network.py +++ b/qweechat/network.py @@ -115,7 +115,7 @@ class Network(QtCore.QObject): def _init_connection(self): self.status = STATUS_DISCONNECTED - self._server = None + self._hostname = None self._port = None self._ssl = None self._password = None @@ -236,9 +236,9 @@ class Network(QtCore.QObject): """Return True if SSL is used, False otherwise.""" return self._ssl - def connect_weechat(self, server, port, ssl, password, totp, lines): + def connect_weechat(self, hostname, port, ssl, password, totp, lines): """Connect to WeeChat.""" - self._server = server + self._hostname = hostname try: self._port = int(port) except ValueError: @@ -256,9 +256,9 @@ class Network(QtCore.QObject): self._socket.abort() if self._ssl: self._socket.ignoreSslErrors() - self._socket.connectToHostEncrypted(self._server, self._port) + self._socket.connectToHostEncrypted(self._hostname, self._port) else: - self._socket.connectToHost(self._server, self._port) + self._socket.connectToHost(self._hostname, self._port) self.set_status(STATUS_CONNECTING) def disconnect_weechat(self): @@ -316,7 +316,7 @@ class Network(QtCore.QObject): def get_options(self): """Get connection options.""" return { - 'server': self._server, + 'hostname': self._hostname, 'port': self._port, 'ssl': 'on' if self._ssl else 'off', 'password': self._password, diff --git a/qweechat/qweechat.py b/qweechat/qweechat.py index 66a8d6a..090b76e 100644 --- a/qweechat/qweechat.py +++ b/qweechat/qweechat.py @@ -188,12 +188,12 @@ class MainWindow(QtWidgets.QMainWindow): # auto-connect to relay if self.config.getboolean('relay', 'autoconnect'): self.network.connect_weechat( - server=self.config.get('relay', 'server'), - port=self.config.get('relay', 'port'), - ssl=self.config.getboolean('relay', 'ssl'), - password=self.config.get('relay', 'password'), + hostname=self.config.get('relay', 'hostname', fallback=''), + port=self.config.get('relay', 'port', fallback=''), + ssl=self.config.getboolean('relay', 'ssl', fallback=''), + password=self.config.get('relay', 'password', fallback=''), totp=None, - lines=self.config.get('relay', 'lines'), + lines=self.config.get('relay', 'lines', fallback=''), ) self.show() @@ -230,8 +230,8 @@ class MainWindow(QtWidgets.QMainWindow): def open_connection_dialog(self): """Open a dialog with connection settings.""" values = {} - for option in ('server', 'port', 'ssl', 'password', 'lines'): - values[option] = self.config.get('relay', option) + for option in ('hostname', 'port', 'ssl', 'password', 'lines'): + values[option] = self.config.get('relay', option, fallback='') self.connection_dialog = ConnectionDialog(values, self) self.connection_dialog.dialog_buttons.accepted.connect( self.connect_weechat) @@ -239,7 +239,7 @@ class MainWindow(QtWidgets.QMainWindow): def connect_weechat(self): """Connect to WeeChat.""" self.network.connect_weechat( - server=self.connection_dialog.fields['server'].text(), + hostname=self.connection_dialog.fields['hostname'].text(), port=self.connection_dialog.fields['port'].text(), ssl=self.connection_dialog.fields['ssl'].isChecked(), password=self.connection_dialog.fields['password'].text(),