1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Show message received text for receipts

This commit is contained in:
James Booth 2015-03-11 23:47:11 +00:00
parent 78becceedb
commit 57c7564445
11 changed files with 54 additions and 34 deletions

View File

@ -1945,7 +1945,7 @@ _cmd_execute_default(const char * inp)
if (otr_is_secure(chatwin->barejid)) { if (otr_is_secure(chatwin->barejid)) {
char *encrypted = otr_encrypt_message(chatwin->barejid, inp); char *encrypted = otr_encrypt_message(chatwin->barejid, inp);
if (encrypted != NULL) { if (encrypted != NULL) {
message_send_chat_encrypted(chatwin->barejid, encrypted); char *id = message_send_chat_encrypted(chatwin->barejid, encrypted);
otr_free_message(encrypted); otr_free_message(encrypted);
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid(); const char *jid = jabber_get_fulljid();
@ -1960,12 +1960,12 @@ _cmd_execute_default(const char * inp)
jid_destroy(jidp); jid_destroy(jidp);
} }
ui_outgoing_chat_msg("me", chatwin->barejid, inp); ui_outgoing_chat_msg("me", chatwin->barejid, inp, id);
} else { } else {
cons_show_error("Failed to send message."); cons_show_error("Failed to send message.");
} }
} else { } else {
message_send_chat(chatwin->barejid, inp); char *id = message_send_chat(chatwin->barejid, inp);
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid(); const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid); Jid *jidp = jid_create(jid);
@ -1973,10 +1973,10 @@ _cmd_execute_default(const char * inp)
jid_destroy(jidp); jid_destroy(jidp);
} }
ui_outgoing_chat_msg("me", chatwin->barejid, inp); ui_outgoing_chat_msg("me", chatwin->barejid, inp, id);
} }
#else #else
message_send_chat(chatwin->barejid, inp); char *id = message_send_chat(chatwin->barejid, inp);
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid(); const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid); Jid *jidp = jid_create(jid);
@ -1984,7 +1984,7 @@ _cmd_execute_default(const char * inp)
jid_destroy(jidp); jid_destroy(jidp);
} }
ui_outgoing_chat_msg("me", chatwin->barejid, inp); ui_outgoing_chat_msg("me", chatwin->barejid, inp, id);
#endif #endif
} }
break; break;

View File

@ -1265,9 +1265,9 @@ cmd_msg(gchar **args, struct cmd_help_t help)
if (otr_is_secure(barejid)) { if (otr_is_secure(barejid)) {
char *encrypted = otr_encrypt_message(barejid, msg); char *encrypted = otr_encrypt_message(barejid, msg);
if (encrypted != NULL) { if (encrypted != NULL) {
message_send_chat_encrypted(barejid, encrypted); char *id = message_send_chat_encrypted(barejid, encrypted);
otr_free_message(encrypted); otr_free_message(encrypted);
ui_outgoing_chat_msg("me", barejid, msg); ui_outgoing_chat_msg("me", barejid, msg, id);
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) { if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid(); const char *jid = jabber_get_fulljid();
@ -1286,6 +1286,7 @@ cmd_msg(gchar **args, struct cmd_help_t help)
} }
} else { } else {
prof_otrpolicy_t policy = otr_get_policy(barejid); prof_otrpolicy_t policy = otr_get_policy(barejid);
char *id = NULL;
if (policy == PROF_OTRPOLICY_ALWAYS) { if (policy == PROF_OTRPOLICY_ALWAYS) {
cons_show_error("Failed to send message. Please check OTR policy"); cons_show_error("Failed to send message. Please check OTR policy");
@ -1294,13 +1295,13 @@ cmd_msg(gchar **args, struct cmd_help_t help)
GString *otr_message = g_string_new(msg); GString *otr_message = g_string_new(msg);
g_string_append(otr_message, OTRL_MESSAGE_TAG_BASE); g_string_append(otr_message, OTRL_MESSAGE_TAG_BASE);
g_string_append(otr_message, OTRL_MESSAGE_TAG_V2); g_string_append(otr_message, OTRL_MESSAGE_TAG_V2);
message_send_chat_encrypted(barejid, otr_message->str); id = message_send_chat_encrypted(barejid, otr_message->str);
g_string_free(otr_message, TRUE); g_string_free(otr_message, TRUE);
} else { } else {
message_send_chat(barejid, msg); id = message_send_chat(barejid, msg);
} }
ui_outgoing_chat_msg("me", barejid, msg); ui_outgoing_chat_msg("me", barejid, msg, id);
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) { if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid(); const char *jid = jabber_get_fulljid();
@ -3073,7 +3074,7 @@ cmd_tiny(gchar **args, struct cmd_help_t help)
if (otr_is_secure(chatwin->barejid)) { if (otr_is_secure(chatwin->barejid)) {
char *encrypted = otr_encrypt_message(chatwin->barejid, tiny); char *encrypted = otr_encrypt_message(chatwin->barejid, tiny);
if (encrypted != NULL) { if (encrypted != NULL) {
message_send_chat_encrypted(chatwin->barejid, encrypted); char *id = message_send_chat_encrypted(chatwin->barejid, encrypted);
otr_free_message(encrypted); otr_free_message(encrypted);
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid(); const char *jid = jabber_get_fulljid();
@ -3088,12 +3089,12 @@ cmd_tiny(gchar **args, struct cmd_help_t help)
jid_destroy(jidp); jid_destroy(jidp);
} }
ui_outgoing_chat_msg("me", chatwin->barejid, tiny); ui_outgoing_chat_msg("me", chatwin->barejid, tiny, id);
} else { } else {
cons_show_error("Failed to send message."); cons_show_error("Failed to send message.");
} }
} else { } else {
message_send_chat(chatwin->barejid, tiny); char *id = message_send_chat(chatwin->barejid, tiny);
if (prefs_get_boolean(PREF_CHLOG)) { if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid(); const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid); Jid *jidp = jid_create(jid);
@ -3101,7 +3102,7 @@ cmd_tiny(gchar **args, struct cmd_help_t help)
jid_destroy(jidp); jid_destroy(jidp);
} }
ui_outgoing_chat_msg("me", chatwin->barejid, tiny); ui_outgoing_chat_msg("me", chatwin->barejid, tiny, id);
} }
#else #else
message_send_chat(chatwin->barejid, tiny); message_send_chat(chatwin->barejid, tiny);

View File

@ -310,7 +310,7 @@ handle_incoming_private_message(char *fulljid, char *message)
void void
handle_carbon(char *barejid, char *message){ handle_carbon(char *barejid, char *message){
ui_outgoing_chat_msg("me", barejid, message); ui_outgoing_chat_msg("me", barejid, message, NULL);
} }
void void

View File

@ -1424,7 +1424,7 @@ ui_open_xmlconsole_win(void)
void void
ui_outgoing_chat_msg(const char * const from, const char * const barejid, ui_outgoing_chat_msg(const char * const from, const char * const barejid,
const char * const message) const char * const message, char *id)
{ {
PContact contact = roster_get_contact(barejid); PContact contact = roster_get_contact(barejid);
ProfWin *window = (ProfWin*)wins_get_chat(barejid); ProfWin *window = (ProfWin*)wins_get_chat(barejid);
@ -1460,7 +1460,16 @@ ui_outgoing_chat_msg(const char * const from, const char * const barejid,
ProfChatWin *chatwin = (ProfChatWin*)window; ProfChatWin *chatwin = (ProfChatWin*)window;
chat_state_active(chatwin->state); chat_state_active(chatwin->state);
win_save_print(window, '-', NULL, 0, THEME_TEXT_ME, from, message); if (id) {
GString *message_with_id = g_string_new(id);
g_string_append(message_with_id, ": ");
g_string_append(message_with_id, message);
win_save_print(window, '-', NULL, 0, THEME_TEXT_ME, from, message_with_id->str);
g_string_free(message_with_id, TRUE);
free(id);
} else {
win_save_print(window, '-', NULL, 0, THEME_TEXT_ME, from, message);
}
ui_switch_win(num); ui_switch_win(num);
} }

View File

@ -122,7 +122,7 @@ void ui_disconnected(void);
void ui_recipient_gone(const char * const barejid, const char * const resource); void ui_recipient_gone(const char * const barejid, const char * const resource);
void ui_outgoing_chat_msg(const char * const from, const char * const barejid, void ui_outgoing_chat_msg(const char * const from, const char * const barejid,
const char * const message); const char * const message, char *id);
void ui_outgoing_private_msg(const char * const from, const char * const fulljid, void ui_outgoing_private_msg(const char * const from, const char * const fulljid,
const char * const message); const char * const message);

View File

@ -79,7 +79,7 @@ message_add_handlers(void)
HANDLE(STANZA_NS_CAPTCHA, NULL, _captcha_handler); HANDLE(STANZA_NS_CAPTCHA, NULL, _captcha_handler);
} }
void char *
message_send_chat(const char * const barejid, const char * const msg) message_send_chat(const char * const barejid, const char * const msg)
{ {
xmpp_conn_t * const conn = connection_get_conn(); xmpp_conn_t * const conn = connection_get_conn();
@ -103,7 +103,8 @@ message_send_chat(const char * const barejid, const char * const msg)
jid = strdup(barejid); jid = strdup(barejid);
} }
xmpp_stanza_t *message = stanza_create_message(ctx, jid, STANZA_TYPE_CHAT, msg); char *id = create_unique_id("msg");
xmpp_stanza_t *message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg);
free(jid); free(jid);
if (state) { if (state) {
@ -115,9 +116,11 @@ message_send_chat(const char * const barejid, const char * const msg)
xmpp_send(conn, message); xmpp_send(conn, message);
xmpp_stanza_release(message); xmpp_stanza_release(message);
return id;
} }
void char *
message_send_chat_encrypted(const char * const barejid, const char * const msg) message_send_chat_encrypted(const char * const barejid, const char * const msg)
{ {
xmpp_conn_t * const conn = connection_get_conn(); xmpp_conn_t * const conn = connection_get_conn();
@ -140,7 +143,8 @@ message_send_chat_encrypted(const char * const barejid, const char * const msg)
jid = strdup(barejid); jid = strdup(barejid);
} }
xmpp_stanza_t *message = stanza_create_message(ctx, barejid, STANZA_TYPE_CHAT, msg); char *id = create_unique_id("msg");
xmpp_stanza_t *message = stanza_create_message(ctx, id, barejid, STANZA_TYPE_CHAT, msg);
free(jid); free(jid);
if (state) { if (state) {
@ -153,6 +157,8 @@ message_send_chat_encrypted(const char * const barejid, const char * const msg)
xmpp_send(conn, message); xmpp_send(conn, message);
xmpp_stanza_release(message); xmpp_stanza_release(message);
return id;
} }
void void
@ -160,7 +166,9 @@ message_send_private(const char * const fulljid, const char * const msg)
{ {
xmpp_conn_t * const conn = connection_get_conn(); xmpp_conn_t * const conn = connection_get_conn();
xmpp_ctx_t * const ctx = connection_get_ctx(); xmpp_ctx_t * const ctx = connection_get_ctx();
xmpp_stanza_t *message = stanza_create_message(ctx, fulljid, STANZA_TYPE_CHAT, msg); char *id = create_unique_id("prv");
xmpp_stanza_t *message = stanza_create_message(ctx, id, fulljid, STANZA_TYPE_CHAT, msg);
free(id);
xmpp_send(conn, message); xmpp_send(conn, message);
xmpp_stanza_release(message); xmpp_stanza_release(message);
@ -171,7 +179,9 @@ message_send_groupchat(const char * const roomjid, const char * const msg)
{ {
xmpp_conn_t * const conn = connection_get_conn(); xmpp_conn_t * const conn = connection_get_conn();
xmpp_ctx_t * const ctx = connection_get_ctx(); xmpp_ctx_t * const ctx = connection_get_ctx();
xmpp_stanza_t *message = stanza_create_message(ctx, roomjid, STANZA_TYPE_GROUPCHAT, msg); char *id = create_unique_id("muc");
xmpp_stanza_t *message = stanza_create_message(ctx, id, roomjid, STANZA_TYPE_GROUPCHAT, msg);
free(id);
xmpp_send(conn, message); xmpp_send(conn, message);
xmpp_stanza_release(message); xmpp_stanza_release(message);

View File

@ -318,7 +318,7 @@ stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza)
} }
xmpp_stanza_t * xmpp_stanza_t *
stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient, stanza_create_message(xmpp_ctx_t *ctx, char *id, const char * const recipient,
const char * const type, const char * const message) const char * const type, const char * const message)
{ {
xmpp_stanza_t *msg, *body, *text; xmpp_stanza_t *msg, *body, *text;
@ -327,9 +327,7 @@ stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient,
xmpp_stanza_set_name(msg, STANZA_NAME_MESSAGE); xmpp_stanza_set_name(msg, STANZA_NAME_MESSAGE);
xmpp_stanza_set_type(msg, type); xmpp_stanza_set_type(msg, type);
xmpp_stanza_set_attribute(msg, STANZA_ATTR_TO, recipient); xmpp_stanza_set_attribute(msg, STANZA_ATTR_TO, recipient);
char *id = create_unique_id(NULL);
xmpp_stanza_set_id(msg, id); xmpp_stanza_set_id(msg, id);
free(id);
body = xmpp_stanza_new(ctx); body = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(body, STANZA_NAME_BODY); xmpp_stanza_set_name(body, STANZA_NAME_BODY);

View File

@ -194,7 +194,7 @@ xmpp_stanza_t * stanza_attach_state(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, cons
xmpp_stanza_t * stanza_attach_carbons_private(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza); xmpp_stanza_t * stanza_attach_carbons_private(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza);
xmpp_stanza_t * stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza); xmpp_stanza_t * stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza);
xmpp_stanza_t* stanza_create_message(xmpp_ctx_t *ctx, xmpp_stanza_t* stanza_create_message(xmpp_ctx_t *ctx, char *id,
const char * const recipient, const char * const type, const char * const message); const char * const recipient, const char * const type, const char * const message);
xmpp_stanza_t* stanza_create_room_join_presence(xmpp_ctx_t * const ctx, xmpp_stanza_t* stanza_create_room_join_presence(xmpp_ctx_t * const ctx,

View File

@ -145,8 +145,8 @@ char* jabber_get_account_name(void);
GList * jabber_get_available_resources(void); GList * jabber_get_available_resources(void);
// message functions // message functions
void message_send_chat(const char * const barejid, const char * const msg); char* message_send_chat(const char * const barejid, const char * const msg);
void message_send_chat_encrypted(const char * const barejid, const char * const msg); char* message_send_chat_encrypted(const char * const barejid, const char * const msg);
void message_send_private(const char * const fulljid, const char * const msg); void message_send_private(const char * const fulljid, const char * const msg);
void message_send_groupchat(const char * const roomjid, const char * const msg); void message_send_groupchat(const char * const roomjid, const char * const msg);
void message_send_groupchat_subject(const char * const roomjid, const char * const subject); void message_send_groupchat_subject(const char * const roomjid, const char * const subject);

View File

@ -202,7 +202,7 @@ void ui_disconnected(void) {}
void ui_recipient_gone(const char * const barejid, const char * const resource) {} void ui_recipient_gone(const char * const barejid, const char * const resource) {}
void ui_outgoing_chat_msg(const char * const from, const char * const barejid, void ui_outgoing_chat_msg(const char * const from, const char * const barejid,
const char * const message) {} const char * const message, char *id) {}
void ui_outgoing_private_msg(const char * const from, const char * const fulljid, void ui_outgoing_private_msg(const char * const from, const char * const fulljid,
const char * const message) {} const char * const message) {}

View File

@ -58,16 +58,18 @@ GList * jabber_get_available_resources(void)
} }
// message functions // message functions
void message_send_chat(const char * const barejid, const char * const msg) char* message_send_chat(const char * const barejid, const char * const msg)
{ {
check_expected(barejid); check_expected(barejid);
check_expected(msg); check_expected(msg);
return NULL;
} }
void message_send_chat_encrypted(const char * const barejid, const char * const msg) char* message_send_chat_encrypted(const char * const barejid, const char * const msg)
{ {
check_expected(barejid); check_expected(barejid);
check_expected(msg); check_expected(msg);
return NULL;
} }
void message_send_private(const char * const fulljid, const char * const msg) {} void message_send_private(const char * const fulljid, const char * const msg) {}