| Server IP : 93.86.61.54 / Your IP : 216.73.216.60 Web Server : Apache/2.4.62 (Ubuntu) System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64 User : www-data ( 33) PHP Version : 8.4.22 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/lib/python3/dist-packages/blueman/main/ |
Upload File : |
from gi.repository import Gio, GLib
from blueman.gobject import SingletonGObjectMeta
class DBusProxyFailed(Exception):
pass
class ProxyBase(Gio.DBusProxy, metaclass=SingletonGObjectMeta):
def __init__(self, name: str, interface_name: str, object_path: str = "/", systembus: bool = False,
flags: Gio.DBusProxyFlags = Gio.DBusProxyFlags.NONE) -> None:
if systembus:
bustype = Gio.BusType.SYSTEM
else:
bustype = Gio.BusType.SESSION
super().__init__(
g_name=name,
g_interface_name=interface_name,
g_object_path=object_path,
g_bus_type=bustype,
g_flags=flags
)
try:
self.init()
except GLib.Error as e:
raise DBusProxyFailed(e.message)
class Mechanism(ProxyBase):
def __init__(self) -> None:
super().__init__(name='org.blueman.Mechanism', interface_name='org.blueman.Mechanism',
object_path="/org/blueman/mechanism", systembus=True)
class AppletService(ProxyBase):
def __init__(self) -> None:
super().__init__(name='org.blueman.Applet', interface_name='org.blueman.Applet',
object_path="/org/blueman/Applet")
class ManagerService(ProxyBase):
def __init__(self) -> None:
super().__init__(name="org.blueman.Manager", interface_name="org.freedesktop.Application",
object_path="/org/blueman/Manager",
flags=Gio.DBusProxyFlags.DO_NOT_AUTO_START_AT_CONSTRUCTION)
def _call_action(self, name: str) -> None:
def call_finish(proxy: "ManagerService", resp: Gio.AsyncResult) -> None:
proxy.call_finish(resp)
param = GLib.Variant('(sava{sv})', (name, [], {}))
self.call('ActivateAction', param, Gio.DBusCallFlags.NONE, -1, None, call_finish)
def startstop(self) -> None:
if self.get_name_owner() is None:
self._call_action("Activate")
else:
self._call_action("Quit")