(purple) Other users changing nick

This commit is contained in:
Jaidyn Ann 2021-08-03 16:23:27 -05:00
parent f439ca9aa6
commit 8f3d206db1
2 changed files with 53 additions and 0 deletions

View File

@ -992,6 +992,30 @@ static PurpleConnectionUiOps _ui_op_connection =
}; };
static PurpleConversationUiOps _ui_op_conversation =
{
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
ui_op_chat_rename_user,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
};
static PurpleRequestUiOps _ui_op_request = static PurpleRequestUiOps _ui_op_request =
{ {
ui_op_request_input, ui_op_request_input,
@ -1031,6 +1055,7 @@ init_ui_ops()
{ {
purple_eventloop_set_ui_ops(&_ui_op_eventloops); purple_eventloop_set_ui_ops(&_ui_op_eventloops);
purple_connections_set_ui_ops(&_ui_op_connection); purple_connections_set_ui_ops(&_ui_op_connection);
purple_conversations_set_ui_ops(&_ui_op_conversation);
purple_request_set_ui_ops(&_ui_op_request); purple_request_set_ui_ops(&_ui_op_request);
purple_notify_set_ui_ops(&_ui_op_notify); purple_notify_set_ui_ops(&_ui_op_notify);
} }
@ -1415,6 +1440,29 @@ ui_op_report_disconnect_reason(PurpleConnection* conn,
} }
static void
ui_op_chat_rename_user(PurpleConversation* conv, const char* old_name,
const char* new_name, const char* new_alias)
{
BString text = B_TRANSLATE("User changed name to %nick%");
text.ReplaceAll("%nick%", new_name);
BMessage left(IM_MESSAGE);
left.AddInt32("im_what", IM_ROOM_PARTICIPANT_LEFT);
left.AddString("user_id", old_name);
left.AddString("chat_id", purple_conversation_get_name(conv));
left.AddString("body", text);
PurpleAccount* account = purple_conversation_get_account(conv);
((PurpleApp*)be_app)->SendMessage(account, left);
BMessage joined(IM_MESSAGE);
joined.AddInt32("im_what", IM_ROOM_PARTICIPANT_JOINED);
joined.AddString("user_id", new_name);
joined.AddString("chat_id", purple_conversation_get_name(conv));
((PurpleApp*)be_app)->SendMessage(account, joined);
}
static void* static void*
ui_op_request_input(const char* title, const char* primary, ui_op_request_input(const char* title, const char* primary,
const char* secondary, const char* default_value, gboolean multiline, const char* secondary, const char* default_value, gboolean multiline,

View File

@ -169,6 +169,11 @@ private:
static void ui_op_report_disconnect_reason(PurpleConnection* conn, static void ui_op_report_disconnect_reason(PurpleConnection* conn,
PurpleConnectionError reason, const char* text); PurpleConnectionError reason, const char* text);
// Conversation ui ops
static void ui_op_chat_rename_user(PurpleConversation* conv,
const char* old_name, const char* new_name,
const char* new_alias);
// Request ui ops // Request ui ops
static void* ui_op_request_input(const char* title, static void* ui_op_request_input(const char* title,
const char* primary, const char* secondary, const char* primary, const char* secondary,