Mercurial > libervia-backend
comparison libervia/backend/bridge/dbus_bridge.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 730f542e4ad0 |
children | 4cf98f506269 |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
29 | 29 |
30 log = getLogger(__name__) | 30 log = getLogger(__name__) |
31 | 31 |
32 # Interface prefix | 32 # Interface prefix |
33 const_INT_PREFIX = config.config_get( | 33 const_INT_PREFIX = config.config_get( |
34 config.parse_main_conf(), | 34 config.parse_main_conf(), "", "bridge_dbus_int_prefix", "org.libervia.Libervia" |
35 "", | 35 ) |
36 "bridge_dbus_int_prefix", | |
37 "org.libervia.Libervia") | |
38 const_ERROR_PREFIX = const_INT_PREFIX + ".error" | 36 const_ERROR_PREFIX = const_INT_PREFIX + ".error" |
39 const_OBJ_PATH = "/org/libervia/Libervia/bridge" | 37 const_OBJ_PATH = "/org/libervia/Libervia/bridge" |
40 const_CORE_SUFFIX = ".core" | 38 const_CORE_SUFFIX = ".core" |
41 const_PLUGIN_SUFFIX = ".plugin" | 39 const_PLUGIN_SUFFIX = ".plugin" |
42 | 40 |
86 | 84 |
87 class DBusObject(objects.DBusObject): | 85 class DBusObject(objects.DBusObject): |
88 | 86 |
89 core_iface = DBusInterface( | 87 core_iface = DBusInterface( |
90 const_INT_PREFIX + const_CORE_SUFFIX, | 88 const_INT_PREFIX + const_CORE_SUFFIX, |
91 Method('action_launch', arguments='sss', returns='s'), | 89 Method("action_launch", arguments="sss", returns="s"), |
92 Method('actions_get', arguments='s', returns='a(ssi)'), | 90 Method("actions_get", arguments="s", returns="a(ssi)"), |
93 Method('config_get', arguments='ss', returns='s'), | 91 Method("config_get", arguments="ss", returns="s"), |
94 Method('connect', arguments='ssa{ss}', returns='b'), | 92 Method("connect", arguments="ssa{ss}", returns="b"), |
95 Method('contact_add', arguments='ss', returns=''), | 93 Method("contact_add", arguments="ss", returns=""), |
96 Method('contact_del', arguments='ss', returns=''), | 94 Method("contact_del", arguments="ss", returns=""), |
97 Method('contact_get', arguments='ss', returns='(a{ss}as)'), | 95 Method("contact_get", arguments="ss", returns="(a{ss}as)"), |
98 Method('contact_update', arguments='ssass', returns=''), | 96 Method("contact_update", arguments="ssass", returns=""), |
99 Method('contacts_get', arguments='s', returns='a(sa{ss}as)'), | 97 Method("contacts_get", arguments="s", returns="a(sa{ss}as)"), |
100 Method('contacts_get_from_group', arguments='ss', returns='as'), | 98 Method("contacts_get_from_group", arguments="ss", returns="as"), |
101 Method('devices_infos_get', arguments='ss', returns='s'), | 99 Method("devices_infos_get", arguments="ss", returns="s"), |
102 Method('disco_find_by_features', arguments='asa(ss)bbbbbs', returns='(a{sa(sss)}a{sa(sss)}a{sa(sss)})'), | 100 Method( |
103 Method('disco_infos', arguments='ssbs', returns='(asa(sss)a{sa(a{ss}as)})'), | 101 "disco_find_by_features", |
104 Method('disco_items', arguments='ssbs', returns='a(sss)'), | 102 arguments="asa(ss)bbbbbs", |
105 Method('disconnect', arguments='s', returns=''), | 103 returns="(a{sa(sss)}a{sa(sss)}a{sa(sss)})", |
106 Method('encryption_namespace_get', arguments='s', returns='s'), | 104 ), |
107 Method('encryption_plugins_get', arguments='', returns='s'), | 105 Method("disco_infos", arguments="ssbs", returns="(asa(sss)a{sa(a{ss}as)})"), |
108 Method('encryption_trust_ui_get', arguments='sss', returns='s'), | 106 Method("disco_items", arguments="ssbs", returns="a(sss)"), |
109 Method('entities_data_get', arguments='asass', returns='a{sa{ss}}'), | 107 Method("disconnect", arguments="s", returns=""), |
110 Method('entity_data_get', arguments='sass', returns='a{ss}'), | 108 Method("encryption_namespace_get", arguments="s", returns="s"), |
111 Method('features_get', arguments='s', returns='a{sa{ss}}'), | 109 Method("encryption_plugins_get", arguments="", returns="s"), |
112 Method('history_get', arguments='ssiba{ss}s', returns='a(sdssa{ss}a{ss}ss)'), | 110 Method("encryption_trust_ui_get", arguments="sss", returns="s"), |
113 Method('image_check', arguments='s', returns='s'), | 111 Method("entities_data_get", arguments="asass", returns="a{sa{ss}}"), |
114 Method('image_convert', arguments='ssss', returns='s'), | 112 Method("entity_data_get", arguments="sass", returns="a{ss}"), |
115 Method('image_generate_preview', arguments='ss', returns='s'), | 113 Method("features_get", arguments="s", returns="a{sa{ss}}"), |
116 Method('image_resize', arguments='sii', returns='s'), | 114 Method("history_get", arguments="ssiba{ss}s", returns="a(sdssa{ss}a{ss}ss)"), |
117 Method('init_pre_script', arguments='', returns=''), | 115 Method("image_check", arguments="s", returns="s"), |
118 Method('is_connected', arguments='s', returns='b'), | 116 Method("image_convert", arguments="ssss", returns="s"), |
119 Method('main_resource_get', arguments='ss', returns='s'), | 117 Method("image_generate_preview", arguments="ss", returns="s"), |
120 Method('menu_help_get', arguments='ss', returns='s'), | 118 Method("image_resize", arguments="sii", returns="s"), |
121 Method('menu_launch', arguments='sasa{ss}is', returns='a{ss}'), | 119 Method("init_pre_script", arguments="", returns=""), |
122 Method('menus_get', arguments='si', returns='a(ssasasa{ss})'), | 120 Method("is_connected", arguments="s", returns="b"), |
123 Method('message_encryption_get', arguments='ss', returns='s'), | 121 Method("main_resource_get", arguments="ss", returns="s"), |
124 Method('message_encryption_start', arguments='ssbs', returns=''), | 122 Method("menu_help_get", arguments="ss", returns="s"), |
125 Method('message_encryption_stop', arguments='ss', returns=''), | 123 Method("menu_launch", arguments="sasa{ss}is", returns="a{ss}"), |
126 Method('message_send', arguments='sa{ss}a{ss}sss', returns=''), | 124 Method("menus_get", arguments="si", returns="a(ssasasa{ss})"), |
127 Method('namespaces_get', arguments='', returns='a{ss}'), | 125 Method("message_encryption_get", arguments="ss", returns="s"), |
128 Method('notification_add', arguments='ssssbbsdss', returns=''), | 126 Method("message_encryption_start", arguments="ssbs", returns=""), |
129 Method('notification_delete', arguments='sbs', returns=''), | 127 Method("message_encryption_stop", arguments="ss", returns=""), |
130 Method('notifications_expired_clean', arguments='ds', returns=''), | 128 Method("message_send", arguments="sa{ss}a{ss}sss", returns=""), |
131 Method('notifications_get', arguments='ss', returns='s'), | 129 Method("namespaces_get", arguments="", returns="a{ss}"), |
132 Method('param_get_a', arguments='ssss', returns='s'), | 130 Method("notification_add", arguments="ssssbbsdss", returns=""), |
133 Method('param_get_a_async', arguments='sssis', returns='s'), | 131 Method("notification_delete", arguments="sbs", returns=""), |
134 Method('param_set', arguments='sssis', returns=''), | 132 Method("notifications_expired_clean", arguments="ds", returns=""), |
135 Method('param_ui_get', arguments='isss', returns='s'), | 133 Method("notifications_get", arguments="ss", returns="s"), |
136 Method('params_categories_get', arguments='', returns='as'), | 134 Method("param_get_a", arguments="ssss", returns="s"), |
137 Method('params_register_app', arguments='sis', returns=''), | 135 Method("param_get_a_async", arguments="sssis", returns="s"), |
138 Method('params_template_load', arguments='s', returns='b'), | 136 Method("param_set", arguments="sssis", returns=""), |
139 Method('params_template_save', arguments='s', returns='b'), | 137 Method("param_ui_get", arguments="isss", returns="s"), |
140 Method('params_values_from_category_get_async', arguments='sisss', returns='a{ss}'), | 138 Method("params_categories_get", arguments="", returns="as"), |
141 Method('presence_set', arguments='ssa{ss}s', returns=''), | 139 Method("params_register_app", arguments="sis", returns=""), |
142 Method('presence_statuses_get', arguments='s', returns='a{sa{s(sia{ss})}}'), | 140 Method("params_template_load", arguments="s", returns="b"), |
143 Method('private_data_delete', arguments='sss', returns=''), | 141 Method("params_template_save", arguments="s", returns="b"), |
144 Method('private_data_get', arguments='sss', returns='s'), | 142 Method( |
145 Method('private_data_set', arguments='ssss', returns=''), | 143 "params_values_from_category_get_async", arguments="sisss", returns="a{ss}" |
146 Method('profile_create', arguments='sss', returns=''), | 144 ), |
147 Method('profile_delete_async', arguments='s', returns=''), | 145 Method("presence_set", arguments="ssa{ss}s", returns=""), |
148 Method('profile_is_session_started', arguments='s', returns='b'), | 146 Method("presence_statuses_get", arguments="s", returns="a{sa{s(sia{ss})}}"), |
149 Method('profile_name_get', arguments='s', returns='s'), | 147 Method("private_data_delete", arguments="sss", returns=""), |
150 Method('profile_set_default', arguments='s', returns=''), | 148 Method("private_data_get", arguments="sss", returns="s"), |
151 Method('profile_start_session', arguments='ss', returns='b'), | 149 Method("private_data_set", arguments="ssss", returns=""), |
152 Method('profiles_list_get', arguments='bb', returns='as'), | 150 Method("profile_create", arguments="sss", returns=""), |
153 Method('progress_get', arguments='ss', returns='a{ss}'), | 151 Method("profile_delete_async", arguments="s", returns=""), |
154 Method('progress_get_all', arguments='s', returns='a{sa{sa{ss}}}'), | 152 Method("profile_is_session_started", arguments="s", returns="b"), |
155 Method('progress_get_all_metadata', arguments='s', returns='a{sa{sa{ss}}}'), | 153 Method("profile_name_get", arguments="s", returns="s"), |
156 Method('ready_get', arguments='', returns=''), | 154 Method("profile_set_default", arguments="s", returns=""), |
157 Method('roster_resync', arguments='s', returns=''), | 155 Method("profile_start_session", arguments="ss", returns="b"), |
158 Method('session_infos_get', arguments='s', returns='a{ss}'), | 156 Method("profiles_list_get", arguments="bb", returns="as"), |
159 Method('sub_waiting_get', arguments='s', returns='a{ss}'), | 157 Method("progress_get", arguments="ss", returns="a{ss}"), |
160 Method('subscription', arguments='sss', returns=''), | 158 Method("progress_get_all", arguments="s", returns="a{sa{sa{ss}}}"), |
161 Method('version_get', arguments='', returns='s'), | 159 Method("progress_get_all_metadata", arguments="s", returns="a{sa{sa{ss}}}"), |
162 Signal('_debug', 'sa{ss}s'), | 160 Method("ready_get", arguments="", returns=""), |
163 Signal('action_new', 'ssis'), | 161 Method("roster_resync", arguments="s", returns=""), |
164 Signal('connected', 'ss'), | 162 Method("session_infos_get", arguments="s", returns="a{ss}"), |
165 Signal('contact_deleted', 'ss'), | 163 Method("sub_waiting_get", arguments="s", returns="a{ss}"), |
166 Signal('contact_new', 'sa{ss}ass'), | 164 Method("subscription", arguments="sss", returns=""), |
167 Signal('disconnected', 's'), | 165 Method("version_get", arguments="", returns="s"), |
168 Signal('entity_data_updated', 'ssss'), | 166 Signal("_debug", "sa{ss}s"), |
169 Signal('message_encryption_started', 'sss'), | 167 Signal("action_new", "ssis"), |
170 Signal('message_encryption_stopped', 'sa{ss}s'), | 168 Signal("connected", "ss"), |
171 Signal('message_new', 'sdssa{ss}a{ss}sss'), | 169 Signal("contact_deleted", "ss"), |
172 Signal('message_update', 'ssss'), | 170 Signal("contact_new", "sa{ss}ass"), |
173 Signal('notification_deleted', 'ss'), | 171 Signal("disconnected", "s"), |
174 Signal('notification_new', 'sdssssbidss'), | 172 Signal("entity_data_updated", "ssss"), |
175 Signal('param_update', 'ssss'), | 173 Signal("message_encryption_started", "sss"), |
176 Signal('presence_update', 'ssia{ss}s'), | 174 Signal("message_encryption_stopped", "sa{ss}s"), |
177 Signal('progress_error', 'sss'), | 175 Signal("message_new", "sdssa{ss}a{ss}sss"), |
178 Signal('progress_finished', 'sa{ss}s'), | 176 Signal("message_update", "ssss"), |
179 Signal('progress_started', 'sa{ss}s'), | 177 Signal("notification_deleted", "ss"), |
180 Signal('subscribe', 'sss'), | 178 Signal("notification_new", "sdssssbidss"), |
179 Signal("param_update", "ssss"), | |
180 Signal("presence_update", "ssia{ss}s"), | |
181 Signal("progress_error", "sss"), | |
182 Signal("progress_finished", "sa{ss}s"), | |
183 Signal("progress_started", "sa{ss}s"), | |
184 Signal("subscribe", "sss"), | |
181 ) | 185 ) |
182 plugin_iface = DBusInterface( | 186 plugin_iface = DBusInterface(const_INT_PREFIX + const_PLUGIN_SUFFIX) |
183 const_INT_PREFIX + const_PLUGIN_SUFFIX | |
184 ) | |
185 | 187 |
186 dbusInterfaces = [core_iface, plugin_iface] | 188 dbusInterfaces = [core_iface, plugin_iface] |
187 | 189 |
188 def __init__(self, path): | 190 def __init__(self, path): |
189 super().__init__(path) | 191 super().__init__(path) |
211 return self._callback("actions_get", profile_key) | 213 return self._callback("actions_get", profile_key) |
212 | 214 |
213 def dbus_config_get(self, section, name): | 215 def dbus_config_get(self, section, name): |
214 return self._callback("config_get", section, name) | 216 return self._callback("config_get", section, name) |
215 | 217 |
216 def dbus_connect(self, profile_key="@DEFAULT@", password='', options={}): | 218 def dbus_connect(self, profile_key="@DEFAULT@", password="", options={}): |
217 return self._callback("connect", profile_key, password, options) | 219 return self._callback("connect", profile_key, password, options) |
218 | 220 |
219 def dbus_contact_add(self, entity_jid, profile_key="@DEFAULT@"): | 221 def dbus_contact_add(self, entity_jid, profile_key="@DEFAULT@"): |
220 return self._callback("contact_add", entity_jid, profile_key) | 222 return self._callback("contact_add", entity_jid, profile_key) |
221 | 223 |
235 return self._callback("contacts_get_from_group", group, profile_key) | 237 return self._callback("contacts_get_from_group", group, profile_key) |
236 | 238 |
237 def dbus_devices_infos_get(self, bare_jid, profile_key): | 239 def dbus_devices_infos_get(self, bare_jid, profile_key): |
238 return self._callback("devices_infos_get", bare_jid, profile_key) | 240 return self._callback("devices_infos_get", bare_jid, profile_key) |
239 | 241 |
240 def dbus_disco_find_by_features(self, namespaces, identities, bare_jid=False, service=True, roster=True, own_jid=True, local_device=False, profile_key="@DEFAULT@"): | 242 def dbus_disco_find_by_features( |
241 return self._callback("disco_find_by_features", namespaces, identities, bare_jid, service, roster, own_jid, local_device, profile_key) | 243 self, |
242 | 244 namespaces, |
243 def dbus_disco_infos(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@"): | 245 identities, |
246 bare_jid=False, | |
247 service=True, | |
248 roster=True, | |
249 own_jid=True, | |
250 local_device=False, | |
251 profile_key="@DEFAULT@", | |
252 ): | |
253 return self._callback( | |
254 "disco_find_by_features", | |
255 namespaces, | |
256 identities, | |
257 bare_jid, | |
258 service, | |
259 roster, | |
260 own_jid, | |
261 local_device, | |
262 profile_key, | |
263 ) | |
264 | |
265 def dbus_disco_infos( | |
266 self, entity_jid, node="", use_cache=True, profile_key="@DEFAULT@" | |
267 ): | |
244 return self._callback("disco_infos", entity_jid, node, use_cache, profile_key) | 268 return self._callback("disco_infos", entity_jid, node, use_cache, profile_key) |
245 | 269 |
246 def dbus_disco_items(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@"): | 270 def dbus_disco_items( |
271 self, entity_jid, node="", use_cache=True, profile_key="@DEFAULT@" | |
272 ): | |
247 return self._callback("disco_items", entity_jid, node, use_cache, profile_key) | 273 return self._callback("disco_items", entity_jid, node, use_cache, profile_key) |
248 | 274 |
249 def dbus_disconnect(self, profile_key="@DEFAULT@"): | 275 def dbus_disconnect(self, profile_key="@DEFAULT@"): |
250 return self._callback("disconnect", profile_key) | 276 return self._callback("disconnect", profile_key) |
251 | 277 |
252 def dbus_encryption_namespace_get(self, arg_0): | 278 def dbus_encryption_namespace_get(self, arg_0): |
253 return self._callback("encryption_namespace_get", arg_0) | 279 return self._callback("encryption_namespace_get", arg_0) |
254 | 280 |
255 def dbus_encryption_plugins_get(self, ): | 281 def dbus_encryption_plugins_get( |
256 return self._callback("encryption_plugins_get", ) | 282 self, |
283 ): | |
284 return self._callback( | |
285 "encryption_plugins_get", | |
286 ) | |
257 | 287 |
258 def dbus_encryption_trust_ui_get(self, to_jid, namespace, profile_key): | 288 def dbus_encryption_trust_ui_get(self, to_jid, namespace, profile_key): |
259 return self._callback("encryption_trust_ui_get", to_jid, namespace, profile_key) | 289 return self._callback("encryption_trust_ui_get", to_jid, namespace, profile_key) |
260 | 290 |
261 def dbus_entities_data_get(self, jids, keys, profile): | 291 def dbus_entities_data_get(self, jids, keys, profile): |
265 return self._callback("entity_data_get", jid, keys, profile) | 295 return self._callback("entity_data_get", jid, keys, profile) |
266 | 296 |
267 def dbus_features_get(self, profile_key): | 297 def dbus_features_get(self, profile_key): |
268 return self._callback("features_get", profile_key) | 298 return self._callback("features_get", profile_key) |
269 | 299 |
270 def dbus_history_get(self, from_jid, to_jid, limit, between=True, filters='', profile="@NONE@"): | 300 def dbus_history_get( |
271 return self._callback("history_get", from_jid, to_jid, limit, between, filters, profile) | 301 self, from_jid, to_jid, limit, between=True, filters="", profile="@NONE@" |
302 ): | |
303 return self._callback( | |
304 "history_get", from_jid, to_jid, limit, between, filters, profile | |
305 ) | |
272 | 306 |
273 def dbus_image_check(self, arg_0): | 307 def dbus_image_check(self, arg_0): |
274 return self._callback("image_check", arg_0) | 308 return self._callback("image_check", arg_0) |
275 | 309 |
276 def dbus_image_convert(self, source, dest, arg_2, extra): | 310 def dbus_image_convert(self, source, dest, arg_2, extra): |
280 return self._callback("image_generate_preview", image_path, profile_key) | 314 return self._callback("image_generate_preview", image_path, profile_key) |
281 | 315 |
282 def dbus_image_resize(self, image_path, width, height): | 316 def dbus_image_resize(self, image_path, width, height): |
283 return self._callback("image_resize", image_path, width, height) | 317 return self._callback("image_resize", image_path, width, height) |
284 | 318 |
285 def dbus_init_pre_script(self, ): | 319 def dbus_init_pre_script( |
286 return self._callback("init_pre_script", ) | 320 self, |
321 ): | |
322 return self._callback( | |
323 "init_pre_script", | |
324 ) | |
287 | 325 |
288 def dbus_is_connected(self, profile_key="@DEFAULT@"): | 326 def dbus_is_connected(self, profile_key="@DEFAULT@"): |
289 return self._callback("is_connected", profile_key) | 327 return self._callback("is_connected", profile_key) |
290 | 328 |
291 def dbus_main_resource_get(self, contact_jid, profile_key="@DEFAULT@"): | 329 def dbus_main_resource_get(self, contact_jid, profile_key="@DEFAULT@"): |
293 | 331 |
294 def dbus_menu_help_get(self, menu_id, language): | 332 def dbus_menu_help_get(self, menu_id, language): |
295 return self._callback("menu_help_get", menu_id, language) | 333 return self._callback("menu_help_get", menu_id, language) |
296 | 334 |
297 def dbus_menu_launch(self, menu_type, path, data, security_limit, profile_key): | 335 def dbus_menu_launch(self, menu_type, path, data, security_limit, profile_key): |
298 return self._callback("menu_launch", menu_type, path, data, security_limit, profile_key) | 336 return self._callback( |
337 "menu_launch", menu_type, path, data, security_limit, profile_key | |
338 ) | |
299 | 339 |
300 def dbus_menus_get(self, language, security_limit): | 340 def dbus_menus_get(self, language, security_limit): |
301 return self._callback("menus_get", language, security_limit) | 341 return self._callback("menus_get", language, security_limit) |
302 | 342 |
303 def dbus_message_encryption_get(self, to_jid, profile_key): | 343 def dbus_message_encryption_get(self, to_jid, profile_key): |
304 return self._callback("message_encryption_get", to_jid, profile_key) | 344 return self._callback("message_encryption_get", to_jid, profile_key) |
305 | 345 |
306 def dbus_message_encryption_start(self, to_jid, namespace='', replace=False, profile_key="@NONE@"): | 346 def dbus_message_encryption_start( |
307 return self._callback("message_encryption_start", to_jid, namespace, replace, profile_key) | 347 self, to_jid, namespace="", replace=False, profile_key="@NONE@" |
348 ): | |
349 return self._callback( | |
350 "message_encryption_start", to_jid, namespace, replace, profile_key | |
351 ) | |
308 | 352 |
309 def dbus_message_encryption_stop(self, to_jid, profile_key): | 353 def dbus_message_encryption_stop(self, to_jid, profile_key): |
310 return self._callback("message_encryption_stop", to_jid, profile_key) | 354 return self._callback("message_encryption_stop", to_jid, profile_key) |
311 | 355 |
312 def dbus_message_send(self, to_jid, message, subject={}, mess_type="auto", extra={}, profile_key="@NONE@"): | 356 def dbus_message_send( |
313 return self._callback("message_send", to_jid, message, subject, mess_type, extra, profile_key) | 357 self, |
314 | 358 to_jid, |
315 def dbus_namespaces_get(self, ): | 359 message, |
316 return self._callback("namespaces_get", ) | 360 subject={}, |
317 | 361 mess_type="auto", |
318 def dbus_notification_add(self, type_, body_plain, body_rich, title, is_global, requires_action, arg_6, priority, expire_at, extra): | 362 extra={}, |
319 return self._callback("notification_add", type_, body_plain, body_rich, title, is_global, requires_action, arg_6, priority, expire_at, extra) | 363 profile_key="@NONE@", |
364 ): | |
365 return self._callback( | |
366 "message_send", to_jid, message, subject, mess_type, extra, profile_key | |
367 ) | |
368 | |
369 def dbus_namespaces_get( | |
370 self, | |
371 ): | |
372 return self._callback( | |
373 "namespaces_get", | |
374 ) | |
375 | |
376 def dbus_notification_add( | |
377 self, | |
378 type_, | |
379 body_plain, | |
380 body_rich, | |
381 title, | |
382 is_global, | |
383 requires_action, | |
384 arg_6, | |
385 priority, | |
386 expire_at, | |
387 extra, | |
388 ): | |
389 return self._callback( | |
390 "notification_add", | |
391 type_, | |
392 body_plain, | |
393 body_rich, | |
394 title, | |
395 is_global, | |
396 requires_action, | |
397 arg_6, | |
398 priority, | |
399 expire_at, | |
400 extra, | |
401 ) | |
320 | 402 |
321 def dbus_notification_delete(self, id_, is_global, profile_key): | 403 def dbus_notification_delete(self, id_, is_global, profile_key): |
322 return self._callback("notification_delete", id_, is_global, profile_key) | 404 return self._callback("notification_delete", id_, is_global, profile_key) |
323 | 405 |
324 def dbus_notifications_expired_clean(self, limit_timestamp, profile_key): | 406 def dbus_notifications_expired_clean(self, limit_timestamp, profile_key): |
325 return self._callback("notifications_expired_clean", limit_timestamp, profile_key) | 407 return self._callback("notifications_expired_clean", limit_timestamp, profile_key) |
326 | 408 |
327 def dbus_notifications_get(self, filters, profile_key): | 409 def dbus_notifications_get(self, filters, profile_key): |
328 return self._callback("notifications_get", filters, profile_key) | 410 return self._callback("notifications_get", filters, profile_key) |
329 | 411 |
330 def dbus_param_get_a(self, name, category, attribute="value", profile_key="@DEFAULT@"): | 412 def dbus_param_get_a( |
413 self, name, category, attribute="value", profile_key="@DEFAULT@" | |
414 ): | |
331 return self._callback("param_get_a", name, category, attribute, profile_key) | 415 return self._callback("param_get_a", name, category, attribute, profile_key) |
332 | 416 |
333 def dbus_param_get_a_async(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@"): | 417 def dbus_param_get_a_async( |
334 return self._callback("param_get_a_async", name, category, attribute, security_limit, profile_key) | 418 self, |
335 | 419 name, |
336 def dbus_param_set(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@"): | 420 category, |
337 return self._callback("param_set", name, value, category, security_limit, profile_key) | 421 attribute="value", |
338 | 422 security_limit=-1, |
339 def dbus_param_ui_get(self, security_limit=-1, app='', extra='', profile_key="@DEFAULT@"): | 423 profile_key="@DEFAULT@", |
424 ): | |
425 return self._callback( | |
426 "param_get_a_async", name, category, attribute, security_limit, profile_key | |
427 ) | |
428 | |
429 def dbus_param_set( | |
430 self, name, value, category, security_limit=-1, profile_key="@DEFAULT@" | |
431 ): | |
432 return self._callback( | |
433 "param_set", name, value, category, security_limit, profile_key | |
434 ) | |
435 | |
436 def dbus_param_ui_get( | |
437 self, security_limit=-1, app="", extra="", profile_key="@DEFAULT@" | |
438 ): | |
340 return self._callback("param_ui_get", security_limit, app, extra, profile_key) | 439 return self._callback("param_ui_get", security_limit, app, extra, profile_key) |
341 | 440 |
342 def dbus_params_categories_get(self, ): | 441 def dbus_params_categories_get( |
343 return self._callback("params_categories_get", ) | 442 self, |
344 | 443 ): |
345 def dbus_params_register_app(self, xml, security_limit=-1, app=''): | 444 return self._callback( |
445 "params_categories_get", | |
446 ) | |
447 | |
448 def dbus_params_register_app(self, xml, security_limit=-1, app=""): | |
346 return self._callback("params_register_app", xml, security_limit, app) | 449 return self._callback("params_register_app", xml, security_limit, app) |
347 | 450 |
348 def dbus_params_template_load(self, filename): | 451 def dbus_params_template_load(self, filename): |
349 return self._callback("params_template_load", filename) | 452 return self._callback("params_template_load", filename) |
350 | 453 |
351 def dbus_params_template_save(self, filename): | 454 def dbus_params_template_save(self, filename): |
352 return self._callback("params_template_save", filename) | 455 return self._callback("params_template_save", filename) |
353 | 456 |
354 def dbus_params_values_from_category_get_async(self, category, security_limit=-1, app="", extra="", profile_key="@DEFAULT@"): | 457 def dbus_params_values_from_category_get_async( |
355 return self._callback("params_values_from_category_get_async", category, security_limit, app, extra, profile_key) | 458 self, category, security_limit=-1, app="", extra="", profile_key="@DEFAULT@" |
356 | 459 ): |
357 def dbus_presence_set(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@"): | 460 return self._callback( |
461 "params_values_from_category_get_async", | |
462 category, | |
463 security_limit, | |
464 app, | |
465 extra, | |
466 profile_key, | |
467 ) | |
468 | |
469 def dbus_presence_set(self, to_jid="", show="", statuses={}, profile_key="@DEFAULT@"): | |
358 return self._callback("presence_set", to_jid, show, statuses, profile_key) | 470 return self._callback("presence_set", to_jid, show, statuses, profile_key) |
359 | 471 |
360 def dbus_presence_statuses_get(self, profile_key="@DEFAULT@"): | 472 def dbus_presence_statuses_get(self, profile_key="@DEFAULT@"): |
361 return self._callback("presence_statuses_get", profile_key) | 473 return self._callback("presence_statuses_get", profile_key) |
362 | 474 |
367 return self._callback("private_data_get", namespace, key, profile_key) | 479 return self._callback("private_data_get", namespace, key, profile_key) |
368 | 480 |
369 def dbus_private_data_set(self, namespace, key, data, profile_key): | 481 def dbus_private_data_set(self, namespace, key, data, profile_key): |
370 return self._callback("private_data_set", namespace, key, data, profile_key) | 482 return self._callback("private_data_set", namespace, key, data, profile_key) |
371 | 483 |
372 def dbus_profile_create(self, profile, password='', component=''): | 484 def dbus_profile_create(self, profile, password="", component=""): |
373 return self._callback("profile_create", profile, password, component) | 485 return self._callback("profile_create", profile, password, component) |
374 | 486 |
375 def dbus_profile_delete_async(self, profile): | 487 def dbus_profile_delete_async(self, profile): |
376 return self._callback("profile_delete_async", profile) | 488 return self._callback("profile_delete_async", profile) |
377 | 489 |
382 return self._callback("profile_name_get", profile_key) | 494 return self._callback("profile_name_get", profile_key) |
383 | 495 |
384 def dbus_profile_set_default(self, profile): | 496 def dbus_profile_set_default(self, profile): |
385 return self._callback("profile_set_default", profile) | 497 return self._callback("profile_set_default", profile) |
386 | 498 |
387 def dbus_profile_start_session(self, password='', profile_key="@DEFAULT@"): | 499 def dbus_profile_start_session(self, password="", profile_key="@DEFAULT@"): |
388 return self._callback("profile_start_session", password, profile_key) | 500 return self._callback("profile_start_session", password, profile_key) |
389 | 501 |
390 def dbus_profiles_list_get(self, clients=True, components=False): | 502 def dbus_profiles_list_get(self, clients=True, components=False): |
391 return self._callback("profiles_list_get", clients, components) | 503 return self._callback("profiles_list_get", clients, components) |
392 | 504 |
397 return self._callback("progress_get_all", profile) | 509 return self._callback("progress_get_all", profile) |
398 | 510 |
399 def dbus_progress_get_all_metadata(self, profile): | 511 def dbus_progress_get_all_metadata(self, profile): |
400 return self._callback("progress_get_all_metadata", profile) | 512 return self._callback("progress_get_all_metadata", profile) |
401 | 513 |
402 def dbus_ready_get(self, ): | 514 def dbus_ready_get( |
403 return self._callback("ready_get", ) | 515 self, |
516 ): | |
517 return self._callback( | |
518 "ready_get", | |
519 ) | |
404 | 520 |
405 def dbus_roster_resync(self, profile_key="@DEFAULT@"): | 521 def dbus_roster_resync(self, profile_key="@DEFAULT@"): |
406 return self._callback("roster_resync", profile_key) | 522 return self._callback("roster_resync", profile_key) |
407 | 523 |
408 def dbus_session_infos_get(self, profile_key): | 524 def dbus_session_infos_get(self, profile_key): |
412 return self._callback("sub_waiting_get", profile_key) | 528 return self._callback("sub_waiting_get", profile_key) |
413 | 529 |
414 def dbus_subscription(self, sub_type, entity, profile_key="@DEFAULT@"): | 530 def dbus_subscription(self, sub_type, entity, profile_key="@DEFAULT@"): |
415 return self._callback("subscription", sub_type, entity, profile_key) | 531 return self._callback("subscription", sub_type, entity, profile_key) |
416 | 532 |
417 def dbus_version_get(self, ): | 533 def dbus_version_get( |
418 return self._callback("version_get", ) | 534 self, |
535 ): | |
536 return self._callback( | |
537 "version_get", | |
538 ) | |
419 | 539 |
420 | 540 |
421 class bridge: | 541 class bridge: |
422 | 542 |
423 def __init__(self): | 543 def __init__(self): |
460 | 580 |
461 def entity_data_updated(self, jid, name, value, profile): | 581 def entity_data_updated(self, jid, name, value, profile): |
462 self._obj.emitSignal("entity_data_updated", jid, name, value, profile) | 582 self._obj.emitSignal("entity_data_updated", jid, name, value, profile) |
463 | 583 |
464 def message_encryption_started(self, to_jid, encryption_data, profile_key): | 584 def message_encryption_started(self, to_jid, encryption_data, profile_key): |
465 self._obj.emitSignal("message_encryption_started", to_jid, encryption_data, profile_key) | 585 self._obj.emitSignal( |
586 "message_encryption_started", to_jid, encryption_data, profile_key | |
587 ) | |
466 | 588 |
467 def message_encryption_stopped(self, to_jid, encryption_data, profile_key): | 589 def message_encryption_stopped(self, to_jid, encryption_data, profile_key): |
468 self._obj.emitSignal("message_encryption_stopped", to_jid, encryption_data, profile_key) | 590 self._obj.emitSignal( |
469 | 591 "message_encryption_stopped", to_jid, encryption_data, profile_key |
470 def message_new(self, uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile): | 592 ) |
471 self._obj.emitSignal("message_new", uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile) | 593 |
594 def message_new( | |
595 self, | |
596 uid, | |
597 timestamp, | |
598 from_jid, | |
599 to_jid, | |
600 message, | |
601 subject, | |
602 mess_type, | |
603 extra, | |
604 profile, | |
605 ): | |
606 self._obj.emitSignal( | |
607 "message_new", | |
608 uid, | |
609 timestamp, | |
610 from_jid, | |
611 to_jid, | |
612 message, | |
613 subject, | |
614 mess_type, | |
615 extra, | |
616 profile, | |
617 ) | |
472 | 618 |
473 def message_update(self, uid, message_type, message_data, profile): | 619 def message_update(self, uid, message_type, message_data, profile): |
474 self._obj.emitSignal("message_update", uid, message_type, message_data, profile) | 620 self._obj.emitSignal("message_update", uid, message_type, message_data, profile) |
475 | 621 |
476 def notification_deleted(self, id, profile): | 622 def notification_deleted(self, id, profile): |
477 self._obj.emitSignal("notification_deleted", id, profile) | 623 self._obj.emitSignal("notification_deleted", id, profile) |
478 | 624 |
479 def notification_new(self, id, timestamp, type, body_plain, body_rich, title, requires_action, priority, expire_at, extra, profile): | 625 def notification_new( |
480 self._obj.emitSignal("notification_new", id, timestamp, type, body_plain, body_rich, title, requires_action, priority, expire_at, extra, profile) | 626 self, |
627 id, | |
628 timestamp, | |
629 type, | |
630 body_plain, | |
631 body_rich, | |
632 title, | |
633 requires_action, | |
634 priority, | |
635 expire_at, | |
636 extra, | |
637 profile, | |
638 ): | |
639 self._obj.emitSignal( | |
640 "notification_new", | |
641 id, | |
642 timestamp, | |
643 type, | |
644 body_plain, | |
645 body_rich, | |
646 title, | |
647 requires_action, | |
648 priority, | |
649 expire_at, | |
650 extra, | |
651 profile, | |
652 ) | |
481 | 653 |
482 def param_update(self, name, value, category, profile): | 654 def param_update(self, name, value, category, profile): |
483 self._obj.emitSignal("param_update", name, value, category, profile) | 655 self._obj.emitSignal("param_update", name, value, category, profile) |
484 | 656 |
485 def presence_update(self, entity_jid, show, priority, statuses, profile): | 657 def presence_update(self, entity_jid, show, priority, statuses, profile): |
486 self._obj.emitSignal("presence_update", entity_jid, show, priority, statuses, profile) | 658 self._obj.emitSignal( |
659 "presence_update", entity_jid, show, priority, statuses, profile | |
660 ) | |
487 | 661 |
488 def progress_error(self, id, error, profile): | 662 def progress_error(self, id, error, profile): |
489 self._obj.emitSignal("progress_error", id, error, profile) | 663 self._obj.emitSignal("progress_error", id, error, profile) |
490 | 664 |
491 def progress_finished(self, id, metadata, profile): | 665 def progress_finished(self, id, metadata, profile): |
503 | 677 |
504 def emit_signal(self, name, *args): | 678 def emit_signal(self, name, *args): |
505 self._obj.emitSignal(name, *args) | 679 self._obj.emitSignal(name, *args) |
506 | 680 |
507 def add_method( | 681 def add_method( |
508 self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={} | 682 self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={} |
509 ): | 683 ): |
510 """Dynamically add a method to D-Bus bridge""" | 684 """Dynamically add a method to D-Bus bridge""" |
511 # FIXME: doc parameter is kept only temporary, the time to remove it from calls | 685 # FIXME: doc parameter is kept only temporary, the time to remove it from calls |
512 log.debug(f"Adding method {name!r} to D-Bus bridge") | 686 log.debug(f"Adding method {name!r} to D-Bus bridge") |
513 self._obj.plugin_iface.addMethod( | 687 self._obj.plugin_iface.addMethod( |
514 Method(name, arguments=in_sign, returns=out_sign) | 688 Method(name, arguments=in_sign, returns=out_sign) |
515 ) | 689 ) |
690 | |
516 # we have to create a method here instead of using partialmethod, because txdbus | 691 # we have to create a method here instead of using partialmethod, because txdbus |
517 # uses __func__ which doesn't work with partialmethod | 692 # uses __func__ which doesn't work with partialmethod |
518 def caller(self_, *args, **kwargs): | 693 def caller(self_, *args, **kwargs): |
519 return self_._callback(name, *args, **kwargs) | 694 return self_._callback(name, *args, **kwargs) |
695 | |
520 setattr(self._obj, f"dbus_{name}", MethodType(caller, self._obj)) | 696 setattr(self._obj, f"dbus_{name}", MethodType(caller, self._obj)) |
521 self.register_method(name, method) | 697 self.register_method(name, method) |
522 | 698 |
523 def add_signal(self, name, int_suffix, signature, doc={}): | 699 def add_signal(self, name, int_suffix, signature, doc={}): |
524 """Dynamically add a signal to D-Bus bridge""" | 700 """Dynamically add a signal to D-Bus bridge""" |