diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-09-20 17:14:55 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-09-20 17:24:30 +0200 |
commit | 9327333813cbcb538f6757934be42d59c34f86d6 (patch) | |
tree | 9c4d39be99205279ba5dbd8bf488405378326f16 /xC.c | |
parent | 7806d4bd4eba73fd423c7d966a0ee286cde37b37 (diff) | |
download | xK-9327333813cbcb538f6757934be42d59c34f86d6.tar.gz xK-9327333813cbcb538f6757934be42d59c34f86d6.tar.xz xK-9327333813cbcb538f6757934be42d59c34f86d6.zip |
xC/xP: show own user's info in frontends
Diffstat (limited to 'xC.c')
-rw-r--r-- | xC.c | 37 |
1 files changed, 28 insertions, 9 deletions
@@ -3067,6 +3067,9 @@ relay_server_state_for_server (struct server *s) return 0; } +// TODO: Consider pushing this whole block of code further down. +static char *irc_to_utf8 (const char *text); + static void relay_prepare_server_update (struct app_context *ctx, struct server *s) { @@ -3074,7 +3077,17 @@ relay_prepare_server_update (struct app_context *ctx, struct server *s) struct relay_event_data_server_update *e = &m->data.server_update; e->event = RELAY_EVENT_SERVER_UPDATE; e->server_name = str_from_cstr (s->name); - e->state = relay_server_state_for_server (s); + e->data.state = relay_server_state_for_server (s); + if (s->state == IRC_REGISTERED) + { + char *user_utf8 = irc_to_utf8 (s->irc_user->nickname); + e->data.registered.user = str_from_cstr (user_utf8); + free (user_utf8); + + char *user_mode_utf8 = irc_to_utf8 (s->irc_user_mode.str); + e->data.registered.user_mode = str_from_cstr (user_mode_utf8); + free (user_mode_utf8); + } } static void @@ -7071,6 +7084,9 @@ irc_handle_mode_user (struct server *s, char **params) { struct mode_processor p = { .s = s }; mode_processor_run (&p, params, mode_processor_apply_user); + + relay_prepare_server_update (s->ctx, s); + relay_broadcast (s->ctx); } // --- Output processing ------------------------------------------------------- @@ -7681,7 +7697,7 @@ irc_handle_nick (struct server *s, const struct irc_message *msg) if (lexicographically_different) hard_assert (!str_map_find (&s->irc_users, new_nickname)); - // Now we can rename the PM buffer to reflect the new nickname + // Now we can rename everything to reflect the new nickname if (pm_buffer) { str_map_set (&s->irc_buffer_map, user->nickname, NULL); @@ -7692,8 +7708,17 @@ irc_handle_nick (struct server *s, const struct irc_message *msg) free (x); } - if (irc_is_this_us (s, msg->prefix)) + str_map_set (&s->irc_users, user->nickname, NULL); + str_map_set (&s->irc_users, new_nickname, user); + + cstr_set (&user->nickname, xstrdup (new_nickname)); + + // Finally broadcast the event to relay clients and secondary buffers + if (irc_is_this_us (s, new_nickname)) { + relay_prepare_server_update (s->ctx, s); + relay_broadcast (s->ctx); + log_nick_self (s, s->buffer, new_nickname); // Log a message in all open buffers on this server @@ -7717,12 +7742,6 @@ irc_handle_nick (struct server *s, const struct irc_message *msg) log_nick (s, buffer, msg->prefix, new_nickname); } } - - // Finally rename the user as it should be safe now - str_map_set (&s->irc_users, user->nickname, NULL); - str_map_set (&s->irc_users, new_nickname, user); - - cstr_set (&user->nickname, xstrdup (new_nickname)); } static void |