From d3c6e5c62cb405cb6db646ee1ee03ca1e51d5e00 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 12 May 2019 00:09:50 +0200 Subject: Enable sending chat state notifications in private rooms --- .../src/module/xep/0085_chat_state_notifications.vala | 9 +++++---- .../src/module/xep/0334_message_processing_hints.vala | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 xmpp-vala/src/module/xep/0334_message_processing_hints.vala (limited to 'xmpp-vala/src') diff --git a/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala b/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala index e1106597..5a9b0914 100644 --- a/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala +++ b/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala @@ -21,11 +21,12 @@ public class Module : XmppStreamModule { /** * "A message stanza that does not contain standard messaging content [...] SHOULD be a state other than " (0085, 5.6) */ - public void send_state(XmppStream stream, Jid jid, string state) { - MessageStanza message = new MessageStanza(); - message.to = jid; - message.type_ = MessageStanza.TYPE_CHAT; + public void send_state(XmppStream stream, Jid jid, string message_type, string state) { + MessageStanza message = new MessageStanza() { to=jid, type_=message_type }; message.stanza.put_node(new StanzaNode.build(state, NS_URI).add_self_xmlns()); + + MessageProcessingHints.set_message_hint(message, MessageProcessingHints.HINT_NO_STORE); + stream.get_module(MessageModule.IDENTITY).send_message(stream, message); } diff --git a/xmpp-vala/src/module/xep/0334_message_processing_hints.vala b/xmpp-vala/src/module/xep/0334_message_processing_hints.vala new file mode 100644 index 00000000..352e03ac --- /dev/null +++ b/xmpp-vala/src/module/xep/0334_message_processing_hints.vala @@ -0,0 +1,15 @@ +namespace Xmpp.Xep.MessageProcessingHints { + +private const string NS_URI = "urn:xmpp:hints"; + +private const string HINT_NO_PERMANENT_STORE = "no-permanent-store"; +private const string HINT_NO_STORE = "no-store"; +private const string HINT_NO_COPY = "no-copy"; +private const string HINT_STORE = "store"; + +public static void set_message_hint(MessageStanza message, string message_hint) { + StanzaNode hint_node = (new StanzaNode.build(message_hint, NS_URI)).add_self_xmlns(); + message.stanza.put_node(hint_node); +} + +} -- cgit v1.2.3-70-g09d2