aboutsummaryrefslogtreecommitdiff
path: root/vala-xmpp/src/module/xep/0030_service_discovery/flag.vala
blob: 5be9f2eb19821b6684994788ab7bec38a9a13e9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using Gee;

using Xmpp.Core;

namespace Xmpp.Xep.ServiceDiscovery {

public class Flag : XmppStreamFlag {
    public const string ID = "service_discovery";

    private HashMap<string, ArrayList<string>> entity_features = new HashMap<string, ArrayList<string>>();
    public ArrayList<string> features = new ArrayList<string>();

    public bool? has_entity_feature(string jid, string feature) {
        if (!entity_features.has_key(jid)) return null;
        return entity_features[jid].contains(feature);
    }

    public void set_entitiy_features(string jid, ArrayList<string> features) {
        entity_features[jid] = features;
    }

    public void add_own_feature(string feature) { features.add(feature); }

    public static Flag? get_flag(XmppStream stream) { return (Flag?) stream.get_flag(NS_URI, ID); }

    public static bool has_flag(XmppStream stream) { return get_flag(stream) != null; }

    public override string get_ns() { return NS_URI; }

    public override string get_id() { return ID; }
}

}