mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Added opportunistic send functionality to cmd_msg
If policy is set to 'opportunistic' then when the user executes cmd_msg it will append the otr whitespace tag to the message The other client should start AKE once it receives the message. TODO: Analyze incoming messages for whitespace tag
This commit is contained in:
parent
1ceca89296
commit
da89e24172
@ -24,6 +24,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <libotr/proto.h>
|
||||||
|
|
||||||
#include "chat_session.h"
|
#include "chat_session.h"
|
||||||
#include "command/commands.h"
|
#include "command/commands.h"
|
||||||
@ -946,10 +947,6 @@ cmd_msg(gchar **args, struct cmd_help_t help)
|
|||||||
}
|
}
|
||||||
if (msg != NULL) {
|
if (msg != NULL) {
|
||||||
#ifdef HAVE_LIBOTR
|
#ifdef HAVE_LIBOTR
|
||||||
if ((strcmp(prefs_get_string(PREF_OTR_POLICY), "always") == 0) && !otr_is_secure(usr_jid)) {
|
|
||||||
cons_show_error("Failed to send message. Please check OTR policy");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
if (otr_is_secure(usr_jid)) {
|
if (otr_is_secure(usr_jid)) {
|
||||||
char *encrypted = otr_encrypt_message(usr_jid, msg);
|
char *encrypted = otr_encrypt_message(usr_jid, msg);
|
||||||
if (encrypted != NULL) {
|
if (encrypted != NULL) {
|
||||||
@ -971,7 +968,25 @@ cmd_msg(gchar **args, struct cmd_help_t help)
|
|||||||
cons_show_error("Failed to encrypt and send message,");
|
cons_show_error("Failed to encrypt and send message,");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
char *policy = prefs_get_string(PREF_OTR_POLICY);
|
||||||
|
|
||||||
|
if (strcmp(policy, "always") == 0)
|
||||||
|
{
|
||||||
|
cons_show_error("Failed to send message. Please check OTR policy");
|
||||||
|
return TRUE;
|
||||||
|
} else if (strcmp(policy, "opportunistic") == 0) {
|
||||||
|
char *otr_base_tag = OTRL_MESSAGE_TAG_BASE;
|
||||||
|
char *otr_v2_tag = OTRL_MESSAGE_TAG_V2;
|
||||||
|
int N = strlen(otr_base_tag) + strlen(otr_v2_tag) + strlen(msg) + 1;
|
||||||
|
char *temp = (char *) malloc( (unsigned) N*sizeof(char *) );
|
||||||
|
strcpy( temp , msg );
|
||||||
|
strcat( temp , otr_base_tag);
|
||||||
|
strcat( temp, otr_v2_tag);
|
||||||
|
message_send(temp, usr_jid);
|
||||||
|
free(temp);
|
||||||
|
} else {
|
||||||
message_send(msg, usr_jid);
|
message_send(msg, usr_jid);
|
||||||
|
}
|
||||||
ui_outgoing_msg("me", usr_jid, msg);
|
ui_outgoing_msg("me", usr_jid, msg);
|
||||||
|
|
||||||
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
|
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#ifndef OTR_H
|
#ifndef OTR_H
|
||||||
#define OTR_H
|
#define OTR_H
|
||||||
|
|
||||||
|
#define OTRL_TAG " \t \t\t\t\t \t \t \t "
|
||||||
|
|
||||||
#include "config/accounts.h"
|
#include "config/accounts.h"
|
||||||
|
|
||||||
void otr_init_module(void);
|
void otr_init_module(void);
|
||||||
|
@ -108,6 +108,8 @@ otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps *ops, char *j
|
|||||||
{
|
{
|
||||||
gcry_error_t err;
|
gcry_error_t err;
|
||||||
|
|
||||||
|
ops.policy = OTRL_POLICY_SEND_WHITESPACE_TAG;
|
||||||
|
|
||||||
err = otrl_message_sending(
|
err = otrl_message_sending(
|
||||||
user_state,
|
user_state,
|
||||||
ops,
|
ops,
|
||||||
|
Loading…
Reference in New Issue
Block a user