From 7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac Mon Sep 17 00:00:00 2001 From: fiaxh Date: Tue, 31 Oct 2017 15:19:30 +0100 Subject: Blocking setting in Contact Details --- libdino/src/service/blocking_manager.vala | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 libdino/src/service/blocking_manager.vala (limited to 'libdino/src/service') diff --git a/libdino/src/service/blocking_manager.vala b/libdino/src/service/blocking_manager.vala new file mode 100644 index 00000000..de79b4d4 --- /dev/null +++ b/libdino/src/service/blocking_manager.vala @@ -0,0 +1,44 @@ +using Gee; + +using Xmpp; +using Dino.Entities; + +namespace Dino { + +public class BlockingManager : StreamInteractionModule, Object { + public static ModuleIdentity IDENTITY = new ModuleIdentity("blocking_manager"); + public string id { get { return IDENTITY.id; } } + + private StreamInteractor stream_interactor; + + public static void start(StreamInteractor stream_interactor) { + BlockingManager m = new BlockingManager(stream_interactor); + stream_interactor.add_module(m); + } + + private BlockingManager(StreamInteractor stream_interactor) { + this.stream_interactor = stream_interactor; + } + + public bool is_blocked(Account account, Jid jid) { + Core.XmppStream stream = stream_interactor.get_stream(account); + return stream != null && stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).is_blocked(stream, jid.to_string()); + } + + public void block(Account account, Jid jid) { + Core.XmppStream stream = stream_interactor.get_stream(account); + stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).block(stream, new ArrayList.wrap(new string[] {jid.to_string()})); + } + + public void unblock(Account account, Jid jid) { + Core.XmppStream stream = stream_interactor.get_stream(account); + stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).unblock(stream, new ArrayList.wrap(new string[] {jid.to_string()})); + } + + public bool is_supported(Account account) { + Core.XmppStream stream = stream_interactor.get_stream(account); + return stream != null && stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).is_supported(stream); + } +} + +} -- cgit v1.2.3-70-g09d2