mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Moved otr message send event to otr module
This commit is contained in:
parent
eb177ccbef
commit
70d1756a1c
@ -62,44 +62,14 @@ client_connect_account(ProfAccount *account)
|
||||
void
|
||||
client_send_msg(const char * const barejid, const char * const msg)
|
||||
{
|
||||
char *id = NULL;
|
||||
|
||||
#ifdef HAVE_LIBOTR
|
||||
prof_otrpolicy_t policy = otr_get_policy(barejid);
|
||||
|
||||
if (otr_is_secure(barejid)) {
|
||||
char *encrypted = otr_encrypt_message(barejid, msg);
|
||||
if (encrypted != NULL) {
|
||||
id = message_send_chat_encrypted(barejid, encrypted);
|
||||
chat_log_otr_msg_out(barejid, msg);
|
||||
ui_outgoing_chat_msg(barejid, msg, id);
|
||||
otr_free_message(encrypted);
|
||||
} else {
|
||||
cons_show_error("Failed to encrypt and send message.");
|
||||
}
|
||||
|
||||
} else if (policy == PROF_OTRPOLICY_ALWAYS) {
|
||||
cons_show_error("Failed to send message. Please check OTR policy");
|
||||
|
||||
} else if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
|
||||
char *otr_tagged_msg = otr_tag_message(msg);
|
||||
id = message_send_chat_encrypted(barejid, otr_tagged_msg);
|
||||
ui_outgoing_chat_msg(barejid, msg, id);
|
||||
chat_log_msg_out(barejid, msg);
|
||||
free(otr_tagged_msg);
|
||||
|
||||
} else {
|
||||
id = message_send_chat(barejid, msg);
|
||||
ui_outgoing_chat_msg(barejid, msg, id);
|
||||
chat_log_msg_out(barejid, msg);
|
||||
}
|
||||
otr_on_message_send(barejid, msg);
|
||||
#else
|
||||
id = message_send_chat(barejid, msg);
|
||||
char *id = message_send_chat(barejid, msg);
|
||||
chat_log_msg_out(barejid, msg);
|
||||
ui_outgoing_chat_msg(barejid, msg, id);
|
||||
#endif
|
||||
|
||||
free(id);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -313,6 +313,43 @@ otr_on_message_recv(const char * const barejid, const char * const resource, con
|
||||
otr_free_message(decrypted);
|
||||
}
|
||||
|
||||
void
|
||||
otr_on_message_send(const char * const barejid, const char * const message)
|
||||
{
|
||||
char *id = NULL;
|
||||
|
||||
prof_otrpolicy_t policy = otr_get_policy(barejid);
|
||||
|
||||
if (otr_is_secure(barejid)) {
|
||||
char *encrypted = otr_encrypt_message(barejid, message);
|
||||
if (encrypted != NULL) {
|
||||
id = message_send_chat_encrypted(barejid, encrypted);
|
||||
chat_log_otr_msg_out(barejid, message);
|
||||
ui_outgoing_chat_msg(barejid, message, id);
|
||||
otr_free_message(encrypted);
|
||||
} else {
|
||||
cons_show_error("Failed to encrypt and send message.");
|
||||
}
|
||||
|
||||
} else if (policy == PROF_OTRPOLICY_ALWAYS) {
|
||||
cons_show_error("Failed to send message. Please check OTR policy");
|
||||
|
||||
} else if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
|
||||
char *otr_tagged_msg = otr_tag_message(message);
|
||||
id = message_send_chat_encrypted(barejid, otr_tagged_msg);
|
||||
ui_outgoing_chat_msg(barejid, message, id);
|
||||
chat_log_msg_out(barejid, message);
|
||||
free(otr_tagged_msg);
|
||||
|
||||
} else {
|
||||
id = message_send_chat(barejid, message);
|
||||
ui_outgoing_chat_msg(barejid, message, id);
|
||||
chat_log_msg_out(barejid, message);
|
||||
}
|
||||
|
||||
free(id);
|
||||
}
|
||||
|
||||
void
|
||||
otr_keygen(ProfAccount *account)
|
||||
{
|
||||
|
@ -56,7 +56,10 @@ char* otr_libotr_version(void);
|
||||
char* otr_start_query(void);
|
||||
void otr_poll(void);
|
||||
void otr_on_connect(ProfAccount *account);
|
||||
|
||||
void otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message);
|
||||
void otr_on_message_send(const char * const barejid, const char * const message);
|
||||
|
||||
void otr_keygen(ProfAccount *account);
|
||||
|
||||
char* otr_tag_message(const char * const msg);
|
||||
|
@ -42,6 +42,7 @@ char* otr_start_query(void)
|
||||
void otr_poll(void) {}
|
||||
void otr_on_connect(ProfAccount *account) {}
|
||||
void otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message) {}
|
||||
void otr_on_message_send(const char * const barejid, const char * const message) {}
|
||||
|
||||
void otr_keygen(ProfAccount *account)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user