From 027d106507380733d26e4152ff21f91d0925903a Mon Sep 17 00:00:00 2001 From: donoban Date: Wed, 9 May 2018 11:31:44 +0200 Subject: [PATCH] VmRowInTable dbus events moved to VmManagerWindow Since we need to do some updates affecting all vms or the Window itself, this is a better place for handling this. --- qubesmanager/qube_manager.py | 50 ++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index e4e9e29..2e2b6ea 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -131,16 +131,6 @@ class VmRowInTable(object): self.table = table - #Connect dbus events - bus = SessionBus() - self.dbus = bus.get("org.qubes.DomainManager1" , "/org/qubes/DomainManager1/domains/" + str(vm.qid)) - self.dbus.PropertiesChanged.connect(self.OnPropertiesChanged) - - def OnPropertiesChanged(self, dbus, properties, dump): - for key in properties: - if key == 'state': - self.update() - def update(self, update_size_on_disk=False): """ Update info in a single VM row @@ -382,10 +372,16 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): self.update_size_on_disk = False self.shutdown_monitor = {} + # Connect dbus events bus = SessionBus() manager = bus.get("org.qubes.DomainManager1") manager.DomainAdded.connect(self.OnDomainAdded) manager.DomainRemoved.connect(self.OnDomainRemoved) + manager.Failed.connect(self.OnFailed) + manager.Halted.connect(self.OnHalted) + manager.Halting.connect(self.OnHalting) + manager.Starting.connect(self.OnStarting) + manager.Started.connect(self.OnStarted) def OnDomainAdded(self, manager, domain): #needs to clear cache @@ -423,6 +419,40 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): self.table.removeRow(row_index) del self.vms_in_table[qid] + def OnFailed(self, manager, domain): + qid = int(domain.split('/')[-1]) + self.vms_in_table[qid].update() + + def OnHalted(self, manager, domain): + qid = int(domain.split('/')[-1]) + self.vms_in_table[qid].update() + + # Check if is TemplatVM and update related AppVMs + starting_vm = self.vms_in_table[qid] + if starting_vm.vm.klass == 'TemplateVM': + for vm in starting_vm.vm.appvms: + if vm.klass == 'AppVM': + self.vms_in_table[vm.qid].update() + + def OnHalting(self, manager, domain): + qid = int(domain.split('/')[-1]) + self.vms_in_table[qid].update() + + def OnStarted(self, manager, domain): + qid = int(domain.split('/')[-1]) + self.vms_in_table[qid].update() + + def OnStarting(self, manager, domain): + qid = int(domain.split('/')[-1]) + self.vms_in_table[qid].update() + + # Check if is TemplatVM and update related AppVMs + starting_vm = self.vms_in_table[qid] + if starting_vm.vm.klass == 'TemplateVM': + for vm in starting_vm.vm.appvms: + if vm.klass == 'AppVM': + self.vms_in_table[vm.qid].update() + def load_manager_settings(self): # visible columns self.visible_columns_count = 0