comparison cagou/plugins/plugin_wid_remote.py @ 492:5114bbb5daa3

plugin remove: update `action_launch` call following changes in bridge API
author Goffi <goffi@goffi.org>
date Fri, 02 Jun 2023 17:53:09 +0200
parents 203755bbe0fe
children
comparison
equal deleted inserted replaced
491:203755bbe0fe 492:5114bbb5daa3
25 from ..core.constants import Const as C 25 from ..core.constants import Const as C
26 from ..core.behaviors import TouchMenuBehavior, FilterBehavior 26 from ..core.behaviors import TouchMenuBehavior, FilterBehavior
27 from ..core.common_widgets import (Identities, ItemWidget, DeviceWidget, 27 from ..core.common_widgets import (Identities, ItemWidget, DeviceWidget,
28 CategorySeparator) 28 CategorySeparator)
29 from sat.tools.common import template_xmlui 29 from sat.tools.common import template_xmlui
30 from sat.tools.common import data_format
30 from cagou.core import xmlui 31 from cagou.core import xmlui
31 from sat_frontends.tools import jid 32 from sat_frontends.tools import jid
32 from kivy import properties 33 from kivy import properties
33 from kivy.uix.label import Label 34 from kivy.uix.label import Label
34 from kivy.uix.boxlayout import BoxLayout 35 from kivy.uix.boxlayout import BoxLayout
73 74
74 @property 75 @property
75 def profile(self): 76 def profile(self):
76 return self.main_wid.profile 77 return self.main_wid.profile
77 78
78 def update_ui(self, action_data): 79 def update_ui(self, action_data_s):
80 action_data = data_format.deserialise(action_data_s)
79 xmlui_raw = action_data['xmlui'] 81 xmlui_raw = action_data['xmlui']
80 ui_tpl = template_xmlui.create(G.host, xmlui_raw) 82 ui_tpl = template_xmlui.create(G.host, xmlui_raw)
81 self.ui_tpl = ui_tpl 83 self.ui_tpl = ui_tpl
82 for prop in ('Title', 'Identity'): 84 for prop in ('Title', 'Identity'):
83 try: 85 try:
102 def ad_hoc_run_cb(self, xmlui_raw): 104 def ad_hoc_run_cb(self, xmlui_raw):
103 ui_tpl = template_xmlui.create(G.host, xmlui_raw) 105 ui_tpl = template_xmlui.create(G.host, xmlui_raw)
104 data = {xmlui.XMLUIPanel.escape("media_player"): self.remote_item.node, 106 data = {xmlui.XMLUIPanel.escape("media_player"): self.remote_item.node,
105 "session_id": ui_tpl.session_id} 107 "session_id": ui_tpl.session_id}
106 G.host.bridge.action_launch( 108 G.host.bridge.action_launch(
107 ui_tpl.submit_id, data, self.profile, 109 ui_tpl.submit_id, data_format.serialise(data),
108 callback=self.update_ui, 110 self.profile, callback=self.update_ui,
109 errback=self.main_wid.errback) 111 errback=self.main_wid.errback
112 )
110 113
111 def on_remote_item(self, __, remote): 114 def on_remote_item(self, __, remote):
112 NS_MEDIA_PLAYER = G.host.ns_map["mediaplayer"] 115 NS_MEDIA_PLAYER = G.host.ns_map["mediaplayer"]
113 G.host.bridge.ad_hoc_run(str(remote.device_jid), NS_MEDIA_PLAYER, self.profile, 116 G.host.bridge.ad_hoc_run(str(remote.device_jid), NS_MEDIA_PLAYER, self.profile,
114 callback=self.ad_hoc_run_cb, 117 callback=self.ad_hoc_run_cb,
129 # but here we have to add them by hand 132 # but here we have to add them by hand
130 hidden = {xmlui.XMLUIPanel.escape(k):v 133 hidden = {xmlui.XMLUIPanel.escape(k):v
131 for k,v in self.ui_tpl.hidden.items()} 134 for k,v in self.ui_tpl.hidden.items()}
132 data.update(hidden) 135 data.update(hidden)
133 G.host.bridge.action_launch( 136 G.host.bridge.action_launch(
134 self.ui_tpl.submit_id, data, self.profile, 137 self.ui_tpl.submit_id, data_format.serialise(data), self.profile,
135 callback=self.update_ui, 138 callback=self.update_ui, errback=self.main_wid.errback
136 errback=self.main_wid.errback) 139 )
137 140
138 141
139 class RemoteDeviceWidget(DeviceWidget): 142 class RemoteDeviceWidget(DeviceWidget):
140 143
141 def xmlui_cb(self, data, cb_id, profile): 144 def xmlui_cb(self, data, cb_id, profile):