mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
xep-0308: enable corrections for outgoing encrypted messages
This commit is contained in:
parent
38c32be14c
commit
11b6e1bfa0
@ -7529,7 +7529,7 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args)
|
||||
|
||||
if (!otr_is_secure(barejid)) {
|
||||
char *otr_query_message = otr_start_query();
|
||||
char *id = message_send_chat_otr(barejid, otr_query_message, FALSE);
|
||||
char *id = message_send_chat_otr(barejid, otr_query_message, FALSE, NULL);
|
||||
free(id);
|
||||
return TRUE;
|
||||
}
|
||||
@ -7562,7 +7562,8 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
|
||||
char *otr_query_message = otr_start_query();
|
||||
char *id = message_send_chat_otr(chatwin->barejid, otr_query_message, FALSE);
|
||||
char *id = message_send_chat_otr(chatwin->barejid, otr_query_message, FALSE, NULL);
|
||||
|
||||
free(id);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -149,13 +149,12 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *
|
||||
#ifdef HAVE_LIBGPGME
|
||||
#ifndef HAVE_OMEMO
|
||||
if (chatwin->pgp_send) {
|
||||
// TODO: replace_id
|
||||
char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt);
|
||||
char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt, replace_id);
|
||||
chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt, replace_id);
|
||||
free(id);
|
||||
} else {
|
||||
gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt);
|
||||
gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt, replace_id);
|
||||
if (!handled) {
|
||||
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
|
||||
chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
@ -175,7 +174,7 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *
|
||||
#ifdef HAVE_LIBOTR
|
||||
#ifndef HAVE_LIBGPGME
|
||||
#ifndef HAVE_OMEMO
|
||||
gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt);
|
||||
gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt, replace_id);
|
||||
if (!handled) {
|
||||
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
|
||||
chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
@ -195,9 +194,9 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *
|
||||
#ifdef HAVE_LIBGPGME
|
||||
#ifndef HAVE_OMEMO
|
||||
if (chatwin->pgp_send) {
|
||||
char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt);
|
||||
char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt, replace_id);
|
||||
chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt, replace_id);
|
||||
free(id);
|
||||
} else {
|
||||
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
|
||||
@ -218,7 +217,7 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *
|
||||
#ifndef HAVE_LIBGPGME
|
||||
#ifdef HAVE_OMEMO
|
||||
if (chatwin->is_omemo) {
|
||||
char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE);
|
||||
char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE, replace_id);
|
||||
chat_log_omemo_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, request_receipt);
|
||||
free(id);
|
||||
@ -241,12 +240,12 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *
|
||||
#ifndef HAVE_LIBGPGME
|
||||
#ifdef HAVE_OMEMO
|
||||
if (chatwin->is_omemo) {
|
||||
char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE);
|
||||
char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE, replace_id);
|
||||
chat_log_omemo_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, request_receipt);
|
||||
free(id);
|
||||
} else {
|
||||
gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt);
|
||||
gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt, replace_id);
|
||||
if (!handled) {
|
||||
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
|
||||
chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
@ -267,19 +266,19 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *
|
||||
#ifdef HAVE_LIBGPGME
|
||||
#ifdef HAVE_OMEMO
|
||||
if (chatwin->is_omemo) {
|
||||
char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE);
|
||||
char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE, replace_id);
|
||||
chat_log_omemo_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, request_receipt);
|
||||
free(id);
|
||||
} else if (chatwin->pgp_send) {
|
||||
char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt);
|
||||
char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt, replace_id);
|
||||
chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt, replace_id);
|
||||
free(id);
|
||||
} else {
|
||||
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt);
|
||||
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
|
||||
chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt, replace_id);
|
||||
free(id);
|
||||
}
|
||||
|
||||
@ -295,17 +294,17 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *
|
||||
#ifdef HAVE_LIBGPGME
|
||||
#ifdef HAVE_OMEMO
|
||||
if (chatwin->is_omemo) {
|
||||
char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE);
|
||||
char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE, replace_id);
|
||||
chat_log_omemo_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, request_receipt, replace_id);
|
||||
free(id);
|
||||
} else if (chatwin->pgp_send) {
|
||||
char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt);
|
||||
char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt, replace_id);
|
||||
chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt, replace_id);
|
||||
free(id);
|
||||
} else {
|
||||
gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt);
|
||||
gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt, replace_id);
|
||||
if (!handled) {
|
||||
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
|
||||
chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
@ -325,9 +324,9 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *
|
||||
#ifndef HAVE_LIBOTR
|
||||
#ifndef HAVE_LIBGPGME
|
||||
#ifndef HAVE_OMEMO
|
||||
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt);
|
||||
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
|
||||
chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt);
|
||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt, replace_id);
|
||||
free(id);
|
||||
|
||||
plugins_post_chat_message_send(chatwin->barejid, plugin_msg);
|
||||
@ -354,7 +353,8 @@ cl_ev_send_muc_msg(ProfMucWin *mucwin, const char *const msg, const char *const
|
||||
|
||||
#ifdef HAVE_OMEMO
|
||||
if (mucwin->is_omemo) {
|
||||
char *id = omemo_on_message_send((ProfWin *)mucwin, plugin_msg, FALSE, TRUE);
|
||||
// TODO: replace_id for MUC
|
||||
char *id = omemo_on_message_send((ProfWin *)mucwin, plugin_msg, FALSE, TRUE, NULL);
|
||||
groupchat_log_omemo_msg_out(mucwin->roomjid, plugin_msg);
|
||||
mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_ENC_OMEMO);
|
||||
free(id);
|
||||
|
@ -671,7 +671,7 @@ out:
|
||||
}
|
||||
|
||||
char *
|
||||
omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_receipt, gboolean muc)
|
||||
omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_receipt, gboolean muc, const char *const replace_id)
|
||||
{
|
||||
char *id = NULL;
|
||||
int res;
|
||||
@ -809,11 +809,11 @@ omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_
|
||||
if (muc) {
|
||||
ProfMucWin *mucwin = (ProfMucWin *)win;
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
id = message_send_chat_omemo(mucwin->roomjid, omemo_ctx.device_id, keys, iv, AES128_GCM_IV_LENGTH, ciphertext, ciphertext_len, request_receipt, TRUE);
|
||||
id = message_send_chat_omemo(mucwin->roomjid, omemo_ctx.device_id, keys, iv, AES128_GCM_IV_LENGTH, ciphertext, ciphertext_len, request_receipt, TRUE, replace_id);
|
||||
} else {
|
||||
ProfChatWin *chatwin = (ProfChatWin *)win;
|
||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||
id = message_send_chat_omemo(chatwin->barejid, omemo_ctx.device_id, keys, iv, AES128_GCM_IV_LENGTH, ciphertext, ciphertext_len, request_receipt, FALSE);
|
||||
id = message_send_chat_omemo(chatwin->barejid, omemo_ctx.device_id, keys, iv, AES128_GCM_IV_LENGTH, ciphertext, ciphertext_len, request_receipt, FALSE, replace_id);
|
||||
}
|
||||
|
||||
out:
|
||||
|
@ -92,5 +92,5 @@ void omemo_start_muc_sessions(const char *const roomjid);
|
||||
void omemo_start_device_session(const char *const jid, uint32_t device_id, GList *prekeys, uint32_t signed_prekey_id, const unsigned char *const signed_prekey, size_t signed_prekey_len, const unsigned char *const signature, size_t signature_len, const unsigned char *const identity_key, size_t identity_key_len);
|
||||
|
||||
gboolean omemo_loaded(void);
|
||||
char * omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_receipt, gboolean muc);
|
||||
char * omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_receipt, gboolean muc, const char *const replace_id);
|
||||
char * omemo_on_message_recv(const char *const from, uint32_t sid, const unsigned char *const iv, size_t iv_len, GList *keys, const unsigned char *const payload, size_t payload_len, gboolean muc, gboolean *trusted);
|
||||
|
@ -118,7 +118,7 @@ static void
|
||||
cb_inject_message(void *opdata, const char *accountname,
|
||||
const char *protocol, const char *recipient, const char *message)
|
||||
{
|
||||
char *id = message_send_chat_otr(recipient, message, FALSE);
|
||||
char *id = message_send_chat_otr(recipient, message, FALSE, NULL);
|
||||
free(id);
|
||||
}
|
||||
|
||||
@ -315,7 +315,7 @@ otr_on_message_recv(const char *const barejid, const char *const resource, const
|
||||
memmove(whitespace_base, whitespace_base+tag_length, tag_length);
|
||||
char *otr_query_message = otr_start_query();
|
||||
cons_show("OTR Whitespace pattern detected. Attempting to start OTR session...");
|
||||
char *id = message_send_chat_otr(barejid, otr_query_message, FALSE);
|
||||
char *id = message_send_chat_otr(barejid, otr_query_message, FALSE, NULL);
|
||||
free(id);
|
||||
}
|
||||
}
|
||||
@ -329,7 +329,7 @@ otr_on_message_recv(const char *const barejid, const char *const resource, const
|
||||
if (policy == PROF_OTRPOLICY_ALWAYS && *decrypted == FALSE && !whitespace_base) {
|
||||
char *otr_query_message = otr_start_query();
|
||||
cons_show("Attempting to start OTR session...");
|
||||
char *id = message_send_chat_otr(barejid, otr_query_message, FALSE);
|
||||
char *id = message_send_chat_otr(barejid, otr_query_message, FALSE, NULL);
|
||||
free(id);
|
||||
}
|
||||
|
||||
@ -337,7 +337,7 @@ otr_on_message_recv(const char *const barejid, const char *const resource, const
|
||||
}
|
||||
|
||||
gboolean
|
||||
otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean request_receipt)
|
||||
otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean request_receipt, const char *const replace_id)
|
||||
{
|
||||
char *id = NULL;
|
||||
prof_otrpolicy_t policy = otr_get_policy(chatwin->barejid);
|
||||
@ -346,10 +346,9 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re
|
||||
if (otr_is_secure(chatwin->barejid)) {
|
||||
char *encrypted = otr_encrypt_message(chatwin->barejid, message);
|
||||
if (encrypted) {
|
||||
id = message_send_chat_otr(chatwin->barejid, encrypted, request_receipt);
|
||||
id = message_send_chat_otr(chatwin->barejid, encrypted, request_receipt, replace_id);
|
||||
chat_log_otr_msg_out(chatwin->barejid, message, NULL);
|
||||
// TODO replace_id
|
||||
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_OTR, request_receipt, NULL);
|
||||
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_OTR, request_receipt, replace_id);
|
||||
otr_free_message(encrypted);
|
||||
free(id);
|
||||
return TRUE;
|
||||
@ -368,9 +367,8 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re
|
||||
// tag and send for policy opportunistic
|
||||
if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
|
||||
char *otr_tagged_msg = otr_tag_message(message);
|
||||
id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg, request_receipt);
|
||||
//TODO replace_id
|
||||
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_PLAIN, request_receipt, NULL);
|
||||
id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg, request_receipt, replace_id);
|
||||
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_PLAIN, request_receipt, replace_id);
|
||||
chat_log_msg_out(chatwin->barejid, message, NULL);
|
||||
free(otr_tagged_msg);
|
||||
free(id);
|
||||
|
@ -73,7 +73,7 @@ void otr_poll(void);
|
||||
void otr_on_connect(ProfAccount *account);
|
||||
|
||||
char* otr_on_message_recv(const char *const barejid, const char *const resource, const char *const message, gboolean *decrypted);
|
||||
gboolean otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean request_receipt);
|
||||
gboolean otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean request_receipt, const char *const replace_id);
|
||||
|
||||
void otr_keygen(ProfAccount *account);
|
||||
|
||||
|
@ -294,7 +294,7 @@ message_send_chat(const char *const barejid, const char *const msg, const char *
|
||||
}
|
||||
|
||||
char*
|
||||
message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean request_receipt)
|
||||
message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id)
|
||||
{
|
||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||
|
||||
@ -346,6 +346,10 @@ message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean
|
||||
stanza_attach_receipt_request(ctx, message);
|
||||
}
|
||||
|
||||
if (replace_id) {
|
||||
stanza_attach_correction(ctx, message, replace_id);
|
||||
}
|
||||
|
||||
_send_message_stanza(message);
|
||||
xmpp_stanza_release(message);
|
||||
|
||||
@ -353,7 +357,7 @@ message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean
|
||||
}
|
||||
|
||||
char*
|
||||
message_send_chat_otr(const char *const barejid, const char *const msg, gboolean request_receipt)
|
||||
message_send_chat_otr(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id)
|
||||
{
|
||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||
|
||||
@ -378,6 +382,10 @@ message_send_chat_otr(const char *const barejid, const char *const msg, gboolean
|
||||
stanza_attach_receipt_request(ctx, message);
|
||||
}
|
||||
|
||||
if (replace_id) {
|
||||
stanza_attach_correction(ctx, message, replace_id);
|
||||
}
|
||||
|
||||
_send_message_stanza(message);
|
||||
xmpp_stanza_release(message);
|
||||
|
||||
@ -389,7 +397,7 @@ char*
|
||||
message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys,
|
||||
const unsigned char *const iv, size_t iv_len,
|
||||
const unsigned char *const ciphertext, size_t ciphertext_len,
|
||||
gboolean request_receipt, gboolean muc)
|
||||
gboolean request_receipt, gboolean muc, const char *const replace_id)
|
||||
{
|
||||
char *state = chat_session_get_state(jid);
|
||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||
@ -489,6 +497,10 @@ message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys,
|
||||
stanza_attach_receipt_request(ctx, message);
|
||||
}
|
||||
|
||||
if (replace_id) {
|
||||
stanza_attach_correction(ctx, message, replace_id);
|
||||
}
|
||||
|
||||
_send_message_stanza(message);
|
||||
xmpp_stanza_release(message);
|
||||
|
||||
|
@ -172,9 +172,9 @@ char* connection_jid_for_feature(const char *const feature);
|
||||
const char* connection_get_profanity_identifier(void);
|
||||
|
||||
char* message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url, gboolean request_receipt, const char *const replace_id);
|
||||
char* message_send_chat_otr(const char *const barejid, const char *const msg, gboolean request_receipt);
|
||||
char* message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean request_receipt);
|
||||
char* message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys, const unsigned char *const iv, size_t iv_len, const unsigned char *const ciphertext, size_t ciphertext_len, gboolean request_receipt, gboolean muc);
|
||||
char* message_send_chat_otr(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id);
|
||||
char* message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id);
|
||||
char* message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys, const unsigned char *const iv, size_t iv_len, const unsigned char *const ciphertext, size_t ciphertext_len, gboolean request_receipt, gboolean muc, const char *const replace_id);
|
||||
void message_send_private(const char *const fulljid, const char *const msg, const char *const oob_url);
|
||||
char* message_send_groupchat(const char *const roomjid, const char *const msg, const char *const oob_url);
|
||||
void message_send_groupchat_subject(const char *const roomjid, const char *const subject);
|
||||
|
Loading…
Reference in New Issue
Block a user