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

Encrypt /tiny command when in OTR session

fixes #292
This commit is contained in:
James Booth 2014-01-23 19:25:53 +00:00
parent 21ab182151
commit 3f31c1a4e7
2 changed files with 35 additions and 1 deletions

View File

@ -1199,6 +1199,7 @@ cmd_execute_default(const char * const inp)
win_type_t win_type = ui_current_win_type();
jabber_conn_status_t status = jabber_get_connection_status();
char *recipient = ui_current_recipient();
cons_debug("Recipient: %s", recipient);
switch (win_type)
{

View File

@ -1838,8 +1838,40 @@ cmd_tiny(gchar **args, struct cmd_help_t help)
if (tiny != NULL) {
if (win_type == WIN_CHAT) {
char *recipient = ui_current_recipient();
message_send(tiny, recipient);
#ifdef HAVE_LIBOTR
if (otr_is_secure(recipient)) {
char *encrypted = otr_encrypt_message(recipient, tiny);
if (encrypted != NULL) {
message_send(encrypted, recipient);
otr_free_message(encrypted);
if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid);
if (strcmp(prefs_get_string(PREF_OTR_LOG), "on") == 0) {
chat_log_chat(jidp->barejid, recipient, tiny, PROF_OUT_LOG, NULL);
} else if (strcmp(prefs_get_string(PREF_OTR_LOG), "redact") == 0) {
chat_log_chat(jidp->barejid, recipient, "[redacted]", PROF_OUT_LOG, NULL);
}
jid_destroy(jidp);
}
ui_outgoing_msg("me", recipient, tiny);
} else {
cons_show_error("Failed to send message.");
}
} else {
message_send(tiny, recipient);
if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid);
chat_log_chat(jidp->barejid, recipient, tiny, PROF_OUT_LOG, NULL);
jid_destroy(jidp);
}
ui_outgoing_msg("me", recipient, tiny);
}
#else
message_send(tiny, recipient);
if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid);
@ -1848,6 +1880,7 @@ cmd_tiny(gchar **args, struct cmd_help_t help)
}
ui_outgoing_msg("me", recipient, tiny);
#endif
} else if (win_type == WIN_PRIVATE) {
char *recipient = ui_current_recipient();
message_send(tiny, recipient);