Coverage for /home/antoine/projects/xpra-git/dist/python3/lib64/python/xpra/server/source/dbus_mixin.py : 100%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- coding: utf-8 -*-
2# This file is part of Xpra.
3# Copyright (C) 2010-2020 Antoine Martin <antoine@xpra.org>
4# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
5# later version. See the file COPYING for details.
7from xpra.server.source.stub_source_mixin import StubSourceMixin
8from xpra.util import typedict
11"""
12Expose the ClientConnection using a dbus service
13"""
14class DBUS_Mixin(StubSourceMixin):
16 @classmethod
17 def is_needed(cls, caps : typedict) -> bool:
18 #the DBUSSource we create is only useful if the client
19 #supports one of the mixins it exposes:
20 return caps.boolget("windows", False) or caps.boolget("sound", False)
22 def __init__(self):
23 self.dbus_control = False
24 self.dbus_server = None
26 def init_from(self, _protocol, server):
27 self.dbus_control = server.dbus_control
29 def init_state(self):
30 if self.dbus_control:
31 from xpra.server.dbus.dbus_common import dbus_exception_wrap
32 def make_dbus_server():
33 import os
34 from xpra.server.dbus.dbus_source import DBUS_Source
35 return DBUS_Source(self, os.environ.get("DISPLAY", "").lstrip(":"))
36 self.dbus_server = dbus_exception_wrap(make_dbus_server, "setting up client dbus instance")
38 def cleanup(self):
39 ds = self.dbus_server
40 if ds:
41 self.dbus_server = None
42 self.idle_add(ds.cleanup)