core: add signal when profile is ready:

A `profile_ready` signal is now sent, so all frontends can know when a profile is
connected, and we don't have to wait for `connect` bridge method and risk a timeout.
This commit is contained in:
Goffi 2026-05-02 12:06:10 +02:00
commit 6cc536472c
4 changed files with 23 additions and 4 deletions

View file

@ -13,6 +13,13 @@ doc=Connection is done
doc_param_0=jid_s: the JID that we were assigned by the server, as the resource might differ from the JID we asked for.
doc_param_1=%(doc_profile)s
[profile_ready]
type=signal
category=core
sig_in=s
doc=Profile is fully initialized (XMPP connected, roster received, all plugins loaded)
doc_param_0=%(doc_profile)s
[disconnected]
type=signal
category=core

View file

@ -179,6 +179,7 @@ class DBusObject(objects.DBusObject):
Signal("notification_new", "sdssssbidss"),
Signal("param_update", "ssss"),
Signal("presence_update", "ssia{ss}s"),
Signal("profile_ready", "s"),
Signal("progress_error", "sss"),
Signal("progress_finished", "sa{ss}s"),
Signal("progress_started", "sa{ss}s"),
@ -666,6 +667,9 @@ class bridge:
"presence_update", entity_jid, show, priority, statuses, profile
)
def profile_ready(self, profile):
self._obj.emitSignal("profile_ready", profile)
def progress_error(self, id, error, profile):
self._obj.emitSignal("progress_error", id, error, profile)

View file

@ -274,6 +274,9 @@ class bridge:
def presence_update(self, entity_jid, show, priority, statuses, profile):
self.send_signal("presence_update", entity_jid, show, priority, statuses, profile)
def profile_ready(self, profile):
self.send_signal("profile_ready", profile)
def progress_error(self, id, error, profile):
self.send_signal("progress_error", id, error, profile)

View file

@ -254,7 +254,9 @@ class SatXMPPEntity(core_types.SatXMPPEntity):
@staticmethod
async def _run_profile_connected(
callback: Callable, entity: "SatXMPPEntity", timer: Dict[str, float]
callback: Callable,
entity: "SatXMPPEntity",
timer: Dict[str, float],
) -> None:
connected_start = time.time()
await utils.as_deferred(callback, entity)
@ -458,10 +460,13 @@ class SatXMPPEntity(core_types.SatXMPPEntity):
f" Plugins total={total_plugins:.2f}s real={total_real:.2f}s\n"
)
await list_d.addCallback(
list_d.addCallback(
log_plugin_results
) # FIXME: we should have a timeout here, and a way to know if a plugin freeze
# TODO: mesure launch time of each plugin
)
# FIXME: we should have a timeout here, and a way to know if a plugin freeze
await list_d
host.bridge.profile_ready(profile)
finally:
cls.profiles_connecting.remove(profile)