(purple) Load buddy avatars

This commit is contained in:
Jaidyn Ann 2021-07-25 19:01:46 -05:00
parent bea52c14be
commit 4fa0542fe0
2 changed files with 19 additions and 2 deletions

View File

@ -1029,6 +1029,8 @@ init_signals()
&handle, PURPLE_CALLBACK(signal_blist_node_removed), NULL); &handle, PURPLE_CALLBACK(signal_blist_node_removed), NULL);
purple_signal_connect(purple_blist_get_handle(), "buddy-status-changed", purple_signal_connect(purple_blist_get_handle(), "buddy-status-changed",
&handle, PURPLE_CALLBACK(signal_buddy_status_changed), NULL); &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", purple_signal_connect(purple_conversations_get_handle(), "chat-joined",
&handle, PURPLE_CALLBACK(signal_chat_joined), NULL); &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 username = purple_account_get_username(account);
BString display = purple_account_get_name_for_display(account); BString display = purple_account_get_name_for_display(account);
BMessage info(IM_MESSAGE);
send_own_info(account); send_own_info(account);
((PurpleApp*)be_app)->fUserNicks.AddItem(username, display); ((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 static void
signal_chat_joined(PurpleConversation* conv) signal_chat_joined(PurpleConversation* conv)
{ {
@ -1336,7 +1352,7 @@ ui_op_report_disconnect_reason(PurpleConnection* conn,
else else
((PurpleApp*)be_app)->SendMessage(account, ((PurpleApp*)be_app)->SendMessage(account,
BMessage(PURPLE_SHUTDOWN_ADDON)); BMessage(PURPLE_SHUTDOWN_ADDON));
else { else {
BMessage disabled(PURPLE_SHUTDOWN_ADDON); BMessage disabled(PURPLE_SHUTDOWN_ADDON);
((PurpleApp*)be_app)->SendMessage(account, disabled); ((PurpleApp*)be_app)->SendMessage(account, disabled);
} }

View File

@ -133,6 +133,7 @@ private:
static void signal_blist_node_removed(PurpleBlistNode* node); static void signal_blist_node_removed(PurpleBlistNode* node);
static void signal_buddy_status_changed(PurpleBuddy* buddy, static void signal_buddy_status_changed(PurpleBuddy* buddy,
PurpleStatus* old_status, PurpleStatus* status); PurpleStatus* old_status, PurpleStatus* status);
static void signal_buddy_icon_changed(PurpleBuddy* buddy);
// Conversation signals // Conversation signals
static void signal_chat_joined(PurpleConversation* conv); static void signal_chat_joined(PurpleConversation* conv);