(purple) Chat-members leaving, receiving statuses

This commit is contained in:
Jaidyn Ann 2021-07-15 16:41:22 -05:00
parent e07ee29d13
commit 0c8af4dd86
2 changed files with 34 additions and 0 deletions

View File

@ -961,6 +961,8 @@ init_signals()
&handle, PURPLE_CALLBACK(signal_blist_node_added), NULL); &handle, PURPLE_CALLBACK(signal_blist_node_added), NULL);
purple_signal_connect(purple_blist_get_handle(), "blist-node-removed", purple_signal_connect(purple_blist_get_handle(), "blist-node-removed",
&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",
&handle, PURPLE_CALLBACK(signal_buddy_status_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);
@ -976,6 +978,8 @@ init_signals()
&handle, PURPLE_CALLBACK(signal_sent_im_msg), NULL); &handle, PURPLE_CALLBACK(signal_sent_im_msg), NULL);
purple_signal_connect(purple_conversations_get_handle(), "chat-buddy-joined", purple_signal_connect(purple_conversations_get_handle(), "chat-buddy-joined",
&handle, PURPLE_CALLBACK(signal_chat_buddy_joined), NULL); &handle, PURPLE_CALLBACK(signal_chat_buddy_joined), NULL);
purple_signal_connect(purple_conversations_get_handle(), "chat-buddy-left",
&handle, PURPLE_CALLBACK(signal_chat_buddy_left), NULL);
purple_signal_connect(purple_conversations_get_handle(), "chat-invited", purple_signal_connect(purple_conversations_get_handle(), "chat-invited",
&handle, PURPLE_CALLBACK(signal_chat_invited), NULL); &handle, PURPLE_CALLBACK(signal_chat_invited), NULL);
purple_signal_connect(purple_conversations_get_handle(), "chat-buddy-flags", purple_signal_connect(purple_conversations_get_handle(), "chat-buddy-flags",
@ -1067,6 +1071,18 @@ signal_blist_node_removed(PurpleBlistNode* node)
} }
static void
signal_buddy_status_changed(PurpleBuddy* buddy, PurpleStatus* old_status,
PurpleStatus* status)
{
BMessage note(IM_MESSAGE);
note.AddInt32("im_what", IM_STATUS_SET);
note.AddInt32("status", purple_status_to_cardie(status));
note.AddString("user_id", purple_buddy_get_name(buddy));
((PurpleApp*)be_app)->SendMessage(purple_buddy_get_account(buddy), note);
}
static void static void
signal_chat_joined(PurpleConversation* conv) signal_chat_joined(PurpleConversation* conv)
{ {
@ -1164,6 +1180,20 @@ signal_chat_buddy_joined(PurpleConversation* conv, const char* name,
} }
static void
signal_chat_buddy_left(PurpleConversation* conv, const char* name,
const char* reason)
{
BMessage left(IM_MESSAGE);
left.AddInt32("im_what", IM_ROOM_PARTICIPANT_LEFT);
left.AddString("chat_id", purple_conversation_get_name(conv));
left.AddString("user_id", name);
left.AddString("body", reason);
PurpleAccount* account = purple_conversation_get_account(conv);
((PurpleApp*)be_app)->SendMessage(account, left);
}
// inviter == user_id, not user_name // inviter == user_id, not user_name
static void static void
signal_chat_invited(PurpleAccount* account, const char* inviter, signal_chat_invited(PurpleAccount* account, const char* inviter,

View File

@ -127,6 +127,8 @@ private:
// Buddy-list signals // Buddy-list signals
static void signal_blist_node_added(PurpleBlistNode* node); static void signal_blist_node_added(PurpleBlistNode* node);
static void signal_blist_node_removed(PurpleBlistNode* node); static void signal_blist_node_removed(PurpleBlistNode* node);
static void signal_buddy_status_changed(PurpleBuddy* buddy,
PurpleStatus* old_status, PurpleStatus* status);
// Conversation signals // Conversation signals
static void signal_chat_joined(PurpleConversation* conv); static void signal_chat_joined(PurpleConversation* conv);
@ -141,6 +143,8 @@ private:
static void signal_chat_buddy_joined(PurpleConversation* conv, static void signal_chat_buddy_joined(PurpleConversation* conv,
const char* name, PurpleConvChatBuddyFlags flags, const char* name, PurpleConvChatBuddyFlags flags,
gboolean new_arrival); gboolean new_arrival);
static void signal_chat_buddy_left(PurpleConversation* conv,
const char* name, const char* reason);
static void signal_chat_invited(PurpleAccount* account, static void signal_chat_invited(PurpleAccount* account,
const char* inviter, const char* chat, const char* inviter, const char* chat,
const char* message, const GHashTable* components); const char* message, const GHashTable* components);