mirror of
https://github.com/profanity-im/profanity.git
synced 2025-05-18 13:58:57 -04:00
Moved message display logic to sv_ev_incoming_message
This commit is contained in:
parent
9b991ae058
commit
8d2d923603
@ -172,7 +172,13 @@ void
|
|||||||
sv_ev_incoming_message(char *barejid, char *resource, char *message)
|
sv_ev_incoming_message(char *barejid, char *resource, char *message)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBOTR
|
#ifdef HAVE_LIBOTR
|
||||||
otr_on_message_recv(barejid, resource, message);
|
gboolean decrypted = FALSE;
|
||||||
|
char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted);
|
||||||
|
if (otr_res) {
|
||||||
|
ui_incoming_msg(barejid, resource, otr_res, NULL);
|
||||||
|
chat_log_otr_msg_in(barejid, otr_res, decrypted);
|
||||||
|
otr_free_message(otr_res);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
ui_incoming_msg(barejid, resource, message, NULL);
|
ui_incoming_msg(barejid, resource, message, NULL);
|
||||||
chat_log_msg_in(barejid, message);
|
chat_log_msg_in(barejid, message);
|
||||||
|
@ -272,12 +272,9 @@ otr_on_connect(ProfAccount *account)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
char*
|
||||||
otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message)
|
otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message, gboolean *was_decrypted)
|
||||||
{
|
{
|
||||||
gboolean was_decrypted = FALSE;
|
|
||||||
char *decrypted;
|
|
||||||
|
|
||||||
prof_otrpolicy_t policy = otr_get_policy(barejid);
|
prof_otrpolicy_t policy = otr_get_policy(barejid);
|
||||||
char *whitespace_base = strstr(message, OTRL_MESSAGE_TAG_BASE);
|
char *whitespace_base = strstr(message, OTRL_MESSAGE_TAG_BASE);
|
||||||
|
|
||||||
@ -298,22 +295,19 @@ otr_on_message_recv(const char * const barejid, const char * const resource, con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
decrypted = otr_decrypt_message(barejid, message, &was_decrypted);
|
|
||||||
|
|
||||||
// internal OTR message
|
char *decrypted = otr_decrypt_message(barejid, message, was_decrypted);
|
||||||
if (decrypted == NULL) {
|
if (!decrypted) { // internal OTR message
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (policy == PROF_OTRPOLICY_ALWAYS && !was_decrypted && !whitespace_base) {
|
if (policy == PROF_OTRPOLICY_ALWAYS && *was_decrypted == FALSE && !whitespace_base) {
|
||||||
char *otr_query_message = otr_start_query();
|
char *otr_query_message = otr_start_query();
|
||||||
cons_show("Attempting to start OTR session...");
|
cons_show("Attempting to start OTR session...");
|
||||||
message_send_chat_otr(barejid, otr_query_message);
|
message_send_chat_otr(barejid, otr_query_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_incoming_msg(barejid, resource, decrypted, NULL);
|
return decrypted;
|
||||||
chat_log_otr_msg_in(barejid, decrypted, was_decrypted);
|
|
||||||
otr_free_message(decrypted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -58,7 +58,7 @@ char* otr_start_query(void);
|
|||||||
void otr_poll(void);
|
void otr_poll(void);
|
||||||
void otr_on_connect(ProfAccount *account);
|
void otr_on_connect(ProfAccount *account);
|
||||||
|
|
||||||
void otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message);
|
char* otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message, gboolean *was_decrypted);
|
||||||
gboolean otr_on_message_send(ProfChatWin *chatwin, const char * const message);
|
gboolean otr_on_message_send(ProfChatWin *chatwin, const char * const message);
|
||||||
|
|
||||||
void otr_keygen(ProfAccount *account);
|
void otr_keygen(ProfAccount *account);
|
||||||
|
@ -41,7 +41,10 @@ char* otr_start_query(void)
|
|||||||
|
|
||||||
void otr_poll(void) {}
|
void otr_poll(void) {}
|
||||||
void otr_on_connect(ProfAccount *account) {}
|
void otr_on_connect(ProfAccount *account) {}
|
||||||
void otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message) {}
|
char* otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message, gboolean *was_decrypted)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
gboolean otr_on_message_send(ProfChatWin *chatwin, const char * const message)
|
gboolean otr_on_message_send(ProfChatWin *chatwin, const char * const message)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user