diff options
author | Marvin W <git@larma.de> | 2018-01-12 21:03:09 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2018-01-28 00:38:47 +0100 |
commit | 782ae4c049e2b6fab13d7453cbb0e74610e7d200 (patch) | |
tree | 1b4cd0a1689cee0c2e2cac2ae9a5fb8ebbe63621 /libdino/src/service/presence_manager.vala | |
parent | d46d071e57e599e8cfb1780597cbecb36881c4d8 (diff) | |
download | dino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.tar.gz dino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.zip |
Move Jid class to xmpp-vala, partially refactor namespace
Diffstat (limited to 'libdino/src/service/presence_manager.vala')
-rw-r--r-- | libdino/src/service/presence_manager.vala | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/libdino/src/service/presence_manager.vala b/libdino/src/service/presence_manager.vala index e3ece45f..0525100b 100644 --- a/libdino/src/service/presence_manager.vala +++ b/libdino/src/service/presence_manager.vala @@ -27,9 +27,9 @@ public class PresenceManager : StreamInteractionModule, Object { } public Show get_last_show(Jid jid, Account account) { - Core.XmppStream? stream = stream_interactor.get_stream(account); + XmppStream? stream = stream_interactor.get_stream(account); if (stream != null) { - Xmpp.Presence.Stanza? presence = stream.get_flag(Presence.Flag.IDENTITY).get_presence(jid.to_string()); + Xmpp.Presence.Stanza? presence = stream.get_flag(Presence.Flag.IDENTITY).get_presence(jid); if (presence != null) { return new Show(jid, presence.show, new DateTime.now_utc()); } @@ -41,20 +41,12 @@ public class PresenceManager : StreamInteractionModule, Object { return shows[jid]; } - public ArrayList<Jid>? get_full_jids(Jid jid, Account account) { - Core.XmppStream? stream = stream_interactor.get_stream(account); + public Gee.List<Jid>? get_full_jids(Jid jid, Account account) { + XmppStream? stream = stream_interactor.get_stream(account); if (stream != null) { Xmpp.Presence.Flag flag = stream.get_flag(Presence.Flag.IDENTITY); if (flag == null) return null; - Gee.List<string>? resources = flag.get_resources(jid.bare_jid.to_string()); - if (resources == null) { - return null; - } - ArrayList<Jid> ret = new ArrayList<Jid>(Jid.equals_func); - foreach (string resource in resources) { - ret.add(new Jid(resource)); - } - return ret; + return flag.get_resources(jid.bare_jid); } return null; } @@ -64,40 +56,39 @@ public class PresenceManager : StreamInteractionModule, Object { } 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()); + XmppStream stream = stream_interactor.get_stream(account); + if (stream != null) stream.get_module(Xmpp.Presence.Module.IDENTITY).request_subscription(stream, jid.bare_jid); } public void approve_subscription(Account account, Jid jid) { - Core.XmppStream stream = stream_interactor.get_stream(account); + 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()); + stream.get_module(Xmpp.Presence.Module.IDENTITY).approve_subscription(stream, jid.bare_jid); subscription_requests.remove(jid); } } public void deny_subscription(Account account, Jid jid) { - Core.XmppStream stream = stream_interactor.get_stream(account); + 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()); + stream.get_module(Xmpp.Presence.Module.IDENTITY).deny_subscription(stream, jid.bare_jid); subscription_requests.remove(jid); } } public void cancel_subscription(Account account, Jid jid) { - Core.XmppStream stream = stream_interactor.get_stream(account); - if (stream != null) stream.get_module(Xmpp.Presence.Module.IDENTITY).cancel_subscription(stream, jid.bare_jid.to_string()); + XmppStream stream = stream_interactor.get_stream(account); + if (stream != null) stream.get_module(Xmpp.Presence.Module.IDENTITY).cancel_subscription(stream, jid.bare_jid); } private void on_account_added(Account account) { stream_interactor.module_manager.get_module(account, Presence.Module.IDENTITY).received_available_show.connect((stream, jid, show) => - on_received_available_show(account, new Jid(jid), show) + on_received_available_show(account, jid, show) ); stream_interactor.module_manager.get_module(account, Presence.Module.IDENTITY).received_unavailable.connect((stream, presence) => - on_received_unavailable(account, new Jid(presence.from)) + on_received_unavailable(account, presence.from) ); - stream_interactor.module_manager.get_module(account, Presence.Module.IDENTITY).received_subscription_request.connect((stream, jid_str) => { - Jid jid = new Jid(jid_str); + stream_interactor.module_manager.get_module(account, Presence.Module.IDENTITY).received_subscription_request.connect((stream, jid) => { if (!subscription_requests.contains(jid)) { subscription_requests.add(jid); } |