aboutsummaryrefslogtreecommitdiff
path: root/libdino/src
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-10-31 15:19:30 +0100
committerfiaxh <fiaxh@users.noreply.github.com>2017-10-31 15:40:42 +0100
commit7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac (patch)
treeeda4f733870ded0eb6ccd8b4b8967d88c6960683 /libdino/src
parenta8d06e634bf0b5b18c7bffaf05c7293bcd29b056 (diff)
downloaddino-7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac.tar.gz
dino-7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac.zip
Blocking setting in Contact Details
Diffstat (limited to 'libdino/src')
-rw-r--r--libdino/src/application.vala1
-rw-r--r--libdino/src/service/blocking_manager.vala44
2 files changed, 45 insertions, 0 deletions
diff --git a/libdino/src/application.vala b/libdino/src/application.vala
index c18b28f9..c9283127 100644
--- a/libdino/src/application.vala
+++ b/libdino/src/application.vala
@@ -31,6 +31,7 @@ public interface Dino.Application : GLib.Application {
MessageStorage.start(stream_interactor, db);
CounterpartInteractionManager.start(stream_interactor);
PresenceManager.start(stream_interactor);
+ BlockingManager.start(stream_interactor);
MucManager.start(stream_interactor);
RosterManager.start(stream_interactor, db);
ConversationManager.start(stream_interactor, db);
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<BlockingManager> IDENTITY = new ModuleIdentity<BlockingManager>("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<string>.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<string>.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);
+ }
+}
+
+}