From 4fa0542fe048359e0358c2c04efd06a9c6ec7fd5 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Sun, 25 Jul 2021 19:01:46 -0500 Subject: [PATCH] (purple) Load buddy avatars --- protocols/purple/PurpleApp.cpp | 20 ++++++++++++++++++-- protocols/purple/PurpleApp.h | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/protocols/purple/PurpleApp.cpp b/protocols/purple/PurpleApp.cpp index 9024f17..e19f3bb 100644 --- a/protocols/purple/PurpleApp.cpp +++ b/protocols/purple/PurpleApp.cpp @@ -1029,6 +1029,8 @@ init_signals() &handle, PURPLE_CALLBACK(signal_blist_node_removed), NULL); purple_signal_connect(purple_blist_get_handle(), "buddy-status-changed", &handle, PURPLE_CALLBACK(signal_buddy_status_changed), NULL); + purple_signal_connect(purple_blist_get_handle(), "buddy-icon-changed", + &handle, PURPLE_CALLBACK(signal_buddy_icon_changed), NULL); purple_signal_connect(purple_conversations_get_handle(), "chat-joined", &handle, PURPLE_CALLBACK(signal_chat_joined), NULL); @@ -1072,7 +1074,6 @@ signal_account_signed_on(PurpleAccount* account) BString username = purple_account_get_username(account); BString display = purple_account_get_name_for_display(account); - BMessage info(IM_MESSAGE); send_own_info(account); ((PurpleApp*)be_app)->fUserNicks.AddItem(username, display); @@ -1164,6 +1165,21 @@ signal_buddy_status_changed(PurpleBuddy* buddy, PurpleStatus* old_status, } +static void +signal_buddy_icon_changed(PurpleBuddy* buddy) +{ + entry_ref ref; + BEntry entry(purple_buddy_icon_get_full_path(purple_buddy_get_icon(buddy))); + entry.GetRef(&ref); + + BMessage avatar(IM_MESSAGE); + avatar.AddInt32("im_what", IM_AVATAR_SET); + avatar.AddString("user_id", purple_buddy_get_name(buddy)); + avatar.AddRef("ref", &ref); + ((PurpleApp*)be_app)->SendMessage(purple_buddy_get_account(buddy), avatar); +} + + static void signal_chat_joined(PurpleConversation* conv) { @@ -1336,7 +1352,7 @@ ui_op_report_disconnect_reason(PurpleConnection* conn, else ((PurpleApp*)be_app)->SendMessage(account, BMessage(PURPLE_SHUTDOWN_ADDON)); - else { + else { BMessage disabled(PURPLE_SHUTDOWN_ADDON); ((PurpleApp*)be_app)->SendMessage(account, disabled); } diff --git a/protocols/purple/PurpleApp.h b/protocols/purple/PurpleApp.h index d242f38..8a31169 100644 --- a/protocols/purple/PurpleApp.h +++ b/protocols/purple/PurpleApp.h @@ -133,6 +133,7 @@ private: static void signal_blist_node_removed(PurpleBlistNode* node); static void signal_buddy_status_changed(PurpleBuddy* buddy, PurpleStatus* old_status, PurpleStatus* status); + static void signal_buddy_icon_changed(PurpleBuddy* buddy); // Conversation signals static void signal_chat_joined(PurpleConversation* conv);