From 8f3d206db167b319370b6e6cdd907a3c0138131d Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Tue, 3 Aug 2021 16:23:27 -0500 Subject: [PATCH] (purple) Other users changing nick --- protocols/purple/PurpleApp.cpp | 48 ++++++++++++++++++++++++++++++++++ protocols/purple/PurpleApp.h | 5 ++++ 2 files changed, 53 insertions(+) diff --git a/protocols/purple/PurpleApp.cpp b/protocols/purple/PurpleApp.cpp index 51eb75c..6c4596d 100644 --- a/protocols/purple/PurpleApp.cpp +++ b/protocols/purple/PurpleApp.cpp @@ -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 = { ui_op_request_input, @@ -1031,6 +1055,7 @@ init_ui_ops() { purple_eventloop_set_ui_ops(&_ui_op_eventloops); 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_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* ui_op_request_input(const char* title, const char* primary, const char* secondary, const char* default_value, gboolean multiline, diff --git a/protocols/purple/PurpleApp.h b/protocols/purple/PurpleApp.h index 9e03784..9c941ac 100644 --- a/protocols/purple/PurpleApp.h +++ b/protocols/purple/PurpleApp.h @@ -169,6 +169,11 @@ private: static void ui_op_report_disconnect_reason(PurpleConnection* conn, 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 static void* ui_op_request_input(const char* title, const char* primary, const char* secondary,