annotate libervia/backend/plugins/plugin_adhoc_dbus.py @ 4340:ea72364131d5 default tip @

doc (components): Update Email Gateway documentation: A section has been added to explain how attachments are handled. fix 453
author Goffi <goffi@goffi.org>
date Tue, 03 Dec 2024 00:53:18 +0100
parents 0d7bb4df2343
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
1 #!/usr/bin/env python3
3137
559a625a236b fixed shebangs
Goffi <goffi@goffi.org>
parents: 3136
diff changeset
2
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # SAT plugin for adding D-Bus to Ad-Hoc Commands
3479
be6d91572633 date update
Goffi <goffi@goffi.org>
parents: 3140
diff changeset
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
20 from collections import OrderedDict
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
21 import os.path
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
22 import uuid
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
23
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
24 from twisted.internet import defer
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
25 from twisted.internet import reactor
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
26 from twisted.words.protocols.jabber import jid
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
27 from wokkel import data_form
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
28
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
29 from libervia.backend.core.constants import Const as C
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
30 from libervia.backend.core.i18n import D_, _
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
31 from libervia.backend.core.log import getLogger
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
32
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
33 log = getLogger(__name__)
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
34
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
35
1542
94901070478e plugins: added new MissingModule exceptions to plugins using third party modules
Goffi <goffi@goffi.org>
parents: 1540
diff changeset
36 try:
94901070478e plugins: added new MissingModule exceptions to plugins using third party modules
Goffi <goffi@goffi.org>
parents: 1540
diff changeset
37 from lxml import etree
94901070478e plugins: added new MissingModule exceptions to plugins using third party modules
Goffi <goffi@goffi.org>
parents: 1540
diff changeset
38 except ImportError:
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
39 etree = None
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
40 log.warning(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
41 "Missing module lxml, please download/install it from http://lxml.de/ ."
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
42 "Auto D-Bus discovery will be disabled"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
43 )
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
44
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
45 try:
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
46 import txdbus
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
47 from txdbus import client as dbus_client
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
48 except ImportError:
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
49 txdbus = None
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
50 log.warning(
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
51 "Missing module txdbus, please download/install it, auto D-Bus discovery will be "
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
52 "disabled"
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
53 )
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
54
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
55
3480
7550ae9cfbac Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
56 NS_MEDIA_PLAYER = "org.libervia.mediaplayer"
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 FD_NAME = "org.freedesktop.DBus"
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 FD_PATH = "/org/freedekstop/DBus"
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 INTROSPECT_IFACE = "org.freedesktop.DBus.Introspectable"
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
60 MPRIS_PREFIX = "org.mpris.MediaPlayer2"
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
61 CMD_GO_BACK = "GoBack"
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
62 CMD_GO_FWD = "GoFW"
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
63 SEEK_OFFSET = 5 * 1000 * 1000
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
64 MPRIS_COMMANDS = [
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
65 "org.mpris.MediaPlayer2.Player." + cmd
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
66 for cmd in ("Previous", CMD_GO_BACK, "PlayPause", CMD_GO_FWD, "Next")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
67 ]
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
68 MPRIS_PATH = "/org/mpris/MediaPlayer2"
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
69 MPRIS_PROPERTIES = OrderedDict(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
70 (
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
71 ("org.mpris.MediaPlayer2", ("Identity",)),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
72 (
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
73 "org.mpris.MediaPlayer2.Player",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
74 (
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
75 "Metadata",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
76 "PlaybackStatus",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
77 "Volume",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
78 ),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
79 ),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
80 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
81 )
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
82 MPRIS_METADATA_KEY = "Metadata"
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
83 MPRIS_METADATA_MAP = OrderedDict((("xesam:title", "Title"),))
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
84
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 INTROSPECT_METHOD = "Introspect"
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
86 IGNORED_IFACES_START = (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
87 "org.freedesktop",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
88 "org.qtproject",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
89 "org.kde.KMainWindow",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
90 ) # commands in interface starting with these values will be ignored
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
91 FLAG_LOOP = "LOOP"
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
92
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 PLUGIN_INFO = {
2145
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
94 C.PI_NAME: "Ad-Hoc Commands - D-Bus",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
95 C.PI_IMPORT_NAME: "AD_HOC_DBUS",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
96 C.PI_TYPE: "Misc",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
97 C.PI_PROTOCOLS: [],
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
98 C.PI_DEPENDENCIES: ["XEP-0050"],
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
99 C.PI_MAIN: "AdHocDBus",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
100 C.PI_HANDLER: "no",
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
101 C.PI_DESCRIPTION: _("""Add D-Bus management to Ad-Hoc commands"""),
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 }
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
103
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
104
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
105 class AdHocDBus:
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
106
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 def __init__(self, host):
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
108 log.info(f"plugin {PLUGIN_INFO[C.PI_NAME]!r} initialization")
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 self.host = host
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
110 if etree is not None:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
111 host.bridge.add_method(
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
112 "ad_hoc_dbus_add_auto",
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
113 ".plugin",
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
114 in_sign="sasasasasasass",
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
115 out_sign="(sa(sss))",
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
116 method=self._ad_hoc_dbus_add_auto,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
117 async_=True,
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
118 )
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
119 host.bridge.add_method(
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
120 "ad_hoc_remotes_get",
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
121 ".plugin",
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
122 in_sign="s",
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
123 out_sign="a(sss)",
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
124 method=self._ad_hoc_remotes_get,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
125 async_=True,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
126 )
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
127 self._c = host.plugins["XEP-0050"]
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
128 host.register_namespace("mediaplayer", NS_MEDIA_PLAYER)
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
129 self.session_con = None
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
130
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
131 async def profile_connected(self, client):
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
132 if txdbus is not None:
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
133 if self.session_con is None:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
134 self.session_con = await dbus_client.connect(reactor, "session")
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
135 self.fd_object = await self.session_con.getRemoteObject(FD_NAME, FD_PATH)
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
136
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
137 self._c.add_ad_hoc_command(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
138 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
139 self.local_media_cb,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
140 D_("Media Players"),
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
141 node=NS_MEDIA_PLAYER,
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
142 timeout=60 * 60 * 6, # 6 hours timeout, to avoid breaking remote
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
143 # in the middle of a movie
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
144 )
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
145
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
146 async def _dbus_async_call(self, proxy, method, *args, **kwargs):
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
147 """Call a DBus method asynchronously and return a deferred
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
148
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 @param proxy: DBus object proxy, as returner by get_object
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 @param method: name of the method to call
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 @param args: will be transmitted to the method
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
152 @param kwargs: will be transmetted to the method, except for the following poped
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
153 values:
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 - interface: name of the interface to use
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 @return: a deferred
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
156
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 """
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
158 return await proxy.callRemote(method, *args, **kwargs)
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
159
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
160 async def _dbus_get_property(self, proxy, interface, name):
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
161 return await self._dbus_async_call(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
162 proxy, "Get", interface, name, interface="org.freedesktop.DBus.Properties"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
163 )
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
164
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
165 async def _dbus_list_names(self):
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
166 return await self.fd_object.callRemote("ListNames")
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
167
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
168 async def _dbus_introspect(self, proxy):
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
169 return await self._dbus_async_call(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
170 proxy, INTROSPECT_METHOD, interface=INTROSPECT_IFACE
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
171 )
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
172
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
173 def _accept_method(self, method):
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
174 """Return True if we accept the method for a command
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
175 @param method: etree.Element
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
176 @return: True if the method is acceptable
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
177
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
178 """
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
179 if method.xpath(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
180 "arg[@direction='in']"
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
181 ): # we don't accept method with argument for the moment
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
182 return False
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
183 return True
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
184
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
185 async def _introspect(self, methods, bus_name, proxy):
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
186 log.debug("introspecting path [%s]" % proxy.object_path)
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
187 assert etree is not None
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
188 introspect_xml = await self._dbus_introspect(proxy)
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
189 el = etree.fromstring(introspect_xml)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
190 for node in el.iterchildren("node", "interface"):
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
191 if node.tag == "node":
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
192 new_path = os.path.join(proxy.object_path, node.get("name"))
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
193 new_proxy = await self.session_con.getRemoteObject(bus_name, new_path)
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
194 await self._introspect(methods, bus_name, new_proxy)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
195 elif node.tag == "interface":
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
196 name = node.get("name")
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
197 if any(name.startswith(ignored) for ignored in IGNORED_IFACES_START):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
198 log.debug("interface [%s] is ignored" % name)
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
199 continue
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
200 log.debug("introspecting interface [%s]" % name)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
201 for method in node.iterchildren("method"):
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
202 if self._accept_method(method):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
203 method_name = method.get("name")
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
204 log.debug("method accepted: [%s]" % method_name)
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
205 methods.add((proxy.object_path, name, method_name))
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
206
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
207 def _ad_hoc_dbus_add_auto(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
208 self,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
209 prog_name,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
210 allowed_jids,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
211 allowed_groups,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
212 allowed_magics,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
213 forbidden_jids,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
214 forbidden_groups,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
215 flags,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
216 profile_key,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
217 ):
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
218 client = self.host.get_client(profile_key)
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
219 return self.ad_hoc_dbus_add_auto(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
220 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
221 prog_name,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
222 allowed_jids,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
223 allowed_groups,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
224 allowed_magics,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
225 forbidden_jids,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
226 forbidden_groups,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
227 flags,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
228 )
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
229
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
230 async def ad_hoc_dbus_add_auto(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
231 self,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
232 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
233 prog_name,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
234 allowed_jids=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
235 allowed_groups=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
236 allowed_magics=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
237 forbidden_jids=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
238 forbidden_groups=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
239 flags=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
240 ):
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
241 bus_names = await self._dbus_list_names()
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
242 bus_names = [bus_name for bus_name in bus_names if "." + prog_name in bus_name]
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
243 if not bus_names:
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 916
diff changeset
244 log.info("Can't find any bus for [%s]" % prog_name)
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
245 return ("", [])
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
246 bus_names.sort()
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
247 for bus_name in bus_names:
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
248 if bus_name.endswith(prog_name):
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
249 break
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
250 else:
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
251 log.info(f"Can't find any command for {prog_name}")
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
252 return ("", [])
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
253 log.info(f"bus name found: {bus_name}")
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
254 proxy = await self.session_con.getRemoteObject(bus_name, "/")
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
255 methods = set()
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
256
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
257 await self._introspect(methods, bus_name, proxy)
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
258
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
259 if methods:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
260 self._add_command(
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
261 client,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
262 prog_name,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
263 bus_name,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
264 methods,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
265 allowed_jids=allowed_jids,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
266 allowed_groups=allowed_groups,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
267 allowed_magics=allowed_magics,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
268 forbidden_jids=forbidden_jids,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
269 forbidden_groups=forbidden_groups,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
270 flags=flags,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
271 )
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
272
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
273 return (str(bus_name), methods)
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
274
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
275 def _add_command(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
276 self,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
277 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
278 adhoc_name,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
279 bus_name,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
280 methods,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
281 allowed_jids=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
282 allowed_groups=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
283 allowed_magics=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
284 forbidden_jids=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
285 forbidden_groups=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
286 flags=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
287 ):
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
288 if flags is None:
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
289 flags = set()
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
290
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
291 async def d_bus_callback(client, command_elt, session_data, action, node):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
292 actions = session_data.setdefault("actions", [])
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
293 names_map = session_data.setdefault("names_map", {})
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
294 actions.append(action)
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
295
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
296 if len(actions) == 1:
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
297 # it's our first request, we ask the desired new status
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
298 status = self._c.STATUS.EXECUTING
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
299 form = data_form.Form("form", title=_("Command selection"))
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
300 options = []
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
301 for path, iface, command in methods:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
302 label = command.rsplit(".", 1)[-1]
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
303 name = str(uuid.uuid4())
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
304 names_map[name] = (path, iface, command)
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
305 options.append(data_form.Option(name, label))
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
306
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
307 field = data_form.Field(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
308 "list-single", "command", options=options, required=True
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
309 )
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
310 form.addField(field)
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
311
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
312 payload = form.toElement()
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
313 note = None
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
314
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
315 elif len(actions) == 2:
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
316 # we should have the answer here
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
317 try:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
318 x_elt = next(command_elt.elements(data_form.NS_X_DATA, "x"))
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
319 answer_form = data_form.Form.fromElement(x_elt)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
320 command = answer_form["command"]
1540
9a4e95c62380 plugin ad-hoc D-Bus: exception fixe + minor fixes
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
321 except (KeyError, StopIteration):
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
322 raise self._c.AdHocError(self._c.ERROR.BAD_PAYLOAD)
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
323
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
324 if command not in names_map:
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
325 raise self._c.AdHocError(self._c.ERROR.BAD_PAYLOAD)
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
326
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
327 path, iface, command = names_map[command]
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
328 proxy = await self.session_con.getRemoteObject(bus_name, path)
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
329
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
330 await self._dbus_async_call(proxy, command, interface=iface)
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
331
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
332 # job done, we can end the session, except if we have FLAG_LOOP
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
333 if FLAG_LOOP in flags:
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
334 # We have a loop, so we clear everything and we execute again the
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
335 # command as we had a first call (command_elt is not used, so None
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
336 # is OK)
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
337 del actions[:]
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
338 names_map.clear()
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
339 return await d_bus_callback(
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
340 client, None, session_data, self._c.ACTION.EXECUTE, node
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
341 )
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
342 form = data_form.Form("form", title=_("Updated"))
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
343 form.addField(data_form.Field("fixed", "Command sent"))
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
344 status = self._c.STATUS.COMPLETED
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
345 payload = None
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
346 note = (self._c.NOTE.INFO, _("Command sent"))
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
347 else:
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
348 raise self._c.AdHocError(self._c.ERROR.INTERNAL)
822
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
349
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
350 return (payload, status, None, note)
30ed86ea1c82 plugin Ad-Hoc D-Bus: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
351
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
352 self._c.add_ad_hoc_command(
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
353 client,
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
354 d_bus_callback,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
355 adhoc_name,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
356 allowed_jids=allowed_jids,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
357 allowed_groups=allowed_groups,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
358 allowed_magics=allowed_magics,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
359 forbidden_jids=forbidden_jids,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
360 forbidden_groups=forbidden_groups,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
361 )
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
362
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
363 ## Local media ##
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
364
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
365 def _ad_hoc_remotes_get(self, profile):
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
366 return self.ad_hoc_remotes_get(self.host.get_client(profile))
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
367
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
368 async def ad_hoc_remotes_get(self, client):
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
369 """Retrieve available remote media controlers in our devices
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
370 @return (list[tuple[unicode, unicode, unicode]]): list of devices with:
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
371 - entity full jid
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
372 - device name
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
373 - device label
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
374 """
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
375 found_data = await defer.ensureDeferred(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
376 self.host.find_by_features(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
377 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
378 [self.host.ns_map["commands"]],
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
379 service=False,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
380 roster=False,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
381 own_jid=True,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
382 local_device=True,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
383 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
384 )
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
385
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
386 remotes = []
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
387
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
388 for found in found_data:
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
389 for device_jid_s in found:
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
390 device_jid = jid.JID(device_jid_s)
4184
50c919dfe61b plugin XEP-0050: small code quality improvements + add `C.ENTITY_ADMINS` magic key to allow administrators profiles
Goffi <goffi@goffi.org>
parents: 4167
diff changeset
391 cmd_list = await self._c.list_commands(client, device_jid)
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
392 for cmd in cmd_list:
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
393 if cmd.nodeIdentifier == NS_MEDIA_PLAYER:
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
394 try:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
395 result_elt = await self._c.do(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
396 client, device_jid, NS_MEDIA_PLAYER, timeout=5
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
397 )
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
398 command_elt = self._c.get_command_elt(result_elt)
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
399 form = data_form.findForm(command_elt, NS_MEDIA_PLAYER)
3014
b6abf8af87db plugin ad-hoc D-Bus: fixed warning when no media player is found
Goffi <goffi@goffi.org>
parents: 3009
diff changeset
400 if form is None:
b6abf8af87db plugin ad-hoc D-Bus: fixed warning when no media player is found
Goffi <goffi@goffi.org>
parents: 3009
diff changeset
401 continue
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
402 mp_options = form.fields["media_player"].options
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
403 session_id = command_elt.getAttribute("sessionid")
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
404 if mp_options and session_id:
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
405 # we just want to discover player, so we cancel the
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
406 # session
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
407 self._c.do(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
408 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
409 device_jid,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
410 NS_MEDIA_PLAYER,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
411 action=self._c.ACTION.CANCEL,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
412 session_id=session_id,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
413 )
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
414
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
415 for opt in mp_options:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
416 remotes.append(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
417 (device_jid_s, opt.value, opt.label or opt.value)
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
418 )
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
419 except Exception as e:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
420 log.warning(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
421 _(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
422 "Can't retrieve remote controllers on {device_jid}: "
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
423 "{reason}".format(device_jid=device_jid, reason=e)
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
424 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
425 )
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
426 break
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
427 return remotes
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
428
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
429 async def do_mpris_command(self, proxy, command):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
430 iface, command = command.rsplit(".", 1)
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
431 if command == CMD_GO_BACK:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
432 command = "Seek"
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
433 args = [-SEEK_OFFSET]
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
434 elif command == CMD_GO_FWD:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
435 command = "Seek"
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
436 args = [SEEK_OFFSET]
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
437 else:
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
438 args = []
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
439 return await self._dbus_async_call(proxy, command, *args, interface=iface)
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
440
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
441 def add_mpris_metadata(self, form, metadata):
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
442 """Serialise MRPIS Metadata according to MPRIS_METADATA_MAP"""
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
443 for mpris_key, name in MPRIS_METADATA_MAP.items():
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
444 if mpris_key in metadata:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
445 value = str(metadata[mpris_key])
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
446 form.addField(data_form.Field(fieldType="fixed", var=name, value=value))
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
447
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
448 async def local_media_cb(self, client, command_elt, session_data, action, node):
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
449 assert txdbus is not None
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
450 try:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
451 x_elt = next(command_elt.elements(data_form.NS_X_DATA, "x"))
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
452 command_form = data_form.Form.fromElement(x_elt)
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
453 except StopIteration:
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
454 command_form = None
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
455
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
456 if command_form is None or len(command_form.fields) == 0:
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
457 # root request, we looks for media players
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
458 bus_names = await self._dbus_list_names()
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
459 bus_names = [b for b in bus_names if b.startswith(MPRIS_PREFIX)]
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
460 if len(bus_names) == 0:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
461 note = (self._c.NOTE.INFO, D_("No media player found."))
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
462 return (None, self._c.STATUS.COMPLETED, None, note)
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
463 options = []
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
464 status = self._c.STATUS.EXECUTING
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
465 form = data_form.Form(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
466 "form", title=D_("Media Player Selection"), formNamespace=NS_MEDIA_PLAYER
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
467 )
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
468 for bus in bus_names:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
469 player_name = bus[len(MPRIS_PREFIX) + 1 :]
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
470 if not player_name:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
471 log.warning(_("Ignoring MPRIS bus without suffix"))
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
472 continue
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
473 options.append(data_form.Option(bus, player_name))
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
474 field = data_form.Field(
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
475 "list-single", "media_player", options=options, required=True
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
476 )
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
477 form.addField(field)
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
478 payload = form.toElement()
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
479 return (payload, status, None, None)
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
480 else:
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
481 # player request
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
482 try:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
483 bus_name = command_form["media_player"]
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
484 except KeyError:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
485 raise ValueError(_("missing media_player value"))
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
486
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
487 if not bus_name.startswith(MPRIS_PREFIX):
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
488 log.warning(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
489 _(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
490 "Media player ad-hoc command trying to use non MPRIS bus. "
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
491 "Hack attempt? Refused bus: {bus_name}"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
492 ).format(bus_name=bus_name)
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
493 )
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
494 note = (self._c.NOTE.ERROR, D_("Invalid player name."))
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
495 return (None, self._c.STATUS.COMPLETED, None, note)
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
496
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
497 try:
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
498 proxy = await self.session_con.getRemoteObject(
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
499 bus_name, MPRIS_PATH, "org.mpris.MediaPlayer2.Player"
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
500 )
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
501 except Exception as e:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
502 log.warning(_("Can't get D-Bus proxy: {reason}").format(reason=e))
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
503 note = (self._c.NOTE.ERROR, D_("Media player is not available anymore"))
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
504 return (None, self._c.STATUS.COMPLETED, None, note)
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
505 try:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
506 command = command_form["command"]
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
507 except KeyError:
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
508 pass
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
509 else:
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
510 await self.do_mpris_command(proxy, command)
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
511
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
512 # we construct the remote control form
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
513 form = data_form.Form("form", title=D_("Media Player Selection"))
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
514 form.addField(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
515 data_form.Field(fieldType="hidden", var="media_player", value=bus_name)
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
516 )
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
517 for iface, properties_names in MPRIS_PROPERTIES.items():
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
518 for name in properties_names:
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
519 try:
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
520 value = await self._dbus_get_property(proxy, iface, name)
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
521 except Exception as e:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
522 log.warning(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
523 _("Can't retrieve attribute {name}: {reason}").format(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
524 name=name, reason=e
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
525 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
526 )
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
527 continue
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
528 if name == MPRIS_METADATA_KEY:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
529 self.add_mpris_metadata(form, value)
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
530 else:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
531 form.addField(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
532 data_form.Field(fieldType="fixed", var=name, value=str(value))
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
533 )
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
534
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 3014
diff changeset
535 commands = [data_form.Option(c, c.rsplit(".", 1)[1]) for c in MPRIS_COMMANDS]
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
536 form.addField(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
537 data_form.Field(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
538 fieldType="list-single",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
539 var="command",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
540 options=commands,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
541 required=True,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
542 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4184
diff changeset
543 )
2667
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
544
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
545 payload = form.toElement()
8dd9db785ac8 plugin XEP-0050, adhoc D-Bus: Ad-Hoc improvment + remote media control:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
546 status = self._c.STATUS.EXECUTING
4167
319a0e47dc8b plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
547 return (payload, status, None, None)