Display user aliases of users not in the buddy list in group chats
This commit is contained in:
parent
b0ac19fc5f
commit
644416aa89
3 changed files with 26 additions and 8 deletions
23
tgp-2prpl.c
23
tgp-2prpl.c
|
@ -306,12 +306,31 @@ PurpleChat *p2tgl_chat_find (struct tgl_state *TLS, tgl_peer_id_t id) {
|
|||
return c;
|
||||
}
|
||||
|
||||
void p2tgl_conv_add_user (PurpleConversation *conv, struct tgl_chat_user user, char *message, int flags, int new_arrival) {
|
||||
void p2tgl_conv_add_user (struct tgl_state *TLS, PurpleConversation *conv,
|
||||
struct tgl_chat_user user, char *message, int flags, int new_arrival) {
|
||||
PurpleConvChat *cdata = purple_conversation_get_chat_data(conv);
|
||||
char *name = g_strdup_printf("%d", user.user_id);
|
||||
|
||||
purple_conv_chat_add_user (cdata, name, message, flags, new_arrival);
|
||||
|
||||
// inject print_name into chat buddies to display a human-readable name
|
||||
// for buddies not in the buddy list instead of the user id
|
||||
tgl_peer_t *U = tgl_peer_get (TLS, TGL_MK_USER(user.user_id));
|
||||
if (U) {
|
||||
PurpleConvChatBuddy *cbuddy = purple_conv_chat_cb_find (PURPLE_CONV_CHAT(conv), name);
|
||||
PurpleConversationUiOps *uiops = purple_conversation_get_ui_ops (conv);;
|
||||
if (cbuddy && cbuddy->alias) {
|
||||
g_free (cbuddy->alias);
|
||||
cbuddy->alias = g_strdup (U->print_name);
|
||||
}
|
||||
if (uiops && uiops->chat_rename_user) {
|
||||
debug ("try rename user %s to %s\n", name, U->print_name);
|
||||
uiops->chat_rename_user (conv, name, name, U->print_name);
|
||||
} else if (uiops && uiops->chat_update_user) {
|
||||
debug ("try update user %s\n", name);
|
||||
uiops->chat_update_user (conv, name);
|
||||
}
|
||||
}
|
||||
|
||||
g_free(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void p2tgl_prpl_got_set_status_offline (struct tgl_state *TLS, tgl_peer_id_t use
|
|||
void p2tgl_connection_set_display_name(struct tgl_state *TLS, tgl_peer_t *user);
|
||||
void p2tgl_conv_del_user (PurpleConversation *conv, tgl_peer_id_t user);
|
||||
void p2tgl_conv_add_users (PurpleConversation *conv, struct tgl_chat_user *list);
|
||||
void p2tgl_conv_add_user (PurpleConversation *conv, struct tgl_chat_user user, char *message, int flags, int new_arrival);
|
||||
void p2tgl_conv_add_user (struct tgl_state *TLS, PurpleConversation *conv, struct tgl_chat_user user, char *message, int flags, int new_arrival);
|
||||
PurpleConversation *p2tgl_find_conversation_with_account (struct tgl_state *TLS, tgl_peer_id_t peer);
|
||||
void p2tgl_conversation_write (PurpleConversation *conv, tgl_peer_id_t who, const char *message, int flags, int date);
|
||||
PurpleConversation *p2tgl_conversation_new (struct tgl_state *TLS, tgl_peer_id_t who);
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
#include "tgp-chat.h"
|
||||
#include "msglog.h"
|
||||
|
||||
void chat_add_all_users (PurpleConversation *pc, struct tgl_chat *chat) {
|
||||
void chat_add_all_users (struct tgl_state *TLS, PurpleConversation *pc, struct tgl_chat *chat) {
|
||||
int i;
|
||||
for (i = 0; i < chat->user_list_size; i++) {
|
||||
struct tgl_chat_user *uid = (chat->user_list + i);
|
||||
int flags = (chat->admin_id == uid->user_id ? PURPLE_CBFLAGS_FOUNDER : PURPLE_CBFLAGS_NONE);
|
||||
p2tgl_conv_add_user (pc, *uid, NULL, flags, 0);
|
||||
p2tgl_conv_add_user (TLS, pc, *uid, NULL, flags, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ void chat_users_update (struct tgl_state *TLS, struct tgl_chat *chat) {
|
|||
PurpleConversation *pc = purple_find_chat(tg_get_conn(TLS), tgl_get_peer_id(chat->id));
|
||||
if (pc) {
|
||||
purple_conv_chat_clear_users (purple_conversation_get_chat_data(pc));
|
||||
chat_add_all_users (pc, chat);
|
||||
chat_add_all_users (TLS, pc, chat);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,8 @@ PurpleConversation *chat_show (PurpleConnection *gc, int id) {
|
|||
}
|
||||
if (! convo || (chat && purple_conv_chat_has_left (chat))) {
|
||||
convo = p2tgl_got_joined_chat (conn->TLS, &P->chat);
|
||||
chat_users_update (conn->TLS, &P->chat);
|
||||
}
|
||||
chat_users_update (conn->TLS, &P->chat);
|
||||
|
||||
return convo;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue