comparison sat_frontends/quick_frontend/quick_app.py @ 4041:2594e1951cf7

core (bridge): `action_new` now use serialised dict for extra data.
author Goffi <goffi@goffi.org>
date Mon, 15 May 2023 16:20:45 +0200
parents 524856bd7b19
children 4b842c1fb686
comparison
equal deleted inserted replaced
4040:1f967f85fc23 4041:2594e1951cf7
740 self.contact_lists[profile].disconnect() 740 self.contact_lists[profile].disconnect()
741 # FIXME: see note on connected_handler 741 # FIXME: see note on connected_handler
742 self.sync = False 742 self.sync = False
743 self.set_presence_status(C.PRESENCE_UNAVAILABLE, "", profile=profile) 743 self.set_presence_status(C.PRESENCE_UNAVAILABLE, "", profile=profile)
744 744
745 def action_new_handler(self, action_data, id_, security_limit, profile): 745 def action_new_handler(self, action_data_s, id_, security_limit, profile):
746 self.action_manager(action_data, user_action=False, profile=profile) 746 self.action_manager(
747 data_format.deserialise(action_data_s), user_action=False, profile=profile
748 )
747 749
748 def contact_new_handler(self, jid_s, attributes, groups, profile): 750 def contact_new_handler(self, jid_s, attributes, groups, profile):
749 entity = jid.JID(jid_s) 751 entity = jid.JID(jid_s)
750 groups = list(groups) 752 groups = list(groups)
751 self.contact_lists[profile].set_contact(entity, groups, attributes, in_roster=True) 753 self.contact_lists[profile].set_contact(entity, groups, attributes, in_roster=True)
1296 else: 1298 else:
1297 if progress_cb or progress_eb: 1299 if progress_cb or progress_eb:
1298 self.register_progress_cbs(progress_id, progress_cb, progress_eb) 1300 self.register_progress_cbs(progress_id, progress_cb, progress_eb)
1299 self.progress_id_handler(progress_id, profile) 1301 self.progress_id_handler(progress_id, profile)
1300 1302
1301 # we ignore metadata
1302 action_data = {
1303 k: v for k, v in action_data.items() if not k.startswith("meta_")
1304 }
1305
1306 if action_data:
1307 raise exceptions.DataError(
1308 "Not all keys in action_data are managed ({keys})".format(
1309 keys=", ".join(list(action_data.keys()))
1310 )
1311 )
1312
1313 def _action_cb(self, data, callback, callback_id, profile): 1303 def _action_cb(self, data, callback, callback_id, profile):
1314 if callback is None: 1304 if callback is None:
1315 self.action_manager(data, profile=profile) 1305 self.action_manager(data, profile=profile)
1316 else: 1306 else:
1317 callback(data=data, cb_id=callback_id, profile=profile) 1307 callback(data=data, cb_id=callback_id, profile=profile)
1332 @param profile: %(doc_profile)s 1322 @param profile: %(doc_profile)s
1333 1323
1334 """ 1324 """
1335 if data is None: 1325 if data is None:
1336 data = dict() 1326 data = dict()
1337 action_cb = lambda data: self._action_cb(data, callback, callback_id, profile) 1327 action_cb = lambda data: self._action_cb(
1328 data_format.deserialise(data), callback, callback_id, profile
1329 )
1338 self.bridge.action_launch( 1330 self.bridge.action_launch(
1339 callback_id, data, profile, callback=action_cb, errback=self.dialog_failure 1331 callback_id, data_format.serialise(data), profile, callback=action_cb,
1332 errback=self.dialog_failure
1340 ) 1333 )
1341 1334
1342 def launch_menu( 1335 def launch_menu(
1343 self, 1336 self,
1344 menu_type, 1337 menu_type,