mirror of
https://github.com/profanity-im/profanity.git
synced 2024-10-27 20:30:13 -04:00
parent
71dcb2e427
commit
a978bb12bf
@ -6616,7 +6616,7 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args)
|
|||||||
|
|
||||||
if (!otr_is_secure(barejid)) {
|
if (!otr_is_secure(barejid)) {
|
||||||
char *otr_query_message = otr_start_query();
|
char *otr_query_message = otr_start_query();
|
||||||
char *id = message_send_chat_otr(barejid, otr_query_message);
|
char *id = message_send_chat_otr(barejid, otr_query_message, FALSE);
|
||||||
free(id);
|
free(id);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -6649,7 +6649,7 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *otr_query_message = otr_start_query();
|
char *otr_query_message = otr_start_query();
|
||||||
char *id = message_send_chat_otr(chatwin->barejid, otr_query_message);
|
char *id = message_send_chat_otr(chatwin->barejid, otr_query_message, FALSE);
|
||||||
free(id);
|
free(id);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "config/preferences.h"
|
||||||
#include "plugins/plugins.h"
|
#include "plugins/plugins.h"
|
||||||
#include "ui/window_list.h"
|
#include "ui/window_list.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
@ -111,22 +112,38 @@ void
|
|||||||
cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oob_url)
|
cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oob_url)
|
||||||
{
|
{
|
||||||
chat_state_active(chatwin->state);
|
chat_state_active(chatwin->state);
|
||||||
|
|
||||||
|
gboolean request_receipt = FALSE;
|
||||||
|
if (prefs_get_boolean(PREF_RECEIPTS_REQUEST)) {
|
||||||
|
char *session_jid = chat_session_get_jid(chatwin->barejid);
|
||||||
|
if (session_jid) {
|
||||||
|
Jid *session_jidp = jid_create(session_jid);
|
||||||
|
if (session_jidp && session_jidp->resourcepart) {
|
||||||
|
if (caps_jid_has_feature(session_jid, XMPP_FEATURE_RECEIPTS)) {
|
||||||
|
request_receipt = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jid_destroy(session_jidp);
|
||||||
|
free(session_jid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char *plugin_msg = plugins_pre_chat_message_send(chatwin->barejid, msg);
|
char *plugin_msg = plugins_pre_chat_message_send(chatwin->barejid, msg);
|
||||||
|
|
||||||
// OTR suported, PGP supported
|
// OTR suported, PGP supported
|
||||||
#ifdef HAVE_LIBOTR
|
#ifdef HAVE_LIBOTR
|
||||||
#ifdef HAVE_LIBGPGME
|
#ifdef HAVE_LIBGPGME
|
||||||
if (chatwin->pgp_send) {
|
if (chatwin->pgp_send) {
|
||||||
char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg);
|
char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt);
|
||||||
chat_log_pgp_msg_out(chatwin->barejid, plugin_msg);
|
chat_log_pgp_msg_out(chatwin->barejid, plugin_msg);
|
||||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PGP);
|
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PGP, request_receipt);
|
||||||
free(id);
|
free(id);
|
||||||
} else {
|
} else {
|
||||||
gboolean handled = otr_on_message_send(chatwin, plugin_msg);
|
gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt);
|
||||||
if (!handled) {
|
if (!handled) {
|
||||||
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url);
|
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt);
|
||||||
chat_log_msg_out(chatwin->barejid, plugin_msg);
|
chat_log_msg_out(chatwin->barejid, plugin_msg);
|
||||||
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PLAIN);
|
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PLAIN, request_receipt);
|
||||||
free(id);
|
free(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ static void
|
|||||||
cb_inject_message(void *opdata, const char *accountname,
|
cb_inject_message(void *opdata, const char *accountname,
|
||||||
const char *protocol, const char *recipient, const char *message)
|
const char *protocol, const char *recipient, const char *message)
|
||||||
{
|
{
|
||||||
char *id = message_send_chat_otr(recipient, message);
|
char *id = message_send_chat_otr(recipient, message, FALSE);
|
||||||
free(id);
|
free(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ otr_on_message_recv(const char *const barejid, const char *const resource, const
|
|||||||
memmove(whitespace_base, whitespace_base+tag_length, tag_length);
|
memmove(whitespace_base, whitespace_base+tag_length, tag_length);
|
||||||
char *otr_query_message = otr_start_query();
|
char *otr_query_message = otr_start_query();
|
||||||
cons_show("OTR Whitespace pattern detected. Attempting to start OTR session...");
|
cons_show("OTR Whitespace pattern detected. Attempting to start OTR session...");
|
||||||
char *id = message_send_chat_otr(barejid, otr_query_message);
|
char *id = message_send_chat_otr(barejid, otr_query_message, FALSE);
|
||||||
free(id);
|
free(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -328,7 +328,7 @@ otr_on_message_recv(const char *const barejid, const char *const resource, const
|
|||||||
if (policy == PROF_OTRPOLICY_ALWAYS && *decrypted == FALSE && !whitespace_base) {
|
if (policy == PROF_OTRPOLICY_ALWAYS && *decrypted == FALSE && !whitespace_base) {
|
||||||
char *otr_query_message = otr_start_query();
|
char *otr_query_message = otr_start_query();
|
||||||
cons_show("Attempting to start OTR session...");
|
cons_show("Attempting to start OTR session...");
|
||||||
char *id = message_send_chat_otr(barejid, otr_query_message);
|
char *id = message_send_chat_otr(barejid, otr_query_message, FALSE);
|
||||||
free(id);
|
free(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ otr_on_message_recv(const char *const barejid, const char *const resource, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
otr_on_message_send(ProfChatWin *chatwin, const char *const message)
|
otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean request_receipt)
|
||||||
{
|
{
|
||||||
char *id = NULL;
|
char *id = NULL;
|
||||||
prof_otrpolicy_t policy = otr_get_policy(chatwin->barejid);
|
prof_otrpolicy_t policy = otr_get_policy(chatwin->barejid);
|
||||||
@ -345,9 +345,9 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message)
|
|||||||
if (otr_is_secure(chatwin->barejid)) {
|
if (otr_is_secure(chatwin->barejid)) {
|
||||||
char *encrypted = otr_encrypt_message(chatwin->barejid, message);
|
char *encrypted = otr_encrypt_message(chatwin->barejid, message);
|
||||||
if (encrypted) {
|
if (encrypted) {
|
||||||
id = message_send_chat_otr(chatwin->barejid, encrypted);
|
id = message_send_chat_otr(chatwin->barejid, encrypted, request_receipt);
|
||||||
chat_log_otr_msg_out(chatwin->barejid, message);
|
chat_log_otr_msg_out(chatwin->barejid, message);
|
||||||
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_OTR);
|
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_OTR, request_receipt);
|
||||||
otr_free_message(encrypted);
|
otr_free_message(encrypted);
|
||||||
free(id);
|
free(id);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -366,8 +366,8 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message)
|
|||||||
// tag and send for policy opportunistic
|
// tag and send for policy opportunistic
|
||||||
if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
|
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_otr(chatwin->barejid, otr_tagged_msg);
|
id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg, request_receipt);
|
||||||
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_PLAIN);
|
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_PLAIN, request_receipt);
|
||||||
chat_log_msg_out(chatwin->barejid, message);
|
chat_log_msg_out(chatwin->barejid, message);
|
||||||
free(otr_tagged_msg);
|
free(otr_tagged_msg);
|
||||||
free(id);
|
free(id);
|
||||||
|
@ -72,7 +72,7 @@ void otr_poll(void);
|
|||||||
void otr_on_connect(ProfAccount *account);
|
void otr_on_connect(ProfAccount *account);
|
||||||
|
|
||||||
char* otr_on_message_recv(const char *const barejid, const char *const resource, const char *const message, gboolean *decrypted);
|
char* otr_on_message_recv(const char *const barejid, const char *const resource, const char *const message, gboolean *decrypted);
|
||||||
gboolean otr_on_message_send(ProfChatWin *chatwin, const char *const message);
|
gboolean otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean request_receipt);
|
||||||
|
|
||||||
void otr_keygen(ProfAccount *account);
|
void otr_keygen(ProfAccount *account);
|
||||||
|
|
||||||
|
@ -293,7 +293,8 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode)
|
chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode,
|
||||||
|
gboolean request_receipt)
|
||||||
{
|
{
|
||||||
assert(chatwin != NULL);
|
assert(chatwin != NULL);
|
||||||
|
|
||||||
@ -304,7 +305,7 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id,
|
|||||||
enc_char = prefs_get_pgp_char();
|
enc_char = prefs_get_pgp_char();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_RECEIPTS_REQUEST) && id) {
|
if (request_receipt && id) {
|
||||||
win_print_with_receipt((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message, id);
|
win_print_with_receipt((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message, id);
|
||||||
} else {
|
} else {
|
||||||
win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message);
|
win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message);
|
||||||
|
@ -133,7 +133,8 @@ void chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, cons
|
|||||||
GDateTime *timestamp, gboolean win_created, prof_enc_t enc_mode);
|
GDateTime *timestamp, gboolean win_created, prof_enc_t enc_mode);
|
||||||
void chatwin_receipt_received(ProfChatWin *chatwin, const char *const id);
|
void chatwin_receipt_received(ProfChatWin *chatwin, const char *const id);
|
||||||
void chatwin_recipient_gone(ProfChatWin *chatwin);
|
void chatwin_recipient_gone(ProfChatWin *chatwin);
|
||||||
void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode);
|
void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode,
|
||||||
|
gboolean request_receipt);
|
||||||
void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_enc_t enc_mode);
|
void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_enc_t enc_mode);
|
||||||
void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity);
|
void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity);
|
||||||
void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status);
|
void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status);
|
||||||
|
@ -307,6 +307,24 @@ caps_lookup(const char *const jid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
caps_jid_has_feature(const char *const jid, const char *const feature)
|
||||||
|
{
|
||||||
|
char *ver = g_hash_table_lookup(jid_to_ver, jid);
|
||||||
|
EntityCapabilities *caps = ver ? _caps_by_ver(ver) : _caps_by_jid(jid);
|
||||||
|
|
||||||
|
if (caps == NULL) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GSList *found = g_slist_find_custom(caps->features, feature, (GCompareFunc)g_strcmp0);
|
||||||
|
gboolean result = found != NULL;
|
||||||
|
|
||||||
|
caps_destroy(caps);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
caps_get_my_sha1(xmpp_ctx_t *const ctx)
|
caps_get_my_sha1(xmpp_ctx_t *const ctx)
|
||||||
{
|
{
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "config/preferences.h"
|
#include "config/preferences.h"
|
||||||
#include "xmpp/xmpp.h"
|
#include "xmpp/xmpp.h"
|
||||||
|
#include "xmpp/stanza.h"
|
||||||
#include "xmpp/chat_session.h"
|
#include "xmpp/chat_session.h"
|
||||||
|
|
||||||
static GHashTable *sessions;
|
static GHashTable *sessions;
|
||||||
@ -100,6 +101,40 @@ chat_session_get(const char *const barejid)
|
|||||||
return g_hash_table_lookup(sessions, barejid);
|
return g_hash_table_lookup(sessions, barejid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
chat_session_get_jid(const char *const barejid)
|
||||||
|
{
|
||||||
|
ChatSession *session = chat_session_get(barejid);
|
||||||
|
char *jid = NULL;
|
||||||
|
if (session) {
|
||||||
|
Jid *jidp = jid_create_from_bare_and_resource(session->barejid, session->resource);
|
||||||
|
jid = strdup(jidp->fulljid);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
} else {
|
||||||
|
jid = strdup(barejid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return jid;
|
||||||
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
chat_session_get_state(const char *const barejid)
|
||||||
|
{
|
||||||
|
ChatSession *session = chat_session_get(barejid);
|
||||||
|
char *state = NULL;
|
||||||
|
if (session) {
|
||||||
|
if (prefs_get_boolean(PREF_STATES) && session->send_states) {
|
||||||
|
state = STANZA_NAME_ACTIVE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (prefs_get_boolean(PREF_STATES)) {
|
||||||
|
state = STANZA_NAME_ACTIVE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
chat_session_recipient_gone(const char *const barejid, const char *const resource)
|
chat_session_recipient_gone(const char *const barejid, const char *const resource)
|
||||||
{
|
{
|
||||||
|
@ -56,6 +56,8 @@ void chat_session_recipient_typing(const char *const barejid, const char *const
|
|||||||
void chat_session_recipient_paused(const char *const barejid, const char *const resource);
|
void chat_session_recipient_paused(const char *const barejid, const char *const resource);
|
||||||
void chat_session_recipient_gone(const char *const barejid, const char *const resource);
|
void chat_session_recipient_gone(const char *const barejid, const char *const resource);
|
||||||
void chat_session_recipient_inactive(const char *const barejid, const char *const resource);
|
void chat_session_recipient_inactive(const char *const barejid, const char *const resource);
|
||||||
|
char* chat_session_get_jid(const char *const barejid);
|
||||||
|
char* chat_session_get_state(const char *const barejid);
|
||||||
|
|
||||||
void chat_session_remove(const char *const barejid);
|
void chat_session_remove(const char *const barejid);
|
||||||
|
|
||||||
|
@ -119,15 +119,17 @@ jid_create_from_bare_and_resource(const char *const room, const char *const nick
|
|||||||
void
|
void
|
||||||
jid_destroy(Jid *jid)
|
jid_destroy(Jid *jid)
|
||||||
{
|
{
|
||||||
if (jid) {
|
if (jid == NULL) {
|
||||||
g_free(jid->str);
|
return;
|
||||||
g_free(jid->localpart);
|
|
||||||
g_free(jid->domainpart);
|
|
||||||
g_free(jid->resourcepart);
|
|
||||||
g_free(jid->barejid);
|
|
||||||
g_free(jid->fulljid);
|
|
||||||
free(jid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free(jid->str);
|
||||||
|
g_free(jid->localpart);
|
||||||
|
g_free(jid->domainpart);
|
||||||
|
g_free(jid->resourcepart);
|
||||||
|
g_free(jid->barejid);
|
||||||
|
g_free(jid->fulljid);
|
||||||
|
free(jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -131,47 +131,14 @@ message_handlers_init(void)
|
|||||||
xmpp_handler_add(conn, _message_handler, NULL, STANZA_NAME_MESSAGE, NULL, ctx);
|
xmpp_handler_add(conn, _message_handler, NULL, STANZA_NAME_MESSAGE, NULL, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char*
|
|
||||||
_session_jid(const char *const barejid)
|
|
||||||
{
|
|
||||||
ChatSession *session = chat_session_get(barejid);
|
|
||||||
char *jid = NULL;
|
|
||||||
if (session) {
|
|
||||||
Jid *jidp = jid_create_from_bare_and_resource(session->barejid, session->resource);
|
|
||||||
jid = strdup(jidp->fulljid);
|
|
||||||
jid_destroy(jidp);
|
|
||||||
} else {
|
|
||||||
jid = strdup(barejid);
|
|
||||||
}
|
|
||||||
|
|
||||||
return jid;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char*
|
|
||||||
_session_state(const char *const barejid)
|
|
||||||
{
|
|
||||||
ChatSession *session = chat_session_get(barejid);
|
|
||||||
char *state = NULL;
|
|
||||||
if (session) {
|
|
||||||
if (prefs_get_boolean(PREF_STATES) && session->send_states) {
|
|
||||||
state = STANZA_NAME_ACTIVE;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (prefs_get_boolean(PREF_STATES)) {
|
|
||||||
state = STANZA_NAME_ACTIVE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
char*
|
char*
|
||||||
message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url)
|
message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url,
|
||||||
|
gboolean request_receipt)
|
||||||
{
|
{
|
||||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||||
|
|
||||||
char *state = _session_state(barejid);
|
char *state = chat_session_get_state(barejid);
|
||||||
char *jid = _session_jid(barejid);
|
char *jid = chat_session_get_jid(barejid);
|
||||||
char *id = create_unique_id("msg");
|
char *id = create_unique_id("msg");
|
||||||
|
|
||||||
xmpp_stanza_t *message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg);
|
xmpp_stanza_t *message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg);
|
||||||
@ -185,7 +152,7 @@ message_send_chat(const char *const barejid, const char *const msg, const char *
|
|||||||
stanza_attach_x_oob_url(ctx, message, oob_url);
|
stanza_attach_x_oob_url(ctx, message, oob_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_RECEIPTS_REQUEST)) {
|
if (request_receipt) {
|
||||||
stanza_attach_receipt_request(ctx, message);
|
stanza_attach_receipt_request(ctx, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,12 +163,12 @@ message_send_chat(const char *const barejid, const char *const msg, const char *
|
|||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
message_send_chat_pgp(const char *const barejid, const char *const msg)
|
message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean request_receipt)
|
||||||
{
|
{
|
||||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||||
|
|
||||||
char *state = _session_state(barejid);
|
char *state = chat_session_get_state(barejid);
|
||||||
char *jid = _session_jid(barejid);
|
char *jid = chat_session_get_jid(barejid);
|
||||||
char *id = create_unique_id("msg");
|
char *id = create_unique_id("msg");
|
||||||
|
|
||||||
xmpp_stanza_t *message = NULL;
|
xmpp_stanza_t *message = NULL;
|
||||||
@ -240,7 +207,7 @@ message_send_chat_pgp(const char *const barejid, const char *const msg)
|
|||||||
stanza_attach_state(ctx, message, state);
|
stanza_attach_state(ctx, message, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_RECEIPTS_REQUEST)) {
|
if (request_receipt) {
|
||||||
stanza_attach_receipt_request(ctx, message);
|
stanza_attach_receipt_request(ctx, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,12 +218,12 @@ message_send_chat_pgp(const char *const barejid, const char *const msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
message_send_chat_otr(const char *const barejid, const char *const msg)
|
message_send_chat_otr(const char *const barejid, const char *const msg, gboolean request_receipt)
|
||||||
{
|
{
|
||||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||||
|
|
||||||
char *state = _session_state(barejid);
|
char *state = chat_session_get_state(barejid);
|
||||||
char *jid = _session_jid(barejid);
|
char *jid = chat_session_get_jid(barejid);
|
||||||
char *id = create_unique_id("msg");
|
char *id = create_unique_id("msg");
|
||||||
|
|
||||||
xmpp_stanza_t *message = stanza_create_message(ctx, id, barejid, STANZA_TYPE_CHAT, msg);
|
xmpp_stanza_t *message = stanza_create_message(ctx, id, barejid, STANZA_TYPE_CHAT, msg);
|
||||||
@ -270,7 +237,7 @@ message_send_chat_otr(const char *const barejid, const char *const msg)
|
|||||||
stanza_attach_hints_no_copy(ctx, message);
|
stanza_attach_hints_no_copy(ctx, message);
|
||||||
stanza_attach_hints_no_store(ctx, message);
|
stanza_attach_hints_no_store(ctx, message);
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_RECEIPTS_REQUEST)) {
|
if (request_receipt) {
|
||||||
stanza_attach_receipt_request(ctx, message);
|
stanza_attach_receipt_request(ctx, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,9 +130,10 @@ gboolean connection_send_stanza(const char *const stanza);
|
|||||||
GList* connection_get_available_resources(void);
|
GList* connection_get_available_resources(void);
|
||||||
gboolean connection_supports(const char *const feature);
|
gboolean connection_supports(const char *const feature);
|
||||||
|
|
||||||
char* message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url);
|
char* message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url,
|
||||||
char* message_send_chat_otr(const char *const barejid, const char *const msg);
|
gboolean request_receipt);
|
||||||
char* message_send_chat_pgp(const char *const barejid, const char *const msg);
|
char* message_send_chat_otr(const char *const barejid, const char *const msg, gboolean request_receipt);
|
||||||
|
char* message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean request_receipt);
|
||||||
void message_send_private(const char *const fulljid, const char *const msg, const char *const oob_url);
|
void message_send_private(const char *const fulljid, const char *const msg, const char *const oob_url);
|
||||||
void message_send_groupchat(const char *const roomjid, const char *const msg, const char *const oob_url);
|
void message_send_groupchat(const char *const roomjid, const char *const msg, const char *const oob_url);
|
||||||
void message_send_groupchat_subject(const char *const roomjid, const char *const subject);
|
void message_send_groupchat_subject(const char *const roomjid, const char *const subject);
|
||||||
@ -183,6 +184,7 @@ void caps_destroy(EntityCapabilities *caps);
|
|||||||
void caps_reset_ver(void);
|
void caps_reset_ver(void);
|
||||||
void caps_add_feature(char *feature);
|
void caps_add_feature(char *feature);
|
||||||
void caps_remove_feature(char *feature);
|
void caps_remove_feature(char *feature);
|
||||||
|
gboolean caps_jid_has_feature(const char *const jid, const char *const feature);
|
||||||
|
|
||||||
gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str);
|
gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str);
|
||||||
gboolean bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str);
|
gboolean bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str);
|
||||||
|
@ -74,6 +74,7 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
PROF_FUNC_TEST(send_receipt_request),
|
PROF_FUNC_TEST(send_receipt_request),
|
||||||
PROF_FUNC_TEST(send_receipt_on_request),
|
PROF_FUNC_TEST(send_receipt_on_request),
|
||||||
|
PROF_FUNC_TEST(does_not_send_receipt_request_to_barejid),
|
||||||
PROF_FUNC_TEST(sends_new_item),
|
PROF_FUNC_TEST(sends_new_item),
|
||||||
PROF_FUNC_TEST(sends_new_item_nick),
|
PROF_FUNC_TEST(sends_new_item_nick),
|
||||||
PROF_FUNC_TEST(sends_remove_item),
|
PROF_FUNC_TEST(sends_remove_item),
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "proftest.h"
|
#include "proftest.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
send_receipt_request(void **state)
|
does_not_send_receipt_request_to_barejid(void **state)
|
||||||
{
|
{
|
||||||
prof_input("/receipts request on");
|
prof_input("/receipts request on");
|
||||||
|
|
||||||
@ -23,6 +23,43 @@ send_receipt_request(void **state)
|
|||||||
assert_true(stbbr_received(
|
assert_true(stbbr_received(
|
||||||
"<message id='*' type='chat' to='somejid@someserver.com'>"
|
"<message id='*' type='chat' to='somejid@someserver.com'>"
|
||||||
"<body>Hi there</body>"
|
"<body>Hi there</body>"
|
||||||
|
"</message>"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
send_receipt_request(void **state)
|
||||||
|
{
|
||||||
|
prof_input("/receipts request on");
|
||||||
|
|
||||||
|
prof_connect();
|
||||||
|
|
||||||
|
stbbr_for_id("prof_caps_4",
|
||||||
|
"<iq from='buddy1@localhost/laptop' to='stabber@localhost' id='prof_caps_4' type='result'>"
|
||||||
|
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://www.profanity.im#hAkb1xZdJV9BQpgGNw8zG5Xsals='>"
|
||||||
|
"<identity category='client' name='Profanity 0.5.0' type='console'/>"
|
||||||
|
"<feature var='urn:xmpp:receipts'/>"
|
||||||
|
"</query>"
|
||||||
|
"</iq>"
|
||||||
|
);
|
||||||
|
|
||||||
|
stbbr_send(
|
||||||
|
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
|
||||||
|
"<priority>15</priority>"
|
||||||
|
"<status>My status</status>"
|
||||||
|
"<c hash='sha-256' xmlns='http://jabber.org/protocol/caps' node='http://www.profanity.im' ver='hAkb1xZdJV9BQpgGNw8zG5Xsals='/>"
|
||||||
|
"</presence>"
|
||||||
|
);
|
||||||
|
|
||||||
|
prof_output_exact("Buddy1 is online, \"My status\"");
|
||||||
|
|
||||||
|
prof_input("/msg Buddy1");
|
||||||
|
prof_input("/resource set laptop");
|
||||||
|
prof_input("Hi there, where is my receipt?");
|
||||||
|
|
||||||
|
assert_true(stbbr_received(
|
||||||
|
"<message id='*' type='chat' to='buddy1@localhost/laptop'>"
|
||||||
|
"<body>Hi there, where is my receipt?</body>"
|
||||||
"<request xmlns='urn:xmpp:receipts'/>"
|
"<request xmlns='urn:xmpp:receipts'/>"
|
||||||
"</message>"
|
"</message>"
|
||||||
));
|
));
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
void does_not_send_receipt_request_to_barejid(void **state);
|
||||||
void send_receipt_request(void **state);
|
void send_receipt_request(void **state);
|
||||||
void send_receipt_on_request(void **state);
|
void send_receipt_on_request(void **state);
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ char* otr_on_message_recv(const char * const barejid, const char * const resourc
|
|||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
gboolean otr_on_message_send(ProfChatWin *chatwin, const char * const message)
|
gboolean otr_on_message_send(ProfChatWin *chatwin, const char * const message, gboolean request_receipt)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,8 @@ void privwin_incoming_msg(ProfPrivateWin *privatewin, const char * const message
|
|||||||
void ui_disconnected(void) {}
|
void ui_disconnected(void) {}
|
||||||
void chatwin_recipient_gone(ProfChatWin *chatwin) {}
|
void chatwin_recipient_gone(ProfChatWin *chatwin) {}
|
||||||
|
|
||||||
void chatwin_outgoing_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode) {}
|
void chatwin_outgoing_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode,
|
||||||
|
gboolean request_receipt) {}
|
||||||
void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char * const message, prof_enc_t enc_mode) {}
|
void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char * const message, prof_enc_t enc_mode) {}
|
||||||
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char * const message) {}
|
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char * const message) {}
|
||||||
|
|
||||||
|
@ -91,21 +91,22 @@ connection_supports(const char *const feature)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// message functions
|
// message functions
|
||||||
char* message_send_chat(const char * const barejid, const char * const msg, const char *const oob_url)
|
char* message_send_chat(const char * const barejid, const char * const msg, const char *const oob_url,
|
||||||
|
gboolean request_receipt)
|
||||||
{
|
{
|
||||||
check_expected(barejid);
|
check_expected(barejid);
|
||||||
check_expected(msg);
|
check_expected(msg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* message_send_chat_otr(const char * const barejid, const char * const msg)
|
char* message_send_chat_otr(const char * const barejid, const char * const msg, gboolean request_receipt)
|
||||||
{
|
{
|
||||||
check_expected(barejid);
|
check_expected(barejid);
|
||||||
check_expected(msg);
|
check_expected(msg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* message_send_chat_pgp(const char * const barejid, const char * const msg)
|
char* message_send_chat_pgp(const char * const barejid, const char * const msg, gboolean request_receipt)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -213,6 +214,10 @@ EntityCapabilities* caps_lookup(const char * const jid)
|
|||||||
void caps_close(void) {}
|
void caps_close(void) {}
|
||||||
void caps_destroy(EntityCapabilities *caps) {}
|
void caps_destroy(EntityCapabilities *caps) {}
|
||||||
void caps_reset_ver(void) {}
|
void caps_reset_ver(void) {}
|
||||||
|
gboolean caps_jid_has_feature(const char *const jid, const char *const feature)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str)
|
gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user