mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Merge pull request #1135 from paulfariello/hotfix/Fix_handling_of_encrypted_carbons
Fix handling of encrypted carbons
This commit is contained in:
commit
4fa5fbaea4
@ -420,26 +420,35 @@ sv_ev_delayed_private_message(ProfMessage *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message, gboolean omemo)
|
sv_ev_outgoing_carbon(ProfMessage *message)
|
||||||
{
|
{
|
||||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
ProfChatWin *chatwin = wins_get_chat(message->jid->barejid);
|
||||||
if (!chatwin) {
|
if (!chatwin) {
|
||||||
chatwin = chatwin_new(barejid);
|
chatwin = chatwin_new(message->jid->barejid);
|
||||||
}
|
}
|
||||||
|
|
||||||
chat_state_active(chatwin->state);
|
chat_state_active(chatwin->state);
|
||||||
|
|
||||||
#ifdef HAVE_LIBGPGME
|
#ifdef HAVE_LIBGPGME
|
||||||
#ifndef HAVE_OMEMO
|
#ifndef HAVE_OMEMO
|
||||||
if (pgp_message) {
|
if (message->encrypted) {
|
||||||
char *decrypted = p_gpg_decrypt(pgp_message);
|
message->plain = p_gpg_decrypt(message->encrypted);
|
||||||
if (decrypted) {
|
if (message->plain) {
|
||||||
chatwin_outgoing_carbon(chatwin, decrypted, PROF_MSG_ENC_PGP);
|
message->enc = PROF_MSG_ENC_PGP;
|
||||||
|
chatwin_outgoing_carbon(chatwin, message);
|
||||||
} else {
|
} else {
|
||||||
chatwin_outgoing_carbon(chatwin, message, PROF_MSG_ENC_PLAIN);
|
if (!message->body) {
|
||||||
|
log_error("Couldn't decrypt GPG message and body was empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
message->enc = PROF_MSG_ENC_PLAIN;
|
||||||
|
message->plain = strdup(message->body);
|
||||||
|
chatwin_outgoing_carbon(chatwin, message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chatwin_outgoing_carbon(chatwin, message, PROF_MSG_ENC_PLAIN);
|
message->enc = PROF_MSG_ENC_PLAIN;
|
||||||
|
message->plain = strdup(message->body);
|
||||||
|
chatwin_outgoing_carbon(chatwin, message);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
@ -447,10 +456,12 @@ sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message, gboolean
|
|||||||
|
|
||||||
#ifndef HAVE_LIBGPGME
|
#ifndef HAVE_LIBGPGME
|
||||||
#ifdef HAVE_OMEMO
|
#ifdef HAVE_OMEMO
|
||||||
if (omemo) {
|
if (message->enc == PROF_MSG_ENC_OMEMO) {
|
||||||
chatwin_outgoing_carbon(chatwin, message, PROF_MSG_ENC_OMEMO);
|
chatwin_outgoing_carbon(chatwin, message);
|
||||||
} else {
|
} else {
|
||||||
chatwin_outgoing_carbon(chatwin, message, PROF_MSG_ENC_PLAIN);
|
message->enc = PROF_MSG_ENC_PLAIN;
|
||||||
|
message->plain = strdup(message->body);
|
||||||
|
chatwin_outgoing_carbon(chatwin, message);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
@ -458,17 +469,26 @@ sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message, gboolean
|
|||||||
|
|
||||||
#ifdef HAVE_LIBGPGME
|
#ifdef HAVE_LIBGPGME
|
||||||
#ifdef HAVE_OMEMO
|
#ifdef HAVE_OMEMO
|
||||||
if (omemo) {
|
if (message->enc == PROF_MSG_ENC_OMEMO) {
|
||||||
chatwin_outgoing_carbon(chatwin, message, PROF_MSG_ENC_OMEMO);
|
chatwin_outgoing_carbon(chatwin, message);
|
||||||
} else if (pgp_message) {
|
} else if (message->encrypted) {
|
||||||
char *decrypted = p_gpg_decrypt(pgp_message);
|
message->plain = p_gpg_decrypt(message->encrypted);
|
||||||
if (decrypted) {
|
if (message->plain) {
|
||||||
chatwin_outgoing_carbon(chatwin, decrypted, PROF_MSG_ENC_PGP);
|
message->enc = PROF_MSG_ENC_PGP;
|
||||||
|
chatwin_outgoing_carbon(chatwin, message);
|
||||||
} else {
|
} else {
|
||||||
chatwin_outgoing_carbon(chatwin, message, PROF_MSG_ENC_PLAIN);
|
if (!message->body) {
|
||||||
|
log_error("Couldn't decrypt GPG message and body was empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
message->enc = PROF_MSG_ENC_PLAIN;
|
||||||
|
message->plain = strdup(message->body);
|
||||||
|
chatwin_outgoing_carbon(chatwin, message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chatwin_outgoing_carbon(chatwin, message, PROF_MSG_ENC_PLAIN);
|
message->enc = PROF_MSG_ENC_PLAIN;
|
||||||
|
message->plain = strdup(message->body);
|
||||||
|
chatwin_outgoing_carbon(chatwin, message);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
@ -476,7 +496,11 @@ sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message, gboolean
|
|||||||
|
|
||||||
#ifndef HAVE_LIBGPGME
|
#ifndef HAVE_LIBGPGME
|
||||||
#ifndef HAVE_OMEMO
|
#ifndef HAVE_OMEMO
|
||||||
chatwin_outgoing_carbon(chatwin, message, PROF_MSG_ENC_PLAIN);
|
if (message->body) {
|
||||||
|
message->enc = PROF_MSG_ENC_PLAIN;
|
||||||
|
message->plain = strdup(message->body);
|
||||||
|
chatwin_outgoing_carbon(chatwin, message);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -494,7 +518,12 @@ _sv_ev_incoming_pgp(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message
|
|||||||
p_gpg_free_decrypted(message->plain);
|
p_gpg_free_decrypted(message->plain);
|
||||||
message->plain = NULL;
|
message->plain = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
if (!message->body) {
|
||||||
|
log_error("Couldn't decrypt GPG message and body was empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
message->enc = PROF_MSG_ENC_PLAIN;
|
message->enc = PROF_MSG_ENC_PLAIN;
|
||||||
|
message->plain = strdup(message->body);
|
||||||
chatwin_incoming_msg(chatwin, message, new_win);
|
chatwin_incoming_msg(chatwin, message, new_win);
|
||||||
chat_log_msg_in(message);
|
chat_log_msg_in(message);
|
||||||
chatwin->pgp_recv = FALSE;
|
chatwin->pgp_recv = FALSE;
|
||||||
@ -539,11 +568,14 @@ _sv_ev_incoming_omemo(ProfChatWin *chatwin, gboolean new_win, ProfMessage *messa
|
|||||||
static void
|
static void
|
||||||
_sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message)
|
_sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message)
|
||||||
{
|
{
|
||||||
|
if (message->body) {
|
||||||
|
message->enc = PROF_MSG_ENC_PLAIN;
|
||||||
message->plain = strdup(message->body);
|
message->plain = strdup(message->body);
|
||||||
chatwin_incoming_msg(chatwin, message, new_win);
|
chatwin_incoming_msg(chatwin, message, new_win);
|
||||||
chat_log_msg_in(message);
|
chat_log_msg_in(message);
|
||||||
chatwin->pgp_recv = FALSE;
|
chatwin->pgp_recv = FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sv_ev_incoming_message(ProfMessage *message)
|
sv_ev_incoming_message(ProfMessage *message)
|
||||||
|
@ -329,20 +329,20 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_enc_t enc_mode)
|
chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message)
|
||||||
{
|
{
|
||||||
assert(chatwin != NULL);
|
assert(chatwin != NULL);
|
||||||
|
|
||||||
char enc_char = '-';
|
char enc_char = '-';
|
||||||
if (enc_mode == PROF_MSG_ENC_PGP) {
|
if (message->enc == PROF_MSG_ENC_PGP) {
|
||||||
enc_char = prefs_get_pgp_char();
|
enc_char = prefs_get_pgp_char();
|
||||||
} else if (enc_mode == PROF_MSG_ENC_OMEMO) {
|
} else if (message->enc == PROF_MSG_ENC_OMEMO) {
|
||||||
enc_char = prefs_get_omemo_char();
|
enc_char = prefs_get_omemo_char();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfWin *window = (ProfWin*)chatwin;
|
ProfWin *window = (ProfWin*)chatwin;
|
||||||
|
|
||||||
win_print_outgoing(window, enc_char, "%s", message);
|
win_print_outgoing(window, enc_char, "%s", message->plain);
|
||||||
int num = wins_get_num(window);
|
int num = wins_get_num(window);
|
||||||
status_bar_active(num, WIN_CHAT, chatwin->barejid);
|
status_bar_active(num, WIN_CHAT, chatwin->barejid);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ void chatwin_receipt_received(ProfChatWin *chatwin, const char *const id);
|
|||||||
void chatwin_recipient_gone(ProfChatWin *chatwin);
|
void chatwin_recipient_gone(ProfChatWin *chatwin);
|
||||||
void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode,
|
void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode,
|
||||||
gboolean request_receipt);
|
gboolean request_receipt);
|
||||||
void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_enc_t enc_mode);
|
void chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message);
|
||||||
void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity);
|
void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity);
|
||||||
void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status);
|
void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status);
|
||||||
char* chatwin_get_string(ProfChatWin *chatwin);
|
char* chatwin_get_string(ProfChatWin *chatwin);
|
||||||
|
@ -162,7 +162,7 @@ void chatwin_recipient_gone(ProfChatWin *chatwin) {}
|
|||||||
|
|
||||||
void chatwin_outgoing_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode,
|
void chatwin_outgoing_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode,
|
||||||
gboolean request_receipt) {}
|
gboolean request_receipt) {}
|
||||||
void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char * const message, prof_enc_t enc_mode) {}
|
void chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message) {}
|
||||||
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char * const message) {}
|
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char * const message) {}
|
||||||
|
|
||||||
void privwin_occupant_offline(ProfPrivateWin *privwin) {}
|
void privwin_occupant_offline(ProfPrivateWin *privwin) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user