mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 12:36:21 +00:00
Require '/otr start' from both parties before encryption used both ways
This commit is contained in:
@@ -1140,10 +1140,24 @@ cmd_execute_default(const char * const inp)
|
||||
ui_current_print_line("You are not currently connected.");
|
||||
} else {
|
||||
#ifdef HAVE_LIBOTR
|
||||
char *encrypted = otr_encrypt_message(recipient, inp);
|
||||
if (encrypted != NULL) {
|
||||
message_send(encrypted, recipient);
|
||||
otr_free_message(encrypted);
|
||||
if (ui_current_win_is_otr()) {
|
||||
char *encrypted = otr_encrypt_message(recipient, inp);
|
||||
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);
|
||||
chat_log_chat(jidp->barejid, recipient, inp, PROF_OUT_LOG, NULL);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
|
||||
ui_outgoing_msg("me", recipient, inp);
|
||||
} else {
|
||||
cons_show_error("Failed to send message.");
|
||||
}
|
||||
} else {
|
||||
message_send(inp, recipient);
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = jabber_get_fulljid();
|
||||
Jid *jidp = jid_create(jid);
|
||||
@@ -1152,8 +1166,6 @@ cmd_execute_default(const char * const inp)
|
||||
}
|
||||
|
||||
ui_outgoing_msg("me", recipient, inp);
|
||||
} else {
|
||||
cons_show_error("Failed to send message.");
|
||||
}
|
||||
#else
|
||||
message_send(inp, recipient);
|
||||
@@ -1166,7 +1178,6 @@ cmd_execute_default(const char * const inp)
|
||||
|
||||
ui_outgoing_msg("me", recipient, inp);
|
||||
#endif
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
#include "tools/parser.h"
|
||||
#include "tools/tinyurl.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/windows.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
#include "xmpp/bookmark.h"
|
||||
|
||||
@@ -917,10 +919,24 @@ cmd_msg(gchar **args, struct cmd_help_t help)
|
||||
}
|
||||
if (msg != NULL) {
|
||||
#ifdef HAVE_LIBOTR
|
||||
char *encrypted = otr_encrypt_message(usr_jid, msg);
|
||||
if (encrypted != NULL) {
|
||||
message_send(encrypted, usr_jid);
|
||||
otr_free_message(encrypted);
|
||||
if (ui_current_win_is_otr()) {
|
||||
char *encrypted = otr_encrypt_message(usr_jid, msg);
|
||||
if (encrypted != NULL) {
|
||||
message_send(encrypted, usr_jid);
|
||||
otr_free_message(encrypted);
|
||||
ui_outgoing_msg("me", usr_jid, msg);
|
||||
|
||||
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = jabber_get_fulljid();
|
||||
Jid *jidp = jid_create(jid);
|
||||
chat_log_chat(jidp->barejid, usr_jid, msg, PROF_OUT_LOG, NULL);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
} else {
|
||||
cons_show_error("Failed to encrypt and send message,");
|
||||
}
|
||||
} else {
|
||||
message_send(msg, usr_jid);
|
||||
ui_outgoing_msg("me", usr_jid, msg);
|
||||
|
||||
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
|
||||
@@ -929,10 +945,8 @@ cmd_msg(gchar **args, struct cmd_help_t help)
|
||||
chat_log_chat(jidp->barejid, usr_jid, msg, PROF_OUT_LOG, NULL);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
} else {
|
||||
cons_show_error("Failed to send message,");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
#else
|
||||
message_send(msg, usr_jid);
|
||||
ui_outgoing_msg("me", usr_jid, msg);
|
||||
@@ -942,9 +956,10 @@ cmd_msg(gchar **args, struct cmd_help_t help)
|
||||
Jid *jidp = jid_create(jid);
|
||||
chat_log_chat(jidp->barejid, usr_jid, msg, PROF_OUT_LOG, NULL);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
const char * jid = NULL;
|
||||
|
||||
@@ -2300,6 +2315,22 @@ cmd_otr(gchar **args, struct cmd_help_t help)
|
||||
char *fingerprint = otr_get_fingerprint();
|
||||
cons_show("Your fingerprint: %s", fingerprint);
|
||||
return TRUE;
|
||||
} else if (strcmp(args[0], "start") == 0) {
|
||||
win_type_t win_type = ui_current_win_type();
|
||||
|
||||
if (win_type != WIN_CHAT) {
|
||||
ui_current_print_line("You must be in a regular chat window to start an OTR session.");
|
||||
} else if (ui_current_win_is_otr()) {
|
||||
ui_current_print_line("You are already in an OTR session.");
|
||||
} else {
|
||||
if (!otr_key_loaded()) {
|
||||
ui_current_print_line("You have not generated or loaded a private key, use '/otr gen'");
|
||||
} else {
|
||||
ui_current_print_line("Starting OTR session");
|
||||
ui_current_set_otr(TRUE);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
return TRUE;
|
||||
|
||||
Reference in New Issue
Block a user