mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added static function for sending otr tagged messages
This commit is contained in:
parent
11966d39b0
commit
848baa95a2
@ -75,6 +75,7 @@ static void _who_room(gchar **args, struct cmd_help_t help);
|
||||
static void _who_roster(gchar **args, struct cmd_help_t help);
|
||||
static void _send_chat_message(const char * const barejid, const char * const message);
|
||||
static void _send_otr_chat_message(const char * const barejid, const char * const message);
|
||||
static void _send_otr_tagged_chat_message(const char * const barejid, const char * const message);
|
||||
|
||||
extern GHashTable *commands;
|
||||
|
||||
@ -1358,31 +1359,22 @@ cmd_msg(gchar **args, struct cmd_help_t help)
|
||||
return TRUE;
|
||||
|
||||
} else {
|
||||
// get barejid
|
||||
char *barejid = roster_barejid_from_name(usr);
|
||||
if (barejid == NULL) {
|
||||
barejid = usr;
|
||||
}
|
||||
|
||||
if (msg != NULL) {
|
||||
if (msg) {
|
||||
#ifdef HAVE_LIBOTR
|
||||
prof_otrpolicy_t policy = otr_get_policy(barejid);
|
||||
if (otr_is_secure(barejid)) {
|
||||
_send_otr_chat_message(barejid, msg);
|
||||
} else if (policy == PROF_OTRPOLICY_ALWAYS) {
|
||||
cons_show_error("Failed to send message. Please check OTR policy");
|
||||
} else if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
|
||||
_send_otr_tagged_chat_message(barejid, msg);
|
||||
} else {
|
||||
prof_otrpolicy_t policy = otr_get_policy(barejid);
|
||||
if (policy == PROF_OTRPOLICY_ALWAYS) {
|
||||
cons_show_error("Failed to send message. Please check OTR policy");
|
||||
return TRUE;
|
||||
} else if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
|
||||
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);
|
||||
free(otr_tagged_msg);
|
||||
} else {
|
||||
_send_chat_message(barejid, msg);
|
||||
}
|
||||
_send_chat_message(barejid, msg);
|
||||
}
|
||||
return TRUE;
|
||||
#else
|
||||
@ -1390,7 +1382,7 @@ cmd_msg(gchar **args, struct cmd_help_t help)
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
} else { // msg == NULL
|
||||
} else {
|
||||
ui_new_chat_win(barejid);
|
||||
#ifdef HAVE_LIBOTR
|
||||
if (otr_is_secure(barejid)) {
|
||||
@ -4433,4 +4425,15 @@ _send_otr_chat_message(const char * const barejid, const char * const message)
|
||||
} else {
|
||||
cons_show_error("Failed to encrypt and send message.");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_send_otr_tagged_chat_message(const char * const barejid, const char * const message)
|
||||
{
|
||||
char *otr_tagged_msg = otr_tag_message(message);
|
||||
char *id = message_send_chat_encrypted(barejid, otr_tagged_msg);
|
||||
ui_outgoing_chat_msg(barejid, message, id);
|
||||
chat_log_msg_out(barejid, message);
|
||||
free(id);
|
||||
free(otr_tagged_msg);
|
||||
}
|
Loading…
Reference in New Issue
Block a user