diff options
author | fiaxh <git@mx.ax.lt> | 2017-12-14 02:01:55 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-12-30 13:10:06 +0100 |
commit | b4bb0912fc328bc44b13e190f59b347eb5d4310a (patch) | |
tree | a18f680f8349eb758dd54fd44321837bcd228545 /libdino/src/service | |
parent | f25fadde2d6c9492b9cafe2cddbcc7b966942e47 (diff) | |
download | dino-b4bb0912fc328bc44b13e190f59b347eb5d4310a.tar.gz dino-b4bb0912fc328bc44b13e190f59b347eb5d4310a.zip |
Show subscription request in conversation summary
Diffstat (limited to 'libdino/src/service')
-rw-r--r-- | libdino/src/service/presence_manager.vala | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/libdino/src/service/presence_manager.vala b/libdino/src/service/presence_manager.vala index 298fa234..7e74f125 100644 --- a/libdino/src/service/presence_manager.vala +++ b/libdino/src/service/presence_manager.vala @@ -14,6 +14,7 @@ public class PresenceManager : StreamInteractionModule, Object { private StreamInteractor stream_interactor; private HashMap<Jid, HashMap<Jid, ArrayList<Show>>> shows = new HashMap<Jid, HashMap<Jid, ArrayList<Show>>>(Jid.hash_bare_func, Jid.equals_bare_func); private HashMap<Jid, ArrayList<Jid>> resources = new HashMap<Jid, ArrayList<Jid>>(Jid.hash_bare_func, Jid.equals_bare_func); + private Gee.List<Jid> subscription_requests = new ArrayList<Jid>(Jid.equals_func); public static void start(StreamInteractor stream_interactor) { PresenceManager m = new PresenceManager(stream_interactor); @@ -59,6 +60,10 @@ public class PresenceManager : StreamInteractionModule, Object { return null; } + public bool exists_subscription_request(Account account, Jid jid) { + return subscription_requests.contains(jid); + } + public void request_subscription(Account account, Jid jid) { Core.XmppStream stream = stream_interactor.get_stream(account); if (stream != null) stream.get_module(Xmpp.Presence.Module.IDENTITY).request_subscription(stream, jid.bare_jid.to_string()); @@ -66,12 +71,18 @@ public class PresenceManager : StreamInteractionModule, Object { public void approve_subscription(Account account, Jid jid) { Core.XmppStream stream = stream_interactor.get_stream(account); - if (stream != null) stream.get_module(Xmpp.Presence.Module.IDENTITY).approve_subscription(stream, jid.bare_jid.to_string()); + if (stream != null) { + stream.get_module(Xmpp.Presence.Module.IDENTITY).approve_subscription(stream, jid.bare_jid.to_string()); + subscription_requests.remove(jid); + } } public void deny_subscription(Account account, Jid jid) { Core.XmppStream stream = stream_interactor.get_stream(account); - if (stream != null) stream.get_module(Xmpp.Presence.Module.IDENTITY).deny_subscription(stream, jid.bare_jid.to_string()); + if (stream != null) { + stream.get_module(Xmpp.Presence.Module.IDENTITY).deny_subscription(stream, jid.bare_jid.to_string()); + subscription_requests.remove(jid); + } } public void cancel_subscription(Account account, Jid jid) { @@ -86,9 +97,13 @@ public class PresenceManager : StreamInteractionModule, Object { stream_interactor.module_manager.get_module(account, Presence.Module.IDENTITY).received_unavailable.connect((stream, presence) => on_received_unavailable(account, new Jid(presence.from)) ); - stream_interactor.module_manager.get_module(account, Presence.Module.IDENTITY).received_subscription_request.connect((stream, jid) => - received_subscription_request(new Jid(jid), account) - ); + stream_interactor.module_manager.get_module(account, Presence.Module.IDENTITY).received_subscription_request.connect((stream, jid_str) => { + Jid jid = new Jid(jid_str); + if (!subscription_requests.contains(jid)) { + subscription_requests.add(jid); + } + received_subscription_request(jid, account); + }); } private void on_received_available_show(Account account, Jid jid, string show) { |