aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/xep
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src/module/xep')
-rw-r--r--xmpp-vala/src/module/xep/0045_muc/module.vala2
-rw-r--r--xmpp-vala/src/module/xep/0313_message_archive_management.vala7
-rw-r--r--xmpp-vala/src/module/xep/0359_unique_stable_stanza_ids.vala46
3 files changed, 53 insertions, 2 deletions
diff --git a/xmpp-vala/src/module/xep/0045_muc/module.vala b/xmpp-vala/src/module/xep/0045_muc/module.vala
index 3ff28b2b..b30145ff 100644
--- a/xmpp-vala/src/module/xep/0045_muc/module.vala
+++ b/xmpp-vala/src/module/xep/0045_muc/module.vala
@@ -48,6 +48,7 @@ public enum Feature {
PUBLIC,
ROOMS,
SEMI_ANONYMOUS,
+ STABLE_ID,
TEMPORARY,
UNMODERATED,
UNSECURED
@@ -376,6 +377,7 @@ public class Module : XmppStreamModule {
case "http://jabber.org/protocol/muc#register": parsed = Feature.REGISTER; break;
case "http://jabber.org/protocol/muc#roomconfig": parsed = Feature.ROOMCONFIG; break;
case "http://jabber.org/protocol/muc#roominfo": parsed = Feature.ROOMINFO; break;
+ case "http://jabber.org/protocol/muc#stable_id": parsed = Feature.STABLE_ID; break;
case "muc_hidden": parsed = Feature.HIDDEN; break;
case "muc_membersonly": parsed = Feature.MEMBERS_ONLY; break;
case "muc_moderated": parsed = Feature.MODERATED; break;
diff --git a/xmpp-vala/src/module/xep/0313_message_archive_management.vala b/xmpp-vala/src/module/xep/0313_message_archive_management.vala
index 69302be3..4f8cadec 100644
--- a/xmpp-vala/src/module/xep/0313_message_archive_management.vala
+++ b/xmpp-vala/src/module/xep/0313_message_archive_management.vala
@@ -106,7 +106,8 @@ public class ReceivedPipelineListener : StanzaListener<MessageStanza> {
StanzaNode? forward_node = message.stanza.get_deep_subnode(NS_VER(stream) + ":result", "urn:xmpp:forward:0:forwarded", DelayedDelivery.NS_URI + ":delay");
DateTime? datetime = DelayedDelivery.Module.get_time_for_node(forward_node);
- message.add_flag(new MessageFlag(datetime));
+ string? mam_id = message.stanza.get_deep_attribute(NS_VER(stream) + ":result", NS_VER(stream) + ":id");
+ message.add_flag(new MessageFlag(datetime, mam_id));
message.stanza = message_node;
message.rerun_parsing = true;
@@ -132,9 +133,11 @@ public class MessageFlag : Xmpp.MessageFlag {
public const string ID = "message_archive_management";
public DateTime? server_time { get; private set; }
+ public string? mam_id { get; private set; }
- public MessageFlag(DateTime? server_time) {
+ public MessageFlag(DateTime? server_time, string? mam_id) {
this.server_time = server_time;
+ this.mam_id = mam_id;
}
public static MessageFlag? get_flag(MessageStanza message) { return (MessageFlag) message.get_flag(NS_URI, ID); }
diff --git a/xmpp-vala/src/module/xep/0359_unique_stable_stanza_ids.vala b/xmpp-vala/src/module/xep/0359_unique_stable_stanza_ids.vala
new file mode 100644
index 00000000..b6defc6d
--- /dev/null
+++ b/xmpp-vala/src/module/xep/0359_unique_stable_stanza_ids.vala
@@ -0,0 +1,46 @@
+namespace Xmpp.Xep.UniqueStableStanzaIDs {
+
+private const string NS_URI = "urn:xmpp:sid:0";
+
+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 class Module : XmppStreamModule {
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0359_unique_and_stable_stanza_ids");
+
+ public override void attach(XmppStream stream) {
+ stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
+ }
+
+ public override void detach(XmppStream stream) {}
+
+ public override string get_ns() { return NS_URI; }
+
+ public override string get_id() { return IDENTITY.id; }
+}
+
+public static void set_origin_id(MessageStanza message, string origin_id) {
+ StanzaNode hint_node = (new StanzaNode.build("origin-id", NS_URI)).add_self_xmlns().put_attribute("id", origin_id);
+ message.stanza.put_node(hint_node);
+}
+
+public static string? get_origin_id(MessageStanza message) {
+ StanzaNode? node = message.stanza.get_subnode("origin-id", NS_URI);
+ if (node == null) return null;
+
+ return node.get_attribute("id");
+}
+
+public static string? get_stanza_id(MessageStanza message, Jid by) {
+ string by_str = by.to_string();
+ foreach (StanzaNode node in message.stanza.get_subnodes("stanza-id", NS_URI)) {
+ if (node.get_attribute("by") == by_str) {
+ return node.get_attribute("id");
+ }
+ }
+ return null;
+}
+
+}