Fix service message formatting in Adium

Adium drops MESSAGE_SYSTEM flags in serv_got_im, directly write to the conversation in case the message contains such a flag.
This commit is contained in:
mjentsch 2015-10-16 00:33:23 +02:00
parent afa650cfc1
commit a2fc31cda7
3 changed files with 15 additions and 10 deletions

View file

@ -199,10 +199,7 @@ static void update_secret_chat_handler (struct tgl_state *TLS, struct tgl_secret
if (!(flags & TGL_UPDATE_CREATED) && buddy) {
if (flags & TGL_UPDATE_DELETED) {
// TODO: Broken in Adium, message not displayed as system message
serv_got_im (conn->gc, tgp_blist_peer_get_name (TLS, U->id), _("Secret chat terminated."),
PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_WHISPER, time (0));
tgp_msg_sys_out (TLS, _("Secret chat terminated."), U->id, FALSE);
purple_prpl_got_user_status (tg_get_acc (TLS), tgp_blist_peer_get_name (TLS, U->id), "offline", NULL);
} else {
_update_buddy (TLS, (tgl_peer_t *)U, flags);

View file

@ -30,6 +30,7 @@
#include "telegram-purple.h"
#include "tgp-utils.h"
#include "telegram-base.h"
#include "tgp-msg.h"
#include <server.h>
#include <tgl.h>
@ -90,7 +91,12 @@ void p2tgl_got_chat_in (struct tgl_state *TLS, tgl_peer_id_t chat, tgl_peer_id_t
void p2tgl_got_im_combo (struct tgl_state *TLS, tgl_peer_id_t who, const char *msg, int flags, time_t when) {
connection_data *conn = TLS->ev_base;
/*
if (flags & PURPLE_MESSAGE_SYSTEM) {
tgp_msg_sys_out (TLS, msg, who, flags & PURPLE_MESSAGE_NO_LOG);
return;
}
/*
Outgoing messages are not well supported in different libpurple clients,
purple_conv_im_write should have the best among different versions. Unfortunately
this causes buggy formatting in Adium, so we don't use this workaround in that case.

View file

@ -260,10 +260,12 @@ void tgp_msg_sys_out (struct tgl_state *TLS, const char *msg, tgl_peer_id_t to_i
break;
case TGL_PEER_USER:
case TGL_PEER_ENCR_CHAT: {
const char *name = tgp_blist_peer_get_name (TLS, to_id);
PurpleConversation *conv = p2tgl_find_conversation_with_account (TLS, to_id);
if (conv) {
purple_conversation_write (conv, tgp_blist_peer_get_name (TLS, to_id), msg, flags, now);
if (! conv) {
conv = purple_conversation_new (PURPLE_CONV_TYPE_IM, tg_get_acc (TLS), name);
}
purple_conversation_write (conv, name, msg, flags, now);
break;
}
}
@ -530,7 +532,7 @@ static void tgp_msg_display (struct tgl_state *TLS, struct tgp_msg_loading *C) {
break;
}
case TGL_PEER_ENCR_CHAT: {
serv_got_im (tg_get_conn (TLS), tgp_blist_peer_get_name (TLS, M->to_id), text, flags, M->date);
p2tgl_got_im_combo (TLS, M->to_id, text, flags, M->date);
pending_reads_add (conn->pending_reads, M->to_id);
break;
}
@ -540,14 +542,14 @@ static void tgp_msg_display (struct tgl_state *TLS, struct tgp_msg_loading *C) {
flags &= ~PURPLE_MESSAGE_RECV;
p2tgl_got_im_combo (TLS, M->to_id, text, flags, M->date);
} else {
serv_got_im (tg_get_conn (TLS), tgp_blist_peer_get_name (TLS, M->from_id), text, flags, M->date);
p2tgl_got_im_combo (TLS, M->from_id, text, flags, M->date);
pending_reads_add (conn->pending_reads, M->from_id);
}
break;
}
}
if (p2tgl_status_is_present (purple_account_get_active_status (conn->pa)) && p2tgl_send_notifications(conn->pa)) {
if (p2tgl_status_is_present (purple_account_get_active_status (conn->pa)) && p2tgl_send_notifications (conn->pa)) {
pending_reads_send_all (conn->pending_reads, conn->TLS);
}