diff --git a/app/connections.py b/app/connections.py index 3f19ccba..c5eada58 100644 --- a/app/connections.py +++ b/app/connections.py @@ -370,7 +370,7 @@ def upload_data(*, settings, download_type=DownloadType.ALL, remove_unused=False try: if s_type is SettingsType.ENIGMA_2 and use_http: - ht = http(settings.http_user, settings.http_password, base_url, callback, settings.http_use_ssl) + ht = http(settings.user, settings.password, base_url, callback, settings.http_use_ssl) next(ht) message = "" if download_type is DownloadType.BOUQUETS: @@ -393,8 +393,8 @@ def upload_data(*, settings, download_type=DownloadType.ALL, remove_unused=False if download_type is not DownloadType.PICONS: # telnet tn = telnet(host=host, - user=settings.telnet_user, - password=settings.telnet_password, + user=settings.user, + password=settings.password, timeout=settings.telnet_timeout) next(tn) # terminate enigma or neutrino @@ -599,7 +599,7 @@ class HttpAPI: @run_task def init(self): - user, password = self._settings.http_user, self._settings.http_password + user, password = self._settings.user, self._settings.password use_ssl = self._settings.http_use_ssl self._main_url = "http{}://{}:{}".format("s" if use_ssl else "", self._settings.host, self._settings.http_port) self._base_url = "{}/web/".format(self._main_url) diff --git a/app/settings.py b/app/settings.py index a0e51329..3b8ee627 100644 --- a/app/settings.py +++ b/app/settings.py @@ -99,10 +99,10 @@ class SettingsType(IntEnum): """ Returns default settings for current type """ if self is self.ENIGMA_2: return {"setting_type": self.value, - "host": "127.0.0.1", "port": "21", "user": "root", "password": "root", "timeout": 5, - "http_user": "root", "http_password": "", "http_port": "80", - "http_timeout": 5, "http_use_ssl": False, - "telnet_user": "root", "telnet_password": "", "telnet_port": "23", "telnet_timeout": 5, + "host": "127.0.0.1", "port": "21", "timeout": 5, + "user": "root", "password": "root", + "http_port": "80", "http_timeout": 5, "http_use_ssl": False, + "telnet_port": "23", "telnet_timeout": 5, "services_path": "/etc/enigma2/", "user_bouquet_path": "/etc/enigma2/", "satellites_xml_path": "/etc/tuxbox/", "data_local_path": DATA_PATH + "enigma2/", "picons_path": "/usr/share/enigma2/picon/", @@ -110,9 +110,10 @@ class SettingsType(IntEnum): "backup_local_path": DATA_PATH + "enigma2/backup/"} elif self is self.NEUTRINO_MP: return {"setting_type": self, - "host": "127.0.0.1", "port": "21", "user": "root", "password": "root", "timeout": 5, - "http_user": "", "http_password": "", "http_port": "80", "http_timeout": 2, "http_use_ssl": False, - "telnet_user": "root", "telnet_password": "", "telnet_port": "23", "telnet_timeout": 1, + "host": "127.0.0.1", "port": "21", "timeout": 5, + "user": "root", "password": "root", + "http_port": "80", "http_timeout": 2, "http_use_ssl": False, + "telnet_port": "23", "telnet_timeout": 1, "services_path": "/var/tuxbox/config/zapit/", "user_bouquet_path": "/var/tuxbox/config/zapit/", "satellites_xml_path": "/var/tuxbox/config/", "data_local_path": DATA_PATH + "neutrino/", "picons_path": "/usr/share/tuxbox/neutrino/icons/logo/", @@ -279,22 +280,6 @@ class Settings: def password(self, value): self._cp_settings["password"] = value - @property - def http_user(self): - return self._cp_settings.get("http_user", self.get_default("http_user")) - - @http_user.setter - def http_user(self, value): - self._cp_settings["http_user"] = value - - @property - def http_password(self): - return self._cp_settings.get("http_password", self.get_default("http_password")) - - @http_password.setter - def http_password(self, value): - self._cp_settings["http_password"] = value - @property def http_port(self): return self._cp_settings.get("http_port", self.get_default("http_port")) @@ -319,22 +304,6 @@ class Settings: def http_use_ssl(self, value): self._cp_settings["http_use_ssl"] = value - @property - def telnet_user(self): - return self._cp_settings.get("telnet_user", self.get_default("telnet_user")) - - @telnet_user.setter - def telnet_user(self, value): - self._cp_settings["telnet_user"] = value - - @property - def telnet_password(self): - return self._cp_settings.get("telnet_password", self.get_default("telnet_password")) - - @telnet_password.setter - def telnet_password(self, value): - self._cp_settings["telnet_password"] = value - @property def telnet_port(self): return self._cp_settings.get("telnet_port", self.get_default("telnet_port")) diff --git a/app/ui/download_dialog.glade b/app/ui/download_dialog.glade index ac726110..ed686765 100644 --- a/app/ui/download_dialog.glade +++ b/app/ui/download_dialog.glade @@ -1,5 +1,5 @@ - - 500 + 550 False False True @@ -217,7 +217,7 @@ Author: Dmitriy Yefremov - + True False center @@ -264,6 +264,7 @@ Author: Dmitriy Yefremov False 5 5 + 5 0.019999999552965164 in @@ -423,201 +424,6 @@ Author: Dmitriy Yefremov 2 - - - True - False - 5 - 5 - 5 - 5 - 0.019999999552965164 - in - - - True - False - 5 - 5 - 5 - 2 - 2 - - - True - False - Login: - 0.10000000149011612 - - - 0 - 0 - - - - - True - True - False - root - False - avatar-default-symbolic - - - 0 - 1 - - - - - True - False - Password: - 0.10000000149011612 - - - 1 - 0 - - - - - True - True - False - False - - root - emblem-readonly - password - - - 1 - 1 - - - - - True - False - Port: - 0.10000000149011612 - - - 2 - 0 - - - - - True - True - False - 8 - 8 - 21 - False - network-workgroup-symbolic - - - 2 - 1 - - - - - True - True - False - 8 - 8 - False - alarm-symbolic - digits - - - 3 - 1 - - - - - True - False - Timeout: - - - 3 - 0 - - - - - - - True - False - - - FTP - True - True - False - True - False - telnet_radio_button - - - - False - True - 0 - - - - - HTTP - True - True - False - False - telnet_radio_button - - - - False - True - 1 - - - - - Telnet - True - True - False - False - ftp_radio_button - - - - False - True - 2 - - - - - - - - False - True - 3 - - True @@ -713,17 +519,7 @@ Author: Dmitriy Yefremov 5 - - - - - - - - - - diff --git a/app/ui/download_dialog.py b/app/ui/download_dialog.py index e9e2ffba..ac1dadc1 100644 --- a/app/ui/download_dialog.py +++ b/app/ui/download_dialog.py @@ -21,7 +21,6 @@ class DownloadDialog: handlers = {"on_receive": self.on_receive, "on_send": self.on_send, - "on_settings_button": self.on_settings_button, "on_settings": self.on_settings, "on_profile_changed": self.on_profile_changed, "on_use_http_state_set": self.on_use_http_state_set, @@ -32,7 +31,6 @@ class DownloadDialog: builder.add_from_file(UI_RESOURCES_PATH + "download_dialog.glade") builder.connect_signals(handlers) - self._current_property = "FTP" self._dialog_window = builder.get_object("download_dialog_window") self._dialog_window.set_transient_for(transient) self._info_bar = builder.get_object("info_bar") @@ -46,12 +44,6 @@ class DownloadDialog: self._bouquets_radio_button = builder.get_object("bouquets_radio_button") self._satellites_radio_button = builder.get_object("satellites_radio_button") self._webtv_radio_button = builder.get_object("webtv_radio_button") - self._login_entry = builder.get_object("login_entry") - self._password_entry = builder.get_object("password_entry") - self._host_entry = builder.get_object("host_entry") - self._port_entry = builder.get_object("port_entry") - self._timeout_entry = builder.get_object("timeout_entry") - self._settings_buttons_box = builder.get_object("settings_buttons_box") self._use_http_switch = builder.get_object("use_http_switch") self._http_radio_button = builder.get_object("http_radio_button") self._use_http_box = builder.get_object("use_http_box") @@ -71,7 +63,6 @@ class DownloadDialog: self._data_path_entry.set_text(self._settings.data_local_path) is_enigma = self._s_type is SettingsType.ENIGMA_2 self._webtv_radio_button.set_visible(not is_enigma) - self._http_radio_button.set_visible(is_enigma) self._use_http_box.set_visible(is_enigma) self._use_http_switch.set_active(is_enigma and self._settings.use_http) self._remove_unused_check_button.set_active(self._settings.remove_unused_bouquets) @@ -104,26 +95,6 @@ class DownloadDialog: def destroy(self): self._dialog_window.destroy() - def on_settings_button(self, button): - if button.get_active(): - label = button.get_label() - if label == "Telnet": - self._login_entry.set_text(self._settings.telnet_user) - self._password_entry.set_text(self._settings.telnet_password) - self._port_entry.set_text(self._settings.telnet_port) - self._timeout_entry.set_text(str(self._settings.telnet_timeout)) - elif label == "HTTP": - self._login_entry.set_text(self._settings.http_user) - self._password_entry.set_text(self._settings.http_password) - self._port_entry.set_text(self._settings.http_port) - self._timeout_entry.set_text(str(self._settings.http_timeout)) - elif label == "FTP": - self._login_entry.set_text(self._settings.user) - self._password_entry.set_text(self._settings.password) - self._port_entry.set_text(self._settings.port) - self._timeout_entry.set_text("") - self._current_property = label - def on_settings(self, item): response = show_settings_dialog(self._dialog_window, self._settings) if response != Gtk.ResponseType.CANCEL: @@ -132,11 +103,6 @@ class DownloadDialog: gen = self._update_settings_callback() GLib.idle_add(lambda: next(gen, False), priority=GLib.PRIORITY_LOW) - for button in self._settings_buttons_box.get_children(): - if button.get_active(): - self.on_settings_button(button) - break - def on_profile_changed(self, box): active = box.get_active_text() if active in self._settings.profiles: diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py index e3822e2a..bb8b975e 100644 --- a/app/ui/main_app_window.py +++ b/app/ui/main_app_window.py @@ -1279,7 +1279,7 @@ class Application(Gtk.Application): use_http = profile is SettingsType.ENIGMA_2 if profile is SettingsType.ENIGMA_2: - host, port, user, password = opts.host, opts.http_port, opts.http_user, opts.http_password + host, port, user, password = opts.host, opts.http_port, opts.user, opts.password try: test_http(host, port, user, password, use_ssl=opts.http_use_ssl, skip_message=True) except (TestException, HttpApiException): diff --git a/app/ui/settings_dialog.glade b/app/ui/settings_dialog.glade index da244fc0..b7cb3b3a 100644 --- a/app/ui/settings_dialog.glade +++ b/app/ui/settings_dialog.glade @@ -226,29 +226,6 @@ Author: Dmitriy Yefremov 5 - - - True - True - True - Reset profile - end - center - True - - - - True - False - gtk-revert-to-saved - - - - - end - 2 - - @@ -311,7 +288,6 @@ Author: Dmitriy Yefremov in - 155 True False vertical @@ -382,6 +358,7 @@ Author: Dmitriy Yefremov True False + False True @@ -430,19 +407,6 @@ Author: Dmitriy Yefremov True - - - True - False - - - - - - True - False - - True @@ -460,6 +424,21 @@ Author: Dmitriy Yefremov True + + + True + False + Reset profile + Reset + True + gtk-revert-to-saved + + + + False + True + + False @@ -467,6 +446,71 @@ Author: Dmitriy Yefremov 1 + + + True + False + 5 + 5 + 5 + 5 + 0.019999999552965164 + in + + + True + False + center + center + 5 + 5 + + + Enigma2 + True + True + False + True + neutrino_radio_button + + + + False + True + 1 + + + + + Neutrino-MP + True + True + False + True + enigma_radio_button + + + False + True + 4 + + + + + + + True + False + Settings type: + + + + + False + True + 2 + + @@ -487,70 +531,6 @@ Author: Dmitriy Yefremov True False vertical - - - True - False - 5 - 5 - 5 - 0.019999999552965164 - in - - - True - False - center - center - 5 - 5 - - - Enigma2 - True - True - False - True - neutrino_radio_button - - - - False - True - 1 - - - - - Neutrino-MP - True - True - False - True - enigma_radio_button - - - False - True - 4 - - - - - - - True - False - Settings type: - - - - - False - True - 0 - - True @@ -561,25 +541,39 @@ Author: Dmitriy Yefremov 0.019999999552965164 in - + True False 5 5 vertical - 2 + 5 - + True False 5 2 - 2 - True + 5 + + + True + False + end + 5 + Host: + 0.019999999552965164 + + + 0 + 0 + + True True + center 127.0.0.1 network-transmit-receive-symbolic @@ -589,52 +583,241 @@ Author: Dmitriy Yefremov - - 22 + True False - 2 - - - True - False - end - 5 - Host: - - - False - True - 0 - - - - - SSL/TSL - False - False - end - True - - - - False - False - end - 1 - - + end + Login: + 0.019999999552965164 0 + 2 + + + + + True + True + center + root + avatar-default-symbolic + False + + + 0 + 3 + + + + + True + False + end + Password: + 0.019999999552965164 + + + 0 + 4 + + + + + True + True + center + False + False + + root + emblem-readonly + False + password + + + 0 + 5 + + + + + True + True + Default 21 + center + 6 + 6 + 21 + network-workgroup-symbolic + + + + 2 + 1 + + + + + True + False + FTP: + 1 + + + 1 + 1 + + + + + True + True + Default 23 + center + 6 + 6 + 23 + network-workgroup-symbolic + + + + 2 + 5 + + + + + True + True + Timeout between commands in seconds + center + 2 + 6 + 6 + 1 + alarm-symbolic + number + telnet_timeout_adjustment + True + 1 + + + 3 + 5 + + + + + True + True + Default 80 + center + 5 + 6 + 6 + 80 + network-workgroup-symbolic + + + + 2 + 3 + + + + + True + False + HTTP: + 1 + + + 1 + 3 + + + + + True + False + Telnet: + 1 + + + 1 + 5 + + + + + True + False + end + Timeout: + + + 3 + 4 + + + + + True + False + end + Port: + + + 2 0 + + + SSL/TSL + True + False + False + start + center + True + + + + 3 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + False True - 0 + 1 @@ -643,11 +826,58 @@ Author: Dmitriy Yefremov False 5 - + True False - center - settings_stack + expand + + + FTP + True + True + False + True + False + telnet_radio_button + + + True + True + 0 + + + + + HTTP + True + True + False + True + False + telnet_radio_button + + + True + True + 1 + + + + + Telnet + True + True + False + True + False + ftp_radio_button + + + True + True + 2 + + False @@ -714,323 +944,6 @@ Author: Dmitriy Yefremov - - False - True - 1 - - - - - True - False - 5 - - - - True - False - 2 - 2 - - - True - False - Login: - - - 0 - 0 - - - - - True - True - True - root - avatar-default-symbolic - False - - - 0 - 1 - - - - - True - False - Password: - - - 1 - 0 - - - - - True - True - True - False - - root - emblem-readonly - False - password - - - 1 - 1 - - - - - True - True - 6 - 6 - 21 - network-workgroup-symbolic - - - - 2 - 1 - - - - - True - False - Port: - - - 2 - 0 - - - - - ftp - FTP - - - - - True - False - 2 - 2 - - - True - False - Login: - - - 0 - 0 - - - - - True - False - Password: - - - 1 - 0 - - - - - True - True - True - avatar-default-symbolic - - - 0 - 1 - - - - - True - False - Port: - - - 2 - 0 - - - - - True - True - 5 - 6 - 6 - 80 - network-workgroup-symbolic - - - - 2 - 1 - - - - - True - True - True - False - - root - emblem-readonly - False - password - - - 1 - 1 - - - - - http - HTTP - 1 - - - - - True - False - 2 - 2 - - - True - False - Port: - - - 2 - 0 - - - - - True - True - 6 - 6 - 23 - network-workgroup-symbolic - - - - 2 - 1 - - - - - True - False - Login: - - - 0 - 0 - - - - - True - True - True - 12 - 15 - avatar-default-symbolic - - - 0 - 1 - - - - - True - False - Password: - - - 1 - 0 - - - - - True - True - True - False - - 12 - 15 - emblem-readonly - - - 1 - 1 - - - - - True - False - Timeout: - - - 3 - 0 - - - - - True - True - Timeout between commands in seconds - 2 - 6 - 6 - 1 - alarm-symbolic - number - telnet_timeout_adjustment - True - 1 - - - 3 - 1 - - - - - telnet - Telnet - 2 - - - False True @@ -1048,7 +961,7 @@ Author: Dmitriy Yefremov - True + False True 1 @@ -1075,7 +988,7 @@ Author: Dmitriy Yefremov True False Services and Bouquets files: - 0 + 0.019999999552965164 0 @@ -1098,7 +1011,7 @@ Author: Dmitriy Yefremov False User bouquet files: - 2.2351741291171123e-10 + 0.019999999552965164 0 diff --git a/app/ui/settings_dialog.py b/app/ui/settings_dialog.py index da937a42..5fcf4fb6 100644 --- a/app/ui/settings_dialog.py +++ b/app/ui/settings_dialog.py @@ -1,6 +1,5 @@ import os import re -from enum import Enum from app.commons import run_task, run_idle, log from app.connections import test_telnet, test_ftp, TestException, test_http, HttpApiException @@ -14,12 +13,6 @@ def show_settings_dialog(transient, options): return SettingsDialog(transient, options).show() -class Property(Enum): - FTP = "ftp" - HTTP = "http" - TELNET = "telnet" - - class SettingsDialog: _DIGIT_ENTRY_NAME = "digit-entry" _DIGIT_PATTERN = re.compile("(?:^[\\s]*$|\\D)") @@ -50,7 +43,6 @@ class SettingsDialog: "on_profile_set_default": self.on_profile_set_default, "on_lang_changed": self.on_lang_changed, "on_main_settings_visible": self.on_main_settings_visible, - "on_network_settings_visible": self.on_network_settings_visible, "on_http_use_ssl_toggled": self.on_http_use_ssl_toggled, "on_click_mode_togged": self.on_click_mode_togged, "on_play_mode_changed": self.on_play_mode_changed, @@ -84,15 +76,13 @@ class SettingsDialog: self._port_field = builder.get_object("port_field") self._login_field = builder.get_object("login_field") self._password_field = builder.get_object("password_field") - self._http_login_field = builder.get_object("http_login_field") - self._http_password_field = builder.get_object("http_password_field") self._http_port_field = builder.get_object("http_port_field") self._http_use_ssl_check_button = builder.get_object("http_use_ssl_check_button") - self._telnet_login_field = builder.get_object("telnet_login_field") - self._telnet_password_field = builder.get_object("telnet_password_field") self._telnet_port_field = builder.get_object("telnet_port_field") self._telnet_timeout_spin_button = builder.get_object("telnet_timeout_spin_button") - self._settings_stack = builder.get_object("settings_stack") + # Test + self._ftp_radio_button = builder.get_object("ftp_radio_button") + self._http_radio_button = builder.get_object("http_radio_button") # Paths self._services_field = builder.get_object("services_field") self._user_bouquet_field = builder.get_object("user_bouquet_field") @@ -176,7 +166,6 @@ class SettingsDialog: self._profile_remove_button = builder.get_object("profile_remove_button") self._apply_profile_button = builder.get_object("apply_profile_button") self._apply_profile_button.bind_property("visible", header_separator, "visible") - self._apply_profile_button.bind_property("visible", builder.get_object("reset_button"), "visible") # Style self._style_provider = Gtk.CssProvider() self._style_provider.load_from_path(UI_RESOURCES_PATH + "style.css") @@ -209,7 +198,6 @@ class SettingsDialog: is_enigma_profile = s_type is SettingsType.ENIGMA_2 self._neutrino_radio_button.set_active(s_type is SettingsType.NEUTRINO_MP) self.update_header_bar() - self._settings_stack.get_child_by_name(Property.HTTP.value).set_visible(is_enigma_profile) http_active = self._support_http_api_switch.get_active() self._click_mode_zap_button.set_sensitive(is_enigma_profile and http_active) self._lang_combo_box.set_active_id(self._ext_settings.language) @@ -265,12 +253,8 @@ class SettingsDialog: self._port_field.set_text(self._settings.port) self._login_field.set_text(self._settings.user) self._password_field.set_text(self._settings.password) - self._http_login_field.set_text(self._settings.http_user) - self._http_password_field.set_text(self._settings.http_password) self._http_port_field.set_text(self._settings.http_port) self._http_use_ssl_check_button.set_active(self._settings.http_use_ssl) - self._telnet_login_field.set_text(self._settings.telnet_user) - self._telnet_password_field.set_text(self._settings.telnet_password) self._telnet_port_field.set_text(self._settings.telnet_port) self._telnet_timeout_spin_button.set_value(self._settings.telnet_timeout) self._services_field.set_text(self._settings.services_path) @@ -326,12 +310,8 @@ class SettingsDialog: self._settings.port = self._port_field.get_text() self._settings.user = self._login_field.get_text() self._settings.password = self._password_field.get_text() - self._settings.http_user = self._http_login_field.get_text() - self._settings.http_password = self._http_password_field.get_text() self._settings.http_port = self._http_port_field.get_text() self._settings.http_use_ssl = self._http_use_ssl_check_button.get_active() - self._settings.telnet_user = self._telnet_login_field.get_text() - self._settings.telnet_password = self._telnet_password_field.get_text() self._settings.telnet_port = self._telnet_port_field.get_text() self._settings.telnet_timeout = int(self._telnet_timeout_spin_button.get_value()) self._settings.services_path = self._services_field.get_text() @@ -391,16 +371,15 @@ class SettingsDialog: if self._test_spinner.get_state() is Gtk.StateType.ACTIVE: return self.show_spinner(True) - current_property = Property(self._settings_stack.get_visible_child_name()) - if current_property is Property.HTTP: - self.test_http() - elif current_property is Property.TELNET: - self.test_telnet() - elif current_property is Property.FTP: + if self._ftp_radio_button.get_active(): self.test_ftp() + elif self._http_radio_button.get_active(): + self.test_http() + else: + self.test_telnet() def test_http(self): - user, password = self._http_login_field.get_text(), self._http_password_field.get_text() + user, password = self._login_field.get_text(), self._password_field.get_text() host, port = self._host_field.get_text(), self._http_port_field.get_text() use_ssl = self._http_use_ssl_check_button.get_active() try: @@ -415,7 +394,7 @@ class SettingsDialog: def test_telnet(self): timeout = int(self._telnet_timeout_spin_button.get_value()) host, port = self._host_field.get_text(), self._telnet_port_field.get_text() - user, password = self._telnet_login_field.get_text(), self._telnet_password_field.get_text() + user, password = self._login_field.get_text(), self._password_field.get_text() try: self.show_info_message(test_telnet(host, port, user, password, timeout), Gtk.MessageType.INFO) self.show_spinner(False) @@ -581,9 +560,6 @@ class SettingsDialog: self._apply_profile_button.set_visible(name == "profiles") self._apply_presets_button.set_visible(name == "streaming") - def on_network_settings_visible(self, stack, param): - self._http_use_ssl_check_button.set_visible(Property(stack.get_visible_child_name()) is Property.HTTP) - def on_http_use_ssl_toggled(self, button): active = button.get_active() self._settings.http_use_ssl = active