mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Pass ProfChatWin to otr_on_message_send
This commit is contained in:
parent
0118178080
commit
be4ee40ed4
@ -66,11 +66,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg)
|
|||||||
chat_state_active(chatwin->state);
|
chat_state_active(chatwin->state);
|
||||||
|
|
||||||
#ifdef HAVE_LIBOTR
|
#ifdef HAVE_LIBOTR
|
||||||
prof_otrsendres_t res = otr_on_message_send(chatwin->barejid, msg);
|
otr_on_message_send(chatwin, msg);
|
||||||
if (res != PROF_OTRSUCCESS) {
|
|
||||||
char *errmsg = otr_senderror_str(res);
|
|
||||||
ui_win_error_line((ProfWin*)chatwin, errmsg);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
char *id = message_send_chat(chatwin->barejid, msg);
|
char *id = message_send_chat(chatwin->barejid, msg);
|
||||||
chat_log_msg_out(chatwin->barejid, msg);
|
chat_log_msg_out(chatwin->barejid, msg);
|
||||||
|
@ -313,43 +313,43 @@ otr_on_message_recv(const char * const barejid, const char * const resource, con
|
|||||||
otr_free_message(decrypted);
|
otr_free_message(decrypted);
|
||||||
}
|
}
|
||||||
|
|
||||||
prof_otrsendres_t
|
void
|
||||||
otr_on_message_send(const char * const barejid, const char * const message)
|
otr_on_message_send(ProfChatWin *chatwin, const char * const message)
|
||||||
{
|
{
|
||||||
char *id = NULL;
|
char *id = NULL;
|
||||||
|
|
||||||
prof_otrpolicy_t policy = otr_get_policy(barejid);
|
prof_otrpolicy_t policy = otr_get_policy(chatwin->barejid);
|
||||||
|
|
||||||
if (otr_is_secure(barejid)) {
|
if (otr_is_secure(chatwin->barejid)) {
|
||||||
char *encrypted = otr_encrypt_message(barejid, message);
|
char *encrypted = otr_encrypt_message(chatwin->barejid, message);
|
||||||
if (encrypted) {
|
if (encrypted) {
|
||||||
id = message_send_chat_encrypted(barejid, encrypted);
|
id = message_send_chat_encrypted(chatwin->barejid, encrypted);
|
||||||
chat_log_otr_msg_out(barejid, message);
|
chat_log_otr_msg_out(chatwin->barejid, message);
|
||||||
ui_outgoing_chat_msg(barejid, message, id);
|
ui_outgoing_chat_msg(chatwin->barejid, message, id);
|
||||||
otr_free_message(encrypted);
|
otr_free_message(encrypted);
|
||||||
} else {
|
} else {
|
||||||
return PROF_OTRENCFAIL;
|
ui_win_error_line((ProfWin*)chatwin, "Failed to encrypt and send message.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (policy == PROF_OTRPOLICY_ALWAYS) {
|
} else if (policy == PROF_OTRPOLICY_ALWAYS) {
|
||||||
return PROF_OTRPOLICYFAIL;
|
ui_win_error_line((ProfWin*)chatwin, "Failed to send message. OTR policy set to: always");
|
||||||
|
return;
|
||||||
|
|
||||||
} else if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
|
} else if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
|
||||||
char *otr_tagged_msg = otr_tag_message(message);
|
char *otr_tagged_msg = otr_tag_message(message);
|
||||||
id = message_send_chat_encrypted(barejid, otr_tagged_msg);
|
id = message_send_chat_encrypted(chatwin->barejid, otr_tagged_msg);
|
||||||
ui_outgoing_chat_msg(barejid, message, id);
|
ui_outgoing_chat_msg(chatwin->barejid, message, id);
|
||||||
chat_log_msg_out(barejid, message);
|
chat_log_msg_out(chatwin->barejid, message);
|
||||||
free(otr_tagged_msg);
|
free(otr_tagged_msg);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
id = message_send_chat(barejid, message);
|
id = message_send_chat(chatwin->barejid, message);
|
||||||
ui_outgoing_chat_msg(barejid, message, id);
|
ui_outgoing_chat_msg(chatwin->barejid, message, id);
|
||||||
chat_log_msg_out(barejid, message);
|
chat_log_msg_out(chatwin->barejid, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(id);
|
free(id);
|
||||||
|
|
||||||
return PROF_OTRSUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -743,16 +743,6 @@ otr_decrypt_message(const char * const from, const char * const message, gboolea
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
|
||||||
otr_senderror_str(prof_otrsendres_t res)
|
|
||||||
{
|
|
||||||
switch (res) {
|
|
||||||
case PROF_OTRENCFAIL: return "Failed to encrypt and send message.";
|
|
||||||
case PROF_OTRPOLICYFAIL: return "Failed to send message. OTR policy set to: always";
|
|
||||||
default: return "Unknown OTR error.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
otr_free_message(char *message)
|
otr_free_message(char *message)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include <libotr/message.h>
|
#include <libotr/message.h>
|
||||||
|
|
||||||
#include "config/accounts.h"
|
#include "config/accounts.h"
|
||||||
|
#include "ui/window.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PROF_OTRPOLICY_MANUAL,
|
PROF_OTRPOLICY_MANUAL,
|
||||||
@ -46,12 +47,6 @@ typedef enum {
|
|||||||
PROF_OTRPOLICY_ALWAYS
|
PROF_OTRPOLICY_ALWAYS
|
||||||
} prof_otrpolicy_t;
|
} prof_otrpolicy_t;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PROF_OTRENCFAIL,
|
|
||||||
PROF_OTRPOLICYFAIL,
|
|
||||||
PROF_OTRSUCCESS
|
|
||||||
} prof_otrsendres_t;
|
|
||||||
|
|
||||||
OtrlUserState otr_userstate(void);
|
OtrlUserState otr_userstate(void);
|
||||||
OtrlMessageAppOps* otr_messageops(void);
|
OtrlMessageAppOps* otr_messageops(void);
|
||||||
GHashTable* otr_smpinitators(void);
|
GHashTable* otr_smpinitators(void);
|
||||||
@ -64,7 +59,7 @@ void otr_poll(void);
|
|||||||
void otr_on_connect(ProfAccount *account);
|
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_recv(const char * const barejid, const char * const resource, const char * const message);
|
||||||
prof_otrsendres_t otr_on_message_send(const char * const barejid, const char * const message);
|
void otr_on_message_send(ProfChatWin *chatwin, const char * const message);
|
||||||
|
|
||||||
void otr_keygen(ProfAccount *account);
|
void otr_keygen(ProfAccount *account);
|
||||||
|
|
||||||
@ -94,6 +89,4 @@ void otr_free_message(char *message);
|
|||||||
|
|
||||||
prof_otrpolicy_t otr_get_policy(const char * const recipient);
|
prof_otrpolicy_t otr_get_policy(const char * const recipient);
|
||||||
|
|
||||||
char* otr_senderror_str(prof_otrsendres_t res);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,10 +42,7 @@ char* otr_start_query(void)
|
|||||||
void otr_poll(void) {}
|
void otr_poll(void) {}
|
||||||
void otr_on_connect(ProfAccount *account) {}
|
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_recv(const char * const barejid, const char * const resource, const char * const message) {}
|
||||||
prof_otrsendres_t otr_on_message_send(const char * const barejid, const char * const message)
|
void otr_on_message_send(ProfChatWin *chatwin, const char * const message) {}
|
||||||
{
|
|
||||||
return PROF_OTRSUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void otr_keygen(ProfAccount *account)
|
void otr_keygen(ProfAccount *account)
|
||||||
{
|
{
|
||||||
@ -109,9 +106,3 @@ prof_otrpolicy_t otr_get_policy(const char * const recipient)
|
|||||||
{
|
{
|
||||||
return PROF_OTRPOLICY_MANUAL;
|
return PROF_OTRPOLICY_MANUAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* otr_senderror_str(prof_otrsendres_t res)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user