Fix glib log errors on joining chats and clean up code

This commit is contained in:
mjentsch 2015-12-29 14:32:13 +01:00
parent 67bc9cea92
commit 6cadb04fbd
2 changed files with 17 additions and 15 deletions

View file

@ -100,23 +100,26 @@ static void tgp_chat_add_all_users (struct tgl_state *TLS, PurpleConversation *c
g_list_free (flags);
}
void tgp_chat_users_update (struct tgl_state *TLS, struct tgl_chat *C) {
PurpleConversation *pc = purple_find_chat (tls_get_conn (TLS), tgl_get_peer_id (C->id));
if (pc) {
purple_conv_chat_clear_users (purple_conversation_get_chat_data (pc));
tgp_chat_add_all_users (TLS, pc, C);
}
}
PurpleConversation *tgp_chat_show (struct tgl_state *TLS, struct tgl_chat *C) {
PurpleConversation *convo = purple_find_chat (tls_get_conn (TLS), tgl_get_peer_id (C->id));
PurpleConvChat *chat = purple_conversation_get_chat_data (convo);
PurpleConvChat *chat = NULL;
if (! convo || (chat && purple_conv_chat_has_left (chat))) {
convo = serv_got_joined_chat (tls_get_conn (TLS), tgl_get_peer_id (C->id), C->print_title);
tgp_chat_users_update (TLS, C);
// check if chat is already shown
PurpleConversation *conv = purple_find_chat (tls_get_conn (TLS), tgl_get_peer_id (C->id));
if (conv) {
chat = purple_conversation_get_chat_data (conv);
if (chat && ! purple_conv_chat_has_left (chat)) {
return conv;
}
}
return convo;
// join the chat now
conv = serv_got_joined_chat (tls_get_conn (TLS), tgl_get_peer_id (C->id), C->print_title);
g_return_val_if_fail(conv, NULL);
purple_conv_chat_clear_users (purple_conversation_get_chat_data (conv));
tgp_chat_add_all_users (TLS, conv, C);
return conv;
}
GList *tgprpl_chat_join_info (PurpleConnection * gc) {

View file

@ -30,7 +30,6 @@ int tgp_chat_has_id (PurpleChat *C);
void tgp_chat_on_loaded_chat_full (struct tgl_state *TLS, struct tgl_chat *C);
PurpleConversation *tgp_chat_show (struct tgl_state *TLS, struct tgl_chat *C);
void tgp_chat_users_update (struct tgl_state *TLS, struct tgl_chat *C);
char *tgprpl_get_chat_name (GHashTable *data);
void tgprpl_chat_join (PurpleConnection *gc, GHashTable *data);