summaryrefslogtreecommitdiffstats
blob: be0cd6f0566e3b786fe984f9a65b38f97402dc4c (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * Copyright (c) 2015-2016 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#pragma once

#include <unordered_map>
#include <unordered_set>

#include <Swiften/Base/API.h>
#include <Swiften/Base/Tristate.h>
#include <Swiften/Elements/DiscoInfo.h>

namespace Swift {

class EntityCapsProvider;
class JID;
class PresenceOracle;

/**
 * @brief The FeatureOracle class enables direct feature support lookup for client features supported by Swiften.
 */
class SWIFTEN_API FeatureOracle {
    public:
        FeatureOracle(EntityCapsProvider* capsProvider, PresenceOracle* presenceOracle);

    public:
        Tristate isFileTransferSupported(const JID& jid);
        Tristate isMessageReceiptsSupported(const JID& jid);
        Tristate isMessageCorrectionSupported(const JID& jid);
        Tristate isWhiteboardSupported(const JID& jid);

        JID getMostAvailableClientForFileTrasfer(const JID& bareJID);

    private:
        /**
         * @brief getDiscoResultForJID returns a  shared reference to a DiscoInfo representing features supported by the jid.
         * @param jid The JID to return an std::unordered_map<std::string, Tristate> for.
         * @return std::unordered_map<std::string, Tristate>
         */
        std::unordered_map<std::string, Tristate> getFeaturesForJID(const JID& jid);

        Tristate isFeatureSupported(const std::unordered_map<std::string, Tristate>& supportedFeatures, const std::string& feature);

    private:
        EntityCapsProvider* capsProvider_;
        PresenceOracle* presenceOracle_;
};

}