From db57a973534f099af2b150f1a1307d1948553d9f Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 19 Mar 2017 12:55:36 +0100 Subject: Add typed identity to manager modules and stream flags --- .../src/module/xep/0030_service_discovery/flag.vala | 8 ++------ .../src/module/xep/0030_service_discovery/module.vala | 11 +++++------ xmpp-vala/src/module/xep/0045_muc/flag.vala | 8 ++------ xmpp-vala/src/module/xep/0045_muc/module.vala | 17 ++++++++--------- xmpp-vala/src/module/xep/0048_bookmarks/module.vala | 5 ++--- xmpp-vala/src/module/xep/0049_private_xml_storage.vala | 5 ++--- xmpp-vala/src/module/xep/0054_vcard/module.vala | 9 ++++----- xmpp-vala/src/module/xep/0060_pubsub.vala | 5 ++--- xmpp-vala/src/module/xep/0084_user_avatars.vala | 5 ++--- .../src/module/xep/0085_chat_state_notifications.vala | 5 ++--- xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala | 9 ++++----- .../src/module/xep/0184_message_delivery_receipts.vala | 5 ++--- xmpp-vala/src/module/xep/0199_ping.vala | 5 ++--- xmpp-vala/src/module/xep/0203_delayed_delivery.vala | 5 ++--- xmpp-vala/src/module/xep/0280_message_carbons.vala | 13 ++++++------- xmpp-vala/src/module/xep/0333_chat_markers.vala | 5 ++--- 16 files changed, 49 insertions(+), 71 deletions(-) (limited to 'xmpp-vala/src/module/xep') 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 IDENTITY = new FlagIdentity(NS_URI, "service_discovery"); private HashMap> entity_features = new HashMap>(); public ArrayList features = new ArrayList(); @@ -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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, "0030_service_discovery_module"); public ArrayList identities = new ArrayList(); @@ -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 tuple = o as Tuple; 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 IDENTITY = new FlagIdentity(NS_URI, "muc"); private HashMap enter_listeners = new HashMap(); private HashMap enter_ids = new HashMap(); @@ -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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, "0048_bookmarks_module"); public signal void conferences_updated(XmppStream stream, ArrayList 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 get_conferences_from_stanza(StanzaNode node) { ArrayList conferences = new ArrayList(); 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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(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 tuple = o as Tuple; 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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, "0060_pubsub_module"); private HashMap event_listeners = new HashMap(); @@ -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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(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 IDENTITY = new ModuleIdentity(NS_URI, ID); + public static ModuleIdentity IDENTITY = new ModuleIdentity(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; -- cgit v1.2.3-70-g09d2