Merge branch 'master' of git.qubes-os.org:/var/lib/qubes/git/aga/qubes-manager

This commit is contained in:
Joanna Rutkowska 2012-03-02 14:08:49 +01:00
commit 0f5cbe84ca
9 changed files with 282 additions and 141 deletions

View File

@ -178,7 +178,7 @@ p, li { white-space: pre-wrap; }
<item>
<widget class="QProgressBar" name="progress_bar">
<property name="value">
<number>24</number>
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>

View File

@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>381</width>
<height>121</height>
<height>193</height>
</rect>
</property>
<property name="windowTitle">
@ -19,78 +19,167 @@
<property name="modal">
<bool>true</bool>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>361</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>14</y>
<width>62</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Address</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>10</x>
<y>44</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Service</string>
</property>
</widget>
<widget class="QComboBox" name="serviceComboBox">
<property name="geometry">
<rect>
<x>70</x>
<y>40</y>
<width>301</width>
<height>27</height>
</rect>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
<widget class="QComboBox" name="addressComboBox">
<property name="geometry">
<rect>
<x>70</x>
<y>10</y>
<width>301</width>
<height>27</height>
</rect>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Protocol</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Service</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="serviceComboBox">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Address</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QComboBox" name="addressComboBox">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="tcp_radio">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>TCP</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QRadioButton" name="udp_radio">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>UDP</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QRadioButton" name="any_radio">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>71</width>
<height>0</height>
</size>
</property>
<property name="text">
<string> Any </string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="tcp_port_lineedit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="inputMethodHints">
<set>Qt::ImhDigitsOnly</set>
</property>
<property name="maxLength">
<number>5</number>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="udp_port_lineedit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="inputMethodHints">
<set>Qt::ImhDigitsOnly</set>
</property>
<property name="maxLength">
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>addressComboBox</tabstop>
<tabstop>serviceComboBox</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>

View File

@ -173,9 +173,17 @@ class BackupVMsWindow(Ui_Backup, QWizard):
if not self.thread_monitor.success:
QMessageBox.warning (None, "Backup error!", "ERROR: {1}".format(self.vm.name, self.thread_monitor.error_msg))
umount_device(self.dev_mount_path)
if self.dev_mount_path != None:
umount_device(self.dev_mount_path)
self.button(self.FinishButton).setEnabled(True)
def reject(self):
if self.dev_mount_path != None:
umount_device(self.dev_mount_path)
self.done(0)
def has_selected_vms(self):
return self.select_vms_widget.selected_list.count() > 0

View File

@ -81,8 +81,7 @@ def fill_devs_list(dialog):
dialog.dev_combobox.setCurrentIndex(0) #current selected is null ""
dialog.prev_dev_idx = 0
dialog.dir_line_edit.clear()
dialog.dir_line_edit.setEnabled(False)
dialog.select_path_button.setEnabled(False)
enable_dir_line_edit(dialog, True)
def enable_dir_line_edit(dialog, boolean):
@ -100,12 +99,10 @@ def dev_combobox_activated(dialog, idx):
if dialog.dev_mount_path != None:
dialog.dev_mount_path = umount_device(dialog.dev_mount_path)
if dialog_dev_mount_path != None:
if dialog.dev_mount_path != None:
dialog.dev_combobox.setCurrentIndex(dialog.prev_dev_idx)
return
enable_dir_line_edit(dialog, False)
if dialog.dev_combobox.currentText() != "None": #An existing device chosen
dev_name = str(dialog.dev_combobox.itemData(idx).toString())
@ -123,16 +120,13 @@ def dev_combobox_activated(dialog, idx):
#check if device mounted
dialog.dev_mount_path = check_if_mounted(dev_path)
if dialog.dev_mount_path != None:
enable_dir_line_edit(dialog, True)
else:
if dialog.dev_mount_path == None:
dialog.dev_mount_path = mount_device(dev_path)
if dialog.dev_mount_path != None:
enable_dir_line_edit(dialog, True)
else:
if dialog.dev_mount_path == None:
dialog.dev_combobox.setCurrentIndex(0) #if couldn't mount - set current device to "None"
dialog.prev_dev_idx = 0
return
dialog.prev_dev_idx = idx
dialog.select_dir_page.emit(SIGNAL("completeChanged()"))
@ -141,7 +135,12 @@ def select_path_button_clicked(dialog):
dialog.backup_dir = dialog.dir_line_edit.text()
file_dialog = QFileDialog()
file_dialog.setReadOnly(True)
new_path = file_dialog.getExistingDirectory(dialog, "Select backup directory.", dialog.dev_mount_path)
if dialog.dev_mount_path != None:
new_path = file_dialog.getExistingDirectory(dialog, "Select backup directory.", dialog.dev_mount_path)
else:
new_path = file_dialog.getExistingDirectory(dialog, "Select backup directory.", "~")
if new_path:
dialog.dir_line_edit.setText(new_path)
dialog.backup_dir = new_path

View File

@ -81,7 +81,7 @@ class NewFwRuleDlg (QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg):
self.set_ok_enabled(False)
self.addressComboBox.setValidator(QIPAddressValidator())
self.addressComboBox.editTextChanged.connect(self.address_editing_finished)
self.serviceComboBox.setValidator(QRegExpValidator(QRegExp("[a-z][a-z0-9-]+|[0-9]+(-[0-9]+)?", Qt.CaseInsensitive), None))
self.serviceComboBox.setValidator(QRegExpValidator(QRegExp("\*|[a-z][a-z0-9-]+|[0-9]+(-[0-9]+)?", Qt.CaseInsensitive), None))
self.serviceComboBox.setInsertPolicy(QComboBox.InsertAtBottom)
self.populate_combos()
@ -115,6 +115,21 @@ class NewFwRuleDlg (QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg):
if ok_button is not None:
ok_button.setEnabled(on)
def on_tcp_radio_toggled(self, checked):
self.tcp_port_lineedit.setEnabled(checked)
self.udp_port_lineedit.setEnabled(not checked)
def on_udp_radio_toggled(self, checked):
self.tcp_port_lineedit.setEnabled(not checked)
self.udp_port_lineedit.setEnabled(checked)
def on_any_radio_toggled(self, checked):
self.tcp_port_lineedit.setEnabled(not checked)
self.udp_port_lineedit.setEnabled(not checked)
class QubesFirewallRuleItem(object):
def __init__(self, address = str(), netmask = 32, portBegin = 0, portEnd = None):
self.__address = address
@ -141,6 +156,8 @@ class QubesFirewallRuleItem(object):
def hasChildren(self):
return False
class QubesFirewallRulesModel(QAbstractItemModel):
def __init__(self, parent=None):
QAbstractItemModel.__init__(self, parent)
@ -168,6 +185,16 @@ class QubesFirewallRulesModel(QAbstractItemModel):
self.__services.append( (service["name"], int(service["port"]), service["protocol"]) )
f.close()
def sort(self, idx, order):
from operator import attrgetter
rev = (order == Qt.AscendingOrder)
if idx==0:
self.children.sort(key=attrgetter('address'), reverse = rev)
if idx==1:
self.children.sort(key=lambda x: self.get_service_name(attrgetter('portBegin')) if attrgetter('portEnd') == None else attrgetter('portBegin'), reverse = rev)
def get_service_name(self, port):
for service in self.__services:
if service[1] == port:

View File

@ -165,7 +165,7 @@ class VmTemplateItem (QTableWidgetItem):
else:
self.setText("---")
self.setTextAlignment(Qt.AlignHCenter)
self.setTextAlignment(Qt.AlignCenter)
class VmIconWidget (QWidget):
@ -196,7 +196,7 @@ class VmNetvmItem (QTableWidgetItem):
else:
self.setText("---")
self.setTextAlignment(Qt.AlignHCenter)
self.setTextAlignment(Qt.AlignCenter)
class VmUsageBarWidget (QWidget):
@ -347,7 +347,7 @@ class VmUpdateInfoWidget(QWidget):
layout.addWidget(self.label, alignment=Qt.AlignCenter)
else:
self.icon = QLabel("")
layout.addWidget(self.icon, alignment=Qt.AlignHCenter)
layout.addWidget(self.icon, alignment=Qt.AlignCenter)
self.setLayout(layout)
self.previous_outdated = False
@ -540,6 +540,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
self.context_menu.addAction(self.action_appmenus)
self.context_menu.addAction(self.action_editfwrules)
self.context_menu.addAction(self.action_updatevm)
self.table_selection_changed()
self.blk_menu = QMenu("Block devices")
self.context_menu.addMenu(self.blk_menu)
@ -704,7 +706,7 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
vm_row.update(self.counter, blk_visible=blk_visible)
#self.table_selection_changed()
self.table_selection_changed()
if not out_of_schedule:
self.counter += 1
@ -850,7 +852,7 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
def get_selected_vm(self):
#vm selection relies on the VmInfo widget's value used for sorting by VM name
row_index = self.table.currentRow()
if row_index != None:
if row_index != -1:
(vm_name, qid) = self.table.item(row_index, self.columns_indices["Name"]).value
assert self.vms_in_table[qid] is not None
vm = self.vms_in_table[qid].vm
@ -914,10 +916,10 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
self.qvm_collection.load()
#TODO: the following two conditions should really be checked by qvm_collection.pop() overload...
if vm.is_template() and qvm_collection.default_template_qid == vm.qid:
qvm_collection.default_template_qid = None
if vm.is_netvm() and qvm_collection.default_netvm_qid == vm.qid:
qvm_collection.default_netvm_qid = None
if vm.is_template() and self.qvm_collection.default_template_qid == vm.qid:
self.qvm_collection.default_template_qid = None
if vm.is_netvm() and self.qvm_collection.default_netvm_qid == vm.qid:
self.qvm_collection.default_netvm_qid = None
vm.remove_from_disk()
self.qvm_collection.pop(vm.qid)

View File

@ -97,7 +97,6 @@ class RestoreVMsWindow(Ui_Restore, QWizard):
def dev_combobox_activated(self, idx):
dev_combobox_activated(self, idx)
@pyqtSlot(name='on_select_path_button_clicked')
def select_path_button_clicked(self):
select_path_button_clicked(self)
@ -209,8 +208,14 @@ class RestoreVMsWindow(Ui_Restore, QWizard):
#if not self.thread_monitor.success:
#QMessageBox.warning (None, "Backup error!", "ERROR: {1}".format(self.vm.name, self.thread_monitor.error_msg))
umount_device(self.dev_mount_path)
if self.dev_mount_path != None:
umount_device(self.dev_mount_path)
self.button(self.FinishButton).setEnabled(True)
def reject(self):
if self.dev_mount_path != None:
umount_device(self.dev_mount_path)
self.done(0)

View File

@ -139,15 +139,16 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.done(0)
def __save_changes__(self, thread_monitor):
self.fw_model.apply_rules()
self.AppListManager.save_appmenu_select_changes()
ret = self.__apply_basic_tab__()
if len(ret) > 0 :
thread_monitor.set_error_msg('\n'.join(ret))
thread_monitor.set_finished()
return
#self.fw_model.apply_rules()
self.AppListManager.save_appmenu_select_changes()
thread_monitor.set_error_msg('\n'.join(ret))
thread_monitor.set_finished()
def current_tab_changed(self, idx):
if idx == self.tabs_indices["firewall"]:
if self.vm.netvm_vm is not None and not self.vm.netvm_vm.is_proxyvm():
@ -211,15 +212,13 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
def __apply_basic_tab__(self):
msg = []
if self.vm.is_running():
msg.append("Can't change settings of a running VM.")
msg.append("telemele")
return msg
# vmname changed
vmname = str(self.vmname.text())
if self.vm.name != vmname:
if self.qvm_collection.get_vm_by_name(vmname) is not None:
if self.vm.is_running():
msg.append("Can't change name of a running VM.")
elif self.qvm_collection.get_vm_by_name(vmname) is not None:
msg.append("A VM named <b>{0}</b> already exists in the system!".format(vmname))
else:
oldname = self.vm.name
@ -236,11 +235,15 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
#vm label changed
if self.vmlabel.currentIndex() != self.label_idx:
label = self.label_list[self.vmlabel.currentIndex()]
self.qvm_collection.lock_db_for_writing()
self.vm.label = label
self.qvm_collection.save()
self.qvm_collection.unlock_db()
if self.vm.is_running():
msg.append("Can't change label of a running VM.")
else:
label = self.label_list[self.vmlabel.currentIndex()]
self.qvm_collection.lock_db_for_writing()
self.vm.label = label
self.qvm_collection.save()
self.qvm_collection.unlock_db()
return msg

View File

@ -29,7 +29,7 @@
<locale language="English" country="UnitedStates"/>
</property>
<property name="currentIndex">
<number>5</number>
<number>2</number>
</property>
<widget class="QWidget" name="basic_tab">
<property name="locale">
@ -470,22 +470,48 @@
<attribute name="title">
<string>Firewall rules</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QRadioButton" name="policyAllowRadioButton">
<property name="text">
<string>Allow network access except...</string>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QCheckBox" name="icmpCheckBox">
<property name="minimumSize">
<size>
<width>323</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Allow ICMP traffic</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="policyDenyRadioButton">
<property name="text">
<string>Deny network access except...</string>
</property>
</widget>
</item>
<item>
<item row="1" column="1">
<widget class="QCheckBox" name="dnsCheckBox">
<property name="text">
<string>Allow DNS queries</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
@ -503,6 +529,9 @@
<property name="itemsExpandable">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
@ -518,28 +547,7 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="icmpCheckBox">
<property name="text">
<string>Allow ICMP traffic</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="dnsCheckBox">
<property name="text">
<string>Allow DNS queries</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<layout class="QHBoxLayout" name="horizontalLayout_4"/>
</item>
</layout>
</item>