diff options
author | fiaxh <git@mx.ax.lt> | 2017-10-31 15:19:30 +0100 |
---|---|---|
committer | fiaxh <fiaxh@users.noreply.github.com> | 2017-10-31 15:40:42 +0100 |
commit | 7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac (patch) | |
tree | eda4f733870ded0eb6ccd8b4b8967d88c6960683 /xmpp-vala/src/module/xep | |
parent | a8d06e634bf0b5b18c7bffaf05c7293bcd29b056 (diff) | |
download | dino-7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac.tar.gz dino-7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac.zip |
Blocking setting in Contact Details
Diffstat (limited to 'xmpp-vala/src/module/xep')
-rw-r--r-- | xmpp-vala/src/module/xep/0191_blocking_command.vala | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/xmpp-vala/src/module/xep/0191_blocking_command.vala b/xmpp-vala/src/module/xep/0191_blocking_command.vala index c970955d..53d7bb7b 100644 --- a/xmpp-vala/src/module/xep/0191_blocking_command.vala +++ b/xmpp-vala/src/module/xep/0191_blocking_command.vala @@ -14,13 +14,15 @@ public class Module : XmppStreamModule, Iq.Handler { public signal void unblock_all_received(XmppStream stream); public bool is_blocked(XmppStream stream, string jid) { - return stream.get_flag(Flag.IDENTITY).blocklist.contains(jid); + foreach (string blocked in stream.get_flag(Flag.IDENTITY).blocklist) { + if (blocked.contains(jid)) return true; + } + return false; } public bool block(XmppStream stream, Gee.List<string> jids) { - // This would otherwise be a bad-request error. - if (jids.size == 0) - return false; + if (jids.size == 0) return false; // This would otherwise be a bad-request error. + StanzaNode block_node = new StanzaNode.build("block", NS_URI).add_self_xmlns(); fill_node_with_items(block_node, jids); Iq.Stanza iq = new Iq.Stanza.set(block_node); @@ -29,9 +31,8 @@ public class Module : XmppStreamModule, Iq.Handler { } public bool unblock(XmppStream stream, Gee.List<string> jids) { - // This would otherwise unblock all blocked JIDs. - if (jids.size == 0) - return false; + if (jids.size == 0) return false; // This would otherwise unblock all blocked JIDs. + StanzaNode unblock_node = new StanzaNode.build("unblock", NS_URI).add_self_xmlns(); fill_node_with_items(unblock_node, jids); Iq.Stanza iq = new Iq.Stanza.set(unblock_node); @@ -45,6 +46,10 @@ public class Module : XmppStreamModule, Iq.Handler { stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, null); } + public bool is_supported(XmppStream stream) { + return stream.has_flag(Flag.IDENTITY); + } + private void on_iq_get(XmppStream stream, Iq.Stanza iq) { } private void on_iq_set(XmppStream stream, Iq.Stanza iq) { StanzaNode? block_node = iq.stanza.get_subnode("block", NS_URI); @@ -81,7 +86,7 @@ public class Module : XmppStreamModule, Iq.Handler { public override string get_id() { return IDENTITY.id; } private void on_stream_negotiated(XmppStream stream) { - stream.get_module(Xep.ServiceDiscovery.Module.IDENTITY).request_info(stream, "jabberfr.org", (stream, info_result) => { + stream.get_module(Xep.ServiceDiscovery.Module.IDENTITY).request_info(stream, stream.remote_name, (stream, info_result) => { if (info_result.features.contains(NS_URI)) { stream.add_flag(new Flag()); get_blocklist(stream, (stream, jids) => { @@ -110,8 +115,9 @@ public class Module : XmppStreamModule, Iq.Handler { Gee.List<string> jids = new ArrayList<string>(); foreach (StanzaNode item_node in item_nodes) { string? jid = item_node.get_attribute("jid", NS_URI); - if (jid != null) + if (jid != null) { jids.add(jid); + } } return jids; } |