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

Added otr_tag_message, removed commands.c dependency on libotr

This commit is contained in:
James Booth 2015-03-16 21:41:35 +00:00
parent ec57c72fb4
commit 11966d39b0
4 changed files with 23 additions and 11 deletions

View File

@ -39,9 +39,6 @@
#include <errno.h>
#include <assert.h>
#include <glib.h>
#ifdef HAVE_LIBOTR
#include <libotr/proto.h>
#endif
#include "chat_session.h"
#include "command/commands.h"
@ -1377,16 +1374,12 @@ cmd_msg(gchar **args, struct cmd_help_t help)
cons_show_error("Failed to send message. Please check OTR policy");
return TRUE;
} else if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
GString *otr_message = g_string_new(msg);
g_string_append(otr_message, OTRL_MESSAGE_TAG_BASE);
g_string_append(otr_message, OTRL_MESSAGE_TAG_V2);
char *id = message_send_chat_encrypted(barejid, otr_message->str);
char *otr_tagged_msg = otr_tag_message(msg);
char *id = message_send_chat_encrypted(barejid, otr_tagged_msg);
ui_outgoing_chat_msg(barejid, msg, id);
chat_log_msg_out(barejid, msg);
free(id);
g_string_free(otr_message, TRUE);
free(otr_tagged_msg);
} else {
_send_chat_message(barejid, msg);
}

View File

@ -365,6 +365,18 @@ otr_key_loaded(void)
return data_loaded;
}
char *
otr_tag_message(const char * const msg)
{
GString *otr_message = g_string_new(msg);
g_string_append(otr_message, OTRL_MESSAGE_TAG_BASE);
g_string_append(otr_message, OTRL_MESSAGE_TAG_V2);
char *result = otr_message->str;
g_string_free(otr_message, FALSE);
return result;
}
gboolean
otr_is_secure(const char * const recipient)
{

View File

@ -58,6 +58,8 @@ void otr_poll(void);
void otr_on_connect(ProfAccount *account);
void otr_keygen(ProfAccount *account);
char* otr_tag_message(const char * const msg);
gboolean otr_key_loaded(void);
gboolean otr_is_secure(const char * const recipient);

View File

@ -52,6 +52,11 @@ gboolean otr_key_loaded(void)
return (gboolean)mock();
}
char* otr_tag_message(const char * const msg)
{
return NULL;
}
gboolean otr_is_secure(const char * const recipient)
{
return FALSE;
@ -98,4 +103,4 @@ void otr_free_message(char *message) {}
prof_otrpolicy_t otr_get_policy(const char * const recipient)
{
return PROF_OTRPOLICY_MANUAL;
}
}