aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/presence/flag.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2018-01-12 21:03:09 +0100
committerfiaxh <git@mx.ax.lt>2018-01-28 00:38:47 +0100
commit782ae4c049e2b6fab13d7453cbb0e74610e7d200 (patch)
tree1b4cd0a1689cee0c2e2cac2ae9a5fb8ebbe63621 /xmpp-vala/src/module/presence/flag.vala
parentd46d071e57e599e8cfb1780597cbecb36881c4d8 (diff)
downloaddino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.tar.gz
dino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.zip
Move Jid class to xmpp-vala, partially refactor namespace
Diffstat (limited to 'xmpp-vala/src/module/presence/flag.vala')
-rw-r--r--xmpp-vala/src/module/presence/flag.vala48
1 files changed, 24 insertions, 24 deletions
diff --git a/xmpp-vala/src/module/presence/flag.vala b/xmpp-vala/src/module/presence/flag.vala
index 8fb44e13..bb3562a4 100644
--- a/xmpp-vala/src/module/presence/flag.vala
+++ b/xmpp-vala/src/module/presence/flag.vala
@@ -1,60 +1,60 @@
using Gee;
-using Xmpp.Core;
-
namespace Xmpp.Presence {
public class Flag : XmppStreamFlag {
public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "presence");
- private HashMap<string, ConcurrentList<string>> resources = new HashMap<string, ConcurrentList<string>>();
- private HashMap<string, Presence.Stanza> presences = new HashMap<string, Presence.Stanza>();
+ private HashMap<Jid, Gee.List<Jid>> resources = new HashMap<Jid, Gee.List<Jid>>(Jid.hash_bare_func, Jid.equals_bare_func);
+ private HashMap<Jid, Presence.Stanza> presences = new HashMap<Jid, Presence.Stanza>(Jid.hash_func, Jid.equals_func);
- public Set<string> get_available_jids() {
+ public Set<Jid> get_available_jids() {
return resources.keys;
}
- public Gee.List<string>? get_resources(string bare_jid) {
- return resources[bare_jid];
+ public Gee.List<Jid>? get_resources(Jid jid) {
+ return resources[jid];
}
- public Presence.Stanza? get_presence(string full_jid) {
+ public Presence.Stanza? get_presence(Jid full_jid) {
return presences[full_jid];
}
public void add_presence(Presence.Stanza presence) {
- string bare_jid = get_bare_jid(presence.from);
- if (!resources.has_key(bare_jid)) {
- resources[bare_jid] = new ConcurrentList<string>();
+ if (!resources.has_key(presence.from)) {
+ resources[presence.from] = new ArrayList<Jid>(Jid.equals_func);
}
- if (resources[bare_jid].contains(presence.from)) {
- resources[bare_jid].remove(presence.from);
+ if (resources[presence.from].contains(presence.from)) {
+ resources[presence.from].remove(presence.from);
}
- resources[bare_jid].add(presence.from);
+ resources[presence.from].add(presence.from);
presences[presence.from] = presence;
}
- public void remove_presence(string jid) {
- string bare_jid = get_bare_jid(jid);
- if (resources.has_key(bare_jid)) {
- if (is_bare_jid(jid)) {
- foreach (string full_jid in resources[jid]) {
+ public void remove_presence(Jid jid) {
+ if (resources.has_key(jid)) {
+ if (jid.is_bare()) {
+ foreach (Jid full_jid in resources[jid]) {
presences.unset(full_jid);
}
resources.unset(jid);
} else {
- resources[bare_jid].remove(jid);
- if (resources[bare_jid].size == 0) {
- resources.unset(bare_jid);
+ resources[jid].remove(jid);
+ if (resources[jid].size == 0) {
+ resources.unset(jid);
}
presences.unset(jid);
}
}
}
- public override string get_ns() { return NS_URI; }
+ public override string get_ns() {
+ return NS_URI;
+ }
- public override string get_id() { return IDENTITY.id; }
+ public override string get_id() {
+ return IDENTITY.id;
+ }
}
} \ No newline at end of file