dbus interface for error icon notify (#615)
This commit is contained in:
parent
3f7fd7ceb7
commit
8fbea00975
15
org.qubesos.QubesManager.conf
Normal file
15
org.qubesos.QubesManager.conf
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE busconfig PUBLIC
|
||||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<!-- This config allows anyone to control QubesManager -->
|
||||
|
||||
<policy context="default">
|
||||
<allow send_destination="org.qubesos.QubesManager"/>
|
||||
</policy>
|
||||
|
||||
<policy group="qubes">
|
||||
<allow own="org.qubesos.QubesManager"/>
|
||||
</policy>
|
||||
</busconfig>
|
||||
|
19
org.qubesos.QubesManager.xml
Normal file
19
org.qubesos.QubesManager.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="org.qubesos.QubesManager">
|
||||
<method name="notify_error">
|
||||
<arg name="vmname" type="s" direction="in"/>
|
||||
<arg name="message" type="s" direction="in"/>
|
||||
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
|
||||
</method>
|
||||
<method name="clear_error_exact">
|
||||
<arg name="vmname" type="s" direction="in"/>
|
||||
<arg name="message" type="s" direction="in"/>
|
||||
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
|
||||
</method>
|
||||
<method name="clear_error">
|
||||
<arg name="vmname" type="s" direction="in"/>
|
||||
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
@ -26,6 +26,8 @@ import signal
|
||||
import fcntl
|
||||
import errno
|
||||
import dbus
|
||||
import dbus.service
|
||||
from dbus.mainloop.qt import DBusQtMainLoop
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
|
||||
@ -62,6 +64,9 @@ qubes_guid_path = '/usr/bin/qubes_guid'
|
||||
|
||||
update_suggestion_interval = 14 # 14 days
|
||||
|
||||
dbus_object_path = '/org/qubesos/QubesManager'
|
||||
dbus_interface = 'org.qubesos.QubesManager'
|
||||
|
||||
power_order = Qt.DescendingOrder
|
||||
update_order = Qt.AscendingOrder
|
||||
|
||||
@ -1810,6 +1815,42 @@ class QubesTrayIcon(QSystemTrayIcon):
|
||||
action.setCheckable(True)
|
||||
return action
|
||||
|
||||
class QubesDbusNotify(dbus.service.Object):
|
||||
def __init__(self, bus, manager_window):
|
||||
# export to system bus (instead of session) to make possible
|
||||
# communication from outside of session (eg. from qmemman)
|
||||
dbus.service.Object.__init__(self, bus, dbus_object_path)
|
||||
self.manager_window = manager_window
|
||||
|
||||
@dbus.service.method(dbus_interface=dbus_interface,
|
||||
in_signature='ss', out_signature='')
|
||||
def notify_error(self, vmname, message):
|
||||
vm = self.manager_window.qvm_collection.get_vm_by_name(vmname)
|
||||
if vm:
|
||||
self.manager_window.set_error(vm.qid, message)
|
||||
else:
|
||||
# ignore VM-not-found error
|
||||
pass
|
||||
@dbus.service.method(dbus_interface=dbus_interface,
|
||||
in_signature='ss', out_signature='')
|
||||
def clear_error_exact(self, vmname, message):
|
||||
vm = self.manager_window.qvm_collection.get_vm_by_name(vmname)
|
||||
if vm:
|
||||
self.manager_window.clear_error_exact(vm.qid, message)
|
||||
else:
|
||||
# ignore VM-not-found error
|
||||
pass
|
||||
|
||||
@dbus.service.method(dbus_interface=dbus_interface,
|
||||
in_signature='s', out_signature='')
|
||||
def clear_error(self, vmname):
|
||||
vm = self.manager_window.qvm_collection.get_vm_by_name(vmname)
|
||||
if vm:
|
||||
self.manager_window.clear_error(vm.qid, message)
|
||||
else:
|
||||
# ignore VM-not-found error
|
||||
pass
|
||||
|
||||
def get_frame_size():
|
||||
w = 0
|
||||
h = 0
|
||||
@ -1923,6 +1964,10 @@ def main():
|
||||
|
||||
sys.excepthook = handle_exception
|
||||
|
||||
# setup dbus connection
|
||||
DBusQtMainLoop(set_as_default=True)
|
||||
|
||||
|
||||
global manager_window
|
||||
manager_window = VmManagerWindow()
|
||||
wm = WatchManager()
|
||||
@ -1933,6 +1978,11 @@ def main():
|
||||
notifier.start()
|
||||
wdd = wm.add_watch(qubes_store_filename, mask)
|
||||
|
||||
global system_bus
|
||||
system_bus = dbus.SystemBus()
|
||||
name = dbus.service.BusName('org.qubesos.QubesManager', system_bus)
|
||||
dbus_notifier = QubesDbusNotify(system_bus, manager_window)
|
||||
|
||||
global trayIcon
|
||||
trayIcon = QubesTrayIcon(QIcon(":/qubes.png"))
|
||||
trayIcon.show()
|
||||
|
@ -13,6 +13,7 @@ License: GPL
|
||||
URL: http://fixme
|
||||
Requires: python, PyQt4, qubes-core-dom0 > 1.7.23, kdebase
|
||||
Requires: pmount, cryptsetup, wmctrl
|
||||
Requires: dbus
|
||||
BuildRequires: PyQt4-devel
|
||||
AutoReq: 0
|
||||
|
||||
@ -64,6 +65,9 @@ cp qubes-manager.desktop $RPM_BUILD_ROOT/usr/share/applications
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/xdg/autostart/
|
||||
cp qubes-manager.desktop $RPM_BUILD_ROOT/etc/xdg/autostart/
|
||||
|
||||
install -D org.qubesos.QubesManager.conf $RPM_BUILD_ROOT/etc/dbus-1/system.d/org.qubesos.QubesManager.conf
|
||||
install -D org.qubesos.QubesManager.xml $RPM_BUILD_ROOT/usr/share/dbus-1/interfaces/org.qubesos.QubesManager.xml
|
||||
|
||||
%post
|
||||
update-desktop-database &> /dev/null || :
|
||||
killall -1 qubes-manager || :
|
||||
@ -152,3 +156,5 @@ rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
/usr/share/applications/qubes-manager.desktop
|
||||
/etc/xdg/autostart/qubes-manager.desktop
|
||||
/etc/dbus-1/system.d/org.qubesos.QubesManager.conf
|
||||
/usr/share/dbus-1/interfaces/org.qubesos.QubesManager.xml
|
||||
|
Loading…
Reference in New Issue
Block a user