From 5f866603056616889b32e142b0d4181532f02823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Wed, 11 Dec 2019 00:44:48 +0100 Subject: [PATCH] Added handling for supported services to VM settings Slight change to layout of services tab, made it hopefully less confusing. Dropdown will now list services supported by this VM and its template, not just an assortment of hardcoded services. --- qubesmanager/settings.py | 54 ++++++++++------- ui/settingsdlg.ui | 123 +++++++++++++++++++++++---------------- 2 files changed, 105 insertions(+), 72 deletions(-) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 73bf647..56a6fef 100644 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -209,8 +209,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): ####### services tab self.__init_services_tab__() - self.service_line_edit.lineEdit().returnPressed.connect( - self.__add_service__) self.add_srv_button.clicked.connect(self.__add_service__) self.remove_srv_button.clicked.connect(self.__remove_service__) @@ -1074,35 +1072,49 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): self.services_list.addItem(item) self.new_srv_dict[service] = self.vm.features[feature] - # add suggested services - self.service_line_edit.addItem('clocksync') - self.service_line_edit.addItem('crond') - self.service_line_edit.addItem('cups') - self.service_line_edit.addItem('disable-default-route') - self.service_line_edit.addItem('disable-dns-server') - self.service_line_edit.addItem('network-manager') - self.service_line_edit.addItem('qubes-firewall') - self.service_line_edit.addItem('qubes-network') - self.service_line_edit.addItem('qubes-update-check') - self.service_line_edit.addItem('qubes-updates-proxy') - self.service_line_edit.addItem('qubes-yum-proxy') - self.service_line_edit.addItem('updates-proxy-setup') - self.service_line_edit.addItem('yum-proxy-setup') + self.service_line_edit.addItem("") + + supported_services = [] + service_prefix = "supported-service." + + for feature in self.vm.features: + if feature.startswith(service_prefix): + supported_services.append(feature[len(service_prefix):]) + if getattr(self.vm, "template", None): + for feature in self.vm.template.features: + if feature.startswith(service_prefix): + supported_services.add(feature[len(service_prefix):]) + + for service in sorted(supported_services): + self.service_line_edit.addItem(service) + + self.service_line_edit.addItem(self.tr('(custom...)')) self.service_line_edit.setEditText("") def __add_service__(self): srv = str(self.service_line_edit.currentText()).strip() + if srv != "": + if self.service_line_edit.currentIndex() == \ + len(self.service_line_edit) - 1: + (custom_name, ok) = QtWidgets.QInputDialog.getText( + self, self.tr("Custom service name"), + self.tr( + "Name of the service:")) + if ok: + srv = custom_name.strip() + else: + return if srv in self.new_srv_dict: QtWidgets.QMessageBox.information( self, '', self.tr('Service already on the list!')) - else: - item = QtWidgets.QListWidgetItem(srv) - item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked) - self.services_list.addItem(item) - self.new_srv_dict[srv] = True + return + item = QtWidgets.QListWidgetItem(srv) + item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked) + self.services_list.addItem(item) + self.new_srv_dict[srv] = True def __remove_service__(self): item = self.services_list.currentItem() diff --git a/ui/settingsdlg.ui b/ui/settingsdlg.ui index e5f7563..96e51c6 100644 --- a/ui/settingsdlg.ui +++ b/ui/settingsdlg.ui @@ -29,7 +29,7 @@ - 1 + 5 @@ -1433,47 +1433,85 @@ The qube must be running to disable seamless mode; this setting is not persisten Services - - - - Qt::Vertical + + + + + 0 + 0 + - - - 20 - 40 - - - + - - - - + Checked services will be turned on. - - - - Unchecked services will be turned off. - - - - + Unlisted services will follow default settings. - + + + + Unchecked services will be turned off. + + + + + + + + + Select a service: + + + + + + + + 0 + 0 + + + + Services listed here are explicitly supported by the qube. Additional services may be added with the '+' button on the right. + + + + + + + + + + Add + + + + :/add.png:/add.png + + + + 24 + 24 + + + + + + + - + Remove service @@ -1487,32 +1525,18 @@ The qube must be running to disable seamless mode; this setting is not persisten - - - - Services listed here are only base Qubes services - other services may be installed and implemented. + + + + Qt::Vertical - - true - - - - - - - - - - - :/add.png:/add.png - - + - 24 - 24 + 20 + 40 - + @@ -1568,10 +1592,7 @@ The qube must be running to disable seamless mode; this setting is not persisten temp_full_access_time no_strict_reset_button refresh_apps_button - service_line_edit - add_srv_button services_list - remove_srv_button