From 128ac91d5677a9edb8221291b79ae01e9a19d055 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Thu, 5 Aug 2021 10:20:52 -0500 Subject: [PATCH] (purple) Fix setting own nick --- protocols/purple/PurpleApp.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/protocols/purple/PurpleApp.cpp b/protocols/purple/PurpleApp.cpp index 6c4596d..f4a41d6 100644 --- a/protocols/purple/PurpleApp.cpp +++ b/protocols/purple/PurpleApp.cpp @@ -270,6 +270,7 @@ PurpleApp::ImMessage(BMessage* msg) GList* users = purple_conv_chat_get_users(chat); for (int i = 0; users != NULL; users = users->next) { PurpleConvChatBuddy* user = (PurpleConvChatBuddy*)users->data; + const char* user_name = purple_conv_chat_cb_get_name(user); if (is_own_user(account, user_name) == false) user_ids.Add(BString(user_name)); @@ -1347,6 +1348,7 @@ signal_chat_buddy_joined(PurpleConversation* conv, const char* name, if (is_own_user(purple_conversation_get_account(conv), name) == true) return; } + joined.AddString("chat_id", purple_conversation_get_name(conv)); joined.AddString("user_id", name); @@ -1444,6 +1446,17 @@ static void ui_op_chat_rename_user(PurpleConversation* conv, const char* old_name, const char* new_name, const char* new_alias) { + PurpleAccount* account = purple_conversation_get_account(conv); + PurpleApp* app = (PurpleApp*)be_app; + + if (is_own_user(account, old_name) == true) { + const char* username = purple_account_get_username(account); + app->fUserNicks.RemoveItemFor(username); + app->fUserNicks.AddItem(username, new_name); + purple_account_set_alias(account, new_name); + return; + } + BString text = B_TRANSLATE("User changed name to %nick%"); text.ReplaceAll("%nick%", new_name); @@ -1452,14 +1465,13 @@ ui_op_chat_rename_user(PurpleConversation* conv, const char* old_name, 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); + 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); + app->SendMessage(account, joined); }