aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src')
-rw-r--r--xmpp-vala/src/core/xmpp_stream.vala29
-rw-r--r--xmpp-vala/src/module/bind.vala23
-rw-r--r--xmpp-vala/src/module/iq/module.vala7
-rw-r--r--xmpp-vala/src/module/message/module.vala7
-rw-r--r--xmpp-vala/src/module/presence/flag.vala8
-rw-r--r--xmpp-vala/src/module/presence/module.vala11
-rw-r--r--xmpp-vala/src/module/roster/flag.vala11
-rw-r--r--xmpp-vala/src/module/roster/module.vala13
-rw-r--r--xmpp-vala/src/module/sasl.vala29
-rw-r--r--xmpp-vala/src/module/stream_error.vala17
-rw-r--r--xmpp-vala/src/module/tls.vala25
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/flag.vala8
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/module.vala11
-rw-r--r--xmpp-vala/src/module/xep/0045_muc/flag.vala8
-rw-r--r--xmpp-vala/src/module/xep/0045_muc/module.vala17
-rw-r--r--xmpp-vala/src/module/xep/0048_bookmarks/module.vala5
-rw-r--r--xmpp-vala/src/module/xep/0049_private_xml_storage.vala5
-rw-r--r--xmpp-vala/src/module/xep/0054_vcard/module.vala9
-rw-r--r--xmpp-vala/src/module/xep/0060_pubsub.vala5
-rw-r--r--xmpp-vala/src/module/xep/0084_user_avatars.vala5
-rw-r--r--xmpp-vala/src/module/xep/0085_chat_state_notifications.vala5
-rw-r--r--xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala9
-rw-r--r--xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala5
-rw-r--r--xmpp-vala/src/module/xep/0199_ping.vala5
-rw-r--r--xmpp-vala/src/module/xep/0203_delayed_delivery.vala5
-rw-r--r--xmpp-vala/src/module/xep/0280_message_carbons.vala13
-rw-r--r--xmpp-vala/src/module/xep/0333_chat_markers.vala5
27 files changed, 126 insertions, 174 deletions
diff --git a/xmpp-vala/src/core/xmpp_stream.vala b/xmpp-vala/src/core/xmpp_stream.vala
index 57eafe45..f3be115d 100644
--- a/xmpp-vala/src/core/xmpp_stream.vala
+++ b/xmpp-vala/src/core/xmpp_stream.vala
@@ -101,11 +101,14 @@ public class XmppStream {
flags.add(flag);
}
- public XmppStreamFlag? get_flag(string ns, string id) {
+ public bool has_flag<T>(FlagIdentity<T>? identity) {
+ return get_flag(identity) != null;
+ }
+
+ public T? get_flag<T>(FlagIdentity<T>? identity) {
+ if (identity == null) return null;
foreach (var flag in flags) {
- if (flag.get_ns() == ns && flag.get_id() == id) {
- return flag;
- }
+ if (identity.matches(flag)) return identity.cast(flag);
}
return null;
}
@@ -225,6 +228,24 @@ public class XmppStream {
}
}
+public class FlagIdentity<T> : Object {
+ public string ns { get; private set; }
+ public string id { get; private set; }
+
+ public FlagIdentity(string ns, string id) {
+ this.ns = ns;
+ this.id = id;
+ }
+
+ public T? cast(XmppStreamFlag module) {
+ return (T?) module;
+ }
+
+ public bool matches(XmppStreamFlag module) {
+ return module.get_ns() == ns && module.get_id() == id;
+ }
+}
+
public abstract class XmppStreamFlag {
public abstract string get_ns();
public abstract string get_id();
diff --git a/xmpp-vala/src/module/bind.vala b/xmpp-vala/src/module/bind.vala
index 0bc271fb..f4b1a948 100644
--- a/xmpp-vala/src/module/bind.vala
+++ b/xmpp-vala/src/module/bind.vala
@@ -5,8 +5,7 @@ namespace Xmpp.Bind {
/** The parties to a stream MUST consider resource binding as mandatory-to-negotiate. (RFC6120 7.3.1) */
public class Module : XmppStreamNegotiationModule {
- public const string ID = "bind_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "bind_module");
private string requested_resource;
@@ -17,7 +16,7 @@ namespace Xmpp.Bind {
}
public void iq_response_stanza(XmppStream stream, Iq.Stanza iq) {
- var flag = Flag.get_flag(stream);
+ var flag = stream.get_flag(Flag.IDENTITY);
if (flag == null || flag.finished) return;
if (iq.type_ == Iq.Stanza.TYPE_RESULT) {
@@ -54,15 +53,15 @@ namespace Xmpp.Bind {
}
public override bool mandatory_outstanding(XmppStream stream) {
- return !Flag.has_flag(stream) || !Flag.get_flag(stream).finished;
+ return !stream.has_flag(Flag.IDENTITY) || !stream.get_flag(Flag.IDENTITY).finished;
}
public override bool negotiation_active(XmppStream stream) {
- return Flag.has_flag(stream) && !Flag.get_flag(stream).finished;
+ return stream.has_flag(Flag.IDENTITY) && !stream.get_flag(Flag.IDENTITY).finished;
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private static void on_bind_response(XmppStream stream, Iq.Stanza iq) {
stream.get_module(Bind.Module.IDENTITY).iq_response_stanza(stream, iq);
@@ -70,19 +69,11 @@ namespace Xmpp.Bind {
}
public class Flag : XmppStreamFlag {
- public const string ID = "bind";
+ public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "bind");
public string? my_jid;
public bool finished = false;
- public static Flag? get_flag(XmppStream stream) {
- return (Flag?) stream.get_flag(NS_URI, ID);
- }
-
- public static bool has_flag(XmppStream stream) {
- return get_flag(stream) != null;
- }
-
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
}
diff --git a/xmpp-vala/src/module/iq/module.vala b/xmpp-vala/src/module/iq/module.vala
index 693f1da3..eed3389d 100644
--- a/xmpp-vala/src/module/iq/module.vala
+++ b/xmpp-vala/src/module/iq/module.vala
@@ -6,8 +6,7 @@ namespace Xmpp.Iq {
private const string NS_URI = "jabber:client";
public class Module : XmppStreamNegotiationModule {
- public const string ID = "iq_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "iq_module");
private HashMap<string, ResponseListener> responseListeners = new HashMap<string, ResponseListener>();
private HashMap<string, ArrayList<Handler>> namespaceRegistrants = new HashMap<string, ArrayList<Handler>>();
@@ -48,10 +47,10 @@ namespace Xmpp.Iq {
public override bool negotiation_active(XmppStream stream) { return false; }
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private void on_received_iq_stanza(XmppStream stream, StanzaNode node) {
- Iq.Stanza iq = new Iq.Stanza.from_stanza(node, Bind.Flag.has_flag(stream) ? Bind.Flag.get_flag(stream).my_jid : null);
+ Iq.Stanza iq = new Iq.Stanza.from_stanza(node, stream.has_flag(Bind.Flag.IDENTITY) ? stream.get_flag(Bind.Flag.IDENTITY).my_jid : null);
if (iq.type_ == Iq.Stanza.TYPE_RESULT || iq.is_error()) {
if (responseListeners.has_key(iq.id)) {
diff --git a/xmpp-vala/src/module/message/module.vala b/xmpp-vala/src/module/message/module.vala
index 1d54443c..060cb4cb 100644
--- a/xmpp-vala/src/module/message/module.vala
+++ b/xmpp-vala/src/module/message/module.vala
@@ -6,8 +6,7 @@ namespace Xmpp.Message {
private const string NS_URI = "jabber:client";
public class Module : XmppStreamModule {
- public const string ID = "message_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "message_module");
public signal void pre_send_message(XmppStream stream, Message.Stanza message);
public signal void pre_received_message(XmppStream stream, Message.Stanza message);
@@ -19,7 +18,7 @@ namespace Xmpp.Message {
}
public void received_message_stanza(XmppStream stream, StanzaNode node) {
- Message.Stanza message = new Message.Stanza.from_stanza(node, Bind.Flag.get_flag(stream).my_jid);
+ Message.Stanza message = new Message.Stanza.from_stanza(node, stream.get_flag(Bind.Flag.IDENTITY).my_jid);
do {
message.rerun_parsing = false;
pre_received_message(stream, message);
@@ -41,7 +40,7 @@ namespace Xmpp.Message {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
}
diff --git a/xmpp-vala/src/module/presence/flag.vala b/xmpp-vala/src/module/presence/flag.vala
index a92c9405..8fb44e13 100644
--- a/xmpp-vala/src/module/presence/flag.vala
+++ b/xmpp-vala/src/module/presence/flag.vala
@@ -5,7 +5,7 @@ using Xmpp.Core;
namespace Xmpp.Presence {
public class Flag : XmppStreamFlag {
- public const string ID = "presence";
+ public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "presence");
private HashMap<string, ConcurrentList<string>> resources = new HashMap<string, ConcurrentList<string>>();
private HashMap<string, Presence.Stanza> presences = new HashMap<string, Presence.Stanza>();
@@ -52,13 +52,9 @@ public class Flag : XmppStreamFlag {
}
}
- public static Flag? get_flag(XmppStream stream) { return (Flag?) stream.get_flag(NS_URI, ID); }
-
- public static bool has_flag(XmppStream stream) { return get_flag(stream) != null; }
-
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
} \ No newline at end of file
diff --git a/xmpp-vala/src/module/presence/module.vala b/xmpp-vala/src/module/presence/module.vala
index 7e5dca17..3c078453 100644
--- a/xmpp-vala/src/module/presence/module.vala
+++ b/xmpp-vala/src/module/presence/module.vala
@@ -4,8 +4,7 @@ namespace Xmpp.Presence {
private const string NS_URI = "jabber:client";
public class Module : XmppStreamModule {
- public const string ID = "presence_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "presence_module");
public signal void received_presence(XmppStream stream, Presence.Stanza presence);
public signal void pre_send_presence_stanza(XmppStream stream, Presence.Stanza presence);
@@ -67,16 +66,16 @@ namespace Xmpp.Presence {
}
private void on_received_presence_stanza(XmppStream stream, StanzaNode node) {
- Presence.Stanza presence = new Presence.Stanza.from_stanza(node, Bind.Flag.get_flag(stream).my_jid);
+ Presence.Stanza presence = new Presence.Stanza.from_stanza(node, stream.get_flag(Bind.Flag.IDENTITY).my_jid);
received_presence(stream, presence);
switch (presence.type_) {
case Presence.Stanza.TYPE_AVAILABLE:
- Flag.get_flag(stream).add_presence(presence);
+ stream.get_flag(Flag.IDENTITY).add_presence(presence);
received_available(stream, presence);
received_available_show(stream, presence.from, presence.show);
break;
case Presence.Stanza.TYPE_UNAVAILABLE:
- Flag.get_flag(stream).remove_presence(presence.from);
+ stream.get_flag(Flag.IDENTITY).remove_presence(presence.from);
received_unavailable(stream, presence.from);
break;
case Presence.Stanza.TYPE_SUBSCRIBE:
@@ -101,7 +100,7 @@ namespace Xmpp.Presence {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
}
diff --git a/xmpp-vala/src/module/roster/flag.vala b/xmpp-vala/src/module/roster/flag.vala
index c3e35158..43d185d9 100644
--- a/xmpp-vala/src/module/roster/flag.vala
+++ b/xmpp-vala/src/module/roster/flag.vala
@@ -6,9 +6,11 @@ namespace Xmpp.Roster {
public class Flag : XmppStreamFlag {
public const string ID = "roster";
+ public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, ID);
+
public HashMap<string, Item> roster_items = new HashMap<string, Item>();
- internal string? iq_id;
+ public string? iq_id;
public Collection<Item> get_roster() {
return roster_items.values;
@@ -18,13 +20,8 @@ public class Flag : XmppStreamFlag {
return roster_items[jid];
}
- public static Flag? get_flag(XmppStream stream) { return (Flag?) stream.get_flag(NS_URI, ID); }
-
- public static bool has_flag(XmppStream stream) { return get_flag(stream) != null; }
-
public override string get_ns() { return NS_URI; }
-
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
} \ No newline at end of file
diff --git a/xmpp-vala/src/module/roster/module.vala b/xmpp-vala/src/module/roster/module.vala
index f29b73f7..1ebb7f22 100644
--- a/xmpp-vala/src/module/roster/module.vala
+++ b/xmpp-vala/src/module/roster/module.vala
@@ -6,8 +6,7 @@ namespace Xmpp.Roster {
private const string NS_URI = "jabber:iq:roster";
public class Module : XmppStreamModule, Iq.Handler {
- public const string ID = "roster_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "roster_module");
public signal void received_roster(XmppStream stream, Collection<Item> roster);
public signal void item_removed(XmppStream stream, Item roster_item);
@@ -56,7 +55,7 @@ namespace Xmpp.Roster {
StanzaNode? query_node = iq.stanza.get_subnode("query", NS_URI);
if (query_node == null) return;
- Flag flag = Flag.get_flag(stream);
+ Flag flag = stream.get_flag(Flag.IDENTITY);
Item item = new Item.from_stanza_node(query_node.get_subnode("item", NS_URI));
switch (item.subscription) {
case Item.SUBSCRIPTION_REMOVE:
@@ -89,17 +88,17 @@ namespace Xmpp.Roster {
}
internal override string get_ns() { return NS_URI; }
- internal override string get_id() { return ID; }
+ internal override string get_id() { return IDENTITY.id; }
private void roster_get(XmppStream stream) {
- Flag.get_flag(stream).iq_id = random_uuid();
+ stream.get_flag(Flag.IDENTITY).iq_id = random_uuid();
StanzaNode query_node = new StanzaNode.build("query", NS_URI).add_self_xmlns();
- Iq.Stanza iq = new Iq.Stanza.get(query_node, Flag.get_flag(stream).iq_id);
+ Iq.Stanza iq = new Iq.Stanza.get(query_node, stream.get_flag(Flag.IDENTITY).iq_id);
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, on_roster_get_received);
}
private static void on_roster_get_received(XmppStream stream, Iq.Stanza iq) {
- Flag flag = Flag.get_flag(stream);
+ Flag flag = stream.get_flag(Flag.IDENTITY);
if (iq.id == flag.iq_id) {
StanzaNode? query_node = iq.stanza.get_subnode("query", NS_URI);
foreach (StanzaNode item_node in query_node.sub_nodes) {
diff --git a/xmpp-vala/src/module/sasl.vala b/xmpp-vala/src/module/sasl.vala
index 79748211..ee6a87f7 100644
--- a/xmpp-vala/src/module/sasl.vala
+++ b/xmpp-vala/src/module/sasl.vala
@@ -4,8 +4,7 @@ namespace Xmpp.PlainSasl {
private const string NS_URI = "urn:ietf:params:xml:ns:xmpp-sasl";
public class Module : XmppStreamNegotiationModule {
- public const string ID = "plain_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "plain_module");
private const string MECHANISM = "PLAIN";
private string name;
@@ -33,18 +32,18 @@ namespace Xmpp.PlainSasl {
if (node.ns_uri == NS_URI) {
if (node.name == "success") {
stream.require_setup();
- Flag.get_flag(stream).finished = true;
+ stream.get_flag(Flag.IDENTITY).finished = true;
} else if (node.name == "failure") {
- stream.remove_flag(Flag.get_flag(stream));
+ stream.remove_flag(stream.get_flag(Flag.IDENTITY));
received_auth_failure(stream, node);
}
}
}
public void received_features_node(XmppStream stream) {
- if (Flag.has_flag(stream)) return;
+ if (stream.has_flag(Flag.IDENTITY)) return;
if (stream.is_setup_needed()) return;
- if (!Tls.Flag.has_flag(stream) || !Tls.Flag.get_flag(stream).finished) return;
+ if (!stream.has_flag(Tls.Flag.IDENTITY) || !stream.get_flag(Tls.Flag.IDENTITY).finished) return;
var mechanisms = stream.features.get_subnode("mechanisms", NS_URI);
if (mechanisms != null) {
@@ -105,32 +104,24 @@ namespace Xmpp.PlainSasl {
}
public override bool mandatory_outstanding(XmppStream stream) {
- return !Flag.has_flag(stream) || !Flag.get_flag(stream).finished;
+ return !stream.has_flag(Flag.IDENTITY) || !stream.get_flag(Flag.IDENTITY).finished;
}
public override bool negotiation_active(XmppStream stream) {
- return Flag.has_flag(stream) && !Flag.get_flag(stream).finished;
+ return stream.has_flag(Flag.IDENTITY) && !stream.get_flag(Flag.IDENTITY).finished;
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
public class Flag : XmppStreamFlag {
- public const string ID = "sasl";
+ public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "sasl");
public string mechanism;
public string name;
public bool finished = false;
- public static Flag? get_flag(XmppStream stream) {
- return (Flag?) stream.get_flag(NS_URI, ID);
- }
-
- public static bool has_flag(XmppStream stream) {
- return get_flag(stream) != null;
- }
-
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
}
diff --git a/xmpp-vala/src/module/stream_error.vala b/xmpp-vala/src/module/stream_error.vala
index c775bdaa..bd292d2b 100644
--- a/xmpp-vala/src/module/stream_error.vala
+++ b/xmpp-vala/src/module/stream_error.vala
@@ -7,8 +7,7 @@ namespace Xmpp.StreamError {
private const string NS_ERROR = "urn:ietf:params:xml:ns:xmpp-streams";
public class Module : XmppStreamModule {
- public const string ID = "stream_error_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "stream_error_module");
public override void attach(XmppStream stream) {
stream.received_nonza.connect(on_received_nonstanza);
@@ -23,7 +22,7 @@ namespace Xmpp.StreamError {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private void on_received_nonstanza(XmppStream stream, StanzaNode node) {
if (node.name == "error" && node.ns_uri == "http://etherx.jabber.org/streams") {
@@ -89,7 +88,7 @@ namespace Xmpp.StreamError {
}
public class Flag : XmppStreamFlag {
- public const string ID = "stream_error";
+ public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "stream_error");
public enum Reconnect {
UNKNOWN,
@@ -102,15 +101,7 @@ namespace Xmpp.StreamError {
public Reconnect reconnection_recomendation = Reconnect.UNKNOWN;
public bool resource_rejected = false;
- public static Flag? get_flag(XmppStream stream) {
- return (Flag?) stream.get_flag(NS_URI, ID);
- }
-
- public static bool has_flag(XmppStream stream) {
- return get_flag(stream) != null;
- }
-
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
}
diff --git a/xmpp-vala/src/module/tls.vala b/xmpp-vala/src/module/tls.vala
index 01dcf51d..8cc7ad16 100644
--- a/xmpp-vala/src/module/tls.vala
+++ b/xmpp-vala/src/module/tls.vala
@@ -4,8 +4,7 @@ namespace Xmpp.Tls {
private const string NS_URI = "urn:ietf:params:xml:ns:xmpp-tls";
public class Module : XmppStreamNegotiationModule {
- public const string ID = "tls_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "tls_module");
public bool require { get; set; default = true; }
public bool server_supports_tls = false;
@@ -34,7 +33,7 @@ namespace Xmpp.Tls {
// not allowed to continue in case that there is an error.
stream.reset_stream(conn);
- var flag = Flag.get_flag(stream);
+ var flag = stream.get_flag(Flag.IDENTITY);
flag.peer_certificate = conn.get_peer_certificate();
flag.finished = true;
} catch (Error e) {
@@ -44,7 +43,7 @@ namespace Xmpp.Tls {
}
private void received_features_node(XmppStream stream) {
- if (Flag.has_flag(stream)) return;
+ if (stream.has_flag(Flag.IDENTITY)) return;
if (stream.is_setup_needed()) return;
var starttls = stream.features.get_subnode("starttls", NS_URI);
@@ -68,31 +67,23 @@ namespace Xmpp.Tls {
}
public override bool mandatory_outstanding(XmppStream stream) {
- return require && (!Flag.has_flag(stream) || !Flag.get_flag(stream).finished);
+ return require && (!stream.has_flag(Flag.IDENTITY) || !stream.get_flag(Flag.IDENTITY).finished);
}
public override bool negotiation_active(XmppStream stream) {
- return Flag.has_flag(stream) && !Flag.get_flag(stream).finished;
+ return stream.has_flag(Flag.IDENTITY) && !stream.get_flag(Flag.IDENTITY).finished;
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
public class Flag : XmppStreamFlag {
- public const string ID = "tls_flag";
+ public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "tls");
public TlsCertificate? peer_certificate;
public bool finished = false;
- public static Flag? get_flag(XmppStream stream) {
- return (Flag?) stream.get_flag(NS_URI, ID);
- }
-
- public static bool has_flag(XmppStream stream) {
- return get_flag(stream) != null;
- }
-
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
}
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala b/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala
index 5be9f2eb..0f82f498 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala
@@ -5,7 +5,7 @@ using Xmpp.Core;
namespace Xmpp.Xep.ServiceDiscovery {
public class Flag : XmppStreamFlag {
- public const string ID = "service_discovery";
+ public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "service_discovery");
private HashMap<string, ArrayList<string>> entity_features = new HashMap<string, ArrayList<string>>();
public ArrayList<string> features = new ArrayList<string>();
@@ -21,13 +21,9 @@ public class Flag : XmppStreamFlag {
public void add_own_feature(string feature) { features.add(feature); }
- public static Flag? get_flag(XmppStream stream) { return (Flag?) stream.get_flag(NS_URI, ID); }
-
- public static bool has_flag(XmppStream stream) { return get_flag(stream) != null; }
-
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
} \ No newline at end of file
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
index 56df7771..4b51e230 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
@@ -8,8 +8,7 @@ namespace Xmpp.Xep.ServiceDiscovery {
public const string NS_URI_ITEMS = NS_URI + "#items";
public class Module : XmppStreamModule, Iq.Handler {
- public const string ID = "0030_service_discovery_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0030_service_discovery_module");
public ArrayList<Identity> identities = new ArrayList<Identity>();
@@ -18,7 +17,7 @@ namespace Xmpp.Xep.ServiceDiscovery {
}
public void add_feature(XmppStream stream, string feature) {
- Flag.get_flag(stream).add_own_feature(feature);
+ stream.get_flag(Flag.IDENTITY).add_own_feature(feature);
}
public void add_feature_notify(XmppStream stream, string feature) {
@@ -66,21 +65,21 @@ namespace Xmpp.Xep.ServiceDiscovery {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private static void on_request_info_response(XmppStream stream, Iq.Stanza iq, Object o) {
Tuple<OnInfoResult, Object> tuple = o as Tuple<OnInfoResult, Object>;
OnInfoResult on_result = tuple.a;
InfoResult? result = InfoResult.create_from_iq(iq);
if (result != null) {
- Flag.get_flag(stream).set_entitiy_features(iq.from, result.features);
+ stream.get_flag(Flag.IDENTITY).set_entitiy_features(iq.from, result.features);
on_result(stream, result, tuple.b);
}
}
private void send_query_result(XmppStream stream, Iq.Stanza iq_request) {
InfoResult query_result = new ServiceDiscovery.InfoResult(iq_request);
- query_result.features = Flag.get_flag(stream).features;
+ query_result.features = stream.get_flag(Flag.IDENTITY).features;
query_result.identities = identities;
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, query_result.iq);
}
diff --git a/xmpp-vala/src/module/xep/0045_muc/flag.vala b/xmpp-vala/src/module/xep/0045_muc/flag.vala
index 13363220..f6340a5c 100644
--- a/xmpp-vala/src/module/xep/0045_muc/flag.vala
+++ b/xmpp-vala/src/module/xep/0045_muc/flag.vala
@@ -5,7 +5,7 @@ using Xmpp.Core;
namespace Xmpp.Xep.Muc {
public class Flag : XmppStreamFlag {
- public const string ID = "muc";
+ public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "muc");
private HashMap<string, ListenerHolder> enter_listeners = new HashMap<string, ListenerHolder>();
private HashMap<string, string> enter_ids = new HashMap<string, string>();
@@ -68,13 +68,9 @@ public class Flag : XmppStreamFlag {
occupant_role.unset(full_jid);
}
- public static Flag? get_flag(XmppStream stream) { return (Flag?) stream.get_flag(NS_URI, ID); }
-
- public static bool has_flag(XmppStream stream) { return get_flag(stream) != null; }
-
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
}
} \ No newline at end of file
diff --git a/xmpp-vala/src/module/xep/0045_muc/module.vala b/xmpp-vala/src/module/xep/0045_muc/module.vala
index 8e139799..624d8421 100644
--- a/xmpp-vala/src/module/xep/0045_muc/module.vala
+++ b/xmpp-vala/src/module/xep/0045_muc/module.vala
@@ -29,8 +29,7 @@ public enum MucEnterError {
}
public class Module : XmppStreamModule {
- public const string ID = "0045_muc_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0045_muc_module");
public signal void received_occupant_affiliation(XmppStream stream, string jid, string? affiliation);
public signal void received_occupant_jid(XmppStream stream, string jid, string? real_jid);
@@ -46,13 +45,13 @@ public class Module : XmppStreamModule {
}
presence.stanza.put_node(x_node);
- Muc.Flag.get_flag(stream).start_muc_enter(bare_jid, presence.id, new ListenerHolder(success_listener, error_listener, store));
+ stream.get_flag(Flag.IDENTITY).start_muc_enter(bare_jid, presence.id, new ListenerHolder(success_listener, error_listener, store));
stream.get_module(Presence.Module.IDENTITY).send_presence(stream, presence);
}
public void exit(XmppStream stream, string jid) {
- string nick = Flag.get_flag(stream).get_muc_nick(jid);
+ string nick = stream.get_flag(Flag.IDENTITY).get_muc_nick(jid);
Presence.Stanza presence = new Presence.Stanza();
presence.to = jid + "/" + nick;
presence.type_ = Presence.Stanza.TYPE_UNAVAILABLE;
@@ -103,7 +102,7 @@ public class Module : XmppStreamModule {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private void change_role(XmppStream stream, string jid, string nick, string new_role) {
StanzaNode query = new StanzaNode.build("query", NS_URI_ADMIN).add_self_xmlns();
@@ -118,14 +117,14 @@ public class Module : XmppStreamModule {
StanzaNode? subject_node = message.stanza.get_subnode("subject");
if (subject_node != null) {
string subject = subject_node.get_string_content();
- Muc.Flag.get_flag(stream).set_muc_subject(message.from, subject);
+ stream.get_flag(Flag.IDENTITY).set_muc_subject(message.from, subject);
subject_set(stream, subject, message.from);
}
}
}
private void on_received_presence(XmppStream stream, Presence.Stanza presence) {
- Flag flag = Flag.get_flag(stream);
+ Flag flag = stream.get_flag(Flag.IDENTITY);
if (presence.is_error() && flag.is_muc_enter_outstanding() && flag.is_occupant(presence.from)) {
string bare_jid = get_bare_jid(presence.from);
ErrorStanza? error_stanza = presence.get_error();
@@ -152,7 +151,7 @@ public class Module : XmppStreamModule {
}
private void on_received_available(XmppStream stream, Presence.Stanza presence) {
- Flag flag = Flag.get_flag(stream);
+ Flag flag = stream.get_flag(Flag.IDENTITY);
if (flag.is_occupant(presence.from)) {
StanzaNode? x_node = presence.stanza.get_subnode("x", NS_URI_USER);
if (x_node != null) {
@@ -181,7 +180,7 @@ public class Module : XmppStreamModule {
}
private void on_received_unavailable(XmppStream stream, string jid) {
- Flag flag = Flag.get_flag(stream);
+ Flag flag = stream.get_flag(Flag.IDENTITY);
if (flag.is_occupant(jid)) {
flag.remove_occupant_info(jid);
}
diff --git a/xmpp-vala/src/module/xep/0048_bookmarks/module.vala b/xmpp-vala/src/module/xep/0048_bookmarks/module.vala
index 656ea6fd..4cb91a5b 100644
--- a/xmpp-vala/src/module/xep/0048_bookmarks/module.vala
+++ b/xmpp-vala/src/module/xep/0048_bookmarks/module.vala
@@ -6,8 +6,7 @@ namespace Xmpp.Xep.Bookmarks {
private const string NS_URI = "storage:bookmarks";
public class Module : XmppStreamModule {
- public const string ID = "0048_bookmarks_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0048_bookmarks_module");
public signal void conferences_updated(XmppStream stream, ArrayList<Conference> conferences);
@@ -91,7 +90,7 @@ public class Module : XmppStreamModule {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private static ArrayList<Conference> get_conferences_from_stanza(StanzaNode node) {
ArrayList<Conference> conferences = new ArrayList<Conference>();
diff --git a/xmpp-vala/src/module/xep/0049_private_xml_storage.vala b/xmpp-vala/src/module/xep/0049_private_xml_storage.vala
index a5d872b6..b843f63b 100644
--- a/xmpp-vala/src/module/xep/0049_private_xml_storage.vala
+++ b/xmpp-vala/src/module/xep/0049_private_xml_storage.vala
@@ -6,8 +6,7 @@ namespace Xmpp.Xep.PrivateXmlStorage {
private const string NS_URI = "jabber:iq:private";
public class Module : XmppStreamModule {
- public const string ID = "0049_private_xml_storage";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0049_private_xml_storage");
[CCode (has_target = false)] public delegate void OnSuccess(XmppStream stream, Object? reference);
public void store(XmppStream stream, StanzaNode node, OnSuccess listener, Object? reference) {
@@ -34,7 +33,7 @@ namespace Xmpp.Xep.PrivateXmlStorage {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private static void on_store_response(XmppStream stream, Iq.Stanza iq, Object o) {
Tuple<OnSuccess, Object> tuple = o as Tuple<OnSuccess, Object>;
diff --git a/xmpp-vala/src/module/xep/0054_vcard/module.vala b/xmpp-vala/src/module/xep/0054_vcard/module.vala
index b4c6910b..040e0646 100644
--- a/xmpp-vala/src/module/xep/0054_vcard/module.vala
+++ b/xmpp-vala/src/module/xep/0054_vcard/module.vala
@@ -5,8 +5,7 @@ private const string NS_URI = "vcard-temp";
private const string NS_URI_UPDATE = NS_URI + ":x:update";
public class Module : XmppStreamModule {
- public const string ID = "0027_current_pgp_usage";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0027_current_pgp_usage");
public signal void received_avatar(XmppStream stream, string jid, string id);
@@ -31,7 +30,7 @@ public class Module : XmppStreamModule {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private void on_received_presence(XmppStream stream, Presence.Stanza presence) {
StanzaNode? update_node = presence.stanza.get_subnode("x", NS_URI_UPDATE);
@@ -41,14 +40,14 @@ public class Module : XmppStreamModule {
string? sha1 = photo_node.get_string_content();
if (sha1 == null) return;
if (storage.has_image(sha1)) {
- if (Muc.Flag.get_flag(stream).is_occupant(presence.from)) {
+ if (stream.get_flag(Muc.Flag.IDENTITY).is_occupant(presence.from)) {
received_avatar(stream, presence.from, sha1);
} else {
received_avatar(stream, get_bare_jid(presence.from), sha1);
}
} else {
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("vCard", NS_URI).add_self_xmlns());
- if (Muc.Flag.get_flag(stream).is_occupant(presence.from)) {
+ if (stream.get_flag(Muc.Flag.IDENTITY).is_occupant(presence.from)) {
iq.to = presence.from;
} else {
iq.to = get_bare_jid(presence.from);
diff --git a/xmpp-vala/src/module/xep/0060_pubsub.vala b/xmpp-vala/src/module/xep/0060_pubsub.vala
index 9c2f4ebf..84b7fe9a 100644
--- a/xmpp-vala/src/module/xep/0060_pubsub.vala
+++ b/xmpp-vala/src/module/xep/0060_pubsub.vala
@@ -7,8 +7,7 @@ namespace Xmpp.Xep.Pubsub {
private const string NS_URI_EVENT = NS_URI + "#event";
public class Module : XmppStreamModule {
- public const string ID = "0060_pubsub_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0060_pubsub_module");
private HashMap<string, EventListenerDelegate> event_listeners = new HashMap<string, EventListenerDelegate>();
@@ -51,7 +50,7 @@ namespace Xmpp.Xep.Pubsub {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private void on_received_message(XmppStream stream, Message.Stanza message) {
StanzaNode event_node = message.stanza.get_subnode("event", NS_URI_EVENT); if (event_node == null) return;
diff --git a/xmpp-vala/src/module/xep/0084_user_avatars.vala b/xmpp-vala/src/module/xep/0084_user_avatars.vala
index 248620fa..fec46675 100644
--- a/xmpp-vala/src/module/xep/0084_user_avatars.vala
+++ b/xmpp-vala/src/module/xep/0084_user_avatars.vala
@@ -6,8 +6,7 @@ namespace Xmpp.Xep.UserAvatars {
private const string NS_URI_METADATA = NS_URI + ":metadata";
public class Module : XmppStreamModule {
- public const string ID = "0084_user_avatars";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0084_user_avatars");
public signal void received_avatar(XmppStream stream, string jid, string id);
@@ -58,7 +57,7 @@ namespace Xmpp.Xep.UserAvatars {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private static void on_pubsub_data_response(XmppStream stream, string jid, string? id, StanzaNode? node, Object? o) {
if (node == null) return;
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 6dbbb6f6..6212cade 100644
--- a/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala
+++ b/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala
@@ -14,8 +14,7 @@ public const string STATE_PAUSED = "paused";
private const string[] STATES = {STATE_ACTIVE, STATE_INACTIVE, STATE_GONE, STATE_COMPOSING, STATE_PAUSED};
public class Module : XmppStreamModule {
- public const string ID = "0085_chat_state_notifications";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0085_chat_state_notifications");
public signal void chat_state_received(XmppStream stream, string jid, string state);
@@ -47,7 +46,7 @@ public class Module : XmppStreamModule {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private void on_pre_send_message(XmppStream stream, Message.Stanza message) {
if (message.body == null) return;
diff --git a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
index 9387faaa..e1d6e6ff 100644
--- a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
+++ b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
@@ -6,8 +6,7 @@ namespace Xmpp.Xep.EntityCapabilities {
private const string NS_URI = "http://jabber.org/protocol/caps";
public class Module : XmppStreamModule {
- public const string ID = "0115_entity_capabilities";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0115_entity_capabilities");
private string own_ver_hash;
private Storage storage;
@@ -18,7 +17,7 @@ namespace Xmpp.Xep.EntityCapabilities {
private string get_own_hash(XmppStream stream) {
if (own_ver_hash == null) {
- own_ver_hash = compute_hash(stream.get_module(ServiceDiscovery.Module.IDENTITY).identities, ServiceDiscovery.Flag.get_flag(stream).features);
+ own_ver_hash = compute_hash(stream.get_module(ServiceDiscovery.Module.IDENTITY).identities, stream.get_flag(ServiceDiscovery.Flag.IDENTITY).features);
}
return own_ver_hash;
}
@@ -41,7 +40,7 @@ namespace Xmpp.Xep.EntityCapabilities {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private void on_pre_send_presence_stanza(XmppStream stream, Presence.Stanza presence) {
if (presence.type_ == Presence.Stanza.TYPE_AVAILABLE) {
@@ -60,7 +59,7 @@ namespace Xmpp.Xep.EntityCapabilities {
if (capabilities.size == 0) {
stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, presence.from, on_received_info_response, Tuple.create(storage, ver_attribute));
} else {
- ServiceDiscovery.Flag.get_flag(stream).set_entitiy_features(presence.from, capabilities);
+ stream.get_flag(ServiceDiscovery.Flag.IDENTITY).set_entitiy_features(presence.from, capabilities);
}
}
}
diff --git a/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala b/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala
index b8597d07..ed19f9a4 100644
--- a/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala
+++ b/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala
@@ -6,8 +6,7 @@ namespace Xmpp.Xep.MessageDeliveryReceipts {
private const string NS_URI = "urn:xmpp:receipts";
public class Module : XmppStreamModule {
- public const string ID = "0184_message_delivery_receipts";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0184_message_delivery_receipts");
public signal void receipt_received(XmppStream stream, string jid, string id);
@@ -30,7 +29,7 @@ namespace Xmpp.Xep.MessageDeliveryReceipts {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private void received_message(XmppStream stream, Message.Stanza message) {
StanzaNode? received_node = message.stanza.get_subnode("received", NS_URI);
diff --git a/xmpp-vala/src/module/xep/0199_ping.vala b/xmpp-vala/src/module/xep/0199_ping.vala
index 35cad26c..3b11bd73 100644
--- a/xmpp-vala/src/module/xep/0199_ping.vala
+++ b/xmpp-vala/src/module/xep/0199_ping.vala
@@ -6,8 +6,7 @@ namespace Xmpp.Xep.Ping {
private const string NS_URI = "urn:xmpp:ping";
public class Module : XmppStreamModule {
- public const string ID = "0199_ping";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0199_ping");
public void send_ping(XmppStream stream, string jid, ResponseListener listener) {
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("ping", NS_URI).add_self_xmlns());
@@ -27,7 +26,7 @@ namespace Xmpp.Xep.Ping {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private class IqHandlerImpl : Iq.Handler, Object {
public void on_iq_get(XmppStream stream, Iq.Stanza iq) {
diff --git a/xmpp-vala/src/module/xep/0203_delayed_delivery.vala b/xmpp-vala/src/module/xep/0203_delayed_delivery.vala
index 4dbe33ff..fe56abc2 100644
--- a/xmpp-vala/src/module/xep/0203_delayed_delivery.vala
+++ b/xmpp-vala/src/module/xep/0203_delayed_delivery.vala
@@ -4,8 +4,7 @@ namespace Xmpp.Xep.DelayedDelivery {
private const string NS_URI = "urn:xmpp:delay";
public class Module : XmppStreamModule {
- public const string ID = "0203_delayed_delivery";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0203_delayed_delivery");
public static void set_message_delay(Message.Stanza message, DateTime datetime) {
StanzaNode delay_node = (new StanzaNode.build("delay", NS_URI)).add_self_xmlns();
@@ -34,7 +33,7 @@ namespace Xmpp.Xep.DelayedDelivery {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private void on_pre_received_message(XmppStream stream, Message.Stanza message) {
DateTime? datetime = get_send_time(message);
diff --git a/xmpp-vala/src/module/xep/0280_message_carbons.vala b/xmpp-vala/src/module/xep/0280_message_carbons.vala
index 6f11ec05..58805a96 100644
--- a/xmpp-vala/src/module/xep/0280_message_carbons.vala
+++ b/xmpp-vala/src/module/xep/0280_message_carbons.vala
@@ -4,8 +4,7 @@ namespace Xmpp.Xep.MessageCarbons {
private const string NS_URI = "urn:xmpp:carbons:2";
public class Module : XmppStreamModule {
- public const string ID = "0280_message_carbons_module";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0280_message_carbons_module");
public void enable(XmppStream stream) {
Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("enable", NS_URI).add_self_xmlns());
@@ -38,7 +37,7 @@ namespace Xmpp.Xep.MessageCarbons {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private void pre_received_message(XmppStream stream, Message.Stanza message) {
StanzaNode? received_node = message.stanza.get_subnode("received", NS_URI);
@@ -51,7 +50,7 @@ namespace Xmpp.Xep.MessageCarbons {
string? from_attribute = message_node.get_attribute("from", Message.NS_URI);
// The security model assumed by this document is that all of the resources for a single user are in the same trust boundary.
// Any forwarded copies received by a Carbons-enabled client MUST be from that user's bare JID; any copies that do not meet this requirement MUST be ignored.
- if (from_attribute != null && from_attribute == get_bare_jid(Bind.Flag.get_flag(stream).my_jid)) {
+ if (from_attribute != null && from_attribute == get_bare_jid(stream.get_flag(Bind.Flag.IDENTITY).my_jid)) {
if (received_node != null) {
message.add_flag(new MessageFlag(MessageFlag.TYPE_RECEIVED));
} else if (sent_node != null) {
@@ -68,7 +67,7 @@ namespace Xmpp.Xep.MessageCarbons {
}
public class MessageFlag : Message.MessageFlag {
- public const string id = "message_carbons";
+ public const string ID = "message_carbons";
public const string TYPE_RECEIVED = "received";
public const string TYPE_SENT = "sent";
@@ -79,10 +78,10 @@ namespace Xmpp.Xep.MessageCarbons {
}
public static MessageFlag? get_flag(Message.Stanza message) {
- return (MessageFlag) message.get_flag(NS_URI, id);
+ return (MessageFlag) message.get_flag(NS_URI, ID);
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return id; }
+ public override string get_id() { return ID; }
}
}
diff --git a/xmpp-vala/src/module/xep/0333_chat_markers.vala b/xmpp-vala/src/module/xep/0333_chat_markers.vala
index 46fb92fa..7ac70806 100644
--- a/xmpp-vala/src/module/xep/0333_chat_markers.vala
+++ b/xmpp-vala/src/module/xep/0333_chat_markers.vala
@@ -12,8 +12,7 @@ public const string MARKER_ACKNOWLEDGED = "acknowledged";
private const string[] MARKERS = {MARKER_RECEIVED, MARKER_DISPLAYED, MARKER_ACKNOWLEDGED};
public class Module : XmppStreamModule {
- public const string ID = "0333_chat_markers";
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID);
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0333_chat_markers");
public signal void marker_received(XmppStream stream, string jid, string marker, string id);
@@ -50,7 +49,7 @@ public class Module : XmppStreamModule {
}
public override string get_ns() { return NS_URI; }
- public override string get_id() { return ID; }
+ public override string get_id() { return IDENTITY.id; }
private void on_received_message(XmppStream stream, Message.Stanza message) {
if (message.type_ != Message.Stanza.TYPE_CHAT) return;