Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Commit

Permalink
Forward Qubes property set events
Browse files Browse the repository at this point in the history
  • Loading branch information
kalkin committed Sep 27, 2016
1 parent 56ced94 commit 28bc2ac
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
8 changes: 0 additions & 8 deletions qubesdbus/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ def __init__(self, bus, bus_name, bus_path, data):
super(Domain, self).__init__(name, data, bus=bus, bus_name=bus_name,
bus_path=bus_path)

@dbus.service.method(dbus_interface="org.freedesktop.DBus.Properties")
def GetAll(self, _):
# According to the dbus spec we should be able to return types not only
# string, but it doesn't work. We need to serialize everything to string
# ☹
return dbus.Dictionary({k: dbus.String(v)
for k, v in self.properties.items()})

@dbus.service.signal(
dbus_interface="org.qubes.DomainManager1.domains.Signals",
signature='s')
Expand Down
4 changes: 2 additions & 2 deletions qubesdbus/domain_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def GetManagedObjects(self):
''' Returns the domain objects paths and their supported interfaces and
properties.
'''
return {"%s/domains/%s" % (self.bus_path, d.qid):
return {"%s/domains/%s" % (self.bus_path, d.properties['qid']):
# pylint: disable=protected-access
"%s.domains.%s" % (self.bus_name._name, d.qid)
"%s.domains.%s" % (self.bus_name._name, d.properties['qid'])
for d in self.domains}

def _proxify_domain(self, vm):
Expand Down
7 changes: 0 additions & 7 deletions qubesdbus/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ def __init__(self, bus, bus_name, bus_path, data):
super(Label, self).__init__(name, data, bus=bus, bus_name=bus_name,
bus_path=bus_path)

@dbus.service.method(dbus_interface="org.freedesktop.DBus.Properties")
def GetAll(self, _):
# According to the dbus spec we should be able to return types not only
# string, but it doesn't work. We need to serialize everything to string ☹
return dbus.Dictionary({k: dbus.String(v)
for k, v in self.properties.items()})


def main(args=None):
''' Main function ''' # pylint: disable=unused-argument
Expand Down
10 changes: 9 additions & 1 deletion qubesdbus/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,15 @@ def forward_vm_event(self, vm, event, *args, **kwargs):

@handler('*', system=True)
def forward_app_event(self, vm, event, *args, **kwargs):
log.debug('A: %s %s %s %s', vm, event, args, kwargs)
if is_garbage(event):
log.debug('Drop %s from %s', event, vm)
return
elif event.startswith('property-set:'):
proxy = app_proxy()
property_set(proxy, args[0], str(args[1]))
log.info('App: %s %s %s %s', vm, event, args, kwargs)
else:
log.warn('Unknown %s from %s', event, vm)


def property_set(proxy, name, value):
Expand Down
8 changes: 8 additions & 0 deletions qubesdbus/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def __init__(self, name, data, *args, **kwargs):
def Get(self, _, property_name):
return self.properties[property_name]

@dbus.service.method(dbus_interface="org.freedesktop.DBus.Properties")
def GetAll(self, _):
# According to the dbus spec we should be able to return types not only
# string, but it doesn't work. We need to serialize everything to string
# ☹
return dbus.Dictionary({k: dbus.String(v)
for k, v in self.properties.items()})

@dbus.service.method(dbus_interface="org.freedesktop.DBus.Properties")
def Set(self, _, name, value): # type: (str, dbus.String, Any) -> None
new_value = value
Expand Down

0 comments on commit 28bc2ac

Please sign in to comment.